Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp10357166rwl; Wed, 11 Jan 2023 19:02:12 -0800 (PST) X-Google-Smtp-Source: AMrXdXtaub8IoX8dxMC4Iwbt76ufL4uTwM+3/BpaEHR9UqDlsmjuQfZl138WkpIGWFSG68ywelLX X-Received: by 2002:a17:906:d96c:b0:7c1:7cc2:1f1e with SMTP id rp12-20020a170906d96c00b007c17cc21f1emr71954281ejb.35.1673492532254; Wed, 11 Jan 2023 19:02:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673492532; cv=none; d=google.com; s=arc-20160816; b=Uhnw9maWv14doTi4a5jhBmtNbSDrTQfU3Rhgipf98b5eZt/VESSunQQxR9kqGcnSXx 4TEqu0qeaAh0ug+Hag4XmNroyj8MvGH9JgsLLD3NkYbkNfUCP6ulOvzIw++7c7zx39IW mDm/j+fvu9IM1nA0sn8zWIppwe1c5XlVLqECwMIa9kOp1+YtsS09pxZAQ7Na0v7I/OCi fm3d5n29xvXrmFbaoV4F1tg2shfjwXFgmxZf2E1dlwff5KEthqF7RmVT98mh8+3EOJhe 2ADzcfQmemf0tg4irfLAOO0a614hAc0qkpm/LrP4+oDD1+pHpSsTkSfMKISQotVs7O8U 6MEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:from :dkim-signature; bh=cYxegMlY1FatV7PXb3AA4EIUSYjnPjYmvybwh7FATNs=; b=oyonrJ2JMAU4g5TGm/BIxrJv7xJpPrFRvI1hkfg71ZABPCL/zEt5tjpIhIkR8hw1RK OIZen/osRtoIkLOMliYoUfEwKFYtRdNqKCQhaMxLBak9F8kS8Ar7JPSmKXKTrpYkHbn1 mVVXFp2kLwo/iQ8TwGMG0MjY/UEBo4Krb4T0HiJUyzY6YLgKR74Ikn5eLVpGxYELhMpJ vHpIZDc3UVOvLyanfeqX3t8Ae0FzDcVM7ytEnlDVbbhehZcKpXzRLNYuDh1018OvvjwP A6fdECxUn2vIgGWgLS8fU7J+3rK7c+t1F+7pJbioM31WfdroF1IJAs0JaR0B9o/z2ua4 ok8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@daynix-com.20210112.gappssmtp.com header.s=20210112 header.b=Sy0ffk1i; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g14-20020a056402090e00b00468eee7250csi7190597edz.510.2023.01.11.19.02.00; Wed, 11 Jan 2023 19:02:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@daynix-com.20210112.gappssmtp.com header.s=20210112 header.b=Sy0ffk1i; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235945AbjALCjl (ORCPT + 50 others); Wed, 11 Jan 2023 21:39:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236177AbjALCjb (ORCPT ); Wed, 11 Jan 2023 21:39:31 -0500 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C49E4829F for ; Wed, 11 Jan 2023 18:39:28 -0800 (PST) Received: by mail-pj1-x1033.google.com with SMTP id w4-20020a17090ac98400b002186f5d7a4cso22161091pjt.0 for ; Wed, 11 Jan 2023 18:39:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=cYxegMlY1FatV7PXb3AA4EIUSYjnPjYmvybwh7FATNs=; b=Sy0ffk1iTCqZGcuYn5rZ3dO6Ms9tShAHrSFiHHl5vs2VNkzzu6x1RHRpNXHVKSIPUP vUXSos1w82yUCL7pURE0eojiMVE+VacPMDsom+mmPgWIP39tqJiHqX7unjUM9oiH15NF ramVsXzn2WJiyhi4u3AcWLVz1GZhnybocvnC7yfTuSKmoob+47+s0W32P2Law/pPPK3f Jk2QedXfFDIdz84KxpZp7c42v+k6CAzQkXwCYKuZsZUdaHrDD2Asz+Ot8J3tO+awDpzy 0+nPcKkEkITBa5mzuowYHwAu4Bb+fmujjGgzo2+nzM9N5UtqxxITqAi0EY324kei7rF+ KnZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cYxegMlY1FatV7PXb3AA4EIUSYjnPjYmvybwh7FATNs=; b=CO8FbqtRE+QqgpHOyTZAvtmkRAhkc4p+0MCriQeYcQWOpL7YIK6qXRm5u/vQaFzzbS MNccwMmo+KUS06GdLCb+5bhmF7LH6WVKxJ+XZdgWdmsFzNlbpKlJN8nSs3j1oPoX0m4E JmN1ewc27IxAHOcFlKzsHn4JvY4Q+K4sT9yI4fSxPNs6VC8ekMKMHjviNU9N2QvfJjdM BomMXhToIlQ0tzTwpzCEsNFzDT4oUm3fmVz93AFZ6/uzNTa3QqsojUj7y8Y85lgl+RqH iz17qLuwpoDHAc8/ZYgHRHCYkp+YhyXk50cHjwVp9vRwMllqJnG7Jl1M6G0eyUk2ZND9 HDNQ== X-Gm-Message-State: AFqh2krIW1gRFdTVnLJtn1owVbIq1BD9xrALOV9vSknxhT+Sr+6Ox49F ULwejOXHp8mjRHZe1bjamYDLkA== X-Received: by 2002:a17:902:6b08:b0:191:3c6:1748 with SMTP id o8-20020a1709026b0800b0019103c61748mr75203524plk.11.1673491167559; Wed, 11 Jan 2023 18:39:27 -0800 (PST) Received: from fedora.flets-east.jp ([2400:4050:a840:1e00:d54:e521:8bac:7bed]) by smtp.gmail.com with ESMTPSA id w7-20020a1709027b8700b001944b1285easm2310331pll.198.2023.01.11.18.39.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Jan 2023 18:39:26 -0800 (PST) From: Akihiko Odaki Cc: Mark Brown , Marc Zyngier , linux-kernel@vger.kernel.org, kvmarm@lists.linux.dev, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, Mathieu Poirier , Oliver Upton , Suzuki K Poulose , Alexandru Elisei , James Morse , Will Deacon , Catalin Marinas , asahi@lists.linux.dev, Alyssa Rosenzweig , Sven Peter , Hector Martin , Akihiko Odaki , Reiji Watanabe Subject: [PATCH v7 5/7] KVM: arm64: Always set HCR_TID2 Date: Thu, 12 Jan 2023 11:38:50 +0900 Message-Id: <20230112023852.42012-6-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230112023852.42012-1-akihiko.odaki@daynix.com> References: <20230112023852.42012-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Always set HCR_TID2 to trap CTR_EL0, CCSIDR2_EL1, CLIDR_EL1, and CSSELR_EL1. This saves a few lines of code and allows to employ their access trap handlers for more purposes anticipated by the old condition for setting HCR_TID2. Suggested-by: Marc Zyngier Signed-off-by: Akihiko Odaki Reviewed-by: Reiji Watanabe --- arch/arm64/include/asm/kvm_arm.h | 3 ++- arch/arm64/include/asm/kvm_emulate.h | 4 ---- arch/arm64/include/asm/kvm_host.h | 2 -- arch/arm64/kvm/hyp/include/hyp/sysreg-sr.h | 2 -- 4 files changed, 2 insertions(+), 9 deletions(-) diff --git a/arch/arm64/include/asm/kvm_arm.h b/arch/arm64/include/asm/kvm_arm.h index 0df3fc3a0173..158f2033fde9 100644 --- a/arch/arm64/include/asm/kvm_arm.h +++ b/arch/arm64/include/asm/kvm_arm.h @@ -81,11 +81,12 @@ * SWIO: Turn set/way invalidates into set/way clean+invalidate * PTW: Take a stage2 fault if a stage1 walk steps in device memory * TID3: Trap EL1 reads of group 3 ID registers + * TID2: Trap CTR_EL0, CCSIDR2_EL1, CLIDR_EL1, and CSSELR_EL1 */ #define HCR_GUEST_FLAGS (HCR_TSC | HCR_TSW | HCR_TWE | HCR_TWI | HCR_VM | \ HCR_BSU_IS | HCR_FB | HCR_TACR | \ HCR_AMO | HCR_SWIO | HCR_TIDCP | HCR_RW | HCR_TLOR | \ - HCR_FMO | HCR_IMO | HCR_PTW | HCR_TID3 ) + HCR_FMO | HCR_IMO | HCR_PTW | HCR_TID3 | HCR_TID2) #define HCR_VIRT_EXCP_MASK (HCR_VSE | HCR_VI | HCR_VF) #define HCR_HOST_NVHE_FLAGS (HCR_RW | HCR_API | HCR_APK | HCR_ATA) #define HCR_HOST_NVHE_PROTECTED_FLAGS (HCR_HOST_NVHE_FLAGS | HCR_TSC) diff --git a/arch/arm64/include/asm/kvm_emulate.h b/arch/arm64/include/asm/kvm_emulate.h index 9bdba47f7e14..30c4598d643b 100644 --- a/arch/arm64/include/asm/kvm_emulate.h +++ b/arch/arm64/include/asm/kvm_emulate.h @@ -88,10 +88,6 @@ static inline void vcpu_reset_hcr(struct kvm_vcpu *vcpu) if (vcpu_el1_is_32bit(vcpu)) vcpu->arch.hcr_el2 &= ~HCR_RW; - if (cpus_have_const_cap(ARM64_MISMATCHED_CACHE_TYPE) || - vcpu_el1_is_32bit(vcpu)) - vcpu->arch.hcr_el2 |= HCR_TID2; - if (kvm_has_mte(vcpu->kvm)) vcpu->arch.hcr_el2 |= HCR_ATA; } diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h index 35a159d131b5..374390a9212e 100644 --- a/arch/arm64/include/asm/kvm_host.h +++ b/arch/arm64/include/asm/kvm_host.h @@ -705,7 +705,6 @@ static inline bool __vcpu_read_sys_reg_from_cpu(int reg, u64 *val) return false; switch (reg) { - case CSSELR_EL1: *val = read_sysreg_s(SYS_CSSELR_EL1); break; case SCTLR_EL1: *val = read_sysreg_s(SYS_SCTLR_EL12); break; case CPACR_EL1: *val = read_sysreg_s(SYS_CPACR_EL12); break; case TTBR0_EL1: *val = read_sysreg_s(SYS_TTBR0_EL12); break; @@ -750,7 +749,6 @@ static inline bool __vcpu_write_sys_reg_to_cpu(u64 val, int reg) return false; switch (reg) { - case CSSELR_EL1: write_sysreg_s(val, SYS_CSSELR_EL1); break; case SCTLR_EL1: write_sysreg_s(val, SYS_SCTLR_EL12); break; case CPACR_EL1: write_sysreg_s(val, SYS_CPACR_EL12); break; case TTBR0_EL1: write_sysreg_s(val, SYS_TTBR0_EL12); break; diff --git a/arch/arm64/kvm/hyp/include/hyp/sysreg-sr.h b/arch/arm64/kvm/hyp/include/hyp/sysreg-sr.h index baa5b9b3dde5..147cb4c846c6 100644 --- a/arch/arm64/kvm/hyp/include/hyp/sysreg-sr.h +++ b/arch/arm64/kvm/hyp/include/hyp/sysreg-sr.h @@ -39,7 +39,6 @@ static inline bool ctxt_has_mte(struct kvm_cpu_context *ctxt) static inline void __sysreg_save_el1_state(struct kvm_cpu_context *ctxt) { - ctxt_sys_reg(ctxt, CSSELR_EL1) = read_sysreg(csselr_el1); ctxt_sys_reg(ctxt, SCTLR_EL1) = read_sysreg_el1(SYS_SCTLR); ctxt_sys_reg(ctxt, CPACR_EL1) = read_sysreg_el1(SYS_CPACR); ctxt_sys_reg(ctxt, TTBR0_EL1) = read_sysreg_el1(SYS_TTBR0); @@ -95,7 +94,6 @@ static inline void __sysreg_restore_user_state(struct kvm_cpu_context *ctxt) static inline void __sysreg_restore_el1_state(struct kvm_cpu_context *ctxt) { write_sysreg(ctxt_sys_reg(ctxt, MPIDR_EL1), vmpidr_el2); - write_sysreg(ctxt_sys_reg(ctxt, CSSELR_EL1), csselr_el1); if (has_vhe() || !cpus_have_final_cap(ARM64_WORKAROUND_SPECULATIVE_AT)) { -- 2.39.0