Skip to content

Commit 834354f

Browse files
committed
Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm
Pull KVM fixes from Radim Krčmář: "PPC: - Fix bug which could leave locks held in the host on return to a guest. x86: - Prevent infinitely looping emulation of a failing syscall while single stepping. - Do not crash the host when nesting is disabled" * tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm: KVM: x86: Don't update RIP or do single-step on faulting emulation KVM: x86: hyper-v: don't crash on KVM_GET_SUPPORTED_HV_CPUID when kvm_intel.nested is disabled KVM: PPC: Book3S: Fix incorrect guest-to-user-translation error handling
2 parents 31bb5fe + 75ee23b commit 834354f

File tree

6 files changed

+19
-16
lines changed

6 files changed

+19
-16
lines changed

arch/powerpc/kvm/book3s_64_vio.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -660,8 +660,10 @@ long kvmppc_h_put_tce_indirect(struct kvm_vcpu *vcpu,
660660
}
661661
tce = be64_to_cpu(tce);
662662

663-
if (kvmppc_tce_to_ua(vcpu->kvm, tce, &ua))
664-
return H_PARAMETER;
663+
if (kvmppc_tce_to_ua(vcpu->kvm, tce, &ua)) {
664+
ret = H_PARAMETER;
665+
goto unlock_exit;
666+
}
665667

666668
list_for_each_entry_lockless(stit, &stt->iommu_tables, next) {
667669
ret = kvmppc_tce_iommu_map(vcpu->kvm, stt,

arch/powerpc/kvm/book3s_64_vio_hv.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -556,8 +556,10 @@ long kvmppc_rm_h_put_tce_indirect(struct kvm_vcpu *vcpu,
556556
unsigned long tce = be64_to_cpu(((u64 *)tces)[i]);
557557

558558
ua = 0;
559-
if (kvmppc_rm_tce_to_ua(vcpu->kvm, tce, &ua, NULL))
560-
return H_PARAMETER;
559+
if (kvmppc_rm_tce_to_ua(vcpu->kvm, tce, &ua, NULL)) {
560+
ret = H_PARAMETER;
561+
goto unlock_exit;
562+
}
561563

562564
list_for_each_entry_lockless(stit, &stt->iommu_tables, next) {
563565
ret = kvmppc_rm_tce_iommu_map(vcpu->kvm, stt,

arch/x86/kvm/hyperv.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1781,7 +1781,7 @@ int kvm_vm_ioctl_hv_eventfd(struct kvm *kvm, struct kvm_hyperv_eventfd *args)
17811781
int kvm_vcpu_ioctl_get_hv_cpuid(struct kvm_vcpu *vcpu, struct kvm_cpuid2 *cpuid,
17821782
struct kvm_cpuid_entry2 __user *entries)
17831783
{
1784-
uint16_t evmcs_ver = kvm_x86_ops->nested_get_evmcs_version(vcpu);
1784+
uint16_t evmcs_ver = 0;
17851785
struct kvm_cpuid_entry2 cpuid_entries[] = {
17861786
{ .function = HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS },
17871787
{ .function = HYPERV_CPUID_INTERFACE },
@@ -1793,6 +1793,9 @@ int kvm_vcpu_ioctl_get_hv_cpuid(struct kvm_vcpu *vcpu, struct kvm_cpuid2 *cpuid,
17931793
};
17941794
int i, nent = ARRAY_SIZE(cpuid_entries);
17951795

1796+
if (kvm_x86_ops->nested_get_evmcs_version)
1797+
evmcs_ver = kvm_x86_ops->nested_get_evmcs_version(vcpu);
1798+
17961799
/* Skip NESTED_FEATURES if eVMCS is not supported */
17971800
if (!evmcs_ver)
17981801
--nent;

arch/x86/kvm/svm.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7128,12 +7128,6 @@ static int svm_unregister_enc_region(struct kvm *kvm,
71287128
return ret;
71297129
}
71307130

7131-
static uint16_t nested_get_evmcs_version(struct kvm_vcpu *vcpu)
7132-
{
7133-
/* Not supported */
7134-
return 0;
7135-
}
7136-
71377131
static int nested_enable_evmcs(struct kvm_vcpu *vcpu,
71387132
uint16_t *vmcs_version)
71397133
{
@@ -7332,7 +7326,7 @@ static struct kvm_x86_ops svm_x86_ops __ro_after_init = {
73327326
.mem_enc_unreg_region = svm_unregister_enc_region,
73337327

73347328
.nested_enable_evmcs = nested_enable_evmcs,
7335-
.nested_get_evmcs_version = nested_get_evmcs_version,
7329+
.nested_get_evmcs_version = NULL,
73367330

73377331
.need_emulation_on_page_fault = svm_need_emulation_on_page_fault,
73387332
};

arch/x86/kvm/vmx/vmx.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7797,6 +7797,7 @@ static struct kvm_x86_ops vmx_x86_ops __ro_after_init = {
77977797
.set_nested_state = NULL,
77987798
.get_vmcs12_pages = NULL,
77997799
.nested_enable_evmcs = NULL,
7800+
.nested_get_evmcs_version = NULL,
78007801
.need_emulation_on_page_fault = vmx_need_emulation_on_page_fault,
78017802
};
78027803

arch/x86/kvm/x86.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6594,12 +6594,13 @@ int x86_emulate_instruction(struct kvm_vcpu *vcpu,
65946594
unsigned long rflags = kvm_x86_ops->get_rflags(vcpu);
65956595
toggle_interruptibility(vcpu, ctxt->interruptibility);
65966596
vcpu->arch.emulate_regs_need_sync_to_vcpu = false;
6597-
kvm_rip_write(vcpu, ctxt->eip);
6598-
if (r == EMULATE_DONE && ctxt->tf)
6599-
kvm_vcpu_do_singlestep(vcpu, &r);
66006597
if (!ctxt->have_exception ||
6601-
exception_type(ctxt->exception.vector) == EXCPT_TRAP)
6598+
exception_type(ctxt->exception.vector) == EXCPT_TRAP) {
6599+
kvm_rip_write(vcpu, ctxt->eip);
6600+
if (r == EMULATE_DONE && ctxt->tf)
6601+
kvm_vcpu_do_singlestep(vcpu, &r);
66026602
__kvm_set_rflags(vcpu, ctxt->eflags);
6603+
}
66036604

66046605
/*
66056606
* For STI, interrupts are shadowed; so KVM_REQ_EVENT will

0 commit comments

Comments
 (0)