From patchwork Thu Mar 9 14:52:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13167720 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 59A49C64EC4 for ; Thu, 9 Mar 2023 15:12:00 +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=FN9YS+N/PQhoAL86nbGWixvHqwt3a35kGKkxt1DPw44=; b=l/QNbTiOojnjGy YTc7DqU5O8n3QwbIygXZfdqM46Bsxxi54nX6m8NzLGiaNIJBfQUfWDPMuZB+QLRlKLeTQkBILYrEw C3AKzM02hQfR+1DlScvcounX7yllqudCET6W2FKsaWF7rRZxoDLwuVvg4oCfQa+OvFvAeY58twpf6 fMOfjjp33sGvZjLv1aVmaM2Wt9yCesuKRPfCqVCy453VSekMM01/0GLb/xATJ3++J4E2sNpoXhKi6 gabMzy0EFjpJ7OJ0NzwQTUJ39TbwktzjugoxYuTsobag6tybd5aUHHPD+eeGwK3IPxOlPE7UVhnkC J6xHTFnXqzNonZtyvepA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1paHuT-00Anwf-0m; Thu, 09 Mar 2023 15:10:27 +0000 Received: from mail-db3eur04on060f.outbound.protection.outlook.com ([2a01:111:f400:fe0c::60f] helo=EUR04-DB3-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1paHec-00Ahg8-B9 for linux-arm-kernel@lists.infradead.org; Thu, 09 Mar 2023 14:54:03 +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=T76og9OrKSgNYBPGf8/+TOj5cE0WD5KLDAV7sLbdVPg=; b=6qPiNYzMQwr92tVKWAC5LgR7TbpRnv0ezBgixqE439l7ix0dR5DHkjYp7HZ+4Ogbgl9bNYxRgwfH9xdVU4+W3SQgFEPyP9f4+DZpmDrFO6WxTVf5gNDpLuYDcnzIYjiPTkmGuOS7BC+2hXObBbSSnd8v5I9rE/O7Q6FH6aq0GeA= Received: from DUZPR01CA0084.eurprd01.prod.exchangelabs.com (2603:10a6:10:46a::11) by DB9PR08MB7674.eurprd08.prod.outlook.com (2603:10a6:10:37d::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.29; Thu, 9 Mar 2023 14:53:51 +0000 Received: from DBAEUR03FT018.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:46a:cafe::78) by DUZPR01CA0084.outlook.office365.com (2603:10a6:10:46a::11) 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:51 +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 DBAEUR03FT018.mail.protection.outlook.com (100.127.142.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.28 via Frontend Transport; Thu, 9 Mar 2023 14:53:51 +0000 Received: ("Tessian outbound c2bcb4c18c29:v135"); Thu, 09 Mar 2023 14:53:51 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 9778585a9c34c1b7 X-CR-MTA-TID: 64aa7808 Received: from 7382ca085ce3.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 994DFC0C-84DA-4539-A4A3-D8DB99DCD3E6.1; Thu, 09 Mar 2023 14:52:56 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 7382ca085ce3.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 09 Mar 2023 14:52:56 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Z9/9nYH+U2MbfEx6lskNf2bsMpqmie2uGg+jYeVn0nYa9+4P+bDxHGOFOnlgdLWEjA658OC48litYrd2aS02+6PuNZbf13zNYvb3Rkoo6IaP6uCHLHy6+HW0hKRylNcPO2mYIIUDO+i6H8JVpENTyKo5oCLILvuiAa8RnUXGecMjDvFJJwRgaXrPMWwrMJrFzt6SCZk77IzTnabYksYhgcIMeOrLM+1HCw3++2mtX5/1RriOtrbX9kd7oaaDmXasXMyL9G9UcJdQC0ek/tHXSLO3hN7G8J5zdDj2gB8l/sUkzBw/cucCJRWbg6vLD363eg3tHi//qHIFQK0TC/XEBg== 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=T76og9OrKSgNYBPGf8/+TOj5cE0WD5KLDAV7sLbdVPg=; b=gVxuCqe5U6hcD346OxXhrJZlkVr+0JNVhK6WQMYFhbIZPgNFi5kvXae7vU7pQhBvPK43BivORSQ4cqgGMIpipEUHRn4zjcobvMVIy6VwVnPeHsu2b85yPE1SniZmF0/AxK5UlOM11i7oJP7uTzj38gEfI1RvWtEBcGuf9ltO5NtJrRJQoJucItbJ7MXic/Q8uPvALbtuN/xke06MuYJTbv1RcCQH0CoiWXpAgXilQB3nQTxU5SYTfcq5My1N3ygw/apfn1S3vn/wPHQeYoed1yhxBxvmNRkqWFtfVIbv3cHu1+pku/+jRtO3v4j4i1O/qOyvBBMA7KnHJJC0GwIElw== 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=T76og9OrKSgNYBPGf8/+TOj5cE0WD5KLDAV7sLbdVPg=; b=6qPiNYzMQwr92tVKWAC5LgR7TbpRnv0ezBgixqE439l7ix0dR5DHkjYp7HZ+4Ogbgl9bNYxRgwfH9xdVU4+W3SQgFEPyP9f4+DZpmDrFO6WxTVf5gNDpLuYDcnzIYjiPTkmGuOS7BC+2hXObBbSSnd8v5I9rE/O7Q6FH6aq0GeA= Received: from AS8PR07CA0041.eurprd07.prod.outlook.com (2603:10a6:20b:459::31) by DU0PR08MB10368.eurprd08.prod.outlook.com (2603:10a6:10:408::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.19; Thu, 9 Mar 2023 14:52:55 +0000 Received: from VI1EUR03FT013.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:459:cafe::31) by AS8PR07CA0041.outlook.office365.com (2603:10a6:20b:459::31) 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:52:55 +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 VI1EUR03FT013.mail.protection.outlook.com (100.127.145.11) 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:52:55 +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.17; Thu, 9 Mar 2023 14:52:54 +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.17; Thu, 9 Mar 2023 14:52:54 +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:53 +0000 From: Joey Gouly To: CC: , , , , , , , , , , Subject: [PATCH v1 09/18] KVM: arm64: Save/restore TCR2_EL1 Date: Thu, 9 Mar 2023 14:52:37 +0000 Message-ID: <20230309145246.22787-10-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: VI1EUR03FT013:EE_|DU0PR08MB10368:EE_|DBAEUR03FT018:EE_|DB9PR08MB7674:EE_ X-MS-Office365-Filtering-Correlation-Id: 89bdb59b-d39e-40a5-ba73-08db20ae18c1 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: /K/Fv8FxLXl+/ycurdyW9bIhVWk7+RWRT6NhyZINMGGHLnj/XMQrMnX7tCvTLjVkpqYk1KeYz9HLiMkUzUA7+ZDJmQ14GjfaF3J6avT8lzP+fznw7Ra7UdXzRV9C0zY3eJUBlhdLweLexSHeSw3JlAnJEP56uEk5iCNyWRm8EBtzPKqks5KYwDe+eirdJGVIuzP1Gt8Uveo8W57IRBGEVuO3iVm2Yk6t/p31CYrcs8CQ3xmte0zxw6o0J3xZf+JNnvU//ZPMU195CeY4EaYjA7quLB2YNuTeyQ2q4AhmvVboV50cwN/SnQei5Pw0CpoZdK/TXxs6UeHzFtb3CwBVJe+WkHZD7hRpvcgXSHOtQQ6iItSYewvRBqOoxECcic28MjOZl4ZIJAy5EMR402hiqNoGO00CznxZO5KqCH4oquJ0F2a5TCq92BV05V66glthcDVy/N8Ns/WjDWERBIogMAmsEa3EB03hsZ8pMUgaxlzsOEqAey9PeUMpkNGTn3UvOwSbdwUMemR/P2qcrGbxATkbm+oLYBYMlYO3sN83B/6WBNBk6ZpbisxMrm1JZNp3DusJRn7Ehh8JhjWGB7MKe6nshZROjytOFwTGhBAQyf+rW8Y1DdDfEsFhbEWLieViELKCAzfThfwzFqjMiozXLVnW+NqP17uejzmPovwEL9pgmnekWO1VjqfJ1oUyrQbG2Liw3PEELTaUIWbiPco+mA== 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)(396003)(136003)(376002)(346002)(39860400002)(451199018)(46966006)(36840700001)(426003)(336012)(47076005)(54906003)(36756003)(316002)(40480700001)(186003)(86362001)(478600001)(81166007)(36860700001)(82740400003)(26005)(1076003)(6666004)(83380400001)(82310400005)(356005)(2616005)(8936002)(7696005)(5660300002)(41300700001)(44832011)(2906002)(6916009)(70206006)(8676002)(4326008)(70586007)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB10368 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT018.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: cd724adf-e495-4737-a295-08db20adf763 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LqcP8qsje9K6k2iQ6erQhxB6zgTV1AV0soCdHz3lmQk4HOazIMWhJy7ZmLYAIbohFw0s57nR/bXVN1lgK0bPCOOjyF0Wq1bddEL/7kkZZKiZbvZkl4yVvxaUzMQ8W2qLnTDVSyf3b90ZtO1aPnT8PwxvkPWt66pnTMggoamCML5v08xDCkGgH+CL4+/UqxXuso+A3HLrNYvKedGreqOPmeWvgLQkPVB785HbapNWZl/61SIdPjHJnlViYrx0wQWjL5Pgn2TFJ6qgcARCa5/iS9XPt1ISvLW2rv6sA15kS0d4QDG+OfRowGb4cOimL1kkQqakwaadnAQ809vz329So0aSlcXavwBspsU5AT4AsE4yb/e17AAJP79HtdIF6vCt7y87Eb4948WFmdFE78z9BwCgJfB46t1sf6L6gz7u4KR0RtxjAMa0rb3C0KLwVTZ6lHzTTQtTluhkETEL/cBK2xmcz5lMz58UDBM1IQU5ykAzCHGCBvw8/8AmaW+hOl3KkGJXH9d4jR/N2a6Fp7kxxpCRrCZhJnHRjY8v8bqacz/VbRdqPMvZXOkEzGpcMiXXKnd7PiW4HfKfxc6bwDB7APyLEE8I2+be1H0xw5Guy43wnU7Oa7EVGpSLPDyzwK9JjnHK7BpB5H6fkY2G67miwKIFMMO+X+qNgNLxHNF+/AXqEmhm0X1/in7MEitgJivQQJlNRinvvgIU5jzmFooVYQ== 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)(39860400002)(136003)(376002)(396003)(346002)(451199018)(46966006)(36840700001)(40470700004)(83380400001)(2616005)(82310400005)(336012)(81166007)(426003)(47076005)(44832011)(36860700001)(4326008)(8676002)(70586007)(6916009)(5660300002)(2906002)(26005)(186003)(70206006)(82740400003)(7696005)(41300700001)(36756003)(478600001)(8936002)(6666004)(107886003)(1076003)(40460700003)(54906003)(316002)(40480700001)(86362001);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Mar 2023 14:53:51.4648 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 89bdb59b-d39e-40a5-ba73-08db20ae18c1 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: DBAEUR03FT018.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB7674 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230309_065402_441647_FA5FA962 X-CRM114-Status: UNSURE ( 9.73 ) 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 Define the new system register TCR2_EL1 and context switch it. Signed-off-by: Joey Gouly Cc: Marc Zyngier Cc: Oliver Upton Cc: James Morse Cc: Suzuki K Poulose Cc: Zenghui Yu Cc: Catalin Marinas Cc: Will Deacon Reviewed-by: Catalin Marinas --- arch/arm64/include/asm/kvm_host.h | 1 + arch/arm64/kvm/hyp/include/hyp/sysreg-sr.h | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h index a1892a8f6032..799857ba281d 100644 --- a/arch/arm64/include/asm/kvm_host.h +++ b/arch/arm64/include/asm/kvm_host.h @@ -266,6 +266,7 @@ enum vcpu_sysreg { TTBR0_EL1, /* Translation Table Base Register 0 */ TTBR1_EL1, /* Translation Table Base Register 1 */ TCR_EL1, /* Translation Control Register */ + TCR2_EL1, /* Extended Translation Control Register */ ESR_EL1, /* Exception Syndrome Register */ AFSR0_EL1, /* Auxiliary Fault Status Register 0 */ AFSR1_EL1, /* Auxiliary Fault Status Register 1 */ diff --git a/arch/arm64/kvm/hyp/include/hyp/sysreg-sr.h b/arch/arm64/kvm/hyp/include/hyp/sysreg-sr.h index 699ea1f8d409..16199a107a47 100644 --- a/arch/arm64/kvm/hyp/include/hyp/sysreg-sr.h +++ b/arch/arm64/kvm/hyp/include/hyp/sysreg-sr.h @@ -44,6 +44,8 @@ static inline void __sysreg_save_el1_state(struct kvm_cpu_context *ctxt) ctxt_sys_reg(ctxt, TTBR0_EL1) = read_sysreg_el1(SYS_TTBR0); ctxt_sys_reg(ctxt, TTBR1_EL1) = read_sysreg_el1(SYS_TTBR1); ctxt_sys_reg(ctxt, TCR_EL1) = read_sysreg_el1(SYS_TCR); + if (cpus_have_final_cap(ARM64_HAS_TCR2)) + ctxt_sys_reg(ctxt, TCR2_EL1) = read_sysreg_el1(SYS_TCR2); ctxt_sys_reg(ctxt, ESR_EL1) = read_sysreg_el1(SYS_ESR); ctxt_sys_reg(ctxt, AFSR0_EL1) = read_sysreg_el1(SYS_AFSR0); ctxt_sys_reg(ctxt, AFSR1_EL1) = read_sysreg_el1(SYS_AFSR1); @@ -114,6 +116,8 @@ static inline void __sysreg_restore_el1_state(struct kvm_cpu_context *ctxt) write_sysreg_el1(ctxt_sys_reg(ctxt, CPACR_EL1), SYS_CPACR); write_sysreg_el1(ctxt_sys_reg(ctxt, TTBR0_EL1), SYS_TTBR0); write_sysreg_el1(ctxt_sys_reg(ctxt, TTBR1_EL1), SYS_TTBR1); + if (cpus_have_final_cap(ARM64_HAS_TCR2)) + write_sysreg_el1(ctxt_sys_reg(ctxt, TCR2_EL1), SYS_TCR2); write_sysreg_el1(ctxt_sys_reg(ctxt, ESR_EL1), SYS_ESR); write_sysreg_el1(ctxt_sys_reg(ctxt, AFSR0_EL1), SYS_AFSR0); write_sysreg_el1(ctxt_sys_reg(ctxt, AFSR1_EL1), SYS_AFSR1);