lkml.org 
[lkml]   [2022]   [Oct]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH v10 094/108] KVM: TDX: Handle TDX PV CPUID hypercall
    Date
    From: Isaku Yamahata <isaku.yamahata@intel.com>

    Wire up TDX PV CPUID hypercall to the KVM backend function.

    Signed-off-by: Isaku Yamahata <isaku.yamahata@intel.com>
    ---
    arch/x86/kvm/vmx/tdx.c | 22 ++++++++++++++++++++++
    1 file changed, 22 insertions(+)

    diff --git a/arch/x86/kvm/vmx/tdx.c b/arch/x86/kvm/vmx/tdx.c
    index f6477d577001..4b83d7a81433 100644
    --- a/arch/x86/kvm/vmx/tdx.c
    +++ b/arch/x86/kvm/vmx/tdx.c
    @@ -810,12 +810,34 @@ static int tdx_emulate_vmcall(struct kvm_vcpu *vcpu)
    return 1;
    }

    +static int tdx_emulate_cpuid(struct kvm_vcpu *vcpu)
    +{
    + u32 eax, ebx, ecx, edx;
    +
    + /* EAX and ECX for cpuid is stored in R12 and R13. */
    + eax = tdvmcall_a0_read(vcpu);
    + ecx = tdvmcall_a1_read(vcpu);
    +
    + kvm_cpuid(vcpu, &eax, &ebx, &ecx, &edx, false);
    +
    + tdvmcall_a0_write(vcpu, eax);
    + tdvmcall_a1_write(vcpu, ebx);
    + tdvmcall_a2_write(vcpu, ecx);
    + tdvmcall_a3_write(vcpu, edx);
    +
    + tdvmcall_set_return_code(vcpu, TDG_VP_VMCALL_SUCCESS);
    +
    + return 1;
    +}
    +
    static int handle_tdvmcall(struct kvm_vcpu *vcpu)
    {
    if (tdvmcall_exit_type(vcpu))
    return tdx_emulate_vmcall(vcpu);

    switch (tdvmcall_leaf(vcpu)) {
    + case EXIT_REASON_CPUID:
    + return tdx_emulate_cpuid(vcpu);
    default:
    break;
    }
    --
    2.25.1
    \
     
     \ /
      Last update: 2022-10-30 07:33    [W:2.485 / U:0.036 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site