| From | Thomas Gleixner <> | Subject | Re: [PATCHv6 04/30] x86/tdx: Extend the confidential computing API to support TDX guests | Date | Thu, 17 Mar 2022 01:01:54 +0100 |
| |
On Wed, Mar 16 2022 at 05:08, Kirill A. Shutemov wrote: > + > +static void get_info(unsigned int *gpa_width)
get_info() is really not a descriptive function name. Also why does this need a pointer and does not return gpa_width?
> > setup_force_cpu_cap(X86_FEATURE_TDX_GUEST); > > + get_info(&gpa_width); > + > + cc_set_vendor(CC_VENDOR_INTEL); > + > + /* > + * The highest bit of a guest physical address is the "sharing" bit. > + * Set it for shared pages and clear it for private pages. > + */ > + cc_set_mask(BIT_ULL(gpa_width - 1));
The code ordering here is silly:
1) Retrieve gpa width 2) Set CC vendor 3) Use gpa width
static u64 get_cc_mask(void) { gpa_width = magic();
/* * Comment explaining the return value */ return BIT_ULL(gpa_width - 1); }
and
cc_set_vendor(CC_VENDOR_INTEL); cc_set_mask(get_cc_mask());
would be too intuitive, right?
Thanks,
tglx
---
“My tastes are simple: I am easily satisfied with the best.” ― Winston S. Churchill
|