From patchwork Thu Mar 9 14:52:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13167719 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 C4C95C61DA4 for ; Thu, 9 Mar 2023 15:11:02 +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=CiGYU+UI+tOUMnZ1TRI8HcfGrRwWNfF7SrEx6OGPQIs=; b=awTrFZnglPzxRk WDAoPPSLh0ceAY0rPsJVe/unqnEuTGSHHCpEn5jTEfYvLe94CQFZ8ijZNl6KcapHSJL8aZ7e/KJN7 MuMulcpRP8X7LtqQ+6Y+4z+15ixtapn6xkAdcKpiuydD8KHxGZOrUT0kRvd70xIAe8cL1f8O63IdP mXXGjXiZ9nqhyjh4Vb8olmHU7/Mx4RvW7P5g1hIFJ5sGPsA60ApkEpLjTytMNXPmxWfRR+PcWRghO K7Vdoc8nkGe3JOSMtWNvHdqGmjeO+k4HkQORxaqsC5kufr79LD2GwaeacPR9WXyyVcOwcllgJUnmc GO9ts22ag+2cLhYDHZDQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1paHtV-00Ane8-U5; Thu, 09 Mar 2023 15:09:27 +0000 Received: from mail-vi1eur05on20609.outbound.protection.outlook.com ([2a01:111:f400:7d00::609] helo=EUR05-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1paHeB-00AhU6-F5 for linux-arm-kernel@lists.infradead.org; Thu, 09 Mar 2023 14:53:37 +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=d2gjcWXP1QO4l3VC9y9y41Nu8HtrnwxfjxuYT4me9WY=; b=2M5xKBhoi+3w5i7kRzMOwFmu6PdQukMHQ69Fw7YYLIOrY6m6Jys5dIjR5IcgJwH8TRwTAYrBvr5ZXfCRF2Yw74J64PMTtrCENvDhmnaXv4eb1WhMbzQvn4fMcqtWKauraea4x7q1ZwA8wsClgqeQJ4b2fGKaghUKuf4O4gCGJmQ= Received: from AM6PR02CA0004.eurprd02.prod.outlook.com (2603:10a6:20b:6e::17) by GV1PR08MB9940.eurprd08.prod.outlook.com (2603:10a6:150:3d::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.18; Thu, 9 Mar 2023 14:53:21 +0000 Received: from VI1EUR03FT009.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:6e:cafe::b4) by AM6PR02CA0004.outlook.office365.com (2603:10a6:20b:6e::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.18 via Frontend Transport; Thu, 9 Mar 2023 14:53:20 +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 VI1EUR03FT009.mail.protection.outlook.com (100.127.144.72) 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:20 +0000 Received: ("Tessian outbound c2bcb4c18c29:v135"); Thu, 09 Mar 2023 14:53:20 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 6813471086eb9276 X-CR-MTA-TID: 64aa7808 Received: from 68fcc66b6404.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 50D78FD4-74DC-484D-8911-2F2F41FF998C.1; Thu, 09 Mar 2023 14:53:14 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 68fcc66b6404.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 09 Mar 2023 14:53:14 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WrKxUSLOA44SNC0TbLDzuaF8AEUSKoRjPrcQz6/an29LryxlvolTT1QTtYXyRBJmliC7U8afLQ4tHLBu/QsAxXkSRd6G6eEAeZ1vJ9temzz2TF5gOBcXujRNqJvg52gvThPAPSHBm56G6OPOX8dL5q+t4vSx8PWxRoM/NZp/spE5bjs3R5mqCMbtfjEY/v81v3MchPseaYuoZRQq3AYGxf/i27X61w8th/wycZ/4xMYoxQmdFVe+JDooyDmjr7TUzQ1uUbK62kdZRSlb9eSPCneTIVxPX363lVUwou6q2TyvFVU6hdRi5MuXlkJOQiRHdQVPjpjZ1ZSPnwGzjMepQA== 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=d2gjcWXP1QO4l3VC9y9y41Nu8HtrnwxfjxuYT4me9WY=; b=LneU2A+4BsCP13px89eK4pFUMVP6dW0JbXTKe7W1XXbTyiKMg08fqiuaBvFKG+R8Me9nQitnXyaKN9fGPg5BMNiQ5Ts+2r3S9yZEpRK7aezVcrumnr7VYuCzE60UKTXB864jexvnfUCa9Foz2Pq8CWhzeV0Qm6T9v9aXqWa2KoQp3jl70lgvXkF1qrcz1v0qrSkNyfMpDSXAiL9NeA8p70qYVQSiw5b4H4b91fYoK38b7JQmStpm014YTccTaeWJbT89yRiRRerHfxEOHVlsAdODR9RziKiD3ONUGB6K5Lp7GKZp8sdhsgosOqpRF6yBLV5ew8Khnhs+zDQky7gPoQ== 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=d2gjcWXP1QO4l3VC9y9y41Nu8HtrnwxfjxuYT4me9WY=; b=2M5xKBhoi+3w5i7kRzMOwFmu6PdQukMHQ69Fw7YYLIOrY6m6Jys5dIjR5IcgJwH8TRwTAYrBvr5ZXfCRF2Yw74J64PMTtrCENvDhmnaXv4eb1WhMbzQvn4fMcqtWKauraea4x7q1ZwA8wsClgqeQJ4b2fGKaghUKuf4O4gCGJmQ= Received: from FR3P281CA0109.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a3::9) by DB3PR08MB10336.eurprd08.prod.outlook.com (2603:10a6:10:43b::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.16; Thu, 9 Mar 2023 14:53:10 +0000 Received: from VI1EUR03FT041.eop-EUR03.prod.protection.outlook.com (2603:10a6:d10:a3:cafe::66) by FR3P281CA0109.outlook.office365.com (2603:10a6:d10:a3::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.17 via Frontend Transport; Thu, 9 Mar 2023 14:53:10 +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 VI1EUR03FT041.mail.protection.outlook.com (100.127.145.15) 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:10 +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:57 +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:57 +0000 From: Joey Gouly To: CC: , , , , , , , , , , Subject: [PATCH v1 18/18] arm64: transfer permission indirection settings to EL2 Date: Thu, 9 Mar 2023 14:52:46 +0000 Message-ID: <20230309145246.22787-19-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: VI1EUR03FT041:EE_|DB3PR08MB10336:EE_|VI1EUR03FT009:EE_|GV1PR08MB9940:EE_ X-MS-Office365-Filtering-Correlation-Id: 0b112a69-db0a-4974-8a60-08db20ae068e 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: hI9pKa7kJdtBtC13KLJMLmp76irl15AGmVMMzj1xwRO8M1Gyf7FPQ1EK354IIuYrnvlwR4n3xoCwhes70M/4fbssF9KtDI1I+mKW+5gLt7qR+hWpQDrWIGa1uHjmz5hzbk69dZsebvsg+rVFjGcesw6HMtIt/NZbWnJJX+ujs6CaPYWnGWpMU5qTtkgliKKWbO3Mp5l5McMtgVm1gB15DO2OZ81DSTbOoPWqjKBFk3HWxfxl7a9Qbvk1yViMxIEsMWRF3XS762MpAh98SH/EIsvuXZ0Btq9t2VzjRZEH2ymr2DtkFybx1EG5BHPSavoGgAB7HaAOElNO+GRyFJTaVBXkIk+Scjo+oUxxkJ9YxI/vO7JAyynNN/ZwgsH0zeSY0aA6ho1DJo/xA77vgQ/KRWGmaqojaW/jQ7EBsyYzWO39zk0ygWwVMF92F9tvDKwbYUYNmKHcEMa5hijC8/UFIrzFXeBeHxqyh+1AgO6f0Sj2vPSz9xN0YhtKzxIX10JRzWatSy846YzJPGsEAHgemcr97GVMMC2YtJMZuIG82W1MdR9oYDhK0ybl+Bg1bYWWgl2Vie1X9yHiSqTIJgPprTE0L158TiM3Q0IiRXScp0NLpTwlEN8kqDNyXWJZhD3sGTNARUx5IpAo3moBUDzyBfU9CDQbu0HRVDwjy+ha5THP6nDwBafVH1lbEpGA3utTPR/fUZW2VQJJkLdIl21I+A== 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)(136003)(346002)(376002)(396003)(39860400002)(451199018)(36840700001)(46966006)(5660300002)(81166007)(6666004)(70206006)(6916009)(4326008)(8676002)(70586007)(41300700001)(336012)(54906003)(82310400005)(7696005)(40480700001)(2616005)(316002)(86362001)(478600001)(356005)(36756003)(8936002)(36860700001)(2906002)(186003)(426003)(47076005)(44832011)(1076003)(82740400003)(26005)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3PR08MB10336 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VI1EUR03FT009.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 04555e4b-9fd3-4993-e5e3-08db20ae0062 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ep2dnbj9MwXtbkPyJKcjp1s3v0xtu8hbZrm6Zz91DmxPEN6J3rfWffA06ZoBimvTy8yoS6DRhqXbZdafXukA8TIB/urSrZb3OLIo13AbFUxaX0Qt4WXo1YexA8vh+GacMxquq9wGDvzYhdRLOLOvr2w5QA7ljuukTyRb34/rHJwmCylEVasd3Kbr2QZxK9z6bopfFpix0RTjdcIFSuPYEJ7ax+6sNe8R7NNEKTKbQZFw0R3ZaeS3Ldao3hwwofmCMxZKmjoKpepYH2Z0ai6YMhHHzQqIpj69Uz0H5uWWqDPMpz0ihAcVzX/7ehLsjAgKYZ1abjUO+MDPrr+Tyil+ipTmn2U73EnqoohNEPe31KE6AVGJv0xN2i+/D3L6X4USkioi7ZLgGsPsAyB3N51M//HQEeM5vOOpNz/bKsb02suDWKWsj9fSg/TobH0VNy7x86rU7krgggi3v4oNFZn/uPPl7WKtgZm+xNhqG4UNLVfnGHKCoL46JWs91Y6InDaeR6yQc0uFJuNnSdWZy+BqA/g3JeS1N27XZwPH9f2OKGBSBzCn8ec1Ek/R+n/v8Ga+Hs5eAKzcXXk7FdcMZS8abXxL7A9ZlCCLxXoyhgcd5URHCTT5vUuf9xAh3A7UOCMKMNRpTOA4lQla88LV9Q2dwjC60cCDwYl/XKnPQpKdoPg/yxNsmxtpksbqdNWlTKa7FX2Vo6rGxrvjsC2VoTFHlA== 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)(346002)(39860400002)(376002)(136003)(396003)(451199018)(36840700001)(46966006)(40470700004)(40460700003)(36756003)(6666004)(54906003)(478600001)(316002)(7696005)(5660300002)(2906002)(8936002)(44832011)(70206006)(8676002)(70586007)(6916009)(41300700001)(4326008)(107886003)(82740400003)(26005)(81166007)(36860700001)(40480700001)(86362001)(186003)(2616005)(82310400005)(1076003)(336012)(426003)(47076005);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Mar 2023 14:53:20.8366 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0b112a69-db0a-4974-8a60-08db20ae068e 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: VI1EUR03FT009.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR08MB9940 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230309_065335_543224_9E6D3BB4 X-CRM114-Status: UNSURE ( 8.46 ) 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