From: Tom Lendacky <thomas.lendacky@amd.com>
To: Borislav Petkov <bp@alien8.de>
Cc: x86@kernel.org, Brijesh Singh <brijesh.singh@amd.com>,
linux-kernel@vger.kernel.org, Ingo Molnar <mingo@redhat.com>,
"H. Peter Anvin" <hpa@zytor.com>,
Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH v1 1/3] x86/mm: Centralize PMD flags in sme_encrypt_kernel()
Date: Wed, 20 Dec 2017 13:59:15 -0600 [thread overview]
Message-ID: <00139399-780e-4d63-f43d-ff0e71db9440@amd.com> (raw)
In-Reply-To: <20171220191301.6ak5kzs5mi6h3vvg@pd.tnic>
On 12/20/2017 1:13 PM, Borislav Petkov wrote:
> On Thu, Dec 07, 2017 at 05:33:52PM -0600, Tom Lendacky wrote:
>> In preparation for encrypting more than just the kernel during early
>> boot processing, centralize the use of the PMD flag settings based
>> on the type of mapping desired. When 4KB aligned encryption is added,
>> this will allow either PTE flags or large page PMD flags to be used
>> without requiring the caller to adjust.
>>
>> Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
>> ---
>> arch/x86/mm/mem_encrypt.c | 109 +++++++++++++++++++++++++--------------------
>> 1 file changed, 60 insertions(+), 49 deletions(-)
>>
>> diff --git a/arch/x86/mm/mem_encrypt.c b/arch/x86/mm/mem_encrypt.c
>> index d9a9e9f..2d8404b 100644
>> --- a/arch/x86/mm/mem_encrypt.c
>> +++ b/arch/x86/mm/mem_encrypt.c
>> @@ -464,6 +464,8 @@ void swiotlb_set_mem_attributes(void *vaddr, unsigned long size)
>> set_memory_decrypted((unsigned long)vaddr, size >> PAGE_SHIFT);
>> }
>>
>> +static void *pgtable_area;
>
> Ewww, a global variable which gets manipulated by functions. Can we not
> do that pls?
>
> sme_populate_pgd() used to return it. Why change that?
It was starting to get pretty hairy with all the parameters and what was
needed to be returned when the second patch was introduced. I'll look at
what I can do to avoid the global, maybe pass in the address of the
variable for updating within the function or combining the parameters into
a struct.
>
>> +
>> static void __init sme_clear_pgd(pgd_t *pgd_base, unsigned long start,
>> unsigned long end)
>> {
>> @@ -484,10 +486,16 @@ static void __init sme_clear_pgd(pgd_t *pgd_base, unsigned long start,
>> #define PGD_FLAGS _KERNPG_TABLE_NOENC
>> #define P4D_FLAGS _KERNPG_TABLE_NOENC
>> #define PUD_FLAGS _KERNPG_TABLE_NOENC
>> -#define PMD_FLAGS (__PAGE_KERNEL_LARGE_EXEC & ~_PAGE_GLOBAL)
>>
>> -static void __init *sme_populate_pgd(pgd_t *pgd_base, void *pgtable_area,
>> - unsigned long vaddr, pmdval_t pmd_val)
>> +#define PMD_FLAGS_LARGE (__PAGE_KERNEL_LARGE_EXEC & ~_PAGE_GLOBAL)
>> +
>> +#define PMD_FLAGS_DEC PMD_FLAGS_LARGE
>> +#define PMD_FLAGS_DEC_WP ((PMD_FLAGS_DEC & ~_PAGE_CACHE_MASK) | \
>> + (_PAGE_PAT | _PAGE_PWT))
>> +#define PMD_FLAGS_ENC (PMD_FLAGS_LARGE | _PAGE_ENC)
>
> Align vertically.
Ok
Thanks,
Tom
>
> Rest looks ok.
>
next prev parent reply other threads:[~2017-12-20 19:59 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-07 23:33 [PATCH v1 0/3] x86: SME: BSP/SME microcode update fix Tom Lendacky
2017-12-07 23:33 ` [PATCH v1 1/3] x86/mm: Centralize PMD flags in sme_encrypt_kernel() Tom Lendacky
2017-12-20 19:13 ` Borislav Petkov
2017-12-20 19:59 ` Tom Lendacky [this message]
2017-12-07 23:34 ` [PATCH v1 2/3] x86/mm: Prepare sme_encrypt_kernel() for PAGE aligned encryption Tom Lendacky
2017-12-21 12:58 ` Borislav Petkov
2017-12-21 16:35 ` Tom Lendacky
2017-12-07 23:34 ` [PATCH v1 3/3] x86/mm: Encrypt the initrd earlier for BSP microcode update Tom Lendacky
2017-12-21 14:49 ` Borislav Petkov
2017-12-21 16:48 ` Tom Lendacky
2017-12-21 17:13 ` 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=00139399-780e-4d63-f43d-ff0e71db9440@amd.com \
--to=thomas.lendacky@amd.com \
--cc=bp@alien8.de \
--cc=brijesh.singh@amd.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--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®