mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Lendacky, Thomas" <Thomas.Lendacky@amd.com>
To: Borislav Petkov <bp@alien8.de>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"x86@kernel.org" <x86@kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	Andy Lutomirski <luto@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Baoquan He <bhe@redhat.com>, Lianbo Jiang <lijiang@redhat.com>
Subject: Re: [PATCH v2 2/2] x86/mm: Create an SME workarea in the kernel for early encryption
Date: Tue, 18 Jun 2019 01:49:13 +0000	[thread overview]
Message-ID: <9e7e1757-2f2f-ae34-5b31-cca5e164a6a9@amd.com> (raw)
In-Reply-To: <20190617110241.GH27127@zn.tnic>

On 6/17/19 6:02 AM, Borislav Petkov wrote:
> On Fri, Jun 14, 2019 at 09:15:19PM +0000, Lendacky, Thomas wrote:
>> diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
>> index ca2252ca6ad7..a7aa65b44c71 100644
>> --- a/arch/x86/kernel/vmlinux.lds.S
>> +++ b/arch/x86/kernel/vmlinux.lds.S
>> @@ -387,6 +387,30 @@ SECTIONS
>>  	. = ALIGN(PAGE_SIZE);		/* keep VO_INIT_SIZE page aligned */
>>  	_end = .;
>>  
>> +#ifdef CONFIG_AMD_MEM_ENCRYPT
>> +	/*
>> +	 * SME workarea section: Lives outside of the kernel proper (_text -
>> +	 * _end) for performing in-place encryption of the kernel during boot.
>> +	 *
>> +	 * Resides after _end because even though the .brk section is after
>> +	 * __end_of_kernel_reserve, the .brk section is later reserved as a
>> +	 * part of the kernel. It is used in very early boot code and not
>> +	 * needed after that, so it is located after __end_of_kernel_reserve
>> +	 * so that it will be discarded and become part of the available
>> +	 * memory.
>> +	 *
>> +	 * Resides on a 2MB boundary to simplify the pagetable setup used for
>> +	 * the encryption.
>> +	 */
>> +	. = ALIGN(HPAGE_SIZE);
>> +	.sme : AT(ADDR(.sme) - LOAD_OFFSET) {
> 
> Should we call that section something more generic as
> 
> 	.early_scratch
> 
> or so?
> 
> Someone else might need something like that too, in the future...

Whoever uses it in the future could rename it if desired.  But I can do
that now. Is there a preferred name?  I can leave it as .early_scratch
or .early_workarea.

> 
> Also, the DISCARDS sections do get freed at runtime so why not make it
> part of the DISCARD section...?

I think it's easier to show the alignment requirements that SME has for
this section by having it be its own section.

> 
>> +		__sme_begin = .;
>> +		*(.sme)
>> +		. = ALIGN(HPAGE_SIZE);
>> +		__sme_end = .;
>> +	}
>> +#endif
>> +
>>  	STABS_DEBUG
>>  	DWARF_DEBUG
>>  
>> diff --git a/arch/x86/mm/mem_encrypt_identity.c b/arch/x86/mm/mem_encrypt_identity.c
>> index 4aa9b1480866..c55c2ec8fb12 100644
>> --- a/arch/x86/mm/mem_encrypt_identity.c
>> +++ b/arch/x86/mm/mem_encrypt_identity.c
>> @@ -73,6 +73,19 @@ struct sme_populate_pgd_data {
>>  	unsigned long vaddr_end;
>>  };
>>  
>> +/*
>> + * This work area lives in the .sme section, which lives outside of
>> + * the kernel proper. It is sized to hold the intermediate copy buffer
>> + * and more than enough pagetable pages.
>> + *
>> + * By using this section, the kernel can be encrypted in place and we
> 
> replace that "we" with an impartial passive formulation.

Ok.

> 
> Other than that, I like the commenting, very helpful!

I'll send out a V3 with the comments addressed (after giving a bit of time
for name suggestions).

Thanks,
Tom

> 
> Thx.
> 

  reply	other threads:[~2019-06-18  1:49 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-14 21:15 [PATCH 0/2] x86: SME: Kexec/kdump memory loading fix Lendacky, Thomas
2019-06-14 21:15 ` [PATCH v2 1/2] x86/mm: Identify the end of the kernel area to be reserved Lendacky, Thomas
2019-06-14 22:06   ` Dave Hansen
2019-06-16 12:03   ` lijiang
2019-06-17  1:54   ` Baoquan He
2019-06-17 10:47   ` Borislav Petkov
2019-06-18  1:43     ` Lendacky, Thomas
2019-06-18  9:37       ` Borislav Petkov
2019-06-14 21:15 ` [PATCH v2 2/2] x86/mm: Create an SME workarea in the kernel for early encryption Lendacky, Thomas
2019-06-17 11:02   ` Borislav Petkov
2019-06-18  1:49     ` Lendacky, Thomas [this message]
2019-06-18 10:11       ` Borislav Petkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9e7e1757-2f2f-ae34-5b31-cca5e164a6a9@amd.com \
    --to=thomas.lendacky@amd.com \
    --cc=bhe@redhat.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=lijiang@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®