From patchwork Tue Jun 6 14:58:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13269351 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 821E1C7EE31 for ; Tue, 6 Jun 2023 15:00:21 +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=9E+heZnHvrCepXl7U2fOirlTTv/ILSQkXM6momEiPiA=; b=KggPegkaEvnXjK 8pYGwkd1fDYwt8bXJb2C1HSVjfxclVfNyQ+IBf4XtMIWXzsuqpONQ6P8/Xkza6e2aQtmYX5cg4rK8 HwSfsjV1hj5cwZaP7Inlw52lmPGu5+lT5XMFQKmIovpv5ySZwtyJtqBO9a2s9hGs5V6MXPWBw2nwK PkKfPXQVmSJKppTaKfkIwWVncZBVlbiopcAysBbVXP0CjwzuQ6hXohGqafnhKZtsF6qkqLyCiCmF6 kBygVkAb1cle/DCtVLy7w7u6SJKKiPFgpFaDoW6qAuHy62+9cMH/htOiOpB1dBNSFNoUlii0yVVtw 2oeHG/DVeTvnVJWXCOMQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q6Y9z-0028px-1T; Tue, 06 Jun 2023 14:59:47 +0000 Received: from mail-db3eur04on0612.outbound.protection.outlook.com ([2a01:111:f400:fe0c::612] helo=EUR04-DB3-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q6Y9l-0028dr-2O for linux-arm-kernel@lists.infradead.org; Tue, 06 Jun 2023 14:59:35 +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=3hO8Juy/IwyPEV95Nvl6zNp8DIo/nPP0UfKZYarNTzc=; b=ufwVfYHns6qhFwwgHe9s+19Sm/zx7fx+EOhod4pYuUoOuuIAI5HtFUaEGVPmItC7YM5Px/3Iq/hmx8hEaj0gylv1mBD61sbcSpguHZm9j5GLKKRJjOKhUq3/S0ZOA7SQzxzGSPx1AQKkMJ2O9XDcVjnYxk4E3AdPj0a/YS7fIwE= Received: from DUZPR01CA0003.eurprd01.prod.exchangelabs.com (2603:10a6:10:3c3::15) by AM7PR08MB5446.eurprd08.prod.outlook.com (2603:10a6:20b:107::11) 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:29 +0000 Received: from DBAEUR03FT060.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:3c3:cafe::f6) by DUZPR01CA0003.outlook.office365.com (2603:10a6:10:3c3::15) 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:29 +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 DBAEUR03FT060.mail.protection.outlook.com (100.127.142.238) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6477.18 via Frontend Transport; Tue, 6 Jun 2023 14:59:29 +0000 Received: ("Tessian outbound 99a3040377ca:v136"); Tue, 06 Jun 2023 14:59:29 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: fa91d2e2502222dd X-CR-MTA-TID: 64aa7808 Received: from d148a57e2fbe.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id AFAAE396-3162-49F4-8DC9-8F6C69D81E36.1; Tue, 06 Jun 2023 14:59:19 +0000 Received: from EUR03-DBA-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id d148a57e2fbe.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 06 Jun 2023 14:59:19 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=f//RM6xFFnC1khFV2xiN8HxlQMts9EdainAsKHBVEH0KcnJuQO3Vx4oy0zh2rl9Uuw0yO+pAM9qC9gKeIQ3Try3ZjzYpFLwoPkJUYLTsY01ZzCim9pITO+P5ZrEAKwT1LhWxW5aKZ502JFF+7t6Z5SydvXEADYqHnq56x9E2mh0hPCxIhU7cKAONzo67zEi0OGWRQzjwDF83x5IPMA5/0/p74XVIyUVbt9kLBL5N5YWoh2jJC0YV/hMInSAHJMOE9/WZzzhj2kSEmORYadj0LjMFtjx+X3LcB1g5KYnftaLcsKm76T8Mt/c/cCxOqT2vRDPOdk2xb+3fgVwM0k1GMA== 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=3hO8Juy/IwyPEV95Nvl6zNp8DIo/nPP0UfKZYarNTzc=; b=i/jDnr0zqvRy/V6KZpwOCOGV2NfaqlA721MPynP+rGOlhOpbFpAkppUMZx2MiYjW4mEcoO/hJl+NpsOfgSTpdRN4SIKo7A2dG63DS7BK2vyyKUF0bfSCaLGbdC68DxDzBDc1NuJFmpmMWhTneken51W7iTyI33SAsGeXi29gj7cZfHgqENv9fZGfk9IuiecFVSgUJ3iUalGGGZ+O7LIkC/G57N8GszSIDMw2Snm/eHMh40kvP1tKTAhSfg9HYzlXzdF1nypMUAB3zCUU0188fBTFaw78Ppg1+dUwfMJZW93HaoslchAIU2bhbq7gqkcI0kq998Osql7RGtqNheJ2Xg== 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=3hO8Juy/IwyPEV95Nvl6zNp8DIo/nPP0UfKZYarNTzc=; b=ufwVfYHns6qhFwwgHe9s+19Sm/zx7fx+EOhod4pYuUoOuuIAI5HtFUaEGVPmItC7YM5Px/3Iq/hmx8hEaj0gylv1mBD61sbcSpguHZm9j5GLKKRJjOKhUq3/S0ZOA7SQzxzGSPx1AQKkMJ2O9XDcVjnYxk4E3AdPj0a/YS7fIwE= Received: from AM5PR04CA0028.eurprd04.prod.outlook.com (2603:10a6:206:1::41) by AM0PR08MB5346.eurprd08.prod.outlook.com (2603:10a6:208:18b::12) 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:18 +0000 Received: from AM7EUR03FT034.eop-EUR03.prod.protection.outlook.com (2603:10a6:206:1:cafe::82) by AM5PR04CA0028.outlook.office365.com (2603:10a6:206:1::41) 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:18 +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 AM7EUR03FT034.mail.protection.outlook.com (100.127.140.87) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6477.19 via Frontend Transport; Tue, 6 Jun 2023 14:59:18 +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.23; Tue, 6 Jun 2023 14:59:09 +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:09 +0000 From: Joey Gouly To: CC: , , , , , , , , , , , Subject: [PATCH v4 16/20] arm64: enable Permission Indirection Extension (PIE) Date: Tue, 6 Jun 2023 15:58:55 +0100 Message-ID: <20230606145859.697944-17-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: AM7EUR03FT034:EE_|AM0PR08MB5346:EE_|DBAEUR03FT060:EE_|AM7PR08MB5446:EE_ X-MS-Office365-Filtering-Correlation-Id: 502a6e66-d4a2-4e37-208f-08db669ea110 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: A7BMODIA+PDgqb5ip5kH32EXlq3t4QQg7M0J9lckxIS++mCStLZSd2gkbPvshE3WzMqzCGL4m/6ZOt/w7178bzRyKAFPDBaN+lTl4KexcGXdIwexHgdggVXYihQjLWshu+OB1Gryfu57cV0ibLN3seagXh7OLkPM7/6BcLv+wuhKSAqnLZLmJTVOIXhQ4/mWtsoTnmWLnZzTmGWUmKAqoV2+FfbatLmvgsn1SijzJaN/j6uC4lRAmkjLd/tsU9BYdLIFnEvUgOn7xubpUXdrngfIyD0NBpzisQc7rUtJXmX/Uyv8chHmUZ2DWiVF4/y1S05VjgRu781jMkfp6GLFaof3euqlF047N6PwEUmNGkO87cfpxBbsTreZNBBtEynqehTeRjdqz9H7wTJ6xucnU8x/nUAP7ZimE49XLMJlXjehvRyc4MslonXVlpFlh6UcevVbfU96fIizQlMXTbKGo5wgyKRtk8DNySLhyVGYQtqR6oF4Lqcnm5h/Z8SLj6al+8AQjaspUDIoNbDhLHWoRWB2wYizYQnMbnNaAYAO1pcc+e6v8jTo5lz5/EXGyxACE0d2LKxOB+xJ83hLLsGPapPOZUA73AaMP36BC2BkW580yC+DYkQSCRDVLHji5kk0UBUVMmJoQ2ysvNpJdH3NLzT7O5TXA8+Euz8x5g6dOLfIlDMvtSI6+EkBdD6UTNUJSeLHQ9aGBDvbzqPoKqByI5RAmeKDT+jdBMtg+n4exx0AnzPhNjBLeh9dXMLTxLQ9 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)(376002)(39860400002)(346002)(396003)(451199021)(36840700001)(46966006)(26005)(1076003)(40480700001)(36756003)(36860700001)(47076005)(426003)(336012)(86362001)(82310400005)(356005)(81166007)(2616005)(186003)(82740400003)(8936002)(41300700001)(44832011)(54906003)(2906002)(478600001)(70206006)(70586007)(6916009)(8676002)(4744005)(4326008)(316002)(5660300002)(7696005)(6666004)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB5346 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT060.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 8cded64d-8a1a-4584-4fe6-08db669e9a5d X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Ldw618BQHk2xFiH8syZ1GYHaenfIlxUy6WxBNINRxLTY7F7UsxfA6n5l5bSZM4XstOzAp1OMWE4VNROf4P9XWFgm7ldOJkjaVGyRn76JJw0Lf2ZLoRqeP2uz54jvLunNuScqh429Zdi8QU7iSNN6YyGH9ShX/dAdZHHniVMRw3v3hOrkMRSkx2FH1fBzsRD0ZXdjoTlTUSy67g8O445Ri6CHipQB5yZsAGMCwY2Ntbrjldv6ohlfjDorSmi1WmL1w3LXF5xKJYls4xYdES2hdmq1mMxzuYqUtzw5H2jTeU35A0zTPaYbPCWp27hPOIN043uAkj/02tUzKhmtMlCtrKC/VLJAw15kCA61llbXr6oAXQWqww8M250/Dnr0awPq4HWxRYry1udZXk0PSfCXRSPvsRqdKWeO12s4zqnFZ6DLw66+CPv+oCPzugAaMeRjBN+hDV/piTqXIFW/IG9WcA/1wQmrx6d86Nbayab64HtZjOY80N48MQ6mBEuZl/0wa3HSCj2B0jdXm9OBR7fkn7/mIRuPCwwUj9vRl7qmgTq0WONnuQ7YI++0uVTd5ForpUXBnV9y1ytpRM6YFBum/D6G7JZq45grNLJbsrvolKo3+6mcKo6kGuynukyxCdLHeLKP0WY8BDPhCauDQwbM9XSI9x0O2xS4WEivcfIwGKjEhtjpaEQQic7g9Pp3hTnePwuUnKE71zoJtEy5Gx10Aa23YuL/zD4ue5Qv/LfbnsSnxUdcebQKvoVsc3GDTb9o 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)(376002)(39860400002)(346002)(136003)(396003)(451199021)(40470700004)(36840700001)(46966006)(47076005)(26005)(2616005)(1076003)(41300700001)(36860700001)(7696005)(6666004)(107886003)(336012)(186003)(426003)(40460700003)(478600001)(54906003)(2906002)(82740400003)(6916009)(70586007)(82310400005)(40480700001)(316002)(70206006)(81166007)(4326008)(8936002)(5660300002)(8676002)(44832011)(4744005)(86362001)(36756003);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jun 2023 14:59:29.6111 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 502a6e66-d4a2-4e37-208f-08db669ea110 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: DBAEUR03FT060.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR08MB5446 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230606_075933_800492_1A13EE53 X-CRM114-Status: UNSURE ( 7.96 ) 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 Now that the necessary changes have been made, set the Permission Indirection registers and enable the Permission Indirection Extension. Signed-off-by: Joey Gouly Cc: Catalin Marinas Cc: Will Deacon Reviewed-by: Catalin Marinas --- arch/arm64/mm/proc.S | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/arch/arm64/mm/proc.S b/arch/arm64/mm/proc.S index 9513a8d2ce0e..2baeec419f62 100644 --- a/arch/arm64/mm/proc.S +++ b/arch/arm64/mm/proc.S @@ -454,6 +454,21 @@ SYM_FUNC_START(__cpu_setup) #endif /* CONFIG_ARM64_HW_AFDBM */ msr mair_el1, mair msr tcr_el1, tcr + + mrs_s x1, SYS_ID_AA64MMFR3_EL1 + ubfx x1, x1, #ID_AA64MMFR3_EL1_S1PIE_SHIFT, #4 + cbz x1, .Lskip_indirection + + mov_q x0, PIE_E0 + msr REG_PIRE0_EL1, x0 + mov_q x0, PIE_E1 + msr REG_PIR_EL1, x0 + + mov x0, TCR2_EL1x_PIE + msr REG_TCR2_EL1, x0 + +.Lskip_indirection: + /* * Prepare SCTLR */