Re: [PATCH 19/26] x86/tdx: Make pages shared in ioremap()

From: Borislav Petkov
Date: Mon Dec 27 2021 - 06:51:29 EST


On Fri, Dec 24, 2021 at 02:03:00PM +0300, Kirill A. Shutemov wrote:
> Okay. Meanwhile I leave it this way:
>
> pgprot_t pgprot_cc_encrypted(pgprot_t prot)
> {
> if (cc_platform_has(CC_ATTR_MEM_ENCRYPT)) {
> if (cc_platform_has(CC_ATTR_GUEST_TDX))
> return __pgprot(pgprot_val(prot) & ~tdx_shared_mask());
> else if (sme_me_mask)
> return __pgprot(__sme_set(pgprot_val(prot)));
> else
> WARN_ON_ONCE(1);

I'm wondering if defining a generic cc_attr especially for this:

if (cc_platform_has(CC_ATTR_MEMORY_SHARING))

to mean, the CC guest needs to do special stuff in order to share memory
with the host (naming sucks, ofc) would be cleaner?

Because then

1. you can return whatever you need to, in the vendor-specific
cc_platform_has() and

2. this can be a separate attribute as I'm assuming it probably will be
used in a couple of places where sharing info with the host is needed.

Hmmm.

--
Regards/Gruss,
Boris.

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