lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20211202155452.jh4qnvpx52r3od67@ldmartin-desk2>
Date:   Thu, 2 Dec 2021 07:55:14 -0800
From:   Lucas De Marchi <lucas.demarchi@...el.com>
To:     Joerg Roedel <joro@...tes.org>
Cc:     x86@...nel.org, Dave Hansen <dave.hansen@...ux.intel.com>,
        Borislav Petkov <bp@...en8.de>, Ingo Molnar <mingo@...hat.com>,
        Thomas Gleixner <tglx@...utronix.de>, hpa@...or.com,
        Andy Lutomirski <luto@...nel.org>,
        Peter Zijlstra <peterz@...radead.org>,
        Tom Lendacky <thomas.lendacky@....com>,
        Brijesh Singh <brijesh.singh@....com>,
        linux-kernel@...r.kernel.org, Joerg Roedel <jroedel@...e.de>
Subject: Re: [PATCH] x86/mm: Fix PAGE_KERNEL_IO removal breakage

On Thu, Dec 02, 2021 at 03:46:46PM +0100, Joerg Roedel wrote:
>From: Joerg Roedel <jroedel@...e.de>
>
>The removal of PAGE_KERNEL_IO broke SEV-ES because it changed the
>mapping of ioremap and some fixmap areas (like the local APIC page)
>from unencrypted to encrypted. Change those mappings back to
>be unencrypted.
>
>Cc: Lucas De Marchi <lucas.demarchi@...el.com>
>Fixes: 27dff0f58bde ("x86/mm: Nuke PAGE_KERNEL_IO")
>Signed-off-by: Joerg Roedel <jroedel@...e.de>

oops, missed the fact PAGE_KERNEL had `| ENC` while PAGE_KERENL_IO
didn't have it. Thanks for the fixup.

Reviewed-by: Lucas De Marchi <lucas.demarchi@...el.com>

Lucas De Marchi

>---
> arch/x86/include/asm/fixmap.h        |  2 +-
> arch/x86/include/asm/pgtable_types.h | 21 +++++++++++----------
> arch/x86/mm/ioremap.c                |  2 +-
> 3 files changed, 13 insertions(+), 12 deletions(-)
>
>diff --git a/arch/x86/include/asm/fixmap.h b/arch/x86/include/asm/fixmap.h
>index 5e186a69db10..a2eaf265f784 100644
>--- a/arch/x86/include/asm/fixmap.h
>+++ b/arch/x86/include/asm/fixmap.h
>@@ -173,7 +173,7 @@ static inline void __set_fixmap(enum fixed_addresses idx,
>  * supported for MMIO addresses, so make sure that the memory encryption
>  * mask is not part of the page attributes.
>  */
>-#define FIXMAP_PAGE_NOCACHE PAGE_KERNEL_NOCACHE
>+#define FIXMAP_PAGE_NOCACHE PAGE_KERNEL_NOCACHE_NOENC
>
> /*
>  * Early memremap routines used for in-place encryption. The mappings created
>diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h
>index a87224767ff3..fc9b6995cb22 100644
>--- a/arch/x86/include/asm/pgtable_types.h
>+++ b/arch/x86/include/asm/pgtable_types.h
>@@ -208,16 +208,17 @@ enum page_cache_mode {
>
> #define __pgprot_mask(x)	__pgprot((x) & __default_kernel_pte_mask)
>
>-#define PAGE_KERNEL		__pgprot_mask(__PAGE_KERNEL            | _ENC)
>-#define PAGE_KERNEL_NOENC	__pgprot_mask(__PAGE_KERNEL            |    0)
>-#define PAGE_KERNEL_RO		__pgprot_mask(__PAGE_KERNEL_RO         | _ENC)
>-#define PAGE_KERNEL_EXEC	__pgprot_mask(__PAGE_KERNEL_EXEC       | _ENC)
>-#define PAGE_KERNEL_EXEC_NOENC	__pgprot_mask(__PAGE_KERNEL_EXEC       |    0)
>-#define PAGE_KERNEL_ROX		__pgprot_mask(__PAGE_KERNEL_ROX        | _ENC)
>-#define PAGE_KERNEL_NOCACHE	__pgprot_mask(__PAGE_KERNEL_NOCACHE    | _ENC)
>-#define PAGE_KERNEL_LARGE	__pgprot_mask(__PAGE_KERNEL_LARGE      | _ENC)
>-#define PAGE_KERNEL_LARGE_EXEC	__pgprot_mask(__PAGE_KERNEL_LARGE_EXEC | _ENC)
>-#define PAGE_KERNEL_VVAR	__pgprot_mask(__PAGE_KERNEL_VVAR       | _ENC)
>+#define PAGE_KERNEL			__pgprot_mask(__PAGE_KERNEL            | _ENC)
>+#define PAGE_KERNEL_NOENC		__pgprot_mask(__PAGE_KERNEL            |    0)
>+#define PAGE_KERNEL_RO			__pgprot_mask(__PAGE_KERNEL_RO         | _ENC)
>+#define PAGE_KERNEL_EXEC		__pgprot_mask(__PAGE_KERNEL_EXEC       | _ENC)
>+#define PAGE_KERNEL_EXEC_NOENC		__pgprot_mask(__PAGE_KERNEL_EXEC       |    0)
>+#define PAGE_KERNEL_ROX			__pgprot_mask(__PAGE_KERNEL_ROX        | _ENC)
>+#define PAGE_KERNEL_NOCACHE		__pgprot_mask(__PAGE_KERNEL_NOCACHE    | _ENC)
>+#define PAGE_KERNEL_NOCACHE_NOENC	__pgprot_mask(__PAGE_KERNEL_NOCACHE    |    0)
>+#define PAGE_KERNEL_LARGE		__pgprot_mask(__PAGE_KERNEL_LARGE      | _ENC)
>+#define PAGE_KERNEL_LARGE_EXEC		__pgprot_mask(__PAGE_KERNEL_LARGE_EXEC | _ENC)
>+#define PAGE_KERNEL_VVAR		__pgprot_mask(__PAGE_KERNEL_VVAR       | _ENC)
>
> #endif	/* __ASSEMBLY__ */
>
>diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
>index 3102dda4b152..4fe8d43d53bb 100644
>--- a/arch/x86/mm/ioremap.c
>+++ b/arch/x86/mm/ioremap.c
>@@ -243,7 +243,7 @@ __ioremap_caller(resource_size_t phys_addr, unsigned long size,
> 	 * make sure the memory encryption attribute is enabled in the
> 	 * resulting mapping.
> 	 */
>-	prot = PAGE_KERNEL;
>+	prot = PAGE_KERNEL_NOENC;
> 	if ((io_desc.flags & IORES_MAP_ENCRYPTED) || encrypted)
> 		prot = pgprot_encrypted(prot);
>
>-- 
>2.34.0
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ