Re: [PATCH] x86/coco, x86/sev: Use cpu_feature_enabled() to detect SEV guest flavor

From: Borislav Petkov
Date: Tue Dec 05 2023 - 11:00:56 EST


On Tue, Dec 05, 2023 at 06:14:37PM +0300, Kirill A. Shutemov wrote:
> My point is that if you need to check for SEV you need to check SEV, not
> CC_ATTR. CC_ATTRs only make sense in generic code that deals with multiple
> CoCo environments.

That makes more sense.

So that commit already says "If future support is added for other
memory encryption technologies, the use of CC_ATTR_GUEST_MEM_ENCRYPT
can be updated, as required."

And what this test needs to do is to check:

if (guest type >= SEV)

meaning SEV and -ES and -SNP.

I'm wondering if we should export amd_cc_platform_has() for such
cases...

The logic being, we're calling a SEV-specific function so using
cc_platform_has() in there is the wrong layer.

Tom?

--
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette