Re: [PATCH v7 01/12] x86/tdx: Add Intel ARCH support to cc_platform_has()

From: Dave Hansen
Date: Thu Sep 16 2021 - 14:44:56 EST


On 9/16/21 11:35 AM, Kuppuswamy Sathyanarayanan wrote:
> --- a/arch/x86/kernel/cc_platform.c
> +++ b/arch/x86/kernel/cc_platform.c
> @@ -10,11 +10,16 @@
> #include <linux/export.h>
> #include <linux/cc_platform.h>
> #include <linux/mem_encrypt.h>
> +#include <linux/processor.h>
> +
> +#include <asm/intel_cc_platform.h>
>
> bool cc_platform_has(enum cc_attr attr)
> {
> if (sme_me_mask)
> return amd_cc_platform_has(attr);
> + else if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL)
> + return intel_cc_platform_has(attr);
>
> return false;
> }

How did this end up out of line? This means that if you compile-time
enable support for even *one* "cc" platform, you can't optimize the
calls away. This ends up being at *LEAST* two calls, just to get an
unconditional "false". That just seems silly.

I know this is a comment more about the cc_platform_has() series that
this one, but this compounds the problem.