[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87fsnh30r1.ffs@tglx>
Date: Thu, 17 Mar 2022 01:01:54 +0100
From: Thomas Gleixner <tglx@...utronix.de>
To: "Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>,
mingo@...hat.com, bp@...en8.de, dave.hansen@...el.com,
luto@...nel.org, peterz@...radead.org
Cc: sathyanarayanan.kuppuswamy@...ux.intel.com, aarcange@...hat.com,
ak@...ux.intel.com, dan.j.williams@...el.com, david@...hat.com,
hpa@...or.com, jgross@...e.com, jmattson@...gle.com,
joro@...tes.org, jpoimboe@...hat.com, knsathya@...nel.org,
pbonzini@...hat.com, sdeep@...are.com, seanjc@...gle.com,
tony.luck@...el.com, vkuznets@...hat.com, wanpengli@...cent.com,
thomas.lendacky@....com, brijesh.singh@....com, x86@...nel.org,
linux-kernel@...r.kernel.org,
"Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>,
Dave Hansen <dave.hansen@...ux.intel.com>,
Borislav Petkov <bp@...e.de>
Subject: Re: [PATCHv6 04/30] x86/tdx: Extend the confidential computing API
to support TDX guests
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
Powered by blists - more mailing lists