Commit 0d33cd0a authored by Linus Torvalds's avatar Linus Torvalds

Merge git://git.kernel.org/pub/scm/virt/kvm/kvm

Pull kvm fixes from Marcelo Tosatti:
 "Fix for higher-order page allocation failures, fix Xen-on-KVM with
  x2apic, L1 crash with unrestricted guest mode (nested VMX)"

* git://git.kernel.org/pub/scm/virt/kvm/kvm:
  kvm: avoid page allocation failure in kvm_set_memory_region()
  KVM: x86: call irq notifiers with directed EOI
  KVM: nVMX: mask unrestricted_guest if disabled on L0
parents 1401b7c3 74496134
...@@ -422,6 +422,7 @@ static void __kvm_ioapic_update_eoi(struct kvm_vcpu *vcpu, ...@@ -422,6 +422,7 @@ static void __kvm_ioapic_update_eoi(struct kvm_vcpu *vcpu,
struct kvm_ioapic *ioapic, int vector, int trigger_mode) struct kvm_ioapic *ioapic, int vector, int trigger_mode)
{ {
int i; int i;
struct kvm_lapic *apic = vcpu->arch.apic;
for (i = 0; i < IOAPIC_NUM_PINS; i++) { for (i = 0; i < IOAPIC_NUM_PINS; i++) {
union kvm_ioapic_redirect_entry *ent = &ioapic->redirtbl[i]; union kvm_ioapic_redirect_entry *ent = &ioapic->redirtbl[i];
...@@ -443,7 +444,8 @@ static void __kvm_ioapic_update_eoi(struct kvm_vcpu *vcpu, ...@@ -443,7 +444,8 @@ static void __kvm_ioapic_update_eoi(struct kvm_vcpu *vcpu,
kvm_notify_acked_irq(ioapic->kvm, KVM_IRQCHIP_IOAPIC, i); kvm_notify_acked_irq(ioapic->kvm, KVM_IRQCHIP_IOAPIC, i);
spin_lock(&ioapic->lock); spin_lock(&ioapic->lock);
if (trigger_mode != IOAPIC_LEVEL_TRIG) if (trigger_mode != IOAPIC_LEVEL_TRIG ||
kvm_apic_get_reg(apic, APIC_SPIV) & APIC_SPIV_DIRECTED_EOI)
continue; continue;
ASSERT(ent->fields.trig_mode == IOAPIC_LEVEL_TRIG); ASSERT(ent->fields.trig_mode == IOAPIC_LEVEL_TRIG);
......
...@@ -833,8 +833,7 @@ int kvm_apic_compare_prio(struct kvm_vcpu *vcpu1, struct kvm_vcpu *vcpu2) ...@@ -833,8 +833,7 @@ int kvm_apic_compare_prio(struct kvm_vcpu *vcpu1, struct kvm_vcpu *vcpu2)
static void kvm_ioapic_send_eoi(struct kvm_lapic *apic, int vector) static void kvm_ioapic_send_eoi(struct kvm_lapic *apic, int vector)
{ {
if (!(kvm_apic_get_reg(apic, APIC_SPIV) & APIC_SPIV_DIRECTED_EOI) && if (kvm_ioapic_handles_vector(apic->vcpu->kvm, vector)) {
kvm_ioapic_handles_vector(apic->vcpu->kvm, vector)) {
int trigger_mode; int trigger_mode;
if (apic_test_vector(vector, apic->regs + APIC_TMR)) if (apic_test_vector(vector, apic->regs + APIC_TMR))
trigger_mode = IOAPIC_LEVEL_TRIG; trigger_mode = IOAPIC_LEVEL_TRIG;
......
...@@ -2479,8 +2479,7 @@ static void nested_vmx_setup_ctls_msrs(struct vcpu_vmx *vmx) ...@@ -2479,8 +2479,7 @@ static void nested_vmx_setup_ctls_msrs(struct vcpu_vmx *vmx)
if (enable_ept) { if (enable_ept) {
/* nested EPT: emulate EPT also to L1 */ /* nested EPT: emulate EPT also to L1 */
vmx->nested.nested_vmx_secondary_ctls_high |= vmx->nested.nested_vmx_secondary_ctls_high |=
SECONDARY_EXEC_ENABLE_EPT | SECONDARY_EXEC_ENABLE_EPT;
SECONDARY_EXEC_UNRESTRICTED_GUEST;
vmx->nested.nested_vmx_ept_caps = VMX_EPT_PAGE_WALK_4_BIT | vmx->nested.nested_vmx_ept_caps = VMX_EPT_PAGE_WALK_4_BIT |
VMX_EPTP_WB_BIT | VMX_EPT_2MB_PAGE_BIT | VMX_EPTP_WB_BIT | VMX_EPT_2MB_PAGE_BIT |
VMX_EPT_INVEPT_BIT; VMX_EPT_INVEPT_BIT;
...@@ -2494,6 +2493,10 @@ static void nested_vmx_setup_ctls_msrs(struct vcpu_vmx *vmx) ...@@ -2494,6 +2493,10 @@ static void nested_vmx_setup_ctls_msrs(struct vcpu_vmx *vmx)
} else } else
vmx->nested.nested_vmx_ept_caps = 0; vmx->nested.nested_vmx_ept_caps = 0;
if (enable_unrestricted_guest)
vmx->nested.nested_vmx_secondary_ctls_high |=
SECONDARY_EXEC_UNRESTRICTED_GUEST;
/* miscellaneous data */ /* miscellaneous data */
rdmsr(MSR_IA32_VMX_MISC, rdmsr(MSR_IA32_VMX_MISC,
vmx->nested.nested_vmx_misc_low, vmx->nested.nested_vmx_misc_low,
......
...@@ -471,7 +471,7 @@ static struct kvm *kvm_create_vm(unsigned long type) ...@@ -471,7 +471,7 @@ static struct kvm *kvm_create_vm(unsigned long type)
BUILD_BUG_ON(KVM_MEM_SLOTS_NUM > SHRT_MAX); BUILD_BUG_ON(KVM_MEM_SLOTS_NUM > SHRT_MAX);
r = -ENOMEM; r = -ENOMEM;
kvm->memslots = kzalloc(sizeof(struct kvm_memslots), GFP_KERNEL); kvm->memslots = kvm_kvzalloc(sizeof(struct kvm_memslots));
if (!kvm->memslots) if (!kvm->memslots)
goto out_err_no_srcu; goto out_err_no_srcu;
...@@ -522,7 +522,7 @@ static struct kvm *kvm_create_vm(unsigned long type) ...@@ -522,7 +522,7 @@ static struct kvm *kvm_create_vm(unsigned long type)
out_err_no_disable: out_err_no_disable:
for (i = 0; i < KVM_NR_BUSES; i++) for (i = 0; i < KVM_NR_BUSES; i++)
kfree(kvm->buses[i]); kfree(kvm->buses[i]);
kfree(kvm->memslots); kvfree(kvm->memslots);
kvm_arch_free_vm(kvm); kvm_arch_free_vm(kvm);
return ERR_PTR(r); return ERR_PTR(r);
} }
...@@ -578,7 +578,7 @@ static void kvm_free_physmem(struct kvm *kvm) ...@@ -578,7 +578,7 @@ static void kvm_free_physmem(struct kvm *kvm)
kvm_for_each_memslot(memslot, slots) kvm_for_each_memslot(memslot, slots)
kvm_free_physmem_slot(kvm, memslot, NULL); kvm_free_physmem_slot(kvm, memslot, NULL);
kfree(kvm->memslots); kvfree(kvm->memslots);
} }
static void kvm_destroy_devices(struct kvm *kvm) static void kvm_destroy_devices(struct kvm *kvm)
...@@ -871,10 +871,10 @@ int __kvm_set_memory_region(struct kvm *kvm, ...@@ -871,10 +871,10 @@ int __kvm_set_memory_region(struct kvm *kvm,
goto out_free; goto out_free;
} }
slots = kmemdup(kvm->memslots, sizeof(struct kvm_memslots), slots = kvm_kvzalloc(sizeof(struct kvm_memslots));
GFP_KERNEL);
if (!slots) if (!slots)
goto out_free; goto out_free;
memcpy(slots, kvm->memslots, sizeof(struct kvm_memslots));
if ((change == KVM_MR_DELETE) || (change == KVM_MR_MOVE)) { if ((change == KVM_MR_DELETE) || (change == KVM_MR_MOVE)) {
slot = id_to_memslot(slots, mem->slot); slot = id_to_memslot(slots, mem->slot);
...@@ -917,7 +917,7 @@ int __kvm_set_memory_region(struct kvm *kvm, ...@@ -917,7 +917,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
kvm_arch_commit_memory_region(kvm, mem, &old, change); kvm_arch_commit_memory_region(kvm, mem, &old, change);
kvm_free_physmem_slot(kvm, &old, &new); kvm_free_physmem_slot(kvm, &old, &new);
kfree(old_memslots); kvfree(old_memslots);
/* /*
* IOMMU mapping: New slots need to be mapped. Old slots need to be * IOMMU mapping: New slots need to be mapped. Old slots need to be
...@@ -936,7 +936,7 @@ int __kvm_set_memory_region(struct kvm *kvm, ...@@ -936,7 +936,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
return 0; return 0;
out_slots: out_slots:
kfree(slots); kvfree(slots);
out_free: out_free:
kvm_free_physmem_slot(kvm, &new, &old); kvm_free_physmem_slot(kvm, &new, &old);
out: out:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment