Re: svn commit: r354672 - head/lib/libc/secure

2019-11-12 Thread Warner Losh
On Tue, Nov 12, 2019 at 9:20 PM Kyle Evans  wrote:

>
>
> On Tue, Nov 12, 2019, 22:04 Pedro Giffuni  wrote:
>
>>
>> On 12/11/2019 22:00, Kyle Evans wrote:
>>
>> Author: kevans
>> Date: Wed Nov 13 03:00:32 2019
>> New Revision: 354672
>> URL: https://svnweb.freebsd.org/changeset/base/354672
>>
>> Log:
>>   ssp: rework the logic to use priority=200 on clang builds
>>
>>   The preproc logic was added at the last minute to appease GCC 4.2, and
>>   kevans@ did clearly not go back and double-check that the logic worked out
>>   for clang builds to use the new variant.
>>
>>   It turns out that clang defines __GNUC__ == 4. Flip it around and check
>>   __clang__ as well, leaving a note to remove it later.
>>
>>
>> clang reports itself as GCC 4.2, the priority argument was introduced in
>> GCC 4.3.
>>
>>   Reported by:   cem
>>
>> Modified:
>>   head/lib/libc/secure/stack_protector.c
>>
>> Modified: head/lib/libc/secure/stack_protector.c
>> ==
>> --- head/lib/libc/secure/stack_protector.c   Wed Nov 13 02:22:00 2019
>> (r354671)
>> +++ head/lib/libc/secure/stack_protector.c   Wed Nov 13 03:00:32 2019
>> (r354672)
>> @@ -47,13 +47,15 @@ __FBSDID("$FreeBSD$");
>>   * they're either not usually statically linked or they simply don't do 
>> things
>>   * in constructors that would be adversely affected by their positioning 
>> with
>>   * respect to this initialization.
>> + *
>> + * This conditional should be removed when GCC 4.2 is removed.
>>   */
>> -#if defined(__GNUC__) && __GNUC__ <= 4
>> -#define _GUARD_SETUP_CTOR_ATTR  \
>> -__attribute__((__constructor__, __used__));
>> -#else
>> +#if defined(__clang__) || (defined(__GNUC__) && __GNUC__ > 4)
>>  #define _GUARD_SETUP_CTOR_ATTR   \
>>  __attribute__((__constructor__ (200), __used__));
>> +#else
>> +#define _GUARD_SETUP_CTOR_ATTR  \
>> +__attribute__((__constructor__, __used__));
>>  #endif
>>
>>  extern int __sysctl(const int *name, u_int namelen, void *oldp,
>>
>> Please fix properly. Assuming clang always supported it, something like:
>>
>> #if __GNUC_PREREQ__(4, 3) || __has_attribute(__constructor__)
>>
>> should work
>>
>> Cheers,
>>
>
> I considered something of this sort, but searching for information on the
> priority argument in the first place was annoying enough that I had too
> much search-fatigue to figure out when GCC actually corrected this, thus
> assuming that GCC5 (which seemed to be an all-around good release if memory
> serves) and later (since I confirmed GCC6) was sufficient.
>
> I'll fix it in the morning (~8 hours) if I receive no further objections
> to address.
>

Soon enough this can be removed entirely... Getting it pedantically right
in the mean time has little value. We don't really support gcc5 at the
moment. gcc6 and later have good support, but anything new between 4.3 and
6.0 likely is poorly tagged...

Warner
___
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"


Re: svn commit: r354672 - head/lib/libc/secure

2019-11-12 Thread Kyle Evans
On Tue, Nov 12, 2019, 22:04 Pedro Giffuni  wrote:

>
> On 12/11/2019 22:00, Kyle Evans wrote:
>
> Author: kevans
> Date: Wed Nov 13 03:00:32 2019
> New Revision: 354672
> URL: https://svnweb.freebsd.org/changeset/base/354672
>
> Log:
>   ssp: rework the logic to use priority=200 on clang builds
>
>   The preproc logic was added at the last minute to appease GCC 4.2, and
>   kevans@ did clearly not go back and double-check that the logic worked out
>   for clang builds to use the new variant.
>
>   It turns out that clang defines __GNUC__ == 4. Flip it around and check
>   __clang__ as well, leaving a note to remove it later.
>
>
> clang reports itself as GCC 4.2, the priority argument was introduced in
> GCC 4.3.
>
>   Reported by:cem
>
> Modified:
>   head/lib/libc/secure/stack_protector.c
>
> Modified: head/lib/libc/secure/stack_protector.c
> ==
> --- head/lib/libc/secure/stack_protector.cWed Nov 13 02:22:00 2019
> (r354671)
> +++ head/lib/libc/secure/stack_protector.cWed Nov 13 03:00:32 2019
> (r354672)
> @@ -47,13 +47,15 @@ __FBSDID("$FreeBSD$");
>   * they're either not usually statically linked or they simply don't do 
> things
>   * in constructors that would be adversely affected by their positioning with
>   * respect to this initialization.
> + *
> + * This conditional should be removed when GCC 4.2 is removed.
>   */
> -#if defined(__GNUC__) && __GNUC__ <= 4
> -#define  _GUARD_SETUP_CTOR_ATTR  \
> -__attribute__((__constructor__, __used__));
> -#else
> +#if defined(__clang__) || (defined(__GNUC__) && __GNUC__ > 4)
>  #define  _GUARD_SETUP_CTOR_ATTR   \
>  __attribute__((__constructor__ (200), __used__));
> +#else
> +#define  _GUARD_SETUP_CTOR_ATTR  \
> +__attribute__((__constructor__, __used__));
>  #endif
>
>  extern int __sysctl(const int *name, u_int namelen, void *oldp,
>
> Please fix properly. Assuming clang always supported it, something like:
>
> #if __GNUC_PREREQ__(4, 3) || __has_attribute(__constructor__)
>
> should work
>
> Cheers,
>

I considered something of this sort, but searching for information on the
priority argument in the first place was annoying enough that I had too
much search-fatigue to figure out when GCC actually corrected this, thus
assuming that GCC5 (which seemed to be an all-around good release if memory
serves) and later (since I confirmed GCC6) was sufficient.

I'll fix it in the morning (~8 hours) if I receive no further objections to
address.

Thanks!

>
___
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"


Re: svn commit: r354672 - head/lib/libc/secure

2019-11-12 Thread Pedro Giffuni



On 12/11/2019 22:00, Kyle Evans wrote:

Author: kevans
Date: Wed Nov 13 03:00:32 2019
New Revision: 354672
URL: https://svnweb.freebsd.org/changeset/base/354672

Log:
   ssp: rework the logic to use priority=200 on clang builds
   
   The preproc logic was added at the last minute to appease GCC 4.2, and

   kevans@ did clearly not go back and double-check that the logic worked out
   for clang builds to use the new variant.
   
   It turns out that clang defines __GNUC__ == 4. Flip it around and check

   __clang__ as well, leaving a note to remove it later.
   
clang reports itself as GCC 4.2, the priority argument was introduced in 
GCC 4.3.

   Reported by: cem

Modified:
   head/lib/libc/secure/stack_protector.c

Modified: head/lib/libc/secure/stack_protector.c
==
--- head/lib/libc/secure/stack_protector.c  Wed Nov 13 02:22:00 2019
(r354671)
+++ head/lib/libc/secure/stack_protector.c  Wed Nov 13 03:00:32 2019
(r354672)
@@ -47,13 +47,15 @@ __FBSDID("$FreeBSD$");
   * they're either not usually statically linked or they simply don't do things
   * in constructors that would be adversely affected by their positioning with
   * respect to this initialization.
+ *
+ * This conditional should be removed when GCC 4.2 is removed.
   */
-#if defined(__GNUC__) && __GNUC__ <= 4
-#define_GUARD_SETUP_CTOR_ATTR  \
-__attribute__((__constructor__, __used__));
-#else
+#if defined(__clang__) || (defined(__GNUC__) && __GNUC__ > 4)
  #define   _GUARD_SETUP_CTOR_ATTR   \
  __attribute__((__constructor__ (200), __used__));
+#else
+#define_GUARD_SETUP_CTOR_ATTR  \
+__attribute__((__constructor__, __used__));
  #endif
  
  extern int __sysctl(const int *name, u_int namelen, void *oldp,


Please fix properly. Assuming clang always supported it, something like:

#if __GNUC_PREREQ__(4, 3) || __has_attribute(__constructor__)

should work

Cheers,

Pedro.

___
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: r354673 - head/stand/libsa

2019-11-12 Thread Ravi Pokala
Author: rpokala
Date: Wed Nov 13 03:56:51 2019
New Revision: 354673
URL: https://svnweb.freebsd.org/changeset/base/354673

Log:
  Logging improvements to loader::nfs
  
  Include the server IP address when logging nfs_open(), add a few missing
  "\n"s, and correct a typo.
  
  Reviewed by:  kevans
  MFC after:2 weeks
  Sponsored by: Panasas
  Differential Revision:https://reviews.freebsd.org/D22346

Modified:
  head/stand/libsa/nfs.c

Modified: head/stand/libsa/nfs.c
==
--- head/stand/libsa/nfs.c  Wed Nov 13 03:00:32 2019(r354672)
+++ head/stand/libsa/nfs.c  Wed Nov 13 03:56:51 2019(r354673)
@@ -486,7 +486,8 @@ nfs_open(const char *upath, struct open_file *f)
 
 #ifdef NFS_DEBUG
if (debug)
-   printf("nfs_open: %s (rootpath=%s)\n", upath, rootpath);
+   printf("nfs_open: %s (rootip=%s rootpath=%s)\n", upath,
+   inet_ntoa(rootip), rootpath);
 #endif
if (!rootpath[0]) {
printf("no rootpath, no nfs\n");
@@ -691,14 +692,14 @@ nfs_read(struct open_file *f, void *buf, size_t size, 
if (cc == -1) {
 #ifdef NFS_DEBUG
if (debug)
-   printf("nfs_read: read: %s", strerror(errno));
+   printf("nfs_read: read: %s\n", strerror(errno));
 #endif
return (errno); /* XXX - from nfs_readdata */
}
if (cc == 0) {
 #ifdef NFS_DEBUG
if (debug)
-   printf("nfs_read: hit EOF unexpectantly");
+   printf("nfs_read: hit EOF unexpectedly\n");
 #endif
goto ret;
}
___
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: r354672 - head/lib/libc/secure

2019-11-12 Thread Kyle Evans
Author: kevans
Date: Wed Nov 13 03:00:32 2019
New Revision: 354672
URL: https://svnweb.freebsd.org/changeset/base/354672

Log:
  ssp: rework the logic to use priority=200 on clang builds
  
  The preproc logic was added at the last minute to appease GCC 4.2, and
  kevans@ did clearly not go back and double-check that the logic worked out
  for clang builds to use the new variant.
  
  It turns out that clang defines __GNUC__ == 4. Flip it around and check
  __clang__ as well, leaving a note to remove it later.
  
  Reported by:  cem

Modified:
  head/lib/libc/secure/stack_protector.c

Modified: head/lib/libc/secure/stack_protector.c
==
--- head/lib/libc/secure/stack_protector.c  Wed Nov 13 02:22:00 2019
(r354671)
+++ head/lib/libc/secure/stack_protector.c  Wed Nov 13 03:00:32 2019
(r354672)
@@ -47,13 +47,15 @@ __FBSDID("$FreeBSD$");
  * they're either not usually statically linked or they simply don't do things
  * in constructors that would be adversely affected by their positioning with
  * respect to this initialization.
+ *
+ * This conditional should be removed when GCC 4.2 is removed.
  */
-#if defined(__GNUC__) && __GNUC__ <= 4
-#define_GUARD_SETUP_CTOR_ATTR  \
-__attribute__((__constructor__, __used__));
-#else
+#if defined(__clang__) || (defined(__GNUC__) && __GNUC__ > 4)
 #define_GUARD_SETUP_CTOR_ATTR   \
 __attribute__((__constructor__ (200), __used__));
+#else
+#define_GUARD_SETUP_CTOR_ATTR  \
+__attribute__((__constructor__, __used__));
 #endif
 
 extern int __sysctl(const int *name, u_int namelen, void *oldp,
___
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: r354671 - head/sys/powerpc/aim

2019-11-12 Thread Justin Hibbits
Author: jhibbits
Date: Wed Nov 13 02:22:00 2019
New Revision: 354671
URL: https://svnweb.freebsd.org/changeset/base/354671

Log:
  powerpc64: Don't guard ISA 3.0 partition table setup with hw_direct_map
  
  PowerISA 3.0 eliminated the 64-bit bridge mode which allowed 32-bit kernels
  to run on 64-bit AIM/Book-S hardware.  Since therefore only a 64-bit kernel
  can run on this hardware, and 64-bit native always has the direct map, there
  is no need to guard it.

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

Modified: head/sys/powerpc/aim/moea64_native.c
==
--- head/sys/powerpc/aim/moea64_native.cWed Nov 13 02:16:24 2019
(r354670)
+++ head/sys/powerpc/aim/moea64_native.cWed Nov 13 02:22:00 2019
(r354671)
@@ -545,9 +545,8 @@ moea64_bootstrap_native(mmu_t mmup, vm_offset_t kernel
if (cpu_features2 & PPC_FEATURE2_ARCH_3_00) {
moea64_part_table =
(struct pate *)moea64_bootstrap_alloc(PART_SIZE, PART_SIZE);
-   if (hw_direct_map)
-   moea64_part_table =
-   (struct pate 
*)PHYS_TO_DMAP((vm_offset_t)moea64_part_table);
+   moea64_part_table =
+   (struct pate *)PHYS_TO_DMAP((vm_offset_t)moea64_part_table);
}
DISABLE_TRANS(msr);
bzero(__DEVOLATILE(void *, moea64_pteg_table), moea64_pteg_count *
___
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: r354670 - head/sys/powerpc/powerpc

2019-11-12 Thread Justin Hibbits
Author: jhibbits
Date: Wed Nov 13 02:16:24 2019
New Revision: 354670
URL: https://svnweb.freebsd.org/changeset/base/354670

Log:
  powerpc: Don't savectx() twice in IPI_STOP handler
  
  We already save context in stoppcbs[] array, so there's no need to also save 
it
  in the PCB, it won't be used.

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

Modified: head/sys/powerpc/powerpc/mp_machdep.c
==
--- head/sys/powerpc/powerpc/mp_machdep.c   Wed Nov 13 02:14:17 2019
(r354669)
+++ head/sys/powerpc/powerpc/mp_machdep.c   Wed Nov 13 02:16:24 2019
(r354670)
@@ -331,7 +331,6 @@ powerpc_ipi_handler(void *arg)
__func__);
cpuid = PCPU_GET(cpuid);
savectx([cpuid]);
-   savectx(PCPU_GET(curpcb));
CPU_SET_ATOMIC(cpuid, _cpus);
while (!CPU_ISSET(cpuid, _cpus))
cpu_spinwait();
___
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: r354669 - head/lib/libc/secure

2019-11-12 Thread Kyle Evans
Author: kevans
Date: Wed Nov 13 02:14:17 2019
New Revision: 354669
URL: https://svnweb.freebsd.org/changeset/base/354669

Log:
  ssp: add a priority to the __stack_chk_guard constructor
  
  First, this commit is a NOP on GCC <= 4.x; this decidedly doesn't work
  cleanly on GCC 4.2, and it will be gone soon anyways so I chose not to dump
  time into figuring out if there's a way to make it work. xtoolchain-gcc,
  clocking in as GCC6, can cope with it just fine and later versions are also
  generally ok with the syntax. I suspect very few users are running GCC4.2
  built worlds and also experiencing potential fallout from the status quo.
  
  For dynamically linked applications, this change also means very little.
  rtld will run libc ctors before most others, so the situation is
  approximately a NOP for these as well.
  
  The real cause for this change is statically linked applications doing
  almost questionable things in their constructors. qemu-user-static, for
  instance, creates a thread in a global constructor for their async rcu
  callbacks. In general, this works in other places-
  
  - On OpenBSD, __stack_chk_guard is stored in an .openbsd.randomdata section
that's initialized by the kernel in the static case, or ld.so in the
dynamic case
  - On Linux, __stack_chk_guard is apparently stored in TLS and such a problem
is circumvented there because the value is presumed stable in the new
thread.
  
  On FreeBSD, the rcu thread creation ctor and __guard_setup are both unmarked
  priority. qemu-user-static spins up the rcu thread prior to __guard_setup
  which starts making function calls- some of these are sprinkled with the
  canary. In the middle of one of these functions, __guard_setup is invoked in
  the main thread and __stack_chk_guard changes- qemu-user-static is promptly
  terminated for an SSP violation that didn't actually happen.
  
  This is not an all-too-common problem. We circumvent it here by giving the
  __stack_chk_guard constructor a solid priority. 200 was chosen because that
  gives static applications ample range (down to 101) for working around it
  if they really need to. I suspect most applications will "just work" as
  expected- the default/non-prioritized flavor of __constructor__ functions
  run last, and the canary is generally not expected to change as of this
  point at the very least.
  
  This took approximately three weeks of spare time debugging to pin down.
  
  PR:   241905

Modified:
  head/lib/libc/secure/stack_protector.c

Modified: head/lib/libc/secure/stack_protector.c
==
--- head/lib/libc/secure/stack_protector.c  Wed Nov 13 01:58:43 2019
(r354668)
+++ head/lib/libc/secure/stack_protector.c  Wed Nov 13 02:14:17 2019
(r354669)
@@ -40,11 +40,27 @@ __FBSDID("$FreeBSD$");
 #include 
 #include "libc_private.h"
 
+/*
+ * We give __guard_setup a defined priority early on so that statically linked
+ * applications have a defined priority at which __stack_chk_guard will be
+ * getting initialized.  This will not matter to most applications, because
+ * they're either not usually statically linked or they simply don't do things
+ * in constructors that would be adversely affected by their positioning with
+ * respect to this initialization.
+ */
+#if defined(__GNUC__) && __GNUC__ <= 4
+#define_GUARD_SETUP_CTOR_ATTR  \
+__attribute__((__constructor__, __used__));
+#else
+#define_GUARD_SETUP_CTOR_ATTR   \
+__attribute__((__constructor__ (200), __used__));
+#endif
+
 extern int __sysctl(const int *name, u_int namelen, void *oldp,
 size_t *oldlenp, void *newp, size_t newlen);
 
 long __stack_chk_guard[8] = {0, 0, 0, 0, 0, 0, 0, 0};
-static void __guard_setup(void) __attribute__((__constructor__, __used__));
+static void __guard_setup(void) _GUARD_SETUP_CTOR_ATTR;
 static void __fail(const char *);
 void __stack_chk_fail(void);
 void __chk_fail(void);
___
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: r354668 - head/sys/cam/scsi

2019-11-12 Thread Warner Losh
Author: imp
Date: Wed Nov 13 01:58:43 2019
New Revision: 354668
URL: https://svnweb.freebsd.org/changeset/base/354668

Log:
  Fix a race between daopen and damediapoll
  
  When we do a daopen, we call dareprobe and wait for the results. The repoll 
runs
  the da state machine up through the DA_STATE_RC* and then exits.
  
  For removable media, we poll the device every 3 seconds with a TUR to see if 
it
  has disappeared. This introduces a race. If the removable device has lots of
  partitions, and if it's a little slow (like say a USB2 connected USB stick),
  then we can have a fair amount of time that this reporbe is going on for. If,
  during that time, damediapoll fires, it calls daschedule which changes the
  scheduling priority from NONE to NORMAL. When that happens, the careful single
  stepping in the da state machine is disrupted and we wind up sceduling 
multiple
  read capacity calls. The first one succeeds and releases the reference. The
  second one succeeds and releases the reference (and panics if the right code 
is
  compiled into the da driver).
  
  To avoid the race, only do the TUR calls while in state normal, otherwise just
  reschedule damediapoll. This prevents the race from happening.

Modified:
  head/sys/cam/scsi/scsi_da.c

Modified: head/sys/cam/scsi/scsi_da.c
==
--- head/sys/cam/scsi/scsi_da.c Wed Nov 13 00:53:45 2019(r354667)
+++ head/sys/cam/scsi/scsi_da.c Wed Nov 13 01:58:43 2019(r354668)
@@ -5949,6 +5949,7 @@ damediapoll(void *arg)
 
if (!cam_iosched_has_work_flags(softc->cam_iosched, DA_WORK_TUR) &&
(softc->flags & DA_FLAG_TUR_PENDING) == 0 &&
+   softc->state == DA_STATE_NORMAL &&
LIST_EMPTY(>pending_ccbs)) {
if (da_periph_acquire(periph, DA_REF_TUR) == 0) {
cam_iosched_set_work_flags(softc->cam_iosched, 
DA_WORK_TUR);
___
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: r354667 - in head/sys: dev/cxgbe dev/cxgbe/crypto dev/cxgbe/tom modules/cxgbe/if_cxgbe

2019-11-12 Thread John Baldwin
Author: jhb
Date: Wed Nov 13 00:53:45 2019
New Revision: 354667
URL: https://svnweb.freebsd.org/changeset/base/354667

Log:
  Create a file to hold shared routines for dealing with T6 key contexts.
  
  ccr(4) and TLS support in cxgbe(4) construct key contexts used by the
  crypto engine in the T6.  This consolidates some duplicated code for
  helper functions used to build key contexts.
  
  Reviewed by:  np
  MFC after:1 month
  Sponsored by: Chelsio Communications
  Differential Revision:https://reviews.freebsd.org/D22156

Added:
  head/sys/dev/cxgbe/crypto/t4_keyctx.c   (contents, props changed)
Modified:
  head/sys/dev/cxgbe/adapter.h
  head/sys/dev/cxgbe/crypto/t4_crypto.c
  head/sys/dev/cxgbe/t4_main.c
  head/sys/dev/cxgbe/tom/t4_tls.c
  head/sys/modules/cxgbe/if_cxgbe/Makefile

Modified: head/sys/dev/cxgbe/adapter.h
==
--- head/sys/dev/cxgbe/adapter.hTue Nov 12 23:57:57 2019
(r354666)
+++ head/sys/dev/cxgbe/adapter.hWed Nov 13 00:53:45 2019
(r354667)
@@ -1142,7 +1142,6 @@ void t4_os_link_changed(struct port_info *);
 void t4_iterate(void (*)(struct adapter *, void *), void *);
 void t4_init_devnames(struct adapter *);
 void t4_add_adapter(struct adapter *);
-void t4_aes_getdeckey(void *, const void *, unsigned int);
 int t4_detach_common(device_t);
 int t4_map_bars_0_and_4(struct adapter *);
 int t4_map_bar_2(struct adapter *);
@@ -1169,6 +1168,15 @@ int cxgbe_media_change(struct ifnet *);
 void cxgbe_media_status(struct ifnet *, struct ifmediareq *);
 bool t4_os_dump_cimla(struct adapter *, int, bool);
 void t4_os_dump_devlog(struct adapter *);
+
+/* t4_keyctx.c */
+struct auth_hash;
+union authctx;
+
+void t4_aes_getdeckey(void *, const void *, unsigned int);
+void t4_copy_partial_hash(int, union authctx *, void *);
+void t4_init_gmac_hash(const char *, int, char *);
+void t4_init_hmac_digest(struct auth_hash *, u_int, char *, int, char *);
 
 #ifdef DEV_NETMAP
 /* t4_netmap.c */

Modified: head/sys/dev/cxgbe/crypto/t4_crypto.c
==
--- head/sys/dev/cxgbe/crypto/t4_crypto.c   Tue Nov 12 23:57:57 2019
(r354666)
+++ head/sys/dev/cxgbe/crypto/t4_crypto.c   Wed Nov 13 00:53:45 2019
(r354667)
@@ -141,8 +141,7 @@ struct ccr_session_hmac {
unsigned int partial_digest_len;
unsigned int auth_mode;
unsigned int mk_size;
-   char ipad[CHCR_HASH_MAX_BLOCK_SIZE_128];
-   char opad[CHCR_HASH_MAX_BLOCK_SIZE_128];
+   char pads[CHCR_HASH_MAX_BLOCK_SIZE_128 * 2];
 };
 
 struct ccr_session_gmac {
@@ -530,10 +529,7 @@ ccr_hash(struct ccr_softc *sc, struct ccr_session *s, 
V_SCMD_LAST_FRAG(0) |
V_SCMD_MORE_FRAGS(crd->crd_len == 0 ? 1 : 0) | V_SCMD_MAC_ONLY(1));
 
-   memcpy(crwr->key_ctx.key, s->hmac.ipad, s->hmac.partial_digest_len);
-   if (use_opad)
-   memcpy(crwr->key_ctx.key + iopad_size, s->hmac.opad,
-   s->hmac.partial_digest_len);
+   memcpy(crwr->key_ctx.key, s->hmac.pads, kctx_len);
 
/* XXX: F_KEY_CONTEXT_SALT_PRESENT set, but 'salt' not set. */
kctx_flits = (sizeof(struct _key_ctx) + kctx_len) / 16;
@@ -1069,8 +1065,7 @@ ccr_authenc(struct ccr_softc *sc, struct ccr_session *
}
 
dst = crwr->key_ctx.key + roundup2(s->blkcipher.key_len, 16);
-   memcpy(dst, s->hmac.ipad, s->hmac.partial_digest_len);
-   memcpy(dst + iopad_size, s->hmac.opad, s->hmac.partial_digest_len);
+   memcpy(dst, s->hmac.pads, iopad_size * 2);
 
dst = (char *)(crwr + 1) + kctx_len;
ccr_write_phys_dsgl(sc, dst, dsgl_nsegs);
@@ -2212,44 +2207,6 @@ ccr_detach(device_t dev)
 }
 
 static void
-ccr_copy_partial_hash(void *dst, int cri_alg, union authctx *auth_ctx)
-{
-   uint32_t *u32;
-   uint64_t *u64;
-   u_int i;
-
-   u32 = (uint32_t *)dst;
-   u64 = (uint64_t *)dst;
-   switch (cri_alg) {
-   case CRYPTO_SHA1:
-   case CRYPTO_SHA1_HMAC:
-   for (i = 0; i < SHA1_HASH_LEN / 4; i++)
-   u32[i] = htobe32(auth_ctx->sha1ctx.h.b32[i]);
-   break;
-   case CRYPTO_SHA2_224:
-   case CRYPTO_SHA2_224_HMAC:
-   for (i = 0; i < SHA2_256_HASH_LEN / 4; i++)
-   u32[i] = htobe32(auth_ctx->sha224ctx.state[i]);
-   break;
-   case CRYPTO_SHA2_256:
-   case CRYPTO_SHA2_256_HMAC:
-   for (i = 0; i < SHA2_256_HASH_LEN / 4; i++)
-   u32[i] = htobe32(auth_ctx->sha256ctx.state[i]);
-   break;
-   case CRYPTO_SHA2_384:
-   case CRYPTO_SHA2_384_HMAC:
-   for (i = 0; i < SHA2_512_HASH_LEN / 8; i++)
-   u64[i] = htobe64(auth_ctx->sha384ctx.state[i]);
-   break;
-   case CRYPTO_SHA2_512:
-   case CRYPTO_SHA2_512_HMAC:
-   for (i = 0; i < 

svn commit: r354666 - head/usr.sbin/sesutil

2019-11-12 Thread Alan Somers
Author: asomers
Date: Tue Nov 12 23:57:57 2019
New Revision: 354666
URL: https://svnweb.freebsd.org/changeset/base/354666

Log:
  sesutil: fix another memory leak
  
  Instead of calloc()ing (and forgetting to free) in a tight loop, just put
  this small array on the stack.
  
  Reported by:  Coverity
  Coverity CID: 1331665
  MFC after:2 weeks
  Sponsored by: Axcient

Modified:
  head/usr.sbin/sesutil/sesutil.c

Modified: head/usr.sbin/sesutil/sesutil.c
==
--- head/usr.sbin/sesutil/sesutil.c Tue Nov 12 23:09:55 2019
(r354665)
+++ head/usr.sbin/sesutil/sesutil.c Tue Nov 12 23:57:57 2019
(r354666)
@@ -261,19 +261,19 @@ sesled(int argc, char **argv, bool setfault)
break;
}
for (j = 0; j < nobj; j++) {
+   const int devnames_size = 128;
+   char devnames[devnames_size];
+
if (all) {
do_led(fd, objp[j].elm_idx, objp[j].elm_type,
onoff, setfault);
continue;
}
memset(, 0, sizeof(objdn));
+   memset(devnames, 0, devnames_size);
objdn.elm_idx = objp[j].elm_idx;
-   objdn.elm_names_size = 128;
-   objdn.elm_devnames = calloc(128, sizeof(char));
-   if (objdn.elm_devnames == NULL) {
-   close(fd);
-   xo_err(EXIT_FAILURE, "calloc()");
-   }
+   objdn.elm_names_size = devnames_size;
+   objdn.elm_devnames = devnames;
if (ioctl(fd, ENCIOC_GETELMDEVNAMES,
(caddr_t) ) <0) {
continue;
___
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: r354665 - head/usr.sbin/sesutil

2019-11-12 Thread Alan Somers
Author: asomers
Date: Tue Nov 12 23:09:55 2019
New Revision: 354665
URL: https://svnweb.freebsd.org/changeset/base/354665

Log:
  sesutil: fix some memory leaks
  
  Reported by:  Coverity
  Coverity CID: 1331665
  MFC after:2 weeks
  Sponsored by: Axcient

Modified:
  head/usr.sbin/sesutil/sesutil.c

Modified: head/usr.sbin/sesutil/sesutil.c
==
--- head/usr.sbin/sesutil/sesutil.c Tue Nov 12 23:03:52 2019
(r354664)
+++ head/usr.sbin/sesutil/sesutil.c Tue Nov 12 23:09:55 2019
(r354665)
@@ -242,18 +242,21 @@ sesled(int argc, char **argv, bool setfault)
}
 
if (ioctl(fd, ENCIOC_GETELMMAP, (caddr_t) objp) < 0) {
+   free(objp);
close(fd);
xo_err(EXIT_FAILURE, "ENCIOC_GETELMMAP");
}
 
if (isses) {
if (sesid >= nobj) {
+   free(objp);
close(fd);
xo_errx(EXIT_FAILURE,
 "Requested SES ID does not exist");
}
do_led(fd, sesid, objp[sesid].elm_type, onoff, 
setfault);
ndisks++;
+   free(objp);
close(fd);
break;
}
___
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: r354664 - head/usr.sbin/sesutil

2019-11-12 Thread Alan Somers
Author: asomers
Date: Tue Nov 12 23:03:52 2019
New Revision: 354664
URL: https://svnweb.freebsd.org/changeset/base/354664

Log:
  sesutil: fix an out-of-bounds array access
  
  sesutil would allow the user to toggle an LED that was one past the maximum
  element.  If he tried, ENCIOC_GETELMSTAT would return EINVAL.
  
  Reported by:  Coverity
  Coverity CID: 1398940
  MFC after:2 weeks
  Sponsored by: Axcient

Modified:
  head/usr.sbin/sesutil/sesutil.c

Modified: head/usr.sbin/sesutil/sesutil.c
==
--- head/usr.sbin/sesutil/sesutil.c Tue Nov 12 22:31:59 2019
(r354663)
+++ head/usr.sbin/sesutil/sesutil.c Tue Nov 12 23:03:52 2019
(r354664)
@@ -247,7 +247,7 @@ sesled(int argc, char **argv, bool setfault)
}
 
if (isses) {
-   if (sesid > nobj) {
+   if (sesid >= nobj) {
close(fd);
xo_errx(EXIT_FAILURE,
 "Requested SES ID does not exist");
___
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"


Re: svn commit: r354491 - in head: . lib/msun/src libexec libexec/rtld-elf libexec/rtld-elf32 share/mk usr.bin usr.bin/ldd32

2019-11-12 Thread Guido Falsi
On 12/11/19 23:33, Brooks Davis wrote:
> On Tue, Nov 12, 2019 at 10:14:28PM +0100, Guido Falsi wrote:
>> On 07/11/19 23:58, Brooks Davis wrote:
>>> Author: brooks
>>> Date: Thu Nov  7 22:58:10 2019
>>> New Revision: 354491
>>> URL: https://svnweb.freebsd.org/changeset/base/354491
>>>
>>> Log:
>>>   libcompat: build 32-bit rtld and ldd as part of "everything"
>>>   
>>>   Alter bsd.compat.mk to set MACHINE and MACHINE_ARCH when included
>>>   directly so MD paths in Makefiles work. In the process centralize
>>>   setting them in LIBCOMPATWMAKEENV.
>>>   
>>>   Alter .PATH and CFLAGS settings in work when the Makefile is included.
>>>   
>>>   While here only support LIB32 on supported platforms rather than always
>>>   enabling it and requiring users of MK_LIB32 to filter based
>>>   TARGET/MACHINE_ARCH.
>>>   
>>>   The net effect of this change is to make Makefile.libcompat only build
>>>   compatability libraries.
>>>   
>>>   Changes relative to r354449:
>>>   
>>>   Correct detection of the compiler type when bsd.compat.mk is used
>>>   outside Makefile.libcompat.  Previously it always matched the clang
>>>   case.
>>>   
>>>   Set LDFLAGS including the linker emulation for mips where -m32 seems to
>>>   be insufficent.
>>>   
>>>   Reviewed by:  imp, kib (origional version in r354449)
>>>   Obtained from:CheriBSD (conceptually)
>>>   Sponsored by: DARPA, AFRL
>>>   Differential Revision:https://reviews.freebsd.org/D22251
>>>
>>
>> Hi,
>>
>> I'm using pkgbase on my head machines and I'm getting this when
>> upgrading packages on head now:
>>
>> Checking integrity... done (1 conflicting)
>>   - FreeBSD-clibs-lib32-13.0.s20191112204216 [mpnet-base] conflicts with
>> FreeBSD-clibs-13.0.s20191112204216 [installed] on
>> /usr/share/man/man1/ld-elf.so.1.1.gz
>>
>>
>> So now these packages, which should be able to cohexist conflict on the
>> man page.
>>
>> I'm not sure, but wthis commit looks like a good candidate for causing this.
> 
> It turns out that I'd missed there being an MLINKS variable.  The MAN?=
> part worked as designed but the new code was installing duplication
> links to rtld.1.

I was looking at that, but had no time to test such a fix.

> 
> Should be fixed in r354663.

Thanks a lot for the quick fix!

-- 
Guido Falsi 
___
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"


Re: svn commit: r354491 - in head: . lib/msun/src libexec libexec/rtld-elf libexec/rtld-elf32 share/mk usr.bin usr.bin/ldd32

2019-11-12 Thread Brooks Davis
On Tue, Nov 12, 2019 at 10:14:28PM +0100, Guido Falsi wrote:
> On 07/11/19 23:58, Brooks Davis wrote:
> > Author: brooks
> > Date: Thu Nov  7 22:58:10 2019
> > New Revision: 354491
> > URL: https://svnweb.freebsd.org/changeset/base/354491
> > 
> > Log:
> >   libcompat: build 32-bit rtld and ldd as part of "everything"
> >   
> >   Alter bsd.compat.mk to set MACHINE and MACHINE_ARCH when included
> >   directly so MD paths in Makefiles work. In the process centralize
> >   setting them in LIBCOMPATWMAKEENV.
> >   
> >   Alter .PATH and CFLAGS settings in work when the Makefile is included.
> >   
> >   While here only support LIB32 on supported platforms rather than always
> >   enabling it and requiring users of MK_LIB32 to filter based
> >   TARGET/MACHINE_ARCH.
> >   
> >   The net effect of this change is to make Makefile.libcompat only build
> >   compatability libraries.
> >   
> >   Changes relative to r354449:
> >   
> >   Correct detection of the compiler type when bsd.compat.mk is used
> >   outside Makefile.libcompat.  Previously it always matched the clang
> >   case.
> >   
> >   Set LDFLAGS including the linker emulation for mips where -m32 seems to
> >   be insufficent.
> >   
> >   Reviewed by:  imp, kib (origional version in r354449)
> >   Obtained from:CheriBSD (conceptually)
> >   Sponsored by: DARPA, AFRL
> >   Differential Revision:https://reviews.freebsd.org/D22251
> > 
> 
> Hi,
> 
> I'm using pkgbase on my head machines and I'm getting this when
> upgrading packages on head now:
> 
> Checking integrity... done (1 conflicting)
>   - FreeBSD-clibs-lib32-13.0.s20191112204216 [mpnet-base] conflicts with
> FreeBSD-clibs-13.0.s20191112204216 [installed] on
> /usr/share/man/man1/ld-elf.so.1.1.gz
> 
> 
> So now these packages, which should be able to cohexist conflict on the
> man page.
> 
> I'm not sure, but wthis commit looks like a good candidate for causing this.

It turns out that I'd missed there being an MLINKS variable.  The MAN?=
part worked as designed but the new code was installing duplication
links to rtld.1.

Should be fixed in r354663.

Thanks,
Brooks


signature.asc
Description: PGP signature


svn commit: r354663 - in head: libexec/rtld-elf libexec/rtld-elf32 usr.bin/ldd32

2019-11-12 Thread Brooks Davis
Author: brooks
Date: Tue Nov 12 22:31:59 2019
New Revision: 354663
URL: https://svnweb.freebsd.org/changeset/base/354663

Log:
  libcompat: Correct rtld MLINKS
  
  Don't install duplicate ld-elf.so.1.1 and ld.so.1 links in rtld-elf32.
  Do install lib-elf32.so.1.1 and ldd32.1 links.
  
  Reported by:  madpilot

Modified:
  head/libexec/rtld-elf/Makefile
  head/libexec/rtld-elf32/Makefile
  head/usr.bin/ldd32/Makefile

Modified: head/libexec/rtld-elf/Makefile
==
--- head/libexec/rtld-elf/Makefile  Tue Nov 12 21:35:05 2019
(r354662)
+++ head/libexec/rtld-elf/Makefile  Tue Nov 12 22:31:59 2019
(r354663)
@@ -49,7 +49,7 @@ INSTALLFLAGS= -C -b
 PRECIOUSPROG=
 BINDIR=/libexec
 SYMLINKS=  ../..${BINDIR}/${PROG} ${LIBEXECDIR}/${PROG}
-MLINKS=rtld.1 ld-elf.so.1.1 \
+MLINKS?=   rtld.1 ld-elf.so.1.1 \
rtld.1 ld.so.1
 
 .if ${MACHINE_CPUARCH} == "sparc64"

Modified: head/libexec/rtld-elf32/Makefile
==
--- head/libexec/rtld-elf32/MakefileTue Nov 12 21:35:05 2019
(r354662)
+++ head/libexec/rtld-elf32/MakefileTue Nov 12 22:31:59 2019
(r354663)
@@ -5,6 +5,7 @@ NEED_COMPAT=32
 
 PROG=  ld-elf32.so.1
 MAN=
+MLINKS=rtld.1 ld-elf32.so.1
 
 .PATH:  ${SRCTOP}/libexec/rtld-elf
 .include "${SRCTOP}/libexec/rtld-elf/Makefile"

Modified: head/usr.bin/ldd32/Makefile
==
--- head/usr.bin/ldd32/Makefile Tue Nov 12 21:35:05 2019(r354662)
+++ head/usr.bin/ldd32/Makefile Tue Nov 12 22:31:59 2019(r354663)
@@ -5,6 +5,7 @@ NEED_COMPAT=32
 
 PROG=  ldd32
 MAN=
+MLINKS=ldd.1 ldd32.1
 
 .PATH: ${SRCTOP}/usr.bin/ldd
 .include "${SRCTOP}/usr.bin/ldd/Makefile"
___
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: r354662 - head/lib/clang

2019-11-12 Thread John Baldwin
Author: jhb
Date: Tue Nov 12 21:35:05 2019
New Revision: 354662
URL: https://svnweb.freebsd.org/changeset/base/354662

Log:
  Sync target triple generation with the version in Makefile.inc1.
  
  Reviewed by:  dim
  Sponsored by: DARPA
  Differential Revision:https://reviews.freebsd.org/D22333

Modified:
  head/lib/clang/llvm.build.mk

Modified: head/lib/clang/llvm.build.mk
==
--- head/lib/clang/llvm.build.mkTue Nov 12 21:29:52 2019
(r354661)
+++ head/lib/clang/llvm.build.mkTue Nov 12 21:35:05 2019
(r354662)
@@ -36,8 +36,8 @@ TARGET_ABI=
 VENDOR=unknown
 OS_VERSION=freebsd13.0
 
-LLVM_TARGET_TRIPLE?=   
${TARGET_ARCH:C/amd64/x86_64/:C/arm64/aarch64/}-${VENDOR}-${OS_VERSION}${TARGET_ABI}
-LLVM_BUILD_TRIPLE?=
${BUILD_ARCH:C/amd64/x86_64/:C/arm64/aarch64/}-${VENDOR}-${OS_VERSION}
+LLVM_TARGET_TRIPLE?=   
${TARGET_ARCH:C/amd64/x86_64/:C/[hs]f$//:S/mipsn32/mips64/}-${VENDOR}-${OS_VERSION}${TARGET_ABI}
+LLVM_BUILD_TRIPLE?=
${BUILD_ARCH:C/amd64/x86_64/:C/[hs]f$//:S/mipsn32/mips64/}-${VENDOR}-${OS_VERSION}
 
 CFLAGS+=   -DLLVM_DEFAULT_TARGET_TRIPLE=\"${LLVM_TARGET_TRIPLE}\"
 CFLAGS+=   -DLLVM_HOST_TRIPLE=\"${LLVM_BUILD_TRIPLE}\"
___
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: r354661 - head

2019-11-12 Thread John Baldwin
Author: jhb
Date: Tue Nov 12 21:29:52 2019
New Revision: 354661
URL: https://svnweb.freebsd.org/changeset/base/354661

Log:
  Force MK_CLANG_IS_CC on in XMAKE.
  
  This ensures that a bootstrap clang compiler is always installed as cc
  in WORLDTMP.  If it is only installed as 'clang' then /usr/bin/cc is
  used during the build instead of the bootstrap compiler.
  
  Reviewed by:  imp
  MFC after:1 month
  Sponsored by: DARPA
  Differential Revision:https://reviews.freebsd.org/D22332

Modified:
  head/Makefile.inc1

Modified: head/Makefile.inc1
==
--- head/Makefile.inc1  Tue Nov 12 21:26:50 2019(r354660)
+++ head/Makefile.inc1  Tue Nov 12 21:29:52 2019(r354661)
@@ -734,6 +734,7 @@ TMAKE=  \
 # TOOLS_PREFIX set in BMAKE
 XMAKE= ${BMAKE} \
TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
+   MK_CLANG_IS_CC=yes \
MK_GDB=no MK_TESTS=no
 
 # kernel-tools stage
___
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: r354660 - head/share/mk

2019-11-12 Thread John Baldwin
Author: jhb
Date: Tue Nov 12 21:26:50 2019
New Revision: 354660
URL: https://svnweb.freebsd.org/changeset/base/354660

Log:
  Enable the RISC-V LLVM backend by default.
  
  Reviewed by:  dim, mhorne, emaste
  MFC after:1 month
  Sponsored by: DARPA
  Differential Revision:https://reviews.freebsd.org/D22284

Modified:
  head/share/mk/src.opts.mk

Modified: head/share/mk/src.opts.mk
==
--- head/share/mk/src.opts.mk   Tue Nov 12 21:07:51 2019(r354659)
+++ head/share/mk/src.opts.mk   Tue Nov 12 21:26:50 2019(r354660)
@@ -276,6 +276,7 @@ __LLVM_TARGETS= \
arm \
mips \
powerpc \
+   riscv \
sparc \
x86
 __LLVM_TARGET_FILT=
C/(amd64|i386)/x86/:S/sparc64/sparc/:S/arm64/aarch64/:S/powerpc64/powerpc/
@@ -298,7 +299,6 @@ __DEFAULT_DEPENDENT_OPTIONS+=   LLVM_TARGET_${__llt:${__
 .endfor
 
 __DEFAULT_NO_OPTIONS+=LLVM_TARGET_BPF
-__DEFAULT_NO_OPTIONS+=LLVM_TARGET_RISCV
 
 .include 
 # If the compiler is not C++11 capable, disable Clang and use GCC instead.
@@ -310,7 +310,7 @@ __DEFAULT_NO_OPTIONS+=LLVM_TARGET_RISCV
 # Clang is enabled, and will be installed as the default /usr/bin/cc.
 __DEFAULT_YES_OPTIONS+=CLANG CLANG_BOOTSTRAP CLANG_IS_CC LLD
 __DEFAULT_NO_OPTIONS+=GCC GCC_BOOTSTRAP GNUCXX GPL_DTC
-.elif ${COMPILER_FEATURES:Mc++11} && ${__T:Mriscv*} == "" && ${__T} != 
"sparc64"
+.elif ${COMPILER_FEATURES:Mc++11} && ${__T} != "sparc64"
 # If an external compiler that supports C++11 is used as ${CC} and Clang
 # supports the target, then Clang is enabled but GCC is installed as the
 # default /usr/bin/cc.
___
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"


Re: svn commit: r354491 - in head: . lib/msun/src libexec libexec/rtld-elf libexec/rtld-elf32 share/mk usr.bin usr.bin/ldd32

2019-11-12 Thread Guido Falsi
On 07/11/19 23:58, Brooks Davis wrote:
> Author: brooks
> Date: Thu Nov  7 22:58:10 2019
> New Revision: 354491
> URL: https://svnweb.freebsd.org/changeset/base/354491
> 
> Log:
>   libcompat: build 32-bit rtld and ldd as part of "everything"
>   
>   Alter bsd.compat.mk to set MACHINE and MACHINE_ARCH when included
>   directly so MD paths in Makefiles work. In the process centralize
>   setting them in LIBCOMPATWMAKEENV.
>   
>   Alter .PATH and CFLAGS settings in work when the Makefile is included.
>   
>   While here only support LIB32 on supported platforms rather than always
>   enabling it and requiring users of MK_LIB32 to filter based
>   TARGET/MACHINE_ARCH.
>   
>   The net effect of this change is to make Makefile.libcompat only build
>   compatability libraries.
>   
>   Changes relative to r354449:
>   
>   Correct detection of the compiler type when bsd.compat.mk is used
>   outside Makefile.libcompat.  Previously it always matched the clang
>   case.
>   
>   Set LDFLAGS including the linker emulation for mips where -m32 seems to
>   be insufficent.
>   
>   Reviewed by:imp, kib (origional version in r354449)
>   Obtained from:  CheriBSD (conceptually)
>   Sponsored by:   DARPA, AFRL
>   Differential Revision:  https://reviews.freebsd.org/D22251
> 

Hi,

I'm using pkgbase on my head machines and I'm getting this when
upgrading packages on head now:

Checking integrity... done (1 conflicting)
  - FreeBSD-clibs-lib32-13.0.s20191112204216 [mpnet-base] conflicts with
FreeBSD-clibs-13.0.s20191112204216 [installed] on
/usr/share/man/man1/ld-elf.so.1.1.gz


So now these packages, which should be able to cohexist conflict on the
man page.

I'm not sure, but wthis commit looks like a good candidate for causing this.

Sorry if I'm wrong.

> Modified: head/libexec/rtld-elf/Makefile
> ==
> --- head/libexec/rtld-elf/MakefileThu Nov  7 22:26:54 2019
> (r354490)
> +++ head/libexec/rtld-elf/MakefileThu Nov  7 22:58:10 2019
> (r354491)
> @@ -4,6 +4,8 @@
>  # linker:
>  # make DEBUG_FLAGS=-g WITHOUT_TESTS=yes all
>  
> +RTLD_ELF_DIR:=   ${.PARSEDIR}
> +
>  .include 
>  PACKAGE= clibs
>  MK_PIE=  no # Always position independent using local rules
> @@ -25,16 +27,16 @@ SRCS= \
>   xmalloc.c \
>   debug.c \
>   libmap.c
> -MAN= rtld.1
> +MAN?=rtld.1

Maybe this part is not workking as expected?


-- 
Guido Falsi 
___
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: r354659 - head/usr.sbin/bhyve

2019-11-12 Thread Vincenzo Maffione
Author: vmaffione
Date: Tue Nov 12 21:07:51 2019
New Revision: 354659
URL: https://svnweb.freebsd.org/changeset/base/354659

Log:
  bhyve: rework mevent processing to fix a race condition
  
  At the end of both mevent_add() and mevent_update(), mevent_notify()
  is called to wakeup the I/O thread, that will call kevent(changelist)
  to update the kernel.
  A race condition is possible where the client calls mevent_add() and
  mevent_update(EV_ENABLE) before the I/O thread has the chance to wake
  up and call mevent_build()+kevent(changelist) in response to mevent_add().
  The mevent_add() is therefore ignored by the I/O thread, and
  kevent(fd, EV_ENABLE) is called before kevent(fd, EV_ADD), resuliting
  in a failure of the kevent(fd, EV_ENABLE) call.
  
  PR:   241808
  Reviewed by:  jhb, markj
  MFC with: r354288
  Differential Revision:https://reviews.freebsd.org/D22286

Modified:
  head/usr.sbin/bhyve/mevent.c

Modified: head/usr.sbin/bhyve/mevent.c
==
--- head/usr.sbin/bhyve/mevent.cTue Nov 12 19:35:46 2019
(r354658)
+++ head/usr.sbin/bhyve/mevent.cTue Nov 12 21:07:51 2019
(r354659)
@@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$");
 #endif
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -62,12 +63,6 @@ __FBSDID("$FreeBSD$");
 
 #defineMEVENT_MAX  64
 
-#defineMEV_ADD 1
-#defineMEV_ENABLE  2
-#defineMEV_DISABLE 3
-#defineMEV_DEL_PENDING 4
-#defineMEV_ADD_DISABLED5
-
 extern char *vmname;
 
 static pthread_t mevent_tid;
@@ -83,7 +78,7 @@ struct mevent {
enum ev_type me_type;
void*me_param;
int me_cq;
-   int me_state;
+   int me_state; /* Desired kevent flags. */
int me_closefd;
LIST_ENTRY(mevent) me_list;
 };
@@ -156,30 +151,7 @@ mevent_kq_filter(struct mevent *mevp)
 static int
 mevent_kq_flags(struct mevent *mevp)
 {
-   int ret;
-
-   switch (mevp->me_state) {
-   case MEV_ADD:
-   ret = EV_ADD;   /* implicitly enabled */
-   break;
-   case MEV_ADD_DISABLED:
-   ret = EV_ADD | EV_DISABLE;
-   break;
-   case MEV_ENABLE:
-   ret = EV_ENABLE;
-   break;
-   case MEV_DISABLE:
-   ret = EV_DISABLE;
-   break;
-   case MEV_DEL_PENDING:
-   ret = EV_DELETE;
-   break;
-   default:
-   assert(0);
-   break;
-   }
-
-   return (ret);
+   return (mevp->me_state);
 }
 
 static int
@@ -224,9 +196,15 @@ mevent_build(int mfd, struct kevent *kev)
mevp->me_cq = 0;
LIST_REMOVE(mevp, me_list);
 
-   if (mevp->me_state == MEV_DEL_PENDING) {
+   if (mevp->me_state & EV_DELETE) {
free(mevp);
} else {
+   /*
+* We need to add the event only once, so we can
+* reset the EV_ADD bit after it has been propagated
+* to the kevent() arguments the first time.
+*/
+   mevp->me_state &= ~EV_ADD;
LIST_INSERT_HEAD(_head, mevp, me_list);
}
 
@@ -318,7 +296,7 @@ mevent_add(int tfd, enum ev_type type,
   void (*func)(int, enum ev_type, void *), void *param)
 {
 
-   return mevent_add_state(tfd, type, func, param, MEV_ADD);
+   return (mevent_add_state(tfd, type, func, param, EV_ADD));
 }
 
 struct mevent *
@@ -326,36 +304,46 @@ mevent_add_disabled(int tfd, enum ev_type type,
void (*func)(int, enum ev_type, void *), void *param)
 {
 
-   return mevent_add_state(tfd, type, func, param, MEV_ADD_DISABLED);
+   return (mevent_add_state(tfd, type, func, param, EV_ADD | EV_DISABLE));
 }
 
 static int
-mevent_update(struct mevent *evp, int newstate)
+mevent_update(struct mevent *evp, bool enable)
 {
+   int newstate;
+
+   mevent_qlock();
+
/*
 * It's not possible to enable/disable a deleted event
 */
-   if (evp->me_state == MEV_DEL_PENDING)
-   return (EINVAL);
+   assert((evp->me_state & EV_DELETE) == 0);
 
+   newstate = evp->me_state;
+   if (enable) {
+   newstate |= EV_ENABLE;
+   newstate &= ~EV_DISABLE;
+   } else {
+   newstate |= EV_DISABLE;
+   newstate &= ~EV_ENABLE;
+   }
+
/*
 * No update needed if state isn't changing
 */
-   if (evp->me_state == newstate)
-   return (0);
-   
-   mevent_qlock();
+   if (evp->me_state != newstate) {
+   evp->me_state = newstate;
 
-   evp->me_state = newstate;
-
-   /*
-* Place the entry onto 

svn commit: r354655 - in head/sys/x86: include x86

2019-11-12 Thread Scott Long
Author: scottl
Date: Tue Nov 12 19:15:16 2019
New Revision: 354655
URL: https://svnweb.freebsd.org/changeset/base/354655

Log:
  Add new bit definitions for TSX, related to the TAA issue.  The actual
  mitigation will follow in a future commit.
  
  Sponsored by: Intel

Modified:
  head/sys/x86/include/specialreg.h
  head/sys/x86/x86/identcpu.c

Modified: head/sys/x86/include/specialreg.h
==
--- head/sys/x86/include/specialreg.h   Tue Nov 12 18:13:51 2019
(r354654)
+++ head/sys/x86/include/specialreg.h   Tue Nov 12 19:15:16 2019
(r354655)
@@ -491,7 +491,13 @@
 #defineIA32_ARCH_CAP_SSB_NO0x0010
 #defineIA32_ARCH_CAP_MDS_NO0x0020
 #defineIA32_ARCH_CAP_IF_PSCHANGE_MC_NO 0x0040
+#defineIA32_ARCH_CAP_TSX_CTRL  0x0080
+#defineIA32_ARCH_CAP_TAA_NO0x0100
 
+/* MSR IA32_TSX_CTRL bits */
+#defineIA32_TSX_CTRL_RTM_DISABLE   0x0001
+#defineIA32_TSX_CTRL_TSX_CPUID_CLEAR   0x0002
+
 /*
  * CPUID manufacturers identifiers
  */
@@ -543,6 +549,7 @@
 #defineMSR_BBL_CR_TRIG 0x11a
 #defineMSR_BBL_CR_BUSY 0x11b
 #defineMSR_BBL_CR_CTL3 0x11e
+#defineMSR_IA32_TSX_CTRL   0x122
 #defineMSR_SYSENTER_CS_MSR 0x174
 #defineMSR_SYSENTER_ESP_MSR0x175
 #defineMSR_SYSENTER_EIP_MSR0x176

Modified: head/sys/x86/x86/identcpu.c
==
--- head/sys/x86/x86/identcpu.c Tue Nov 12 18:13:51 2019(r354654)
+++ head/sys/x86/x86/identcpu.c Tue Nov 12 19:15:16 2019(r354655)
@@ -1046,6 +1046,8 @@ printcpuinfo(void)
   "\004SKIP_L1DFL_VME"
   "\005SSB_NO"
   "\006MDS_NO"
+  "\010TSX_CTRL"
+  "\011TAA_NO"
   );
}
 
___
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: r354649 - in head: share/man/man7 sys/amd64/amd64 sys/amd64/include sys/dev/cpuctl sys/x86/include

2019-11-12 Thread Konstantin Belousov
Author: kib
Date: Tue Nov 12 18:01:33 2019
New Revision: 354649
URL: https://svnweb.freebsd.org/changeset/base/354649

Log:
  Workaround for Intel SKL002/SKL012S errata.
  
  Disable the use of executable 2M page mappings in EPT-format page
  tables on affected CPUs.  For bhyve virtual machines, this effectively
  disables all use of superpage mappings on affected CPUs.  The
  vm.pmap.allow_2m_x_ept sysctl can be set to override the default and
  enable mappings on affected CPUs.
  
  Alternate approaches have been suggested, but at present we do not
  believe the complexity is warranted for typical bhyve's use cases.
  
  Reviewed by:  alc, emaste, markj, scottl
  Security: CVE-2018-12207
  Sponsored by: The FreeBSD Foundation
  Differential revision:https://reviews.freebsd.org/D21884

Modified:
  head/share/man/man7/security.7
  head/sys/amd64/amd64/pmap.c
  head/sys/amd64/include/pmap.h
  head/sys/dev/cpuctl/cpuctl.c
  head/sys/x86/include/specialreg.h

Modified: head/share/man/man7/security.7
==
--- head/share/man/man7/security.7  Tue Nov 12 16:24:37 2019
(r354648)
+++ head/share/man/man7/security.7  Tue Nov 12 18:01:33 2019
(r354649)
@@ -28,7 +28,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd August 13, 2019
+.Dd November 12, 2019
 .Dt SECURITY 7
 .Os
 .Sh NAME
@@ -1015,6 +1015,13 @@ hardware information leak.
 .It Dv hw.vmm.vmx.l1d_flush
 amd64.
 Controls the mitigation of L1 Terminal Fault in bhyve hypervisor.
+.It Dv vm.pmap.allow_2m_x_ept
+amd64.
+Allows the use of superpages for executable mappings under the EPT
+page table format used by hypervisors on Intel CPUs to map the guest
+physical address space to machine physical memory.
+May be disabled to work around a CPU Erratum called
+Machine Check Error Avoidance on Page Size Change.
 .It Dv kern.elf32.aslr.enable
 Controls system-global Address Space Layout Randomization (ASLR) for
 normal non-PIE (Position Independent Executable) 32bit binaries.

Modified: head/sys/amd64/amd64/pmap.c
==
--- head/sys/amd64/amd64/pmap.c Tue Nov 12 16:24:37 2019(r354648)
+++ head/sys/amd64/amd64/pmap.c Tue Nov 12 18:01:33 2019(r354649)
@@ -1894,6 +1894,51 @@ pmap_page_init(vm_page_t m)
m->md.pat_mode = PAT_WRITE_BACK;
 }
 
+static int pmap_allow_2m_x_ept;
+SYSCTL_INT(_vm_pmap, OID_AUTO, allow_2m_x_ept, CTLFLAG_RWTUN | CTLFLAG_NOFETCH,
+_allow_2m_x_ept, 0,
+"Allow executable superpage mappings in EPT");
+
+void
+pmap_allow_2m_x_ept_recalculate(void)
+{
+   /*
+* SKL002, SKL012S.  Since the EPT format is only used by
+* Intel CPUs, the vendor check is merely a formality.
+*/
+   if (!(cpu_vendor_id != CPU_VENDOR_INTEL ||
+   (cpu_ia32_arch_caps & IA32_ARCH_CAP_IF_PSCHANGE_MC_NO) != 0 ||
+   (CPUID_TO_FAMILY(cpu_id) == 0x6 &&
+   (CPUID_TO_MODEL(cpu_id) == 0x26 ||  /* Atoms */
+   CPUID_TO_MODEL(cpu_id) == 0x27 ||
+   CPUID_TO_MODEL(cpu_id) == 0x35 ||
+   CPUID_TO_MODEL(cpu_id) == 0x36 ||
+   CPUID_TO_MODEL(cpu_id) == 0x37 ||
+   CPUID_TO_MODEL(cpu_id) == 0x86 ||
+   CPUID_TO_MODEL(cpu_id) == 0x1c ||
+   CPUID_TO_MODEL(cpu_id) == 0x4a ||
+   CPUID_TO_MODEL(cpu_id) == 0x4c ||
+   CPUID_TO_MODEL(cpu_id) == 0x4d ||
+   CPUID_TO_MODEL(cpu_id) == 0x5a ||
+   CPUID_TO_MODEL(cpu_id) == 0x5c ||
+   CPUID_TO_MODEL(cpu_id) == 0x5d ||
+   CPUID_TO_MODEL(cpu_id) == 0x5f ||
+   CPUID_TO_MODEL(cpu_id) == 0x6e ||
+   CPUID_TO_MODEL(cpu_id) == 0x7a ||
+   CPUID_TO_MODEL(cpu_id) == 0x57 ||   /* Knights */
+   CPUID_TO_MODEL(cpu_id) == 0x85
+   pmap_allow_2m_x_ept = 1;
+   TUNABLE_INT_FETCH("hw.allow_2m_x_ept", _allow_2m_x_ept);
+}
+
+static bool
+pmap_allow_2m_x_page(pmap_t pmap, bool executable)
+{
+
+   return (pmap->pm_type != PT_EPT || !executable ||
+   !pmap_allow_2m_x_ept);
+}
+
 #ifdef NUMA
 static void
 pmap_init_pv_table(void)
@@ -2037,6 +2082,9 @@ pmap_init(void)
}
}
 
+   /* IFU */
+   pmap_allow_2m_x_ept_recalculate();
+
/*
 * Initialize the vm page array entries for the kernel pmap's
 * page table pages.
@@ -5718,6 +5766,15 @@ retry:
 }
 
 #if VM_NRESERVLEVEL > 0
+static bool
+pmap_pde_ept_executable(pmap_t pmap, pd_entry_t pde)
+{
+
+   if (pmap->pm_type != PT_EPT)
+   return (false);
+   return ((pde & EPT_PG_EXECUTE) != 0);
+}
+
 /*
  * Tries to promote the 512, contiguous 4KB page mappings that are within a
  * single page table page (PTP) to a single 2MB page mapping.  For promotion
@@ -5753,7 +5810,9 @@ pmap_promote_pde(pmap_t pmap, pd_entry_t *pde, vm_offs
firstpte = (pt_entry_t *)PHYS_TO_DMAP(*pde & PG_FRAME);
 setpde:
newpde = *firstpte;
-   

svn commit: r354648 - head/sys/dev/nvdimm

2019-11-12 Thread D Scott Phillips
Author: scottph
Date: Tue Nov 12 16:24:37 2019
New Revision: 354648
URL: https://svnweb.freebsd.org/changeset/base/354648

Log:
  nvdimm(4): Fix various problems when the using the second label index block
  
  struct nvdimm_label_index is dynamically sized, with the `free`
  bitfield expanding to hold `slot_cnt` entries. Fix a few places
  where we were treating the struct as though it had a fixed sized.
  
  Reviewed by:  cem
  Approved by:  scottl (mentor)
  MFC after:1 week
  Sponsored by: Intel Corporation
  Differential Revision:https://reviews.freebsd.org/D22253

Modified:
  head/sys/dev/nvdimm/nvdimm.c

Modified: head/sys/dev/nvdimm/nvdimm.c
==
--- head/sys/dev/nvdimm/nvdimm.cTue Nov 12 15:56:27 2019
(r354647)
+++ head/sys/dev/nvdimm/nvdimm.cTue Nov 12 16:24:37 2019
(r354648)
@@ -183,7 +183,7 @@ label_index_is_valid(struct nvdimm_label_index *index,
 {
uint64_t checksum;
 
-   index = (struct nvdimm_label_index *)((uint8_t *)index + offset);
+   index = (struct nvdimm_label_index *)((uint8_t *)index + size * offset);
if (strcmp(index->signature, NVDIMM_INDEX_BLOCK_SIGNATURE) != 0)
return false;
checksum = index->checksum;
@@ -242,7 +242,7 @@ read_label(struct nvdimm_dev *nv, int num)
 static int
 read_labels(struct nvdimm_dev *nv)
 {
-   struct nvdimm_label_index *indices;
+   struct nvdimm_label_index *indices, *index1;
size_t bitfield_size, index_size, num_labels;
int error, n;
bool index_0_valid, index_1_valid;
@@ -258,6 +258,7 @@ read_labels(struct nvdimm_dev *nv)
sizeof(struct nvdimm_label);
bitfield_size = roundup2(num_labels, 8) / 8;
indices = malloc(2 * index_size, M_NVDIMM, M_WAITOK);
+   index1 = (void *)((uint8_t *)indices + index_size);
error = read_label_area(nv, (void *)indices, 0, 2 * index_size);
if (error != 0) {
free(indices, M_NVDIMM);
@@ -271,18 +272,29 @@ read_labels(struct nvdimm_dev *nv)
free(indices, M_NVDIMM);
return (ENXIO);
}
-   if (index_0_valid && index_1_valid &&
-   (indices[1].seq > indices[0].seq ||
-   (indices[1].seq == 1 && indices[0].seq == 3)))
-   index_0_valid = false;
+   if (index_0_valid && index_1_valid) {
+   if (((int)indices->seq - (int)index1->seq + 3) % 3 == 1) {
+   /* index 0 was more recently updated */
+   index_1_valid = false;
+   } else {
+   /*
+* either index 1 was more recently updated,
+* or the sequence numbers are equal, in which
+* case the specification says the block with
+* the higher offset is to be treated as valid
+*/
+   index_0_valid = false;
+   }
+   }
nv->label_index = malloc(index_size, M_NVDIMM, M_WAITOK);
-   bcopy(indices + (index_0_valid ? 0 : 1), nv->label_index, index_size);
+   bcopy(index_0_valid ? indices : index1, nv->label_index, index_size);
free(indices, M_NVDIMM);
-   for (bit_ffc_at((bitstr_t *)nv->label_index->free, 0, num_labels, );
-n >= 0;
-bit_ffc_at((bitstr_t *)nv->label_index->free, n + 1, num_labels,
-)) {
+   bit_ffc_at((bitstr_t *)nv->label_index->free, 0,
+   nv->label_index->slot_cnt, );
+   while (n >= 0) {
read_label(nv, n);
+   bit_ffc_at((bitstr_t *)nv->label_index->free, n + 1,
+   nv->label_index->slot_cnt, );
}
return (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: r354647 - in head/sys/i386: i386 include

2019-11-12 Thread Konstantin Belousov
Author: kib
Date: Tue Nov 12 15:56:27 2019
New Revision: 354647
URL: https://svnweb.freebsd.org/changeset/base/354647

Log:
  i386: stop guessing the address of the trap frame in ddb backtrace.
  
  Save the address of the trap frame in %ebp on kernel entry.  This
  automatically provides it in struct i386_frame.f_frame to unwinder.
  
  While there, more accurately handle the terminating frames,
  
  Reviewed by:  avg, markj
  Sponsored by: The FreeBSD Foundation
  MFC after:1 week
  Differential revision:https://reviews.freebsd.org/D22321

Modified:
  head/sys/i386/i386/db_trace.c
  head/sys/i386/include/asmacros.h

Modified: head/sys/i386/i386/db_trace.c
==
--- head/sys/i386/i386/db_trace.c   Tue Nov 12 15:51:47 2019
(r354646)
+++ head/sys/i386/i386/db_trace.c   Tue Nov 12 15:56:27 2019
(r354647)
@@ -297,7 +297,6 @@ db_nextframe(struct i386_frame **fp, db_addr_t *ip, st
 {
struct trapframe *tf;
int frame_type;
-   int narg;
int eip, esp, ebp;
db_expr_t offset;
c_db_sym_t sym;
@@ -317,14 +316,6 @@ db_nextframe(struct i386_frame **fp, db_addr_t *ip, st
 */
frame_type = NORMAL;
 
-   /*
-* This is the number of arguments that a syscall / trap / interrupt
-* service routine passes to its callee.  This number is used only for
-* special frame types.  In most cases there is one argument: the trap
-* frame address.
-*/
-   narg = 1;
-
if (eip >= PMAP_TRM_MIN_ADDRESS) {
sym = db_search_symbol(eip - 1 - setidt_disp, DB_STGY_ANY,
);
@@ -338,8 +329,6 @@ db_nextframe(struct i386_frame **fp, db_addr_t *ip, st
frame_type = TRAP;
else if (strncmp(name, "Xatpic_intr", 11) == 0 ||
strncmp(name, "Xapic_isr", 9) == 0) {
-   /* Additional argument: vector number. */
-   narg = 2;
frame_type = INTERRUPT;
} else if (strcmp(name, "Xlcall_syscall") == 0 ||
strcmp(name, "Xint0x80_syscall") == 0)
@@ -353,7 +342,6 @@ db_nextframe(struct i386_frame **fp, db_addr_t *ip, st
strcmp(name, "Xrendezvous") == 0 ||
strcmp(name, "Xipi_intr_bitmap_handler") == 0) {
/* No arguments. */
-   narg = 0;
frame_type = INTERRUPT;
}
}
@@ -387,13 +375,23 @@ db_nextframe(struct i386_frame **fp, db_addr_t *ip, st
}
 
/*
-* Point to base of trapframe which is just above the
-* current frame.  Note that struct i386_frame already accounts for one
-* argument.
+* Point to base of trapframe which is just above the current
+* frame.  Pointer to it was put into %ebp by the kernel entry
+* code.
 */
-   tf = (struct trapframe *)((char *)*fp + sizeof(struct i386_frame) +
-   4 * (narg - 1));
+   tf = (struct trapframe *)(*fp)->f_frame;
 
+   /*
+* This can be the case for e.g. fork_trampoline, last frame
+* of a kernel thread stack.
+*/
+   if (tf == NULL) {
+   *ip = 0;
+   *fp = 0;
+   db_printf("--- kthread start\n");
+   return;
+   }
+
esp = get_esp(tf);
eip = tf->tf_eip;
ebp = tf->tf_ebp;
@@ -413,15 +411,20 @@ db_nextframe(struct i386_frame **fp, db_addr_t *ip, st
}
db_printf(", eip = %#r, esp = %#r, ebp = %#r ---\n", eip, esp, ebp);
 
+   /*
+* Detect the last (trap) frame on the kernel stack, where we
+* entered kernel from usermode.  Terminate tracing in this
+* case.
+*/
switch (frame_type) {
case TRAP:
case INTERRUPT:
-   if ((tf->tf_eflags & PSL_VM) != 0 ||
-   (tf->tf_cs & SEL_RPL_MASK) != 0)
-   ebp = 0;
-   break;
+   if (!TRAPF_USERMODE(tf))
+   break;
+   /* FALLTHROUGH */
case SYSCALL:
ebp = 0;
+   eip = 0;
break;
}
 
@@ -575,9 +578,12 @@ out:
 * after printing the pc if it is the kernel.
 */
if (frame == NULL || frame <= actframe) {
-   sym = db_search_symbol(pc, DB_STGY_ANY, );
-   db_symbol_values(sym, , NULL);
-   db_print_stack_entry(name, 0, 0, 0, pc, frame);
+   if (pc != 0) {
+   sym = db_search_symbol(pc, DB_STGY_ANY,
+   );
+   db_symbol_values(sym, , NULL);
+   db_print_stack_entry(name, 0, 0, 0, pc, frame);
+   

svn commit: r354646 - in head/sys: amd64/amd64 amd64/include amd64/vmm cddl/contrib/opensolaris/uts/intel/dtrace

2019-11-12 Thread Konstantin Belousov
Author: kib
Date: Tue Nov 12 15:51:47 2019
New Revision: 354646
URL: https://svnweb.freebsd.org/changeset/base/354646

Log:
  amd64: move GDT into PCPU area.
  
  Reviewed by:  jhb, markj
  Tested by:pho
  Sponsored by: The FreeBSD Foundation
  MFC after:1 week
  Differential revision:https://reviews.freebsd.org/D22302

Modified:
  head/sys/amd64/amd64/machdep.c
  head/sys/amd64/amd64/mp_machdep.c
  head/sys/amd64/amd64/pmap.c
  head/sys/amd64/amd64/trap.c
  head/sys/amd64/include/pcpu.h
  head/sys/amd64/include/segments.h
  head/sys/amd64/vmm/vmm_host.h
  head/sys/cddl/contrib/opensolaris/uts/intel/dtrace/fasttrap_isa.c

Modified: head/sys/amd64/amd64/machdep.c
==
--- head/sys/amd64/amd64/machdep.c  Tue Nov 12 15:50:30 2019
(r354645)
+++ head/sys/amd64/amd64/machdep.c  Tue Nov 12 15:51:47 2019
(r354646)
@@ -658,8 +658,6 @@ cpu_setregs(void)
 /*
  * Initialize segments & interrupt table
  */
-
-struct user_segment_descriptor gdt[NGDT * MAXCPU];/* global descriptor tables 
*/
 static struct gate_descriptor idt0[NIDT];
 struct gate_descriptor *idt = [0];/* interrupt descriptor table */
 
@@ -1546,8 +1544,10 @@ amd64_conf_fast_syscall(void)
 void
 amd64_bsp_pcpu_init1(struct pcpu *pc)
 {
+   struct user_segment_descriptor *gdt;
 
PCPU_SET(prvspace, pc);
+   gdt = *PCPU_PTR(gdt);
PCPU_SET(curthread, );
PCPU_SET(tssp, PCPU_PTR(common_tss));
PCPU_SET(tss, (struct system_segment_descriptor *)[GPROC0_SEL]);
@@ -1610,6 +1610,7 @@ hammer_time(u_int64_t modulep, u_int64_t physfree)
struct xstate_hdr *xhdr;
u_int64_t rsp0;
char *env;
+   struct user_segment_descriptor *gdt;
struct region_descriptor r_gdt;
size_t kstack0_sz;
int late_console;
@@ -1667,6 +1668,8 @@ hammer_time(u_int64_t modulep, u_int64_t physfree)
pmap_thread_init_invl_gen();
 
pc = _bsp_pcpu;
+   pcpu_init(pc, 0, sizeof(struct pcpu));
+   gdt = _bsp_pcpu.pc_gdt[0];
 
/*
 * make gdt memory segments
@@ -1681,14 +1684,13 @@ hammer_time(u_int64_t modulep, u_int64_t physfree)
(struct system_segment_descriptor *)[GPROC0_SEL]);
 
r_gdt.rd_limit = NGDT * sizeof(gdt[0]) - 1;
-   r_gdt.rd_base =  (long) gdt;
+   r_gdt.rd_base = (long)gdt;
lgdt(_gdt);
 
wrmsr(MSR_FSBASE, 0);   /* User value */
wrmsr(MSR_GSBASE, (u_int64_t)pc);
wrmsr(MSR_KGSBASE, 0);  /* User value while in the kernel */
 
-   pcpu_init(pc, 0, sizeof(struct pcpu));
dpcpu_init((void *)(physfree + KERNBASE), 0);
physfree += DPCPU_SIZE;
amd64_bsp_pcpu_init1(pc);

Modified: head/sys/amd64/amd64/mp_machdep.c
==
--- head/sys/amd64/amd64/mp_machdep.c   Tue Nov 12 15:50:30 2019
(r354645)
+++ head/sys/amd64/amd64/mp_machdep.c   Tue Nov 12 15:51:47 2019
(r354646)
@@ -275,9 +275,10 @@ init_secondary(void)
 {
struct pcpu *pc;
struct nmi_pcpu *np;
+   struct user_segment_descriptor *gdt;
+   struct region_descriptor ap_gdt;
u_int64_t cr0;
int cpu, gsel_tss, x;
-   struct region_descriptor ap_gdt;
 
/* Set by the startup code for us to use */
cpu = bootAP;
@@ -298,12 +299,11 @@ init_secondary(void)
pc->pc_rsp0 = 0;
pc->pc_pti_rsp0 = (((vm_offset_t)>pc_pti_stack +
PC_PTI_STACK_SZ * sizeof(uint64_t)) & ~0xful);
-   pc->pc_tss = (struct system_segment_descriptor *)[NGDT * cpu +
-   GPROC0_SEL];
-   pc->pc_fs32p = [NGDT * cpu + GUFS32_SEL];
-   pc->pc_gs32p = [NGDT * cpu + GUGS32_SEL];
-   pc->pc_ldt = (struct system_segment_descriptor *)[NGDT * cpu +
-   GUSERLDT_SEL];
+   gdt = pc->pc_gdt;
+   pc->pc_tss = (struct system_segment_descriptor *)[GPROC0_SEL];
+   pc->pc_fs32p = [GUFS32_SEL];
+   pc->pc_gs32p = [GUGS32_SEL];
+   pc->pc_ldt = (struct system_segment_descriptor *)[GUSERLDT_SEL];
/* See comment in pmap_bootstrap(). */
pc->pc_pcid_next = PMAP_PCID_KERN + 2;
pc->pc_pcid_gen = 1;
@@ -331,14 +331,14 @@ init_secondary(void)
/* Prepare private GDT */
gdt_segs[GPROC0_SEL].ssd_base = (long)>pc_common_tss;
for (x = 0; x < NGDT; x++) {
-   if (x != GPROC0_SEL && x != (GPROC0_SEL + 1) &&
-   x != GUSERLDT_SEL && x != (GUSERLDT_SEL + 1))
-   ssdtosd(_segs[x], [NGDT * cpu + x]);
+   if (x != GPROC0_SEL && x != GPROC0_SEL + 1 &&
+   x != GUSERLDT_SEL && x != GUSERLDT_SEL + 1)
+   ssdtosd(_segs[x], [x]);
}
ssdtosyssd(_segs[GPROC0_SEL],
-   (struct system_segment_descriptor *)[NGDT * cpu + GPROC0_SEL]);
+   (struct system_segment_descriptor *)[GPROC0_SEL]);

svn commit: r354645 - head/sys/dev/nvdimm

2019-11-12 Thread D Scott Phillips
Author: scottph
Date: Tue Nov 12 15:50:30 2019
New Revision: 354645
URL: https://svnweb.freebsd.org/changeset/base/354645

Log:
  nvdimm(4): Only expose namespaces for accessible data SPAs
  
  Apply the same user accessible filter to namespaces as is applied
  to full-SPA devices. Also, explicitly filter out control region
  SPAs which don't expose the nvdimm data area.
  
  Reviewed by:  cem
  Approved by:  scottl (mentor)
  MFC after:1 week
  Sponsored by: Intel Corporation
  Differential Revision:https://reviews.freebsd.org/D21987

Modified:
  head/sys/dev/nvdimm/nvdimm_acpi.c
  head/sys/dev/nvdimm/nvdimm_spa.c
  head/sys/dev/nvdimm/nvdimm_var.h

Modified: head/sys/dev/nvdimm/nvdimm_acpi.c
==
--- head/sys/dev/nvdimm/nvdimm_acpi.c   Tue Nov 12 15:47:46 2019
(r354644)
+++ head/sys/dev/nvdimm/nvdimm_acpi.c   Tue Nov 12 15:50:30 2019
(r354645)
@@ -144,7 +144,9 @@ nvdimm_root_create_spas(struct nvdimm_root_dev *dev, A
free(spa_mapping, M_NVDIMM_ACPI);
break;
}
-   nvdimm_create_namespaces(spa_mapping, nfitbl);
+   if (nvdimm_spa_type_user_accessible(spa_type) &&
+   spa_type != SPA_TYPE_CONTROL_REGION)
+   nvdimm_create_namespaces(spa_mapping, nfitbl);
SLIST_INSERT_HEAD(>spas, spa_mapping, link);
}
free(spas, M_NVDIMM_ACPI);

Modified: head/sys/dev/nvdimm/nvdimm_spa.c
==
--- head/sys/dev/nvdimm/nvdimm_spa.cTue Nov 12 15:47:46 2019
(r354644)
+++ head/sys/dev/nvdimm/nvdimm_spa.cTue Nov 12 15:50:30 2019
(r354645)
@@ -155,6 +155,15 @@ nvdimm_spa_type_from_uuid(struct uuid *uuid)
return (SPA_TYPE_UNKNOWN);
 }
 
+bool
+nvdimm_spa_type_user_accessible(enum SPA_mapping_type spa_type)
+{
+
+   if ((int)spa_type < 0 || spa_type >= nitems(nvdimm_SPA_uuid_list))
+   return (false);
+   return (nvdimm_SPA_uuid_list[spa_type].u_usr_acc);
+}
+
 static vm_memattr_t
 nvdimm_spa_memattr(uint64_t efi_mem_flags)
 {

Modified: head/sys/dev/nvdimm/nvdimm_var.h
==
--- head/sys/dev/nvdimm/nvdimm_var.hTue Nov 12 15:47:46 2019
(r354644)
+++ head/sys/dev/nvdimm/nvdimm_var.hTue Nov 12 15:50:30 2019
(r354645)
@@ -166,6 +166,7 @@ void acpi_nfit_get_flush_addrs(ACPI_TABLE_NFIT *nfitbl
 uint64_t ***listp, int *countp);
 enum SPA_mapping_type nvdimm_spa_type_from_name(const char *);
 enum SPA_mapping_type nvdimm_spa_type_from_uuid(struct uuid *);
+bool nvdimm_spa_type_user_accessible(enum SPA_mapping_type);
 struct nvdimm_dev *nvdimm_find_by_handle(nfit_handle_t nv_handle);
 int nvdimm_spa_init(struct SPA_mapping *spa, ACPI_NFIT_SYSTEM_ADDRESS 
*nfitaddr,
 enum SPA_mapping_type spa_type);
___
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: r354644 - head/sys/amd64/amd64

2019-11-12 Thread Konstantin Belousov
Author: kib
Date: Tue Nov 12 15:47:46 2019
New Revision: 354644
URL: https://svnweb.freebsd.org/changeset/base/354644

Log:
  amd64: assert that size of the software prototype table for gdt is equal
  to the size of hardware gdt.
  
  Reviewed by:  jhb, markj
  Tested by:pho
  Sponsored by: The FreeBSD Foundation
  MFC after:1 week
  Differential revision:https://reviews.freebsd.org/D22302

Modified:
  head/sys/amd64/amd64/machdep.c

Modified: head/sys/amd64/amd64/machdep.c
==
--- head/sys/amd64/amd64/machdep.c  Tue Nov 12 15:46:28 2019
(r354643)
+++ head/sys/amd64/amd64/machdep.c  Tue Nov 12 15:47:46 2019
(r354644)
@@ -794,6 +794,7 @@ struct soft_segment_descriptor gdt_segs[] = {
.ssd_def32 = 0,
.ssd_gran = 0   },
 };
+_Static_assert(nitems(gdt_segs) == NGDT, "Stale NGDT");
 
 void
 setidt(int idx, inthand_t *func, int typ, int dpl, int ist)
___
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: r354643 - in head/sys: netinet netinet6

2019-11-12 Thread Bjoern A. Zeeb
Author: bz
Date: Tue Nov 12 15:46:28 2019
New Revision: 354643
URL: https://svnweb.freebsd.org/changeset/base/354643

Log:
  netinet*: update *mp to pass the proper value back
  
  In ip6_[direct_]input() we are looping over the extension headers
  to deal with the next header.  We pass a pointer to an mbuf pointer
  to the handling functions.  In certain cases the mbuf can be updated
  there and we need to pass the new one back.  That missing in
  dest6_input() and route6_input().  In tcp6_input() we should also
  update it before we call tcp_input().
  
  In addition to that mark the mbuf NULL all the times when we return
  that we are done with handling the packet and no next header should
  be checked (IPPROTO_DONE).  This will eventually allow us to assert
  proper behaviour and catch the above kind of errors more easily,
  expecting *mp to always be set.
  
  This change is extracted from a larger patch and not an exhaustive
  change across the entire stack yet.
  
  PR:   240135
  Reported by:  prabhakar.lakhera gmail.com
  MFC after:3 weeks
  Sponsored by: Netflix

Modified:
  head/sys/netinet/tcp_input.c
  head/sys/netinet6/dest6.c
  head/sys/netinet6/frag6.c
  head/sys/netinet6/icmp6.c
  head/sys/netinet6/ip6_input.c
  head/sys/netinet6/route6.c
  head/sys/netinet6/udp6_usrreq.c

Modified: head/sys/netinet/tcp_input.c
==
--- head/sys/netinet/tcp_input.cTue Nov 12 15:34:19 2019
(r354642)
+++ head/sys/netinet/tcp_input.cTue Nov 12 15:46:28 2019
(r354643)
@@ -530,11 +530,13 @@ tcp6_input(struct mbuf **mp, int *offp, int proto)
ifa_free(>ia_ifa);
icmp6_error(m, ICMP6_DST_UNREACH, ICMP6_DST_UNREACH_ADDR,
(caddr_t)>ip6_dst - (caddr_t)ip6);
+   *mp = NULL;
return (IPPROTO_DONE);
}
if (ia6)
ifa_free(>ia_ifa);
 
+   *mp = m;
return (tcp_input(mp, offp, proto));
 }
 #endif /* INET6 */

Modified: head/sys/netinet6/dest6.c
==
--- head/sys/netinet6/dest6.c   Tue Nov 12 15:34:19 2019(r354642)
+++ head/sys/netinet6/dest6.c   Tue Nov 12 15:46:28 2019(r354643)
@@ -113,17 +113,21 @@ dest6_input(struct mbuf **mp, int *offp, int proto)
default:/* unknown option */
optlen = ip6_unknown_opt(opt, m,
opt - mtod(m, u_int8_t *));
-   if (optlen == -1)
+   if (optlen == -1) {
+   *mp = NULL;
return (IPPROTO_DONE);
+   }
optlen += 2;
break;
}
}
 
*offp = off;
+   *mp = m;
return (dstopts->ip6d_nxt);
 
   bad:
m_freem(m);
+   *mp = NULL;
return (IPPROTO_DONE);
 }

Modified: head/sys/netinet6/frag6.c
==
--- head/sys/netinet6/frag6.c   Tue Nov 12 15:34:19 2019(r354642)
+++ head/sys/netinet6/frag6.c   Tue Nov 12 15:46:28 2019(r354643)
@@ -419,6 +419,7 @@ frag6_input(struct mbuf **mp, int *offp, int proto)
if (ip6->ip6_plen == 0) {
icmp6_error(m, ICMP6_PARAM_PROB, ICMP6_PARAMPROB_HEADER, 
offset);
in6_ifstat_inc(dstifp, ifs6_reass_fail);
+   *mp = NULL;
return (IPPROTO_DONE);
}
 
@@ -433,6 +434,7 @@ frag6_input(struct mbuf **mp, int *offp, int proto)
icmp6_error(m, ICMP6_PARAM_PROB, ICMP6_PARAMPROB_HEADER,
offsetof(struct ip6_hdr, ip6_plen));
in6_ifstat_inc(dstifp, ifs6_reass_fail);
+   *mp = NULL;
return (IPPROTO_DONE);
}
 
@@ -476,6 +478,7 @@ frag6_input(struct mbuf **mp, int *offp, int proto)
offsetof(struct ip6_hdr, ip6_plen));
in6_ifstat_inc(dstifp, ifs6_reass_fail);
IP6STAT_INC(ip6s_fragdropped);
+   *mp = NULL;
return (IPPROTO_DONE);
}
 
@@ -611,6 +614,7 @@ frag6_input(struct mbuf **mp, int *offp, int proto)
icmp6_error(m, ICMP6_PARAM_PROB, ICMP6_PARAMPROB_HEADER,
offset - sizeof(struct ip6_frag) +
offsetof(struct ip6_frag, ip6f_offlg));
+   *mp = NULL;
return (IPPROTO_DONE);
}
} else if (fragoff + frgpartlen > IPV6_MAXPACKET) {
@@ -627,6 +631,7 @@ frag6_input(struct mbuf **mp, int *offp, int proto)
icmp6_error(m, ICMP6_PARAM_PROB, ICMP6_PARAMPROB_HEADER,
offset - sizeof(struct ip6_frag) +
offsetof(struct 

svn commit: r354639 - head/usr.bin/netstat

2019-11-12 Thread Bjoern A. Zeeb
Author: bz
Date: Tue Nov 12 13:57:17 2019
New Revision: 354639
URL: https://svnweb.freebsd.org/changeset/base/354639

Log:
  netstat: igmp stats, error on unexpected information, not only warn
  
  The igmp stats tend to print two lines of warning for an unexpected
  version and length.  Despite an invalid version and struct size it
  continues to try to do something with the data.  Do not try to parse
  the remainder of the struct and error on warning.
  
  Note the underlying issue of the data not being available properly
  is still there and needs to be fixed seperately.
  
  Reported by:  test cases, lwhsu
  MFC after:3 weeks

Modified:
  head/usr.bin/netstat/inet.c

Modified: head/usr.bin/netstat/inet.c
==
--- head/usr.bin/netstat/inet.c Tue Nov 12 11:00:01 2019(r354638)
+++ head/usr.bin/netstat/inet.c Tue Nov 12 13:57:17 2019(r354639)
@@ -1230,10 +1230,12 @@ igmp_stats(u_long off, const char *name, int af1 __unu
if (igmpstat.igps_version != IGPS_VERSION_3) {
xo_warnx("%s: version mismatch (%d != %d)", __func__,
igmpstat.igps_version, IGPS_VERSION_3);
+   return;
}
if (igmpstat.igps_len != IGPS_VERSION3_LEN) {
xo_warnx("%s: size mismatch (%d != %d)", __func__,
igmpstat.igps_len, IGPS_VERSION3_LEN);
+   return;
}
 
xo_open_container(name);
___
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: r354638 - in head/sys: amd64/amd64 i386/i386

2019-11-12 Thread Andriy Gapon
Author: avg
Date: Tue Nov 12 11:00:01 2019
New Revision: 354638
URL: https://svnweb.freebsd.org/changeset/base/354638

Log:
  teach db_nextframe/x86 about [X]xen_intr_upcall interrupt handler
  
  Discussed with:   kib, royger
  MFC after:3 weeks
  Sponsored by: Panzura

Modified:
  head/sys/amd64/amd64/db_trace.c
  head/sys/i386/i386/db_trace.c

Modified: head/sys/amd64/amd64/db_trace.c
==
--- head/sys/amd64/amd64/db_trace.c Tue Nov 12 10:31:28 2019
(r354637)
+++ head/sys/amd64/amd64/db_trace.c Tue Nov 12 11:00:01 2019
(r354638)
@@ -203,6 +203,7 @@ db_nextframe(struct amd64_frame **fp, db_addr_t *ip, s
frame_type = TRAP;
else if (strncmp(name, "Xatpic_intr", 11) == 0 ||
strncmp(name, "Xapic_isr", 9) == 0 ||
+   strcmp(name, "Xxen_intr_upcall") == 0 ||
strcmp(name, "Xtimerint") == 0 ||
strcmp(name, "Xipi_intr_bitmap_handler") == 0 ||
strcmp(name, "Xcpustop") == 0 ||

Modified: head/sys/i386/i386/db_trace.c
==
--- head/sys/i386/i386/db_trace.c   Tue Nov 12 10:31:28 2019
(r354637)
+++ head/sys/i386/i386/db_trace.c   Tue Nov 12 11:00:01 2019
(r354638)
@@ -346,7 +346,8 @@ db_nextframe(struct i386_frame **fp, db_addr_t *ip, st
frame_type = SYSCALL;
else if (strcmp(name, "dblfault_handler") == 0)
frame_type = DOUBLE_FAULT;
-   else if (strcmp(name, "Xtimerint") == 0)
+   else if (strcmp(name, "Xtimerint") == 0 ||
+   strcmp(name, "Xxen_intr_upcall") == 0)
frame_type = INTERRUPT;
else if (strcmp(name, "Xcpustop") == 0 ||
strcmp(name, "Xrendezvous") == 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: r354637 - head/sys/x86/xen

2019-11-12 Thread Roger Pau Monné
Author: royger
Date: Tue Nov 12 10:31:28 2019
New Revision: 354637
URL: https://svnweb.freebsd.org/changeset/base/354637

Log:
  xen: fix dispatching of NMIs
  
  Currently NMIs are sent over event channels, but that defeats the
  purpose of NMIs since event channels can be masked. Fix this by
  issuing NMIs using a hypercall, which injects a NMI (vector #2) to the
  desired vCPU.
  
  Note that NMIs could also be triggered using the emulated local APIC,
  but using a hypercall is better from a performance point of view
  since it doesn't involve instruction decoding when not using x2APIC
  mode.
  
  Reported and Tested by:   avg
  Sponsored by: Citrix Systems R

Modified:
  head/sys/x86/xen/xen_apic.c

Modified: head/sys/x86/xen/xen_apic.c
==
--- head/sys/x86/xen/xen_apic.c Tue Nov 12 10:22:48 2019(r354636)
+++ head/sys/x86/xen/xen_apic.c Tue Nov 12 10:31:28 2019(r354637)
@@ -72,7 +72,6 @@ static driver_filter_t xen_invlcache;
 static driver_filter_t xen_ipi_bitmap_handler;
 static driver_filter_t xen_cpustop_handler;
 static driver_filter_t xen_cpususpend_handler;
-static driver_filter_t xen_cpustophard_handler;
 #endif
 
 /*-- Macros 
--*/
@@ -96,7 +95,6 @@ static struct xen_ipi_handler xen_ipis[] = 
[IPI_TO_IDX(IPI_BITMAP_VECTOR)] = { xen_ipi_bitmap_handler, "b"   },
[IPI_TO_IDX(IPI_STOP)]  = { xen_cpustop_handler,"st"  },
[IPI_TO_IDX(IPI_SUSPEND)]   = { xen_cpususpend_handler, "sp"  },
-   [IPI_TO_IDX(IPI_STOP_HARD)] = { xen_cpustophard_handler,"sth" },
 };
 #endif
 
@@ -259,12 +257,52 @@ xen_pv_lapic_ipi_raw(register_t icrlo, u_int dest)
XEN_APIC_UNSUPPORTED;
 }
 
+#define PCPU_ID_GET(id, field) (pcpu_find(id)->pc_##field)
 static void
+send_nmi(int dest)
+{
+   unsigned int cpu;
+
+   /*
+* NMIs are not routed over event channels, and instead delivered as on
+* native using the exception vector (#2). Triggering them can be done
+* using the local APIC, or an hypercall as a shortcut like it's done
+* below.
+*/
+   switch(dest) {
+   case APIC_IPI_DEST_SELF:
+   HYPERVISOR_vcpu_op(VCPUOP_send_nmi, PCPU_GET(vcpu_id), NULL);
+   break;
+   case APIC_IPI_DEST_ALL:
+   CPU_FOREACH(cpu)
+   HYPERVISOR_vcpu_op(VCPUOP_send_nmi,
+   PCPU_ID_GET(cpu, vcpu_id), NULL);
+   break;
+   case APIC_IPI_DEST_OTHERS:
+   CPU_FOREACH(cpu)
+   if (cpu != PCPU_GET(cpuid))
+   HYPERVISOR_vcpu_op(VCPUOP_send_nmi,
+   PCPU_ID_GET(cpu, vcpu_id), NULL);
+   break;
+   default:
+   HYPERVISOR_vcpu_op(VCPUOP_send_nmi,
+   PCPU_ID_GET(apic_cpuid(dest), vcpu_id), NULL);
+   break;
+   }
+}
+#undef PCPU_ID_GET
+
+static void
 xen_pv_lapic_ipi_vectored(u_int vector, int dest)
 {
xen_intr_handle_t *ipi_handle;
int ipi_idx, to_cpu, self;
 
+   if (vector >= IPI_NMI_FIRST) {
+   send_nmi(dest);
+   return;
+   }
+
ipi_idx = IPI_TO_IDX(vector);
if (ipi_idx >= nitems(xen_ipis))
panic("IPI out of range");
@@ -519,14 +557,6 @@ xen_cpususpend_handler(void *arg)
 {
 
cpususpend_handler();
-   return (FILTER_HANDLED);
-}
-
-static int
-xen_cpustophard_handler(void *arg)
-{
-
-   ipi_nmi_handler();
return (FILTER_HANDLED);
 }
 
___
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: r354635 - head/stand/libsa/zfs

2019-11-12 Thread Toomas Soome
Author: tsoome
Date: Tue Nov 12 10:02:39 2019
New Revision: 354635
URL: https://svnweb.freebsd.org/changeset/base/354635

Log:
  reverting r354594
  
  In our case the structure is more complex and simple static initializer
  will upset compiler diagnostics - using memset is still better than building
  more complext initializer.

Modified:
  head/stand/libsa/zfs/zfsimpl.c

Modified: head/stand/libsa/zfs/zfsimpl.c
==
--- head/stand/libsa/zfs/zfsimpl.c  Tue Nov 12 09:54:48 2019
(r354634)
+++ head/stand/libsa/zfs/zfsimpl.c  Tue Nov 12 10:02:39 2019
(r354635)
@@ -1697,7 +1697,7 @@ vdev_uberblock_load(vdev_t *vd, uberblock_t *ub)
 static int
 vdev_probe(vdev_phys_read_t *_read, void *read_priv, spa_t **spap)
 {
-   vdev_t vtmp = { 0 };
+   vdev_t vtmp;
spa_t *spa;
vdev_t *vdev, *top_vdev, *pool_vdev;
unsigned char *nvlist;
@@ -1713,6 +1713,7 @@ vdev_probe(vdev_phys_read_t *_read, void *read_priv, s
 * Load the vdev label and figure out which
 * uberblock is most current.
 */
+   memset(, 0, sizeof(vtmp));
vtmp.v_phys_read = _read;
vtmp.v_read_priv = read_priv;
vtmp.v_psize = P2ALIGN(ldi_get_size(read_priv),
___
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"