From patchwork Thu Apr 13 11:05:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13210149 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 A91B0C77B61 for ; Thu, 13 Apr 2023 11:07: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=RCTVjMKNUm6NtzL8/ZSMBSdSTh8wUgFRMgZIStc9PPc=; b=QLXd6mCFhDInmL VFiiaDi4R2VEHXoz9YmBJKLZ2dt02m/MOIKkkN5wYnBnf4tYZVMQTUPye1yIcQCpsaCCy87bh3wkc J1hDiAHGlatgvsZRqvuBjC4rjU/aCxAtLZSXmKIHQ6Q5YgvSqXhXGs5a5NJcSwJMQlHD/JFVZ0DVx 9TuVmdyPJUhV3fEsGtsKR+tQdHHytKZcQGYJvh4/YUHvpCgaNqSZZSWCGwBjw3KTdhuV3nZe85QPL pDnzam6jtBEBPAsXhdUesafsPQ6bkYpGBye8wjNjIbrMfylxnmGiU3uX0+5F0sSfTO8mzWZXl+QKj ILJBz91tMyxhrRUd+uVg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pmumu-005zAm-1Q; Thu, 13 Apr 2023 11:06:48 +0000 Received: from mail-vi1eur05on20612.outbound.protection.outlook.com ([2a01:111:f400:7d00::612] helo=EUR05-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pmulz-005yRi-35 for linux-arm-kernel@lists.infradead.org; Thu, 13 Apr 2023 11:05:53 +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=2PkvxGMwAh7TXnG6EpHIgjGW4tOcTdrH8C0yGwIB5Zc=; b=aq+poyT0d6CX1hz57vDq8hcnlb3v31KgEqhJvXPJF4GaFz7OfZIF5351ctYtk2a33wW6s+qd8El6FzD/qqJoL8ccASTSeYYhwIDQWTOJUDdO4391zPzgsOBAtQTL/8uQAW4tHLXGC7h9pnLOgMnQ0giQEZZfpzudYGUGB5Kv72A= Received: from DB6PR1001CA0026.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:4:55::12) by AS2PR08MB9426.eurprd08.prod.outlook.com (2603:10a6:20b:5ea::22) 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 DBAEUR03FT033.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:55:cafe::b) by DB6PR1001CA0026.outlook.office365.com (2603:10a6:4:55::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.30 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 DBAEUR03FT033.mail.protection.outlook.com (100.127.142.251) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.31 via Frontend Transport; Thu, 13 Apr 2023 11:05:36 +0000 Received: ("Tessian outbound 8b05220b4215:v136"); Thu, 13 Apr 2023 11:05:36 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 5670fad22b998a39 X-CR-MTA-TID: 64aa7808 Received: from a2db9dcc8cd2.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 4A54D2D5-8B1F-468D-B584-5C841F456958.1; Thu, 13 Apr 2023 11:05:29 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id a2db9dcc8cd2.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=dpkFKyATVPwQvQFrlS55xLScYWprlSqR6N8OcGcB9GTlkgS7+J8tECQap5dLBA7mp2+PIctU17e/M6RrPSQky+HyFaPYvozqxYfHrXna290a/Rht4LyuX+Vi3m7JUqlFylchCO1Vr+prAJ5I/0aNklKKYG1gkuTCG0VfeNgqj0etA3VNz7RAuyiGhKcgdJzXcbjymhkZovNPGMn+IdH2dunK402B4f5jy2GNkWdFocmo3QA2GjfNh0vqUvm4vLYE3U5/A0W3qDh4I6DFn7EJ47jfI8Z//u2j2rqezwIaa338IT+91GXVUHmVAefqyPrdn0M6yQH4yDNq5nO2TtyLgQ== 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=2PkvxGMwAh7TXnG6EpHIgjGW4tOcTdrH8C0yGwIB5Zc=; b=iwKIwQEOfJc9eTQMRQKYMkkd9LTuJdu68vqq2+HxpipP05vEVCuxWGry6b2XInQg5NxHKLyzEzVuaV7sD93ya8UU5Ac5JMtAgoCZTeLuciHe0TRk65iABJFcZQQVvzQO2kQS4qbU8+2ci8Hq/65vDDB2yW1v1OFMm9Hb7gHpJ4WYahAXMg42Jv7x+euQdEN7bv5/ZR8BLNBxdVbab58KeZPWJWLgOVEQ7ckdxCW25AfqpJHZmpRYmL9Jy8xaVrkqBWv/nZSI2VccUD/ayyAdNU5/Poy6ToCWHXIqd5IYqwm6rAP2qfcu7H/Gw5mRwd7g/PlQr4QRD5nfcPFGN27LQg== 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=2PkvxGMwAh7TXnG6EpHIgjGW4tOcTdrH8C0yGwIB5Zc=; b=aq+poyT0d6CX1hz57vDq8hcnlb3v31KgEqhJvXPJF4GaFz7OfZIF5351ctYtk2a33wW6s+qd8El6FzD/qqJoL8ccASTSeYYhwIDQWTOJUDdO4391zPzgsOBAtQTL/8uQAW4tHLXGC7h9pnLOgMnQ0giQEZZfpzudYGUGB5Kv72A= Received: from AS9PR06CA0441.eurprd06.prod.outlook.com (2603:10a6:20b:49e::24) by AS8PR08MB6712.eurprd08.prod.outlook.com (2603:10a6:20b:393::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.30; Thu, 13 Apr 2023 11:05:28 +0000 Received: from AM7EUR03FT045.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:49e:cafe::d2) by AS9PR06CA0441.outlook.office365.com (2603:10a6:20b:49e::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:28 +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:28 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) 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:21 +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:20 +0000 From: Joey Gouly To: CC: , , , , , , , , , , Subject: [PATCH v2 17/19] arm64: transfer permission indirection settings to EL2 Date: Thu, 13 Apr 2023 12:05:11 +0100 Message-ID: <20230413110513.243326-18-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_|AS8PR08MB6712:EE_|DBAEUR03FT033:EE_|AS2PR08MB9426:EE_ X-MS-Office365-Filtering-Correlation-Id: 13edb374-2f80-4b43-d363-08db3c0f0276 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: RK1sCOQoKCPDNMNjfWggBMMwfDawZqhtBZWxNfjfUyShCpV1INvAxiRjMpo4enFnKieWBs8lO5fubiMgCfRo20eGNA6qabp+jeVDtvNxgHCVCMzUVGsbwcO/j5kKcElls3nmnkCssXN5JhYki5SouIBScFFRqvdwb6bQjzZocVM9FOtHByZPSBrNoPB7K7fezU/qecL2E45dSbEf/RLm971wsiq71bN/Iq/AfNwQJZw2lwGCC/prl7/gi9Of7GdHw4LE94rzJEtnFH0/K5buk7Ngo6O1+6j14QqV5qURwcvcs9uEZ3PiuAdIM37hWP6aLRh54XbJhWFkSABrb74qUA6BKeMGRVKMeuuk/SHSpqJF6CfQeH7L72vofOmBx8R2JSR03r69BIOVtcx9hU+dm/4UIuAlGH0kCE8jl/OJdxB9BolIV7dEwvA5q9OLFyu7lEJ8H1GzemBhHAfRPmFClB3iBQx68D9KmJxyY5epbQN2wKN/v7HcZR6iA8ReUb+Yqqlwuj9TS6qvMx9/z+VDp8PDlsqcxW8Zx6tOYg/XQ3mBfJLATj8uyLdKPjejYuKMqbRTTV2S3dFN/Z/FYbnCjmiX9z5UdDo1jKcAxifroZ7o7FlO/2qoYejlqgF8mZiupgHlO64AruP1R3232Za1y7Jgi0oc1DaxHdw8xAjyRVLd7hgJsFWFHXIcTBsTtKhUEDmtBtZefZQxg3lrMpyR3SCRYukcHFxWYTly/6H6Vkk= 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)(376002)(136003)(39860400002)(346002)(396003)(451199021)(46966006)(36840700001)(40470700004)(86362001)(54906003)(44832011)(40460700003)(478600001)(356005)(81166007)(316002)(41300700001)(82740400003)(8676002)(8936002)(5660300002)(6916009)(70206006)(40480700001)(70586007)(36756003)(1076003)(26005)(426003)(336012)(186003)(36860700001)(4326008)(6666004)(2906002)(7696005)(2616005)(82310400005)(47076005)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6712 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT033.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 94e6f6d3-a0f2-4eb1-7f93-08db3c0efd5f X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: oIU2CysvLHWJYeN7OOZVLAWEVK2gWOyTcxoNR1oxlTFduboO6cvYwXeDheRvF0jJG7lplWNRD2z8uxktlUWeGQecEdSXngBHWbWPtC6gaX+FpN4lvb3H+0syus71difsL/gWal4pmmj/+WCCEX/be2IHu/tMSth49hQMxCgBfPeYWrPiMFI145ZUwvht98MYPOs61CK5Ua098GFxD57TqGRwubG0DyB87nnDtRvE2mQ8gPoimb5X1O14EvMph82it+6meo1oEb2Hqwl4SnRxr+ttLHwcQynl/IMWfgyc81/SoWkkUKu9UC4vqFt8NHvUH3Qx6uIMxGbS62S9IU02EE2UvlpB9ErQtS4YsrHSt/QPPTyuekhqukGE1tXGnEEzsSo1wc6V0ltNkxJauTcIc2pjMNl7iZSzPZcFW7zwGSqdZDcDMU6GKpMcCUSeR85BC2x42UAmPVE3PMzaOuGQhVvC45J49K925sLVWiFbDO8x+xpIVw2iorZUTZGEwakRX6hzRr3YCKIOcNZSAGSfzHsHi/gQQi0A0MYExs+IvjMpI0A89/2HwQA+JHLXTvHxQXeebBXj1FoH2S3pqBmXlG+naeIDfgF86pizJUnIFbwtJdZ95lN1xhWiz8UKsxZe5FV9ihVsWq65GPyk7j5K4ZVBO5yvyk8xsG0ZcddFa9AWNsugTAF8Oxkc3rriqU2CHGq2mMHz5CAS3CWKol1ifA== 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)(346002)(376002)(136003)(396003)(451199021)(40470700004)(46966006)(36840700001)(36756003)(2906002)(26005)(40460700003)(54906003)(478600001)(8936002)(2616005)(81166007)(47076005)(1076003)(82740400003)(44832011)(186003)(5660300002)(336012)(40480700001)(426003)(86362001)(36860700001)(70206006)(70586007)(4326008)(8676002)(6916009)(7696005)(82310400005)(316002)(107886003)(6666004)(41300700001);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Apr 2023 11:05:36.6574 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 13edb374-2f80-4b43-d363-08db3c0f0276 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: DBAEUR03FT033.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS2PR08MB9426 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230413_040552_018853_793E8DB1 X-CRM114-Status: UNSURE ( 8.32 ) 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 Copy the EL1 registers: TCR2_EL1, PIR_EL1, PIRE0_EL1, such that PIE is also enabled for EL2. Signed-off-by: Joey Gouly Cc: Catalin Marinas Cc: Will Deacon Cc: Marc Zyngier Cc: Oliver Upton Reviewed-by: Catalin Marinas --- arch/arm64/kernel/hyp-stub.S | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/arch/arm64/kernel/hyp-stub.S b/arch/arm64/kernel/hyp-stub.S index 9439240c3fcf..d63de1973ddb 100644 --- a/arch/arm64/kernel/hyp-stub.S +++ b/arch/arm64/kernel/hyp-stub.S @@ -119,6 +119,24 @@ SYM_CODE_START_LOCAL(__finalise_el2) msr ttbr1_el1, x0 mrs_s x0, SYS_MAIR_EL12 msr mair_el1, x0 + mrs x1, REG_ID_AA64MMFR3_EL1 + ubfx x1, x1, #ID_AA64MMFR3_EL1_TCRX_SHIFT, #4 + cbz x1, .Lskip_tcr2 + mrs x0, REG_TCR2_EL12 + msr REG_TCR2_EL1, x0 + + // Transfer permission indirection state + mrs x1, REG_ID_AA64MMFR3_EL1 + ubfx x1, x1, #ID_AA64MMFR3_EL1_S1PIE_SHIFT, #4 + cbz x1, .Lskip_indirection + mrs x0, REG_PIRE0_EL12 + msr REG_PIRE0_EL1, x0 + mrs x0, REG_PIR_EL12 + msr REG_PIR_EL1, x0 + +.Lskip_indirection: +.Lskip_tcr2: + isb // Hack the exception return to stay at EL2