Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-9]: src/sys/dev/nvmm/x86 Pull up following revision(s) (requested...



details:   https://anonhg.NetBSD.org/src/rev/08db526be8b5
branches:  netbsd-9
changeset: 936830:08db526be8b5
user:      martin <martin%NetBSD.org@localhost>
date:      Wed Aug 05 15:18:24 2020 +0000

description:
Pull up following revision(s) (requested by maxv in ticket #1041):

        sys/dev/nvmm/x86/nvmm_x86_vmx.c: revision 1.66
        sys/dev/nvmm/x86/nvmm_x86_vmx.c: revision 1.50
        sys/dev/nvmm/x86/nvmm_x86_svm.c: revision 1.66
        sys/dev/nvmm/x86/nvmm_x86_vmx.c: revision 1.46
        sys/dev/nvmm/x86/nvmm_x86_vmx.c: revision 1.49
        sys/dev/nvmm/x86/nvmm_x86_svm.c: revision 1.55
        sys/dev/nvmm/x86/nvmm_x86_svm.c: revision 1.56

pg->phys_addr > VM_PAGE_TO_PHYS(pg)

Explicitly cast pointers to uintptr_t before casting to enums. They are
not necessarily the same size. Don't cast pointers to bool, check for
NULL instead.

vmx_vmptrst(): only used when DIAGNOSTIC

Simplify, remove unnecessary #ifdef DIAGNOSTIC around KASSERTs.

Use ULL, to make it clear we are unsigned.

diffstat:

 sys/dev/nvmm/x86/nvmm_x86_svm.c |  10 +++++-----
 sys/dev/nvmm/x86/nvmm_x86_vmx.c |  20 +++++++-------------
 2 files changed, 12 insertions(+), 18 deletions(-)

diffs (134 lines):

diff -r 555403a0399e -r 08db526be8b5 sys/dev/nvmm/x86/nvmm_x86_svm.c
--- a/sys/dev/nvmm/x86/nvmm_x86_svm.c   Wed Aug 05 15:14:18 2020 +0000
+++ b/sys/dev/nvmm/x86/nvmm_x86_svm.c   Wed Aug 05 15:18:24 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nvmm_x86_svm.c,v 1.46.4.6 2020/08/02 08:49:08 martin Exp $     */
+/*     $NetBSD: nvmm_x86_svm.c,v 1.46.4.7 2020/08/05 15:18:24 martin Exp $     */
 
 /*
  * Copyright (c) 2018-2019 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_svm.c,v 1.46.4.6 2020/08/02 08:49:08 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_svm.c,v 1.46.4.7 2020/08/05 15:18:24 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -225,7 +225,7 @@
 #define VMCB_EXITCODE_AVIC_INCOMP_IPI  0x0401
 #define VMCB_EXITCODE_AVIC_NOACCEL     0x0402
 #define VMCB_EXITCODE_VMGEXIT          0x0403
-#define VMCB_EXITCODE_INVALID          -1
+#define VMCB_EXITCODE_INVALID          -1ULL
 
 /* -------------------------------------------------------------------------- */
 
@@ -1507,7 +1507,7 @@
            &pglist, 1, 0);
        if (ret != 0)
                return ENOMEM;
-       _pa = TAILQ_FIRST(&pglist)->phys_addr;
+       _pa = VM_PAGE_TO_PHYS(TAILQ_FIRST(&pglist));
        _va = uvm_km_alloc(kernel_map, npages * PAGE_SIZE, 0,
            UVM_KMF_VAONLY | UVM_KMF_NOWAIT);
        if (_va == 0)
@@ -2337,7 +2337,7 @@
 static void
 svm_change_cpu(void *arg1, void *arg2)
 {
-       bool enable = (bool)arg1;
+       bool enable = arg1 != NULL;
        uint64_t msr;
 
        msr = rdmsr(MSR_VMCR);
diff -r 555403a0399e -r 08db526be8b5 sys/dev/nvmm/x86/nvmm_x86_vmx.c
--- a/sys/dev/nvmm/x86/nvmm_x86_vmx.c   Wed Aug 05 15:14:18 2020 +0000
+++ b/sys/dev/nvmm/x86/nvmm_x86_vmx.c   Wed Aug 05 15:18:24 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nvmm_x86_vmx.c,v 1.36.2.8 2020/08/02 08:49:08 martin Exp $     */
+/*     $NetBSD: nvmm_x86_vmx.c,v 1.36.2.9 2020/08/05 15:18:24 martin Exp $     */
 
 /*
  * Copyright (c) 2018-2019 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_vmx.c,v 1.36.2.8 2020/08/02 08:49:08 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_vmx.c,v 1.36.2.9 2020/08/05 15:18:24 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -135,6 +135,7 @@
        );
 }
 
+#ifdef DIAGNOSTIC
 static inline paddr_t
 vmx_vmptrst(void)
 {
@@ -149,6 +150,7 @@
 
        return pa;
 }
+#endif
 
 static inline void
 vmx_vmptrld(paddr_t *pa)
@@ -871,15 +873,11 @@
 {
        struct vmx_cpudata *cpudata = vcpu->cpudata;
        struct cpu_info *vmcs_ci;
-       paddr_t oldpa __diagused;
 
        cpudata->vmcs_refcnt++;
        if (cpudata->vmcs_refcnt > 1) {
-#ifdef DIAGNOSTIC
                KASSERT(kpreempt_disabled());
-               oldpa = vmx_vmptrst();
-               KASSERT(oldpa == cpudata->vmcs_pa);
-#endif
+               KASSERT(vmx_vmptrst() == cpudata->vmcs_pa);
                return;
        }
 
@@ -909,9 +907,7 @@
        struct vmx_cpudata *cpudata = vcpu->cpudata;
 
        KASSERT(kpreempt_disabled());
-#ifdef DIAGNOSTIC
        KASSERT(vmx_vmptrst() == cpudata->vmcs_pa);
-#endif
        KASSERT(cpudata->vmcs_refcnt > 0);
        cpudata->vmcs_refcnt--;
 
@@ -929,9 +925,7 @@
        struct vmx_cpudata *cpudata = vcpu->cpudata;
 
        KASSERT(kpreempt_disabled());
-#ifdef DIAGNOSTIC
        KASSERT(vmx_vmptrst() == cpudata->vmcs_pa);
-#endif
        KASSERT(cpudata->vmcs_refcnt == 1);
        cpudata->vmcs_refcnt--;
 
@@ -2230,7 +2224,7 @@
            &pglist, 1, 0);
        if (ret != 0)
                return ENOMEM;
-       _pa = TAILQ_FIRST(&pglist)->phys_addr;
+       _pa = VM_PAGE_TO_PHYS(TAILQ_FIRST(&pglist));
        _va = uvm_km_alloc(kernel_map, npages * PAGE_SIZE, 0,
            UVM_KMF_VAONLY | UVM_KMF_NOWAIT);
        if (_va == 0)
@@ -3248,7 +3242,7 @@
 vmx_change_cpu(void *arg1, void *arg2)
 {
        struct cpu_info *ci = curcpu();
-       bool enable = (bool)arg1;
+       bool enable = arg1 != NULL;
        uint64_t cr4;
 
        if (!enable) {



Home | Main Index | Thread Index | Old Index