svn commit: r367908 - head/sys/powerpc/powerpc

2020-11-20 Thread Alfredo Dal7;Ava Junior
Author: alfredo
Date: Fri Nov 20 18:52:37 2020
New Revision: 367908
URL: https://svnweb.freebsd.org/changeset/base/367908

Log:
  [POWERPC] print uprintf_signal 'type' field in hex
  
  Print 'type' field in hex to improve readability
  
  Reviewed by:  jhibbits
  Differential Revision:https://reviews.freebsd.org/D27294

Modified:
  head/sys/powerpc/powerpc/trap.c

Modified: head/sys/powerpc/powerpc/trap.c
==
--- head/sys/powerpc/powerpc/trap.c Fri Nov 20 18:42:01 2020
(r367907)
+++ head/sys/powerpc/powerpc/trap.c Fri Nov 20 18:52:37 2020
(r367908)
@@ -503,7 +503,7 @@ trap(struct trapframe *frame)
ksi.ksi_addr = (void *)addr;
ksi.ksi_trapno = type;
if (uprintf_signal) {
-   uprintf("pid %d comm %s: signal %d code %d type %d "
+   uprintf("pid %d comm %s: signal %d code %d type 0x%x "
"addr 0x%lx r1 0x%lx srr0 0x%lx srr1 0x%lx\n",
p->p_pid, p->p_comm, sig, ucode, type,
(u_long)addr, (u_long)frame->fixreg[1],
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r367907 - head

2020-11-20 Thread Alfredo Dal7;Ava Junior
Author: alfredo
Date: Fri Nov 20 18:42:01 2020
New Revision: 367907
URL: https://svnweb.freebsd.org/changeset/base/367907

Log:
  [POWERPC64LE,POWEPCSPE] set default kernel config for powerpc64le and 
powerpcspe variants
  
  Default KERNCONF for powerpc64le should be GENERIC64, and powerpcspe should
  select MPC85XXSPE
  
  Reviewed by:  bdragon,emaste
  Sponsored by: Eldorado Research Institute (eldorado.org.br)
  Differential Revision:https://reviews.freebsd.org/D27257

Modified:
  head/Makefile.inc1

Modified: head/Makefile.inc1
==
--- head/Makefile.inc1  Fri Nov 20 18:02:04 2020(r367906)
+++ head/Makefile.inc1  Fri Nov 20 18:42:01 2020(r367907)
@@ -1591,6 +1591,10 @@ KERNCONF=${KERNFAST}
 .endif
 .if ${TARGET_ARCH} == "powerpc64"
 KERNCONF?= GENERIC64
+.elif ${TARGET_ARCH} == "powerpc64le"
+KERNCONF?= GENERIC64LE
+.elif ${TARGET_ARCH} == "powerpcspe"
+KERNCONF?= MPC85XXSPE
 .else
 KERNCONF?= GENERIC
 .endif
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r367811 - head/lib/msun/tests

2020-11-18 Thread Alfredo Dal7;Ava Junior
Author: alfredo
Date: Wed Nov 18 19:23:30 2020
New Revision: 367811
URL: https://svnweb.freebsd.org/changeset/base/367811

Log:
  msun tests: use standard floating-point exception flags on lrint and fenv 
tests
  
  Some platforms have additional architecture-specific floating-point flags.
  Msun test cases lrint and test_fegsetenv (fenv) expects only standard flags,
  so make sure to mask them appropriately.
  
  This makes test pass on PowerPC64.
  
  Reviewed by:  jhibbits, ngie
  Sponsored by: Eldorado Research Institute (eldorado.org.br)
  Differential Revision:https://reviews.freebsd.org/D27202

Modified:
  head/lib/msun/tests/fenv_test.c
  head/lib/msun/tests/lrint_test.c

Modified: head/lib/msun/tests/fenv_test.c
==
--- head/lib/msun/tests/fenv_test.c Wed Nov 18 19:22:24 2020
(r367810)
+++ head/lib/msun/tests/fenv_test.c Wed Nov 18 19:23:30 2020
(r367811)
@@ -43,13 +43,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
-/*
- * Implementations are permitted to define additional exception flags
- * not specified in the standard, so it is not necessarily true that
- * FE_ALL_EXCEPT == ALL_STD_EXCEPT.
- */
-#defineALL_STD_EXCEPT  (FE_DIVBYZERO | FE_INEXACT | FE_INVALID | \
-FE_OVERFLOW | FE_UNDERFLOW)
+#include "test-utils.h"
 
 #defineNEXCEPTS(sizeof(std_excepts) / sizeof(std_excepts[0]))
 
@@ -373,7 +367,13 @@ test_fegsetenv(void)
assert(fegetround() == FE_TONEAREST);
 
assert(fesetenv(&env2) == 0);
-   assert(fetestexcept(FE_ALL_EXCEPT) == excepts);
+
+   /* 
+* Some platforms like powerpc may set extra exception bits. 
Since
+* only standard exceptions are tested, mask against 
ALL_STD_EXCEPT 
+*/
+   assert((fetestexcept(FE_ALL_EXCEPT) & ALL_STD_EXCEPT) == 
excepts);
+
assert(fegetround() == FE_DOWNWARD);
assert(fesetenv(&env1) == 0);
assert(fetestexcept(FE_ALL_EXCEPT) == 0);

Modified: head/lib/msun/tests/lrint_test.c
==
--- head/lib/msun/tests/lrint_test.cWed Nov 18 19:22:24 2020
(r367810)
+++ head/lib/msun/tests/lrint_test.cWed Nov 18 19:23:30 2020
(r367811)
@@ -41,6 +41,8 @@ __FBSDID("$FreeBSD$");
 #include 
 #endif
 
+#include "test-utils.h"
+
 /*
  * XXX The volatile here is to avoid gcc's bogus constant folding and work
  * around the lack of support for the FENV_ACCESS pragma.
@@ -49,7 +51,8 @@ __FBSDID("$FreeBSD$");
volatile double _d = x; \
assert(feclearexcept(FE_ALL_EXCEPT) == 0);  \
assert((func)(_d) == (result) || fetestexcept(FE_INVALID)); \
-   assert(fetestexcept(FE_ALL_EXCEPT) == (excepts));   \
+   assert((fetestexcept(FE_ALL_EXCEPT) & ALL_STD_EXCEPT)   \
+   == (excepts));  \
 } while (0)
 
 #definetestall(x, result, excepts) do {
\
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r367761 - head/lib/msun/powerpc

2020-11-17 Thread Alfredo Dal7;Ava Junior
Author: alfredo
Date: Tue Nov 17 12:36:59 2020
New Revision: 367761
URL: https://svnweb.freebsd.org/changeset/base/367761

Log:
  [POWERPC] msun: fix incorrect flag in fesetexceptflag
  
  Fix incorrect mask being used when FE_INVALID bit is wanted by user.
  The problem was noticed thanks to msun fenv tests.
  
  Reviewed by:  jhibbits, luporl
  Sponsored by: Eldorado Research Institute (eldorado.org.br)
  Differential Revision:https://reviews.freebsd.org/D27201

Modified:
  head/lib/msun/powerpc/fenv.h

Modified: head/lib/msun/powerpc/fenv.h
==
--- head/lib/msun/powerpc/fenv.hTue Nov 17 12:33:12 2020
(r367760)
+++ head/lib/msun/powerpc/fenv.hTue Nov 17 12:36:59 2020
(r367761)
@@ -148,7 +148,7 @@ fesetexceptflag(const fexcept_t *__flagp, int __except
union __fpscr __r;
 
if (__excepts & FE_INVALID)
-   __excepts |= FE_ALL_EXCEPT;
+   __excepts |= FE_ALL_INVALID;
__mffs(&__r);
__r.__bits.__reg &= ~__excepts;
__r.__bits.__reg |= *__flagp & __excepts;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r367760 - head/sys/powerpc/powerpc

2020-11-17 Thread Alfredo Dal7;Ava Junior
Author: alfredo
Date: Tue Nov 17 12:33:12 2020
New Revision: 367760
URL: https://svnweb.freebsd.org/changeset/base/367760

Log:
  [POWERPC] fix signal race condition
  
  r367416 should have called save_fpu() before kern_sigprocmask to avoid
  race condition
  
  Thanks jhibbits and bdragon for pointing it out
  
  Reviewed by:  jhibbits
  Sponsored by: Eldorado Research Institute (eldorado.org.br)
  Differential Revision:https://reviews.freebsd.org/D27241

Modified:
  head/sys/powerpc/powerpc/exec_machdep.c

Modified: head/sys/powerpc/powerpc/exec_machdep.c
==
--- head/sys/powerpc/powerpc/exec_machdep.c Tue Nov 17 12:04:29 2020
(r367759)
+++ head/sys/powerpc/powerpc/exec_machdep.c Tue Nov 17 12:33:12 2020
(r367760)
@@ -334,8 +334,6 @@ sys_sigreturn(struct thread *td, struct sigreturn_args
if (error != 0)
return (error);
 
-   kern_sigprocmask(td, SIG_SETMASK, &uc.uc_sigmask, NULL, 0);
-
/* 
 * Save FPU state if needed. User may have changed it on
 * signal handler 
@@ -343,6 +341,8 @@ sys_sigreturn(struct thread *td, struct sigreturn_args
if (uc.uc_mcontext.mc_srr1 & PSL_FP)
save_fpu(td);
 
+   kern_sigprocmask(td, SIG_SETMASK, &uc.uc_sigmask, NULL, 0);
+
CTR3(KTR_SIG, "sigreturn: return td=%p pc=%#x sp=%#x",
 td, uc.uc_mcontext.mc_srr0, uc.uc_mcontext.mc_gpr[1]);
 
@@ -836,8 +836,6 @@ freebsd32_sigreturn(struct thread *td, struct freebsd3
if (error != 0)
return (error);
 
-   kern_sigprocmask(td, SIG_SETMASK, &uc.uc_sigmask, NULL, 0);
-
/*
 * Save FPU state if needed. User may have changed it on
 * signal handler
@@ -845,6 +843,7 @@ freebsd32_sigreturn(struct thread *td, struct freebsd3
if (uc.uc_mcontext.mc_srr1 & PSL_FP)
save_fpu(td);
 
+   kern_sigprocmask(td, SIG_SETMASK, &uc.uc_sigmask, NULL, 0);
 
CTR3(KTR_SIG, "sigreturn: return td=%p pc=%#x sp=%#x",
 td, uc.uc_mcontext.mc_srr0, uc.uc_mcontext.mc_gpr[1]);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r367416 - in head/sys/powerpc: include powerpc

2020-11-06 Thread Alfredo Dal7;Ava Junior
Author: alfredo
Date: Fri Nov  6 13:34:30 2020
New Revision: 367416
URL: https://svnweb.freebsd.org/changeset/base/367416

Log:
  [POWERPC] Floating-Point Exception trap support
  
  Add support for Floating-Point Exception traps on 32 and 64 bit platforms.
  Also make sure to clean FPSCR on EXEC and thread exit
  
  Author of initial version: Renato Riolino 
  
  Reviewed by:  jhibbits
  Sponsored by: Eldorado Research Institute (eldorado.org.br)
  Differential Revision:https://reviews.freebsd.org/D23623

Modified:
  head/sys/powerpc/include/cpufunc.h
  head/sys/powerpc/include/fpu.h
  head/sys/powerpc/include/psl.h
  head/sys/powerpc/powerpc/exec_machdep.c
  head/sys/powerpc/powerpc/fpu.c
  head/sys/powerpc/powerpc/trap.c

Modified: head/sys/powerpc/include/cpufunc.h
==
--- head/sys/powerpc/include/cpufunc.h  Fri Nov  6 07:16:21 2020
(r367415)
+++ head/sys/powerpc/include/cpufunc.h  Fri Nov  6 13:34:30 2020
(r367416)
@@ -163,6 +163,25 @@ mttb(u_quad_t time)
mtspr(TBR_TBWL, (uint32_t)(time & 0x));
 }
 
+
+static __inline register_t
+mffs(void)
+{
+   register_t value;
+
+   __asm __volatile ("mffs 0; stfd 0,0(%0)"
+   :: "b"(&value));
+
+   return (value);
+}
+
+static __inline void
+mtfsf(register_t value)
+{
+   __asm __volatile ("lfd 0,0(%0); mtfsf 0xff,0"
+   :: "b"(&value));
+}
+
 static __inline void
 eieio(void)
 {

Modified: head/sys/powerpc/include/fpu.h
==
--- head/sys/powerpc/include/fpu.h  Fri Nov  6 07:16:21 2020
(r367415)
+++ head/sys/powerpc/include/fpu.h  Fri Nov  6 13:34:30 2020
(r367416)
@@ -75,6 +75,8 @@
 voidenable_fpu(struct thread *);
 voidsave_fpu(struct thread *);
 voidsave_fpu_nodrop(struct thread *);
+voidcleanup_fpscr(void);
+u_int   get_fpu_exception(struct thread *);
 
 #endif /* _KERNEL */
 

Modified: head/sys/powerpc/include/psl.h
==
--- head/sys/powerpc/include/psl.h  Fri Nov  6 07:16:21 2020
(r367415)
+++ head/sys/powerpc/include/psl.h  Fri Nov  6 13:34:30 2020
(r367416)
@@ -88,7 +88,7 @@
 #definePSL_FE_NONREC   PSL_FE1 /* imprecise non-recoverable */
 #definePSL_FE_REC  PSL_FE0 /* imprecise recoverable */
 #definePSL_FE_PREC (PSL_FE0 | PSL_FE1) /* precise */
-#definePSL_FE_DFLT PSL_FE_DIS  /* default == none */
+#definePSL_FE_DFLT PSL_FE_PREC /* default == precise */
 
 #ifndef LOCORE
 extern register_t psl_kernset; /* Default MSR values for kernel */

Modified: head/sys/powerpc/powerpc/exec_machdep.c
==
--- head/sys/powerpc/powerpc/exec_machdep.c Fri Nov  6 07:16:21 2020
(r367415)
+++ head/sys/powerpc/powerpc/exec_machdep.c Fri Nov  6 13:34:30 2020
(r367416)
@@ -239,11 +239,14 @@ sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask
usfp = (void *)((sp - rndfsize) & ~0xFul);
}
 
-   /*
-* Save the floating-point state, if necessary, then copy it.
+   /* 
+* Set Floating Point facility to "Ignore Exceptions Mode" so signal
+* handler can run. 
 */
-   /* XXX */
+   if (td->td_pcb->pcb_flags & PCB_FPU)
+   tf->srr1 = tf->srr1 & ~(PSL_FE0 | PSL_FE1);
 
+
/*
 * Set up the registers to return to sigcode.
 *
@@ -333,6 +336,13 @@ sys_sigreturn(struct thread *td, struct sigreturn_args
 
kern_sigprocmask(td, SIG_SETMASK, &uc.uc_sigmask, NULL, 0);
 
+   /* 
+* Save FPU state if needed. User may have changed it on
+* signal handler 
+*/ 
+   if (uc.uc_mcontext.mc_srr1 & PSL_FP)
+   save_fpu(td);
+
CTR3(KTR_SIG, "sigreturn: return td=%p pc=%#x sp=%#x",
 td, uc.uc_mcontext.mc_srr0, uc.uc_mcontext.mc_gpr[1]);
 
@@ -556,6 +566,8 @@ cleanup_power_extras(struct thread *td)
mtspr(SPR_FSCR, 0);
if (pcb_flags & PCB_CDSCR) 
mtspr(SPR_DSCRP, 0);
+
+   cleanup_fpscr();
 }
 
 /*
@@ -825,6 +837,14 @@ freebsd32_sigreturn(struct thread *td, struct freebsd3
return (error);
 
kern_sigprocmask(td, SIG_SETMASK, &uc.uc_sigmask, NULL, 0);
+
+   /*
+* Save FPU state if needed. User may have changed it on
+* signal handler
+*/
+   if (uc.uc_mcontext.mc_srr1 & PSL_FP)
+   save_fpu(td);
+
 
CTR3(KTR_SIG, "sigreturn: return td=%p pc=%#x sp=%#x",
 td, uc.uc_mcontext.mc_srr0, uc.uc_mcontext.mc_gpr[1]);

Modified: head/sys/powerpc/powerpc/fpu.c
==
--- head/sys/pow

svn commit: r366548 - head/sys/powerpc/powerpc

2020-10-08 Thread Alfredo Dal7;Ava Junior
Author: alfredo
Date: Thu Oct  8 22:00:31 2020
New Revision: 366548
URL: https://svnweb.freebsd.org/changeset/base/366548

Log:
  [PowerPC] add machdep.uprintf_signal sysctl
  
  Add support for sysctl 'machdep.uprintf_signal' that prints debugging
  information on trap signal.
  
  Reviewed by:  jhibbits, luporl, bdragon
  Sponsored by: Eldorado Research Institute (eldorado.org.br)
  Differential Revision:https://reviews.freebsd.org/D26004

Modified:
  head/sys/powerpc/powerpc/trap.c

Modified: head/sys/powerpc/powerpc/trap.c
==
--- head/sys/powerpc/powerpc/trap.c Thu Oct  8 20:56:11 2020
(r366547)
+++ head/sys/powerpc/powerpc/trap.c Thu Oct  8 22:00:31 2020
(r366548)
@@ -153,6 +153,11 @@ static struct powerpc_exception powerpc_exceptions[] =
{ EXC_LAST, NULL }
 };
 
+static int uprintf_signal;
+SYSCTL_INT(_machdep, OID_AUTO, uprintf_signal, CTLFLAG_RWTUN,
+&uprintf_signal, 0,
+"Print debugging information on trap signal to ctty");
+
 #define ESR_BITMASK\
 "\20"  \
 "\040b0\037b1\036b2\035b3\034PIL\033PRR\032PTR\031FP"  \
@@ -489,6 +494,14 @@ trap(struct trapframe *frame)
ksi.ksi_code = (int) ucode; /* XXX, not POSIX */
ksi.ksi_addr = (void *)addr;
ksi.ksi_trapno = type;
+   if (uprintf_signal) {
+   uprintf("pid %d comm %s: signal %d code %d type %d "
+   "addr 0x%lx r1 0x%lx srr0 0x%lx srr1 0x%lx\n",
+   p->p_pid, p->p_comm, sig, ucode, type,
+   (u_long)addr, (u_long)frame->fixreg[1],
+   (u_long)frame->srr0, (u_long)frame->srr1);
+   }
+
trapsignal(td, &ksi);
}
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r363646 - head/sys/dev/virtio/pci

2020-07-28 Thread Alfredo Dal7;Ava Junior
Author: alfredo
Date: Tue Jul 28 11:23:37 2020
New Revision: 363646
URL: https://svnweb.freebsd.org/changeset/base/363646

Log:
  virtio: fix mips regression introduced by r357596
  
  PowerPC support was fixed in r357596 by changing PCI bustag to BE as
  part of the solution, but this caused regression on mips. This change
  implements byte swapping of virtio PCI config area in the driver,
  leaving lower layer untouched.
  
  Submittnd by: Fernando Valle 
  Reported by:  arichardson
  Reviewed by:  alfredo, arichardson
  Sponsored by: Eldorado Research Institute (eldorado.org.br)
  Differential Revision:https://reviews.freebsd.org/D25416

Modified:
  head/sys/dev/virtio/pci/virtio_pci.c

Modified: head/sys/dev/virtio/pci/virtio_pci.c
==
--- head/sys/dev/virtio/pci/virtio_pci.cTue Jul 28 11:13:37 2020
(r363645)
+++ head/sys/dev/virtio/pci/virtio_pci.cTue Jul 28 11:23:37 2020
(r363646)
@@ -179,23 +179,25 @@ static void   vtpci_config_intr(void *);
  * I/O port read/write wrappers.
  */
 #define vtpci_read_config_1(sc, o) bus_read_1((sc)->vtpci_res, (o))
-#define vtpci_read_config_2(sc, o) bus_read_2((sc)->vtpci_res, (o))
-#define vtpci_read_config_4(sc, o) bus_read_4((sc)->vtpci_res, (o))
 #define vtpci_write_config_1(sc, o, v) bus_write_1((sc)->vtpci_res, (o), (v))
-#define vtpci_write_config_2(sc, o, v) bus_write_2((sc)->vtpci_res, (o), (v))
-#define vtpci_write_config_4(sc, o, v) bus_write_4((sc)->vtpci_res, (o), (v))
 
 /*
- * Legacy VirtIO header is always PCI endianness (little), so if we
- * are in a BE machine we need to swap bytes from LE to BE when reading
- * and from BE to LE when writing.
- * If we are in a LE machine, there will be no swaps.
+ * Virtio-pci specifies that PCI Configuration area is guest endian. However,
+ * since PCI devices are inherently little-endian, on BE systems the bus layer
+ * transparently converts it to BE. For virtio-legacy, this conversion is
+ * undesired, so an extra byte swap is required to fix it.
  */
-#define vtpci_read_header_2(sc, o) le16toh(vtpci_read_config_2(sc, o))
-#define vtpci_read_header_4(sc, o) le32toh(vtpci_read_config_4(sc, o))
-#define vtpci_write_header_2(sc, o, v)  vtpci_write_config_2(sc, o, 
(htole16(v)))
-#define vtpci_write_header_4(sc, o, v)  vtpci_write_config_4(sc, o, 
(htole32(v)))
+#define vtpci_read_config_2(sc, o)  le16toh(bus_read_2((sc)->vtpci_res, 
(o)))
+#define vtpci_read_config_4(sc, o)  le32toh(bus_read_4((sc)->vtpci_res, 
(o)))
+#define vtpci_write_config_2(sc, o, v)  bus_write_2((sc)->vtpci_res, (o), 
(htole16(v)))
+#define vtpci_write_config_4(sc, o, v)  bus_write_4((sc)->vtpci_res, (o), 
(htole32(v)))
 
+/* PCI Header LE. On BE systems the bus layer takes care of byte swapping */
+#define vtpci_read_header_2(sc, o)  (bus_read_2((sc)->vtpci_res, (o)))
+#define vtpci_read_header_4(sc, o)  (bus_read_4((sc)->vtpci_res, (o)))
+#define vtpci_write_header_2(sc, o, v)  bus_write_2((sc)->vtpci_res, (o), (v))
+#define vtpci_write_header_4(sc, o, v)  bus_write_4((sc)->vtpci_res, (o), (v))
+
 /* Tunables. */
 static int vtpci_disable_msix = 0;
 TUNABLE_INT("hw.virtio.pci.disable_msix", &vtpci_disable_msix);
@@ -289,17 +291,6 @@ vtpci_attach(device_t dev)
device_printf(dev, "cannot map I/O space\n");
return (ENXIO);
}
-
-/*
- * For legacy VirtIO, the device-specific configuration is guest
- * endian, while the common configuration header is always
- * PCI (little) endian and will be handled specifically in
- * other parts of this file via functions
- * 'vtpci_[read|write]_header_[2|4]'
- */
-#if _BYTE_ORDER == _BIG_ENDIAN
-   rman_set_bustag(sc->vtpci_res, &bs_be_tag);
-#endif
 
if (pci_find_cap(dev, PCIY_MSI, NULL) != 0)
sc->vtpci_flags |= VTPCI_FLAG_NO_MSI;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r363020 - head/lib/libkvm/tests

2020-07-08 Thread Alfredo Dal7;Ava Junior
Author: alfredo
Date: Wed Jul  8 18:58:44 2020
New Revision: 363020
URL: https://svnweb.freebsd.org/changeset/base/363020

Log:
  test: add libkvm read test
  
  This test checks if value received from kvm_read is sane, based on
  value returned by sysctl interface.
  
  This should catch regression on bug fixed by r359160
  
  Reviewed by:  jhb
  Approved by:  jhibbits (mentor)
  MFC after:1 week
  Sponsored by: Eldorado Research Institute (eldorado.org.br)
  Differential Revision:https://reviews.freebsd.org/D23783

Added:
  head/lib/libkvm/tests/kvm_read_test.c   (contents, props changed)
Modified:
  head/lib/libkvm/tests/Makefile

Modified: head/lib/libkvm/tests/Makefile
==
--- head/lib/libkvm/tests/Makefile  Wed Jul  8 18:32:25 2020
(r363019)
+++ head/lib/libkvm/tests/Makefile  Wed Jul  8 18:58:44 2020
(r363020)
@@ -6,8 +6,10 @@ ATF_TESTS_C+=  kvm_close_test
 ATF_TESTS_C+=  kvm_geterr_test
 ATF_TESTS_C+=  kvm_open_test
 ATF_TESTS_C+=  kvm_open2_test
+ATF_TESTS_C+=  kvm_read_test
 
 CFLAGS.kvm_geterr_test+=   -I${.CURDIR:H}
+CFLAGS.kvm_read_test+= -I${.CURDIR:H}
 
 LIBADD+=   kvm
 
@@ -15,7 +17,7 @@ WARNS?=   6
 
 BINDIR=${TESTSDIR}
 
-.for t in kvm_geterr_test kvm_open_test kvm_open2_test
+.for t in kvm_geterr_test kvm_open_test kvm_open2_test kvm_read_test
 SRCS.$t=   $t.c kvm_test_common.c
 .endfor
 

Added: head/lib/libkvm/tests/kvm_read_test.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/lib/libkvm/tests/kvm_read_test.c   Wed Jul  8 18:58:44 2020
(r363020)
@@ -0,0 +1,98 @@
+/*-
+ * Copyright (c) 2020 Alfredo Dal'Ava Junior 
+ * Copyright (c) 2017 Enji Cooper 
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * From: FreeBSD: src/lib/libkvm/tests/kvm_geterr_test.c
+ */
+
+#include 
+__FBSDID("$FreeBSD$");
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include "kvm_test_common.h"
+
+ATF_TC(kvm_read_positive_test_no_error);
+ATF_TC_HEAD(kvm_read_positive_test_no_error, tc)
+{
+
+   atf_tc_set_md_var(tc, "descr",
+   "test that kvm_read returns a sane value");
+   atf_tc_set_md_var(tc, "require.user", "root");
+}
+
+ATF_TC_BODY(kvm_read_positive_test_no_error, tc)
+{
+   kvm_t *kd;
+   struct nlist nl[] = {
+#defineSYMNAME "_mp_maxcpus"
+#defineX_MAXCPUS   0
+   { SYMNAME, 0, 0, 0, 0 },
+   { NULL, 0, 0, 0, 0 },
+   };
+   ssize_t rc;
+   int sysctl_maxcpus, mp_maxcpus, retcode;
+   size_t len = sizeof(sysctl_maxcpus);
+
+   errbuf_clear();
+   kd = kvm_open(NULL, NULL, NULL, O_RDONLY, errbuf);
+   ATF_CHECK(!errbuf_has_error(errbuf));
+   ATF_REQUIRE_MSG(kd != NULL, "kvm_open failed: %s", errbuf);
+   retcode = kvm_nlist(kd, nl);
+   ATF_REQUIRE_MSG(retcode != -1,
+   "kvm_nlist failed (returned %d): %s", retcode, kvm_geterr(kd));
+   if (nl[X_MAXCPUS].n_type == 0)
+   atf_tc_skip("symbol (\"%s\") couldn't be found", SYMNAME);
+
+   rc = kvm_read(kd, nl[X_MAXCPUS].n_value, &mp_maxcpus,
+   sizeof(mp_maxcpus));
+
+   ATF_REQUIRE_MSG(rc != -1, "kvm_read failed: %s", kvm_geterr(kd));
+   ATF_REQUIRE_MSG(kvm_close(kd) == 0, "kvm_close failed: %s",
+   strerror(errno));
+
+   /* Check if value read from kv

svn commit: r359992 - head/sys/powerpc/aim

2020-04-15 Thread Alfredo Dal7;Ava Junior
Author: alfredo
Date: Wed Apr 15 20:33:09 2020
New Revision: 359992
URL: https://svnweb.freebsd.org/changeset/base/359992

Log:
  powerpc: autosize bpvo based on physical memory
  
  Default moea64_bpvo_pool_size 327680 was insufficient for initial
  memory mapping at boot time on systems with, for example, 64G and
  no huge pages enabled.
  
  Submitted by: Andre Silva 
  Reviewed by:  jhibbits, alfredo
  Approved by:  jhibbits (mentor)
  Sponsored by: Eldorado Research Institute (eldorado.org.br)
  Differential Revision:https://reviews.freebsd.org/D24102

Modified:
  head/sys/powerpc/aim/mmu_oea64.c

Modified: head/sys/powerpc/aim/mmu_oea64.c
==
--- head/sys/powerpc/aim/mmu_oea64.cWed Apr 15 20:28:20 2020
(r359991)
+++ head/sys/powerpc/aim/mmu_oea64.cWed Apr 15 20:33:09 2020
(r359992)
@@ -65,6 +65,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -184,10 +185,12 @@ uma_zone_tmoea64_pvo_zone; /* zone for pvo 
entries */
 
 static struct  pvo_entry *moea64_bpvo_pool;
 static int moea64_bpvo_pool_index = 0;
-static int moea64_bpvo_pool_size = 327680;
+static int moea64_bpvo_pool_size = 0;
 SYSCTL_INT(_machdep, OID_AUTO, moea64_allocated_bpvo_entries, CTLFLAG_RD, 
 &moea64_bpvo_pool_index, 0, "");
 
+#defineBPVO_POOL_SIZE  327680 /* Sensible historical default value */
+#defineBPVO_POOL_EXPANSION_FACTOR  3
 #defineVSID_NBPW   (sizeof(u_int32_t) * 8)
 #ifdef __powerpc64__
 #defineNVSIDS  (NPMAPS * 16)
@@ -916,6 +919,20 @@ moea64_mid_bootstrap(mmu_t mmup, vm_offset_t kernelsta
 * Initialise the bootstrap pvo pool.
 */
TUNABLE_INT_FETCH("machdep.moea64_bpvo_pool_size", 
&moea64_bpvo_pool_size);
+   if (moea64_bpvo_pool_size == 0) {
+   if (!hw_direct_map)
+   moea64_bpvo_pool_size = ((ptoa((uintmax_t)physmem) * 
sizeof(struct vm_page)) /
+   (PAGE_SIZE * PAGE_SIZE)) * 
BPVO_POOL_EXPANSION_FACTOR;
+   else
+   moea64_bpvo_pool_size = BPVO_POOL_SIZE;
+   }
+
+   if (boothowto & RB_VERBOSE) {
+   printf("mmu_oea64: bpvo pool entries = %d, bpvo pool size = %ju 
MB\n",
+   moea64_bpvo_pool_size,
+   moea64_bpvo_pool_size*sizeof(struct pvo_entry) / 1048576);
+   }
+
moea64_bpvo_pool = (struct pvo_entry *)moea64_bootstrap_alloc(
moea64_bpvo_pool_size*sizeof(struct pvo_entry), PAGE_SIZE);
moea64_bpvo_pool_index = 0;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r359342 - head/lib/msun/src

2020-03-26 Thread Alfredo Dal7;Ava Junior
Author: alfredo
Date: Thu Mar 26 18:50:54 2020
New Revision: 359342
URL: https://svnweb.freebsd.org/changeset/base/359342

Log:
  msun: swap words order instead of bits order on BIG ENDIAN
  
  The "for" loop on big endian was inverting all the bits instead of
  just the words
  
  Issue reported by TestSuite (msun lib nan_test case)
  
  Submitted by: Renato Riolino 
  Submitted by: Fernando Valle 
  Reviewed by:  pfg, alfredo
  Approved by:  jhibbits (mentor)
  Sponsored by: Eldorado Research Institute (eldorado.org.br)
  Differential Revision:https://reviews.freebsd.org/D23926

Modified:
  head/lib/msun/src/s_nan.c

Modified: head/lib/msun/src/s_nan.c
==
--- head/lib/msun/src/s_nan.c   Thu Mar 26 17:59:48 2020(r359341)
+++ head/lib/msun/src/s_nan.c   Thu Mar 26 18:50:54 2020(r359342)
@@ -66,14 +66,15 @@ _scan_nan(uint32_t *words, int num_words, const char *
;
 
/* Scan backwards, filling in the bits in words[] as we go. */
-#if _BYTE_ORDER == _LITTLE_ENDIAN
for (bitpos = 0; bitpos < 32 * num_words; bitpos += 4) {
-#else
-   for (bitpos = 32 * num_words - 4; bitpos >= 0; bitpos -= 4) {
-#endif
if (--si < 0)
break;
+#if _BYTE_ORDER == _LITTLE_ENDIAN
words[bitpos / 32] |= digittoint(s[si]) << (bitpos % 32);
+#else
+   words[num_words - 1 - bitpos / 32] |=
+   digittoint(s[si]) << (bitpos % 32);
+#endif
}
 }
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r359309 - head/tests/sys/netinet

2020-03-25 Thread Alfredo Dal7;Ava Junior
Author: alfredo
Date: Wed Mar 25 20:20:08 2020
New Revision: 359309
URL: https://svnweb.freebsd.org/changeset/base/359309

Log:
  so_reuseport_lb_test: correct setsockopt parameter size
  
  Change type of variable used in setsocketopt so correct size of
  option is passed.
  
  Test failure was identified when running the test on PowerPC64,
  and the following error message was seen:
  
"bind () failed: Address already in use"
  
  Submitted by: Fernando Valle 
  Reviewed by:  melifaro, adalava
  Approved by:  jhibbits (mentor)
  Sponsored by: Eldorado Research Institute (eldorado.org.br)
  Differential Revision:https://reviews.freebsd.org/D24164

Modified:
  head/tests/sys/netinet/so_reuseport_lb_test.c

Modified: head/tests/sys/netinet/so_reuseport_lb_test.c
==
--- head/tests/sys/netinet/so_reuseport_lb_test.c   Wed Mar 25 20:16:24 
2020(r359308)
+++ head/tests/sys/netinet/so_reuseport_lb_test.c   Wed Mar 25 20:20:08 
2020(r359309)
@@ -108,7 +108,7 @@ lb_simple_accept_loop(int domain, const struct sockadd
 static int
 lb_listen_socket(int domain, int flags)
 {
-   size_t one;
+   int one;
int error, sd;
 
sd = socket(domain, SOCK_STREAM | flags, 0);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r359160 - head/sys/powerpc/powerpc

2020-03-20 Thread Alfredo Dal7;Ava Junior
Author: alfredo
Date: Fri Mar 20 11:51:08 2020
New Revision: 359160
URL: https://svnweb.freebsd.org/changeset/base/359160

Log:
  [PowerPC] fix panic reading /dev/kmem on !DMAP machines
  
  This fixes /dev/kmem causing panic on machines not using DMAP.
  
  Found when running libkvm Kyua test case on QEMU VM with no
  Huge Pages support.
  
  Reviewed by:  jhibbits, luporl
  Approved by:  jhibbits (mentor)
  Sponsored by: Eldorado Research Institute (eldorado.org.br)
  Differential Revision:https://reviews.freebsd.org/D23776

Modified:
  head/sys/powerpc/powerpc/mem.c

Modified: head/sys/powerpc/powerpc/mem.c
==
--- head/sys/powerpc/powerpc/mem.c  Fri Mar 20 05:12:16 2020
(r359159)
+++ head/sys/powerpc/powerpc/mem.c  Fri Mar 20 11:51:08 2020
(r359160)
@@ -98,9 +98,11 @@ memrw(struct cdev *dev, struct uio *uio, int flags)
struct vm_page m;
vm_page_t marr;
vm_size_t cnt;
+   ssize_t orig_resid;
 
cnt = 0;
error = 0;
+   orig_resid = uio->uio_resid;
 
while (uio->uio_resid > 0 && !error) {
iov = uio->uio_iov;
@@ -137,7 +139,8 @@ kmem_direct_mapped: off = v & PAGE_MASK;
else if (dev2unit(dev) == CDEV_MINOR_KMEM) {
va = uio->uio_offset;
 
-   if ((va < VM_MIN_KERNEL_ADDRESS) || (va > virtual_end)) 
{
+   if (hw_direct_map &&
+   ((va < VM_MIN_KERNEL_ADDRESS) || (va > 
virtual_end))) {
v = DMAP_TO_PHYS(va);
goto kmem_direct_mapped;
}
@@ -151,24 +154,34 @@ kmem_direct_mapped:   off = v & PAGE_MASK;
 * so that we don't create any zero-fill pages.
 */
 
-   for (; va < eva; va += PAGE_SIZE)
-   if (pmap_extract(kernel_pmap, va) == 0)
-   return (EFAULT);
+   for (; va < eva; va += PAGE_SIZE) {
+   if (pmap_extract(kernel_pmap, va) == 0) {
+   error = EFAULT;
+   break;
+   }
+   }
+   if (error != 0)
+   break;
 
prot = (uio->uio_rw == UIO_READ)
? VM_PROT_READ : VM_PROT_WRITE;
 
va = uio->uio_offset;
-   if (kernacc((void *) va, iov->iov_len, prot)
-   == FALSE)
-   return (EFAULT);
+   if (((va >= VM_MIN_KERNEL_ADDRESS) && (va <= 
virtual_end)) &&
+   !kernacc((void *) va, iov->iov_len, prot)) {
+   error = EFAULT;
+   break;
+   }
 
error = uiomove((void *)va, iov->iov_len, uio);
-
-   continue;
}
}
-
+   /*
+* Don't return error if any byte was written.  Read and write
+* can return error only if no i/o was performed.
+*/
+   if (uio->uio_resid != orig_resid)
+   error = 0;
return (error);
 }
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r359015 - head/sys/dev/usb/input

2020-03-16 Thread Alfredo Dal7;Ava Junior
Author: alfredo
Date: Mon Mar 16 13:53:29 2020
New Revision: 359015
URL: https://svnweb.freebsd.org/changeset/base/359015

Log:
  atp: fix mouse attachment on PowerBook5,6 (G4)
  
  Skip device mode switch step on Fountain-based devices as they don't
  support RAW_SENSOR_MODE command, so failing to attach.
  
  This was reproduced on PowerBook G4 (model PowerBook5,6) equipped with
  product ID 0x020e
  
  Reviewed by:  hselasky
  Approved by:  jhibbits (mentor)
  Differential Revision:https://reviews.freebsd.org/D24005

Modified:
  head/sys/dev/usb/input/atp.c

Modified: head/sys/dev/usb/input/atp.c
==
--- head/sys/dev/usb/input/atp.cMon Mar 16 12:33:57 2020
(r359014)
+++ head/sys/dev/usb/input/atp.cMon Mar 16 13:53:29 2020
(r359015)
@@ -2219,6 +2219,9 @@ atp_attach(device_t dev)
return (ENXIO);
}
 
+   di = USB_GET_DRIVER_INFO(uaa);
+   sc->sc_family = DECODE_FAMILY_FROM_DRIVER_INFO(di);
+
/*
 * By default the touchpad behaves like an HID device, sending
 * packets with reportID = 2. Such reports contain only
@@ -2227,17 +2230,18 @@ atp_attach(device_t dev)
 * sensors. The device input mode can be switched from HID
 * reports to raw sensor data using vendor-specific USB
 * control commands.
+* FOUNTAIN devices will give an error when trying to switch
+* input mode, so we skip this command
 */
-   if ((err = atp_set_device_mode(sc, RAW_SENSOR_MODE)) != 0) {
+   if ((sc->sc_family == TRACKPAD_FAMILY_FOUNTAIN_GEYSER) &&
+   (DECODE_PRODUCT_FROM_DRIVER_INFO(di) == FOUNTAIN))
+   DPRINTF("device mode switch skipped: Fountain device\n");
+   else if ((err = atp_set_device_mode(sc, RAW_SENSOR_MODE)) != 0) {
DPRINTF("failed to set mode to 'RAW_SENSOR' (%d)\n", err);
return (ENXIO);
}
 
mtx_init(&sc->sc_mutex, "atpmtx", NULL, MTX_DEF | MTX_RECURSE);
-
-   di = USB_GET_DRIVER_INFO(uaa);
-
-   sc->sc_family = DECODE_FAMILY_FROM_DRIVER_INFO(di);
 
switch(sc->sc_family) {
case TRACKPAD_FAMILY_FOUNTAIN_GEYSER:
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r358672 - head/lib/libc/powerpc64/string

2020-03-05 Thread Alfredo Dal7;Ava Junior
Author: alfredo
Date: Thu Mar  5 14:13:22 2020
New Revision: 358672
URL: https://svnweb.freebsd.org/changeset/base/358672

Log:
  [PowerPC64] restrict memcpy/bcopy optimization to POWER ISA >=V2.07
  
  VSX instructions were added in POWER ISA V2.06 (POWER7), but it
  requires data to be word-aligned. Such requirement was removed in
  ISA V2.07B (POWER8).
  
  Since current memcpy/bcopy optimization relies on VSX instructions
  handling misalignment transparently, and kernel doesn't currently
  implement an alignment error handler, this optimzation should be
  restrict to ISA V2.07 onwards.
  
  SIGBUS on stxvd2x instruction was reproduced in POWER7+ CPU.
  
  Reviewed by:  luporl, jhibbits, bdragon
  Approved by:  jhibbits (mentor)
  Differential Revision:https://reviews.freebsd.org/D23958

Modified:
  head/lib/libc/powerpc64/string/bcopy_resolver.c

Modified: head/lib/libc/powerpc64/string/bcopy_resolver.c
==
--- head/lib/libc/powerpc64/string/bcopy_resolver.c Thu Mar  5 14:05:22 
2020(r358671)
+++ head/lib/libc/powerpc64/string/bcopy_resolver.c Thu Mar  5 14:13:22 
2020(r358672)
@@ -61,7 +61,12 @@ FN_RET FN_NAME_VSX FN_PARAMS;
 
 DEFINE_UIFUNC(, FN_RET, FN_NAME, FN_PARAMS)
 {
-   if (cpu_features & PPC_FEATURE_HAS_VSX)
+   /* VSX instructions were added in POWER ISA 2.06,
+* however it requires data to be word-aligned.
+* Since POWER ISA 2.07B this is solved transparently
+* by the hardware
+*/
+   if (cpu_features2 & PPC_FEATURE2_ARCH_2_07)
return (FN_NAME_VSX);
else
return (FN_NAME_NOVSX);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r358670 - head/sys/powerpc/powerpc

2020-03-05 Thread Alfredo Dal7;Ava Junior
Author: alfredo
Date: Thu Mar  5 12:24:48 2020
New Revision: 358670
URL: https://svnweb.freebsd.org/changeset/base/358670

Log:
  [PowerPC64] fix uma_small_free panic
  
  Fix panic "Freeing UMA block at 0xn with no associated page".
  Also replaces pmap_remove call by pmap_kremove, for symmetry.
  
  Reviewed by:  jhibbits
  Approved by:  jhibbits (mentor)
  Differential Revision:https://reviews.freebsd.org/D23931

Modified:
  head/sys/powerpc/powerpc/uma_machdep.c

Modified: head/sys/powerpc/powerpc/uma_machdep.c
==
--- head/sys/powerpc/powerpc/uma_machdep.c  Thu Mar  5 10:52:16 2020
(r358669)
+++ head/sys/powerpc/powerpc/uma_machdep.c  Thu Mar  5 12:24:48 2020
(r358670)
@@ -95,14 +95,13 @@ uma_small_free(void *mem, vm_size_t size, u_int8_t fla
 {
vm_page_t m;
 
-   if (!hw_direct_map)
-   pmap_remove(kernel_pmap,(vm_offset_t)mem,
-   (vm_offset_t)mem + PAGE_SIZE);
-
if (hw_direct_map)
m = PHYS_TO_VM_PAGE(DMAP_TO_PHYS((vm_offset_t)mem));
-   else
-   m = PHYS_TO_VM_PAGE((vm_offset_t)mem);
+   else {
+   m = PHYS_TO_VM_PAGE(pmap_kextract((vm_offset_t)mem));
+   pmap_kremove((vm_offset_t)mem);
+   }
+
KASSERT(m != NULL,
("Freeing UMA block at %p with no associated page", mem));
 #ifdef __powerpc64__
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r357596 - head/sys/dev/virtio/pci

2020-02-05 Thread Alfredo Dal7;Ava Junior
Author: alfredo
Date: Wed Feb  5 20:39:18 2020
New Revision: 357596
URL: https://svnweb.freebsd.org/changeset/base/357596

Log:
  [virtio] Fix r/w to PCI configuration area on big endian platforms
  
  In legacy VirtIO drivers, the header must be PCI endianness (little) and the
  device-specific region is encoded in the native endian of the guest.
  
  This patch makes the access (read/write) to VirtIO header using the little
  endian order. Other read and write access are native endianness. This also
  sets the device's IO region as big endian if on big endian machine.
  
  PR:   205178
  Submitted by: Andre Silva 
  Reported by:  Kenneth Salerno 
  Reviewed by:  bryanv, bdragon, luporl, alfredo
  Approved by:  jhibbits (mentor)
  Differential Revision:https://reviews.freebsd.org/D23401

Modified:
  head/sys/dev/virtio/pci/virtio_pci.c

Modified: head/sys/dev/virtio/pci/virtio_pci.c
==
--- head/sys/dev/virtio/pci/virtio_pci.cWed Feb  5 20:34:22 2020
(r357595)
+++ head/sys/dev/virtio/pci/virtio_pci.cWed Feb  5 20:39:18 2020
(r357596)
@@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -184,6 +185,17 @@ static voidvtpci_config_intr(void *);
 #define vtpci_write_config_2(sc, o, v) bus_write_2((sc)->vtpci_res, (o), (v))
 #define vtpci_write_config_4(sc, o, v) bus_write_4((sc)->vtpci_res, (o), (v))
 
+/*
+ * Legacy VirtIO header is always PCI endianness (little), so if we
+ * are in a BE machine we need to swap bytes from LE to BE when reading
+ * and from BE to LE when writing.
+ * If we are in a LE machine, there will be no swaps.
+ */
+#define vtpci_read_header_2(sc, o) le16toh(vtpci_read_config_2(sc, o))
+#define vtpci_read_header_4(sc, o) le32toh(vtpci_read_config_4(sc, o))
+#define vtpci_write_header_2(sc, o, v)  vtpci_write_config_2(sc, o, 
(htole16(v)))
+#define vtpci_write_header_4(sc, o, v)  vtpci_write_config_4(sc, o, 
(htole32(v)))
+
 /* Tunables. */
 static int vtpci_disable_msix = 0;
 TUNABLE_INT("hw.virtio.pci.disable_msix", &vtpci_disable_msix);
@@ -278,6 +290,17 @@ vtpci_attach(device_t dev)
return (ENXIO);
}
 
+/*
+ * For legacy VirtIO, the device-specific configuration is guest
+ * endian, while the common configuration header is always
+ * PCI (little) endian and will be handled specifically in
+ * other parts of this file via functions
+ * 'vtpci_[read|write]_header_[2|4]'
+ */
+#if _BYTE_ORDER == _BIG_ENDIAN
+   rman_set_bustag(sc->vtpci_res, &bs_be_tag);
+#endif
+
if (pci_find_cap(dev, PCIY_MSI, NULL) != 0)
sc->vtpci_flags |= VTPCI_FLAG_NO_MSI;
 
@@ -447,7 +470,7 @@ vtpci_negotiate_features(device_t dev, uint64_t child_
 
sc = device_get_softc(dev);
 
-   host_features = vtpci_read_config_4(sc, VIRTIO_PCI_HOST_FEATURES);
+   host_features = vtpci_read_header_4(sc, VIRTIO_PCI_HOST_FEATURES);
vtpci_describe_features(sc, "host", host_features);
 
/*
@@ -459,7 +482,7 @@ vtpci_negotiate_features(device_t dev, uint64_t child_
sc->vtpci_features = features;
 
vtpci_describe_features(sc, "negotiated", features);
-   vtpci_write_config_4(sc, VIRTIO_PCI_GUEST_FEATURES, features);
+   vtpci_write_header_4(sc, VIRTIO_PCI_GUEST_FEATURES, features);
 
return (features);
 }
@@ -502,7 +525,7 @@ vtpci_alloc_virtqueues(device_t dev, int flags, int nv
info = &vq_info[idx];
 
vtpci_select_virtqueue(sc, idx);
-   size = vtpci_read_config_2(sc, VIRTIO_PCI_QUEUE_NUM);
+   size = vtpci_read_header_2(sc, VIRTIO_PCI_QUEUE_NUM);
 
error = virtqueue_alloc(dev, idx, size, VIRTIO_PCI_VRING_ALIGN,
~(vm_paddr_t)0, info, &vq);
@@ -512,7 +535,7 @@ vtpci_alloc_virtqueues(device_t dev, int flags, int nv
break;
}
 
-   vtpci_write_config_4(sc, VIRTIO_PCI_QUEUE_PFN,
+   vtpci_write_header_4(sc, VIRTIO_PCI_QUEUE_PFN,
virtqueue_paddr(vq) >> VIRTIO_PCI_QUEUE_ADDR_SHIFT);
 
vqx->vtv_vq = *info->vqai_vq = vq;
@@ -646,7 +669,7 @@ vtpci_notify_virtqueue(device_t dev, uint16_t queue)
 
sc = device_get_softc(dev);
 
-   vtpci_write_config_2(sc, VIRTIO_PCI_QUEUE_NOTIFY, queue);
+   vtpci_write_header_2(sc, VIRTIO_PCI_QUEUE_NOTIFY, queue);
 }
 
 static uint8_t
@@ -1046,10 +1069,10 @@ vtpci_register_msix_vector(struct vtpci_softc *sc, int
} else
vector = VIRTIO_MSI_NO_VECTOR;
 
-   vtpci_write_config_2(sc, offset, vector);
+   vtpci_write_header_2(sc, offset, vector);
 
/* Read vector to determine if the host had sufficient resources. */
-   if (vtpci_read_config_2(sc, offset) != vector) {
+   if (vtpci_read_header_2(sc, offset) != vector) {
device_printf(dev,

svn commit: r357261 - in head: share/misc usr.bin/calendar/calendars

2020-01-29 Thread Alfredo Dal7;Ava Junior
Author: alfredo
Date: Wed Jan 29 17:39:38 2020
New Revision: 357261
URL: https://svnweb.freebsd.org/changeset/base/357261

Log:
  Add myself (alfredo) to committers-src.dot and calendar.freebsd
  
  Approved by:  jhibbits (mentor)

Modified:
  head/share/misc/committers-src.dot
  head/usr.bin/calendar/calendars/calendar.freebsd

Modified: head/share/misc/committers-src.dot
==
--- head/share/misc/committers-src.dot  Wed Jan 29 17:01:02 2020
(r357260)
+++ head/share/misc/committers-src.dot  Wed Jan 29 17:39:38 2020
(r357261)
@@ -105,6 +105,7 @@ adrian [label="Adrian Chadd\nadr...@freebsd.org\n2000/
 ae [label="Andrey V. Elsukov\n...@freebsd.org\n2010/06/03"]
 akiyama [label="Shunsuke Akiyama\nakiy...@freebsd.org\n2000/06/19"]
 alc [label="Alan Cox\n...@freebsd.org\n1999/02/23"]
+alfredo [label="Alfredo Dal'Ava Junior\nalfr...@freebsd.org\n2020/01/27"]
 allanjude [label="Allan Jude\nallanj...@freebsd.org\n2015/07/30"]
 ambrisko [label="Doug Ambrisko\nambri...@freebsd.org\n2001/12/19"]
 anchie [label="Ana Kukec\nanc...@freebsd.org\n2010/04/14"]
@@ -613,6 +614,7 @@ jhb -> rpokala
 jhb -> arichardson
 jhb -> scottph
 
+jhibbits -> alfredo
 jhibbits -> bdragon
 jhibbits -> leitao
 jhibbits -> luporl

Modified: head/usr.bin/calendar/calendars/calendar.freebsd
==
--- head/usr.bin/calendar/calendars/calendar.freebsdWed Jan 29 17:01:02 
2020(r357260)
+++ head/usr.bin/calendar/calendars/calendar.freebsdWed Jan 29 17:39:38 
2020(r357261)
@@ -324,6 +324,7 @@
 08/19  Chin-San Huang  born in Yi-Lan, Taiwan, Republic 
of China, 1979
 08/19  Pav Lucistnik  born in Kutna Hora, Czech Republic, 
1980
 08/20  Michael Heffner  born in Cleona, Pennsylvania, 
United States, 1981
+08/21  Alfredo Dal'Ava Junior  born in Pocos de Caldas, 
Minas Gerais, Brazil, 1981
 08/21  Jason A. Harmening  born in Fort Wayne, Indiana, 
United States, 1981
 08/22  Ilya Bakulin  born in Tbilisi, USSR, 1986
 08/24  Mark Linimon  born in Houston, Texas, United 
States, 1955
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"