Messages in this thread | | | Date | Thu, 7 Oct 2021 19:06:27 +0200 | From | Borislav Petkov <> | Subject | Re: [PATCH v8 06/11] x86/traps: Add #VE support for TDX guest |
| |
On Mon, Oct 04, 2021 at 07:52:00PM -0700, Kuppuswamy Sathyanarayanan wrote: > diff --git a/arch/x86/kernel/tdx.c b/arch/x86/kernel/tdx.c > index d5fc2904facf..f7885c777a09 100644 > --- a/arch/x86/kernel/tdx.c > +++ b/arch/x86/kernel/tdx.c > @@ -6,6 +6,9 @@ > > #include <asm/tdx.h> > > +/* TDX Module call Leaf IDs */ > +#define TDGETVEINFO 3 > + > /* > * Allocate it in the data region to avoid zeroing it during > * BSS initialization. It is mainly used in cc_platform_has() > @@ -50,6 +53,36 @@ static inline u64 _tdx_hypercall(u64 fn, u64 r12, u64 r13, u64 r14, > return out->r10; > } > > +unsigned long tdx_get_ve_info(struct ve_info *ve) > +{ > + struct tdx_module_output out = {0}; > + u64 ret; > + > + /* > + * NMIs and machine checks are suppressed. Before this point any > + * #VE is fatal. After this point (TDGETVEINFO call), NMIs and > + * additional #VEs are permitted (but it is expected not to > + * happen unless kernel panics). > + */ > + ret = __tdx_module_call(TDGETVEINFO, 0, 0, 0, 0, &out);
Same question as before - why do you need to clear this @out thing above when __tdx_module_call() will overwrite it?
What you should do instead is check that @ve pointer which you get passed in - it might be NULL.
> + ve->exit_reason = out.rcx; > + ve->exit_qual = out.rdx; > + ve->gla = out.r8; > + ve->gpa = out.r9; > + ve->instr_len = out.r10 & UINT_MAX; > + ve->instr_info = out.r10 >> 32; > + > + return ret; > -- Regards/Gruss, Boris.
https://people.kernel.org/tglx/notes-about-netiquette
| |