From patchwork Tue Jun 6 14:58:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13269347 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 D86B0C7EE29 for ; Tue, 6 Jun 2023 15:00:15 +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=EgoUOTGHi56oYeBIbxWJHzj6KNczveZZXN9YPeXkKr4=; b=31Lz8Ng6zZNaoa QKlfwsZ/rYZ0cJJ9QURKQoGf3BXpNe94yJXNW23Z/AvSVjdQcNjUaTVjPBA7pNOynHYBCGhOodMLM yZZ8dgMajnlA7qDwnoeNIcjOAJ3ltF+zTC22QcLxBYgew80Skuu0FH2/PJBaRtS6jE5EhXvBJoPxq FY6wwJV5s25nlP+O1CB08+UNRrl3B23qmDED2VrU+mJhmXcz5dHFzCM4vSd5qIdG2quok1M2De3v2 nua6A69fmkHqVOWUi3r3io67FLgCb2cn39J7vBoI3pbSPMZxZXf5mEnCiGbnaPGxZvfugxJNAiJJh 2iUwX9NukFzAE3r9ALtA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q6YA3-0028sv-0Z; Tue, 06 Jun 2023 14:59:51 +0000 Received: from mail-db3eur04on0607.outbound.protection.outlook.com ([2a01:111:f400:fe0c::607] helo=EUR04-DB3-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q6Y9m-0028ec-0j for linux-arm-kernel@lists.infradead.org; Tue, 06 Jun 2023 14:59: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=UK4BD2MoL5VDl7qWTOzZG+RLjNdfbMM+qqt9DY5A2mY=; b=4xzYY0eRi+IJ6k+g5LKnDtfMkiUYJ+bQ+OIWCla+tVXEjIVGj+ZCAHgjVGlU4OXhyeLWxRH7aLm754kDAJdiYj/1c8YzgBSQVKPCxT+FFgr2fqoNxv8pUe7ittqx3mWoRKeufDlA39XMR944adbzPAWkx4fU1u/3nOeeLrlkm6I= Received: from AS9P251CA0018.EURP251.PROD.OUTLOOK.COM (2603:10a6:20b:50f::16) by GV1PR08MB8619.eurprd08.prod.outlook.com (2603:10a6:150:83::9) 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:27 +0000 Received: from AM7EUR03FT027.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:50f:cafe::f2) by AS9P251CA0018.outlook.office365.com (2603:10a6:20b:50f::16) 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:27 +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 AM7EUR03FT027.mail.protection.outlook.com (100.127.140.124) 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:27 +0000 Received: ("Tessian outbound 8b05220b4215:v136"); Tue, 06 Jun 2023 14:59:27 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 74088ac5aa05ef3a X-CR-MTA-TID: 64aa7808 Received: from 0082d616b984.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 6299D544-8705-4EEB-A955-0802B769E754.1; Tue, 06 Jun 2023 14:59:20 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 0082d616b984.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=Y0WFFABA9WbzwnvYDH8oaX0KWTgr/C6O9+s3hZJcRCbZTP0DztnidWGMcXH3Q7fG26Vdi9oLhanPMFH1MNCwFd7DBr6q/PD537h/sPWPGrLjwp/AM52O/ePkPVToGHxv/Hhpr7FV/pRytwxF2x34pcxONvGk+0wkmHVYDjzNN+dRrq7R1PcBaaFi6sQ4pVPtLdjUciKQ8NdGAt45Ntp43p1cOiqi8KzumbwkOsZZApfZeUgsE01hnzkHFRoSDJIwlzOWwqVCa7mKTj0hPCrUnynapLnAbZvWdBXNZpnmekcmBP5t6WUxsfxf+X5gh3Q9g/q9JY0XWSnaJUxzW26wyQ== 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=UK4BD2MoL5VDl7qWTOzZG+RLjNdfbMM+qqt9DY5A2mY=; b=MZX9YtEPwZ6puB/JoIKyscb5LUYACA1EKZLdVfPvPKXUD1t6r1bfihkjKBr21l8jWaE/jiH4wxJJdLgKEMcNTenrzSdKp0GJ60rM8GhXqnU1tI59otfA1n+AHnuo5RkAzxgioZVp7A/AlPyPjJZTEg5I8ATjekK1JfT7OYoWk/gYFnN3UZgR4SNEbaLCF5TL3C+hPL1tpRp5S+MTwZA9srCPOCoPS567WOwMKNHt1lknmdE8QtTG4yQJu3U9wBO4xA7ba52ONWjZCjwv1GsauHLQ4KnHij4qrOW8jUZOZWzT8kvuy32LY21RU4mX531D6MXwj+U+v5QSvvJTQcrEkA== 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=UK4BD2MoL5VDl7qWTOzZG+RLjNdfbMM+qqt9DY5A2mY=; b=4xzYY0eRi+IJ6k+g5LKnDtfMkiUYJ+bQ+OIWCla+tVXEjIVGj+ZCAHgjVGlU4OXhyeLWxRH7aLm754kDAJdiYj/1c8YzgBSQVKPCxT+FFgr2fqoNxv8pUe7ittqx3mWoRKeufDlA39XMR944adbzPAWkx4fU1u/3nOeeLrlkm6I= Received: from AS8PR04CA0171.eurprd04.prod.outlook.com (2603:10a6:20b:331::26) by DB9PR08MB6474.eurprd08.prod.outlook.com (2603:10a6:10:255::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:18 +0000 Received: from AM7EUR03FT015.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:331:cafe::bb) by AS8PR04CA0171.outlook.office365.com (2603:10a6:20b:331::26) 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:17 +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 AM7EUR03FT015.mail.protection.outlook.com (100.127.140.173) 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:17 +0000 Received: from AZ-NEU-EX02.Emea.Arm.com (10.251.26.5) 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 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: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:08 +0000 From: Joey Gouly To: CC: , , , , , , , , , , , Subject: [PATCH v4 14/20] arm64: disable EL2 traps for PIE Date: Tue, 6 Jun 2023 15:58:53 +0100 Message-ID: <20230606145859.697944-15-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: AM7EUR03FT015:EE_|DB9PR08MB6474:EE_|AM7EUR03FT027:EE_|GV1PR08MB8619:EE_ X-MS-Office365-Filtering-Correlation-Id: 1ead7682-2f90-4df2-c61c-08db669e9fb4 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: p4PDRig1Cg/jLXOYKhwsgQUm+FzElAyReAFX49/t602fsNblktafAAkbMKvUoOh1jdycEe4UC+VtUEdlgUWzzg/2BZ6nZOhN7clLYxpdhQGeVUtBokzhrYU8EIUZeYjU+iVO3QgxwnYkwIpcEobDtAcIIl/+BY2T+ERnaFG1Mc8av9owNS6TtkxWah1YBcSM61uMuWDA1Cep5alIETO+xE06IIalR/aFn1GjAjXsaRJOaJCb1TxarJ5TpeHvLitTK/vjHD46OOK0nGUVxbzfj3QjCv/iBGBkoAg10FznKLfM6Ywp9Od5WTYVW3ypVBEkoXCos2VjlL4DV2CmDmuRzr8g6J7am7CCX5nxEX/876OJWzzdn4iWSofJB9vxRx1coj73im/Ub5xwPoeiXh57ID6e8+YYyxxc891phx6NGLUJ9W2Qm8mYMxMB1VHH181HALqJw9AzV1XjlXcTkOZQp6OGLcMEuf4Fds+2JjPYnnznbIKaa5qoXPp9ExgyXhyZY4MVPDdOJjswAb0m6wRNygmdAcGnXqGEiRPxLHOnjF9c0HZfpOKxDd7oe/lUYBXrInD9zYr7hs1h3UMBH+/2P9nT7dKqahgktGClihuKorFyt517UNyyV4yHcqbh4v5nYA1qwRjk+QKvr/vmxY8Zdx3Y+kz9iUisU0rC6X2jtBB0agjNKHF7+jUeQHGgt4r6yzPK4HodsvDOKJUMjzaifAXxPqBGm3yb8JID5ZN57rXfMEsOhx4BZxY0maDtigq9RsomTqPWimZKnuknP53IPA== 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)(39860400002)(346002)(136003)(396003)(451199021)(40470700004)(36840700001)(46966006)(47076005)(26005)(2616005)(1076003)(83380400001)(41300700001)(36860700001)(7696005)(6666004)(336012)(186003)(426003)(356005)(40460700003)(478600001)(54906003)(2906002)(19627235002)(82740400003)(6916009)(70586007)(82310400005)(40480700001)(316002)(70206006)(81166007)(4326008)(8936002)(5660300002)(8676002)(44832011)(86362001)(36756003)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB6474 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT027.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: ed433949-3ed9-4c80-77d2-08db669e9a05 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HN+Bc0QbfElJR8EhD++xESs7oTNih1Rpw+lQQ/jOj4vRN5bjkKNnSdFTKqFmB5uEr69kxFaCIwPSGWGSfdzMPwVztnXUYx5FAr2afqnnJPeLGXmuo4QvogQmDwdaxNbyy26LT9l1L6oD2y0COsgFOIW1RCvwsgOH87Zl0UvVLFvG2iCEjAuXp0M7rNjj42BGzTXKi2v51U5iUXor/J1kAR53e2mfqxCYHfi33Gy8lbRmdJ0vB1ytlOi0DgUPCv16+9stDeRbk025KLW/LVYBW6hnZ1aQs04MjZveY/15hpAXxeQXwOlbdleb6ii+lb0pFksgUMG3uKoy+4GRGuBEViJ6syDyk+YDmUQPzy0AjGZQbT7LU/p2ZEI/SKa5Ac1aWz7zq8s48wq5uv6q017AP+i3JlJSzhGSiPxpAxvGHljsD/3XiN4sg+jzRCty84Rm9voNaOyzN58jgbtJ8ktTDJneE8mdgF3VSDUR1g1n0Fu4yL0Vf/XRR4PcPJtMkwk3OPAJAIdptOB2OZWBIXoY+7T2DTyCJ5pguALOUKwbKIOPHVDxM1IP46GX9maP3H4lh23gV42ADeul/zjBOgr7zPooMgfFYaHUrrQgkjHdUU5Z8+HOj3SwhdMcwOE8OJ33dlXkEOgGPT6K1cuaNXt3mZ9yACMVvAJw+CUtLd7/docOInjaNrHR3PLzqvsLQjdEMzeFHRs0m+28kx+r9m4T0iCG8fcsHiAGCktNVEArNH4epaut68V/MR45y3RiqwW5 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)(396003)(376002)(136003)(346002)(451199021)(46966006)(36840700001)(40470700004)(107886003)(1076003)(2616005)(41300700001)(36860700001)(336012)(7696005)(426003)(6666004)(47076005)(26005)(186003)(83380400001)(40460700003)(478600001)(40480700001)(19627235002)(54906003)(81166007)(6916009)(82310400005)(70586007)(82740400003)(70206006)(316002)(4326008)(5660300002)(8676002)(8936002)(44832011)(2906002)(86362001)(36756003);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jun 2023 14:59:27.2878 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1ead7682-2f90-4df2-c61c-08db669e9fb4 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: AM7EUR03FT027.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR08MB8619 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230606_075934_278120_6E313D2D X-CRM114-Status: GOOD ( 10.37 ) 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 Disable trapping of TCR2_EL1 and PIRx_EL1 registers, so they can be accessed from by EL1. Signed-off-by: Joey Gouly Cc: Catalin Marinas Cc: Will Deacon Reviewed-by: Mark Brown Reviewed-by: Catalin Marinas --- arch/arm64/include/asm/el2_setup.h | 11 ++++++++++- arch/arm64/include/asm/kvm_arm.h | 4 ++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/arch/arm64/include/asm/el2_setup.h b/arch/arm64/include/asm/el2_setup.h index 0201577863ca..e12a7c29aedc 100644 --- a/arch/arm64/include/asm/el2_setup.h +++ b/arch/arm64/include/asm/el2_setup.h @@ -159,12 +159,21 @@ mov x0, xzr mrs x1, id_aa64pfr1_el1 ubfx x1, x1, #ID_AA64PFR1_EL1_SME_SHIFT, #4 - cbz x1, .Lset_fgt_\@ + cbz x1, .Lset_pie_fgt_\@ /* Disable nVHE traps of TPIDR2 and SMPRI */ orr x0, x0, #HFGxTR_EL2_nSMPRI_EL1_MASK orr x0, x0, #HFGxTR_EL2_nTPIDR2_EL0_MASK +.Lset_pie_fgt_\@: + mrs_s x1, SYS_ID_AA64MMFR3_EL1 + ubfx x1, x1, #ID_AA64MMFR3_EL1_S1PIE_SHIFT, #4 + cbz x1, .Lset_fgt_\@ + + /* Disable trapping of PIR_EL1 / PIRE0_EL1 */ + orr x0, x0, #HFGxTR_EL2_nPIR_EL1 + orr x0, x0, #HFGxTR_EL2_nPIRE0_EL1 + .Lset_fgt_\@: msr_s SYS_HFGRTR_EL2, x0 msr_s SYS_HFGWTR_EL2, x0 diff --git a/arch/arm64/include/asm/kvm_arm.h b/arch/arm64/include/asm/kvm_arm.h index d2d4f4cd12b8..c6e12e8f2751 100644 --- a/arch/arm64/include/asm/kvm_arm.h +++ b/arch/arm64/include/asm/kvm_arm.h @@ -93,8 +93,8 @@ #define HCR_HOST_NVHE_PROTECTED_FLAGS (HCR_HOST_NVHE_FLAGS | HCR_TSC) #define HCR_HOST_VHE_FLAGS (HCR_RW | HCR_TGE | HCR_E2H) -#define HCRX_GUEST_FLAGS (HCRX_EL2_SMPME) -#define HCRX_HOST_FLAGS (HCRX_EL2_MSCEn) +#define HCRX_GUEST_FLAGS (HCRX_EL2_SMPME | HCRX_EL2_TCR2En) +#define HCRX_HOST_FLAGS (HCRX_EL2_MSCEn | HCRX_EL2_TCR2En) /* TCR_EL2 Registers bits */ #define TCR_EL2_RES1 ((1U << 31) | (1 << 23))