Re: [PATCHv2 22/29] x86/tdx: Make pages shared in ioremap()

Borislav Petkov
2022-02-17T15:24:11Z

On Wed, Feb 16, 2022 at 06:37:03PM +0300, Kirill A. Shutemov wrote:
> bool cc_platform_has(enum cc_attr attr)
> {
> if (cpu_feature_enabled(X86_FEATURE_TDX_GUEST))
> return intel_cc_platform_has(attr);
> else if (cc_mask)
> return amd_cc_platform_has(attr);

It is exactly stuff like that I'd like to avoid because that is
dependent on the order the test happens.

It would be a lot more robust if this did:

switch (cc_vendor) {
case INTEL: return intel_cc_platform_has(attr);
case AMD: return amd_cc_platform_has(attr);
case HYPERV: return hyperv_cc_platform_has(attr);
default: return false;
}

--
Regards/Gruss,
Boris.