lkml.org 
[lkml]   [2024]   [Feb]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH v19 115/130] KVM: TDX: Handle TDG.VP.VMCALL<GetTdVmCallInfo> hypercall
    Date
    From: Isaku Yamahata <isaku.yamahata@intel.com>

    Implement TDG.VP.VMCALL<GetTdVmCallInfo> hypercall. If the input value is
    zero, return success code and zero in output registers.

    TDG.VP.VMCALL<GetTdVmCallInfo> hypercall is a subleaf of TDG.VP.VMCALL to
    enumerate which TDG.VP.VMCALL sub leaves are supported. This hypercall is
    for future enhancement of the Guest-Host-Communication Interface (GHCI)
    specification. The GHCI version of 344426-001US defines it to require
    input R12 to be zero and to return zero in output registers, R11, R12, R13,
    and R14 so that guest TD enumerates no enhancement.

    Signed-off-by: Isaku Yamahata <isaku.yamahata@intel.com>
    ---
    v19:
    - rename TDG_VP_VMCALL_GET_TD_VM_CALL_INFO => TDVMCALL_GET_TD_VM_CALL_INFO
    ---
    arch/x86/include/asm/shared/tdx.h | 1 +
    arch/x86/kvm/vmx/tdx.c | 16 ++++++++++++++++
    2 files changed, 17 insertions(+)

    diff --git a/arch/x86/include/asm/shared/tdx.h b/arch/x86/include/asm/shared/tdx.h
    index 28c4a62b7dba..3e8ce567fde0 100644
    --- a/arch/x86/include/asm/shared/tdx.h
    +++ b/arch/x86/include/asm/shared/tdx.h
    @@ -22,6 +22,7 @@
    #define TDCS_NOTIFY_ENABLES 0x9100000000000010

    /* TDX hypercall Leaf IDs */
    +#define TDVMCALL_GET_TD_VM_CALL_INFO 0x10000
    #define TDVMCALL_MAP_GPA 0x10001
    #define TDVMCALL_GET_QUOTE 0x10002
    #define TDVMCALL_REPORT_FATAL_ERROR 0x10003
    diff --git a/arch/x86/kvm/vmx/tdx.c b/arch/x86/kvm/vmx/tdx.c
    index 3481c0b6ef2c..725cb40d0814 100644
    --- a/arch/x86/kvm/vmx/tdx.c
    +++ b/arch/x86/kvm/vmx/tdx.c
    @@ -1353,6 +1353,20 @@ static int tdx_emulate_wrmsr(struct kvm_vcpu *vcpu)
    return 1;
    }

    +static int tdx_get_td_vm_call_info(struct kvm_vcpu *vcpu)
    +{
    + if (tdvmcall_a0_read(vcpu))
    + tdvmcall_set_return_code(vcpu, TDVMCALL_INVALID_OPERAND);
    + else {
    + tdvmcall_set_return_code(vcpu, TDVMCALL_SUCCESS);
    + kvm_r11_write(vcpu, 0);
    + tdvmcall_a0_write(vcpu, 0);
    + tdvmcall_a1_write(vcpu, 0);
    + tdvmcall_a2_write(vcpu, 0);
    + }
    + return 1;
    +}
    +
    static int handle_tdvmcall(struct kvm_vcpu *vcpu)
    {
    if (tdvmcall_exit_type(vcpu))
    @@ -1371,6 +1385,8 @@ static int handle_tdvmcall(struct kvm_vcpu *vcpu)
    return tdx_emulate_rdmsr(vcpu);
    case EXIT_REASON_MSR_WRITE:
    return tdx_emulate_wrmsr(vcpu);
    + case TDVMCALL_GET_TD_VM_CALL_INFO:
    + return tdx_get_td_vm_call_info(vcpu);
    default:
    break;
    }
    --
    2.25.1

    \
     
     \ /
      Last update: 2024-05-27 15:21    [W:2.557 / U:0.740 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site