mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-07 12:44:32 -04:00
KVM: x86: Fold retry_instruction() into x86_emulate_instruction()
Now that retry_instruction() is reasonably tiny, fold it into its sole
caller, x86_emulate_instruction(). In addition to getting rid of the
absurdly confusing retry_instruction() name, handling the retry in
x86_emulate_instruction() pairs it back up with the code that resets
last_retry_{eip,address}.
No functional change intended.
Reviewed-by: Yuan Yao <yuan.yao@intel.com>
Link: https://lore.kernel.org/r/20240831001538.336683-12-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
This commit is contained in:
@@ -8924,26 +8924,6 @@ static bool reexecute_instruction(struct kvm_vcpu *vcpu, gpa_t cr2_or_gpa,
|
||||
return !(emulation_type & EMULTYPE_WRITE_PF_TO_SP);
|
||||
}
|
||||
|
||||
static bool retry_instruction(struct x86_emulate_ctxt *ctxt,
|
||||
gpa_t cr2_or_gpa, int emulation_type)
|
||||
{
|
||||
struct kvm_vcpu *vcpu = emul_to_vcpu(ctxt);
|
||||
|
||||
/*
|
||||
* If the emulation is caused by #PF and it is non-page_table
|
||||
* writing instruction, it means the VM-EXIT is caused by shadow
|
||||
* page protected, we can zap the shadow page and retry this
|
||||
* instruction directly.
|
||||
*/
|
||||
if (!(emulation_type & EMULTYPE_ALLOW_RETRY_PF))
|
||||
return false;
|
||||
|
||||
if (x86_page_table_writing_insn(ctxt))
|
||||
return false;
|
||||
|
||||
return kvm_mmu_unprotect_gfn_and_retry(vcpu, cr2_or_gpa);
|
||||
}
|
||||
|
||||
static int complete_emulated_mmio(struct kvm_vcpu *vcpu);
|
||||
static int complete_emulated_pio(struct kvm_vcpu *vcpu);
|
||||
|
||||
@@ -9223,7 +9203,15 @@ int x86_emulate_instruction(struct kvm_vcpu *vcpu, gpa_t cr2_or_gpa,
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (retry_instruction(ctxt, cr2_or_gpa, emulation_type))
|
||||
/*
|
||||
* If emulation was caused by a write-protection #PF on a non-page_table
|
||||
* writing instruction, try to unprotect the gfn, i.e. zap shadow pages,
|
||||
* and retry the instruction, as the vCPU is likely no longer using the
|
||||
* gfn as a page table.
|
||||
*/
|
||||
if ((emulation_type & EMULTYPE_ALLOW_RETRY_PF) &&
|
||||
!x86_page_table_writing_insn(ctxt) &&
|
||||
kvm_mmu_unprotect_gfn_and_retry(vcpu, cr2_or_gpa))
|
||||
return 1;
|
||||
|
||||
/* this is needed for vmware backdoor interface to work since it
|
||||
|
||||
Reference in New Issue
Block a user