Re: [PATCH v2] x86/sme: Explicitly map new EFI memmap table as encrypted

From: Tom Lendacky
Date: Fri Dec 03 2021 - 11:22:15 EST


On 12/3/21 4:30 AM, Ard Biesheuvel wrote:
On Wed, 1 Dec 2021 at 15:06, Tom Lendacky <thomas.lendacky@xxxxxxx> wrote:

On 10/27/21 12:04 PM, Tom Lendacky wrote:


On 10/27/21 11:59 AM, Ard Biesheuvel wrote:
On Wed, 27 Oct 2021 at 18:56, Borislav Petkov <bp@xxxxxxxxx> wrote:

On Wed, Oct 27, 2021 at 05:14:35PM +0200, Ard Biesheuvel wrote:
I could take it, but since it will ultimately go through -tip anyway,
perhaps better if they just take it directly? (This will change after
the next -rc1 though)

Boris?

Yeah, I'm being told this is not urgent enough to rush in now so you
could queue it into your fixes branch for 5.16 once -rc1 is out and send
it to Linus then. The stable tag is just so it gets backported to the
respective trees.

But if you prefer I should take it, then I can queue it after -rc1.
It'll boil down to the same thing though.


No, in that case, I can take it myself.

Tom, does that work for you?

Yup, that works for me. Thanks guys!

I don't see this in any tree yet, so just a gentle reminder in case it
dropped off the radar.


Apologies for the delay, I've pushed this out to -next now.

Before I send it to Linus, can you please confirm (for my peace of
mind) how this only affects systems that have memory encryption
available and enabled in the first place?

Certainly.

An early_memremap() call uses the FIXMAP_PAGE_NORMAL protection value for performing the mapping. Prior to performing the actual mapping though, a call to early_memremap_pgprot_adjust() is made to possibly alter the protection value, but only if memory encryption is active.

Changing the call to early_memremap_prot() and providing pgprot_encrypted(FIXMAP_PAGE_NORMAL) as the protection value results in an equivalent call to early_memremap() when memory encryption is not active. This is because the pgprot_encrypted() is, in effect, a NOP when memory encryption is not active.

So when memory encryption is not available or active, the result of an early_memremap_prot() call with a protection value of pgprot_encrypted(FIXMAP_PAGE_NORMAL) is equivalent to an early_memremap() call.

Let me know if that answers your question.

Thanks,
Tom