From patchwork Tue Jun 6 14:58:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13269355 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 010F3C77B7A for ; Tue, 6 Jun 2023 15:00:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=UAwu1+MRUBZrkHD17TAR+b6WkaZbmDMPyNQjgNRrL6o=; b=Axc7pyBB3EEQXk 6RqvHXZQRK4rEdX32bpEH1hT4F4stqSM1QhozAIHeKbBS6y6Umct8L16NluQf55qPaCLb+wnegkw/ FSZYdrjwyVPGlJAVuZbbzW3GYDu2Us//prxIC//O+pTcY92COBpOE8at7Nb5dO0JbckIk0wYJAfmp FePgP7kBforARn6ukCchADsBcUnA1OU7RkqNZxqkLAqeBQbkfOGLBNKrITR2o6qowaIi5KtB+oRNY tMg+WqgvMHpYlIaYLakl2mUMtjgJ2SL/8dIJzP7ptcThWQKao6Tlc30HzOIS7NgodQLUAe5C5/qMH qFeURFaRRMnyXzquM1PA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q6YA2-0028sI-1k; Tue, 06 Jun 2023 14:59:50 +0000 Received: from mail-am6eur05on2061a.outbound.protection.outlook.com ([2a01:111:f400:7e1b::61a] helo=EUR05-AM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q6Y9l-0028eG-32 for linux-arm-kernel@lists.infradead.org; Tue, 06 Jun 2023 14:59:38 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=NGTI0YTL6PM2JPEJg2ubM1Zrcx84uY5eFXPvMvRWQLw=; b=anu4yokopFyebdBI9crDuufb6yKv1P/njj+p2u0dyD66cjo3tpsEFEnSR7vlO7YrLaBmFeubvT+sJjjyNFJHAceW44oeXo8zZW9RKyWyY5LDceZJeP3Hg/El5JVhtbdyFZL43BsM8YeGWgfbTpOVtIVMp0ADyDOtVqivab6tRB4= Received: from AM5PR04CA0020.eurprd04.prod.outlook.com (2603:10a6:206:1::33) by DB9PR08MB6666.eurprd08.prod.outlook.com (2603:10a6:10:2a7::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.33; Tue, 6 Jun 2023 14:59:24 +0000 Received: from AM7EUR03FT034.eop-EUR03.prod.protection.outlook.com (2603:10a6:206:1:cafe::83) by AM5PR04CA0020.outlook.office365.com (2603:10a6:206:1::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.33 via Frontend Transport; Tue, 6 Jun 2023 14:59:23 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM7EUR03FT034.mail.protection.outlook.com (100.127.140.87) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6477.19 via Frontend Transport; Tue, 6 Jun 2023 14:59:23 +0000 Received: ("Tessian outbound 5154e9d36775:v136"); Tue, 06 Jun 2023 14:59:23 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 9d418b441166ed56 X-CR-MTA-TID: 64aa7808 Received: from a1264251e992.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id B1A1622B-AB05-4574-8CA2-20C782D58046.1; Tue, 06 Jun 2023 14:59:15 +0000 Received: from EUR04-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id a1264251e992.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 06 Jun 2023 14:59:15 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ldGlziOXab83pHtRWxUdUgbLnCtXuBLVUslZ29hFDv0M0iFEWcjVxWxtj1kSxDKj36aXW5D8kIulB24WEiohBy1EUmSohMadUJYwXRHaezZRLP3WxsmNsXbV3JQR5jnbk9wgAAffBbM5RthfM8v2mQxWM8nxJ3g1CFNvuRZHx0aKjioP2NuqsWCi+xazfjOuQh+HAeij0n76eEy+PqGMThiHB6QSw8xFofYPg81K9wGmQGDsa1JyYHnVQRK0If6WCP2xuSDo2CQihRPCk/vdtwTEe1PP47c/M1uAizhUxNZx6dIDJZnZI7IzezAmqzVYK8h0mBCPbaj3egn81W1s/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=NGTI0YTL6PM2JPEJg2ubM1Zrcx84uY5eFXPvMvRWQLw=; b=iGSVWmJbe7BrsSVv69V6cGubjM06/ans9gPqHd8fGKGVYuSFtz3Odmj9Iqlbe2mWldDVTJhP3GVWbGCODBUR4sNd5Kz8AmuACQ6ApJSOw16gnSkUxrwrXOA/54LNKZdfhGvJiaqNN0TTULKHK/0OaKtxdcAXFODpFL4p4h36jhny9Z4X8Gpewk93FRMundYirIFwmNBQetzoQaKCjM/ipfsYMkJm7gR1JnKlaAxo39zKpGHFCL0nv8gQDoNOlGwaSbREwe1p/sBG3mVfWUhr/sN7+olcoIXJBTGv2IhWb7M2CgxDDlYRyOXc15DriH/1b1JG9S4i5tqFyt3HBXMhzg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=lists.infradead.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=NGTI0YTL6PM2JPEJg2ubM1Zrcx84uY5eFXPvMvRWQLw=; b=anu4yokopFyebdBI9crDuufb6yKv1P/njj+p2u0dyD66cjo3tpsEFEnSR7vlO7YrLaBmFeubvT+sJjjyNFJHAceW44oeXo8zZW9RKyWyY5LDceZJeP3Hg/El5JVhtbdyFZL43BsM8YeGWgfbTpOVtIVMp0ADyDOtVqivab6tRB4= Received: from DB7PR05CA0025.eurprd05.prod.outlook.com (2603:10a6:10:36::38) by AS8PR08MB9837.eurprd08.prod.outlook.com (2603:10a6:20b:616::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.32; Tue, 6 Jun 2023 14:59:12 +0000 Received: from DBAEUR03FT061.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:36:cafe::d1) by DB7PR05CA0025.outlook.office365.com (2603:10a6:10:36::38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.32 via Frontend Transport; Tue, 6 Jun 2023 14:59:12 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; pr=C Received: from nebula.arm.com (40.67.248.234) by DBAEUR03FT061.mail.protection.outlook.com (100.127.143.28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6477.21 via Frontend Transport; Tue, 6 Jun 2023 14:59:12 +0000 Received: from AZ-NEU-EX02.Emea.Arm.com (10.251.26.5) by AZ-NEU-EX04.Arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Tue, 6 Jun 2023 14:59:09 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) by AZ-NEU-EX02.Emea.Arm.com (10.251.26.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Tue, 6 Jun 2023 14:59:08 +0000 Received: from e124191.cambridge.arm.com (10.1.197.45) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2507.23 via Frontend Transport; Tue, 6 Jun 2023 14:59:08 +0000 From: Joey Gouly To: CC: , , , , , , , , , , , Subject: [PATCH v4 13/20] arm64: reorganise PAGE_/PROT_ macros Date: Tue, 6 Jun 2023 15:58:52 +0100 Message-ID: <20230606145859.697944-14-joey.gouly@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230606145859.697944-1-joey.gouly@arm.com> References: <20230606145859.697944-1-joey.gouly@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: DBAEUR03FT061:EE_|AS8PR08MB9837:EE_|AM7EUR03FT034:EE_|DB9PR08MB6666:EE_ X-MS-Office365-Filtering-Correlation-Id: 0b3102ac-4a5d-4deb-a301-08db669e9dab x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: HXWFxMsoITBT9ZjqzXufaopPidsak16gr0DHt05k/P8kRdnYwbBmzy502qzPeJxkV2PDxIsUtva/hjLi2E7yU3Gr9db34LHYIrhccOFNDx6tpyi8epCGlznHyUsNXtaIuj5EkKsh1yNG6rFIrcuC87wY/VJQ0qUpu2vyRKNBFbbeFA0jrdZLgVbLduK/v5TOAJRAjrKyL0OQfdtLSayGU+T+Ak4HjD3ijnz+Abo4bwasSZRcc21h9RdBdIGizWfW3NAOqMTA9vnu7KZ0rGwlW9MSirVpXbNBkI2dPt+ccrc9nMRml93KVpAkV6Hv0gIRwUxBRDitFr0orFLjzj1VovS6VnMbh2yvvIH56Qy0u6+OI3AXMgEDJEcY4TLgZADSexl6EOUhKTDFA1bwrateM3rWrmFi3K7lplCnxQAz9zk3sh3RARRUmISHmElHUA7nUomp5LO84mZqs5T4ZLFEL3+gNUsywSF7vYgUjbBzNX3IcqkzzE6UmZgVgEOnMxLbc68GTvJW9bjiSaIyB9Rt1eJt0e1zFuac24t1dUzgJV/CcMVMIhZRNuuI+irNyxRhik7M3ptA//12+D9UhnVoa8+lrElfKEMer/IA7y9dQujtOvg0XxbyCjbjynt9vTGcJ59RcZFK5YEHyNmg4LG+tbzkHchA+/mEVylHQGEPHuIi9zY1f4Gc+gBwXVbZ8Jgbw6N24UEevW1xRCrzYcP3l5AnXWum9SjUpc7bBR7CeRFVP9D9ZsBDJTDoimtGT/gAZiKsWPDFH7ygNdvnxiXV+Q== X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(136003)(346002)(39860400002)(376002)(396003)(451199021)(46966006)(36840700001)(40470700004)(186003)(8936002)(8676002)(7696005)(478600001)(54906003)(1076003)(316002)(41300700001)(5660300002)(6666004)(26005)(44832011)(4326008)(70586007)(70206006)(6916009)(426003)(40460700003)(83380400001)(2906002)(2616005)(47076005)(336012)(36860700001)(356005)(81166007)(82740400003)(40480700001)(86362001)(82310400005)(36756003)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB9837 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT034.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: d76d7270-110e-44c4-eea0-08db669e96f8 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rwr6osgHRUuojNnIlTGrrqQfXCo31bpK1Qcrg4aLj49lyiH/ifrVGhNt5t60GAyBkPDRhf7JpgGh7f1qXvEQeQYY28nweRO4guXrWcaHvzQ7bKlK7vXLn0S1KLqGvINDuwDbJ2Xdg+sB+i2tqfv5gxzIdEBaJrVZiJekbRPLZnGv4NydOM+xRFb/C80Z1F/6QaHUVMOKSXCyhbc3Phwkf/t4YKfd1jNOOlbZkx2tYB4IiggN+gjB48A/4dEMPQli562GcQ2irRTNQmIGEBHSKNJRsg5DFAjCtqmw+F9HzN3l8GvULFSrDGkcXdPDk2muuhnrA0XcLbZiuRRCkN1JKdaq5x1XCD5M1dJzeLxozuq4DW96mwI9vVgxGdquAjXAGgR8ndPKiDRhmiJtKEwxqupiizLsLThZmuOhm6ecNIqL2JfQsuRjYbrQS1FkU5eK7nvTE846QXsmEKPHuE+zOqK3r+snMeBLWZKYLcpDxrWoa+KsGht1MptXC3VCv9Jz22ri1oPsrPdtqAbW3I0AzG1YjlB6ofLc+eCHyalvIUPckKSWK7YpvgwR2Ye+k7HvsRn0mckU4cyD0Y8pV6JpxGgQNjW+SvWj9M8zhQiHd45QhLUr6oCai22ocqicprwkPickBf8EPBzTNRqFEeaUmO3R9w5s7S1sS3sibTJ4stmsQlX7KbUmgh/9QDBUtiQOxUejWWpaElYpU9svTf65xK+7A6iZL93WiRNReYO1ZqxEZ0WG7N6sVfai64wBsLMO X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230028)(4636009)(136003)(39860400002)(396003)(346002)(376002)(451199021)(46966006)(36840700001)(40470700004)(40460700003)(7696005)(6666004)(83380400001)(36860700001)(186003)(336012)(36756003)(2616005)(426003)(86362001)(82310400005)(81166007)(47076005)(82740400003)(1076003)(26005)(40480700001)(107886003)(316002)(54906003)(70206006)(70586007)(8936002)(6916009)(4326008)(8676002)(5660300002)(44832011)(41300700001)(2906002)(478600001);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jun 2023 14:59:23.8413 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0b3102ac-4a5d-4deb-a301-08db669e9dab X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AM7EUR03FT034.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB6666 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230606_075934_141302_B4A51F9D X-CRM114-Status: UNSURE ( 9.62 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Make these macros available to assembly code, so they can be re-used by the PIE initialisation code. This involves adding some extra macros, prepended with _ that are the raw values not `pgprot` values. A dummy value for PTE_MAYBE_NG is also provided, for use in assembly. Signed-off-by: Joey Gouly Cc: Catalin Marinas Cc: Will Deacon Cc: Mark Rutland Reviewed-by: Catalin Marinas --- arch/arm64/include/asm/pgtable-prot.h | 72 ++++++++++++++++----------- 1 file changed, 44 insertions(+), 28 deletions(-) diff --git a/arch/arm64/include/asm/pgtable-prot.h b/arch/arm64/include/asm/pgtable-prot.h index d26d0b427c0a..a45af0a22b25 100644 --- a/arch/arm64/include/asm/pgtable-prot.h +++ b/arch/arm64/include/asm/pgtable-prot.h @@ -27,6 +27,40 @@ */ #define PMD_PRESENT_INVALID (_AT(pteval_t, 1) << 59) /* only when !PMD_SECT_VALID */ +#define _PROT_DEFAULT (PTE_TYPE_PAGE | PTE_AF | PTE_SHARED) +#define _PROT_SECT_DEFAULT (PMD_TYPE_SECT | PMD_SECT_AF | PMD_SECT_S) + +#define PROT_DEFAULT (_PROT_DEFAULT | PTE_MAYBE_NG) +#define PROT_SECT_DEFAULT (_PROT_SECT_DEFAULT | PMD_MAYBE_NG) + +#define PROT_DEVICE_nGnRnE (PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_WRITE | PTE_ATTRINDX(MT_DEVICE_nGnRnE)) +#define PROT_DEVICE_nGnRE (PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_WRITE | PTE_ATTRINDX(MT_DEVICE_nGnRE)) +#define PROT_NORMAL_NC (PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_WRITE | PTE_ATTRINDX(MT_NORMAL_NC)) +#define PROT_NORMAL (PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_WRITE | PTE_ATTRINDX(MT_NORMAL)) +#define PROT_NORMAL_TAGGED (PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_WRITE | PTE_ATTRINDX(MT_NORMAL_TAGGED)) + +#define PROT_SECT_DEVICE_nGnRE (PROT_SECT_DEFAULT | PMD_SECT_PXN | PMD_SECT_UXN | PMD_ATTRINDX(MT_DEVICE_nGnRE)) +#define PROT_SECT_NORMAL (PROT_SECT_DEFAULT | PMD_SECT_PXN | PMD_SECT_UXN | PTE_WRITE | PMD_ATTRINDX(MT_NORMAL)) +#define PROT_SECT_NORMAL_EXEC (PROT_SECT_DEFAULT | PMD_SECT_UXN | PMD_ATTRINDX(MT_NORMAL)) + +#define _PAGE_DEFAULT (_PROT_DEFAULT | PTE_ATTRINDX(MT_NORMAL)) + +#define _PAGE_KERNEL (PROT_NORMAL) +#define _PAGE_KERNEL_RO ((PROT_NORMAL & ~PTE_WRITE) | PTE_RDONLY) +#define _PAGE_KERNEL_ROX ((PROT_NORMAL & ~(PTE_WRITE | PTE_PXN)) | PTE_RDONLY) +#define _PAGE_KERNEL_EXEC (PROT_NORMAL & ~PTE_PXN) +#define _PAGE_KERNEL_EXEC_CONT ((PROT_NORMAL & ~PTE_PXN) | PTE_CONT) + +#define _PAGE_SHARED (_PAGE_DEFAULT | PTE_USER | PTE_RDONLY | PTE_NG | PTE_PXN | PTE_UXN | PTE_WRITE) +#define _PAGE_SHARED_EXEC (_PAGE_DEFAULT | PTE_USER | PTE_RDONLY | PTE_NG | PTE_PXN | PTE_WRITE) +#define _PAGE_READONLY (_PAGE_DEFAULT | PTE_USER | PTE_RDONLY | PTE_NG | PTE_PXN | PTE_UXN) +#define _PAGE_READONLY_EXEC (_PAGE_DEFAULT | PTE_USER | PTE_RDONLY | PTE_NG | PTE_PXN) +#define _PAGE_EXECONLY (_PAGE_DEFAULT | PTE_RDONLY | PTE_NG | PTE_PXN) + +#ifdef __ASSEMBLY__ +#define PTE_MAYBE_NG 0 +#endif + #ifndef __ASSEMBLY__ #include @@ -34,9 +68,6 @@ extern bool arm64_use_ng_mappings; -#define _PROT_DEFAULT (PTE_TYPE_PAGE | PTE_AF | PTE_SHARED) -#define _PROT_SECT_DEFAULT (PMD_TYPE_SECT | PMD_SECT_AF | PMD_SECT_S) - #define PTE_MAYBE_NG (arm64_use_ng_mappings ? PTE_NG : 0) #define PMD_MAYBE_NG (arm64_use_ng_mappings ? PMD_SECT_NG : 0) @@ -50,26 +81,11 @@ extern bool arm64_use_ng_mappings; #define PTE_MAYBE_GP 0 #endif -#define PROT_DEFAULT (_PROT_DEFAULT | PTE_MAYBE_NG) -#define PROT_SECT_DEFAULT (_PROT_SECT_DEFAULT | PMD_MAYBE_NG) - -#define PROT_DEVICE_nGnRnE (PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_WRITE | PTE_ATTRINDX(MT_DEVICE_nGnRnE)) -#define PROT_DEVICE_nGnRE (PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_WRITE | PTE_ATTRINDX(MT_DEVICE_nGnRE)) -#define PROT_NORMAL_NC (PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_WRITE | PTE_ATTRINDX(MT_NORMAL_NC)) -#define PROT_NORMAL (PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_WRITE | PTE_ATTRINDX(MT_NORMAL)) -#define PROT_NORMAL_TAGGED (PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_WRITE | PTE_ATTRINDX(MT_NORMAL_TAGGED)) - -#define PROT_SECT_DEVICE_nGnRE (PROT_SECT_DEFAULT | PMD_SECT_PXN | PMD_SECT_UXN | PMD_ATTRINDX(MT_DEVICE_nGnRE)) -#define PROT_SECT_NORMAL (PROT_SECT_DEFAULT | PMD_SECT_PXN | PMD_SECT_UXN | PTE_WRITE | PMD_ATTRINDX(MT_NORMAL)) -#define PROT_SECT_NORMAL_EXEC (PROT_SECT_DEFAULT | PMD_SECT_UXN | PMD_ATTRINDX(MT_NORMAL)) - -#define _PAGE_DEFAULT (_PROT_DEFAULT | PTE_ATTRINDX(MT_NORMAL)) - -#define PAGE_KERNEL __pgprot(PROT_NORMAL) -#define PAGE_KERNEL_RO __pgprot((PROT_NORMAL & ~PTE_WRITE) | PTE_RDONLY) -#define PAGE_KERNEL_ROX __pgprot((PROT_NORMAL & ~(PTE_WRITE | PTE_PXN)) | PTE_RDONLY) -#define PAGE_KERNEL_EXEC __pgprot(PROT_NORMAL & ~PTE_PXN) -#define PAGE_KERNEL_EXEC_CONT __pgprot((PROT_NORMAL & ~PTE_PXN) | PTE_CONT) +#define PAGE_KERNEL __pgprot(_PAGE_KERNEL) +#define PAGE_KERNEL_RO __pgprot(_PAGE_KERNEL_RO) +#define PAGE_KERNEL_ROX __pgprot(_PAGE_KERNEL_ROX) +#define PAGE_KERNEL_EXEC __pgprot(_PAGE_KERNEL_EXEC) +#define PAGE_KERNEL_EXEC_CONT __pgprot(_PAGE_KERNEL_EXEC_CONT) #define PAGE_S2_MEMATTR(attr, has_fwb) \ ({ \ @@ -83,11 +99,11 @@ extern bool arm64_use_ng_mappings; #define PAGE_NONE __pgprot(((_PAGE_DEFAULT) & ~PTE_VALID) | PTE_PROT_NONE | PTE_RDONLY | PTE_NG | PTE_PXN | PTE_UXN) /* shared+writable pages are clean by default, hence PTE_RDONLY|PTE_WRITE */ -#define PAGE_SHARED __pgprot(_PAGE_DEFAULT | PTE_USER | PTE_RDONLY | PTE_NG | PTE_PXN | PTE_UXN | PTE_WRITE) -#define PAGE_SHARED_EXEC __pgprot(_PAGE_DEFAULT | PTE_USER | PTE_RDONLY | PTE_NG | PTE_PXN | PTE_WRITE) -#define PAGE_READONLY __pgprot(_PAGE_DEFAULT | PTE_USER | PTE_RDONLY | PTE_NG | PTE_PXN | PTE_UXN) -#define PAGE_READONLY_EXEC __pgprot(_PAGE_DEFAULT | PTE_USER | PTE_RDONLY | PTE_NG | PTE_PXN) -#define PAGE_EXECONLY __pgprot(_PAGE_DEFAULT | PTE_RDONLY | PTE_NG | PTE_PXN) +#define PAGE_SHARED __pgprot(_PAGE_SHARED) +#define PAGE_SHARED_EXEC __pgprot(_PAGE_SHARED_EXEC) +#define PAGE_READONLY __pgprot(_PAGE_READONLY) +#define PAGE_READONLY_EXEC __pgprot(_PAGE_READONLY_EXEC) +#define PAGE_EXECONLY __pgprot(_PAGE_EXECONLY) #endif /* __ASSEMBLY__ */