From patchwork Thu Apr 13 11:05:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13210144 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 7C1FAC77B6E for ; Thu, 13 Apr 2023 11:07:01 +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=yuyQmyscqe31PH m+4/IcLJ+8btg+wddL7BdrJ6z6sGYsCe6biMt9wBdUHZ4nQ82m5JBFpa2pAPYIxojR+iIenvIavCK U1LqMyV9IFd6hLR2/CXtQx2bu9i/JeA9z03pjN48n29t74HEMr/6KUkV41Zo94nLrl3WyAxRnG1o1 1aoW6lVLwKuHjgEghiKM1CkK1tY+xsfGo/jiJCQ/j/kNTndlNkOJBLxpUm80EMA3dYoXL2+JlC8AI 4E0f8NUKFVqshV1fdUndLj5dGv7pbB8mqEZwbb/lF+TAR5NnaAGnqoZypTEe+Yj1lYC9rnBBv3neE OCz406cXDkQa1IKXCv/w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pmum3-005yWp-25; Thu, 13 Apr 2023 11:05:55 +0000 Received: from mail-vi1eur05on2062d.outbound.protection.outlook.com ([2a01:111:f400:7d00::62d] helo=EUR05-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pmulp-005yNt-0W for linux-arm-kernel@lists.infradead.org; Thu, 13 Apr 2023 11:05:43 +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=75oWZrBtM6rZfvlutfUUb1TzYEMGXKqt1he9cJFquN/R5BXbZGPdYEqhzXKaItNAbYkp96F9U9aU9WyuAF4izh6Bp4XGTrm8Ye1OIYQS0RPmRxMdvFAWx7pWasD5MepCjX+SgjEY7t/qf4B+9IOeepAyv/5W9Z0RgrDcOZYMPgA= Received: from DB6PR0802CA0038.eurprd08.prod.outlook.com (2603:10a6:4:a3::24) by DB9PR08MB7583.eurprd08.prod.outlook.com (2603:10a6:10:307::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.38; Thu, 13 Apr 2023 11:05:36 +0000 Received: from DBAEUR03FT014.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:a3:cafe::41) by DB6PR0802CA0038.outlook.office365.com (2603:10a6:4:a3::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.32 via Frontend Transport; Thu, 13 Apr 2023 11:05:36 +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 DBAEUR03FT014.mail.protection.outlook.com (100.127.143.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.29 via Frontend Transport; Thu, 13 Apr 2023 11:05:36 +0000 Received: ("Tessian outbound 945aec65ec65:v136"); Thu, 13 Apr 2023 11:05:36 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 62a9f29a8b0025ac X-CR-MTA-TID: 64aa7808 Received: from c9952f8a9ded.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 7480848A-597A-48CD-A6E9-D82EE20DC23E.1; Thu, 13 Apr 2023 11:05:29 +0000 Received: from EUR02-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id c9952f8a9ded.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 13 Apr 2023 11:05:29 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jdahNCNpQ0A2zPuBV55/Of+Zr5YS0XBIx9blb0wPuPTe7e3qKJ0qEV1ddy/BUe0C3GBTHnRv5ONRJPOwgrccjz/RCITaaz2Hx2xQ2CghEftwNjuBBix2brXmt6Ge2J41hLTheH4UImgPXWor4MZhiT1OwNX7PAbEOZDuve/S945qHxHbiKr5siRrKBV3VRCfQPv2qHWHSsE36Qaeqwtg7Gq3Xeh28HRpM4mKrpoklp+hvnJAQEF7rFdABguYI7BmfdkHNErmhCkcN/KiKCcnBiL1ips1Oh7YKlqDTgKhWiRbuT3ggt/F/MHtM2jLhmX5c1IGr31qrzD6JDkOQmxZBw== 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=QzCfYB86ALs0KurIcGraOYEfzogrq7Jhhx3nDfP1EZNphqpPKFTamwEUBEAEXHXhwd4h/U+5ueDRdt2vuRppMJzEH0GH15L/n52nCqdpeuweKMFycRxKR4BY5jjVAFLWsho/7D1RDSZprj8ZBxDNK64fbEw7hCfI2qVSrH5+W++wePrnfUzJZrX1WmUMurTUb/hQS7TTKbgKtwz//Cx5K8icPVSK82qQnALJpEzn3j/vhHhaLrZsKvFLt1Ou5pbi+YGHoSDSY0UmYC9FeVRbebLw4n6Ad74/d6Vn1Omw1tHYxnZucN8WVDyMZ1qExpFJ3KKME8uJ88doTXZZ4X46Rg== 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=75oWZrBtM6rZfvlutfUUb1TzYEMGXKqt1he9cJFquN/R5BXbZGPdYEqhzXKaItNAbYkp96F9U9aU9WyuAF4izh6Bp4XGTrm8Ye1OIYQS0RPmRxMdvFAWx7pWasD5MepCjX+SgjEY7t/qf4B+9IOeepAyv/5W9Z0RgrDcOZYMPgA= Received: from AS9PR06CA0445.eurprd06.prod.outlook.com (2603:10a6:20b:49e::31) by AS8PR08MB5976.eurprd08.prod.outlook.com (2603:10a6:20b:299::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.28; Thu, 13 Apr 2023 11:05:25 +0000 Received: from AM7EUR03FT045.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:49e:cafe::d9) by AS9PR06CA0445.outlook.office365.com (2603:10a6:20b:49e::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.32 via Frontend Transport; Thu, 13 Apr 2023 11:05:25 +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 AM7EUR03FT045.mail.protection.outlook.com (100.127.140.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6298.31 via Frontend Transport; Thu, 13 Apr 2023 11:05:25 +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.17; Thu, 13 Apr 2023 11:05:20 +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.17; Thu, 13 Apr 2023 11:05:19 +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.17 via Frontend Transport; Thu, 13 Apr 2023 11:05:19 +0000 From: Joey Gouly To: CC: , , , , , , , , , , Subject: [PATCH v2 13/19] arm64: reorganise PAGE_/PROT_ macros Date: Thu, 13 Apr 2023 12:05:07 +0100 Message-ID: <20230413110513.243326-14-joey.gouly@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230413110513.243326-1-joey.gouly@arm.com> References: <20230413110513.243326-1-joey.gouly@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: AM7EUR03FT045:EE_|AS8PR08MB5976:EE_|DBAEUR03FT014:EE_|DB9PR08MB7583:EE_ X-MS-Office365-Filtering-Correlation-Id: f0fcb197-c713-45ce-f927-08db3c0f027f 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: tUnfSt0ce2AzMMzwjsK7ikM/8fY7ka3YGULDybBttmEgMMC5owm4g7C2oh2Q5gIDYAHs4I8l3GroHQbQs7VbPKC3RUqgdFGK80r3+h7MVqsP/WyV1+tEUt7hDD02qYgvMMV/2vpnp7OSyiWY1gzOHn2MVGiyv5u7bx1pBQeS7baGOY+mljpifUoIigyHw6/yyPoOvnEKLgapSWA8FjakEc+u07/7+uoo0Q8/+xJwC9MRDYcca5ltntHXQ7NKVl29yQLYBk4zmeV3zIhLuBmLZl/mFTiyuFtvqB/89U0VvCUCkFWu52pApF2v9zFub4B0jGR8R6CT3vmGrOiikKvsjvAy+uxfWdcwhIHMV4eO++omXRX4qG7aDKpf44o2Gm80zO4w2cPTE9pPA4jTkQ4NoORPpZvg5qxq6tRvYlNOVtUYzdF5WLggR0faqalqPoJuIzxvrEca5YKxWwmDyYF6Z4A5XqOnId17NOUS8Lqtd2DYWBpCClGn2JZrPsgKblriGXbFjXKDN7aHnMeMFFRwIpAbz/JKD+fUMxO0pRJvS8kNjHHOUhQlv+nsSJA9MTta8YU92K2pThvlzDjqKV2nSfNkkYuBBpoWEnwUKvLgEuQA+3TtKglDTLnMBEief2GEjRz9YT1+AicY+K+QwYztrYrZclgPnrG6zcPeFoK7NUVEKjIfmmtDeVO4z3I3W9xpD9alH7bfkf7/I2vqrxnjbRf/ERaoC0sNRjxxT8kvE7o= 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)(396003)(376002)(39860400002)(136003)(346002)(451199021)(36840700001)(40470700004)(46966006)(54906003)(36860700001)(2616005)(83380400001)(478600001)(7696005)(1076003)(40480700001)(26005)(6666004)(70586007)(6916009)(70206006)(316002)(82740400003)(4326008)(47076005)(426003)(336012)(186003)(5660300002)(44832011)(8676002)(8936002)(356005)(40460700003)(2906002)(81166007)(41300700001)(86362001)(36756003)(82310400005)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB5976 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT014.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 4756438b-3f2f-4aef-e552-08db3c0efbf9 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QlOBQj2L2gkysox9VFdlA3rF40NFY6vgBRcw3ciSLVn3nJD+UJX24Y8HPOrOhMRdZNGebe3qo9XnR/4rFd4I+B3UCATMzMM24gs+Xg8FdKrlKTua5nJGVhdGYyr+DKJtUSFEL3Hj8eTxNeUyxuHQ3dGj+Yndn5DtjG7dKxC65P07VPqVo0NGyuaEbAKtVgrZsGqaCjsOV09wH+BR664L050FmPFjmk+sxFwPO4P1nfsMNKN1mYvKAo59zDfIj5fHLUKzKMgvQFq23Qw+1LZYNB39vK1eksXXgQ2SehPiYwSLKE5P0yKA/FYWUXur1AQKJKZbpPrZs569SW4IibFcqK4ESrTgM7bgZaVYByNa6q7ts5n1iAJ9olXxNJHindrm+lBDXjhU1sKBrD7DHVGLn5Qk9hmqBdtlSyaMCAFjwEM4nNkKAy81opbFerlmIW//Zpl0wVKUtjojp5znxfub4IrmLy+AX+PcWL4lvujKkkMBXxnArtp3qM+DNaXbKWturP7ohlIvEx4C7zSeCCZT//x5nbG5Q+3tCKUJXZG17T6b2/lUJCzNLVhf+5uqnvIOKFp2TNGEoHuzgnrxfFymYH4eGCUthM+mghQv0BCzb2QGs7rvD9SXN5MWAxErev+5sr8/fqI/Qz/fCDpsmX+6UflDdf/bBhNWA3iSzYWyv2V6tRQG4m68TJOanF7lf+vPvW6BvhgsZd8RAZyhiGN4Dg== 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)(39860400002)(396003)(346002)(136003)(376002)(451199021)(36840700001)(40470700004)(46966006)(478600001)(44832011)(336012)(83380400001)(2616005)(426003)(86362001)(8936002)(70586007)(47076005)(4326008)(70206006)(5660300002)(6916009)(8676002)(2906002)(40480700001)(36756003)(82740400003)(107886003)(26005)(36860700001)(1076003)(54906003)(81166007)(316002)(82310400005)(186003)(40460700003)(7696005)(6666004)(41300700001);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Apr 2023 11:05:36.7018 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f0fcb197-c713-45ce-f927-08db3c0f027f 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: DBAEUR03FT014.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB7583 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230413_040541_380658_F141EE94 X-CRM114-Status: UNSURE ( 9.70 ) 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__ */