Skip to content

Commit 0b75889

Browse files
yamahatabonzini
authored andcommitted
KVM: TDX: Add a method to ignore hypercall patching
Because guest TD memory is protected, VMM patching guest binary for hypercall instruction isn't possible. Add a method to ignore hypercall patching. Note: guest TD kernel needs to be modified to use TDG.VP.VMCALL for hypercall. Signed-off-by: Isaku Yamahata <isaku.yamahata@intel.com> Signed-off-by: Binbin Wu <binbin.wu@linux.intel.com> Message-ID: <20250227012021.1778144-18-binbin.wu@linux.intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent 79264ff commit 0b75889

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

arch/x86/kvm/vmx/main.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,19 @@ static u32 vt_get_interrupt_shadow(struct kvm_vcpu *vcpu)
673673
return vmx_get_interrupt_shadow(vcpu);
674674
}
675675

676+
static void vt_patch_hypercall(struct kvm_vcpu *vcpu,
677+
unsigned char *hypercall)
678+
{
679+
/*
680+
* Because guest memory is protected, guest can't be patched. TD kernel
681+
* is modified to use TDG.VP.VMCALL for hypercall.
682+
*/
683+
if (is_td_vcpu(vcpu))
684+
return;
685+
686+
vmx_patch_hypercall(vcpu, hypercall);
687+
}
688+
676689
static void vt_inject_irq(struct kvm_vcpu *vcpu, bool reinjected)
677690
{
678691
if (is_td_vcpu(vcpu))
@@ -952,7 +965,7 @@ struct kvm_x86_ops vt_x86_ops __initdata = {
952965
.update_emulated_instruction = vmx_update_emulated_instruction,
953966
.set_interrupt_shadow = vt_set_interrupt_shadow,
954967
.get_interrupt_shadow = vt_get_interrupt_shadow,
955-
.patch_hypercall = vmx_patch_hypercall,
968+
.patch_hypercall = vt_patch_hypercall,
956969
.inject_irq = vt_inject_irq,
957970
.inject_nmi = vt_inject_nmi,
958971
.inject_exception = vt_inject_exception,

0 commit comments

Comments
 (0)