[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1d77e91c-e151-7846-6cd4-6264236ca5ae@intel.com>
Date: Mon, 7 Feb 2022 08:57:39 -0800
From: Dave Hansen <dave.hansen@...el.com>
To: Borislav Petkov <bp@...en8.de>,
"Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>
Cc: tglx@...utronix.de, mingo@...hat.com, luto@...nel.org,
peterz@...radead.org, 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, x86@...nel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCHv2 22/29] x86/tdx: Make pages shared in ioremap()
On 2/7/22 08:27, Borislav Petkov wrote:
> On Mon, Jan 24, 2022 at 06:02:08PM +0300, Kirill A. Shutemov wrote:
>> -/*
>> - * Macros to add or remove encryption attribute
>> - */
>> -#define pgprot_encrypted(prot) __pgprot(__sme_set(pgprot_val(prot)))
>> -#define pgprot_decrypted(prot) __pgprot(__sme_clr(pgprot_val(prot)))
> Why can't you simply define
>
> cc_set() and cc_clear()
>
> helpers which either call the __sme variants or __tdx variants, the
> latter you can define the same way, respectively, as the __sme ones.
I think your basic point here is valid: Let's have a single function to
take a pgprot and turn it into an "encrypted" or "decrypted" pgprot.
But, we can't do it with functions like cc_set() and cc_clear() because
the polarity is different:
> +pgprot_t pgprot_encrypted(pgprot_t prot)
> +{
> + if (sme_me_mask)
> + return __pgprot(__sme_set(pgprot_val(prot)));
> + else if (is_tdx_guest())
> + return __pgprot(pgprot_val(prot) & ~tdx_shared_mask());
> +
> + return prot;
> +}
For "encrypted", SME sets bits and TDX clears bits.
For "decrypted", SME clears bits and TDX sets bits.
We can surely *do* this with cc_something() helpers. It's just not as
easy as making cc_set/cc_clear().
Powered by blists - more mailing lists