Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932338AbdLTTNO (ORCPT ); Wed, 20 Dec 2017 14:13:14 -0500 Received: from mail.skyhub.de ([5.9.137.197]:40844 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755902AbdLTTNM (ORCPT ); Wed, 20 Dec 2017 14:13:12 -0500 Date: Wed, 20 Dec 2017 20:13:01 +0100 From: Borislav Petkov To: Tom Lendacky Cc: x86@kernel.org, Brijesh Singh , linux-kernel@vger.kernel.org, Ingo Molnar , "H. Peter Anvin" , Thomas Gleixner Subject: Re: [PATCH v1 1/3] x86/mm: Centralize PMD flags in sme_encrypt_kernel() Message-ID: <20171220191301.6ak5kzs5mi6h3vvg@pd.tnic> References: <20171207233342.29646.12858.stgit@tlendack-t1.amdoffice.net> <20171207233352.29646.52076.stgit@tlendack-t1.amdoffice.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20171207233352.29646.52076.stgit@tlendack-t1.amdoffice.net> User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2032 Lines: 55 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 > --- > 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? > + > 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. Rest looks ok. -- Regards/Gruss, Boris. Good mailing practices for 400: avoid top-posting and trim the reply.