Message ID | 20240812224820.34826-6-rick.p.edgecombe@intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | TDX vCPU/VM creation | expand |
On Mon, Aug 12, 2024 at 03:48:00PM -0700, Rick Edgecombe <rick.p.edgecombe@intel.com> wrote: > From: Isaku Yamahata <isaku.yamahata@intel.com> > > Add helper functions to print out errors from the TDX module in a uniform > manner. > > Signed-off-by: Isaku Yamahata <isaku.yamahata@intel.com> > Signed-off-by: Rick Edgecombe <rick.p.edgecombe@intel.com> > Reviewed-by: Binbin Wu <binbin.wu@linux.intel.com> > Reviewed-by: Yuan Yao <yuan.yao@intel.com> > --- > uAPI breakout v1: > - Update for the wrapper functions for SEAMCALLs. (Sean) > - Reorder header file include to adjust argument change of the C wrapper. > - Fix bisectability issues in headers (Kai) > - Updates from seamcall overhaul (Kai) > > v19: > - dropped unnecessary include <asm/tdx.h> > > v18: > - Added Reviewed-by Binbin. > --- > arch/x86/kvm/vmx/tdx_ops.h | 15 +++++++++++++++ > 1 file changed, 15 insertions(+) > > diff --git a/arch/x86/kvm/vmx/tdx_ops.h b/arch/x86/kvm/vmx/tdx_ops.h > index a9b9ad15f6a8..3f64c871a3f2 100644 > --- a/arch/x86/kvm/vmx/tdx_ops.h > +++ b/arch/x86/kvm/vmx/tdx_ops.h > @@ -16,6 +16,21 @@ > > #include "x86.h" > > +#define pr_tdx_error(__fn, __err) \ > + pr_err_ratelimited("SEAMCALL %s failed: 0x%llx\n", #__fn, __err) > + > +#define pr_tdx_error_N(__fn, __err, __fmt, ...) \ > + pr_err_ratelimited("SEAMCALL %s failed: 0x%llx, " __fmt, #__fn, __err, __VA_ARGS__) Stringify in the inner macro results in expansion of __fn. It means value itself, not symbolic string. Stringify should be in the outer macro. "SEAMCALL 7 failed" vs "SEAMCALL TDH_MEM_RANGE_BLOCK failed" #define __pr_tdx_error_N(__fn_str, __err, __fmt, ...) \ pr_err_ratelimited("SEAMCALL " __fn_str " failed: 0x%llx, " __fmt, __err, __VA_ARGS__) #define pr_tdx_error_N(__fn, __err, __fmt, ...) \ __pr_tdx_error_N(#__fn, __err, __fmt, __VA_ARGS__) #define pr_tdx_error_1(__fn, __err, __rcx) \ __pr_tdx_error_N(#__fn, __err, "rcx 0x%llx\n", __rcx) #define pr_tdx_error_2(__fn, __err, __rcx, __rdx) \ __pr_tdx_error_N(#__fn, __err, "rcx 0x%llx, rdx 0x%llx\n", __rcx, __rdx) #define pr_tdx_error_3(__fn, __err, __rcx, __rdx, __r8) \ __pr_tdx_error_N(#__fn, __err, "rcx 0x%llx, rdx 0x%llx, r8 0x%llx\n", __rcx, __rdx, __r8) > + > +#define pr_tdx_error_1(__fn, __err, __rcx) \ > + pr_tdx_error_N(__fn, __err, "rcx 0x%llx\n", __rcx) > + > +#define pr_tdx_error_2(__fn, __err, __rcx, __rdx) \ > + pr_tdx_error_N(__fn, __err, "rcx 0x%llx, rdx 0x%llx\n", __rcx, __rdx) > + > +#define pr_tdx_error_3(__fn, __err, __rcx, __rdx, __r8) \ > + pr_tdx_error_N(__fn, __err, "rcx 0x%llx, rdx 0x%llx, r8 0x%llx\n", __rcx, __rdx, __r8) > + > static inline u64 tdh_mng_addcx(struct kvm_tdx *kvm_tdx, hpa_t addr) > { > struct tdx_module_args in = { > -- > 2.34.1 > >
>> +#define pr_tdx_error(__fn, __err) \ >> + pr_err_ratelimited("SEAMCALL %s failed: 0x%llx\n", #__fn, __err) >> + >> +#define pr_tdx_error_N(__fn, __err, __fmt, ...) \ >> + pr_err_ratelimited("SEAMCALL %s failed: 0x%llx, " __fmt, #__fn, __err, __VA_ARGS__) > > Stringify in the inner macro results in expansion of __fn. It means value > itself, not symbolic string. Stringify should be in the outer macro. > "SEAMCALL 7 failed" vs "SEAMCALL TDH_MEM_RANGE_BLOCK failed" > > #define __pr_tdx_error_N(__fn_str, __err, __fmt, ...) \ > pr_err_ratelimited("SEAMCALL " __fn_str " failed: 0x%llx, " __fmt, __err, __VA_ARGS__) > > #define pr_tdx_error_N(__fn, __err, __fmt, ...) \ > __pr_tdx_error_N(#__fn, __err, __fmt, __VA_ARGS__) > > #define pr_tdx_error_1(__fn, __err, __rcx) \ > __pr_tdx_error_N(#__fn, __err, "rcx 0x%llx\n", __rcx) > > #define pr_tdx_error_2(__fn, __err, __rcx, __rdx) \ > __pr_tdx_error_N(#__fn, __err, "rcx 0x%llx, rdx 0x%llx\n", __rcx, __rdx) > > #define pr_tdx_error_3(__fn, __err, __rcx, __rdx, __r8) \ > __pr_tdx_error_N(#__fn, __err, "rcx 0x%llx, rdx 0x%llx, r8 0x%llx\n", __rcx, __rdx, __r8) > You are right. Thanks for catching this! The above code looks good to me, except we don't need pr_tdx_error_N() anymore. I think we can just replace the old pr_tdx_error_N() with your __pr_tdx_error_N().
On Wed, Aug 14, 2024 at 10:34:11AM +1200, "Huang, Kai" <kai.huang@intel.com> wrote: > > > > +#define pr_tdx_error(__fn, __err) \ > > > + pr_err_ratelimited("SEAMCALL %s failed: 0x%llx\n", #__fn, __err) > > > + > > > +#define pr_tdx_error_N(__fn, __err, __fmt, ...) \ > > > + pr_err_ratelimited("SEAMCALL %s failed: 0x%llx, " __fmt, #__fn, __err, __VA_ARGS__) > > > > Stringify in the inner macro results in expansion of __fn. It means value > > itself, not symbolic string. Stringify should be in the outer macro. > > "SEAMCALL 7 failed" vs "SEAMCALL TDH_MEM_RANGE_BLOCK failed" > > > > #define __pr_tdx_error_N(__fn_str, __err, __fmt, ...) \ > > pr_err_ratelimited("SEAMCALL " __fn_str " failed: 0x%llx, " __fmt, __err, __VA_ARGS__) > > > > #define pr_tdx_error_N(__fn, __err, __fmt, ...) \ > > __pr_tdx_error_N(#__fn, __err, __fmt, __VA_ARGS__) > > > > #define pr_tdx_error_1(__fn, __err, __rcx) \ > > __pr_tdx_error_N(#__fn, __err, "rcx 0x%llx\n", __rcx) > > > > #define pr_tdx_error_2(__fn, __err, __rcx, __rdx) \ > > __pr_tdx_error_N(#__fn, __err, "rcx 0x%llx, rdx 0x%llx\n", __rcx, __rdx) > > > > #define pr_tdx_error_3(__fn, __err, __rcx, __rdx, __r8) \ > > __pr_tdx_error_N(#__fn, __err, "rcx 0x%llx, rdx 0x%llx, r8 0x%llx\n", __rcx, __rdx, __r8) > > > > You are right. Thanks for catching this! > > The above code looks good to me, except we don't need pr_tdx_error_N() > anymore. > > I think we can just replace the old pr_tdx_error_N() with your > __pr_tdx_error_N(). Agreed, we don't have the direct user of pr_tdx_error_N().
On Tue, Aug 13, 2024 at 05:31:31PM -0700, Isaku Yamahata wrote: > On Wed, Aug 14, 2024 at 10:34:11AM +1200, > "Huang, Kai" <kai.huang@intel.com> wrote: > > > > > > > +#define pr_tdx_error(__fn, __err) \ > > > > + pr_err_ratelimited("SEAMCALL %s failed: 0x%llx\n", #__fn, __err) > > > > + > > > > +#define pr_tdx_error_N(__fn, __err, __fmt, ...) \ > > > > + pr_err_ratelimited("SEAMCALL %s failed: 0x%llx, " __fmt, #__fn, __err, __VA_ARGS__) > > > > > > Stringify in the inner macro results in expansion of __fn. It means value > > > itself, not symbolic string. Stringify should be in the outer macro. > > > "SEAMCALL 7 failed" vs "SEAMCALL TDH_MEM_RANGE_BLOCK failed" > > > > > > #define __pr_tdx_error_N(__fn_str, __err, __fmt, ...) \ > > > pr_err_ratelimited("SEAMCALL " __fn_str " failed: 0x%llx, " __fmt, __err, __VA_ARGS__) > > > > > > #define pr_tdx_error_N(__fn, __err, __fmt, ...) \ > > > __pr_tdx_error_N(#__fn, __err, __fmt, __VA_ARGS__) > > > > > > #define pr_tdx_error_1(__fn, __err, __rcx) \ > > > __pr_tdx_error_N(#__fn, __err, "rcx 0x%llx\n", __rcx) > > > > > > #define pr_tdx_error_2(__fn, __err, __rcx, __rdx) \ > > > __pr_tdx_error_N(#__fn, __err, "rcx 0x%llx, rdx 0x%llx\n", __rcx, __rdx) > > > > > > #define pr_tdx_error_3(__fn, __err, __rcx, __rdx, __r8) \ > > > __pr_tdx_error_N(#__fn, __err, "rcx 0x%llx, rdx 0x%llx, r8 0x%llx\n", __rcx, __rdx, __r8) > > > > > > > You are right. Thanks for catching this! > > > > The above code looks good to me, except we don't need pr_tdx_error_N() > > anymore. > > > > I think we can just replace the old pr_tdx_error_N() with your > > __pr_tdx_error_N(). > > Agreed, we don't have the direct user of pr_tdx_error_N(). I'll do a patch for these changes. Tony
diff --git a/arch/x86/kvm/vmx/tdx_ops.h b/arch/x86/kvm/vmx/tdx_ops.h index a9b9ad15f6a8..3f64c871a3f2 100644 --- a/arch/x86/kvm/vmx/tdx_ops.h +++ b/arch/x86/kvm/vmx/tdx_ops.h @@ -16,6 +16,21 @@ #include "x86.h" +#define pr_tdx_error(__fn, __err) \ + pr_err_ratelimited("SEAMCALL %s failed: 0x%llx\n", #__fn, __err) + +#define pr_tdx_error_N(__fn, __err, __fmt, ...) \ + pr_err_ratelimited("SEAMCALL %s failed: 0x%llx, " __fmt, #__fn, __err, __VA_ARGS__) + +#define pr_tdx_error_1(__fn, __err, __rcx) \ + pr_tdx_error_N(__fn, __err, "rcx 0x%llx\n", __rcx) + +#define pr_tdx_error_2(__fn, __err, __rcx, __rdx) \ + pr_tdx_error_N(__fn, __err, "rcx 0x%llx, rdx 0x%llx\n", __rcx, __rdx) + +#define pr_tdx_error_3(__fn, __err, __rcx, __rdx, __r8) \ + pr_tdx_error_N(__fn, __err, "rcx 0x%llx, rdx 0x%llx, r8 0x%llx\n", __rcx, __rdx, __r8) + static inline u64 tdh_mng_addcx(struct kvm_tdx *kvm_tdx, hpa_t addr) { struct tdx_module_args in = {