From 8192ba83909d7ba1e3678b60d665d2aed110e2d6 Mon Sep 17 00:00:00 2001 From: jhb Date: Fri, 9 Sep 2016 19:57:32 +0000 Subject: [PATCH 1/2] MFC 304637: Fix build for !SMP kernels after the Xen MSIX workaround. Move msix_disable_migration under #ifdef SMP since it doesn't make sense for !SMP kernels. PR: 212014 --- sys/amd64/include/intr_machdep.h | 3 ++- sys/i386/include/intr_machdep.h | 3 ++- sys/x86/x86/msi.c | 6 ++++++ sys/x86/xen/hvm.c | 2 ++ 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/sys/amd64/include/intr_machdep.h b/sys/amd64/include/intr_machdep.h index 636757054b25..e7320e6e3a69 100644 --- a/sys/amd64/include/intr_machdep.h +++ b/sys/amd64/include/intr_machdep.h @@ -148,8 +148,9 @@ extern cpuset_t intr_cpus; #endif extern struct mtx icu_lock; extern int elcr_found; - +#ifdef SMP extern int msix_disable_migration; +#endif #ifndef DEV_ATPIC void atpic_reset(void); diff --git a/sys/i386/include/intr_machdep.h b/sys/i386/include/intr_machdep.h index 629f137e84ba..a8dd45642f94 100644 --- a/sys/i386/include/intr_machdep.h +++ b/sys/i386/include/intr_machdep.h @@ -139,8 +139,9 @@ extern cpuset_t intr_cpus; #endif extern struct mtx icu_lock; extern int elcr_found; - +#ifdef SMP extern int msix_disable_migration; +#endif #ifndef DEV_ATPIC void atpic_reset(void); diff --git a/sys/x86/x86/msi.c b/sys/x86/x86/msi.c index 324ac6c023d5..51115c04a4a3 100644 --- a/sys/x86/x86/msi.c +++ b/sys/x86/x86/msi.c @@ -149,6 +149,7 @@ struct pic msi_pic = { .pic_reprogram_pin = NULL, }; +#ifdef SMP /** * Xen hypervisors prior to 4.6.0 do not properly handle updates to * enabled MSI-X table entries. Allow migration of MSI-X interrupts @@ -162,6 +163,7 @@ int msix_disable_migration = -1; SYSCTL_INT(_machdep, OID_AUTO, disable_msix_migration, CTLFLAG_RDTUN, &msix_disable_migration, 0, "Disable migration of MSI-X interrupts between CPUs"); +#endif static int msi_enabled; static int msi_last_irq; @@ -241,8 +243,10 @@ msi_assign_cpu(struct intsrc *isrc, u_int apic_id) if (msi->msi_first != msi) return (EINVAL); +#ifdef SMP if (msix_disable_migration && msi->msi_msix) return (EINVAL); +#endif /* Store information to free existing irq. */ old_vector = msi->msi_vector; @@ -316,10 +320,12 @@ msi_init(void) return; } +#ifdef SMP if (msix_disable_migration == -1) { /* The default is to allow migration of MSI-X interrupts. */ msix_disable_migration = 0; } +#endif msi_enabled = 1; intr_register_pic(&msi_pic); diff --git a/sys/x86/xen/hvm.c b/sys/x86/xen/hvm.c index 3569cd084e7e..e10659e64ad1 100644 --- a/sys/x86/xen/hvm.c +++ b/sys/x86/xen/hvm.c @@ -143,6 +143,7 @@ xen_hvm_init_hypercall_stubs(enum xen_hvm_init_type init_type) printf("XEN: Hypervisor version %d.%d detected.\n", major, minor); +#ifdef SMP if (((major < 4) || (major == 4 && minor <= 5)) && msix_disable_migration == -1) { /* @@ -157,6 +158,7 @@ xen_hvm_init_hypercall_stubs(enum xen_hvm_init_type init_type) "Set machdep.msix_disable_migration=0 to forcefully enable it.\n"); msix_disable_migration = 1; } +#endif } /* From 118b08f60f0e07d0164ba036c65c9d0f115c9d96 Mon Sep 17 00:00:00 2001 From: jhb Date: Fri, 9 Sep 2016 20:30:36 +0000 Subject: [PATCH 2/2] MFC 303713: Correct assertion on vcpuid argument to vm_gpa_hold(). PR: 208168 --- sys/amd64/vmm/vmm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/amd64/vmm/vmm.c b/sys/amd64/vmm/vmm.c index cb04f3cb8511..ebd63601e5c1 100644 --- a/sys/amd64/vmm/vmm.c +++ b/sys/amd64/vmm/vmm.c @@ -914,7 +914,7 @@ vm_gpa_hold(struct vm *vm, int vcpuid, vm_paddr_t gpa, size_t len, int reqprot, * guaranteed if at least one vcpu is in the VCPU_FROZEN state. */ int state; - KASSERT(vcpuid >= -1 || vcpuid < VM_MAXCPU, ("%s: invalid vcpuid %d", + KASSERT(vcpuid >= -1 && vcpuid < VM_MAXCPU, ("%s: invalid vcpuid %d", __func__, vcpuid)); for (i = 0; i < VM_MAXCPU; i++) { if (vcpuid != -1 && vcpuid != i)