From patchwork Tue Jun 6 14:58:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13269346 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 340FAC7EE24 for ; Tue, 6 Jun 2023 15:00:14 +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=f4v2vmGXcNh8rO b4egbzzc/6jtahF6WvB6pc4EdAbyBcqvFJ+KKXy+YEFq31ba2B9kp+HOgPaBry4CX+YXLtHtsvT1I I66vRIn8ubfzsihs81u0rUzMM1eJh4eV71MQMxuYcIlwyybr7Req5v7TMvK3Blv2Dimw2fH678qUf CHmNhzkF4eL+6+my21TiSghFLp/xEgax0z5MVk+cGv02tkont4X16pK5gEZXZWbX79qGGzUFty2S3 IpsDuwGVcNlHB/i4nF5Tfonquju03HRlNUfPEug/1oeIOaw2x/kDthW1TIRzrFnR6XFPFSmNmXqi1 +KmXwaoVgsjOGOZjm5BA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q6YA0-0028qY-0z; Tue, 06 Jun 2023 14:59:48 +0000 Received: from mail-db5eur02on20626.outbound.protection.outlook.com ([2a01:111:f400:fe12::626] helo=EUR02-DB5-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q6Y9l-0028eF-2Q 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=2PkvxGMwAh7TXnG6EpHIgjGW4tOcTdrH8C0yGwIB5Zc=; b=kqHe+WtTuvvMhAJO8YlQmHRya1iC00ltSdOuJ9NeDm70GQ4nwVYe8k51l+g07Wg/ELDb5bXBhDwmMJ+Bwf9sIIv4i+lt2Rwb8skkEadZG0ojG3JQ4ZL6coH+PHyrq/wj0rAWtDMvtMFyuXwapRWKL4i2FQV+TbnrowbjKU9ITLA= Received: from DB6P193CA0020.EURP193.PROD.OUTLOOK.COM (2603:10a6:6:29::30) by PAVPR08MB9843.eurprd08.prod.outlook.com (2603:10a6:102:31f::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.31; Tue, 6 Jun 2023 14:59:30 +0000 Received: from DBAEUR03FT024.eop-EUR03.prod.protection.outlook.com (2603:10a6:6:29:cafe::6f) by DB6P193CA0020.outlook.office365.com (2603:10a6:6:29::30) 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:30 +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 DBAEUR03FT024.mail.protection.outlook.com (100.127.142.163) 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:30 +0000 Received: ("Tessian outbound 5154e9d36775:v136"); Tue, 06 Jun 2023 14:59:29 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 483362ce057099ac X-CR-MTA-TID: 64aa7808 Received: from 61b847c788af.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 74D47747-FFE4-48B8-B030-DB9932B8F94A.1; Tue, 06 Jun 2023 14:59:23 +0000 Received: from EUR01-VE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 61b847c788af.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 06 Jun 2023 14:59:23 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WyX6RW4tnflb/wH5ldmykAj96DkZsA2gTcp7uQ3uVx/Ls5LhC8Mt0TCx8tPbxOmK7va+x48Lm8cihGzAQeXGebylxMwAecmIHgV5Xt+DpysWCRE0Z3B32ncO1bVm2X5rA1IXec3OvKCukS3KBXJ0OhOneYl09jsB8VDlUx5boWTpLV4jWkMvnGL5tJElQ8lnmUSRSA2ITl2m8rTpI2iIInYiqQFviSdsQ9eXhbyI7U5Z0VqeeNlVg7eqENdnXySaQOLgv/1X8HUX6YgNDAmBFwO1g7OL/WaMBagy4bUvB7yUK7cqM0Ms4CKZ9iXwQeHLSYurPYJbrt/qzmpD22vkZw== 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=Xi2Po/0czGA6/DGuOn5cyLtJcSdcaRB1QC2VBcuNMqcT8upA/xK4MtDWC4+RA12HZOjle+tPfWwvRLgBMy2YCXXJWkHNTx4DcrnH5S5AHL5LE9tLuBT6PJcVfe409OwQoAaicJNQibtWG89+Ge/5h10eBMM7pxWE+9IOsMj2V7oQ+V85lo3LicTbXFGV+kGYBGKojbKLHy9Uz+TwzAm0arWZLAUohj7K7UgzpNHXx/+zUXxjAYgeiy15cTR3+Bns06r6yIU/8dxFe6R4oDd31UScAJSccuzxFf2jhFFBBK7p8b7MTTYLgNQlAr1ZCTcRXJEKW3zIF3bTCydyKPsxGA== 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=kqHe+WtTuvvMhAJO8YlQmHRya1iC00ltSdOuJ9NeDm70GQ4nwVYe8k51l+g07Wg/ELDb5bXBhDwmMJ+Bwf9sIIv4i+lt2Rwb8skkEadZG0ojG3JQ4ZL6coH+PHyrq/wj0rAWtDMvtMFyuXwapRWKL4i2FQV+TbnrowbjKU9ITLA= Received: from DB7PR05CA0026.eurprd05.prod.outlook.com (2603:10a6:10:36::39) by PAXPR08MB6671.eurprd08.prod.outlook.com (2603:10a6:102:13b::17) 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:20 +0000 Received: from DBAEUR03FT061.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:36:cafe::6f) by DB7PR05CA0026.outlook.office365.com (2603:10a6:10:36::39) 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:20 +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:20 +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:10 +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:10 +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 17/20] arm64: transfer permission indirection settings to EL2 Date: Tue, 6 Jun 2023 15:58:56 +0100 Message-ID: <20230606145859.697944-18-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_|PAXPR08MB6671:EE_|DBAEUR03FT024:EE_|PAVPR08MB9843:EE_ X-MS-Office365-Filtering-Correlation-Id: dccbb859-b188-48a3-9744-08db669ea14c 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: NzIZixkpZSsFDXLLrfnY/ezlbi+Deja32N+rFqCCfKH+H2nAxNwqZea7DHxpoqq/uHI4db+NDqOqEYZ3qNovVRxpSHed2dX/LBk3CYZpFnDlTB6nOPnvPt6uUCs5Uf4zcx1F35pEqtt+GEdEy7sL1JTYZOAhPlH9oac0z1m7qkVTAw2w4UV4dH4MmPVNOM76s7j4WMBaVq4VbkC6XnVCK39nrNALDnmGieALoFMyPBqqiU60pQ2kA4KPiUYjKaamm0G7tHper2Zn1koHfwllcbSaf1OPDpk2XBi9F0hUz6RSOxqblNHFTeYsEObjWKz2+QKoQtFSs6WmGgf6zeyWiiFohtzzSf3+U6ZL6QjYdNwBmbokYUKws6koH06ABVCym9U7h/ZZM7X/6uNnLqSstTuuEt6aZd0oVIu+2hj4xEMz7Ccc2bvN5nnTAoN5N6QEkj2P1Na/YhabUmvplVcMr9ZFSAk1K/3tzKmdvbOjnFVbribLurvlfYfCYm6SwAmBHM/Gs2JszMZ49rzEZjX1UpPVVrlBll2QurV4vYzn0sEz7FmsEqav7sjbtQOiH4lBo2TkrU01pG5LJWZA7CuvJ5ShpxJgC4ckOQHx7WQjoxB8Xb32il19DthFUju2hLbIJd+uCzdlJdMYMrqsFY1QcbA3kjFbBE3GAMPqbk9R91/OQLFy3jztL5koHUw/HX4911xhmA7dZ+dr36sgpgFYdv4GGanirYRFSKLuNwgmUmCuf/GV2Xjjm0/+z2gTKN0hZkZCvcX6ZNgbFiAvy6lkRQ== 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)(396003)(376002)(39860400002)(451199021)(40470700004)(46966006)(36840700001)(1076003)(186003)(26005)(2616005)(426003)(336012)(47076005)(36756003)(6666004)(36860700001)(54906003)(82310400005)(7696005)(2906002)(8676002)(8936002)(40480700001)(44832011)(82740400003)(478600001)(40460700003)(5660300002)(6916009)(86362001)(4326008)(70206006)(41300700001)(316002)(70586007)(356005)(81166007)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB6671 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT024.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 46583934-d5ad-4709-c48a-08db669e9bb8 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: A4mlMmxZanNT+TWbX/lEv0XOTr/kkKaoqzt4Q3mlPKOFaWRVk2vF+2hHkRebttfcqszjtw25NU8F/a0QfII60D9o+/+ie+kkabEmH5dN6nt5tPiAKSUR7j712n5ArMcN2FZ7Q1HLbALc2GKbfjsrLq4BhZ+AVzv9pmRXSqOTJXRkOq03ZrfsCW6AE1LaDUWp9bVgGlOfUF6RPRx76mLYg939Ygz6LDdH5ZixiAmdNfIVXgV2mhIqWHb2lrZBD86jcEpL3469PZRBaBWwmWeVtF/z3BhvUIH/KxLDSWt877tIOm3xYQM1/df/v5zVdCLT0HZ9Co3qvzU/bvxSqBir8hMv3Z7WxOKqExbLGIcOlDLRDSviIogbXDS0EkGcH/smT3bdTsZqjyzDLdUIURD64X31Syk/8vTYV48rk/fKJW0/ojnST1GKPQKRmS46gBqRzSCCMBfiHFS3xBtOS/x9yt+pBv7ulT9p45sQBb1T79RZmlvDHr54gvOeb+eR0qT1yUJLomag/7nyfPpDBKDAtJb8B8Bxq3sybTaX0rEaPoZ3z9oWloxcF3lGt7idVRzKK8+L/Pbh8O/fezxV5zegs2sC+MigF5blxhWhUvoHigRUaLyNKVYHE21XapHtSGEjdlMpmgauxgsFA1aflCj3DGBv2jW/l8o1ia6ACS45yHtF0KaAYeJj2rY+SUlnDugLuS5zq5uKW5TUH+OfWCc+QGYYnD0i85bqAdentOpA8fQ= 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)(346002)(396003)(376002)(39860400002)(451199021)(36840700001)(40470700004)(46966006)(82740400003)(47076005)(316002)(36756003)(478600001)(81166007)(36860700001)(41300700001)(82310400005)(70206006)(26005)(1076003)(70586007)(186003)(336012)(4326008)(426003)(86362001)(2616005)(6666004)(6916009)(54906003)(2906002)(107886003)(40460700003)(7696005)(40480700001)(44832011)(5660300002)(8936002)(8676002);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jun 2023 14:59:30.0074 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dccbb859-b188-48a3-9744-08db669ea14c 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: DBAEUR03FT024.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAVPR08MB9843 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230606_075933_802221_CA14165F X-CRM114-Status: UNSURE ( 8.07 ) 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