From patchwork Thu Mar 9 14:52:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13167716 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 523AFC64EC4 for ; Thu, 9 Mar 2023 15:08:41 +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=Z1sYg3dGwX0a/qNiM7yixIjtVv0m/ckeAoeaN8M2YM4=; b=Bt8s3BXHVTS90L d5eHnwUusVeIU0fUE/Nc4mcNLHgcTCiWso3Jx/B3SjRZKjT7OQ6jLxGIkB5HDT45WC3Nt2H3bRhKo ixfLa2VyakXekmAbjOC08QiOtbfyUo1W3H7QXkWsCnpvBcD+865qKZlsF8D96VXgVnWdznNX21nIX gz7asN2rtM2gytHnW7ZbcJiZrO6z1M3qvFw2FsmX7EoyDgFciory/2g/WSCqqbXGxK/Y9Sx+Wjvnb JwT3UdzoZc90S7IhcxYIUTFJNP5RO7TxarNzlI0t0Qe/59YmtPvgBA6iwgEqwxkuAE0N+AolYoZs1 z18azn7T5KTW4k4V+yYw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1paHqy-00AmlH-Ba; Thu, 09 Mar 2023 15:06:52 +0000 Received: from mail-dbaeur03on20619.outbound.protection.outlook.com ([2a01:111:f400:fe1a::619] helo=EUR03-DBA-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1paHe0-00AhOT-NL for linux-arm-kernel@lists.infradead.org; Thu, 09 Mar 2023 14:53:28 +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=wkMk6qDdip+Re7v++g8pFUjrDidVTs4aKldZlOw7650=; b=3Krq440DTiiO+bomZukr7HHwXf5L4cvB1DfFWXJe8DcIil3AuuuSj6jkYpiSgBgBhg5P/xEn5xIMP9AkSdNf1IOYY1zwvEpksC5UNcqqbSAt9HlV3mk/fr5HxdgsIlaaBDZNl4oMfgd4dTTELZnAJ6obMD9r8iB0X1iQdOLaRto= Received: from AS9PR04CA0149.eurprd04.prod.outlook.com (2603:10a6:20b:48a::22) by DU0PR08MB8664.eurprd08.prod.outlook.com (2603:10a6:10:400::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.29; Thu, 9 Mar 2023 14:53:20 +0000 Received: from VI1EUR03FT030.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:48a:cafe::20) by AS9PR04CA0149.outlook.office365.com (2603:10a6:20b:48a::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.19 via Frontend Transport; Thu, 9 Mar 2023 14:53:19 +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 VI1EUR03FT030.mail.protection.outlook.com (100.127.144.128) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.19 via Frontend Transport; Thu, 9 Mar 2023 14:53:19 +0000 Received: ("Tessian outbound c2bcb4c18c29:v135"); Thu, 09 Mar 2023 14:53:19 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 6a55a74d6bcbccc9 X-CR-MTA-TID: 64aa7808 Received: from beea0b0e6dd2.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 50C237E5-E04D-4E9A-82A6-FB9C25BE5F60.1; Thu, 09 Mar 2023 14:53:13 +0000 Received: from EUR02-DB5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id beea0b0e6dd2.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 09 Mar 2023 14:53:13 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=J6iofLUYW99TturaCHadrsRqwp9xQCSFI2VL5/s65aaYU8f+AUXUCZ31z1/A2UvvG47aNvN1Xw62YtTY230Mv0MoKwiqFmARyH7zXLxXXqHsGWFRS6TDxj83ZzK61urkVf6Kdl88bxiJBXeGU70CyIEyzzVtsSE/R1Pv1vmkQ8aTJTJ8/g497h6YjAWnDewS1ZYMkKxBruNkmO2EMctwrYEI0L2jlDszoZLGqAskF45tlYefm3UR6zYgOTMq5Vvm1v2miN93gnW8oaCFIKVwJh4ZH0xnm0BDii0DWTNkeTplpRZ0m/pI+eCleW1EaYQfjxmithy4b43hP0vayxGLrg== 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=wkMk6qDdip+Re7v++g8pFUjrDidVTs4aKldZlOw7650=; b=RtTSllW2LZbr7Ol/TrKX6CzNXrXTUs74RGJZV67IE8AaZvBbgU2FUCfoJd+ZQNKngWvrQLQ+9mO27/0rXfH6YZjqbdkHspTRaV5VpfuWr+5mzFvPmlB2vTAzKnARXF8DuuqhdV3p71RIh74HUgdQfg29GOJ8xnUepMM42KBKjOYTuRE8ppGL99HuWyyLl83m17A2WgNZj9CeCKMFTchUQtcDutAd50uP2su0lzYk4DgssFagooJ/4M4qgJGq/CSAXYbic8mLDJFgFo504/5s8keh2GUfPjjQoF6OdFhBEfj6UPpb515aYc2CSwaENEj1FR79h3EpH1UaOsN2yjELvA== 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=wkMk6qDdip+Re7v++g8pFUjrDidVTs4aKldZlOw7650=; b=3Krq440DTiiO+bomZukr7HHwXf5L4cvB1DfFWXJe8DcIil3AuuuSj6jkYpiSgBgBhg5P/xEn5xIMP9AkSdNf1IOYY1zwvEpksC5UNcqqbSAt9HlV3mk/fr5HxdgsIlaaBDZNl4oMfgd4dTTELZnAJ6obMD9r8iB0X1iQdOLaRto= Received: from AS9PR05CA0118.eurprd05.prod.outlook.com (2603:10a6:20b:498::7) by PAXPR08MB6480.eurprd08.prod.outlook.com (2603:10a6:102:155::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.19; Thu, 9 Mar 2023 14:53:09 +0000 Received: from VI1EUR03FT059.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:498:cafe::60) by AS9PR05CA0118.outlook.office365.com (2603:10a6:20b:498::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.19 via Frontend Transport; Thu, 9 Mar 2023 14:53:09 +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 VI1EUR03FT059.mail.protection.outlook.com (100.127.144.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6178.19 via Frontend Transport; Thu, 9 Mar 2023 14:53:08 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.17; Thu, 9 Mar 2023 14:52:56 +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, 9 Mar 2023 14:52:55 +0000 From: Joey Gouly To: CC: , , , , , , , , , , Subject: [PATCH v1 14/18] arm64: reorganise PAGE_/PROT_ macros Date: Thu, 9 Mar 2023 14:52:42 +0000 Message-ID: <20230309145246.22787-15-joey.gouly@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230309145246.22787-1-joey.gouly@arm.com> References: <20230309145246.22787-1-joey.gouly@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: VI1EUR03FT059:EE_|PAXPR08MB6480:EE_|VI1EUR03FT030:EE_|DU0PR08MB8664:EE_ X-MS-Office365-Filtering-Correlation-Id: 1e602695-107d-4957-e482-08db20ae05de 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: OmO1j5EPUf3oclFGFhVMSrZcqnNSZBs3vR+9O9mLvZH8L2gn6EaKZpTYvgU2c/6cpK7jOarvHEyDNYBG/w8YHRxtWpH0ZGKPkLnlKZcDkhSn0RKz6rTou0BoETWuHNGltnSjD5/ABgTJxOV1OPN8Z/1+sORUbQ72j0PPtz/AZYH7nmilrL6nCy0gO70SwMDqrXylIz0A0Rpyg2Hnj4C+M3fyJ+h/vC+qtSAtfEjPND0QRbb+RTO7ZFhxkW/7cPMO58NYAmORc526ywWtSpzOhNdmfMfPb3CboCmfwkg5D4XCl4h3isL7K8hDyclNZ4kX45BaeYyvwlkMCllc/xVIEFkIMj06V4H60skVkjter4uO+aq/igwL/Z6kEuC9J3s1oSq1pg9CnAR7vgPFWj3squLhYT9C1mv5hdj6QxQ684AWw8nj7KxgFfhquGwdDqx/WsNYVNV1UxFcJ/AX+VS4ULkmUCgGX3r0+AV2Ih54073XPem4Bh6q2GavY9RwgoBZFYv7woEtpDhj0vWKP6PkMhCkmKhZ4zpZS2BBvGMYfAT7R06Kvv+HJil+/tyKw+X2wQNjJKCX0xmLmIQMaToczH+9fyfbBTtSfQ4fPh7DSzJkUqoETA30llA7En5aN+ZhSD+AJaYQGpJaavInV5P05TTEKJxKm9ozadDB0e7AErZiQJGIV+X9dIpGMZsrSuxcOtokViJiaX515LkOrSnxRw== 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:(13230025)(4636009)(346002)(136003)(376002)(39860400002)(396003)(451199018)(46966006)(36840700001)(36756003)(54906003)(316002)(478600001)(7696005)(5660300002)(8936002)(8676002)(2906002)(44832011)(70586007)(70206006)(4326008)(6916009)(41300700001)(81166007)(82740400003)(36860700001)(40480700001)(356005)(86362001)(186003)(2616005)(6666004)(1076003)(26005)(83380400001)(82310400005)(47076005)(336012)(426003)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB6480 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VI1EUR03FT030.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: ec074e50-c526-4c5d-c5e1-08db20adff67 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XVfGiSSVUiXNLVD96OtQtSf8WgehMI3G1JXI8f58f6rJqQMqhY3t9eSwXnsVQ9Tan6vOq1napFyl8nJXfn7+6OBhEMMKc2lr8UXCKx8hRTYZRXcUoJS/XfhXLBZHSd0qKlcQeFYJjnNK3oY4IL8jxCAw4hFxIssROECQFi7yOl+wxJTtVRQMl78U5qYB8lOgaQUSsN416pwz/bhIi+dWh/l/Hzlk7b3yogbsz1icvaXRxOkzUjRAB6vmXmPGRgmDtTGJnSbBf1UHOabd6cW5kuL9doBaGDVjY2qlcKxBMT6qLHxXNWvFSeCq2d2AYK+jsrvnyzlB38WhYio3RD5IwB6dgfvGD3Cbahsc3KWg2CJhkXhf6MzVbF/hNIqxaFbclULFURookuqUNw1bn28ZBG4dqfSn6l0RKJRr8NU3d9bdHMqVZqPupt8xz97hm6dpz4V8NmQgsA5J52sO2Kwc00QoromraJVf3azCaTzxH46Fnu6dBOrgmxfw1EN0s/QM/cnxjROeibJhvm/uMLibsuuV/7GCcrVg/5acv97kgohMfDIreRNDGn4ZIpTOvLnLurXTxE+1cbl9pz2r0lgKoYMGvj68sJTo3988M6Fsv73xYm0+jddEOQl091JzGh1fXPUb7KTJTapS1tEYAAb1+YeLVdDJMXtn6VBliPviTZF/MxVZRbVbvTeAzY7GNUXf1mJArOyH8pCFWOu0c850JA== 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:(13230025)(4636009)(376002)(346002)(39860400002)(396003)(136003)(451199018)(40470700004)(46966006)(36840700001)(4326008)(8936002)(44832011)(36756003)(82740400003)(6916009)(41300700001)(36860700001)(70206006)(70586007)(8676002)(5660300002)(2906002)(81166007)(86362001)(54906003)(6666004)(7696005)(2616005)(107886003)(478600001)(1076003)(316002)(47076005)(82310400005)(83380400001)(40480700001)(426003)(26005)(186003)(336012)(40460700003);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Mar 2023 14:53:19.6855 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1e602695-107d-4957-e482-08db20ae05de 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: VI1EUR03FT030.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB8664 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230309_065324_959971_00FC873F X-CRM114-Status: UNSURE ( 9.98 ) 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__ */