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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <7e587261-6c77-f3d2-6258-32fac15fabb7@redhat.com>
Date:   Tue, 6 Jul 2021 15:25:35 +0200
From:   Paolo Bonzini <pbonzini@...hat.com>
To:     isaku.yamahata@...el.com, Thomas Gleixner <tglx@...utronix.de>,
        Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
        "H . Peter Anvin" <hpa@...or.com>,
        Vitaly Kuznetsov <vkuznets@...hat.com>,
        Wanpeng Li <wanpengli@...cent.com>,
        Jim Mattson <jmattson@...gle.com>,
        Joerg Roedel <joro@...tes.org>, erdemaktas@...gle.com,
        Connor Kuehl <ckuehl@...hat.com>,
        Sean Christopherson <seanjc@...gle.com>, x86@...nel.org,
        linux-kernel@...r.kernel.org, kvm@...r.kernel.org
Cc:     isaku.yamahata@...il.com, Xiaoyao Li <xiaoyao.li@...el.com>
Subject: Re: [RFC PATCH v2 10/69] KVM: TDX: Print the name of SEAMCALL status
 code

On 03/07/21 00:04, isaku.yamahata@...el.com wrote:
> From: Isaku Yamahata <isaku.yamahata@...el.com>
> 
> SEAMCALL error code is not intuitive to tell what's wrong in the
> SEAMCALL, print the error code name along with it.
> 
> Signed-off-by: Xiaoyao Li <xiaoyao.li@...el.com>
> Signed-off-by: Isaku Yamahata <isaku.yamahata@...el.com>
> ---
>   arch/x86/kvm/boot/seam/tdx_common.c | 21 +++++++++++++++++++++
>   arch/x86/kvm/vmx/seamcall.h         |  7 +++++--
>   2 files changed, 26 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/x86/kvm/boot/seam/tdx_common.c b/arch/x86/kvm/boot/seam/tdx_common.c
> index d803dbd11693..4fe352fb8586 100644
> --- a/arch/x86/kvm/boot/seam/tdx_common.c
> +++ b/arch/x86/kvm/boot/seam/tdx_common.c
> @@ -9,6 +9,7 @@
>   #include <asm/kvm_boot.h>
>   
>   #include "vmx/tdx_arch.h"
> +#include "vmx/tdx_errno.h"
>   
>   /*
>    * TDX system information returned by TDSYSINFO.
> @@ -165,3 +166,23 @@ void tdx_keyid_free(int keyid)
>   	ida_free(&tdx_keyid_pool, keyid);
>   }
>   EXPORT_SYMBOL_GPL(tdx_keyid_free);
> +
> +static struct tdx_seamcall_status {
> +	u64 err_code;
> +	const char *err_name;
> +} tdx_seamcall_status_codes[] = {TDX_SEAMCALL_STATUS_CODES};
> +
> +const char *tdx_seamcall_error_name(u64 error_code)
> +{
> +	struct tdx_seamcall_status status;
> +	int i;
> +
> +	for (i = 0; i < ARRAY_SIZE(tdx_seamcall_status_codes); i++) {
> +		status = tdx_seamcall_status_codes[i];
> +		if ((error_code & TDX_SEAMCALL_STATUS_MASK) == status.err_code)
> +			return status.err_name;
> +	}
> +
> +	return "Unknown SEAMCALL status code";
> +}
> +EXPORT_SYMBOL_GPL(tdx_seamcall_error_name);
> diff --git a/arch/x86/kvm/vmx/seamcall.h b/arch/x86/kvm/vmx/seamcall.h
> index 2c83ab46eeac..fbb18aea1720 100644
> --- a/arch/x86/kvm/vmx/seamcall.h
> +++ b/arch/x86/kvm/vmx/seamcall.h
> @@ -37,11 +37,14 @@ static inline u64 _seamcall(u64 op, u64 rcx, u64 rdx, u64 r8, u64 r9, u64 r10,
>   	_seamcall(SEAMCALL_##op, (rcx), (rdx), (r8), (r9), (r10), (ex))
>   #endif
>   
> +const char *tdx_seamcall_error_name(u64 error_code);
> +
>   static inline void __pr_seamcall_error(u64 op, const char *op_str,
>   				       u64 err, struct tdx_ex_ret *ex)
>   {
> -	pr_err_ratelimited("SEAMCALL[%s] failed on cpu %d: 0x%llx\n",
> -			   op_str, smp_processor_id(), (err));
> +	pr_err_ratelimited("SEAMCALL[%s] failed on cpu %d: %s (0x%llx)\n",
> +			   op_str, smp_processor_id(),
> +			   tdx_seamcall_error_name(err), err);
>   	if (ex)
>   		pr_err_ratelimited(
>   			"RCX 0x%llx, RDX 0x%llx, R8 0x%llx, R9 0x%llx, R10 0x%llx, R11 0x%llx\n",
> 

You can squash it in the earlier patch that introduced __pr_seamcall_error.

Paolo

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ