From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B0508C433EF for ; Mon, 18 Jul 2022 00:19:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233130AbiGRATQ (ORCPT ); Sun, 17 Jul 2022 20:19:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233242AbiGRASM (ORCPT ); Sun, 17 Jul 2022 20:18:12 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1857913E13 for ; Sun, 17 Jul 2022 17:17:38 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id AA84E60F0B for ; Mon, 18 Jul 2022 00:17:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F353DC341C0; Mon, 18 Jul 2022 00:17:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1658103457; bh=rMlKCuMAZMlqg39xcz15ZLPdEi0foz7FsTtjet41IvE=; h=Date:To:From:Subject:From; b=SckBs0CS2K239oiVjgKXjdlrNXzmZajeSMSse80Bp+8A0rf8qwJmRd2GYpp4LYnim Af9nr4E8dZ+X8TcyxWKc4NdmD2HCcR9R6LN5BU7ybJFvRZ2IVhf/N4hsA6NOY5TubB QarP1rXi8AlJAKaneqy9cbeEzZZ+Krlu35b+wqYE= Date: Sun, 17 Jul 2022 17:17:36 -0700 To: mm-commits@vger.kernel.org, ysato@users.sourceforge.jp, will@kernel.org, vgupta@kernel.org, tsbogend@alpha.franken.de, tglx@linutronix.de, shorne@gmail.com, sam@ravnborg.org, rth@twiddle.net, paul.walmsley@sifive.com, paulus@samba.org, palmer@dabbelt.com, npiggin@gmail.com, mpe@ellerman.id.au, monstr@monstr.eu, mingo@redhat.com, linux@armlinux.org.uk, kernel@xen0n.name, jonas@southpole.se, jdike@addtoit.com, James.Bottomley@HansenPartnership.com, hch@lst.de, hch@infradead.org, hca@linux.ibm.com, guoren@kernel.org, gor@linux.ibm.com, geert@linux-m68k.org, dinguyen@kernel.org, davem@davemloft.net, dalias@libc.org, chris@zankel.net, christophe.leroy@csgroup.eu, chenhuacai@kernel.org, catalin.marinas@arm.com, bcain@quicinc.com, arnd@arndb.de, anshuman.khandual@arm.com, akpm@linux-foundation.org From: Andrew Morton Subject: [merged mm-stable] x86-mm-move-protection_map-inside-the-platform.patch removed from -mm tree Message-Id: <20220718001736.F353DC341C0@smtp.kernel.org> Precedence: bulk Reply-To: linux-kernel@vger.kernel.org List-ID: X-Mailing-List: mm-commits@vger.kernel.org The quilt patch titled Subject: x86/mm: move protection_map[] inside the platform has been removed from the -mm tree. Its filename was x86-mm-move-protection_map-inside-the-platform.patch This patch was dropped because it was merged into the mm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm ------------------------------------------------------ From: Anshuman Khandual Subject: x86/mm: move protection_map[] inside the platform Date: Mon, 11 Jul 2022 12:35:40 +0530 This moves protection_map[] inside the platform and makes it a static. This also defines a helper function add_encrypt_protection_map() that can update the protection_map[] array with pgprot_encrypted(). Link: https://lkml.kernel.org/r/20220711070600.2378316-7-anshuman.khandual@arm.com Signed-off-by: Anshuman Khandual Reviewed-by: Christoph Hellwig Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Arnd Bergmann Cc: Brian Cain Cc: Catalin Marinas Cc: Christophe Leroy Cc: Christoph Hellwig Cc: Chris Zankel Cc: "David S. Miller" Cc: Dinh Nguyen Cc: Geert Uytterhoeven Cc: Guo Ren Cc: Heiko Carstens Cc: Huacai Chen Cc: "James E.J. Bottomley" Cc: Jeff Dike Cc: Jonas Bonn Cc: Michael Ellerman Cc: Michal Simek Cc: Nicholas Piggin Cc: Palmer Dabbelt Cc: Paul Mackerras Cc: Paul Walmsley Cc: Richard Henderson Cc: Rich Felker Cc: Russell King Cc: Sam Ravnborg Cc: Stafford Horne Cc: Thomas Bogendoerfer Cc: Vasily Gorbik Cc: Vineet Gupta Cc: WANG Xuerui Cc: Will Deacon Cc: Yoshinori Sato Signed-off-by: Andrew Morton --- arch/x86/include/asm/mem_encrypt.h | 2 + arch/x86/include/asm/pgtable_types.h | 19 ---------------- arch/x86/mm/mem_encrypt_amd.c | 6 +---- arch/x86/mm/pgprot.c | 28 +++++++++++++++++++++++++ 4 files changed, 32 insertions(+), 23 deletions(-) --- a/arch/x86/include/asm/mem_encrypt.h~x86-mm-move-protection_map-inside-the-platform +++ a/arch/x86/include/asm/mem_encrypt.h @@ -89,6 +89,8 @@ static inline void mem_encrypt_free_decr /* Architecture __weak replacement functions */ void __init mem_encrypt_init(void); +void add_encrypt_protection_map(void); + /* * The __sme_pa() and __sme_pa_nodebug() macros are meant for use when * writing to or comparing values from the cr3 register. Having the --- a/arch/x86/include/asm/pgtable_types.h~x86-mm-move-protection_map-inside-the-platform +++ a/arch/x86/include/asm/pgtable_types.h @@ -230,25 +230,6 @@ enum page_cache_mode { #endif /* __ASSEMBLY__ */ -/* xwr */ -#define __P000 PAGE_NONE -#define __P001 PAGE_READONLY -#define __P010 PAGE_COPY -#define __P011 PAGE_COPY -#define __P100 PAGE_READONLY_EXEC -#define __P101 PAGE_READONLY_EXEC -#define __P110 PAGE_COPY_EXEC -#define __P111 PAGE_COPY_EXEC - -#define __S000 PAGE_NONE -#define __S001 PAGE_READONLY -#define __S010 PAGE_SHARED -#define __S011 PAGE_SHARED -#define __S100 PAGE_READONLY_EXEC -#define __S101 PAGE_READONLY_EXEC -#define __S110 PAGE_SHARED_EXEC -#define __S111 PAGE_SHARED_EXEC - /* * early identity mapping pte attrib macros. */ --- a/arch/x86/mm/mem_encrypt_amd.c~x86-mm-move-protection_map-inside-the-platform +++ a/arch/x86/mm/mem_encrypt_amd.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -486,8 +487,6 @@ void __init early_set_mem_enc_dec_hyperc void __init sme_early_init(void) { - unsigned int i; - if (!sme_me_mask) return; @@ -496,8 +495,7 @@ void __init sme_early_init(void) __supported_pte_mask = __sme_set(__supported_pte_mask); /* Update the protection map with memory encryption mask */ - for (i = 0; i < ARRAY_SIZE(protection_map); i++) - protection_map[i] = pgprot_encrypted(protection_map[i]); + add_encrypt_protection_map(); x86_platform.guest.enc_status_change_prepare = amd_enc_status_change_prepare; x86_platform.guest.enc_status_change_finish = amd_enc_status_change_finish; --- a/arch/x86/mm/pgprot.c~x86-mm-move-protection_map-inside-the-platform +++ a/arch/x86/mm/pgprot.c @@ -3,6 +3,34 @@ #include #include #include +#include + +static pgprot_t protection_map[16] __ro_after_init = { + [VM_NONE] = PAGE_NONE, + [VM_READ] = PAGE_READONLY, + [VM_WRITE] = PAGE_COPY, + [VM_WRITE | VM_READ] = PAGE_COPY, + [VM_EXEC] = PAGE_READONLY_EXEC, + [VM_EXEC | VM_READ] = PAGE_READONLY_EXEC, + [VM_EXEC | VM_WRITE] = PAGE_COPY_EXEC, + [VM_EXEC | VM_WRITE | VM_READ] = PAGE_COPY_EXEC, + [VM_SHARED] = PAGE_NONE, + [VM_SHARED | VM_READ] = PAGE_READONLY, + [VM_SHARED | VM_WRITE] = PAGE_SHARED, + [VM_SHARED | VM_WRITE | VM_READ] = PAGE_SHARED, + [VM_SHARED | VM_EXEC] = PAGE_READONLY_EXEC, + [VM_SHARED | VM_EXEC | VM_READ] = PAGE_READONLY_EXEC, + [VM_SHARED | VM_EXEC | VM_WRITE] = PAGE_SHARED_EXEC, + [VM_SHARED | VM_EXEC | VM_WRITE | VM_READ] = PAGE_SHARED_EXEC +}; + +void add_encrypt_protection_map(void) +{ + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(protection_map); i++) + protection_map[i] = pgprot_encrypted(protection_map[i]); +} pgprot_t vm_get_page_prot(unsigned long vm_flags) { _ Patches currently in -mm which might be from anshuman.khandual@arm.com are