lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 14 Jun 2022 11:15:00 -0700
From:   Sagi Shahar <sagis@...gle.com>
To:     "Yamahata, Isaku" <isaku.yamahata@...el.com>
Cc:     kvm@...r.kernel.org, linux-kernel@...r.kernel.org,
        isaku.yamahata@...il.com, Paolo Bonzini <pbonzini@...hat.com>,
        Erdem Aktas <erdemaktas@...gle.com>,
        Sean Christopherson <seanjc@...gle.com>
Subject: Re: [RFC PATCH v6 090/104] KVM: TDX: Handle TDX PV CPUID hypercall

On Thu, May 5, 2022 at 11:16 AM <isaku.yamahata@...el.com> wrote:
>
> From: Isaku Yamahata <isaku.yamahata@...el.com>
>
> Wire up TDX PV CPUID hypercall to the KVM backend function.
>
> Signed-off-by: Isaku Yamahata <isaku.yamahata@...el.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 9c712f661a7c..c7cdfee397ec 100644
> --- a/arch/x86/kvm/vmx/tdx.c
> +++ b/arch/x86/kvm/vmx/tdx.c
> @@ -946,12 +946,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, true);

According to the GHCI spec section 3.6
(TDG.VP.VMCALL<Instruction.CPUID>) we should return
VMCALL_INVALID_OPERAND if an invalid CPUID is requested.

kvm_cpuid already returns false in this case so we should use that
return value to set the tdvmcall return code in case of invalid leaf.
> +
> +       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
>

Sagi

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ