CVS commit: src/sys/arch/amd64/include
Module Name:src Committed By: maxv Date: Fri Nov 1 15:11:43 UTC 2019 Modified Files: src/sys/arch/amd64/include: pmap.h Log Message: Fix KUBSAN: the kernel size now exceeds the mapping limit, so bump the limit. To generate a diff of this commit: cvs rdiff -u -r1.62 -r1.63 src/sys/arch/amd64/include/pmap.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/amd64/include/pmap.h diff -u src/sys/arch/amd64/include/pmap.h:1.62 src/sys/arch/amd64/include/pmap.h:1.63 --- src/sys/arch/amd64/include/pmap.h:1.62 Wed Aug 7 06:23:48 2019 +++ src/sys/arch/amd64/include/pmap.h Fri Nov 1 15:11:43 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.h,v 1.62 2019/08/07 06:23:48 maxv Exp $ */ +/* $NetBSD: pmap.h,v 1.63 2019/11/01 15:11:43 maxv Exp $ */ /* * Copyright (c) 1997 Charles D. Cranor and Washington University. @@ -68,6 +68,7 @@ #if defined(_KERNEL_OPT) #include "opt_xen.h" #include "opt_kasan.h" +#include "opt_kubsan.h" #endif #include @@ -139,7 +140,11 @@ extern pt_entry_t *pte_base; #define NKL4_KIMG_ENTRIES 1 #define NKL3_KIMG_ENTRIES 1 +#if defined(KUBSAN) +#define NKL2_KIMG_ENTRIES 64 /* really big kernel */ +#else #define NKL2_KIMG_ENTRIES 48 +#endif /* * Since kva space is below the kernel in its entirety, we start off
CVS commit: src/sys/arch/amd64/include
Module Name:src Committed By: maxv Date: Fri Nov 1 15:11:43 UTC 2019 Modified Files: src/sys/arch/amd64/include: pmap.h Log Message: Fix KUBSAN: the kernel size now exceeds the mapping limit, so bump the limit. To generate a diff of this commit: cvs rdiff -u -r1.62 -r1.63 src/sys/arch/amd64/include/pmap.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch
Module Name:src Committed By: maxv Date: Wed Oct 30 17:06:57 UTC 2019 Modified Files: src/sys/arch/amd64/amd64: cpufunc.S src/sys/arch/i386/i386: cpufunc.S src/sys/arch/x86/include: cpufunc.h Log Message: More inlined ASM. To generate a diff of this commit: cvs rdiff -u -r1.45 -r1.46 src/sys/arch/amd64/amd64/cpufunc.S cvs rdiff -u -r1.35 -r1.36 src/sys/arch/i386/i386/cpufunc.S cvs rdiff -u -r1.36 -r1.37 src/sys/arch/x86/include/cpufunc.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch
Module Name:src Committed By: maxv Date: Wed Oct 30 17:06:57 UTC 2019 Modified Files: src/sys/arch/amd64/amd64: cpufunc.S src/sys/arch/i386/i386: cpufunc.S src/sys/arch/x86/include: cpufunc.h Log Message: More inlined ASM. To generate a diff of this commit: cvs rdiff -u -r1.45 -r1.46 src/sys/arch/amd64/amd64/cpufunc.S cvs rdiff -u -r1.35 -r1.36 src/sys/arch/i386/i386/cpufunc.S cvs rdiff -u -r1.36 -r1.37 src/sys/arch/x86/include/cpufunc.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/amd64/amd64/cpufunc.S diff -u src/sys/arch/amd64/amd64/cpufunc.S:1.45 src/sys/arch/amd64/amd64/cpufunc.S:1.46 --- src/sys/arch/amd64/amd64/cpufunc.S:1.45 Sat Sep 7 18:56:01 2019 +++ src/sys/arch/amd64/amd64/cpufunc.S Wed Oct 30 17:06:57 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: cpufunc.S,v 1.45 2019/09/07 18:56:01 maxv Exp $ */ +/* $NetBSD: cpufunc.S,v 1.46 2019/10/30 17:06:57 maxv Exp $ */ /* * Copyright (c) 1998, 2007, 2008 The NetBSD Foundation, Inc. @@ -313,16 +313,6 @@ ENTRY(x86_mwait) ret END(x86_mwait) -ENTRY(fnsave) - fnsave (%rdi) - ret -END(fnsave) - -ENTRY(frstor) - frstor (%rdi) - ret -END(frstor) - ENTRY(stts) movq %cr0, %rax orq $CR0_TS, %rax @@ -330,46 +320,12 @@ ENTRY(stts) ret END(stts) -ENTRY(fxsave) - fxsave (%rdi) - ret -END(fxsave) - -ENTRY(fxrstor) - fxrstor (%rdi) - ret -END(fxrstor) - ENTRY(fldummy) ffree %st(7) fldz ret END(fldummy) -ENTRY(xsave) - movq %rsi, %rax - movq %rsi, %rdx - shrq $32, %rdx - xsave (%rdi) - ret -END(xsave) - -ENTRY(xsaveopt) - movq %rsi, %rax - movq %rsi, %rdx - shrq $32, %rdx - xsaveopt (%rdi) - ret -END(xsaveopt) - -ENTRY(xrstor) - movq %rsi, %rax - movq %rsi, %rdx - shrq $32, %rdx - xrstor (%rdi) - ret -END(xrstor) - ENTRY(inb) movq %rdi, %rdx xorq %rax, %rax Index: src/sys/arch/i386/i386/cpufunc.S diff -u src/sys/arch/i386/i386/cpufunc.S:1.35 src/sys/arch/i386/i386/cpufunc.S:1.36 --- src/sys/arch/i386/i386/cpufunc.S:1.35 Sat Sep 7 18:33:16 2019 +++ src/sys/arch/i386/i386/cpufunc.S Wed Oct 30 17:06:57 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: cpufunc.S,v 1.35 2019/09/07 18:33:16 maxv Exp $ */ +/* $NetBSD: cpufunc.S,v 1.36 2019/10/30 17:06:57 maxv Exp $ */ /*- * Copyright (c) 1998, 2007 The NetBSD Foundation, Inc. @@ -38,7 +38,7 @@ #include #include -__KERNEL_RCSID(0, "$NetBSD: cpufunc.S,v 1.35 2019/09/07 18:33:16 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpufunc.S,v 1.36 2019/10/30 17:06:57 maxv Exp $"); #include "opt_xen.h" @@ -224,18 +224,6 @@ ENTRY(x86_mwait) ret END(x86_mwait) -ENTRY(fnsave) - movl 4(%esp), %eax - fnsave (%eax) - ret -END(fnsave) - -ENTRY(frstor) - movl 4(%esp), %eax - frstor (%eax) - ret -END(frstor) - ENTRY(stts) movl %cr0, %eax testl $CR0_TS, %eax @@ -246,42 +234,6 @@ ENTRY(stts) ret END(stts) -ENTRY(fxsave) - movl 4(%esp), %eax - fxsave (%eax) - ret -END(fxsave) - -ENTRY(fxrstor) - movl 4(%esp), %eax - fxrstor (%eax) - ret -END(fxrstor) - -ENTRY(xsave) - movl 4(%esp), %ecx - movl 8(%esp), %eax /* feature mask bits */ - movl 12(%esp), %edx - xsave (%ecx) - ret -END(xsave) - -ENTRY(xsaveopt) - movl 4(%esp), %ecx - movl 8(%esp), %eax /* feature mask bits */ - movl 12(%esp), %edx - xsaveopt (%ecx) - ret -END(xsaveopt) - -ENTRY(xrstor) - movl 4(%esp), %ecx - movl 8(%esp), %eax /* feature mask bits */ - movl 12(%esp), %edx - xrstor (%ecx) - ret -END(xrstor) - ENTRY(fldummy) ffree %st(7) fldz Index: src/sys/arch/x86/include/cpufunc.h diff -u src/sys/arch/x86/include/cpufunc.h:1.36 src/sys/arch/x86/include/cpufunc.h:1.37 --- src/sys/arch/x86/include/cpufunc.h:1.36 Sat Sep 7 18:33:16 2019 +++ src/sys/arch/x86/include/cpufunc.h Wed Oct 30 17:06:57 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: cpufunc.h,v 1.36 2019/09/07 18:33:16 maxv Exp $ */ +/* $NetBSD: cpufunc.h,v 1.37 2019/10/30 17:06:57 maxv Exp $ */ /* * Copyright (c) 1998, 2007, 2019 The NetBSD Foundation, Inc. @@ -358,15 +358,105 @@ wrxcr(uint32_t xcr, uint64_t val) ); } -void fnsave(union savefpu *); -void frstor(const union savefpu *); +static inline void +fnsave(void *addr) +{ + uint8_t *area = addr; + + __asm volatile ( + "fnsave %[area]" + : [area] "=m" (*area) + : + : "memory" + ); +} -void fxsave(union savefpu *); -void fxrstor(const union savefpu *); +static inline void +frstor(void *addr) +{ + const uint8_t *area = addr; + + __asm volatile ( + "frstor %[area]" + : + : [area] "m" (*area) + : "memory" + ); +} -void xsave(union savefpu *, uint64_t); -void xsaveopt(union savefpu *, uint64_t); -void xrstor(const union savefpu *, uint64_t); +static inline void +fxsave(void *addr) +{ + uint8_t *area = addr; + + __asm volatile ( + "fxsave %[area]" + : [area] "=m" (*area) + : + : "memory" + ); +} + +static inline void +fxrstor(void *addr) +{ + const uint8_t *area = addr; + + __asm volatile ( + "fxrstor %[area]" + : + : [area] "m" (*area) + : "memory" + ); +} + +static inline
CVS commit: src/sys/arch/x86/x86
Module Name:src Committed By: maxv Date: Wed Oct 30 16:32:04 UTC 2019 Modified Files: src/sys/arch/x86/x86: fpu.c Log Message: Style. To generate a diff of this commit: cvs rdiff -u -r1.58 -r1.59 src/sys/arch/x86/x86/fpu.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/x86/x86
Module Name:src Committed By: maxv Date: Wed Oct 30 16:32:04 UTC 2019 Modified Files: src/sys/arch/x86/x86: fpu.c Log Message: Style. To generate a diff of this commit: cvs rdiff -u -r1.58 -r1.59 src/sys/arch/x86/x86/fpu.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/x86/fpu.c diff -u src/sys/arch/x86/x86/fpu.c:1.58 src/sys/arch/x86/x86/fpu.c:1.59 --- src/sys/arch/x86/x86/fpu.c:1.58 Sat Oct 12 06:31:04 2019 +++ src/sys/arch/x86/x86/fpu.c Wed Oct 30 16:32:04 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: fpu.c,v 1.58 2019/10/12 06:31:04 maxv Exp $ */ +/* $NetBSD: fpu.c,v 1.59 2019/10/30 16:32:04 maxv Exp $ */ /* * Copyright (c) 2008, 2019 The NetBSD Foundation, Inc. All @@ -96,7 +96,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.58 2019/10/12 06:31:04 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.59 2019/10/30 16:32:04 maxv Exp $"); #include "opt_multiprocessor.h" @@ -784,16 +784,15 @@ process_read_xstate(struct lwp *l, struc xstate->xs_xstate_bv = fpu_save->sv_xsave_hdr.xsh_xstate_bv; KASSERT(!(xstate->xs_xstate_bv & ~xstate->xs_rfbm)); -#define COPY_COMPONENT(xcr0_val, xsave_val, field)\ - if (xstate->xs_xstate_bv & xcr0_val) { \ - KASSERT(x86_xsave_offsets[xsave_val]\ - >= sizeof(struct xsave_header));\ - KASSERT(x86_xsave_sizes[xsave_val]\ - >= sizeof(xstate -> field));\ - \ - memcpy( -> field, \ - (char*)fpu_save + x86_xsave_offsets[xsave_val], \ - sizeof(xstate -> field)); \ +#define COPY_COMPONENT(xcr0_val, xsave_val, field) \ + if (xstate->xs_xstate_bv & xcr0_val) {\ + KASSERT(x86_xsave_offsets[xsave_val] \ + >= sizeof(struct xsave_header)); \ + KASSERT(x86_xsave_sizes[xsave_val] \ + >= sizeof(xstate->field));\ + memcpy(>field, \ + (char*)fpu_save + x86_xsave_offsets[xsave_val], \ + sizeof(xstate->field));\ } COPY_COMPONENT(XCR0_YMM_Hi128, XSAVE_YMM_Hi128, xs_ymm_hi128); @@ -846,8 +845,8 @@ process_write_xstate(struct lwp *l, cons /* If XSAVE is supported, make sure that xstate_bv is set correctly. */ if (x86_fpu_save >= FPU_SAVE_XSAVE) { /* - * Bit-wise xstate->xs_rfbm ? xstate->xs_xstate_bv - * : fpu_save->sv_xsave_hdr.xsh_xstate_bv + * Bit-wise "xstate->xs_rfbm ? xstate->xs_xstate_bv : + * fpu_save->sv_xsave_hdr.xsh_xstate_bv" */ fpu_save->sv_xsave_hdr.xsh_xstate_bv = (fpu_save->sv_xsave_hdr.xsh_xstate_bv & ~xstate->xs_rfbm) | @@ -865,8 +864,8 @@ process_write_xstate(struct lwp *l, cons } /* - * Copy MXCSR if either SSE or AVX state is requested, to match the XSAVE - * behavior for those flags. + * Copy MXCSR if either SSE or AVX state is requested, to match the + * XSAVE behavior for those flags. */ if (xstate->xs_xstate_bv & (XCR0_SSE|XCR0_YMM_Hi128)) { /* @@ -880,19 +879,17 @@ process_write_xstate(struct lwp *l, cons if (xstate->xs_xstate_bv & XCR0_SSE) { memcpy(_save->sv_xsave_hdr.xsh_fxsave[160], - xstate->xs_fxsave.fx_xmm, - sizeof(xstate->xs_fxsave.fx_xmm)); + xstate->xs_fxsave.fx_xmm, sizeof(xstate->xs_fxsave.fx_xmm)); } -#define COPY_COMPONENT(xcr0_val, xsave_val, field)\ - if (xstate->xs_xstate_bv & xcr0_val) { \ - KASSERT(x86_xsave_offsets[xsave_val]\ - >= sizeof(struct xsave_header));\ - KASSERT(x86_xsave_sizes[xsave_val]\ - >= sizeof(xstate -> field));\ - \ - memcpy((char*)fpu_save + x86_xsave_offsets[xsave_val], \ - -> field, sizeof(xstate -> field)); \ +#define COPY_COMPONENT(xcr0_val, xsave_val, field) \ + if (xstate->xs_xstate_bv & xcr0_val) {\ + KASSERT(x86_xsave_offsets[xsave_val] \ + >= sizeof(struct xsave_header)); \ + KASSERT(x86_xsave_sizes[xsave_val] \ + >= sizeof(xstate->field));\ + memcpy((char *)fpu_save + x86_xsave_offsets[xsave_val], \ + >field, sizeof(xstate->field)); \ } COPY_COMPONENT(XCR0_YMM_Hi128, XSAVE_YMM_Hi128, xs_ymm_hi128);
CVS commit: src/sys/dev/raidframe
Module Name:src Committed By: maxv Date: Wed Oct 30 07:59:45 UTC 2019 Modified Files: src/sys/dev/raidframe: rf_netbsdkintf.c Log Message: Get >sc_dksc only when we know 'rsc' is not NULL. This was actually harmless because we didn't use the pointer then. Reported-by: syzbot+77097fae0e3aad6de...@syzkaller.appspotmail.com To generate a diff of this commit: cvs rdiff -u -r1.376 -r1.377 src/sys/dev/raidframe/rf_netbsdkintf.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/raidframe
Module Name:src Committed By: maxv Date: Wed Oct 30 07:59:45 UTC 2019 Modified Files: src/sys/dev/raidframe: rf_netbsdkintf.c Log Message: Get >sc_dksc only when we know 'rsc' is not NULL. This was actually harmless because we didn't use the pointer then. Reported-by: syzbot+77097fae0e3aad6de...@syzkaller.appspotmail.com To generate a diff of this commit: cvs rdiff -u -r1.376 -r1.377 src/sys/dev/raidframe/rf_netbsdkintf.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/raidframe/rf_netbsdkintf.c diff -u src/sys/dev/raidframe/rf_netbsdkintf.c:1.376 src/sys/dev/raidframe/rf_netbsdkintf.c:1.377 --- src/sys/dev/raidframe/rf_netbsdkintf.c:1.376 Fri Mar 1 11:06:56 2019 +++ src/sys/dev/raidframe/rf_netbsdkintf.c Wed Oct 30 07:59:44 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: rf_netbsdkintf.c,v 1.376 2019/03/01 11:06:56 pgoyette Exp $ */ +/* $NetBSD: rf_netbsdkintf.c,v 1.377 2019/10/30 07:59:44 maxv Exp $ */ /*- * Copyright (c) 1996, 1997, 1998, 2008-2011 The NetBSD Foundation, Inc. @@ -101,7 +101,7 @@ ***/ #include -__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.376 2019/03/01 11:06:56 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.377 2019/10/30 07:59:44 maxv Exp $"); #ifdef _KERNEL_OPT #include "opt_raid_autoconfig.h" @@ -518,7 +518,6 @@ rf_buildroothack(RF_ConfigSet_t *config_ rf_cleanup_config_set(cset); cset = next_cset; } - dksc = >sc_dksc; /* if the user has specified what the root device should be then we don't touch booted_device or boothowto... */ @@ -543,6 +542,7 @@ rf_buildroothack(RF_ConfigSet_t *config_ */ if (num_root == 1) { device_t candidate_root; + dksc = >sc_dksc; if (dksc->sc_dkdev.dk_nwedges != 0) { char cname[sizeof(cset->ac->devname)]; /* XXX: assume partition 'a' first */
CVS commit: src/sys/arch
Module Name:src Committed By: maxv Date: Wed Oct 30 07:40:06 UTC 2019 Modified Files: src/sys/arch/i386/i386: gdt.c src/sys/arch/x86/x86: pmap.c src/sys/arch/xen/include: xenpmap.h src/sys/arch/xen/x86: x86_xpmap.c xen_pmap.c src/sys/arch/xen/xen: if_xennet_xenbus.c Log Message: Switch to new PTE bits. To generate a diff of this commit: cvs rdiff -u -r1.70 -r1.71 src/sys/arch/i386/i386/gdt.c cvs rdiff -u -r1.336 -r1.337 src/sys/arch/x86/x86/pmap.c cvs rdiff -u -r1.41 -r1.42 src/sys/arch/xen/include/xenpmap.h cvs rdiff -u -r1.84 -r1.85 src/sys/arch/xen/x86/x86_xpmap.c cvs rdiff -u -r1.31 -r1.32 src/sys/arch/xen/x86/xen_pmap.c cvs rdiff -u -r1.86 -r1.87 src/sys/arch/xen/xen/if_xennet_xenbus.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch
Module Name:src Committed By: maxv Date: Wed Oct 30 07:40:06 UTC 2019 Modified Files: src/sys/arch/i386/i386: gdt.c src/sys/arch/x86/x86: pmap.c src/sys/arch/xen/include: xenpmap.h src/sys/arch/xen/x86: x86_xpmap.c xen_pmap.c src/sys/arch/xen/xen: if_xennet_xenbus.c Log Message: Switch to new PTE bits. To generate a diff of this commit: cvs rdiff -u -r1.70 -r1.71 src/sys/arch/i386/i386/gdt.c cvs rdiff -u -r1.336 -r1.337 src/sys/arch/x86/x86/pmap.c cvs rdiff -u -r1.41 -r1.42 src/sys/arch/xen/include/xenpmap.h cvs rdiff -u -r1.84 -r1.85 src/sys/arch/xen/x86/x86_xpmap.c cvs rdiff -u -r1.31 -r1.32 src/sys/arch/xen/x86/xen_pmap.c cvs rdiff -u -r1.86 -r1.87 src/sys/arch/xen/xen/if_xennet_xenbus.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/i386/i386/gdt.c diff -u src/sys/arch/i386/i386/gdt.c:1.70 src/sys/arch/i386/i386/gdt.c:1.71 --- src/sys/arch/i386/i386/gdt.c:1.70 Sat Mar 9 08:42:25 2019 +++ src/sys/arch/i386/i386/gdt.c Wed Oct 30 07:40:05 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: gdt.c,v 1.70 2019/03/09 08:42:25 maxv Exp $ */ +/* $NetBSD: gdt.c,v 1.71 2019/10/30 07:40:05 maxv Exp $ */ /* * Copyright (c) 1996, 1997, 2009 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: gdt.c,v 1.70 2019/03/09 08:42:25 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: gdt.c,v 1.71 2019/10/30 07:40:05 maxv Exp $"); #include "opt_multiprocessor.h" #include "opt_xen.h" @@ -83,7 +83,7 @@ update_descriptor(union descriptor *tabl pt_entry_t *ptp; ptp = kvtopte((vaddr_t)table); - pa = (*ptp & PG_FRAME) | ((vaddr_t)table & ~PG_FRAME); + pa = (*ptp & PTE_4KFRAME) | ((vaddr_t)table & ~PTE_4KFRAME); if (HYPERVISOR_update_descriptor(pa, entry->raw[0], entry->raw[1])) panic("HYPERVISOR_update_descriptor failed\n"); #endif Index: src/sys/arch/x86/x86/pmap.c diff -u src/sys/arch/x86/x86/pmap.c:1.336 src/sys/arch/x86/x86/pmap.c:1.337 --- src/sys/arch/x86/x86/pmap.c:1.336 Sat Oct 5 07:19:49 2019 +++ src/sys/arch/x86/x86/pmap.c Wed Oct 30 07:40:05 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.336 2019/10/05 07:19:49 maxv Exp $ */ +/* $NetBSD: pmap.c,v 1.337 2019/10/30 07:40:05 maxv Exp $ */ /* * Copyright (c) 2008, 2010, 2016, 2017 The NetBSD Foundation, Inc. @@ -130,7 +130,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.336 2019/10/05 07:19:49 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.337 2019/10/30 07:40:05 maxv Exp $"); #include "opt_user_ldt.h" #include "opt_lockdebug.h" @@ -747,7 +747,7 @@ pmap_exec_account(struct pmap *pm, vaddr pm != vm_map_pmap(>p_vmspace->vm_map)) return; - if ((opte ^ npte) & PG_X) + if ((opte ^ npte) & PTE_X) pmap_update_pg(va); /* @@ -757,7 +757,7 @@ pmap_exec_account(struct pmap *pm, vaddr * We can't do that because of locking constraints on the vm map. */ - if ((opte & PG_X) && (npte & PG_X) == 0 && va == pm->pm_hiexec) { + if ((opte & PTE_X) && (npte & PTE_X) == 0 && va == pm->pm_hiexec) { struct trapframe *tf = curlwp->l_md.md_regs; tf->tf_cs = GSEL(GUCODE_SEL, SEL_UPL); @@ -1068,13 +1068,13 @@ pmap_bootstrap(vaddr_t kva_start) * into a x86 PTE. */ protection_codes[VM_PROT_NONE] = pmap_pg_nx; - protection_codes[VM_PROT_EXECUTE] = PG_X; + protection_codes[VM_PROT_EXECUTE] = PTE_X; protection_codes[VM_PROT_READ] = pmap_pg_nx; - protection_codes[VM_PROT_READ|VM_PROT_EXECUTE] = PG_X; + protection_codes[VM_PROT_READ|VM_PROT_EXECUTE] = PTE_X; protection_codes[VM_PROT_WRITE] = PTE_W | pmap_pg_nx; - protection_codes[VM_PROT_WRITE|VM_PROT_EXECUTE] = PTE_W | PG_X; + protection_codes[VM_PROT_WRITE|VM_PROT_EXECUTE] = PTE_W | PTE_X; protection_codes[VM_PROT_WRITE|VM_PROT_READ] = PTE_W | pmap_pg_nx; - protection_codes[VM_PROT_ALL] = PTE_W | PG_X; + protection_codes[VM_PROT_ALL] = PTE_W | PTE_X; /* * Now we init the kernel's pmap. Index: src/sys/arch/xen/include/xenpmap.h diff -u src/sys/arch/xen/include/xenpmap.h:1.41 src/sys/arch/xen/include/xenpmap.h:1.42 --- src/sys/arch/xen/include/xenpmap.h:1.41 Wed Feb 13 06:52:43 2019 +++ src/sys/arch/xen/include/xenpmap.h Wed Oct 30 07:40:06 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: xenpmap.h,v 1.41 2019/02/13 06:52:43 cherry Exp $ */ +/* $NetBSD: xenpmap.h,v 1.42 2019/10/30 07:40:06 maxv Exp $ */ /* * @@ -85,7 +85,7 @@ xpmap_mtop_masked(paddr_t mpa) static __inline paddr_t xpmap_mtop(paddr_t mpa) { - return (xpmap_mtop_masked(mpa) | (mpa & ~PG_FRAME)); + return (xpmap_mtop_masked(mpa) | (mpa & ~PTE_4KFRAME)); } static __inline paddr_t @@ -99,7 +99,7 @@ xpmap_ptom_masked(paddr_t ppa) static __inline paddr_t xpmap_ptom(paddr_t ppa) { - return (xpmap_ptom_masked(ppa) | (ppa & ~PG_FRAME)); + return (xpmap_ptom_masked(ppa) | (ppa & ~PTE_4KFRAME)); } static __inline void Index: src/sys/arch/xen/x86/x86_xpmap.c diff -u src/sys/arch/xen/x86/x86_xpmap.c:1.84
CVS commit: src/sys/arch/x86/x86
Module Name:src Committed By: maxv Date: Tue Oct 29 12:39:46 UTC 2019 Modified Files: src/sys/arch/x86/x86: identcpu.c Log Message: Enable XSAVEOPT. To generate a diff of this commit: cvs rdiff -u -r1.97 -r1.98 src/sys/arch/x86/x86/identcpu.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/x86/x86
Module Name:src Committed By: maxv Date: Tue Oct 29 12:39:46 UTC 2019 Modified Files: src/sys/arch/x86/x86: identcpu.c Log Message: Enable XSAVEOPT. To generate a diff of this commit: cvs rdiff -u -r1.97 -r1.98 src/sys/arch/x86/x86/identcpu.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/x86/identcpu.c diff -u src/sys/arch/x86/x86/identcpu.c:1.97 src/sys/arch/x86/x86/identcpu.c:1.98 --- src/sys/arch/x86/x86/identcpu.c:1.97 Mon Oct 21 10:09:24 2019 +++ src/sys/arch/x86/x86/identcpu.c Tue Oct 29 12:39:46 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: identcpu.c,v 1.97 2019/10/21 10:09:24 maxv Exp $ */ +/* $NetBSD: identcpu.c,v 1.98 2019/10/29 12:39:46 maxv Exp $ */ /*- * Copyright (c) 1999, 2000, 2001, 2006, 2007, 2008 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: identcpu.c,v 1.97 2019/10/21 10:09:24 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: identcpu.c,v 1.98 2019/10/29 12:39:46 maxv Exp $"); #include "opt_xen.h" @@ -804,11 +804,9 @@ cpu_probe_fpu(struct cpu_info *ci) x86_fpu_save = FPU_SAVE_XSAVE; -#if 0 /* XXX PR 52966 */ x86_cpuid2(0xd, 1, descs); if (descs[0] & CPUID_PES1_XSAVEOPT) x86_fpu_save = FPU_SAVE_XSAVEOPT; -#endif /* Get features and maximum size of the save area */ x86_cpuid(0xd, descs);
CVS commit: src/usr.sbin/nvmmctl
Module Name:src Committed By: maxv Date: Tue Oct 29 08:13:17 UTC 2019 Modified Files: src/usr.sbin/nvmmctl: Makefile Log Message: Forgot to put nvmmctl in the "nvmm" group. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/usr.sbin/nvmmctl/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/nvmmctl/Makefile diff -u src/usr.sbin/nvmmctl/Makefile:1.1 src/usr.sbin/nvmmctl/Makefile:1.2 --- src/usr.sbin/nvmmctl/Makefile:1.1 Mon Oct 28 13:04:18 2019 +++ src/usr.sbin/nvmmctl/Makefile Tue Oct 29 08:13:16 2019 @@ -1,12 +1,16 @@ -# $NetBSD: Makefile,v 1.1 2019/10/28 13:04:18 maxv Exp $ +# $NetBSD: Makefile,v 1.2 2019/10/29 08:13:16 maxv Exp $ .include MAN= nvmmctl.8 .if (${MACHINE_ARCH} == "x86_64") -PROG= nvmmctl -SRCS= nvmmctl.c +USE_FORT?=yes # setgid +PROG=nvmmctl +SRCS=nvmmctl.c + +BINGRP=nvmm +BINMODE=2555 CPPFLAGS+=-D_KERNTYPES LDADD+=-lutil -lnvmm
CVS commit: src/usr.sbin/nvmmctl
Module Name:src Committed By: maxv Date: Tue Oct 29 08:13:17 UTC 2019 Modified Files: src/usr.sbin/nvmmctl: Makefile Log Message: Forgot to put nvmmctl in the "nvmm" group. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/usr.sbin/nvmmctl/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/lib/libnvmm
Module Name:src Committed By: maxv Date: Mon Oct 28 14:20:28 UTC 2019 Modified Files: src/lib/libnvmm: libnvmm.3 Log Message: should be fork(2), noticed by wiz To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/lib/libnvmm/libnvmm.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/lib/libnvmm
Module Name:src Committed By: maxv Date: Mon Oct 28 14:20:28 UTC 2019 Modified Files: src/lib/libnvmm: libnvmm.3 Log Message: should be fork(2), noticed by wiz To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/lib/libnvmm/libnvmm.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libnvmm/libnvmm.3 diff -u src/lib/libnvmm/libnvmm.3:1.24 src/lib/libnvmm/libnvmm.3:1.25 --- src/lib/libnvmm/libnvmm.3:1.24 Mon Oct 28 13:43:42 2019 +++ src/lib/libnvmm/libnvmm.3 Mon Oct 28 14:20:28 2019 @@ -1,4 +1,4 @@ -.\" $NetBSD: libnvmm.3,v 1.24 2019/10/28 13:43:42 wiz Exp $ +.\" $NetBSD: libnvmm.3,v 1.25 2019/10/28 14:20:28 maxv Exp $ .\" .\" Copyright (c) 2018, 2019 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -336,7 +336,7 @@ if they were not already destroyed by th .Fn nvmm_machine_destroy . .Pp Virtual machines are not inherited across -.Xr fork 9 +.Xr fork 2 operations. .Ss Machine Configuration Emulator software can configure several parameters of a virtual machine by using
CVS commit: src
Module Name:src Committed By: maxv Date: Mon Oct 28 13:04:19 UTC 2019 Modified Files: src/distrib/sets/lists/base: md.amd64 src/distrib/sets/lists/man: mi src/share/mk: bsd.hostprog.mk src/usr.sbin: Makefile Added Files: src/usr.sbin/nvmmctl: Makefile nvmmctl.8 nvmmctl.c Log Message: Add nvmmctl, with two commands for now. To generate a diff of this commit: cvs rdiff -u -r1.280 -r1.281 src/distrib/sets/lists/base/md.amd64 cvs rdiff -u -r1.1659 -r1.1660 src/distrib/sets/lists/man/mi cvs rdiff -u -r1.81 -r1.82 src/share/mk/bsd.hostprog.mk cvs rdiff -u -r1.281 -r1.282 src/usr.sbin/Makefile cvs rdiff -u -r0 -r1.1 src/usr.sbin/nvmmctl/Makefile \ src/usr.sbin/nvmmctl/nvmmctl.8 src/usr.sbin/nvmmctl/nvmmctl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src
INE_ARCH} == "x86_64") +PROG= nvmmctl +SRCS= nvmmctl.c + +CPPFLAGS+=-D_KERNTYPES +LDADD+=-lutil -lnvmm +DPADD+=${LIBUTIL} ${LIBNVMM} +.endif + +.include Index: src/usr.sbin/nvmmctl/nvmmctl.8 diff -u /dev/null src/usr.sbin/nvmmctl/nvmmctl.8:1.1 --- /dev/null Mon Oct 28 13:04:19 2019 +++ src/usr.sbin/nvmmctl/nvmmctl.8 Mon Oct 28 13:04:18 2019 @@ -0,0 +1,63 @@ +.\" $NetBSD: nvmmctl.8,v 1.1 2019/10/28 13:04:18 maxv Exp $ +.\" +.\" Copyright (c) 2019 The NetBSD Foundation, Inc. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to The NetBSD Foundation +.\" by Maxime Villard. +.\" +.\" 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. +.\" +.Dd October 27, 2019 +.Dt NVMMCTL 8 +.Os +.Sh NAME +.Nm nvmmctl +.Nd program to control virtual machines +.Sh SYNOPSIS +.Nm nvmmctl +.Ar command +.Op Ar arguments +.Sh DESCRIPTION +The +.Nm +command can be used to control and inspect the state of virtual machines in the +system. +.Pp +The first argument, +.Ar command , +specifies the action to take. +Valid commands are: +.Bl -tag -width +.It identify +Display the capabilities of the system. +.It list +Display information on each virtual machine registered in the system. +.El +.Sh SEE ALSO +.Xr nvmm 4 , +.Xr libnvmm 3 +.Sh AUTHORS +The +.Nm +tool was written by +.An Maxime Villard . Index: src/usr.sbin/nvmmctl/nvmmctl.c diff -u /dev/null src/usr.sbin/nvmmctl/nvmmctl.c:1.1 --- /dev/null Mon Oct 28 13:04:19 2019 +++ src/usr.sbin/nvmmctl/nvmmctl.c Mon Oct 28 13:04:18 2019 @@ -0,0 +1,180 @@ +/* $NetBSD: nvmmctl.c,v 1.1 2019/10/28 13:04:18 maxv Exp $ */ + +/* + * Copyright (c) 2019 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Maxime Villard. + * + * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. + */ + +#include +#ifndef lint +__RCSID("$NetBSD: nvmmctl.c,v 1.1 2019/10/28 13:04:18 maxv Exp $"); +#endif /* not lint */ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +__dead static void usage(void); +static void nvmm_identify(char **); +static void nvmm_list(char **); + +static struct cmdtab { + const char *label;
CVS commit: src/sys/dev/nvmm
Module Name:src Committed By: maxv Date: Mon Oct 28 09:00:08 UTC 2019 Modified Files: src/sys/dev/nvmm: nvmm.c nvmm_ioctl.h Log Message: Add nram in struct nvmm_ctl_mach_info. To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/sys/dev/nvmm/nvmm.c cvs rdiff -u -r1.8 -r1.9 src/sys/dev/nvmm/nvmm_ioctl.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/nvmm/nvmm.c diff -u src/sys/dev/nvmm/nvmm.c:1.24 src/sys/dev/nvmm/nvmm.c:1.25 --- src/sys/dev/nvmm/nvmm.c:1.24 Sun Oct 27 20:17:36 2019 +++ src/sys/dev/nvmm/nvmm.c Mon Oct 28 09:00:08 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: nvmm.c,v 1.24 2019/10/27 20:17:36 maxv Exp $ */ +/* $NetBSD: nvmm.c,v 1.25 2019/10/28 09:00:08 maxv Exp $ */ /* * Copyright (c) 2018-2019 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: nvmm.c,v 1.24 2019/10/27 20:17:36 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nvmm.c,v 1.25 2019/10/28 09:00:08 maxv Exp $"); #include #include @@ -915,6 +915,14 @@ nvmm_ctl_mach_info(struct nvmm_owner *ow ctl.nvcpus++; nvmm_vcpu_put(vcpu); } + + ctl.nram = 0; + for (i = 0; i < NVMM_MAX_HMAPPINGS; i++) { + if (!mach->hmap[i].present) + continue; + ctl.nram += mach->hmap[i].size; + } + ctl.pid = mach->owner->pid; ctl.time = mach->time; Index: src/sys/dev/nvmm/nvmm_ioctl.h diff -u src/sys/dev/nvmm/nvmm_ioctl.h:1.8 src/sys/dev/nvmm/nvmm_ioctl.h:1.9 --- src/sys/dev/nvmm/nvmm_ioctl.h:1.8 Wed Oct 23 07:01:11 2019 +++ src/sys/dev/nvmm/nvmm_ioctl.h Mon Oct 28 09:00:08 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: nvmm_ioctl.h,v 1.8 2019/10/23 07:01:11 maxv Exp $ */ +/* $NetBSD: nvmm_ioctl.h,v 1.9 2019/10/28 09:00:08 maxv Exp $ */ /* * Copyright (c) 2018-2019 The NetBSD Foundation, Inc. @@ -122,7 +122,8 @@ struct nvmm_ioc_gpa_unmap { struct nvmm_ctl_mach_info { nvmm_machid_t machid; - size_t nvcpus; + uint32_t nvcpus; + uint64_t nram; pid_t pid; time_t time; };
CVS commit: src/sys/dev/nvmm
Module Name:src Committed By: maxv Date: Mon Oct 28 09:00:08 UTC 2019 Modified Files: src/sys/dev/nvmm: nvmm.c nvmm_ioctl.h Log Message: Add nram in struct nvmm_ctl_mach_info. To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/sys/dev/nvmm/nvmm.c cvs rdiff -u -r1.8 -r1.9 src/sys/dev/nvmm/nvmm_ioctl.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src
Module Name:src Committed By: maxv Date: Mon Oct 28 08:30:49 UTC 2019 Modified Files: src/lib/libnvmm: libnvmm.3 nvmm.h src/sys/dev/nvmm: nvmm.h src/sys/dev/nvmm/x86: nvmm_x86.h nvmm_x86_svm.c nvmm_x86_vmx.c Log Message: A few changes: - Use smaller types in struct nvmm_capability. - Use smaller type for nvmm_io.port. - Switch exitstate to a compacted structure. To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/lib/libnvmm/libnvmm.3 cvs rdiff -u -r1.16 -r1.17 src/lib/libnvmm/nvmm.h cvs rdiff -u -r1.11 -r1.12 src/sys/dev/nvmm/nvmm.h cvs rdiff -u -r1.17 -r1.18 src/sys/dev/nvmm/x86/nvmm_x86.h cvs rdiff -u -r1.52 -r1.53 src/sys/dev/nvmm/x86/nvmm_x86_svm.c cvs rdiff -u -r1.43 -r1.44 src/sys/dev/nvmm/x86/nvmm_x86_vmx.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src
Module Name:src Committed By: maxv Date: Mon Oct 28 08:30:49 UTC 2019 Modified Files: src/lib/libnvmm: libnvmm.3 nvmm.h src/sys/dev/nvmm: nvmm.h src/sys/dev/nvmm/x86: nvmm_x86.h nvmm_x86_svm.c nvmm_x86_vmx.c Log Message: A few changes: - Use smaller types in struct nvmm_capability. - Use smaller type for nvmm_io.port. - Switch exitstate to a compacted structure. To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/lib/libnvmm/libnvmm.3 cvs rdiff -u -r1.16 -r1.17 src/lib/libnvmm/nvmm.h cvs rdiff -u -r1.11 -r1.12 src/sys/dev/nvmm/nvmm.h cvs rdiff -u -r1.17 -r1.18 src/sys/dev/nvmm/x86/nvmm_x86.h cvs rdiff -u -r1.52 -r1.53 src/sys/dev/nvmm/x86/nvmm_x86_svm.c cvs rdiff -u -r1.43 -r1.44 src/sys/dev/nvmm/x86/nvmm_x86_vmx.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libnvmm/libnvmm.3 diff -u src/lib/libnvmm/libnvmm.3:1.22 src/lib/libnvmm/libnvmm.3:1.23 --- src/lib/libnvmm/libnvmm.3:1.22 Sun Oct 27 10:28:55 2019 +++ src/lib/libnvmm/libnvmm.3 Mon Oct 28 08:30:49 2019 @@ -1,4 +1,4 @@ -.\" $NetBSD: libnvmm.3,v 1.22 2019/10/27 10:28:55 maxv Exp $ +.\" $NetBSD: libnvmm.3,v 1.23 2019/10/28 08:30:49 maxv Exp $ .\" .\" Copyright (c) 2018, 2019 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -27,7 +27,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd October 27, 2019 +.Dd October 28, 2019 .Dt LIBNVMM 3 .Os .Sh NAME @@ -502,7 +502,9 @@ struct nvmm_vcpu_exit { union { ... } u; - uint64_t exitstate[8]; + struct { + ... + } exitstate; }; .Ed .Pp @@ -611,7 +613,7 @@ This structure describes an I/O transact struct nvmm_io { struct nvmm_machine *mach; struct nvmm_vcpu *vcpu; - uint64_t port; + uint16_t port; bool in; size_t size; uint8_t *data; Index: src/lib/libnvmm/nvmm.h diff -u src/lib/libnvmm/nvmm.h:1.16 src/lib/libnvmm/nvmm.h:1.17 --- src/lib/libnvmm/nvmm.h:1.16 Sun Oct 27 20:17:36 2019 +++ src/lib/libnvmm/nvmm.h Mon Oct 28 08:30:49 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: nvmm.h,v 1.16 2019/10/27 20:17:36 maxv Exp $ */ +/* $NetBSD: nvmm.h,v 1.17 2019/10/28 08:30:49 maxv Exp $ */ /* * Copyright (c) 2018-2019 The NetBSD Foundation, Inc. @@ -65,7 +65,7 @@ struct nvmm_vcpu { struct nvmm_io { struct nvmm_machine *mach; struct nvmm_vcpu *vcpu; - uint64_t port; + uint16_t port; bool in; size_t size; uint8_t *data; Index: src/sys/dev/nvmm/nvmm.h diff -u src/sys/dev/nvmm/nvmm.h:1.11 src/sys/dev/nvmm/nvmm.h:1.12 --- src/sys/dev/nvmm/nvmm.h:1.11 Wed Oct 23 07:01:11 2019 +++ src/sys/dev/nvmm/nvmm.h Mon Oct 28 08:30:49 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: nvmm.h,v 1.11 2019/10/23 07:01:11 maxv Exp $ */ +/* $NetBSD: nvmm.h,v 1.12 2019/10/28 08:30:49 maxv Exp $ */ /* * Copyright (c) 2018-2019 The NetBSD Foundation, Inc. @@ -51,10 +51,10 @@ typedef uint32_t nvmm_cpuid_t; #define NVMM_KERN_VERSION 1 struct nvmm_capability { - uint64_t version; - uint64_t state_size; - uint64_t max_machines; - uint64_t max_vcpus; + uint32_t version; + uint32_t state_size; + uint32_t max_machines; + uint32_t max_vcpus; uint64_t max_ram; struct nvmm_cap_md arch; }; Index: src/sys/dev/nvmm/x86/nvmm_x86.h diff -u src/sys/dev/nvmm/x86/nvmm_x86.h:1.17 src/sys/dev/nvmm/x86/nvmm_x86.h:1.18 --- src/sys/dev/nvmm/x86/nvmm_x86.h:1.17 Sun Oct 27 10:28:55 2019 +++ src/sys/dev/nvmm/x86/nvmm_x86.h Mon Oct 28 08:30:49 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: nvmm_x86.h,v 1.17 2019/10/27 10:28:55 maxv Exp $ */ +/* $NetBSD: nvmm_x86.h,v 1.18 2019/10/28 08:30:49 maxv Exp $ */ /* * Copyright (c) 2018-2019 The NetBSD Foundation, Inc. @@ -102,7 +102,15 @@ struct nvmm_x86_exit { struct nvmm_x86_exit_insn insn; struct nvmm_x86_exit_invalid inv; } u; - uint64_t exitstate[8]; + struct { + uint64_t rflags; + uint64_t cr8; + uint64_t int_shadow:1; + uint64_t int_window_exiting:1; + uint64_t nmi_window_exiting:1; + uint64_t evt_pending:1; + uint64_t rsvd:60; + } exitstate; }; #define NVMM_VCPU_EVENT_EXCP 0 @@ -128,7 +136,7 @@ struct nvmm_cap_md { uint64_t xcr0_mask; uint32_t mxcsr_mask; uint32_t conf_cpuid_maxops; - uint64_t rsvd[4]; + uint64_t rsvd[6]; }; #endif @@ -236,14 +244,6 @@ struct nvmm_x64_state_intr { uint64_t rsvd:60; }; -/* VM exit state indexes. */ -#define NVMM_X64_EXITSTATE_CR8 0 -#define NVMM_X64_EXITSTATE_RFLAGS 1 -#define NVMM_X64_EXITSTATE_INT_SHADOW 2 -#define NVMM_X64_EXITSTATE_INT_WINDOW_EXIT 3 -#define NVMM_X64_EXITSTATE_NMI_WINDOW_EXIT 4 -#define NVMM_X64_EXITSTATE_EVT_PENDING 5 - /* Flags. */ #define NVMM_X64_STATE_SEGS 0x01 #define NVMM_X64_STATE_GPRS 0x02 Index: src/sys/dev/nvmm/x86/nvmm_x86_svm.c diff -u src/sys/dev/nvmm/x86/nvmm_x86_svm.c:1.52 src/sys/dev/nvmm/x86/nvmm_x86_svm.c:1.53 --- src/sys/dev/nvmm/x86/nvmm_x86_svm.c:1.52 Sun Oct 27 10:28:55 2019 +++ src/sys/dev/nvmm/x86/nvmm_x86_svm.c Mon Oct 28 08:30:49 2019 @@
CVS commit: src
Module Name:src Committed By: maxv Date: Sun Oct 27 20:17:36 UTC 2019 Modified Files: src/lib/libnvmm: libnvmm.c nvmm.h src/sys/dev/nvmm: nvmm.c Log Message: Change the way root_owner works: consider the calling process as root_owner not if it has root privileges, but if the /dev/nvmm device was opened with write permissions. Introduce the undocumented nvmm_root_init() function to achieve that. The goal is to simplify the logic and have more granularity, eg if we want a monitoring agent to access VMs but don't want to give this agent real root access on the system. To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/lib/libnvmm/libnvmm.c cvs rdiff -u -r1.15 -r1.16 src/lib/libnvmm/nvmm.h cvs rdiff -u -r1.23 -r1.24 src/sys/dev/nvmm/nvmm.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src
Module Name:src Committed By: maxv Date: Sun Oct 27 20:17:36 UTC 2019 Modified Files: src/lib/libnvmm: libnvmm.c nvmm.h src/sys/dev/nvmm: nvmm.c Log Message: Change the way root_owner works: consider the calling process as root_owner not if it has root privileges, but if the /dev/nvmm device was opened with write permissions. Introduce the undocumented nvmm_root_init() function to achieve that. The goal is to simplify the logic and have more granularity, eg if we want a monitoring agent to access VMs but don't want to give this agent real root access on the system. To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/lib/libnvmm/libnvmm.c cvs rdiff -u -r1.15 -r1.16 src/lib/libnvmm/nvmm.h cvs rdiff -u -r1.23 -r1.24 src/sys/dev/nvmm/nvmm.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libnvmm/libnvmm.c diff -u src/lib/libnvmm/libnvmm.c:1.17 src/lib/libnvmm/libnvmm.c:1.18 --- src/lib/libnvmm/libnvmm.c:1.17 Sun Oct 27 07:08:15 2019 +++ src/lib/libnvmm/libnvmm.c Sun Oct 27 20:17:36 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: libnvmm.c,v 1.17 2019/10/27 07:08:15 maxv Exp $ */ +/* $NetBSD: libnvmm.c,v 1.18 2019/10/27 20:17:36 maxv Exp $ */ /* * Copyright (c) 2018-2019 The NetBSD Foundation, Inc. @@ -180,6 +180,29 @@ nvmm_init(void) } int +nvmm_root_init(void) +{ + if (nvmm_fd != -1) + return 0; + nvmm_fd = open("/dev/nvmm", O_WRONLY | O_CLOEXEC); + if (nvmm_fd == -1) + return -1; + if (nvmm_capability(&__capability) == -1) { + close(nvmm_fd); + nvmm_fd = -1; + return -1; + } + if (__capability.version != NVMM_KERN_VERSION) { + close(nvmm_fd); + nvmm_fd = -1; + errno = EPROGMISMATCH; + return -1; + } + + return 0; +} + +int nvmm_capability(struct nvmm_capability *cap) { struct nvmm_ioc_capability args; Index: src/lib/libnvmm/nvmm.h diff -u src/lib/libnvmm/nvmm.h:1.15 src/lib/libnvmm/nvmm.h:1.16 --- src/lib/libnvmm/nvmm.h:1.15 Sun Oct 27 07:08:15 2019 +++ src/lib/libnvmm/nvmm.h Sun Oct 27 20:17:36 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: nvmm.h,v 1.15 2019/10/27 07:08:15 maxv Exp $ */ +/* $NetBSD: nvmm.h,v 1.16 2019/10/27 20:17:36 maxv Exp $ */ /* * Copyright (c) 2018-2019 The NetBSD Foundation, Inc. @@ -90,6 +90,7 @@ struct nvmm_mem { typedef uint64_t nvmm_prot_t; int nvmm_init(void); +int nvmm_root_init(void); int nvmm_capability(struct nvmm_capability *); Index: src/sys/dev/nvmm/nvmm.c diff -u src/sys/dev/nvmm/nvmm.c:1.23 src/sys/dev/nvmm/nvmm.c:1.24 --- src/sys/dev/nvmm/nvmm.c:1.23 Wed Oct 23 07:01:11 2019 +++ src/sys/dev/nvmm/nvmm.c Sun Oct 27 20:17:36 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: nvmm.c,v 1.23 2019/10/23 07:01:11 maxv Exp $ */ +/* $NetBSD: nvmm.c,v 1.24 2019/10/27 20:17:36 maxv Exp $ */ /* * Copyright (c) 2018-2019 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: nvmm.c,v 1.23 2019/10/23 07:01:11 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nvmm.c,v 1.24 2019/10/27 20:17:36 maxv Exp $"); #include #include @@ -889,7 +889,7 @@ out: /* -- */ static int -nvmm_ctl_mach_info(struct nvmm_ioc_ctl *args) +nvmm_ctl_mach_info(struct nvmm_owner *owner, struct nvmm_ioc_ctl *args) { struct nvmm_ctl_mach_info ctl; struct nvmm_machine *mach; @@ -903,7 +903,7 @@ nvmm_ctl_mach_info(struct nvmm_ioc_ctl * if (error) return error; - error = nvmm_machine_get(_owner, ctl.machid, , true); + error = nvmm_machine_get(owner, ctl.machid, , true); if (error) return error; @@ -930,16 +930,9 @@ nvmm_ctl_mach_info(struct nvmm_ioc_ctl * static int nvmm_ctl(struct nvmm_owner *owner, struct nvmm_ioc_ctl *args) { - int error; - - error = kauth_authorize_device(curlwp->l_cred, KAUTH_DEVICE_NVMM_CTL, - NULL, NULL, NULL, NULL); - if (error) - return error; - switch (args->op) { case NVMM_CTL_MACH_INFO: - return nvmm_ctl_mach_info(args); + return nvmm_ctl_mach_info(owner, args); default: return EINVAL; } @@ -1047,8 +1040,12 @@ nvmm_open(dev_t dev, int flags, int type if (error) return error; - owner = kmem_alloc(sizeof(*owner), KM_SLEEP); - owner->pid = l->l_proc->p_pid; + if (OFLAGS(flags) & O_WRONLY) { + owner = _owner; + } else { + owner = kmem_alloc(sizeof(*owner), KM_SLEEP); + owner->pid = l->l_proc->p_pid; + } return fd_clone(fp, fd, flags, _fileops, owner); } @@ -1060,7 +1057,9 @@ nvmm_close(file_t *fp) KASSERT(owner != NULL); nvmm_kill_machines(owner); - kmem_free(owner, sizeof(*owner)); + if (owner != _owner) { + kmem_free(owner, sizeof(*owner)); + } fp->f_data = NULL; return 0;
CVS commit: src/sys/dev/nvmm/x86
Module Name:src Committed By: maxv Date: Sun Oct 27 18:26:54 UTC 2019 Modified Files: src/sys/dev/nvmm/x86: nvmm_x86_vmx.c Log Message: Add PCID support in the guests. This speeds up most 64bit guests, because since Meltdown, everybody uses PCID (including NetBSD). To generate a diff of this commit: cvs rdiff -u -r1.42 -r1.43 src/sys/dev/nvmm/x86/nvmm_x86_vmx.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/nvmm/x86/nvmm_x86_vmx.c diff -u src/sys/dev/nvmm/x86/nvmm_x86_vmx.c:1.42 src/sys/dev/nvmm/x86/nvmm_x86_vmx.c:1.43 --- src/sys/dev/nvmm/x86/nvmm_x86_vmx.c:1.42 Sun Oct 27 11:11:09 2019 +++ src/sys/dev/nvmm/x86/nvmm_x86_vmx.c Sun Oct 27 18:26:54 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: nvmm_x86_vmx.c,v 1.42 2019/10/27 11:11:09 maxv Exp $ */ +/* $NetBSD: nvmm_x86_vmx.c,v 1.43 2019/10/27 18:26:54 maxv Exp $ */ /* * Copyright (c) 2018-2019 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_vmx.c,v 1.42 2019/10/27 11:11:09 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_vmx.c,v 1.43 2019/10/27 18:26:54 maxv Exp $"); #include #include @@ -1150,6 +1150,9 @@ vmx_inkernel_handle_cpuid(struct nvmm_cp cpudata->gprs[NVMM_X64_GPR_RCX] &= nvmm_cpuid_0001.ecx; cpudata->gprs[NVMM_X64_GPR_RCX] |= CPUID2_RAZ; + if (vmx_procbased_ctls2 & PROC_CTLS2_INVPCID_ENABLE) { + cpudata->gprs[NVMM_X64_GPR_RCX] |= CPUID2_PCID; + } cpudata->gprs[NVMM_X64_GPR_RDX] &= nvmm_cpuid_0001.edx; @@ -1171,6 +1174,9 @@ vmx_inkernel_handle_cpuid(struct nvmm_cp cpudata->gprs[NVMM_X64_GPR_RBX] &= nvmm_cpuid_0007.ebx; cpudata->gprs[NVMM_X64_GPR_RCX] &= nvmm_cpuid_0007.ecx; cpudata->gprs[NVMM_X64_GPR_RDX] &= nvmm_cpuid_0007.edx; + if (vmx_procbased_ctls2 & PROC_CTLS2_INVPCID_ENABLE) { + cpudata->gprs[NVMM_X64_GPR_RBX] |= CPUID_SEF_INVPCID; + } break; case 0x000A: cpudata->gprs[NVMM_X64_GPR_RAX] = 0; @@ -2893,6 +2899,40 @@ vmx_machine_configure(struct nvmm_machin /* -- */ +#define CTLS_ONE_ALLOWED(msrval, bitoff) \ + ((msrval & __BIT(32 + bitoff)) != 0) +#define CTLS_ZERO_ALLOWED(msrval, bitoff) \ + ((msrval & __BIT(bitoff)) == 0) + +static int +vmx_check_ctls(uint64_t msr_ctls, uint64_t msr_true_ctls, uint64_t set_one) +{ + uint64_t basic, val, true_val; + bool has_true; + size_t i; + + basic = rdmsr(MSR_IA32_VMX_BASIC); + has_true = (basic & IA32_VMX_BASIC_TRUE_CTLS) != 0; + + val = rdmsr(msr_ctls); + if (has_true) { + true_val = rdmsr(msr_true_ctls); + } else { + true_val = val; + } + + for (i = 0; i < 32; i++) { + if (!(set_one & __BIT(i))) { + continue; + } + if (!CTLS_ONE_ALLOWED(true_val, i)) { + return -1; + } + } + + return 0; +} + static int vmx_init_ctls(uint64_t msr_ctls, uint64_t msr_true_ctls, uint64_t set_one, uint64_t set_zero, uint64_t *res) @@ -2911,14 +2951,9 @@ vmx_init_ctls(uint64_t msr_ctls, uint64_ true_val = val; } -#define ONE_ALLOWED(msrval, bitoff) \ - ((msrval & __BIT(32 + bitoff)) != 0) -#define ZERO_ALLOWED(msrval, bitoff) \ - ((msrval & __BIT(bitoff)) == 0) - for (i = 0; i < 32; i++) { - one_allowed = ONE_ALLOWED(true_val, i); - zero_allowed = ZERO_ALLOWED(true_val, i); + one_allowed = CTLS_ONE_ALLOWED(true_val, i); + zero_allowed = CTLS_ZERO_ALLOWED(true_val, i); if (zero_allowed && !one_allowed) { if (set_one & __BIT(i)) @@ -2935,9 +2970,9 @@ vmx_init_ctls(uint64_t msr_ctls, uint64_ *res |= __BIT(i); } else if (!has_true) { *res &= ~__BIT(i); - } else if (ZERO_ALLOWED(val, i)) { + } else if (CTLS_ZERO_ALLOWED(val, i)) { *res &= ~__BIT(i); - } else if (ONE_ALLOWED(val, i)) { + } else if (CTLS_ONE_ALLOWED(val, i)) { *res |= __BIT(i); } else { return -1; @@ -3011,6 +3046,12 @@ vmx_ident(void) if (ret == -1) { return false; } + ret = vmx_check_ctls( + MSR_IA32_VMX_PROCBASED_CTLS2, MSR_IA32_VMX_PROCBASED_CTLS2, + PROC_CTLS2_INVPCID_ENABLE); + if (ret != -1) { + vmx_procbased_ctls2 |= PROC_CTLS2_INVPCID_ENABLE; + } ret = vmx_init_ctls( MSR_IA32_VMX_ENTRY_CTLS, MSR_IA32_VMX_TRUE_ENTRY_CTLS, VMX_ENTRY_CTLS_ONE, VMX_ENTRY_CTLS_ZERO,
CVS commit: src/sys/dev/nvmm/x86
Module Name:src Committed By: maxv Date: Sun Oct 27 18:26:54 UTC 2019 Modified Files: src/sys/dev/nvmm/x86: nvmm_x86_vmx.c Log Message: Add PCID support in the guests. This speeds up most 64bit guests, because since Meltdown, everybody uses PCID (including NetBSD). To generate a diff of this commit: cvs rdiff -u -r1.42 -r1.43 src/sys/dev/nvmm/x86/nvmm_x86_vmx.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/nvmm/x86
Module Name:src Committed By: maxv Date: Sun Oct 27 11:11:09 UTC 2019 Modified Files: src/sys/dev/nvmm/x86: nvmm_x86_vmx.c Log Message: Mask CPUID leaf 0x0A on Intel, because we don't want the guest to try (and fail) to probe the PMC MSRs. This avoids "Unexpected WRMSR" warnings in qemu-nvmm. To generate a diff of this commit: cvs rdiff -u -r1.41 -r1.42 src/sys/dev/nvmm/x86/nvmm_x86_vmx.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/nvmm/x86
Module Name:src Committed By: maxv Date: Sun Oct 27 11:11:09 UTC 2019 Modified Files: src/sys/dev/nvmm/x86: nvmm_x86_vmx.c Log Message: Mask CPUID leaf 0x0A on Intel, because we don't want the guest to try (and fail) to probe the PMC MSRs. This avoids "Unexpected WRMSR" warnings in qemu-nvmm. To generate a diff of this commit: cvs rdiff -u -r1.41 -r1.42 src/sys/dev/nvmm/x86/nvmm_x86_vmx.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/nvmm/x86/nvmm_x86_vmx.c diff -u src/sys/dev/nvmm/x86/nvmm_x86_vmx.c:1.41 src/sys/dev/nvmm/x86/nvmm_x86_vmx.c:1.42 --- src/sys/dev/nvmm/x86/nvmm_x86_vmx.c:1.41 Sun Oct 27 10:28:55 2019 +++ src/sys/dev/nvmm/x86/nvmm_x86_vmx.c Sun Oct 27 11:11:09 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: nvmm_x86_vmx.c,v 1.41 2019/10/27 10:28:55 maxv Exp $ */ +/* $NetBSD: nvmm_x86_vmx.c,v 1.42 2019/10/27 11:11:09 maxv Exp $ */ /* * Copyright (c) 2018-2019 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_vmx.c,v 1.41 2019/10/27 10:28:55 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_vmx.c,v 1.42 2019/10/27 11:11:09 maxv Exp $"); #include #include @@ -1172,6 +1172,12 @@ vmx_inkernel_handle_cpuid(struct nvmm_cp cpudata->gprs[NVMM_X64_GPR_RCX] &= nvmm_cpuid_0007.ecx; cpudata->gprs[NVMM_X64_GPR_RDX] &= nvmm_cpuid_0007.edx; break; + case 0x000A: + cpudata->gprs[NVMM_X64_GPR_RAX] = 0; + cpudata->gprs[NVMM_X64_GPR_RBX] = 0; + cpudata->gprs[NVMM_X64_GPR_RCX] = 0; + cpudata->gprs[NVMM_X64_GPR_RDX] = 0; + break; case 0x000D: if (vmx_xcr0_mask == 0) { break;
CVS commit: src
Module Name:src Committed By: maxv Date: Sun Oct 27 10:28:55 UTC 2019 Modified Files: src/lib/libnvmm: libnvmm.3 src/sys/dev/nvmm/x86: nvmm_x86.h nvmm_x86_svm.c nvmm_x86_vmx.c Log Message: Add a new VCPU conf option, that allows userland to request VMEXITs after a TPR change. This is supported on all Intel CPUs, and not-too-old AMD CPUs. The reason for wanting this option is that certain OSes (like Win10 64bit) manage interrupt priority in hardware via CR8 directly, and for these OSes, the emulator may want to sync its internal TPR state on each change. Add two new fields in cap.arch, to report the conf capabilities. Report TPR only on Intel for now, not AMD, because I don't have a recent AMD CPU on which to test. To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/lib/libnvmm/libnvmm.3 cvs rdiff -u -r1.16 -r1.17 src/sys/dev/nvmm/x86/nvmm_x86.h cvs rdiff -u -r1.51 -r1.52 src/sys/dev/nvmm/x86/nvmm_x86_svm.c cvs rdiff -u -r1.40 -r1.41 src/sys/dev/nvmm/x86/nvmm_x86_vmx.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src
Module Name:src Committed By: maxv Date: Sun Oct 27 10:28:55 UTC 2019 Modified Files: src/lib/libnvmm: libnvmm.3 src/sys/dev/nvmm/x86: nvmm_x86.h nvmm_x86_svm.c nvmm_x86_vmx.c Log Message: Add a new VCPU conf option, that allows userland to request VMEXITs after a TPR change. This is supported on all Intel CPUs, and not-too-old AMD CPUs. The reason for wanting this option is that certain OSes (like Win10 64bit) manage interrupt priority in hardware via CR8 directly, and for these OSes, the emulator may want to sync its internal TPR state on each change. Add two new fields in cap.arch, to report the conf capabilities. Report TPR only on Intel for now, not AMD, because I don't have a recent AMD CPU on which to test. To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/lib/libnvmm/libnvmm.3 cvs rdiff -u -r1.16 -r1.17 src/sys/dev/nvmm/x86/nvmm_x86.h cvs rdiff -u -r1.51 -r1.52 src/sys/dev/nvmm/x86/nvmm_x86_svm.c cvs rdiff -u -r1.40 -r1.41 src/sys/dev/nvmm/x86/nvmm_x86_vmx.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libnvmm/libnvmm.3 diff -u src/lib/libnvmm/libnvmm.3:1.21 src/lib/libnvmm/libnvmm.3:1.22 --- src/lib/libnvmm/libnvmm.3:1.21 Sun Oct 27 07:08:15 2019 +++ src/lib/libnvmm/libnvmm.3 Sun Oct 27 10:28:55 2019 @@ -1,4 +1,4 @@ -.\" $NetBSD: libnvmm.3,v 1.21 2019/10/27 07:08:15 maxv Exp $ +.\" $NetBSD: libnvmm.3,v 1.22 2019/10/27 10:28:55 maxv Exp $ .\" .\" Copyright (c) 2018, 2019 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -27,7 +27,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd October 25, 2019 +.Dd October 27, 2019 .Dt LIBNVMM 3 .Os .Sh NAME @@ -489,6 +489,7 @@ structure is used to handle VM exits: #define NVMM_VCPU_EXIT_INT_READY 0x1001ULL #define NVMM_VCPU_EXIT_NMI_READY 0x1002ULL #define NVMM_VCPU_EXIT_HALTED 0x1003ULL +#define NVMM_VCPU_EXIT_TPR_CHANGED 0x1004ULL /* x86: instructions. */ #define NVMM_VCPU_EXIT_RDMSR 0x2000ULL #define NVMM_VCPU_EXIT_WRMSR 0x2001ULL Index: src/sys/dev/nvmm/x86/nvmm_x86.h diff -u src/sys/dev/nvmm/x86/nvmm_x86.h:1.16 src/sys/dev/nvmm/x86/nvmm_x86.h:1.17 --- src/sys/dev/nvmm/x86/nvmm_x86.h:1.16 Wed Oct 23 07:01:11 2019 +++ src/sys/dev/nvmm/x86/nvmm_x86.h Sun Oct 27 10:28:55 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: nvmm_x86.h,v 1.16 2019/10/23 07:01:11 maxv Exp $ */ +/* $NetBSD: nvmm_x86.h,v 1.17 2019/10/27 10:28:55 maxv Exp $ */ /* * Copyright (c) 2018-2019 The NetBSD Foundation, Inc. @@ -84,6 +84,7 @@ struct nvmm_x86_exit_invalid { #define NVMM_VCPU_EXIT_INT_READY 0x1001ULL #define NVMM_VCPU_EXIT_NMI_READY 0x1002ULL #define NVMM_VCPU_EXIT_HALTED 0x1003ULL +#define NVMM_VCPU_EXIT_TPR_CHANGED 0x1004ULL /* x86: instructions. */ #define NVMM_VCPU_EXIT_RDMSR 0x2000ULL #define NVMM_VCPU_EXIT_WRMSR 0x2001ULL @@ -118,10 +119,16 @@ struct nvmm_x86_event { }; struct nvmm_cap_md { + uint64_t mach_conf_support; + + uint64_t vcpu_conf_support; +#define NVMM_CAP_ARCH_VCPU_CONF_CPUID __BIT(0) +#define NVMM_CAP_ARCH_VCPU_CONF_TPR __BIT(1) + uint64_t xcr0_mask; uint32_t mxcsr_mask; uint32_t conf_cpuid_maxops; - uint64_t rsvd[6]; + uint64_t rsvd[4]; }; #endif @@ -261,6 +268,7 @@ struct nvmm_x64_state { }; #define NVMM_VCPU_CONF_CPUID NVMM_VCPU_CONF_MD_BEGIN +#define NVMM_VCPU_CONF_TPR (NVMM_VCPU_CONF_MD_BEGIN + 1) struct nvmm_vcpu_conf_cpuid { /* The options. */ @@ -290,13 +298,18 @@ struct nvmm_vcpu_conf_cpuid { } u; }; +struct nvmm_vcpu_conf_tpr { + uint32_t exit_changed:1; + uint32_t rsvd:31; +}; + #define nvmm_vcpu_exit nvmm_x86_exit #define nvmm_vcpu_event nvmm_x86_event #define nvmm_vcpu_state nvmm_x64_state #ifdef _KERNEL #define NVMM_X86_MACH_NCONF 0 -#define NVMM_X86_VCPU_NCONF 1 +#define NVMM_X86_VCPU_NCONF 2 struct nvmm_x86_cpuid_mask { uint32_t eax; uint32_t ebx; Index: src/sys/dev/nvmm/x86/nvmm_x86_svm.c diff -u src/sys/dev/nvmm/x86/nvmm_x86_svm.c:1.51 src/sys/dev/nvmm/x86/nvmm_x86_svm.c:1.52 --- src/sys/dev/nvmm/x86/nvmm_x86_svm.c:1.51 Wed Oct 23 07:01:11 2019 +++ src/sys/dev/nvmm/x86/nvmm_x86_svm.c Sun Oct 27 10:28:55 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: nvmm_x86_svm.c,v 1.51 2019/10/23 07:01:11 maxv Exp $ */ +/* $NetBSD: nvmm_x86_svm.c,v 1.52 2019/10/27 10:28:55 maxv Exp $ */ /* * Copyright (c) 2018-2019 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_svm.c,v 1.51 2019/10/23 07:01:11 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_svm.c,v 1.52 2019/10/27 10:28:55 maxv Exp $"); #include #include @@ -509,7 +509,9 @@ struct svm_machdata { static const size_t svm_vcpu_conf_sizes[NVMM_X86_VCPU_NCONF] = { [NVMM_VCPU_CONF_MD(NVMM_VCPU_CONF_CPUID)] = -
CVS commit: src/lib/libnvmm
Module Name:src Committed By: maxv Date: Sun Oct 27 08:30:05 UTC 2019 Modified Files: src/lib/libnvmm: libnvmm_x86.c Log Message: Use the new PTE naming, and define CR3_FRAME_* separately. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.37 -r1.38 src/lib/libnvmm/libnvmm_x86.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/lib/libnvmm
Module Name:src Committed By: maxv Date: Sun Oct 27 08:30:05 UTC 2019 Modified Files: src/lib/libnvmm: libnvmm_x86.c Log Message: Use the new PTE naming, and define CR3_FRAME_* separately. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.37 -r1.38 src/lib/libnvmm/libnvmm_x86.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libnvmm/libnvmm_x86.c diff -u src/lib/libnvmm/libnvmm_x86.c:1.37 src/lib/libnvmm/libnvmm_x86.c:1.38 --- src/lib/libnvmm/libnvmm_x86.c:1.37 Wed Oct 23 12:02:55 2019 +++ src/lib/libnvmm/libnvmm_x86.c Sun Oct 27 08:30:05 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: libnvmm_x86.c,v 1.37 2019/10/23 12:02:55 maxv Exp $ */ +/* $NetBSD: libnvmm_x86.c,v 1.38 2019/10/27 08:30:05 maxv Exp $ */ /* * Copyright (c) 2018-2019 The NetBSD Foundation, Inc. @@ -116,7 +116,7 @@ nvmm_vcpu_dump(struct nvmm_machine *mach #define pte32_l1idx(va) (((va) & PTE32_L1_MASK) >> PTE32_L1_SHIFT) #define pte32_l2idx(va) (((va) & PTE32_L2_MASK) >> PTE32_L2_SHIFT) -#define CR3_FRAME_32BIT PG_FRAME +#define CR3_FRAME_32BIT __BITS(31, 12) typedef uint32_t pte_32bit_t; @@ -138,36 +138,36 @@ x86_gva_to_gpa_32bit(struct nvmm_machine return -1; pdir = (pte_32bit_t *)L2hva; pte = pdir[pte32_l2idx(gva)]; - if ((pte & PG_V) == 0) + if ((pte & PTE_P) == 0) return -1; - if ((pte & PG_u) == 0) + if ((pte & PTE_U) == 0) *prot &= ~NVMM_PROT_USER; - if ((pte & PG_KW) == 0) + if ((pte & PTE_W) == 0) *prot &= ~NVMM_PROT_WRITE; - if ((pte & PG_PS) && !has_pse) + if ((pte & PTE_PS) && !has_pse) return -1; - if (pte & PG_PS) { + if (pte & PTE_PS) { *gpa = (pte & PTE32_L2_FRAME); *gpa = *gpa + (gva & PTE32_L1_MASK); return 0; } /* Parse L1. */ - L1gpa = (pte & PG_FRAME); + L1gpa = (pte & PTE_FRAME); if (nvmm_gpa_to_hva(mach, L1gpa, , ) == -1) return -1; pdir = (pte_32bit_t *)L1hva; pte = pdir[pte32_l1idx(gva)]; - if ((pte & PG_V) == 0) + if ((pte & PTE_P) == 0) return -1; - if ((pte & PG_u) == 0) + if ((pte & PTE_U) == 0) *prot &= ~NVMM_PROT_USER; - if ((pte & PG_KW) == 0) + if ((pte & PTE_W) == 0) *prot &= ~NVMM_PROT_WRITE; - if (pte & PG_PS) + if (pte & PTE_PS) return -1; - *gpa = (pte & PG_FRAME); + *gpa = (pte & PTE_FRAME); return 0; } @@ -211,51 +211,51 @@ x86_gva_to_gpa_32bit_pae(struct nvmm_mac return -1; pdir = (pte_32bit_pae_t *)L3hva; pte = pdir[pte32_pae_l3idx(gva)]; - if ((pte & PG_V) == 0) + if ((pte & PTE_P) == 0) return -1; - if (pte & PG_NX) + if (pte & PTE_NX) *prot &= ~NVMM_PROT_EXEC; - if (pte & PG_PS) + if (pte & PTE_PS) return -1; /* Parse L2. */ - L2gpa = (pte & PG_FRAME); + L2gpa = (pte & PTE_FRAME); if (nvmm_gpa_to_hva(mach, L2gpa, , ) == -1) return -1; pdir = (pte_32bit_pae_t *)L2hva; pte = pdir[pte32_pae_l2idx(gva)]; - if ((pte & PG_V) == 0) + if ((pte & PTE_P) == 0) return -1; - if ((pte & PG_u) == 0) + if ((pte & PTE_U) == 0) *prot &= ~NVMM_PROT_USER; - if ((pte & PG_KW) == 0) + if ((pte & PTE_W) == 0) *prot &= ~NVMM_PROT_WRITE; - if (pte & PG_NX) + if (pte & PTE_NX) *prot &= ~NVMM_PROT_EXEC; - if (pte & PG_PS) { + if (pte & PTE_PS) { *gpa = (pte & PTE32_PAE_L2_FRAME); *gpa = *gpa + (gva & PTE32_PAE_L1_MASK); return 0; } /* Parse L1. */ - L1gpa = (pte & PG_FRAME); + L1gpa = (pte & PTE_FRAME); if (nvmm_gpa_to_hva(mach, L1gpa, , ) == -1) return -1; pdir = (pte_32bit_pae_t *)L1hva; pte = pdir[pte32_pae_l1idx(gva)]; - if ((pte & PG_V) == 0) + if ((pte & PTE_P) == 0) return -1; - if ((pte & PG_u) == 0) + if ((pte & PTE_U) == 0) *prot &= ~NVMM_PROT_USER; - if ((pte & PG_KW) == 0) + if ((pte & PTE_W) == 0) *prot &= ~NVMM_PROT_WRITE; - if (pte & PG_NX) + if (pte & PTE_NX) *prot &= ~NVMM_PROT_EXEC; - if (pte & PG_PS) + if (pte & PTE_PS) return -1; - *gpa = (pte & PG_FRAME); + *gpa = (pte & PTE_FRAME); return 0; } @@ -281,7 +281,7 @@ x86_gva_to_gpa_32bit_pae(struct nvmm_mac #define pte64_l3idx(va) (((va) & PTE64_L3_MASK) >> PTE64_L3_SHIFT) #define pte64_l4idx(va) (((va) & PTE64_L4_MASK) >> PTE64_L4_SHIFT) -#define CR3_FRAME_64BIT PG_FRAME +#define CR3_FRAME_64BIT __BITS(51, 12) typedef uint64_t pte_64bit_t; @@ -314,75 +314,75 @@ x86_gva_to_gpa_64bit(struct nvmm_machine return -1; pdir = (pte_64bit_t *)L4hva; pte = pdir[pte64_l4idx(gva)]; - if ((pte & PG_V) == 0) + if ((pte & PTE_P) == 0) return -1; - if ((pte & PG_u) == 0) + if ((pte & PTE_U) == 0) *prot &= ~NVMM_PROT_USER; - if ((pte & PG_KW) == 0) + if ((pte & PTE_W) == 0) *prot &= ~NVMM_PROT_WRITE; - if (pte & PG_NX) + if (pte & PTE_NX) *prot &= ~NVMM_PROT_EXEC; - if (pte & PG_PS) + if (pte & PTE_PS) return -1; /* Parse L3. */ - L3gpa = (pte & PG_FRAME); + L3gpa = (pte & PTE_FRAME); if (nvmm_gpa_to_hva(mach, L3gpa, , ) == -1) return -1; pdir = (pte_64bit_t *)L3hva; pte = pdir[pte64_l3idx(gva)]; - if ((pte & PG_V) == 0) + if ((pte
CVS commit: src
Module Name:src Committed By: maxv Date: Sun Oct 27 07:08:15 UTC 2019 Modified Files: src/etc: MAKEDEV.tmpl group src/lib/libnvmm: libnvmm.3 libnvmm.c nvmm.h src/tests/lib/libnvmm: h_io_assist.c h_mem_assist.c Log Message: Add the "nvmm" group, and make nvmm_init() public. Sent to tech-kern@ a few days ago. To generate a diff of this commit: cvs rdiff -u -r1.208 -r1.209 src/etc/MAKEDEV.tmpl cvs rdiff -u -r1.34 -r1.35 src/etc/group cvs rdiff -u -r1.20 -r1.21 src/lib/libnvmm/libnvmm.3 cvs rdiff -u -r1.16 -r1.17 src/lib/libnvmm/libnvmm.c cvs rdiff -u -r1.14 -r1.15 src/lib/libnvmm/nvmm.h cvs rdiff -u -r1.10 -r1.11 src/tests/lib/libnvmm/h_io_assist.c cvs rdiff -u -r1.16 -r1.17 src/tests/lib/libnvmm/h_mem_assist.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/etc/MAKEDEV.tmpl diff -u src/etc/MAKEDEV.tmpl:1.208 src/etc/MAKEDEV.tmpl:1.209 --- src/etc/MAKEDEV.tmpl:1.208 Thu Sep 19 01:44:48 2019 +++ src/etc/MAKEDEV.tmpl Sun Oct 27 07:08:15 2019 @@ -1,5 +1,5 @@ #!/bin/sh - -# $NetBSD: MAKEDEV.tmpl,v 1.208 2019/09/19 01:44:48 thorpej Exp $ +# $NetBSD: MAKEDEV.tmpl,v 1.209 2019/10/27 07:08:15 maxv Exp $ # # Copyright (c) 2003,2007,2008 The NetBSD Foundation, Inc. # All rights reserved. @@ -500,6 +500,7 @@ setup() g_gpio="%gid__gpio%" g_kmem="%gid_kmem%" g_ntpd="%gid_ntpd%" + g_nvmm="%gid_nvmm%" g_operator="%gid_operator%" g_wheel="%gid_wheel%" dialin=0 @@ -2227,7 +2228,7 @@ nvme[0-9]*) ;; nvmm) - mkdev nvmm c %nvmm_chr% 0 + mkdev nvmm c %nvmm_chr% 0 640 $g_nvmm ;; autofs) Index: src/etc/group diff -u src/etc/group:1.34 src/etc/group:1.35 --- src/etc/group:1.34 Sat Jan 7 20:00:33 2017 +++ src/etc/group Sun Oct 27 07:08:15 2019 @@ -29,6 +29,7 @@ _rtadvd:*:30: guest:*:31:root _unbound:*:32: _nsd:*:33: +nvmm:*:34:root nobody:*:39: utmp:*:45: authpf:*:72: Index: src/lib/libnvmm/libnvmm.3 diff -u src/lib/libnvmm/libnvmm.3:1.20 src/lib/libnvmm/libnvmm.3:1.21 --- src/lib/libnvmm/libnvmm.3:1.20 Fri Oct 25 09:09:24 2019 +++ src/lib/libnvmm/libnvmm.3 Sun Oct 27 07:08:15 2019 @@ -1,4 +1,4 @@ -.\" $NetBSD: libnvmm.3,v 1.20 2019/10/25 09:09:24 maxv Exp $ +.\" $NetBSD: libnvmm.3,v 1.21 2019/10/27 07:08:15 maxv Exp $ .\" .\" Copyright (c) 2018, 2019 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -38,6 +38,8 @@ .Sh SYNOPSIS .In nvmm.h .Ft int +.Fn nvmm_init "void" +.Ft int .Fn nvmm_capability "struct nvmm_capability *cap" .Ft int .Fn nvmm_machine_create "struct nvmm_machine *mach" @@ -98,6 +100,12 @@ to manage virtual machines. A virtual CPU is described by a public structure, .Cd nvmm_vcpu . .Pp +.Fn nvmm_init +initializes NVMM. +See +.Sx NVMM Initialization +below for details. +.Pp .Fn nvmm_capability gets the capabilities of NVMM. See @@ -277,6 +285,23 @@ from machine See .Sx Mem Assist below for details. +.Ss NVMM Initialization +NVMM initialization is performed by the +.Fn nvmm_init +function, which must be invoked by emulator software before any other NVMM +function. +.Pp +.Fn nvmm_init +opens the NVMM device, and expects to have the proper permissions to do so. +In a default configuration, this implies being part of the "nvmm" group. +If using a special configuration, emulator software should arrange to have the +proper permissions before invoking +.Fn nvmm_init , +and can drop them after the call has completed. +.Pp +It is to be noted that +.Fn nvmm_init +may perform non-re-entrant operations, and should be called only once. .Ss NVMM Capability The .Cd nvmm_capability Index: src/lib/libnvmm/libnvmm.c diff -u src/lib/libnvmm/libnvmm.c:1.16 src/lib/libnvmm/libnvmm.c:1.17 --- src/lib/libnvmm/libnvmm.c:1.16 Wed Oct 23 12:02:55 2019 +++ src/lib/libnvmm/libnvmm.c Sun Oct 27 07:08:15 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: libnvmm.c,v 1.16 2019/10/23 12:02:55 maxv Exp $ */ +/* $NetBSD: libnvmm.c,v 1.17 2019/10/27 07:08:15 maxv Exp $ */ /* * Copyright (c) 2018-2019 The NetBSD Foundation, Inc. @@ -156,7 +156,7 @@ __area_remove_all(struct nvmm_machine *m /* -- */ -static int +int nvmm_init(void) { if (nvmm_fd != -1) @@ -185,10 +185,6 @@ nvmm_capability(struct nvmm_capability * struct nvmm_ioc_capability args; int ret; - if (nvmm_init() == -1) { - return -1; - } - ret = ioctl(nvmm_fd, NVMM_IOC_CAPABILITY, ); if (ret == -1) return -1; @@ -206,10 +202,6 @@ nvmm_machine_create(struct nvmm_machine area_list_t *areas; int ret; - if (nvmm_init() == -1) { - return -1; - } - areas = calloc(1, sizeof(*areas)); if (areas == NULL) return -1; @@ -537,10 +529,6 @@ nvmm_ctl(int op, void *data, size_t size struct nvmm_ioc_ctl args; int ret; - if (nvmm_init() == -1) { - return -1; - } - args.op = op; args.data = data; args.size = size; Index: src/lib/libnvmm/nvmm.h diff -u src/lib/libnvmm/nvmm.h:1.14 src/lib/libnvmm/nvmm.h:1.15 ---
CVS commit: src
Module Name:src Committed By: maxv Date: Sun Oct 27 07:08:15 UTC 2019 Modified Files: src/etc: MAKEDEV.tmpl group src/lib/libnvmm: libnvmm.3 libnvmm.c nvmm.h src/tests/lib/libnvmm: h_io_assist.c h_mem_assist.c Log Message: Add the "nvmm" group, and make nvmm_init() public. Sent to tech-kern@ a few days ago. To generate a diff of this commit: cvs rdiff -u -r1.208 -r1.209 src/etc/MAKEDEV.tmpl cvs rdiff -u -r1.34 -r1.35 src/etc/group cvs rdiff -u -r1.20 -r1.21 src/lib/libnvmm/libnvmm.3 cvs rdiff -u -r1.16 -r1.17 src/lib/libnvmm/libnvmm.c cvs rdiff -u -r1.14 -r1.15 src/lib/libnvmm/nvmm.h cvs rdiff -u -r1.10 -r1.11 src/tests/lib/libnvmm/h_io_assist.c cvs rdiff -u -r1.16 -r1.17 src/tests/lib/libnvmm/h_mem_assist.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/lib/libnvmm
Module Name:src Committed By: maxv Date: Fri Oct 25 09:09:24 UTC 2019 Modified Files: src/lib/libnvmm: libnvmm.3 Log Message: Update the libnvmm man page: - Sync the naming with reality. - Replace "relevant" by "desired" and "virtualizer" by "emulator", closer to what I meant. - Add a "VCPU Configuration" section. - Add a "Machine Ownership" section. To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/lib/libnvmm/libnvmm.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libnvmm/libnvmm.3 diff -u src/lib/libnvmm/libnvmm.3:1.19 src/lib/libnvmm/libnvmm.3:1.20 --- src/lib/libnvmm/libnvmm.3:1.19 Sat Jun 8 07:27:44 2019 +++ src/lib/libnvmm/libnvmm.3 Fri Oct 25 09:09:24 2019 @@ -1,4 +1,4 @@ -.\" $NetBSD: libnvmm.3,v 1.19 2019/06/08 07:27:44 maxv Exp $ +.\" $NetBSD: libnvmm.3,v 1.20 2019/10/25 09:09:24 maxv Exp $ .\" .\" Copyright (c) 2018, 2019 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -27,7 +27,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd May 30, 2019 +.Dd October 25, 2019 .Dt LIBNVMM 3 .Os .Sh NAME @@ -52,6 +52,9 @@ .Ft int .Fn nvmm_vcpu_destroy "struct nvmm_machine *mach" "struct nvmm_vcpu *vcpu" .Ft int +.Fn nvmm_vcpu_configure "struct nvmm_machine *mach" "struct nvmm_vcpu *vcpu" \ +"uint64_t op" "void *conf" +.Ft int .Fn nvmm_vcpu_getstate "struct nvmm_machine *mach" "struct nvmm_vcpu *vcpu" \ "uint64_t flags" .Ft int @@ -133,6 +136,16 @@ destroys the virtual CPU identified by in the machine .Fa mach . .Pp +.Fn nvmm_vcpu_configure +configures, on the VCPU +.Fa vcpu +of machine +.Fa mach , +the parameter indicated in +.Fa op . +.Fa conf +describes the value of the parameter. +.Pp .Fn nvmm_vcpu_getstate gets the state of the virtual CPU identified by .Fa vcpu @@ -287,12 +300,28 @@ For example, the field indicates the maximum number of virtual machines supported, while .Cd max_vcpus indicates the maximum number of VCPUs supported per virtual machine. +.Ss Machine Ownership +When a process creates a virtual machine via +.Fn nvmm_machine_create , +it is considered the owner of this machine. +No other processes than the owner can operate a virtual machine. +.Pp +When an owner exits, all the virtual machines associated with it are destroyed, +if they were not already destroyed by the owner itself via +.Fn nvmm_machine_destroy . +.Pp +Virtual machines are not inherited across +.Xr fork 9 +operations. .Ss Machine Configuration Emulator software can configure several parameters of a virtual machine by using -.Fn nvmm_machine_configure , -which can take the following operations: +.Fn nvmm_machine_configure . +Currently, no parameters are implemented. +.Ss VCPU Configuration +Emulator software can configure several parameters of a VCPU by using +.Fn nvmm_vcpu_configure , which can take the following operations: .Bd -literal -#define NVMM_MACH_CONF_CALLBACKS 0 +#define NVMM_VCPU_CONF_CALLBACKS 0 ... .Ed .Pp @@ -386,8 +415,8 @@ A VCPU is described by a public structur struct nvmm_vcpu { nvmm_cpuid_t cpuid; struct nvmm_vcpu_state *state; - struct nvmm_event *event; - struct nvmm_exit *exit; + struct nvmm_vcpu_event *event; + struct nvmm_vcpu_exit *exit; }; .Ed .Pp @@ -399,11 +428,11 @@ they are initialized to special values b .Pp A call to .Fn nvmm_vcpu_getstate -will fetch the relevant parts of the VCPU state and put them in +will fetch the desired parts of the VCPU state and put them in .Fa vcpu->state . A call to .Fn nvmm_vcpu_setstate -will install in the VCPU the relevant parts of +will install in the VCPU the desired parts of .Fa vcpu->state . A call to .Fn nvmm_vcpu_inject @@ -421,22 +450,28 @@ Emulator software should not modify the different threads. .Ss Exit Reasons The -.Cd nvmm_exit +.Cd nvmm_vcpu_exit structure is used to handle VM exits: .Bd -literal -/* Exit Reasons */ -#define NVMM_EXIT_NONE 0xULL -#define NVMM_EXIT_MEMORY 0x0001ULL -#define NVMM_EXIT_IO 0x0002ULL -#define NVMM_EXIT_MSR 0x0003ULL -#define NVMM_EXIT_INT_READY 0x0004ULL -#define NVMM_EXIT_NMI_READY 0x0005ULL -#define NVMM_EXIT_HALTED 0x0006ULL -#define NVMM_EXIT_SHUTDOWN 0x0007ULL - ... -#define NVMM_EXIT_INVALID 0xULL +/* Generic. */ +#define NVMM_VCPU_EXIT_NONE 0xULL +#define NVMM_VCPU_EXIT_INVALID 0xULL +/* x86: operations. */ +#define NVMM_VCPU_EXIT_MEMORY 0x0001ULL +#define NVMM_VCPU_EXIT_IO 0x0002ULL +/* x86: changes in VCPU state. */ +#define NVMM_VCPU_EXIT_SHUTDOWN 0x1000ULL +#define NVMM_VCPU_EXIT_INT_READY 0x1001ULL +#define NVMM_VCPU_EXIT_NMI_READY 0x1002ULL +#define NVMM_VCPU_EXIT_HALTED 0x1003ULL +/*
CVS commit: src/lib/libnvmm
Module Name:src Committed By: maxv Date: Fri Oct 25 09:09:24 UTC 2019 Modified Files: src/lib/libnvmm: libnvmm.3 Log Message: Update the libnvmm man page: - Sync the naming with reality. - Replace "relevant" by "desired" and "virtualizer" by "emulator", closer to what I meant. - Add a "VCPU Configuration" section. - Add a "Machine Ownership" section. To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/lib/libnvmm/libnvmm.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src
Module Name:src Committed By: maxv Date: Wed Oct 23 12:02:56 UTC 2019 Modified Files: src/lib/libnvmm: libnvmm.c libnvmm_x86.c nvmm.h src/tests/lib/libnvmm: h_io_assist.c h_mem_assist.c Log Message: Three changes in libnvmm: - Add 'mach' and 'vcpu' backpointers in the nvmm_io and nvmm_mem structures. - Rename 'nvmm_callbacks' to 'nvmm_assist_callbacks'. - Rename and migrate NVMM_MACH_CONF_CALLBACKS to NVMM_VCPU_CONF_CALLBACKS, it now becomes per-VCPU. To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/lib/libnvmm/libnvmm.c cvs rdiff -u -r1.36 -r1.37 src/lib/libnvmm/libnvmm_x86.c cvs rdiff -u -r1.13 -r1.14 src/lib/libnvmm/nvmm.h cvs rdiff -u -r1.9 -r1.10 src/tests/lib/libnvmm/h_io_assist.c cvs rdiff -u -r1.15 -r1.16 src/tests/lib/libnvmm/h_mem_assist.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libnvmm/libnvmm.c diff -u src/lib/libnvmm/libnvmm.c:1.15 src/lib/libnvmm/libnvmm.c:1.16 --- src/lib/libnvmm/libnvmm.c:1.15 Wed Oct 23 07:01:11 2019 +++ src/lib/libnvmm/libnvmm.c Wed Oct 23 12:02:55 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: libnvmm.c,v 1.15 2019/10/23 07:01:11 maxv Exp $ */ +/* $NetBSD: libnvmm.c,v 1.16 2019/10/23 12:02:55 maxv Exp $ */ /* * Copyright (c) 2018-2019 The NetBSD Foundation, Inc. @@ -260,12 +260,6 @@ nvmm_machine_configure(struct nvmm_machi struct nvmm_ioc_machine_configure args; int ret; - switch (op) { - case NVMM_MACH_CONF_CALLBACKS: - memcpy(>cbs, conf, sizeof(mach->cbs)); - return 0; - } - args.machid = mach->machid; args.op = op; args.conf = conf; @@ -335,6 +329,12 @@ nvmm_vcpu_configure(struct nvmm_machine struct nvmm_ioc_vcpu_configure args; int ret; + switch (op) { + case NVMM_VCPU_CONF_CALLBACKS: + memcpy(>cbs, conf, sizeof(vcpu->cbs)); + return 0; + } + args.machid = mach->machid; args.cpuid = vcpu->cpuid; args.op = op; Index: src/lib/libnvmm/libnvmm_x86.c diff -u src/lib/libnvmm/libnvmm_x86.c:1.36 src/lib/libnvmm/libnvmm_x86.c:1.37 --- src/lib/libnvmm/libnvmm_x86.c:1.36 Wed Oct 23 07:01:11 2019 +++ src/lib/libnvmm/libnvmm_x86.c Wed Oct 23 12:02:55 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: libnvmm_x86.c,v 1.36 2019/10/23 07:01:11 maxv Exp $ */ +/* $NetBSD: libnvmm_x86.c,v 1.37 2019/10/23 12:02:55 maxv Exp $ */ /* * Copyright (c) 2018-2019 The NetBSD Foundation, Inc. @@ -555,9 +555,10 @@ rep_set_cnt(struct nvmm_x64_state *state } static int -read_guest_memory(struct nvmm_machine *mach, struct nvmm_x64_state *state, +read_guest_memory(struct nvmm_machine *mach, struct nvmm_vcpu *vcpu, gvaddr_t gva, uint8_t *data, size_t size) { + struct nvmm_x64_state *state = vcpu->state; struct nvmm_mem mem; nvmm_prot_t prot; gpaddr_t gpa; @@ -585,11 +586,13 @@ read_guest_memory(struct nvmm_machine *m is_mmio = (ret == -1); if (is_mmio) { + mem.mach = mach; + mem.vcpu = vcpu; mem.data = data; mem.gpa = gpa; mem.write = false; mem.size = size; - (*mach->cbs.mem)(); + (*vcpu->cbs.mem)(); } else { if (__predict_false(!(prot & NVMM_PROT_READ))) { errno = EFAULT; @@ -599,7 +602,7 @@ read_guest_memory(struct nvmm_machine *m } if (remain > 0) { - ret = read_guest_memory(mach, state, gva + size, + ret = read_guest_memory(mach, vcpu, gva + size, data + size, remain); } else { ret = 0; @@ -609,9 +612,10 @@ read_guest_memory(struct nvmm_machine *m } static int -write_guest_memory(struct nvmm_machine *mach, struct nvmm_x64_state *state, +write_guest_memory(struct nvmm_machine *mach, struct nvmm_vcpu *vcpu, gvaddr_t gva, uint8_t *data, size_t size) { + struct nvmm_x64_state *state = vcpu->state; struct nvmm_mem mem; nvmm_prot_t prot; gpaddr_t gpa; @@ -639,11 +643,13 @@ write_guest_memory(struct nvmm_machine * is_mmio = (ret == -1); if (is_mmio) { + mem.mach = mach; + mem.vcpu = vcpu; mem.data = data; mem.gpa = gpa; mem.write = true; mem.size = size; - (*mach->cbs.mem)(); + (*vcpu->cbs.mem)(); } else { if (__predict_false(!(prot & NVMM_PROT_WRITE))) { errno = EFAULT; @@ -653,7 +659,7 @@ write_guest_memory(struct nvmm_machine * } if (remain > 0) { - ret = write_guest_memory(mach, state, gva + size, + ret = write_guest_memory(mach, vcpu, gva + size, data + size, remain); } else { ret = 0; @@ -664,12 +670,12 @@ write_guest_memory(struct nvmm_machine * /* -- */ -static int fetch_segment(struct nvmm_machine *, struct nvmm_x64_state *); +static int fetch_segment(struct nvmm_machine *, struct nvmm_vcpu *); #define NVMM_IO_BATCH_SIZE 32 static int -assist_io_batch(struct nvmm_machine *mach, struct nvmm_x64_state *state, +assist_io_batch(struct nvmm_machine *mach, struct nvmm_vcpu *vcpu, struct nvmm_io *io, gvaddr_t gva, uint64_t cnt) { uint8_t iobuf[NVMM_IO_BATCH_SIZE]; @@ -683,18 +689,18 @@
CVS commit: src
Module Name:src Committed By: maxv Date: Wed Oct 23 12:02:56 UTC 2019 Modified Files: src/lib/libnvmm: libnvmm.c libnvmm_x86.c nvmm.h src/tests/lib/libnvmm: h_io_assist.c h_mem_assist.c Log Message: Three changes in libnvmm: - Add 'mach' and 'vcpu' backpointers in the nvmm_io and nvmm_mem structures. - Rename 'nvmm_callbacks' to 'nvmm_assist_callbacks'. - Rename and migrate NVMM_MACH_CONF_CALLBACKS to NVMM_VCPU_CONF_CALLBACKS, it now becomes per-VCPU. To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/lib/libnvmm/libnvmm.c cvs rdiff -u -r1.36 -r1.37 src/lib/libnvmm/libnvmm_x86.c cvs rdiff -u -r1.13 -r1.14 src/lib/libnvmm/nvmm.h cvs rdiff -u -r1.9 -r1.10 src/tests/lib/libnvmm/h_io_assist.c cvs rdiff -u -r1.15 -r1.16 src/tests/lib/libnvmm/h_mem_assist.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src
Module Name:src Committed By: maxv Date: Wed Oct 23 07:01:12 UTC 2019 Modified Files: src/lib/libnvmm: libnvmm.c libnvmm_x86.c nvmm.h src/sys/dev/nvmm: nvmm.c nvmm.h nvmm_internal.h nvmm_ioctl.h src/sys/dev/nvmm/x86: nvmm_x86.h nvmm_x86_svm.c nvmm_x86_vmx.c src/tests/lib/libnvmm: h_io_assist.c h_mem_assist.c Log Message: Miscellaneous changes in NVMM, to address several inconsistencies and issues in the libnvmm API. - Rename NVMM_CAPABILITY_VERSION to NVMM_KERN_VERSION, and check it in libnvmm. Introduce NVMM_USER_VERSION, for future use. - In libnvmm, open "/dev/nvmm" as read-only and with O_CLOEXEC. This is to avoid sharing the VMs with the children if the process forks. In the NVMM driver, force O_CLOEXEC on open(). - Rename the following things for consistency: nvmm_exit* -> nvmm_vcpu_exit* nvmm_event* -> nvmm_vcpu_event* NVMM_EXIT_* -> NVMM_VCPU_EXIT_* NVMM_EVENT_INTERRUPT_HW -> NVMM_VCPU_EVENT_INTR NVMM_EVENT_EXCEPTION-> NVMM_VCPU_EVENT_EXCP Delete NVMM_EVENT_INTERRUPT_SW, unused already. - Slightly reorganize the MI/MD definitions, for internal clarity. - Split NVMM_VCPU_EXIT_MSR in two: NVMM_VCPU_EXIT_{RD,WR}MSR. Also provide separate u.rdmsr and u.wrmsr fields. This is more consistent with the other exit reasons. - Change the types of several variables: event.type enum -> u_int event.vectoruint64_t -> uint8_t exit.u.*msr.msr:uint64_t -> uint32_t exit.u.io.type: enum -> bool exit.u.io.seg: int -> int8_t cap.arch.mxcsr_mask:uint64_t -> uint32_t cap.arch.conf_cpuid_maxops: uint64_t -> uint32_t - Delete NVMM_VCPU_EXIT_MWAIT_COND, it is AMD-only and confusing, and we already intercept 'monitor' so it is never armed. - Introduce vmx_exit_insn() for NVMM-Intel, similar to svm_exit_insn(). The 'npc' field wasn't getting filled properly during certain VMEXITs. - Introduce nvmm_vcpu_configure(). Similar to nvmm_machine_configure(), but as its name indicates, the configuration is per-VCPU and not per-VM. Migrate and rename NVMM_MACH_CONF_X86_CPUID to NVMM_VCPU_CONF_CPUID. This becomes per-VCPU, which makes more sense than per-VM. - Extend the NVMM_VCPU_CONF_CPUID conf to allow triggering VMEXITs on specific leaves. Until now we could only mask the leaves. An uint32_t is added in the structure: uint32_t mask:1; uint32_t exit:1; uint32_t rsvd:30; The two first bits select the desired behavior on the leaf. Specifying zero on both resets the leaf to the default behavior. The new NVMM_VCPU_EXIT_CPUID exit reason is added. To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/lib/libnvmm/libnvmm.c cvs rdiff -u -r1.35 -r1.36 src/lib/libnvmm/libnvmm_x86.c cvs rdiff -u -r1.12 -r1.13 src/lib/libnvmm/nvmm.h cvs rdiff -u -r1.22 -r1.23 src/sys/dev/nvmm/nvmm.c cvs rdiff -u -r1.10 -r1.11 src/sys/dev/nvmm/nvmm.h cvs rdiff -u -r1.12 -r1.13 src/sys/dev/nvmm/nvmm_internal.h cvs rdiff -u -r1.7 -r1.8 src/sys/dev/nvmm/nvmm_ioctl.h cvs rdiff -u -r1.15 -r1.16 src/sys/dev/nvmm/x86/nvmm_x86.h cvs rdiff -u -r1.50 -r1.51 src/sys/dev/nvmm/x86/nvmm_x86_svm.c cvs rdiff -u -r1.39 -r1.40 src/sys/dev/nvmm/x86/nvmm_x86_vmx.c cvs rdiff -u -r1.8 -r1.9 src/tests/lib/libnvmm/h_io_assist.c cvs rdiff -u -r1.14 -r1.15 src/tests/lib/libnvmm/h_mem_assist.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src
Module Name:src Committed By: maxv Date: Wed Oct 23 07:01:12 UTC 2019 Modified Files: src/lib/libnvmm: libnvmm.c libnvmm_x86.c nvmm.h src/sys/dev/nvmm: nvmm.c nvmm.h nvmm_internal.h nvmm_ioctl.h src/sys/dev/nvmm/x86: nvmm_x86.h nvmm_x86_svm.c nvmm_x86_vmx.c src/tests/lib/libnvmm: h_io_assist.c h_mem_assist.c Log Message: Miscellaneous changes in NVMM, to address several inconsistencies and issues in the libnvmm API. - Rename NVMM_CAPABILITY_VERSION to NVMM_KERN_VERSION, and check it in libnvmm. Introduce NVMM_USER_VERSION, for future use. - In libnvmm, open "/dev/nvmm" as read-only and with O_CLOEXEC. This is to avoid sharing the VMs with the children if the process forks. In the NVMM driver, force O_CLOEXEC on open(). - Rename the following things for consistency: nvmm_exit* -> nvmm_vcpu_exit* nvmm_event* -> nvmm_vcpu_event* NVMM_EXIT_* -> NVMM_VCPU_EXIT_* NVMM_EVENT_INTERRUPT_HW -> NVMM_VCPU_EVENT_INTR NVMM_EVENT_EXCEPTION-> NVMM_VCPU_EVENT_EXCP Delete NVMM_EVENT_INTERRUPT_SW, unused already. - Slightly reorganize the MI/MD definitions, for internal clarity. - Split NVMM_VCPU_EXIT_MSR in two: NVMM_VCPU_EXIT_{RD,WR}MSR. Also provide separate u.rdmsr and u.wrmsr fields. This is more consistent with the other exit reasons. - Change the types of several variables: event.type enum -> u_int event.vectoruint64_t -> uint8_t exit.u.*msr.msr:uint64_t -> uint32_t exit.u.io.type: enum -> bool exit.u.io.seg: int -> int8_t cap.arch.mxcsr_mask:uint64_t -> uint32_t cap.arch.conf_cpuid_maxops: uint64_t -> uint32_t - Delete NVMM_VCPU_EXIT_MWAIT_COND, it is AMD-only and confusing, and we already intercept 'monitor' so it is never armed. - Introduce vmx_exit_insn() for NVMM-Intel, similar to svm_exit_insn(). The 'npc' field wasn't getting filled properly during certain VMEXITs. - Introduce nvmm_vcpu_configure(). Similar to nvmm_machine_configure(), but as its name indicates, the configuration is per-VCPU and not per-VM. Migrate and rename NVMM_MACH_CONF_X86_CPUID to NVMM_VCPU_CONF_CPUID. This becomes per-VCPU, which makes more sense than per-VM. - Extend the NVMM_VCPU_CONF_CPUID conf to allow triggering VMEXITs on specific leaves. Until now we could only mask the leaves. An uint32_t is added in the structure: uint32_t mask:1; uint32_t exit:1; uint32_t rsvd:30; The two first bits select the desired behavior on the leaf. Specifying zero on both resets the leaf to the default behavior. The new NVMM_VCPU_EXIT_CPUID exit reason is added. To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/lib/libnvmm/libnvmm.c cvs rdiff -u -r1.35 -r1.36 src/lib/libnvmm/libnvmm_x86.c cvs rdiff -u -r1.12 -r1.13 src/lib/libnvmm/nvmm.h cvs rdiff -u -r1.22 -r1.23 src/sys/dev/nvmm/nvmm.c cvs rdiff -u -r1.10 -r1.11 src/sys/dev/nvmm/nvmm.h cvs rdiff -u -r1.12 -r1.13 src/sys/dev/nvmm/nvmm_internal.h cvs rdiff -u -r1.7 -r1.8 src/sys/dev/nvmm/nvmm_ioctl.h cvs rdiff -u -r1.15 -r1.16 src/sys/dev/nvmm/x86/nvmm_x86.h cvs rdiff -u -r1.50 -r1.51 src/sys/dev/nvmm/x86/nvmm_x86_svm.c cvs rdiff -u -r1.39 -r1.40 src/sys/dev/nvmm/x86/nvmm_x86_vmx.c cvs rdiff -u -r1.8 -r1.9 src/tests/lib/libnvmm/h_io_assist.c cvs rdiff -u -r1.14 -r1.15 src/tests/lib/libnvmm/h_mem_assist.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libnvmm/libnvmm.c diff -u src/lib/libnvmm/libnvmm.c:1.14 src/lib/libnvmm/libnvmm.c:1.15 --- src/lib/libnvmm/libnvmm.c:1.14 Sat Jun 8 07:27:44 2019 +++ src/lib/libnvmm/libnvmm.c Wed Oct 23 07:01:11 2019 @@ -1,7 +1,7 @@ -/* $NetBSD: libnvmm.c,v 1.14 2019/06/08 07:27:44 maxv Exp $ */ +/* $NetBSD: libnvmm.c,v 1.15 2019/10/23 07:01:11 maxv Exp $ */ /* - * Copyright (c) 2018 The NetBSD Foundation, Inc. + * Copyright (c) 2018-2019 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -161,7 +161,7 @@ nvmm_init(void) { if (nvmm_fd != -1) return 0; - nvmm_fd = open("/dev/nvmm", O_RDWR); + nvmm_fd = open("/dev/nvmm", O_RDONLY | O_CLOEXEC); if (nvmm_fd == -1) return -1; if (nvmm_capability(&__capability) == -1) { @@ -169,6 +169,13 @@ nvmm_init(void) nvmm_fd = -1; return -1; } + if (__capability.version != NVMM_KERN_VERSION) { + close(nvmm_fd); + nvmm_fd = -1; + errno = EPROGMISMATCH; + return -1; + } + return 0; } @@ -322,6 +329,25 @@ nvmm_vcpu_destroy(struct nvmm_machine *m } int +nvmm_vcpu_configure(struct nvmm_machine *mach, struct nvmm_vcpu *vcpu, +uint64_t op, void *conf) +{ + struct nvmm_ioc_vcpu_configure args; + int ret; + + args.machid = mach->machid; + args.cpuid = vcpu->cpuid; +
CVS commit: src/sys/arch/x86/x86
Module Name:src Committed By: maxv Date: Mon Oct 21 10:09:24 UTC 2019 Modified Files: src/sys/arch/x86/x86: identcpu.c Log Message: Call cpu_probe_fpu() only once (from cpu0), and style. To generate a diff of this commit: cvs rdiff -u -r1.96 -r1.97 src/sys/arch/x86/x86/identcpu.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/x86/identcpu.c diff -u src/sys/arch/x86/x86/identcpu.c:1.96 src/sys/arch/x86/x86/identcpu.c:1.97 --- src/sys/arch/x86/x86/identcpu.c:1.96 Thu Oct 3 05:06:29 2019 +++ src/sys/arch/x86/x86/identcpu.c Mon Oct 21 10:09:24 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: identcpu.c,v 1.96 2019/10/03 05:06:29 maxv Exp $ */ +/* $NetBSD: identcpu.c,v 1.97 2019/10/21 10:09:24 maxv Exp $ */ /*- * Copyright (c) 1999, 2000, 2001, 2006, 2007, 2008 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: identcpu.c,v 1.96 2019/10/03 05:06:29 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: identcpu.c,v 1.97 2019/10/21 10:09:24 maxv Exp $"); #include "opt_xen.h" @@ -736,7 +736,7 @@ cpu_probe_vortex86(struct cpu_info *ci) } static void -cpu_probe_old_fpu(struct cpu_info *ci) +cpu_probe_fpu_old(struct cpu_info *ci) { #if defined(__i386__) && !defined(XENPV) @@ -764,8 +764,7 @@ cpu_probe_fpu(struct cpu_info *ci) /* If we have FXSAVE/FXRESTOR, use them. */ if ((ci->ci_feat_val[0] & CPUID_FXSR) == 0) { i386_use_fxsave = 0; - /* Allow for no fpu even if cpuid is supported */ - cpu_probe_old_fpu(ci); + cpu_probe_fpu_old(ci); return; } @@ -788,14 +787,14 @@ cpu_probe_fpu(struct cpu_info *ci) x86_fpu_save = FPU_SAVE_FXSAVE; x86_fpu_save_size = sizeof(struct fxsave); - /* See if xsave (for AVX) is supported */ + /* See if XSAVE is supported */ if ((ci->ci_feat_val[1] & CPUID2_XSAVE) == 0) return; #ifdef XENPV /* * Xen kernel can disable XSAVE via "no-xsave" option, in that case - * XSAVE instructions like xrstor become privileged and trigger + * the XSAVE/XRSTOR instructions become privileged and trigger * supervisor trap. OSXSAVE flag seems to be reliably set according * to whether XSAVE is actually available. */ @@ -843,7 +842,7 @@ cpu_probe(struct cpu_info *ci) if (cpuid_level < 0) { /* cpuid instruction not supported */ - cpu_probe_old_fpu(ci); + cpu_probe_fpu_old(ci); return; } @@ -949,7 +948,9 @@ cpu_probe(struct cpu_info *ci) cpu_probe_geode(ci); cpu_probe_vortex86(ci); - cpu_probe_fpu(ci); + if (ci == _info_primary) { + cpu_probe_fpu(ci); + } x86_cpu_topology(ci);
CVS commit: src/sys/arch/x86/x86
Module Name:src Committed By: maxv Date: Mon Oct 21 10:09:24 UTC 2019 Modified Files: src/sys/arch/x86/x86: identcpu.c Log Message: Call cpu_probe_fpu() only once (from cpu0), and style. To generate a diff of this commit: cvs rdiff -u -r1.96 -r1.97 src/sys/arch/x86/x86/identcpu.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/lib/libnvmm
Module Name:src Committed By: maxv Date: Sat Oct 19 19:45:10 UTC 2019 Modified Files: src/lib/libnvmm: libnvmm_x86.c Log Message: Put back 'default', because llvm apparently doesn't realize that all cases are covered in the switch. To generate a diff of this commit: cvs rdiff -u -r1.34 -r1.35 src/lib/libnvmm/libnvmm_x86.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libnvmm/libnvmm_x86.c diff -u src/lib/libnvmm/libnvmm_x86.c:1.34 src/lib/libnvmm/libnvmm_x86.c:1.35 --- src/lib/libnvmm/libnvmm_x86.c:1.34 Mon Oct 14 10:43:40 2019 +++ src/lib/libnvmm/libnvmm_x86.c Sat Oct 19 19:45:10 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: libnvmm_x86.c,v 1.34 2019/10/14 10:43:40 maxv Exp $ */ +/* $NetBSD: libnvmm_x86.c,v 1.35 2019/10/19 19:45:10 maxv Exp $ */ /* * Copyright (c) 2018-2019 The NetBSD Foundation, Inc. @@ -2240,6 +2240,7 @@ get_disp_type(struct x86_instr *instr) } return DISP_4; case 0b11: /* direct */ + default: /* llvm */ return DISP_NONE; } }
CVS commit: src/lib/libnvmm
Module Name:src Committed By: maxv Date: Sat Oct 19 19:45:10 UTC 2019 Modified Files: src/lib/libnvmm: libnvmm_x86.c Log Message: Put back 'default', because llvm apparently doesn't realize that all cases are covered in the switch. To generate a diff of this commit: cvs rdiff -u -r1.34 -r1.35 src/lib/libnvmm/libnvmm_x86.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/x86/x86
Module Name:src Committed By: maxv Date: Fri Oct 18 16:26:38 UTC 2019 Modified Files: src/sys/arch/x86/x86: vm_machdep.c Log Message: Remove unused call to savectx(). To generate a diff of this commit: cvs rdiff -u -r1.38 -r1.39 src/sys/arch/x86/x86/vm_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/x86/x86
Module Name:src Committed By: maxv Date: Fri Oct 18 16:26:38 UTC 2019 Modified Files: src/sys/arch/x86/x86: vm_machdep.c Log Message: Remove unused call to savectx(). To generate a diff of this commit: cvs rdiff -u -r1.38 -r1.39 src/sys/arch/x86/x86/vm_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/x86/vm_machdep.c diff -u src/sys/arch/x86/x86/vm_machdep.c:1.38 src/sys/arch/x86/x86/vm_machdep.c:1.39 --- src/sys/arch/x86/x86/vm_machdep.c:1.38 Sat Oct 12 06:31:04 2019 +++ src/sys/arch/x86/x86/vm_machdep.c Fri Oct 18 16:26:38 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: vm_machdep.c,v 1.38 2019/10/12 06:31:04 maxv Exp $ */ +/* $NetBSD: vm_machdep.c,v 1.39 2019/10/18 16:26:38 maxv Exp $ */ /*- * Copyright (c) 1982, 1986 The Regents of the University of California. @@ -80,7 +80,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.38 2019/10/12 06:31:04 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.39 2019/10/18 16:26:38 maxv Exp $"); #include "opt_mtrr.h" @@ -136,19 +136,11 @@ cpu_lwp_fork(struct lwp *l1, struct lwp struct switchframe *sf; vaddr_t uv; + KASSERT(l1 == curlwp || l1 == ); + pcb1 = lwp_getpcb(l1); pcb2 = lwp_getpcb(l2); - /* - * Sync the PCB before we copy it. - */ - if (l1 == curlwp) { - KASSERT(pcb1 == curpcb); - savectx(pcb1); - } else { - KASSERT(l1 == ); - } - /* Copy the PCB from parent, except the FPU state. */ memcpy(pcb2, pcb1, offsetof(struct pcb, pcb_savefpu));
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: maxv Date: Thu Oct 17 14:00:28 UTC 2019 Modified Files: src/sys/lib/libsa: loadfile_elf32.c Log Message: Make sure we're dealing with a static binary. Otherwise we could crash if the user mistakenly tries to boot a KASLR kernel with 'boot' instead of 'pkboot'. Now we fail cleanly. Reported by cryo@. To generate a diff of this commit: cvs rdiff -u -r1.55 -r1.56 src/sys/lib/libsa/loadfile_elf32.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/lib/libsa/loadfile_elf32.c diff -u src/sys/lib/libsa/loadfile_elf32.c:1.55 src/sys/lib/libsa/loadfile_elf32.c:1.56 --- src/sys/lib/libsa/loadfile_elf32.c:1.55 Sun Jul 21 16:53:17 2019 +++ src/sys/lib/libsa/loadfile_elf32.c Thu Oct 17 14:00:28 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: loadfile_elf32.c,v 1.55 2019/07/21 16:53:17 rin Exp $ */ +/* $NetBSD: loadfile_elf32.c,v 1.56 2019/10/17 14:00:28 maxv Exp $ */ /* * Copyright (c) 1997, 2008, 2017 The NetBSD Foundation, Inc. @@ -699,6 +699,11 @@ ELFNAMEEND(loadfile_static)(int fd, Elf_ internalize_ehdr(elf->e_ident[EI_DATA], elf); + if (elf->e_type != ET_EXEC) { + errno = EINVAL; + return 1; + } + sz = elf->e_phnum * sizeof(Elf_Phdr); phdr = ALLOC(sz); ret = ELFNAMEEND(readfile_local)(fd, elf->e_phoff, phdr, sz);
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: maxv Date: Thu Oct 17 14:00:28 UTC 2019 Modified Files: src/sys/lib/libsa: loadfile_elf32.c Log Message: Make sure we're dealing with a static binary. Otherwise we could crash if the user mistakenly tries to boot a KASLR kernel with 'boot' instead of 'pkboot'. Now we fail cleanly. Reported by cryo@. To generate a diff of this commit: cvs rdiff -u -r1.55 -r1.56 src/sys/lib/libsa/loadfile_elf32.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.sbin/sysinst
Module Name:src Committed By: maxv Date: Thu Oct 17 08:54:50 UTC 2019 Modified Files: src/usr.sbin/sysinst: msg.mi.en msg.mi.fr Log Message: Sentence begins with capital letter ("yes or no?"). Also add a few french sentences, to make it less awful, but not complete. Not tested. To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/usr.sbin/sysinst/msg.mi.en cvs rdiff -u -r1.20 -r1.21 src/usr.sbin/sysinst/msg.mi.fr Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/sysinst/msg.mi.en diff -u src/usr.sbin/sysinst/msg.mi.en:1.22 src/usr.sbin/sysinst/msg.mi.en:1.23 --- src/usr.sbin/sysinst/msg.mi.en:1.22 Wed Oct 2 11:16:04 2019 +++ src/usr.sbin/sysinst/msg.mi.en Thu Oct 17 08:54:50 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: msg.mi.en,v 1.22 2019/10/02 11:16:04 maya Exp $ */ +/* $NetBSD: msg.mi.en,v 1.23 2019/10/17 08:54:50 maxv Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -980,7 +980,7 @@ message Configure_network {Configure net message Partition_a_disk {Partition a disk} message Logging_functions {Logging functions} message Halt_the_system {Halt the system} -message yes_or_no {yes or no?} +message yes_or_no {Yes or no?} message Hit_enter_to_continue {Hit enter to continue} message Choose_your_installation {Choose your installation} Index: src/usr.sbin/sysinst/msg.mi.fr diff -u src/usr.sbin/sysinst/msg.mi.fr:1.20 src/usr.sbin/sysinst/msg.mi.fr:1.21 --- src/usr.sbin/sysinst/msg.mi.fr:1.20 Wed Oct 2 11:16:04 2019 +++ src/usr.sbin/sysinst/msg.mi.fr Thu Oct 17 08:54:50 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: msg.mi.fr,v 1.20 2019/10/02 11:16:04 maya Exp $ */ +/* $NetBSD: msg.mi.fr,v 1.21 2019/10/17 08:54:50 maxv Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -269,7 +269,7 @@ message add_another_ptn * $1 = size unit GB */ message fssizesok -{Go on. Free space $0 $1.} +{Valider. Espace libre $0 $1.} /* Called with: Example * $0 = missing space 1.4 @@ -1053,7 +1053,6 @@ message Finished {Terminée} message Command_failed {Échec} message Command_ended_on_signal {Commande terminée par un signal} - message NetBSD_VERSION_Install_System {NetBSD-@@VERSION@@ Programme d'installation} message Exit_Install_System {Quitter le programme d'installation} message Install_NetBSD_to_hard_disk {Installation de NetBSD sur disque dur} @@ -1062,8 +1061,8 @@ message Re_install_sets_or_install_addit message Reboot_the_computer {Redémarrer l'ordinateur} message Utility_menu {Utilitaires} message Config_menu {Configuration} -message exit_menu_generic {Quitter} message exit_utility_menu {Quitter} +message exit_menu_generic {Quitter} message NetBSD_VERSION_Utilities {Utilitaires NetBSD-@@VERSION@@} message Run_bin_sh {Exécuter /bin/sh} message Set_timezone {Configurer le fuseau horaire} @@ -1071,7 +1070,7 @@ message Configure_network {Configurer le message Partition_a_disk {Partitionner un disque} message Logging_functions {Journaux} message Halt_the_system {Arrêter le système} -message yes_or_no {oui ou non?} +message yes_or_no {Oui ou non?} message Hit_enter_to_continue {Appuyez sur la touche Entrée pour continuer} message Choose_your_installation {Choisir le type d'installation désiré} @@ -1334,7 +1333,7 @@ message custom_type {Unknown} message dl_type_invalid {Invalid file system type code (0 .. 255)} -message cancel {Cancel} +message cancel {Annuler} message out_of_range {Invalid value} @@ -1380,7 +1379,7 @@ message fs_type_ffsv2 {FFSv2} message fs_type_ffs {FFS} message other_fs_type {Other type} -message editpack {Edit name of the disk} +message editpack {Changer le nom du disque} message edit_disk_pack_hdr {The name of the disk is arbitrary. It is useful for distinguishing between multiple disks.
CVS commit: src/usr.sbin/sysinst
Module Name:src Committed By: maxv Date: Thu Oct 17 08:54:50 UTC 2019 Modified Files: src/usr.sbin/sysinst: msg.mi.en msg.mi.fr Log Message: Sentence begins with capital letter ("yes or no?"). Also add a few french sentences, to make it less awful, but not complete. Not tested. To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/usr.sbin/sysinst/msg.mi.en cvs rdiff -u -r1.20 -r1.21 src/usr.sbin/sysinst/msg.mi.fr Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/net
Module Name:src Committed By: maxv Date: Mon Oct 14 16:43:04 UTC 2019 Modified Files: src/sys/net: rtsock_shared.c Log Message: Error out if the type is beyond the storage size. No functional change, since the shift would otherwise 'and' against zero, returning EEXIST. Reported-by: syzbot+cb68ccdc1ef3aca2d...@syzkaller.appspotmail.com To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/sys/net/rtsock_shared.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/net
Module Name:src Committed By: maxv Date: Mon Oct 14 16:43:04 UTC 2019 Modified Files: src/sys/net: rtsock_shared.c Log Message: Error out if the type is beyond the storage size. No functional change, since the shift would otherwise 'and' against zero, returning EEXIST. Reported-by: syzbot+cb68ccdc1ef3aca2d...@syzkaller.appspotmail.com To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/sys/net/rtsock_shared.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/net/rtsock_shared.c diff -u src/sys/net/rtsock_shared.c:1.10 src/sys/net/rtsock_shared.c:1.11 --- src/sys/net/rtsock_shared.c:1.10 Mon Aug 19 03:23:30 2019 +++ src/sys/net/rtsock_shared.c Mon Oct 14 16:43:04 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: rtsock_shared.c,v 1.10 2019/08/19 03:23:30 ozaki-r Exp $ */ +/* $NetBSD: rtsock_shared.c,v 1.11 2019/10/14 16:43:04 maxv Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -61,7 +61,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: rtsock_shared.c,v 1.10 2019/08/19 03:23:30 ozaki-r Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rtsock_shared.c,v 1.11 2019/10/14 16:43:04 maxv Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -227,6 +227,8 @@ COMPATNAME(route_filter)(struct mbuf *m, return EINVAL; rtm = mtod(m, struct rt_xmsghdr *); + if (rtm->rtm_type >= sizeof(rop->rocb_msgfilter) * CHAR_BIT) + return EINVAL; /* If the rtm type is filtered out, return a positive. */ if (!(rop->rocb_msgfilter & RTMSGFILTER(rtm->rtm_type))) return EEXIST;
CVS commit: src/sys/kern
Module Name:src Committed By: maxv Date: Mon Oct 14 16:27:04 UTC 2019 Modified Files: src/sys/kern: uipc_socket.c Log Message: Add a check before the memcpy. memcpy is defined to never take NULL as second argument, and the compiler is free to perform optimizations knowing that this argument is never NULL. In this particular case, it was harmless. But still good to fix. Reported-by: syzbot+6f504255accb795eb...@syzkaller.appspotmail.com To generate a diff of this commit: cvs rdiff -u -r1.284 -r1.285 src/sys/kern/uipc_socket.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/kern
Module Name:src Committed By: maxv Date: Mon Oct 14 16:27:04 UTC 2019 Modified Files: src/sys/kern: uipc_socket.c Log Message: Add a check before the memcpy. memcpy is defined to never take NULL as second argument, and the compiler is free to perform optimizations knowing that this argument is never NULL. In this particular case, it was harmless. But still good to fix. Reported-by: syzbot+6f504255accb795eb...@syzkaller.appspotmail.com To generate a diff of this commit: cvs rdiff -u -r1.284 -r1.285 src/sys/kern/uipc_socket.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/uipc_socket.c diff -u src/sys/kern/uipc_socket.c:1.284 src/sys/kern/uipc_socket.c:1.285 --- src/sys/kern/uipc_socket.c:1.284 Fri Sep 27 00:32:03 2019 +++ src/sys/kern/uipc_socket.c Mon Oct 14 16:27:03 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: uipc_socket.c,v 1.284 2019/09/27 00:32:03 pgoyette Exp $ */ +/* $NetBSD: uipc_socket.c,v 1.285 2019/10/14 16:27:03 maxv Exp $ */ /* * Copyright (c) 2002, 2007, 2008, 2009 The NetBSD Foundation, Inc. @@ -71,7 +71,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.284 2019/09/27 00:32:03 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.285 2019/10/14 16:27:03 maxv Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -2096,7 +2096,9 @@ sockopt_set(struct sockopt *sopt, const } sopt->sopt_retsize = MIN(sopt->sopt_size, len); - memcpy(sopt->sopt_data, buf, sopt->sopt_retsize); + if (sopt->sopt_retsize > 0) { + memcpy(sopt->sopt_data, buf, sopt->sopt_retsize); + } return 0; }
CVS commit: src/lib/libnvmm
Module Name:src Committed By: maxv Date: Mon Oct 14 10:43:40 UTC 2019 Modified Files: src/lib/libnvmm: libnvmm_x86.c Log Message: Improve nvmm_vcpu_dump(). To generate a diff of this commit: cvs rdiff -u -r1.33 -r1.34 src/lib/libnvmm/libnvmm_x86.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libnvmm/libnvmm_x86.c diff -u src/lib/libnvmm/libnvmm_x86.c:1.33 src/lib/libnvmm/libnvmm_x86.c:1.34 --- src/lib/libnvmm/libnvmm_x86.c:1.33 Mon Oct 14 10:39:24 2019 +++ src/lib/libnvmm/libnvmm_x86.c Mon Oct 14 10:43:40 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: libnvmm_x86.c,v 1.33 2019/10/14 10:39:24 maxv Exp $ */ +/* $NetBSD: libnvmm_x86.c,v 1.34 2019/10/14 10:43:40 maxv Exp $ */ /* * Copyright (c) 2018-2019 The NetBSD Foundation, Inc. @@ -70,20 +70,28 @@ nvmm_vcpu_dump(struct nvmm_machine *mach return -1; printf("+ VCPU id=%d\n", (int)vcpu->cpuid); - printf("| -> RIP=%"PRIx64"\n", state->gprs[NVMM_X64_GPR_RIP]); - printf("| -> RSP=%"PRIx64"\n", state->gprs[NVMM_X64_GPR_RSP]); printf("| -> RAX=%"PRIx64"\n", state->gprs[NVMM_X64_GPR_RAX]); - printf("| -> RBX=%"PRIx64"\n", state->gprs[NVMM_X64_GPR_RBX]); printf("| -> RCX=%"PRIx64"\n", state->gprs[NVMM_X64_GPR_RCX]); + printf("| -> RDX=%"PRIx64"\n", state->gprs[NVMM_X64_GPR_RDX]); + printf("| -> RBX=%"PRIx64"\n", state->gprs[NVMM_X64_GPR_RBX]); + printf("| -> RSP=%"PRIx64"\n", state->gprs[NVMM_X64_GPR_RSP]); + printf("| -> RBP=%"PRIx64"\n", state->gprs[NVMM_X64_GPR_RBP]); + printf("| -> RSI=%"PRIx64"\n", state->gprs[NVMM_X64_GPR_RSI]); + printf("| -> RDI=%"PRIx64"\n", state->gprs[NVMM_X64_GPR_RDI]); + printf("| -> RIP=%"PRIx64"\n", state->gprs[NVMM_X64_GPR_RIP]); printf("| -> RFLAGS=%p\n", (void *)state->gprs[NVMM_X64_GPR_RFLAGS]); for (i = 0; i < NVMM_X64_NSEG; i++) { attr = (uint16_t *)>segs[i].attrib; - printf("| -> %s: sel=0x%x base=%"PRIx64", limit=%x, attrib=%x\n", + printf("| -> %s: sel=0x%x base=%"PRIx64", limit=%x, " + "attrib=%x [type=%d,l=%d,def=%d]\n", segnames[i], state->segs[i].selector, state->segs[i].base, state->segs[i].limit, - *attr); + *attr, + state->segs[i].attrib.type, + state->segs[i].attrib.l, + state->segs[i].attrib.def); } printf("| -> MSR_EFER=%"PRIx64"\n", state->msrs[NVMM_X64_MSR_EFER]); printf("| -> CR0=%"PRIx64"\n", state->crs[NVMM_X64_CR_CR0]);
CVS commit: src/lib/libnvmm
Module Name:src Committed By: maxv Date: Mon Oct 14 10:43:40 UTC 2019 Modified Files: src/lib/libnvmm: libnvmm_x86.c Log Message: Improve nvmm_vcpu_dump(). To generate a diff of this commit: cvs rdiff -u -r1.33 -r1.34 src/lib/libnvmm/libnvmm_x86.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src
Module Name:src Committed By: maxv Date: Mon Oct 14 10:39:24 UTC 2019 Modified Files: src/lib/libnvmm: libnvmm_x86.c src/tests/lib/libnvmm: h_mem_assist.c h_mem_assist_asm.S Log Message: Implement XCHG, add associated tests, and add comments to explain. With this in place the Windows 95 installer completes successfuly. Part of PR/54611. To generate a diff of this commit: cvs rdiff -u -r1.32 -r1.33 src/lib/libnvmm/libnvmm_x86.c cvs rdiff -u -r1.13 -r1.14 src/tests/lib/libnvmm/h_mem_assist.c cvs rdiff -u -r1.7 -r1.8 src/tests/lib/libnvmm/h_mem_assist_asm.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libnvmm/libnvmm_x86.c diff -u src/lib/libnvmm/libnvmm_x86.c:1.32 src/lib/libnvmm/libnvmm_x86.c:1.33 --- src/lib/libnvmm/libnvmm_x86.c:1.32 Sun Oct 13 17:32:15 2019 +++ src/lib/libnvmm/libnvmm_x86.c Mon Oct 14 10:39:24 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: libnvmm_x86.c,v 1.32 2019/10/13 17:32:15 maxv Exp $ */ +/* $NetBSD: libnvmm_x86.c,v 1.33 2019/10/14 10:39:24 maxv Exp $ */ /* * Copyright (c) 2018-2019 The NetBSD Foundation, Inc. @@ -838,13 +838,15 @@ out: /* -- */ struct x86_emul { - bool read; + bool readreg; + bool backprop; bool notouch; void (*func)(struct nvmm_machine *, struct nvmm_mem *, uint64_t *); }; static void x86_func_or(struct nvmm_machine *, struct nvmm_mem *, uint64_t *); static void x86_func_and(struct nvmm_machine *, struct nvmm_mem *, uint64_t *); +static void x86_func_xchg(struct nvmm_machine *, struct nvmm_mem *, uint64_t *); static void x86_func_sub(struct nvmm_machine *, struct nvmm_mem *, uint64_t *); static void x86_func_xor(struct nvmm_machine *, struct nvmm_mem *, uint64_t *); static void x86_func_cmp(struct nvmm_machine *, struct nvmm_mem *, uint64_t *); @@ -855,22 +857,28 @@ static void x86_func_lods(struct nvmm_ma static void x86_func_movs(struct nvmm_machine *, struct nvmm_mem *, uint64_t *); static const struct x86_emul x86_emul_or = { - .read = true, + .readreg = true, .func = x86_func_or }; static const struct x86_emul x86_emul_and = { - .read = true, + .readreg = true, .func = x86_func_and }; +static const struct x86_emul x86_emul_xchg = { + .readreg = true, + .backprop = true, + .func = x86_func_xchg +}; + static const struct x86_emul x86_emul_sub = { - .read = true, + .readreg = true, .func = x86_func_sub }; static const struct x86_emul x86_emul_xor = { - .read = true, + .readreg = true, .func = x86_func_xor }; @@ -1322,6 +1330,28 @@ static const struct x86_opcode primary_o }, /* + * XCHG + */ + [0x86] = { + /* Eb, Gb */ + .valid = true, + .regmodrm = true, + .regtorm = true, + .szoverride = false, + .defsize = OPSIZE_BYTE, + .emul = _emul_xchg + }, + [0x87] = { + /* Ev, Gv */ + .valid = true, + .regmodrm = true, + .regtorm = true, + .szoverride = true, + .defsize = -1, + .emul = _emul_xchg + }, + + /* * MOV */ [0x88] = { @@ -2616,10 +2646,10 @@ exec_##instr##sz(uint##sz##_t op1, uint# { \ uint##sz##_t res; \ __asm __volatile ( \ - #instr " %2, %3;" \ - "mov %3, %1;" \ + #instr" %2, %3;" \ + "mov %3, %1;" \ "pushfq;" \ - "popq %0" \ + "popq %0" \ : "=r" (*rflags), "=r" (res)\ : "r" (op1), "r" (op2)); \ return res; \ @@ -2677,7 +2707,7 @@ EXEC_DISPATCHER(xor) /* * Emulation functions. We don't care about the order of the operands, except - * for SUB, CMP and TEST. For these ones we look at mem->write todetermine who + * for SUB, CMP and TEST. For these ones we look at mem->write to determine who * is op1 and who is op2. */ @@ -2746,6 +2776,28 @@ x86_func_and(struct nvmm_machine *mach, } static void +x86_func_xchg(struct nvmm_machine *mach, struct nvmm_mem *mem, uint64_t *gprs) +{ + uint64_t *op1, op2; + + op1 = (uint64_t *)mem->data; + op2 = 0; + + /* Fetch op2. */ + mem->data = (uint8_t *) + mem->write = false; + (*mach->cbs.mem)(mem); + + /* Write op1 in op2. */ + mem->data = (uint8_t *)op1; + mem->write = true; + (*mach->cbs.mem)(mem); + + /* Write op2 in op1. */ + *op1 = op2; +} + +static void x86_func_sub(struct nvmm_machine *mach, struct nvmm_mem *mem, uint64_t *gprs) { uint64_t *retval = (uint64_t *)mem->data; @@ -3154,7 +3206,9 @@ assist_mem_single(struct nvmm_machine *m if (mem.write) { switch (instr->src.type) { case STORE_REG: - if (instr->src.disp.type != DISP_NONE) { + /* The instruction was "reg -> mem". Fetch the register + * in membuf. */ + if (__predict_false(instr->src.disp.type != DISP_NONE)) { DISASSEMBLER_BUG(); } val = state->gprs[instr->src.u.reg->num]; @@ -3162,16 +3216,20 @@ assist_mem_single(struct nvmm_machine *m memcpy(mem.data, , mem.size); break; case STORE_IMM: + /* The instruction was "imm -> mem". Fetch the
CVS commit: src
Module Name:src Committed By: maxv Date: Mon Oct 14 10:39:24 UTC 2019 Modified Files: src/lib/libnvmm: libnvmm_x86.c src/tests/lib/libnvmm: h_mem_assist.c h_mem_assist_asm.S Log Message: Implement XCHG, add associated tests, and add comments to explain. With this in place the Windows 95 installer completes successfuly. Part of PR/54611. To generate a diff of this commit: cvs rdiff -u -r1.32 -r1.33 src/lib/libnvmm/libnvmm_x86.c cvs rdiff -u -r1.13 -r1.14 src/tests/lib/libnvmm/h_mem_assist.c cvs rdiff -u -r1.7 -r1.8 src/tests/lib/libnvmm/h_mem_assist_asm.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src
Module Name:src Committed By: maxv Date: Sun Oct 13 17:32:15 UTC 2019 Modified Files: src/lib/libnvmm: libnvmm_x86.c src/tests/lib/libnvmm: h_mem_assist.c h_mem_assist_asm.S Log Message: Fix incorrect parsing: the R/M field uses a special GPR map when the address size is 16 bits, regardless of the actual operating mode. With this special map there can be two registers referenced at once, and also disp16-only. Implement this special behavior, and add associated tests. While here simplify a few things. With this in place, the Windows 95 installer initializes correctly. Part of PR/54611. To generate a diff of this commit: cvs rdiff -u -r1.31 -r1.32 src/lib/libnvmm/libnvmm_x86.c cvs rdiff -u -r1.11 -r1.12 src/tests/lib/libnvmm/h_mem_assist.c cvs rdiff -u -r1.6 -r1.7 src/tests/lib/libnvmm/h_mem_assist_asm.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys
Module Name:src Committed By: maxv Date: Sat Oct 12 06:31:04 UTC 2019 Modified Files: src/sys/arch/amd64/amd64: amd64_trap.S genassym.cf locore.S machdep.c spl.S src/sys/arch/amd64/include: frameasm.h pcb.h proc.h src/sys/arch/i386/i386: genassym.cf i386_trap.S locore.S machdep.c spl.S src/sys/arch/i386/include: frameasm.h pcb.h proc.h src/sys/arch/x86/acpi: acpi_wakeup.c src/sys/arch/x86/include: cpu.h fpu.h src/sys/arch/x86/x86: cpu.c fpu.c ipi.c vm_machdep.c src/sys/arch/xen/x86: cpu.c xen_ipi.c src/sys/dev/nvmm/x86: nvmm_x86_svm.c nvmm_x86_vmx.c src/sys/sys: param.h Log Message: Rewrite the FPU code on x86. This greatly simplifies the logic and removes the dependency on IPL_HIGH. NVMM is updated accordingly. Posted on port-amd64 a week ago. Bump the kernel version to 9.99.16. To generate a diff of this commit: cvs rdiff -u -r1.48 -r1.49 src/sys/arch/amd64/amd64/amd64_trap.S cvs rdiff -u -r1.76 -r1.77 src/sys/arch/amd64/amd64/genassym.cf cvs rdiff -u -r1.188 -r1.189 src/sys/arch/amd64/amd64/locore.S cvs rdiff -u -r1.336 -r1.337 src/sys/arch/amd64/amd64/machdep.c cvs rdiff -u -r1.40 -r1.41 src/sys/arch/amd64/amd64/spl.S cvs rdiff -u -r1.44 -r1.45 src/sys/arch/amd64/include/frameasm.h cvs rdiff -u -r1.29 -r1.30 src/sys/arch/amd64/include/pcb.h cvs rdiff -u -r1.22 -r1.23 src/sys/arch/amd64/include/proc.h cvs rdiff -u -r1.113 -r1.114 src/sys/arch/i386/i386/genassym.cf cvs rdiff -u -r1.19 -r1.20 src/sys/arch/i386/i386/i386_trap.S cvs rdiff -u -r1.171 -r1.172 src/sys/arch/i386/i386/locore.S cvs rdiff -u -r1.820 -r1.821 src/sys/arch/i386/i386/machdep.c cvs rdiff -u -r1.48 -r1.49 src/sys/arch/i386/i386/spl.S cvs rdiff -u -r1.28 -r1.29 src/sys/arch/i386/include/frameasm.h cvs rdiff -u -r1.58 -r1.59 src/sys/arch/i386/include/pcb.h cvs rdiff -u -r1.45 -r1.46 src/sys/arch/i386/include/proc.h cvs rdiff -u -r1.50 -r1.51 src/sys/arch/x86/acpi/acpi_wakeup.c cvs rdiff -u -r1.109 -r1.110 src/sys/arch/x86/include/cpu.h cvs rdiff -u -r1.18 -r1.19 src/sys/arch/x86/include/fpu.h cvs rdiff -u -r1.172 -r1.173 src/sys/arch/x86/x86/cpu.c cvs rdiff -u -r1.57 -r1.58 src/sys/arch/x86/x86/fpu.c cvs rdiff -u -r1.27 -r1.28 src/sys/arch/x86/x86/ipi.c cvs rdiff -u -r1.37 -r1.38 src/sys/arch/x86/x86/vm_machdep.c cvs rdiff -u -r1.129 -r1.130 src/sys/arch/xen/x86/cpu.c cvs rdiff -u -r1.32 -r1.33 src/sys/arch/xen/x86/xen_ipi.c cvs rdiff -u -r1.49 -r1.50 src/sys/dev/nvmm/x86/nvmm_x86_svm.c cvs rdiff -u -r1.38 -r1.39 src/sys/dev/nvmm/x86/nvmm_x86_vmx.c cvs rdiff -u -r1.616 -r1.617 src/sys/sys/param.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys
db_printf("%p %s %ld %x %x %10p %10p\n", + db_printf("%p %s %ld %x %x %10p\n", ci, ci->ci_dev == NULL ? "BOOT" : device_xname(ci->ci_dev), (long)ci->ci_cpuid, ci->ci_flags, ci->ci_ipis, - ci->ci_curlwp, - ci->ci_fpcurlwp); + ci->ci_curlwp); } } #endif @@ -1159,11 +1158,7 @@ cpu_init_msrs(struct cpu_info *ci, bool void cpu_offline_md(void) { - int s; - - s = splhigh(); - fpusave_cpu(true); - splx(s); + return; } /* XXX joerg restructure and restart CPUs individually */ Index: src/sys/arch/x86/x86/fpu.c diff -u src/sys/arch/x86/x86/fpu.c:1.57 src/sys/arch/x86/x86/fpu.c:1.58 --- src/sys/arch/x86/x86/fpu.c:1.57 Fri Oct 4 11:47:08 2019 +++ src/sys/arch/x86/x86/fpu.c Sat Oct 12 06:31:04 2019 @@ -1,11 +1,11 @@ -/* $NetBSD: fpu.c,v 1.57 2019/10/04 11:47:08 maxv Exp $ */ +/* $NetBSD: fpu.c,v 1.58 2019/10/12 06:31:04 maxv Exp $ */ /* - * Copyright (c) 2008 The NetBSD Foundation, Inc. All + * Copyright (c) 2008, 2019 The NetBSD Foundation, Inc. All * rights reserved. * * This code is derived from software developed for The NetBSD Foundation - * by Andrew Doran. + * by Andrew Doran and Maxime Villard. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -96,7 +96,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.57 2019/10/04 11:47:08 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.58 2019/10/12 06:31:04 maxv Exp $"); #include "opt_multiprocessor.h" @@ -126,14 +126,44 @@ __KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.57 #define stts() HYPERVISOR_fpu_taskswitch(1) #endif +void fpu_handle_deferred(void); +void fpu_switch(struct lwp *, struct lwp *); + uint32_t x86_fpu_mxcsr_mask __read_mostly = 0; static inline union savefpu * -lwp_fpuarea(struct lwp *l) +fpu_lwp_area(struct lwp *l) +{ + struct pcb *pcb = lwp_getpcb(l); + union savefpu *area = >pcb_savefpu; + + KASSERT((l->l_flag & LW_SYSTEM) == 0); + if (l == curlwp) { + fpu_save(); + } + KASSERT(!(l->l_md.md_flags & MDL_FPU_IN_CPU)); + + return area; +} + +/* + * Bring curlwp's FPU state in memory. It will get installed back in the CPU + * when returning to userland. + */ +void +fpu_save(void) { + struct lwp *l = curlwp; struct pcb *pcb = lwp_getpcb(l); + union savefpu *area = >pcb_savefpu; - return >pcb_savefpu; + kpreempt_disable(); + if (l->l_md.md_flags & MDL_FPU_IN_CPU) { + KASSERT((l->l_flag & LW_SYSTEM) == 0); + fpu_area_save(area, x86_xsave_features); + l->l_md.md_flags &= ~MDL_FPU_IN_CPU; + } + kpreempt_enable(); } void @@ -213,8 +243,6 @@ fpu_errata_amd(void) void fpu_area_save(void *area, uint64_t xsave_features) { - clts(); - switch (x86_fpu_save) { case FPU_SAVE_FSAVE: fnsave(area); @@ -229,6 +257,8 @@ fpu_area_save(void *area, uint64_t xsave xsaveopt(area, xsave_features); break; } + + stts(); } void @@ -254,45 +284,56 @@ fpu_area_restore(void *area, uint64_t xs } } -static void -fpu_lwp_install(struct lwp *l) +void +fpu_handle_deferred(void) { - struct pcb *pcb = lwp_getpcb(l); - struct cpu_info *ci = curcpu(); - - KASSERT(ci->ci_fpcurlwp == NULL); - KASSERT(pcb->pcb_fpcpu == NULL); - ci->ci_fpcurlwp = l; - pcb->pcb_fpcpu = ci; + struct pcb *pcb = lwp_getpcb(curlwp); fpu_area_restore(>pcb_savefpu, x86_xsave_features); } -void fpu_switch(struct lwp *, struct lwp *); - void fpu_switch(struct lwp *oldlwp, struct lwp *newlwp) { - int s; + struct pcb *pcb; - s = splhigh(); -#ifdef DIAGNOSTIC - if (oldlwp != NULL) { - struct pcb *pcb = lwp_getpcb(oldlwp); - struct cpu_info *ci = curcpu(); - if (pcb->pcb_fpcpu == NULL) { - KASSERT(ci->ci_fpcurlwp != oldlwp); - } else if (pcb->pcb_fpcpu == ci) { - KASSERT(ci->ci_fpcurlwp == oldlwp); - } else { - panic("%s: oldlwp's state installed elsewhere", - __func__); - } + if ((oldlwp != NULL) && (oldlwp->l_md.md_flags & MDL_FPU_IN_CPU)) { + KASSERT(!(oldlwp->l_flag & LW_SYSTEM)); + pcb = lwp_getpcb(oldlwp); + fpu_area_save(>pcb_savefpu, x86_xsave_features); + oldlwp->l_md.md_flags &= ~MDL_FPU_IN_CPU; } -#endif - fpusave_cpu(true); - if (!(newlwp->l_flag & LW_SYSTEM)) - fpu_lwp_install(newlwp); - splx(s); + KASSERT(!(newlwp->l_md.md_flags & MDL_FPU_IN_CPU)); +} + +void +fpu_lwp_fork(struct lwp *l1, struct lwp *l2) +{ + struct pcb *pcb2 = lwp_getpcb(l2); + union savefpu *fpu_save; + + /* Kernel threads have no FPU. */ + if (__predict_false(l2->l_flag & LW_SYSTEM)) { + return; + } + /* For init(8). */ + if (__predict_false(l1->l_flag & LW_SYSTEM)) { + memset(>pcb_savefpu, 0, x86_fpu_save_size); + return; + } + + fpu_save = fpu_lwp_area(l1); + memcpy(>pcb_savefpu, fpu_save, x86_fpu_save_size); + l2->l_md.md_flags &= ~MDL_FPU_IN_CPU; +}
CVS commit: src/sys
Module Name:src Committed By: maxv Date: Thu Oct 10 13:45:14 UTC 2019 Modified Files: src/sys/kern: subr_asan.c src/sys/sys: systm.h Log Message: Add KASAN instrumentation on ucas and ufetch. To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/sys/kern/subr_asan.c cvs rdiff -u -r1.286 -r1.287 src/sys/sys/systm.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/subr_asan.c diff -u src/sys/kern/subr_asan.c:1.15 src/sys/kern/subr_asan.c:1.16 --- src/sys/kern/subr_asan.c:1.15 Fri Oct 4 06:27:42 2019 +++ src/sys/kern/subr_asan.c Thu Oct 10 13:45:14 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: subr_asan.c,v 1.15 2019/10/04 06:27:42 maxv Exp $ */ +/* $NetBSD: subr_asan.c,v 1.16 2019/10/10 13:45:14 maxv Exp $ */ /* * Copyright (c) 2018-2019 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: subr_asan.c,v 1.15 2019/10/04 06:27:42 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: subr_asan.c,v 1.16 2019/10/10 13:45:14 maxv Exp $"); #include #include @@ -559,6 +559,109 @@ kasan_copyoutstr(const void *kaddr, void /* -- */ +#undef _ucas_32 +#undef _ucas_32_mp +#undef _ucas_64 +#undef _ucas_64_mp +#undef _ufetch_8 +#undef _ufetch_16 +#undef _ufetch_32 +#undef _ufetch_64 + +int _ucas_32(volatile uint32_t *, uint32_t, uint32_t, uint32_t *); +int kasan__ucas_32(volatile uint32_t *, uint32_t, uint32_t, uint32_t *); +int +kasan__ucas_32(volatile uint32_t *uaddr, uint32_t old, uint32_t new, +uint32_t *ret) +{ + kasan_shadow_check((unsigned long)ret, sizeof(*ret), true, + __RET_ADDR); + return _ucas_32(uaddr, old, new, ret); +} + +#ifdef __HAVE_UCAS_MP +int _ucas_32_mp(volatile uint32_t *, uint32_t, uint32_t, uint32_t *); +int kasan__ucas_32_mp(volatile uint32_t *, uint32_t, uint32_t, uint32_t *); +int +kasan__ucas_32_mp(volatile uint32_t *uaddr, uint32_t old, uint32_t new, +uint32_t *ret) +{ + kasan_shadow_check((unsigned long)ret, sizeof(*ret), true, + __RET_ADDR); + return _ucas_32_mp(uaddr, old, new, ret); +} +#endif + +#ifdef _LP64 +int _ucas_64(volatile uint64_t *, uint64_t, uint64_t, uint64_t *); +int kasan__ucas_64(volatile uint64_t *, uint64_t, uint64_t, uint64_t *); +int +kasan__ucas_64(volatile uint64_t *uaddr, uint64_t old, uint64_t new, +uint64_t *ret) +{ + kasan_shadow_check((unsigned long)ret, sizeof(*ret), true, + __RET_ADDR); + return _ucas_64(uaddr, old, new, ret); +} + +#ifdef __HAVE_UCAS_MP +int _ucas_64_mp(volatile uint64_t *, uint64_t, uint64_t, uint64_t *); +int kasan__ucas_64_mp(volatile uint64_t *, uint64_t, uint64_t, uint64_t *); +int +kasan__ucas_64_mp(volatile uint64_t *uaddr, uint64_t old, uint64_t new, +uint64_t *ret) +{ + kasan_shadow_check((unsigned long)ret, sizeof(*ret), true, + __RET_ADDR); + return _ucas_64_mp(uaddr, old, new, ret); +} +#endif +#endif + +int _ufetch_8(const uint8_t *, uint8_t *); +int kasan__ufetch_8(const uint8_t *, uint8_t *); +int +kasan__ufetch_8(const uint8_t *uaddr, uint8_t *valp) +{ + kasan_shadow_check((unsigned long)valp, sizeof(*valp), true, + __RET_ADDR); + return _ufetch_8(uaddr, valp); +} + +int _ufetch_16(const uint16_t *, uint16_t *); +int kasan__ufetch_16(const uint16_t *, uint16_t *); +int +kasan__ufetch_16(const uint16_t *uaddr, uint16_t *valp) +{ + kasan_shadow_check((unsigned long)valp, sizeof(*valp), true, + __RET_ADDR); + return _ufetch_16(uaddr, valp); +} + +int _ufetch_32(const uint32_t *, uint32_t *); +int kasan__ufetch_32(const uint32_t *, uint32_t *); +int +kasan__ufetch_32(const uint32_t *uaddr, uint32_t *valp) +{ + kasan_shadow_check((unsigned long)valp, sizeof(*valp), true, + __RET_ADDR); + return _ufetch_32(uaddr, valp); +} + +#ifdef _LP64 +int _ufetch_64(const uint64_t *, uint64_t *); +int kasan__ufetch_64(const uint64_t *, uint64_t *); +int +kasan__ufetch_64(const uint64_t *uaddr, uint64_t *valp) +{ + kasan_shadow_check((unsigned long)valp, sizeof(*valp), true, + __RET_ADDR); + return _ufetch_64(uaddr, valp); +} +#endif + +/* -- */ + #undef atomic_add_32 #undef atomic_add_int #undef atomic_add_long Index: src/sys/sys/systm.h diff -u src/sys/sys/systm.h:1.286 src/sys/sys/systm.h:1.287 --- src/sys/sys/systm.h:1.286 Tue Jul 23 17:39:36 2019 +++ src/sys/sys/systm.h Thu Oct 10 13:45:14 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: systm.h,v 1.286 2019/07/23 17:39:36 rin Exp $ */ +/* $NetBSD: systm.h,v 1.287 2019/10/10 13:45:14 maxv Exp $ */ /*- * Copyright (c) 1982, 1988, 1991, 1993 @@ -43,6 +43,7 @@ #include "opt_ddb.h" #include "opt_multiprocessor.h" #include "opt_gprof.h" +#include "opt_kasan.h" #include "opt_kleak.h" #include "opt_wsdisplay_compat.h" #endif @@ -319,74 +320,102 @@ int copyout_vmspace(struct vmspace *, co int ioctl_copyin(int ioctlflags, const
CVS commit: src/sys
Module Name:src Committed By: maxv Date: Thu Oct 10 13:45:14 UTC 2019 Modified Files: src/sys/kern: subr_asan.c src/sys/sys: systm.h Log Message: Add KASAN instrumentation on ucas and ufetch. To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/sys/kern/subr_asan.c cvs rdiff -u -r1.286 -r1.287 src/sys/sys/systm.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Re: CVS commit: src/sys/kern
Le 30/09/2019 à 20:51, Nick Hudson a écrit : On 30 Sep 2019, at 18:06, Tobias Nygren wrote: On Mon, 23 Sep 2019 05:39:59 + Nick Hudson wrote: Modified Files: src/sys/kern: subr_pool.c Log Message: Enable POOL_REDZONE with DIAGNOSTIC. The bug in the arm pmap was fixed long ago. To generate a diff of this commit: cvs rdiff -u -r1.258 -r1.259 src/sys/kern/subr_pool.c Hi, I see 30% packet loss on my BananaPi evbarm system with -current. I bisected it to the above change. It may have had unintended side effects. This is maxv’s change really - feel free to revert Sounds like it corrupts pool allocated memory in some cases I have rarely seen a memory corruption that cleanly drops packets. Rather, it just seems to me that the board has limited ram, the redzone adds a 2-byte overhead, in the specific case of mbufs that means we lose one item per page, and the limit on the pool is reached as a result. Perhaps a useful change would be to drop the redzone if the 2-byte poison turns out to cost (too much) more than two bytes.
CVS commit: src/sys/arch/x86/include
Module Name:src Committed By: maxv Date: Wed Oct 9 17:28:46 UTC 2019 Modified Files: src/sys/arch/x86/include: pte.h Log Message: Add new bits. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/arch/x86/include/pte.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/include/pte.h diff -u src/sys/arch/x86/include/pte.h:1.2 src/sys/arch/x86/include/pte.h:1.3 --- src/sys/arch/x86/include/pte.h:1.2 Sat Oct 5 07:30:03 2019 +++ src/sys/arch/x86/include/pte.h Wed Oct 9 17:28:46 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: pte.h,v 1.2 2019/10/05 07:30:03 maxv Exp $ */ +/* $NetBSD: pte.h,v 1.3 2019/10/09 17:28:46 maxv Exp $ */ /* * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -39,12 +39,14 @@ #define PGC_UC (PTE_PWT | PTE_PCD) /* hard UC */ /* - * page protection exception bits + * Page protection exception bits */ - -#define PGEX_P 0x01 /* protection violation (vs. no mapping) */ -#define PGEX_W 0x02 /* exception during a write cycle */ -#define PGEX_U 0x04 /* exception while in user mode (upl) */ -#define PGEX_X 0x10 /* exception during instruction fetch */ +#define PGEX_P 0x0001 /* the page was present */ +#define PGEX_W 0x0002 /* exception during a write cycle */ +#define PGEX_U 0x0004 /* exception while in user mode */ +#define PGEX_RSVD 0x0008 /* a reserved bit was set in the page tables */ +#define PGEX_X 0x0010 /* exception during instruction fetch */ +#define PGEX_PK 0x0020 /* access disallowed by protection key */ +#define PGEX_SGX 0x8000 /* violation of sgx-specific access rights */ #endif /* _X86_PTE_H */
CVS commit: src/sys/arch/x86/include
Module Name:src Committed By: maxv Date: Wed Oct 9 17:28:46 UTC 2019 Modified Files: src/sys/arch/x86/include: pte.h Log Message: Add new bits. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/arch/x86/include/pte.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/netatalk
Module Name:src Committed By: maxv Date: Wed Oct 9 14:15:40 UTC 2019 Modified Files: src/sys/netatalk: at_var.h Log Message: Memset to prevent stack info leak. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/netatalk/at_var.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/netatalk
Module Name:src Committed By: maxv Date: Wed Oct 9 14:15:40 UTC 2019 Modified Files: src/sys/netatalk: at_var.h Log Message: Memset to prevent stack info leak. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/netatalk/at_var.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/netatalk/at_var.h diff -u src/sys/netatalk/at_var.h:1.8 src/sys/netatalk/at_var.h:1.9 --- src/sys/netatalk/at_var.h:1.8 Thu Apr 19 21:50:10 2018 +++ src/sys/netatalk/at_var.h Wed Oct 9 14:15:40 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: at_var.h,v 1.8 2018/04/19 21:50:10 christos Exp $ */ +/* $NetBSD: at_var.h,v 1.9 2019/10/09 14:15:40 maxv Exp $ */ /* * Copyright (c) 1990,1991 Regents of The University of Michigan. @@ -75,13 +75,13 @@ sockaddr_at_init1(struct sockaddr_at *sa { sat->sat_port = port; sat->sat_addr = *addr; - memset(>sat_range, 0, sizeof(sat->sat_range)); } static __inline void sockaddr_at_init(struct sockaddr_at *sat, const struct at_addr *addr, uint8_t port) { + memset(sat, 0, sizeof(*sat)); sat->sat_family = AF_APPLETALK; sat->sat_len = sizeof(*sat); sockaddr_at_init1(sat, addr, port); @@ -92,7 +92,8 @@ sockaddr_at_alloc(const struct at_addr * { struct sockaddr *sa; - sa = sockaddr_alloc(AF_APPLETALK, sizeof(struct sockaddr_at), flags); + sa = sockaddr_alloc(AF_APPLETALK, sizeof(struct sockaddr_at), + flags | M_ZERO); if (sa == NULL) return NULL;
CVS commit: src/sys/dev
Module Name:src Committed By: maxv Date: Wed Oct 9 14:03:58 UTC 2019 Modified Files: src/sys/dev/acpi: tpm_acpi.c src/sys/dev/ic: tpm.c tpmvar.h src/sys/dev/isa: tpm_isa.c Log Message: Provide a better abstraction for the TPM interface. Report it in the ioctl. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/sys/dev/acpi/tpm_acpi.c cvs rdiff -u -r1.15 -r1.16 src/sys/dev/ic/tpm.c cvs rdiff -u -r1.6 -r1.7 src/sys/dev/ic/tpmvar.h cvs rdiff -u -r1.6 -r1.7 src/sys/dev/isa/tpm_isa.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev
Module Name:src Committed By: maxv Date: Wed Oct 9 14:03:58 UTC 2019 Modified Files: src/sys/dev/acpi: tpm_acpi.c src/sys/dev/ic: tpm.c tpmvar.h src/sys/dev/isa: tpm_isa.c Log Message: Provide a better abstraction for the TPM interface. Report it in the ioctl. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/sys/dev/acpi/tpm_acpi.c cvs rdiff -u -r1.15 -r1.16 src/sys/dev/ic/tpm.c cvs rdiff -u -r1.6 -r1.7 src/sys/dev/ic/tpmvar.h cvs rdiff -u -r1.6 -r1.7 src/sys/dev/isa/tpm_isa.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/acpi/tpm_acpi.c diff -u src/sys/dev/acpi/tpm_acpi.c:1.10 src/sys/dev/acpi/tpm_acpi.c:1.11 --- src/sys/dev/acpi/tpm_acpi.c:1.10 Wed Oct 9 07:30:58 2019 +++ src/sys/dev/acpi/tpm_acpi.c Wed Oct 9 14:03:57 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: tpm_acpi.c,v 1.10 2019/10/09 07:30:58 maxv Exp $ */ +/* $NetBSD: tpm_acpi.c,v 1.11 2019/10/09 14:03:57 maxv Exp $ */ /* * Copyright (c) 2012, 2019 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tpm_acpi.c,v 1.10 2019/10/09 07:30:58 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tpm_acpi.c,v 1.11 2019/10/09 14:03:57 maxv Exp $"); #include #include @@ -118,33 +118,26 @@ tpm_acpi_attach(device_t parent, device_ (uint64_t)mem->ar_length, TPM_SPACE_SIZE); goto out; } + base = mem->ar_base; + size = mem->ar_length; sc->sc_dev = self; sc->sc_ver = TPM_2_0; mutex_init(>sc_lock, MUTEX_DEFAULT, IPL_NONE); sc->sc_busy = false; - sc->sc_init = tpm_tis12_init; - sc->sc_start = tpm_tis12_start; - sc->sc_read = tpm_tis12_read; - sc->sc_write = tpm_tis12_write; - sc->sc_end = tpm_tis12_end; + sc->sc_intf = _intf_tis12; sc->sc_bt = aa->aa_memt; - - base = mem->ar_base; - size = mem->ar_length; - if (bus_space_map(sc->sc_bt, base, size, 0, >sc_bh)) { aprint_error_dev(sc->sc_dev, "cannot map registers\n"); goto out; } - if (!tpm_tis12_probe(sc->sc_bt, sc->sc_bh)) { - aprint_error_dev(sc->sc_dev, "TIS1.2 probe failed\n"); + if ((rv = (*sc->sc_intf->probe)(sc->sc_bt, sc->sc_bh)) != 0) { + aprint_error_dev(sc->sc_dev, "probe failed, rv=%d\n", rv); goto out1; } - - if ((*sc->sc_init)(sc) != 0) { - aprint_error_dev(sc->sc_dev, "cannot init device %d\n", rv); + if ((rv = (*sc->sc_intf->init)(sc)) != 0) { + aprint_error_dev(sc->sc_dev, "cannot init device, rv=%d\n", rv); goto out1; } Index: src/sys/dev/ic/tpm.c diff -u src/sys/dev/ic/tpm.c:1.15 src/sys/dev/ic/tpm.c:1.16 --- src/sys/dev/ic/tpm.c:1.15 Wed Oct 9 07:30:58 2019 +++ src/sys/dev/ic/tpm.c Wed Oct 9 14:03:58 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: tpm.c,v 1.15 2019/10/09 07:30:58 maxv Exp $ */ +/* $NetBSD: tpm.c,v 1.16 2019/10/09 14:03:58 maxv Exp $ */ /* * Copyright (c) 2019 The NetBSD Foundation, Inc. @@ -48,7 +48,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tpm.c,v 1.15 2019/10/09 07:30:58 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tpm.c,v 1.16 2019/10/09 14:03:58 maxv Exp $"); #include #include @@ -93,42 +93,6 @@ tpm_tmotohz(int tmo) } static int -tpm_request_locality(struct tpm_softc *sc, int l) -{ - uint32_t r; - int to, rv; - - if (l != 0) - return EINVAL; - - if ((bus_space_read_1(sc->sc_bt, sc->sc_bh, TPM_ACCESS) & - (TPM_ACCESS_VALID | TPM_ACCESS_ACTIVE_LOCALITY)) == - (TPM_ACCESS_VALID | TPM_ACCESS_ACTIVE_LOCALITY)) - return 0; - - bus_space_write_1(sc->sc_bt, sc->sc_bh, TPM_ACCESS, - TPM_ACCESS_REQUEST_USE); - - to = tpm_tmotohz(TPM_ACCESS_TMO); - - while ((r = bus_space_read_1(sc->sc_bt, sc->sc_bh, TPM_ACCESS) & - (TPM_ACCESS_VALID | TPM_ACCESS_ACTIVE_LOCALITY)) != - (TPM_ACCESS_VALID | TPM_ACCESS_ACTIVE_LOCALITY) && to--) { - rv = tsleep(sc->sc_init, PCATCH, "tpm_locality", 1); - if (rv && rv != EWOULDBLOCK) { - return rv; - } - } - - if ((r & (TPM_ACCESS_VALID | TPM_ACCESS_ACTIVE_LOCALITY)) != - (TPM_ACCESS_VALID | TPM_ACCESS_ACTIVE_LOCALITY)) { - return EBUSY; - } - - return 0; -} - -static int tpm_getburst(struct tpm_softc *sc) { int burst, to, rv; @@ -174,9 +138,9 @@ tpm12_suspend(struct tpm_softc *sc) }; struct tpm_header response; - if ((*sc->sc_write)(sc, , sizeof(command)) != 0) + if ((*sc->sc_intf->write)(sc, , sizeof(command)) != 0) return false; - if ((*sc->sc_read)(sc, , sizeof(response), NULL, 0) != 0) + if ((*sc->sc_intf->read)(sc, , sizeof(response), NULL, 0) != 0) return false; if (TPM_BE32(response.code) != 0) return false; @@ -195,9 +159,9 @@ tpm20_suspend(struct tpm_softc *sc) }; struct tpm_header response; - if ((*sc->sc_write)(sc, , sizeof(command)) != 0) + if ((*sc->sc_intf->write)(sc, , sizeof(command)) != 0) return false; - if ((*sc->sc_read)(sc, , sizeof(response), NULL, 0) != 0) + if ((*sc->sc_intf->read)(sc, , sizeof(response), NULL, 0) != 0) return false; if (TPM_BE32(response.code) != 0) return false; @@ -286,10 +250,46 @@
CVS commit: src/sys/dev
Module Name:src Committed By: maxv Date: Wed Oct 9 07:30:58 UTC 2019 Modified Files: src/sys/dev/acpi: tpm_acpi.c src/sys/dev/ic: tpm.c tpmreg.h tpmvar.h src/sys/dev/isa: tpm_isa.c Log Message: Add suspend support for TPM 2.0 chips. Check the TPM response also for 1.2 chips. Unfortunately I cannot really test this change since ACPI suspend does not work on any of my laptops. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/dev/acpi/tpm_acpi.c cvs rdiff -u -r1.14 -r1.15 src/sys/dev/ic/tpm.c cvs rdiff -u -r1.5 -r1.6 src/sys/dev/ic/tpmreg.h src/sys/dev/ic/tpmvar.h cvs rdiff -u -r1.5 -r1.6 src/sys/dev/isa/tpm_isa.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev
Module Name:src Committed By: maxv Date: Wed Oct 9 07:30:58 UTC 2019 Modified Files: src/sys/dev/acpi: tpm_acpi.c src/sys/dev/ic: tpm.c tpmreg.h tpmvar.h src/sys/dev/isa: tpm_isa.c Log Message: Add suspend support for TPM 2.0 chips. Check the TPM response also for 1.2 chips. Unfortunately I cannot really test this change since ACPI suspend does not work on any of my laptops. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/dev/acpi/tpm_acpi.c cvs rdiff -u -r1.14 -r1.15 src/sys/dev/ic/tpm.c cvs rdiff -u -r1.5 -r1.6 src/sys/dev/ic/tpmreg.h src/sys/dev/ic/tpmvar.h cvs rdiff -u -r1.5 -r1.6 src/sys/dev/isa/tpm_isa.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/acpi/tpm_acpi.c diff -u src/sys/dev/acpi/tpm_acpi.c:1.9 src/sys/dev/acpi/tpm_acpi.c:1.10 --- src/sys/dev/acpi/tpm_acpi.c:1.9 Tue Oct 8 18:43:02 2019 +++ src/sys/dev/acpi/tpm_acpi.c Wed Oct 9 07:30:58 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: tpm_acpi.c,v 1.9 2019/10/08 18:43:02 maxv Exp $ */ +/* $NetBSD: tpm_acpi.c,v 1.10 2019/10/09 07:30:58 maxv Exp $ */ /* * Copyright (c) 2012, 2019 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tpm_acpi.c,v 1.9 2019/10/08 18:43:02 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tpm_acpi.c,v 1.10 2019/10/09 07:30:58 maxv Exp $"); #include #include @@ -148,6 +148,8 @@ tpm_acpi_attach(device_t parent, device_ goto out1; } + if (!pmf_device_register(self, tpm_suspend, tpm_resume)) + aprint_error_dev(self, "couldn't establish power handler\n"); acpi_resource_cleanup(); return; Index: src/sys/dev/ic/tpm.c diff -u src/sys/dev/ic/tpm.c:1.14 src/sys/dev/ic/tpm.c:1.15 --- src/sys/dev/ic/tpm.c:1.14 Tue Oct 8 18:43:02 2019 +++ src/sys/dev/ic/tpm.c Wed Oct 9 07:30:58 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: tpm.c,v 1.14 2019/10/08 18:43:02 maxv Exp $ */ +/* $NetBSD: tpm.c,v 1.15 2019/10/09 07:30:58 maxv Exp $ */ /* * Copyright (c) 2019 The NetBSD Foundation, Inc. @@ -48,7 +48,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tpm.c,v 1.14 2019/10/08 18:43:02 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tpm.c,v 1.15 2019/10/09 07:30:58 maxv Exp $"); #include #include @@ -65,8 +65,9 @@ __KERNEL_RCSID(0, "$NetBSD: tpm.c,v 1.14 #include "ioconf.h" +CTASSERT(sizeof(struct tpm_header) == 10); + #define TPM_BUFSIZ 1024 -#define TPM_HDRSIZE 10 #define TPM_PARAM_SIZE 0x0001 /* that's a flag */ @@ -163,31 +164,69 @@ tpm_status(struct tpm_softc *sc) /* -- */ -/* - * Save TPM state on suspend. On resume we don't do anything, since the BIOS - * is supposed to restore the previously saved state. - */ +static bool +tpm12_suspend(struct tpm_softc *sc) +{ + static const uint8_t command[10] = { + 0x00, 0xC1, /* TPM_TAG_RQU_COMMAND */ + 0x00, 0x00, 0x00, 10, /* Length in bytes */ + 0x00, 0x00, 0x00, 0x98 /* TPM_ORD_SaveState */ + }; + struct tpm_header response; -bool -tpm12_suspend(device_t dev, const pmf_qual_t *qual) + if ((*sc->sc_write)(sc, , sizeof(command)) != 0) + return false; + if ((*sc->sc_read)(sc, , sizeof(response), NULL, 0) != 0) + return false; + if (TPM_BE32(response.code) != 0) + return false; + + return true; +} + +static bool +tpm20_suspend(struct tpm_softc *sc) { - struct tpm_softc *sc = device_private(dev); - static const uint8_t command[] = { - 0, 0xC1, /* TPM_TAG_RQU_COMMAND */ - 0, 0, 0, 10, /* Length in bytes */ - 0, 0, 0, 0x98 /* TPM_ORD_SaveState */ + static const uint8_t command[12] = { + 0x80, 0x01, /* TPM_ST_NO_SESSIONS */ + 0x00, 0x00, 0x00, 12, /* Length in bytes */ + 0x00, 0x00, 0x01, 0x45, /* TPM_CC_Shutdown */ + 0x00, 0x01 /* TPM_SU_STATE */ }; - uint8_t scratch[sizeof(command)]; + struct tpm_header response; - (*sc->sc_write)(sc, , sizeof(command)); - (*sc->sc_read)(sc, , sizeof(scratch), NULL, 0); + if ((*sc->sc_write)(sc, , sizeof(command)) != 0) + return false; + if ((*sc->sc_read)(sc, , sizeof(response), NULL, 0) != 0) + return false; + if (TPM_BE32(response.code) != 0) + return false; return true; } bool -tpm12_resume(device_t dev, const pmf_qual_t *qual) +tpm_suspend(device_t dev, const pmf_qual_t *qual) { + struct tpm_softc *sc = device_private(dev); + + switch (sc->sc_ver) { + case TPM_1_2: + return tpm12_suspend(sc); + case TPM_2_0: + return tpm20_suspend(sc); + default: + panic("%s: impossible", __func__); + } +} + +bool +tpm_resume(device_t dev, const pmf_qual_t *qual) +{ + /* + * Don't do anything, the BIOS is supposed to restore the previously + * saved state. + */ return true; } @@ -508,6 +547,7 @@ static int tpmread(dev_t dev, struct uio *uio, int flags) { struct tpm_softc *sc = device_lookup_private(_cd, minor(dev)); + struct tpm_header hdr; uint8_t buf[TPM_BUFSIZ]; size_t cnt, len, n; int rv; @@ -519,11 +559,11 @@
CVS commit: src/sys/arch
Module Name:src Committed By: maxv Date: Tue Oct 8 18:50:44 UTC 2019 Modified Files: src/sys/arch/amd64/conf: ALL GENERIC src/sys/arch/i386/conf: ALL GENERIC Log Message: No I/O ports for TPM-ISA, only MMIO, so remove commented-out options. To generate a diff of this commit: cvs rdiff -u -r1.124 -r1.125 src/sys/arch/amd64/conf/ALL cvs rdiff -u -r1.537 -r1.538 src/sys/arch/amd64/conf/GENERIC cvs rdiff -u -r1.471 -r1.472 src/sys/arch/i386/conf/ALL cvs rdiff -u -r1.1211 -r1.1212 src/sys/arch/i386/conf/GENERIC Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch
Module Name:src Committed By: maxv Date: Tue Oct 8 18:50:44 UTC 2019 Modified Files: src/sys/arch/amd64/conf: ALL GENERIC src/sys/arch/i386/conf: ALL GENERIC Log Message: No I/O ports for TPM-ISA, only MMIO, so remove commented-out options. To generate a diff of this commit: cvs rdiff -u -r1.124 -r1.125 src/sys/arch/amd64/conf/ALL cvs rdiff -u -r1.537 -r1.538 src/sys/arch/amd64/conf/GENERIC cvs rdiff -u -r1.471 -r1.472 src/sys/arch/i386/conf/ALL cvs rdiff -u -r1.1211 -r1.1212 src/sys/arch/i386/conf/GENERIC Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/amd64/conf/ALL diff -u src/sys/arch/amd64/conf/ALL:1.124 src/sys/arch/amd64/conf/ALL:1.125 --- src/sys/arch/amd64/conf/ALL:1.124 Mon Oct 7 11:53:40 2019 +++ src/sys/arch/amd64/conf/ALL Tue Oct 8 18:50:44 2019 @@ -1,4 +1,4 @@ -# $NetBSD: ALL,v 1.124 2019/10/07 11:53:40 msaitoh Exp $ +# $NetBSD: ALL,v 1.125 2019/10/08 18:50:44 maxv Exp $ # From NetBSD: GENERIC,v 1.787 2006/10/01 18:37:54 bouyer Exp # # ALL machine description file @@ -17,7 +17,7 @@ include "arch/amd64/conf/std.amd64" options INCLUDE_CONFIG_FILE # embed config file in kernel binary -#ident "ALL-$Revision: 1.124 $" +#ident "ALL-$Revision: 1.125 $" maxusers 64 # estimated number of users @@ -1549,13 +1549,8 @@ btsco* at bthub? hifn* at pci? dev ? function ? # Hifn 7755/7811/795x ubsec* at pci? dev ? function ? # Broadcom 5501/5601/580x/582x - # Trusted Platform Module tpm* at isa? iomem 0xfed4 irq 7 -#tpm* at isa? port 0x02e -#tpm* at isa? port 0x04e -#tpm* at isa? port 0x07e -#tpm* at isa? port 0x0ee # Joysticks Index: src/sys/arch/amd64/conf/GENERIC diff -u src/sys/arch/amd64/conf/GENERIC:1.537 src/sys/arch/amd64/conf/GENERIC:1.538 --- src/sys/arch/amd64/conf/GENERIC:1.537 Mon Oct 7 11:53:40 2019 +++ src/sys/arch/amd64/conf/GENERIC Tue Oct 8 18:50:44 2019 @@ -1,4 +1,4 @@ -# $NetBSD: GENERIC,v 1.537 2019/10/07 11:53:40 msaitoh Exp $ +# $NetBSD: GENERIC,v 1.538 2019/10/08 18:50:44 maxv Exp $ # # GENERIC machine description file # @@ -22,7 +22,7 @@ include "arch/amd64/conf/std.amd64" options INCLUDE_CONFIG_FILE # embed config file in kernel binary -#ident "GENERIC-$Revision: 1.537 $" +#ident "GENERIC-$Revision: 1.538 $" maxusers 64 # estimated number of users @@ -437,10 +437,6 @@ ubsec* at pci? dev ? function ? # Broadc # Trusted Platform Module tpm* at isa? iomem 0xfed4 irq 7 -#tpm* at isa? port 0x02e -#tpm* at isa? port 0x04e -#tpm* at isa? port 0x07e -#tpm* at isa? port 0x0ee # Serial Devices Index: src/sys/arch/i386/conf/ALL diff -u src/sys/arch/i386/conf/ALL:1.471 src/sys/arch/i386/conf/ALL:1.472 --- src/sys/arch/i386/conf/ALL:1.471 Mon Oct 7 11:53:40 2019 +++ src/sys/arch/i386/conf/ALL Tue Oct 8 18:50:44 2019 @@ -1,4 +1,4 @@ -# $NetBSD: ALL,v 1.471 2019/10/07 11:53:40 msaitoh Exp $ +# $NetBSD: ALL,v 1.472 2019/10/08 18:50:44 maxv Exp $ # From NetBSD: GENERIC,v 1.787 2006/10/01 18:37:54 bouyer Exp # # ALL machine description file @@ -17,7 +17,7 @@ include "arch/i386/conf/std.i386" options INCLUDE_CONFIG_FILE # embed config file in kernel binary -#ident "ALL-$Revision: 1.471 $" +#ident "ALL-$Revision: 1.472 $" maxusers 64 # estimated number of users @@ -1667,13 +1667,8 @@ glxsb* at pci? dev ? function ? # AMD Ge hifn* at pci? dev ? function ? # Hifn 7755/7811/795x ubsec* at pci? dev ? function ? # Broadcom 5501/5601/580x/582x - # Trusted Platform Module tpm* at isa? iomem 0xfed4 irq 7 -#tpm* at isa? port 0x02e -#tpm* at isa? port 0x04e -#tpm* at isa? port 0x07e -#tpm* at isa? port 0x0ee # Joysticks Index: src/sys/arch/i386/conf/GENERIC diff -u src/sys/arch/i386/conf/GENERIC:1.1211 src/sys/arch/i386/conf/GENERIC:1.1212 --- src/sys/arch/i386/conf/GENERIC:1.1211 Mon Oct 7 11:53:40 2019 +++ src/sys/arch/i386/conf/GENERIC Tue Oct 8 18:50:44 2019 @@ -1,4 +1,4 @@ -# $NetBSD: GENERIC,v 1.1211 2019/10/07 11:53:40 msaitoh Exp $ +# $NetBSD: GENERIC,v 1.1212 2019/10/08 18:50:44 maxv Exp $ # # GENERIC machine description file # @@ -22,7 +22,7 @@ include "arch/i386/conf/std.i386" options INCLUDE_CONFIG_FILE # embed config file in kernel binary -#ident "GENERIC-$Revision: 1.1211 $" +#ident "GENERIC-$Revision: 1.1212 $" maxusers 64 # estimated number of users @@ -1367,10 +1367,6 @@ ubsec* at pci? dev ? function ? # Broadc # Trusted Platform Module tpm* at isa? iomem 0xfed4 irq 7 -#tpm* at isa? port 0x02e -#tpm* at isa? port 0x04e -#tpm* at isa? port 0x07e -#tpm* at isa? port 0x0ee # Joysticks
CVS commit: src
Module Name:src Committed By: maxv Date: Tue Oct 8 18:43:03 UTC 2019 Modified Files: src/share/man/man4: tpm.4 src/sys/dev/acpi: tpm_acpi.c src/sys/dev/ic: tpm.c tpmreg.h tpmvar.h src/sys/dev/isa: tpm_isa.c Log Message: Improvements in tpm(4): - Remove interrupt support, do polling only, avoids unnecessary trouble. - Simplify a few things. - Fix the suspend function, the SaveState command is 0x98, not 0x9C. - Make the driver MP-safe. - Sync the man page with reality. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/share/man/man4/tpm.4 cvs rdiff -u -r1.8 -r1.9 src/sys/dev/acpi/tpm_acpi.c cvs rdiff -u -r1.13 -r1.14 src/sys/dev/ic/tpm.c cvs rdiff -u -r1.4 -r1.5 src/sys/dev/ic/tpmreg.h src/sys/dev/ic/tpmvar.h cvs rdiff -u -r1.4 -r1.5 src/sys/dev/isa/tpm_isa.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/share/man/man4/tpm.4 diff -u src/share/man/man4/tpm.4:1.4 src/share/man/man4/tpm.4:1.5 --- src/share/man/man4/tpm.4:1.4 Thu Feb 22 01:40:49 2018 +++ src/share/man/man4/tpm.4 Tue Oct 8 18:43:03 2019 @@ -1,20 +1,33 @@ -.\" $NetBSD: tpm.4,v 1.4 2018/02/22 01:40:49 pgoyette Exp $ +.\" $NetBSD: tpm.4,v 1.5 2019/10/08 18:43:03 maxv Exp $ .\" -.\" Copyright (c) 2010 Hans-Jörg Höxer, +.\" Copyright (c) 2019 The NetBSD Foundation, Inc. +.\" All rights reserved. .\" -.\" Permission to use, copy, modify, and distribute this software for any -.\" purpose with or without fee is hereby granted, provided that the above -.\" copyright notice and this permission notice appear in all copies. +.\" This code is derived from software contributed to The NetBSD Foundation +.\" by Maxime Villard. .\" -.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +.\" 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. .\" -.Dd February 22, 2018 +.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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. +.\" +.Dd October 6, 2019 .Dt TPM 4 .Os .Sh NAME @@ -22,40 +35,22 @@ .Nd Trusted Platform Module .Sh SYNOPSIS .Cd "tpm* at isa? iomem 0xfed4" -.Cd "tpm* at isa? iomem 0xfed4 irq 7" .Cd "tpm* at acpi?" .Sh DESCRIPTION The .Nm -driver provides support for various trusted platform modules (TPM) that can -store cryptographic keys. +driver provides support for various Trusted Platform Module (TPM) chips. .Pp Supported modules: .Pp .Bl -bullet -compact -offset indent .It -Atmel 97SC3203 -.It -Broadcom BCM0102 -.It -Infineon IFX SLD 9630 TT 1.1 and IFX SLB 9635 TT 1.2 -.It -Intel INTC0102 -.It -Sinosun SNS SSX35 -.It -STM ST19WP18 +TPM 2.0 chips over ACPI .It -Winbond WEC WPCT200 +TPM 1.2 chips over ISA .El .Pp -The driver can be configured to use an IRQ by providing a free ISA -interrupt vector using the keyword -.Em irq -in the kernel configuration file or using -.Xr config 1 . -If not IRQ is specified, the driver uses polling. -This is the default configuration. +Note that the supported interface version is TIS1.2 in each case. .Sh SEE ALSO .Xr
CVS commit: src
Module Name:src Committed By: maxv Date: Tue Oct 8 18:43:03 UTC 2019 Modified Files: src/share/man/man4: tpm.4 src/sys/dev/acpi: tpm_acpi.c src/sys/dev/ic: tpm.c tpmreg.h tpmvar.h src/sys/dev/isa: tpm_isa.c Log Message: Improvements in tpm(4): - Remove interrupt support, do polling only, avoids unnecessary trouble. - Simplify a few things. - Fix the suspend function, the SaveState command is 0x98, not 0x9C. - Make the driver MP-safe. - Sync the man page with reality. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/share/man/man4/tpm.4 cvs rdiff -u -r1.8 -r1.9 src/sys/dev/acpi/tpm_acpi.c cvs rdiff -u -r1.13 -r1.14 src/sys/dev/ic/tpm.c cvs rdiff -u -r1.4 -r1.5 src/sys/dev/ic/tpmreg.h src/sys/dev/ic/tpmvar.h cvs rdiff -u -r1.4 -r1.5 src/sys/dev/isa/tpm_isa.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Re: CVS commit: src/sys/kern
Le 01/10/2019 à 18:36, Chuck Silvers a écrit : Module Name:src Committed By: chs Date: Tue Oct 1 16:36:58 UTC 2019 Modified Files: src/sys/kern: sysv_shm.c Log Message: in shmdt(), wait until shmat() completes before detaching. Reported-by: syzbot+8f470a1bf36b47ae0...@syzkaller.appspotmail.com Reported-by: syzbot+45810b4c41ed65d91...@syzkaller.appspotmail.com To generate a diff of this commit: cvs rdiff -u -r1.138 -r1.139 src/sys/kern/sysv_shm.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Looks like this line is missing diff --git a/sys/kern/sysv_shm.c b/sys/kern/sysv_shm.c index b090d1bc4262..c52cb65ec768 100644 --- a/sys/kern/sysv_shm.c +++ b/sys/kern/sysv_shm.c @@ -259,6 +259,7 @@ shmmap_getprivate(struct proc *p) shmmap_se = kmem_alloc(sizeof(struct shmmap_entry), KM_SLEEP); shmmap_se->va = oshmmap_se->va; shmmap_se->shmid = oshmmap_se->shmid; + shmmap_se->busy = oshmmap_se->busy; SLIST_INSERT_HEAD(_s->entries, shmmap_se, next); } shmmap_s->nitems = oshmmap_s->nitems; The access made from the caller is not initialized 353 if (shmmap_se->busy) {
CVS commit: src/sys/arch/x86/include
Module Name:src Committed By: maxv Date: Sat Oct 5 07:30:03 UTC 2019 Modified Files: src/sys/arch/x86/include: pmap.h pte.h Log Message: Switch to the new PTE naming. No binary diff (tested with MKREPRO). To generate a diff of this commit: cvs rdiff -u -r1.102 -r1.103 src/sys/arch/x86/include/pmap.h cvs rdiff -u -r1.1 -r1.2 src/sys/arch/x86/include/pte.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/x86/include
Module Name:src Committed By: maxv Date: Sat Oct 5 07:30:03 UTC 2019 Modified Files: src/sys/arch/x86/include: pmap.h pte.h Log Message: Switch to the new PTE naming. No binary diff (tested with MKREPRO). To generate a diff of this commit: cvs rdiff -u -r1.102 -r1.103 src/sys/arch/x86/include/pmap.h cvs rdiff -u -r1.1 -r1.2 src/sys/arch/x86/include/pte.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/include/pmap.h diff -u src/sys/arch/x86/include/pmap.h:1.102 src/sys/arch/x86/include/pmap.h:1.103 --- src/sys/arch/x86/include/pmap.h:1.102 Wed Aug 7 06:23:48 2019 +++ src/sys/arch/x86/include/pmap.h Sat Oct 5 07:30:03 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.h,v 1.102 2019/08/07 06:23:48 maxv Exp $ */ +/* $NetBSD: pmap.h,v 1.103 2019/10/05 07:30:03 maxv Exp $ */ /* * Copyright (c) 1997 Charles D. Cranor and Washington University. @@ -315,8 +315,8 @@ struct pmap { */ extern u_long PDPpaddr; -extern pd_entry_t pmap_pg_g; /* do we support PG_G? */ -extern pd_entry_t pmap_pg_nx; /* do we support PG_NX? */ +extern pd_entry_t pmap_pg_g; /* do we support PTE_G? */ +extern pd_entry_t pmap_pg_nx; /* do we support PTE_NX? */ extern int pmap_largepages; extern long nkptp[PTP_LEVELS]; @@ -526,7 +526,7 @@ kvtopte(vaddr_t va) KASSERT(va >= VM_MIN_KERNEL_ADDRESS); pde = L2_BASE + pl2_i(va); - if (*pde & PG_PS) + if (*pde & PTE_PS) return ((pt_entry_t *)pde); return (PTE_BASE + pl1_i(va)); @@ -560,7 +560,7 @@ xpmap_ptetomach(pt_entry_t *pte) va = ((va & XPTE_MASK) >> XPTE_SHIFT) | (vaddr_t) PTE_BASE; up_pte = (pt_entry_t *) va; - return (paddr_t) (((*up_pte) & PG_FRAME) + (((vaddr_t) pte) & (~PG_FRAME & ~VA_SIGN_MASK))); + return (paddr_t) (((*up_pte) & PTE_FRAME) + (((vaddr_t) pte) & (~PTE_FRAME & ~VA_SIGN_MASK))); } /* Xen helpers to change bits of a pte */ Index: src/sys/arch/x86/include/pte.h diff -u src/sys/arch/x86/include/pte.h:1.1 src/sys/arch/x86/include/pte.h:1.2 --- src/sys/arch/x86/include/pte.h:1.1 Tue Jul 6 20:50:35 2010 +++ src/sys/arch/x86/include/pte.h Sat Oct 5 07:30:03 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: pte.h,v 1.1 2010/07/06 20:50:35 cegger Exp $ */ +/* $NetBSD: pte.h,v 1.2 2019/10/05 07:30:03 maxv Exp $ */ /* * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -33,10 +33,10 @@ #define _X86_PTE_H /* Cacheability bits when we are using PAT */ -#define PGC_WB 0 /* The default */ -#define PGC_WC PG_WT /* WT and CD is WC */ -#define PGC_UCMINUS PG_N/* UC but mtrr can override */ -#define PGC_UC (PG_WT | PG_N) /* hard UC */ +#define PGC_WB 0 /* The default */ +#define PGC_WC PTE_PWT /* WT and CD is WC */ +#define PGC_UCMINUS PTE_PCD /* UC but mtrr can override */ +#define PGC_UC (PTE_PWT | PTE_PCD) /* hard UC */ /* * page protection exception bits
CVS commit: src/sys/arch/x86/x86
Module Name:src Committed By: maxv Date: Sat Oct 5 07:19:49 UTC 2019 Modified Files: src/sys/arch/x86/x86: pmap.c Log Message: Switch to the new PTE naming: PG_PVLIST -> PTE_PVLIST PG_W -> PTE_WIRED PG_FRAME -> PTE_FRAME No functional change. To generate a diff of this commit: cvs rdiff -u -r1.335 -r1.336 src/sys/arch/x86/x86/pmap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/x86/x86
Module Name:src Committed By: maxv Date: Sat Oct 5 07:19:49 UTC 2019 Modified Files: src/sys/arch/x86/x86: pmap.c Log Message: Switch to the new PTE naming: PG_PVLIST -> PTE_PVLIST PG_W -> PTE_WIRED PG_FRAME -> PTE_FRAME No functional change. To generate a diff of this commit: cvs rdiff -u -r1.335 -r1.336 src/sys/arch/x86/x86/pmap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/x86/pmap.c diff -u src/sys/arch/x86/x86/pmap.c:1.335 src/sys/arch/x86/x86/pmap.c:1.336 --- src/sys/arch/x86/x86/pmap.c:1.335 Wed Aug 7 06:23:48 2019 +++ src/sys/arch/x86/x86/pmap.c Sat Oct 5 07:19:49 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.335 2019/08/07 06:23:48 maxv Exp $ */ +/* $NetBSD: pmap.c,v 1.336 2019/10/05 07:19:49 maxv Exp $ */ /* * Copyright (c) 2008, 2010, 2016, 2017 The NetBSD Foundation, Inc. @@ -130,7 +130,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.335 2019/08/07 06:23:48 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.336 2019/10/05 07:19:49 maxv Exp $"); #include "opt_user_ldt.h" #include "opt_lockdebug.h" @@ -299,10 +299,10 @@ struct pmap *const kernel_pmap_ptr = struct bootspace bootspace __read_mostly; struct slotspace slotspace __read_mostly; -/* Set to PG_NX if supported. */ +/* Set to PTE_NX if supported. */ pd_entry_t pmap_pg_nx __read_mostly = 0; -/* Set to PG_G if supported. */ +/* Set to PTE_G if supported. */ pd_entry_t pmap_pg_g __read_mostly = 0; /* Set to true if large pages are supported. */ @@ -512,10 +512,10 @@ static inline void pmap_stats_update_bypte(struct pmap *pmap, pt_entry_t npte, pt_entry_t opte) { int resid_diff = ((npte & PTE_P) ? 1 : 0) - ((opte & PTE_P) ? 1 : 0); - int wired_diff = ((npte & PG_W) ? 1 : 0) - ((opte & PG_W) ? 1 : 0); + int wired_diff = ((npte & PTE_WIRED) ? 1 : 0) - ((opte & PTE_WIRED) ? 1 : 0); - KASSERT((npte & (PTE_P | PG_W)) != PG_W); - KASSERT((opte & (PTE_P | PG_W)) != PG_W); + KASSERT((npte & (PTE_P | PTE_WIRED)) != PTE_WIRED); + KASSERT((opte & (PTE_P | PTE_WIRED)) != PTE_WIRED); pmap_stats_update(pmap, resid_diff, wired_diff); } @@ -973,7 +973,7 @@ pmap_kremove1(vaddr_t sva, vsize_t len, } KASSERTMSG((opte & PTE_PS) == 0, "va %#" PRIxVADDR " is a large page", va); - KASSERTMSG((opte & PG_PVLIST) == 0, + KASSERTMSG((opte & PTE_PVLIST) == 0, "va %#" PRIxVADDR " is a pv tracked page", va); } if (localonly) { @@ -3507,12 +3507,12 @@ pmap_remove_pte(struct pmap *pmap, struc /* * If we are not on a pv_head list - we are done. */ - if ((opte & PG_PVLIST) == 0) { + if ((opte & PTE_PVLIST) == 0) { #ifndef DOM0OPS KASSERTMSG((PHYS_TO_VM_PAGE(pmap_pte2pa(opte)) == NULL), - "managed page without PG_PVLIST for %#"PRIxVADDR, va); + "managed page without PTE_PVLIST for %#"PRIxVADDR, va); KASSERTMSG((pmap_pv_tracked(pmap_pte2pa(opte)) == NULL), - "pv-tracked page without PG_PVLIST for %#"PRIxVADDR, va); + "pv-tracked page without PTE_PVLIST for %#"PRIxVADDR, va); #endif return true; } @@ -3522,7 +3522,7 @@ pmap_remove_pte(struct pmap *pmap, struc pp = VM_PAGE_TO_PP(pg); } else if ((pp = pmap_pv_tracked(pmap_pte2pa(opte))) == NULL) { paddr_t pa = pmap_pte2pa(opte); - panic("%s: PG_PVLIST with pv-untracked page" + panic("%s: PTE_PVLIST with pv-untracked page" " va = %#"PRIxVADDR"pa = %#"PRIxPADDR" (%#"PRIxPADDR")", __func__, va, pa, atop(pa)); } @@ -4124,8 +4124,8 @@ pmap_unwire(struct pmap *pmap, vaddr_t v opte = *ptep; KASSERT(pmap_valid_entry(opte)); - if (opte & PG_W) { - pt_entry_t npte = opte & ~PG_W; + if (opte & PTE_WIRED) { + pt_entry_t npte = opte & ~PTE_WIRED; opte = pmap_pte_testset(ptep, npte); pmap_stats_update_bypte(pmap, npte, opte); @@ -4202,7 +4202,7 @@ pmap_enter_ma(struct pmap *pmap, vaddr_t npte = ma | protection_codes[prot] | PTE_P; npte |= pmap_pat_flags(flags); if (wired) - npte |= PG_W; + npte |= PTE_WIRED; if (va < VM_MAXUSER_ADDRESS) npte |= PTE_U; @@ -4224,11 +4224,11 @@ pmap_enter_ma(struct pmap *pmap, vaddr_t new_pg = PHYS_TO_VM_PAGE(pa); if (new_pg != NULL) { /* This is a managed page */ - npte |= PG_PVLIST; + npte |= PTE_PVLIST; new_pp = VM_PAGE_TO_PP(new_pg); } else if ((new_pp = pmap_pv_tracked(pa)) != NULL) { /* This is an unmanaged pv-tracked page */ - npte |= PG_PVLIST; + npte |= PTE_PVLIST; } else { new_pp = NULL; } @@ -4334,19 +4334,19 @@ pmap_enter_ma(struct pmap *pmap, vaddr_t * If the same page, we can skip pv_entry handling. */ if (((opte ^ npte) & (PTE_FRAME | PTE_P)) == 0) { - KASSERT(((opte ^ npte) & PG_PVLIST) == 0); + KASSERT(((opte ^ npte) & PTE_PVLIST) == 0); goto same_pa; } /* * If old page is pv-tracked, remove pv_entry from its list. */ - if ((~opte & (PTE_P | PG_PVLIST)) == 0) { + if ((~opte & (PTE_P |
CVS commit: src/sys/arch/i386/i386
Module Name:src Committed By: maxv Date: Fri Oct 4 15:28:00 UTC 2019 Modified Files: src/sys/arch/i386/i386: i386_trap.S locore.S spl.S Log Message: Misc reordering, to clarify and reduce the diff against amd64. To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/sys/arch/i386/i386/i386_trap.S cvs rdiff -u -r1.170 -r1.171 src/sys/arch/i386/i386/locore.S cvs rdiff -u -r1.47 -r1.48 src/sys/arch/i386/i386/spl.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/i386/i386
Module Name:src Committed By: maxv Date: Fri Oct 4 15:28:00 UTC 2019 Modified Files: src/sys/arch/i386/i386: i386_trap.S locore.S spl.S Log Message: Misc reordering, to clarify and reduce the diff against amd64. To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/sys/arch/i386/i386/i386_trap.S cvs rdiff -u -r1.170 -r1.171 src/sys/arch/i386/i386/locore.S cvs rdiff -u -r1.47 -r1.48 src/sys/arch/i386/i386/spl.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/i386/i386/i386_trap.S diff -u src/sys/arch/i386/i386/i386_trap.S:1.18 src/sys/arch/i386/i386/i386_trap.S:1.19 --- src/sys/arch/i386/i386/i386_trap.S:1.18 Mon Feb 11 17:28:52 2019 +++ src/sys/arch/i386/i386/i386_trap.S Fri Oct 4 15:28:00 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: i386_trap.S,v 1.18 2019/02/11 17:28:52 cherry Exp $ */ +/* $NetBSD: i386_trap.S,v 1.19 2019/10/04 15:28:00 maxv Exp $ */ /* * Copyright 2002 (c) Wasabi Systems, Inc. @@ -66,7 +66,7 @@ #if 0 #include -__KERNEL_RCSID(0, "$NetBSD: i386_trap.S,v 1.18 2019/02/11 17:28:52 cherry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: i386_trap.S,v 1.19 2019/10/04 15:28:00 maxv Exp $"); #endif /* @@ -220,7 +220,7 @@ IDTVEC(trap07) pushl %esp call _C_LABEL(fpudna) addl $4,%esp - jmp _C_LABEL(trapreturn) + jmp .Lalltraps_checkusr IDTVEC_END(trap07) IDTVEC(trap08) @@ -282,7 +282,7 @@ IDTVEC(trap0f) #ifdef DIAGNOSTIC movl CPUVAR(ILEVEL),%ebx #endif - jmp _C_LABEL(trapreturn) + jmp .Lalltraps_checkusr IDTVEC_END(trap0f) IDTVEC_END(intrspurious) @@ -302,7 +302,7 @@ IDTVEC(trap10) adcl $0,CPUVAR(NTRAP)+4 call _C_LABEL(fputrap) addl $4,%esp - jmp _C_LABEL(trapreturn) + jmp .Lalltraps_checkusr IDTVEC_END(trap10) IDTVEC(trap11) @@ -394,13 +394,14 @@ IDTVEC_END(tss_trap08) .type _C_LABEL(trap_return_fault_return),@function LABEL(trap_return_fault_return) mov 4(%esp),%esp /* frame for user return */ - jmp _C_LABEL(trapreturn) + jmp .Lalltraps_checkusr END(trap_return_fault_return) /* LINTSTUB: Ignore */ ENTRY(alltraps) INTRENTRY STI(%eax) + calltrap: #ifdef DIAGNOSTIC movl CPUVAR(ILEVEL),%ebx @@ -410,16 +411,18 @@ calltrap: pushl %esp call _C_LABEL(trap) addl $4,%esp -_C_LABEL(trapreturn): .globl trapreturn + +.Lalltraps_checkusr: testb $CHK_UPL,TF_CS(%esp) jnz .Lalltraps_checkast jmp 6f + .Lalltraps_checkast: /* Check for ASTs on exit to user mode. */ CLI(%eax) CHECK_ASTPENDING(%eax) jz 3f -5: CLEAR_ASTPENDING(%eax) + CLEAR_ASTPENDING(%eax) STI(%eax) movl $T_ASTFLT,TF_TRAPNO(%esp) addl $1,CPUVAR(NTRAP) /* statistical info */ @@ -430,6 +433,7 @@ _C_LABEL(trapreturn): .globl trapreturn jmp .Lalltraps_checkast /* re-check ASTs */ 3: CHECK_DEFERRED_SWITCH jnz 9f + #ifdef XEN STIC(%eax) jz 6f @@ -450,15 +454,23 @@ _C_LABEL(trapreturn): .globl trapreturn movl CPUVAR(XSOURCES)(,%eax,4),%eax jmp *IS_RESUME(%eax) 7: movl %ebx,CPUVAR(ILEVEL) /* restore cpl */ - jmp _C_LABEL(trapreturn) -#endif /* XEN */ -#ifndef DIAGNOSTIC -6: INTRFASTEXIT -#else -6: cmpl CPUVAR(ILEVEL),%ebx - jne 3f + jmp .Lalltraps_checkusr +#endif + +6: +#ifdef DIAGNOSTIC + cmpl CPUVAR(ILEVEL),%ebx + jne .Lspl_error +#endif INTRFASTEXIT -3: STI(%eax) + +9: STI(%eax) + call _C_LABEL(pmap_load) + jmp .Lalltraps_checkast /* re-check ASTs */ + +#ifdef DIAGNOSTIC +.Lspl_error: + STI(%eax) pushl $4f call _C_LABEL(panic) addl $4,%esp @@ -467,8 +479,5 @@ _C_LABEL(trapreturn): .globl trapreturn addl $4,%esp jmp .Lalltraps_checkast /* re-check ASTs */ 4: .asciz "SPL NOT LOWERED ON TRAP EXIT\n" -#endif /* DIAGNOSTIC */ -9: STI(%eax) - call _C_LABEL(pmap_load) - jmp .Lalltraps_checkast /* re-check ASTs */ +#endif END(alltraps) Index: src/sys/arch/i386/i386/locore.S diff -u src/sys/arch/i386/i386/locore.S:1.170 src/sys/arch/i386/i386/locore.S:1.171 --- src/sys/arch/i386/i386/locore.S:1.170 Fri Oct 4 11:47:07 2019 +++ src/sys/arch/i386/i386/locore.S Fri Oct 4 15:28:00 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: locore.S,v 1.170 2019/10/04 11:47:07 maxv Exp $ */ +/* $NetBSD: locore.S,v 1.171 2019/10/04 15:28:00 maxv Exp $ */ /* * Copyright-o-rama! @@ -128,7 +128,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.170 2019/10/04 11:47:07 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.171 2019/10/04 15:28:00 maxv Exp $"); #include "opt_copy_symtab.h" #include "opt_ddb.h" @@ -1264,6 +1264,7 @@ IDTVEC(syscall) pushl $T_ASTFLT /* trap # for doing ASTs */ INTRENTRY STI(%eax) + #ifdef DIAGNOSTIC movl CPUVAR(ILEVEL),%ebx testl %ebx,%ebx @@ -1276,6 +1277,7 @@ IDTVEC(syscall) #endif 1: #endif /* DIAGNOSTIC */ + addl $1,CPUVAR(NSYSCALL) /* count it atomically */ adcl $0,CPUVAR(NSYSCALL)+4 /* count it atomically */ movl CPUVAR(CURLWP),%edi @@ -1290,6 +1292,7 @@ IDTVEC(syscall) movl L_MD_ASTPENDING(%edi), %eax orl CPUVAR(WANT_PMAPLOAD), %eax jnz 9f + #ifdef XEN STIC(%eax) jz 14f
CVS commit: src/sys/dev/nvmm/x86
Module Name:src Committed By: maxv Date: Fri Oct 4 12:17:05 UTC 2019 Modified Files: src/sys/dev/nvmm/x86: nvmm_x86_svm.c nvmm_x86_vmx.c Log Message: Switch to the new PTE naming. To generate a diff of this commit: cvs rdiff -u -r1.48 -r1.49 src/sys/dev/nvmm/x86/nvmm_x86_svm.c cvs rdiff -u -r1.37 -r1.38 src/sys/dev/nvmm/x86/nvmm_x86_vmx.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/nvmm/x86
Module Name:src Committed By: maxv Date: Fri Oct 4 12:17:05 UTC 2019 Modified Files: src/sys/dev/nvmm/x86: nvmm_x86_svm.c nvmm_x86_vmx.c Log Message: Switch to the new PTE naming. To generate a diff of this commit: cvs rdiff -u -r1.48 -r1.49 src/sys/dev/nvmm/x86/nvmm_x86_svm.c cvs rdiff -u -r1.37 -r1.38 src/sys/dev/nvmm/x86/nvmm_x86_vmx.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/nvmm/x86/nvmm_x86_svm.c diff -u src/sys/dev/nvmm/x86/nvmm_x86_svm.c:1.48 src/sys/dev/nvmm/x86/nvmm_x86_svm.c:1.49 --- src/sys/dev/nvmm/x86/nvmm_x86_svm.c:1.48 Fri Oct 4 12:15:21 2019 +++ src/sys/dev/nvmm/x86/nvmm_x86_svm.c Fri Oct 4 12:17:05 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: nvmm_x86_svm.c,v 1.48 2019/10/04 12:15:21 maxv Exp $ */ +/* $NetBSD: nvmm_x86_svm.c,v 1.49 2019/10/04 12:17:05 maxv Exp $ */ /* * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_svm.c,v 1.48 2019/10/04 12:15:21 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_svm.c,v 1.49 2019/10/04 12:17:05 maxv Exp $"); #include #include @@ -2131,7 +2131,7 @@ svm_tlb_flush(struct pmap *pm) atomic_inc_64(>mach_htlb_gen); /* Generates IPIs, which cause #VMEXITs. */ - pmap_tlb_shootdown(pmap_kernel(), -1, PG_G, TLBSHOOT_UPDATE); + pmap_tlb_shootdown(pmap_kernel(), -1, PTE_G, TLBSHOOT_UPDATE); } static void Index: src/sys/dev/nvmm/x86/nvmm_x86_vmx.c diff -u src/sys/dev/nvmm/x86/nvmm_x86_vmx.c:1.37 src/sys/dev/nvmm/x86/nvmm_x86_vmx.c:1.38 --- src/sys/dev/nvmm/x86/nvmm_x86_vmx.c:1.37 Fri Sep 13 14:19:13 2019 +++ src/sys/dev/nvmm/x86/nvmm_x86_vmx.c Fri Oct 4 12:17:05 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: nvmm_x86_vmx.c,v 1.37 2019/09/13 14:19:13 maxv Exp $ */ +/* $NetBSD: nvmm_x86_vmx.c,v 1.38 2019/10/04 12:17:05 maxv Exp $ */ /* * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_vmx.c,v 1.37 2019/09/13 14:19:13 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_vmx.c,v 1.38 2019/10/04 12:17:05 maxv Exp $"); #include #include @@ -2749,7 +2749,7 @@ vmx_tlb_flush(struct pmap *pm) atomic_inc_64(>mach_htlb_gen); /* Generates IPIs, which cause #VMEXITs. */ - pmap_tlb_shootdown(pmap_kernel(), -1, PG_G, TLBSHOOT_UPDATE); + pmap_tlb_shootdown(pmap_kernel(), -1, PTE_G, TLBSHOOT_UPDATE); } static void
CVS commit: src/sys/dev/nvmm/x86
Module Name:src Committed By: maxv Date: Fri Oct 4 12:15:21 UTC 2019 Modified Files: src/sys/dev/nvmm/x86: nvmm_x86_svm.c Log Message: Fix definition for MWAIT. It should be bit 11, not 12; 12 is the armed version. To generate a diff of this commit: cvs rdiff -u -r1.47 -r1.48 src/sys/dev/nvmm/x86/nvmm_x86_svm.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/nvmm/x86
Module Name:src Committed By: maxv Date: Fri Oct 4 12:11:38 UTC 2019 Modified Files: src/sys/dev/nvmm/x86: nvmm_x86_svm.c Log Message: Add definitions for RDPRU, MCOMMIT, GMET and VTE. To generate a diff of this commit: cvs rdiff -u -r1.46 -r1.47 src/sys/dev/nvmm/x86/nvmm_x86_svm.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/nvmm/x86/nvmm_x86_svm.c diff -u src/sys/dev/nvmm/x86/nvmm_x86_svm.c:1.46 src/sys/dev/nvmm/x86/nvmm_x86_svm.c:1.47 --- src/sys/dev/nvmm/x86/nvmm_x86_svm.c:1.46 Sat May 11 07:31:56 2019 +++ src/sys/dev/nvmm/x86/nvmm_x86_svm.c Fri Oct 4 12:11:38 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: nvmm_x86_svm.c,v 1.46 2019/05/11 07:31:56 maxv Exp $ */ +/* $NetBSD: nvmm_x86_svm.c,v 1.47 2019/10/04 12:11:38 maxv Exp $ */ /* * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_svm.c,v 1.46 2019/05/11 07:31:56 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_svm.c,v 1.47 2019/10/04 12:11:38 maxv Exp $"); #include #include @@ -202,6 +202,7 @@ int svm_vmrun(paddr_t, uint64_t *); #define VMCB_EXITCODE_MWAIT 0x008B #define VMCB_EXITCODE_MWAIT_CONDITIONAL 0x008C #define VMCB_EXITCODE_XSETBV 0x008D +#define VMCB_EXITCODE_RDPRU 0x008E #define VMCB_EXITCODE_EFER_WRITE_TRAP 0x008F #define VMCB_EXITCODE_CR0_WRITE_TRAP 0x0090 #define VMCB_EXITCODE_CR1_WRITE_TRAP 0x0091 @@ -219,6 +220,7 @@ int svm_vmrun(paddr_t, uint64_t *); #define VMCB_EXITCODE_CR13_WRITE_TRAP 0x009D #define VMCB_EXITCODE_CR14_WRITE_TRAP 0x009E #define VMCB_EXITCODE_CR15_WRITE_TRAP 0x009F +#define VMCB_EXITCODE_MCOMMIT 0x00A3 #define VMCB_EXITCODE_NPF 0x0400 #define VMCB_EXITCODE_AVIC_INCOMP_IPI 0x0401 #define VMCB_EXITCODE_AVIC_NOACCEL 0x0402 @@ -287,10 +289,14 @@ struct vmcb_ctrl { #define VMCB_CTRL_INTERCEPT_MONITOR __BIT(10) #define VMCB_CTRL_INTERCEPT_MWAIT __BIT(12) #define VMCB_CTRL_INTERCEPT_XSETBV __BIT(13) +#define VMCB_CTRL_INTERCEPT_RDPRU __BIT(14) #define VMCB_CTRL_INTERCEPT_EFER_SPEC __BIT(15) #define VMCB_CTRL_INTERCEPT_WCR_SPEC(x) __BIT(16 + x) - uint8_t rsvd1[40]; + uint32_t intercept_misc3; +#define VMCB_CTRL_INTERCEPT_MCOMMIT __BIT(3) + + uint8_t rsvd1[36]; uint16_t pause_filt_thresh; uint16_t pause_filt_cnt; uint64_t iopm_base_pa; @@ -332,6 +338,8 @@ struct vmcb_ctrl { #define VMCB_CTRL_ENABLE_NP __BIT(0) #define VMCB_CTRL_ENABLE_SEV __BIT(1) #define VMCB_CTRL_ENABLE_ES_SEV __BIT(2) +#define VMCB_CTRL_ENABLE_GMET __BIT(3) +#define VMCB_CTRL_ENABLE_VTE __BIT(5) uint64_t avic; #define VMCB_CTRL_AVIC_APIC_BAR __BITS(51,0)
CVS commit: src/sys/dev/nvmm/x86
Module Name:src Committed By: maxv Date: Fri Oct 4 12:11:38 UTC 2019 Modified Files: src/sys/dev/nvmm/x86: nvmm_x86_svm.c Log Message: Add definitions for RDPRU, MCOMMIT, GMET and VTE. To generate a diff of this commit: cvs rdiff -u -r1.46 -r1.47 src/sys/dev/nvmm/x86/nvmm_x86_svm.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch
Module Name:src Committed By: maxv Date: Fri Oct 4 11:47:08 UTC 2019 Modified Files: src/sys/arch/amd64/amd64: locore.S src/sys/arch/i386/i386: locore.S src/sys/arch/x86/include: fpu.h src/sys/arch/x86/x86: fpu.c Log Message: Rename fpu_eagerswitch to fpu_switch, and add fpu_xstate_reload to simplify. To generate a diff of this commit: cvs rdiff -u -r1.187 -r1.188 src/sys/arch/amd64/amd64/locore.S cvs rdiff -u -r1.169 -r1.170 src/sys/arch/i386/i386/locore.S cvs rdiff -u -r1.17 -r1.18 src/sys/arch/x86/include/fpu.h cvs rdiff -u -r1.56 -r1.57 src/sys/arch/x86/x86/fpu.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/amd64/amd64/locore.S diff -u src/sys/arch/amd64/amd64/locore.S:1.187 src/sys/arch/amd64/amd64/locore.S:1.188 --- src/sys/arch/amd64/amd64/locore.S:1.187 Thu Oct 3 05:06:29 2019 +++ src/sys/arch/amd64/amd64/locore.S Fri Oct 4 11:47:07 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: locore.S,v 1.187 2019/10/03 05:06:29 maxv Exp $ */ +/* $NetBSD: locore.S,v 1.188 2019/10/04 11:47:07 maxv Exp $ */ /* * Copyright-o-rama! @@ -1150,7 +1150,7 @@ ENTRY(cpu_switchto) /* Switch the FPU. */ movq %r13,%rdi movq %r12,%rsi - callq _C_LABEL(fpu_eagerswitch) + callq _C_LABEL(fpu_switch) /* Don't bother with the rest if switching to a system process. */ testl $LW_SYSTEM,L_FLAG(%r12) Index: src/sys/arch/i386/i386/locore.S diff -u src/sys/arch/i386/i386/locore.S:1.169 src/sys/arch/i386/i386/locore.S:1.170 --- src/sys/arch/i386/i386/locore.S:1.169 Thu Oct 3 05:06:29 2019 +++ src/sys/arch/i386/i386/locore.S Fri Oct 4 11:47:07 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: locore.S,v 1.169 2019/10/03 05:06:29 maxv Exp $ */ +/* $NetBSD: locore.S,v 1.170 2019/10/04 11:47:07 maxv Exp $ */ /* * Copyright-o-rama! @@ -128,7 +128,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.169 2019/10/03 05:06:29 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.170 2019/10/04 11:47:07 maxv Exp $"); #include "opt_copy_symtab.h" #include "opt_ddb.h" @@ -1141,7 +1141,7 @@ skip_save: pushl %edx pushl %edi pushl %esi - call _C_LABEL(fpu_eagerswitch) + call _C_LABEL(fpu_switch) addl $8,%esp popl %edx Index: src/sys/arch/x86/include/fpu.h diff -u src/sys/arch/x86/include/fpu.h:1.17 src/sys/arch/x86/include/fpu.h:1.18 --- src/sys/arch/x86/include/fpu.h:1.17 Wed Jun 26 12:30:13 2019 +++ src/sys/arch/x86/include/fpu.h Fri Oct 4 11:47:08 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: fpu.h,v 1.17 2019/06/26 12:30:13 mgorny Exp $ */ +/* $NetBSD: fpu.h,v 1.18 2019/10/04 11:47:08 maxv Exp $ */ #ifndef _X86_FPU_H_ #define _X86_FPU_H_ @@ -20,8 +20,6 @@ void fpu_area_restore(void *, uint64_t); void fpusave_lwp(struct lwp *, bool); void fpusave_cpu(bool); -void fpu_eagerswitch(struct lwp *, struct lwp *); - void fpu_set_default_cw(struct lwp *, unsigned int); void fputrap(struct trapframe *); Index: src/sys/arch/x86/x86/fpu.c diff -u src/sys/arch/x86/x86/fpu.c:1.56 src/sys/arch/x86/x86/fpu.c:1.57 --- src/sys/arch/x86/x86/fpu.c:1.56 Thu Oct 3 05:06:29 2019 +++ src/sys/arch/x86/x86/fpu.c Fri Oct 4 11:47:08 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: fpu.c,v 1.56 2019/10/03 05:06:29 maxv Exp $ */ +/* $NetBSD: fpu.c,v 1.57 2019/10/04 11:47:08 maxv Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. All @@ -96,7 +96,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.56 2019/10/03 05:06:29 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.57 2019/10/04 11:47:08 maxv Exp $"); #include "opt_multiprocessor.h" @@ -267,8 +267,10 @@ fpu_lwp_install(struct lwp *l) fpu_area_restore(>pcb_savefpu, x86_xsave_features); } +void fpu_switch(struct lwp *, struct lwp *); + void -fpu_eagerswitch(struct lwp *oldlwp, struct lwp *newlwp) +fpu_switch(struct lwp *oldlwp, struct lwp *newlwp) { int s; @@ -536,6 +538,17 @@ fpusave_lwp(struct lwp *l, bool save) } } +static inline void +fpu_xstate_reload(union savefpu *fpu_save, uint64_t xstate) +{ + /* + * Force a reload of the given xstate during the next XRSTOR. + */ + if (x86_fpu_save >= FPU_SAVE_XSAVE) { + fpu_save->sv_xsave_hdr.xsh_xstate_bv |= xstate; + } +} + void fpu_set_default_cw(struct lwp *l, unsigned int x87_cw) { @@ -544,13 +557,8 @@ fpu_set_default_cw(struct lwp *l, unsign if (i386_use_fxsave) { fpu_save->sv_xmm.fx_cw = x87_cw; - - /* Force a reload of CW */ - if ((x87_cw != __INITIAL_NPXCW__) && - (x86_fpu_save == FPU_SAVE_XSAVE || - x86_fpu_save == FPU_SAVE_XSAVEOPT)) { - fpu_save->sv_xsave_hdr.xsh_xstate_bv |= - XCR0_X87; + if (x87_cw != __INITIAL_NPXCW__) { + fpu_xstate_reload(fpu_save, XCR0_X87); } } else { fpu_save->sv_87.s87_cw = x87_cw; @@ -594,14 +602,8 @@ fpu_clear(struct lwp *l, unsigned int x8 fpu_save->sv_xmm.fx_mxcsr = __INITIAL_MXCSR__; fpu_save->sv_xmm.fx_mxcsr_mask = x86_fpu_mxcsr_mask; fpu_save->sv_xmm.fx_cw = x87_cw;
CVS commit: src/sys/arch
Module Name:src Committed By: maxv Date: Fri Oct 4 11:47:08 UTC 2019 Modified Files: src/sys/arch/amd64/amd64: locore.S src/sys/arch/i386/i386: locore.S src/sys/arch/x86/include: fpu.h src/sys/arch/x86/x86: fpu.c Log Message: Rename fpu_eagerswitch to fpu_switch, and add fpu_xstate_reload to simplify. To generate a diff of this commit: cvs rdiff -u -r1.187 -r1.188 src/sys/arch/amd64/amd64/locore.S cvs rdiff -u -r1.169 -r1.170 src/sys/arch/i386/i386/locore.S cvs rdiff -u -r1.17 -r1.18 src/sys/arch/x86/include/fpu.h cvs rdiff -u -r1.56 -r1.57 src/sys/arch/x86/x86/fpu.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys
Module Name:src Committed By: maxv Date: Fri Oct 4 06:27:42 UTC 2019 Modified Files: src/sys/arch/amd64/include: types.h src/sys/arch/x86/include: bus_defs.h src/sys/arch/x86/x86: bus_dma.c src/sys/kern: subr_asan.c src/sys/sys: asan.h Log Message: Add DMA instrumentation in KASAN. We note the original buffer and length in the map, and check the buffer on each bus_dmamap_sync. This allows us to find DMA buffer overflows and UAFs, which couldn't be found before because the device accesses to memory are outside of KASAN's control. To generate a diff of this commit: cvs rdiff -u -r1.62 -r1.63 src/sys/arch/amd64/include/types.h cvs rdiff -u -r1.3 -r1.4 src/sys/arch/x86/include/bus_defs.h cvs rdiff -u -r1.79 -r1.80 src/sys/arch/x86/x86/bus_dma.c cvs rdiff -u -r1.14 -r1.15 src/sys/kern/subr_asan.c cvs rdiff -u -r1.10 -r1.11 src/sys/sys/asan.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/amd64/include/types.h diff -u src/sys/arch/amd64/include/types.h:1.62 src/sys/arch/amd64/include/types.h:1.63 --- src/sys/arch/amd64/include/types.h:1.62 Mon Sep 23 23:06:26 2019 +++ src/sys/arch/amd64/include/types.h Fri Oct 4 06:27:42 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: types.h,v 1.62 2019/09/23 23:06:26 kamil Exp $ */ +/* $NetBSD: types.h,v 1.63 2019/10/04 06:27:42 maxv Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. @@ -108,6 +108,7 @@ typedef unsigned char __cpu_simple_lock #include "opt_kasan.h" #ifdef KASAN #define __HAVE_KASAN_INSTR_BUS +#define __HAVE_KASAN_INSTR_DMA #endif #if defined(__x86_64__) && !defined(XENPV) #if !defined(KASAN) Index: src/sys/arch/x86/include/bus_defs.h diff -u src/sys/arch/x86/include/bus_defs.h:1.3 src/sys/arch/x86/include/bus_defs.h:1.4 --- src/sys/arch/x86/include/bus_defs.h:1.3 Mon Sep 23 16:17:58 2019 +++ src/sys/arch/x86/include/bus_defs.h Fri Oct 4 06:27:42 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: bus_defs.h,v 1.3 2019/09/23 16:17:58 skrll Exp $ */ +/* $NetBSD: bus_defs.h,v 1.4 2019/10/04 06:27:42 maxv Exp $ */ /*- * Copyright (c) 1996, 1997, 1998, 2001 The NetBSD Foundation, Inc. @@ -64,6 +64,10 @@ #ifndef _X86_BUS_H_ #define _X86_BUS_H_ +#ifdef _KERNEL_OPT +#include "opt_kasan.h" +#endif + #include #ifdef BUS_SPACE_DEBUG @@ -141,6 +145,11 @@ struct x86_bus_dmamap { /* * PUBLIC MEMBERS: these are used by machine-independent code. */ +#if defined(KASAN) + void *dm_buf; + bus_size_t dm_buflen; + int dm_buftype; +#endif bus_size_t dm_maxsegsz; /* largest possible segment */ bus_size_t dm_mapsize; /* size of the mapping */ int dm_nsegs; /* # valid segments in mapping */ Index: src/sys/arch/x86/x86/bus_dma.c diff -u src/sys/arch/x86/x86/bus_dma.c:1.79 src/sys/arch/x86/x86/bus_dma.c:1.80 --- src/sys/arch/x86/x86/bus_dma.c:1.79 Fri Jun 14 03:35:31 2019 +++ src/sys/arch/x86/x86/bus_dma.c Fri Oct 4 06:27:42 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: bus_dma.c,v 1.79 2019/06/14 03:35:31 mrg Exp $ */ +/* $NetBSD: bus_dma.c,v 1.80 2019/10/04 06:27:42 maxv Exp $ */ /*- * Copyright (c) 1996, 1997, 1998, 2007 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.79 2019/06/14 03:35:31 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.80 2019/10/04 06:27:42 maxv Exp $"); /* * The following is included because _bus_dma_uiomove is derived from @@ -95,6 +95,7 @@ __KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v #include #include #include +#include #include #include @@ -1327,6 +1328,8 @@ bus_dmamap_sync(bus_dma_tag_t t, bus_dma { bus_dma_tag_t it; + kasan_dma_sync(p, o, l, ops); + if ((t->bdt_exists & BUS_DMAMAP_OVERRIDE_SYNC) == 0) ; /* skip override */ else for (it = t; it != NULL; it = it->bdt_super) { @@ -1386,6 +1389,8 @@ bus_dmamap_load(bus_dma_tag_t t, bus_dma { bus_dma_tag_t it; + kasan_dma_load(dmam, buf, buflen, KASAN_DMA_LINEAR); + if ((t->bdt_exists & BUS_DMAMAP_OVERRIDE_LOAD) == 0) ; /* skip override */ else for (it = t; it != NULL; it = it->bdt_super) { @@ -1404,6 +1409,8 @@ bus_dmamap_load_mbuf(bus_dma_tag_t t, bu { bus_dma_tag_t it; + kasan_dma_load(dmam, chain, 0, KASAN_DMA_MBUF); + if ((t->bdt_exists & BUS_DMAMAP_OVERRIDE_LOAD_MBUF) == 0) ; /* skip override */ else for (it = t; it != NULL; it = it->bdt_super) { @@ -1422,6 +1429,8 @@ bus_dmamap_load_uio(bus_dma_tag_t t, bus { bus_dma_tag_t it; + kasan_dma_load(dmam, uio, 0, KASAN_DMA_UIO); + if ((t->bdt_exists & BUS_DMAMAP_OVERRIDE_LOAD_UIO) == 0) ; /* skip override */ else for (it = t; it != NULL; it = it->bdt_super) { @@ -1441,6 +1450,8 @@ bus_dmamap_load_raw(bus_dma_tag_t t, bus { bus_dma_tag_t it; + kasan_dma_load(dmam, NULL, 0, KASAN_DMA_RAW); + if ((t->bdt_exists & BUS_DMAMAP_OVERRIDE_LOAD_RAW) == 0) ; /* skip override */ else for (it = t; it != NULL; it = it->bdt_super) {
CVS commit: src/sys
Module Name:src Committed By: maxv Date: Fri Oct 4 06:27:42 UTC 2019 Modified Files: src/sys/arch/amd64/include: types.h src/sys/arch/x86/include: bus_defs.h src/sys/arch/x86/x86: bus_dma.c src/sys/kern: subr_asan.c src/sys/sys: asan.h Log Message: Add DMA instrumentation in KASAN. We note the original buffer and length in the map, and check the buffer on each bus_dmamap_sync. This allows us to find DMA buffer overflows and UAFs, which couldn't be found before because the device accesses to memory are outside of KASAN's control. To generate a diff of this commit: cvs rdiff -u -r1.62 -r1.63 src/sys/arch/amd64/include/types.h cvs rdiff -u -r1.3 -r1.4 src/sys/arch/x86/include/bus_defs.h cvs rdiff -u -r1.79 -r1.80 src/sys/arch/x86/x86/bus_dma.c cvs rdiff -u -r1.14 -r1.15 src/sys/kern/subr_asan.c cvs rdiff -u -r1.10 -r1.11 src/sys/sys/asan.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/usb
Module Name:src Committed By: maxv Date: Thu Oct 3 05:20:31 UTC 2019 Modified Files: src/sys/dev/usb: usb_subr.c Log Message: Fix memory leaks. Was wondering where memory had gone after several hours of attach/detach with vHCI. To generate a diff of this commit: cvs rdiff -u -r1.240 -r1.241 src/sys/dev/usb/usb_subr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/usb
Module Name:src Committed By: maxv Date: Thu Oct 3 05:20:31 UTC 2019 Modified Files: src/sys/dev/usb: usb_subr.c Log Message: Fix memory leaks. Was wondering where memory had gone after several hours of attach/detach with vHCI. To generate a diff of this commit: cvs rdiff -u -r1.240 -r1.241 src/sys/dev/usb/usb_subr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/usb_subr.c diff -u src/sys/dev/usb/usb_subr.c:1.240 src/sys/dev/usb/usb_subr.c:1.241 --- src/sys/dev/usb/usb_subr.c:1.240 Sun Sep 15 09:24:38 2019 +++ src/sys/dev/usb/usb_subr.c Thu Oct 3 05:20:31 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: usb_subr.c,v 1.240 2019/09/15 09:24:38 maxv Exp $ */ +/* $NetBSD: usb_subr.c,v 1.241 2019/10/03 05:20:31 maxv Exp $ */ /* $FreeBSD: src/sys/dev/usb/usb_subr.c,v 1.18 1999/11/17 22:33:47 n_hibma Exp $ */ /* @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.240 2019/09/15 09:24:38 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.241 2019/10/03 05:20:31 maxv Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -1479,6 +1479,15 @@ usbd_remove_device(struct usbd_device *d up->up_dev = NULL; dev->ud_bus->ub_devices[usb_addr2dindex(dev->ud_addr)] = NULL; + if (dev->ud_vendor != NULL) { + kmem_free(dev->ud_vendor, USB_MAX_ENCODED_STRING_LEN); + } + if (dev->ud_product != NULL) { + kmem_free(dev->ud_product, USB_MAX_ENCODED_STRING_LEN); + } + if (dev->ud_serial != NULL) { + kmem_free(dev->ud_serial, USB_MAX_ENCODED_STRING_LEN); + } kmem_free(dev, sizeof(*dev)); }
CVS commit: src/sys/dev/usb
Module Name:src Committed By: maxv Date: Thu Oct 3 05:16:16 UTC 2019 Modified Files: src/sys/dev/usb: umidi.c Log Message: More less kmem_zalloc(0). To generate a diff of this commit: cvs rdiff -u -r1.79 -r1.80 src/sys/dev/usb/umidi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/usb
Module Name:src Committed By: maxv Date: Thu Oct 3 05:16:16 UTC 2019 Modified Files: src/sys/dev/usb: umidi.c Log Message: More less kmem_zalloc(0). To generate a diff of this commit: cvs rdiff -u -r1.79 -r1.80 src/sys/dev/usb/umidi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/umidi.c diff -u src/sys/dev/usb/umidi.c:1.79 src/sys/dev/usb/umidi.c:1.80 --- src/sys/dev/usb/umidi.c:1.79 Sun Sep 15 09:18:17 2019 +++ src/sys/dev/usb/umidi.c Thu Oct 3 05:16:16 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: umidi.c,v 1.79 2019/09/15 09:18:17 maxv Exp $ */ +/* $NetBSD: umidi.c,v 1.80 2019/10/03 05:16:16 maxv Exp $ */ /* * Copyright (c) 2001, 2012, 2014 The NetBSD Foundation, Inc. @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: umidi.c,v 1.79 2019/09/15 09:18:17 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: umidi.c,v 1.80 2019/10/03 05:16:16 maxv Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -1081,9 +1081,10 @@ alloc_all_jacks(struct umidi_softc *sc) cn_spec = NULL; /* allocate/initialize structures */ - sc->sc_jacks = - kmem_zalloc(sizeof(*sc->sc_out_jacks)*(sc->sc_in_num_jacks - + sc->sc_out_num_jacks), KM_SLEEP); + if (sc->sc_in_num_jacks == 0 && sc->sc_out_num_jacks == 0) + return USBD_INVAL; + sc->sc_jacks = kmem_zalloc(sizeof(*sc->sc_out_jacks) * + (sc->sc_in_num_jacks + sc->sc_out_num_jacks), KM_SLEEP); if (!sc->sc_jacks) return USBD_NOMEM; sc->sc_out_jacks = @@ -1154,8 +1155,8 @@ free_all_jacks(struct umidi_softc *sc) mutex_enter(>sc_lock); jacks = sc->sc_jacks; - len = sizeof(*sc->sc_out_jacks) - * (sc->sc_in_num_jacks + sc->sc_out_num_jacks); + len = sizeof(*sc->sc_out_jacks) * + (sc->sc_in_num_jacks + sc->sc_out_num_jacks); sc->sc_jacks = sc->sc_in_jacks = sc->sc_out_jacks = NULL; mutex_exit(>sc_lock);
CVS commit: src/sys/dev/usb
Module Name:src Committed By: maxv Date: Thu Oct 3 05:13:24 UTC 2019 Modified Files: src/sys/dev/usb: vhci.c Log Message: Improvements: - Don't process packets if the USB device is detached. Contrary to the other HCIs, vHCI has no timeout, so we never collect the pending packets, and must drop them synchronously. - Fix refcounting bug in vhci_device_ctrl_abort. - Implement vhci_activate. - Add a few KASSERTs. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/dev/usb/vhci.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch
Module Name:src Committed By: maxv Date: Thu Oct 3 05:06:29 UTC 2019 Modified Files: src/sys/arch/amd64/amd64: locore.S src/sys/arch/i386/i386: locore.S src/sys/arch/x86/include: cpu.h src/sys/arch/x86/x86: fpu.c identcpu.c x86_machdep.c Log Message: Remove the LazyFPU code, as posted 5 months ago on port-amd64@. To generate a diff of this commit: cvs rdiff -u -r1.186 -r1.187 src/sys/arch/amd64/amd64/locore.S cvs rdiff -u -r1.168 -r1.169 src/sys/arch/i386/i386/locore.S cvs rdiff -u -r1.108 -r1.109 src/sys/arch/x86/include/cpu.h cvs rdiff -u -r1.55 -r1.56 src/sys/arch/x86/x86/fpu.c cvs rdiff -u -r1.95 -r1.96 src/sys/arch/x86/x86/identcpu.c cvs rdiff -u -r1.127 -r1.128 src/sys/arch/x86/x86/x86_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/amd64/amd64/locore.S diff -u src/sys/arch/amd64/amd64/locore.S:1.186 src/sys/arch/amd64/amd64/locore.S:1.187 --- src/sys/arch/amd64/amd64/locore.S:1.186 Wed Aug 21 16:35:10 2019 +++ src/sys/arch/amd64/amd64/locore.S Thu Oct 3 05:06:29 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: locore.S,v 1.186 2019/08/21 16:35:10 maxv Exp $ */ +/* $NetBSD: locore.S,v 1.187 2019/10/03 05:06:29 maxv Exp $ */ /* * Copyright-o-rama! @@ -1147,13 +1147,10 @@ ENTRY(cpu_switchto) movq %r12,%rsi callq _C_LABEL(x86_dbregs_switch) - movb _C_LABEL(x86_fpu_eager),%dl - testb %dl,%dl - jz .Lno_eagerfpu + /* Switch the FPU. */ movq %r13,%rdi movq %r12,%rsi callq _C_LABEL(fpu_eagerswitch) -.Lno_eagerfpu: /* Don't bother with the rest if switching to a system process. */ testl $LW_SYSTEM,L_FLAG(%r12) Index: src/sys/arch/i386/i386/locore.S diff -u src/sys/arch/i386/i386/locore.S:1.168 src/sys/arch/i386/i386/locore.S:1.169 --- src/sys/arch/i386/i386/locore.S:1.168 Sun May 19 08:17:02 2019 +++ src/sys/arch/i386/i386/locore.S Thu Oct 3 05:06:29 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: locore.S,v 1.168 2019/05/19 08:17:02 maxv Exp $ */ +/* $NetBSD: locore.S,v 1.169 2019/10/03 05:06:29 maxv Exp $ */ /* * Copyright-o-rama! @@ -128,7 +128,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.168 2019/05/19 08:17:02 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.169 2019/10/03 05:06:29 maxv Exp $"); #include "opt_copy_symtab.h" #include "opt_ddb.h" @@ -1137,15 +1137,12 @@ skip_save: call _C_LABEL(x86_dbregs_switch) addl $8,%esp + /* Switch the FPU. */ pushl %edx - movb _C_LABEL(x86_fpu_eager),%dl - testb %dl,%dl - jz .Lno_eagerfpu pushl %edi pushl %esi call _C_LABEL(fpu_eagerswitch) addl $8,%esp -.Lno_eagerfpu: popl %edx /* Don't bother with the rest if switching to a system process. */ Index: src/sys/arch/x86/include/cpu.h diff -u src/sys/arch/x86/include/cpu.h:1.108 src/sys/arch/x86/include/cpu.h:1.109 --- src/sys/arch/x86/include/cpu.h:1.108 Wed Aug 7 06:23:48 2019 +++ src/sys/arch/x86/include/cpu.h Thu Oct 3 05:06:29 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.h,v 1.108 2019/08/07 06:23:48 maxv Exp $ */ +/* $NetBSD: cpu.h,v 1.109 2019/10/03 05:06:29 maxv Exp $ */ /* * Copyright (c) 1990 The Regents of the University of California. @@ -462,7 +462,6 @@ extern uint64_t x86_xsave_features; extern size_t x86_xsave_offsets[]; extern size_t x86_xsave_sizes[]; extern uint32_t x86_fpu_mxcsr_mask; -extern bool x86_fpu_eager; extern void (*x86_cpu_idle)(void); #define cpu_idle() (*x86_cpu_idle)() Index: src/sys/arch/x86/x86/fpu.c diff -u src/sys/arch/x86/x86/fpu.c:1.55 src/sys/arch/x86/x86/fpu.c:1.56 --- src/sys/arch/x86/x86/fpu.c:1.55 Fri Jul 5 17:08:56 2019 +++ src/sys/arch/x86/x86/fpu.c Thu Oct 3 05:06:29 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: fpu.c,v 1.55 2019/07/05 17:08:56 maxv Exp $ */ +/* $NetBSD: fpu.c,v 1.56 2019/10/03 05:06:29 maxv Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. All @@ -96,7 +96,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.55 2019/07/05 17:08:56 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.56 2019/10/03 05:06:29 maxv Exp $"); #include "opt_multiprocessor.h" @@ -127,7 +127,6 @@ __KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.55 #endif uint32_t x86_fpu_mxcsr_mask __read_mostly = 0; -bool x86_fpu_eager __read_mostly = false; static inline union savefpu * lwp_fpuarea(struct lwp *l) @@ -440,20 +439,13 @@ fputrap(struct trapframe *frame) } /* - * Implement device not available (DNA) exception. - * - * If we were the last lwp to use the FPU, we can simply return. - * Otherwise, we save the previous state, if necessary, and restore - * our last saved state. - * - * Called directly from the trap 0x13 entry with interrupts still disabled. + * Implement device not available (DNA) exception. Called with interrupts still + * disabled. */ void fpudna(struct trapframe *frame) { struct cpu_info *ci = curcpu(); - struct lwp *l, *fl; - struct pcb *pcb; int s; if (!USERMODE(frame->tf_cs)) { @@ -461,55 +453,9 @@
CVS commit: src/sys/arch
Module Name:src Committed By: maxv Date: Thu Oct 3 05:06:29 UTC 2019 Modified Files: src/sys/arch/amd64/amd64: locore.S src/sys/arch/i386/i386: locore.S src/sys/arch/x86/include: cpu.h src/sys/arch/x86/x86: fpu.c identcpu.c x86_machdep.c Log Message: Remove the LazyFPU code, as posted 5 months ago on port-amd64@. To generate a diff of this commit: cvs rdiff -u -r1.186 -r1.187 src/sys/arch/amd64/amd64/locore.S cvs rdiff -u -r1.168 -r1.169 src/sys/arch/i386/i386/locore.S cvs rdiff -u -r1.108 -r1.109 src/sys/arch/x86/include/cpu.h cvs rdiff -u -r1.55 -r1.56 src/sys/arch/x86/x86/fpu.c cvs rdiff -u -r1.95 -r1.96 src/sys/arch/x86/x86/identcpu.c cvs rdiff -u -r1.127 -r1.128 src/sys/arch/x86/x86/x86_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/ic
Module Name:src Committed By: maxv Date: Mon Sep 23 17:37:04 UTC 2019 Modified Files: src/sys/dev/ic: an.c Log Message: Move the timeout check out of the loop, otherwise it is never reached. Found by the lgtm bot. To generate a diff of this commit: cvs rdiff -u -r1.71 -r1.72 src/sys/dev/ic/an.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.