Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp5911689rwr; Tue, 9 May 2023 07:52:19 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4NaavFiPC6NDkJl3cUfxdq8Ig4Ffd4sfCNrYw7HM76WknUcv/trPWRnSV2MpFTU+ed/AK+ X-Received: by 2002:a05:6a20:158e:b0:101:c4df:ee73 with SMTP id h14-20020a056a20158e00b00101c4dfee73mr64005pzj.21.1683643939636; Tue, 09 May 2023 07:52:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683643939; cv=none; d=google.com; s=arc-20160816; b=t3w8fnCMsZ4sz0MaWbpaM6nMzVrn9DWYtfbXdnjzW5vgRpkHyTJ3V1pcW+hHzIRx87 p2/mvv7pNtTGZcqZq6BhGLL62Y8NjPtmnPXSjtZYim6qfqsjrbMdgOXV+pSrpyqYB3UF v3Lng+r2CNoCQ+Aw7102icSSc7ooPh1m3UHrcQUv1w21vrcYvRuBzM3aNoR6u3ILYQ06 snRzzcjNdL4W/VUNz2uYi7z6EotWzc48MemwOVobkEmqsJq4R92NpBAeOAKIx/v8lYRC C5M35fVwr0oLYM5gl6F9BPEv8tOFUyPWDMIr4qTK1GJlT5gm0/KGJ2nIk/kqEhsUHlqB cNIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=2XBmNWJBMx1jrXOvE7WAmvQjwDJKOQnh7RFqH8eyNW4=; b=uBbLhUaaAKxe/Mal0FTfx75d6UjxUvi6F6kU817VSJa0m/g8QkIA7RJs0gH3JKWyTo VcXDZLNn8PosUymYpTWtrjEJQHon1BdZ6BxlBGIXY4+7DzJNNE803be21eWZoi6+ffHR 5Mup154zoXR24/Mb/CumBWPuh9hR2+k/wVFWqKqijlf1Ahb02l8q+YNYtewp9zCSN9EE G3TdcAKB4at0/TVAaLu6P+RKCdGqwqOjXQJHhWK5x7bEkPEMwwL/FIckz52IGPWLOpTq 4DOOvNseA7TBjSrl/Xqv09CfRpdF5kuGpLHkdimSzU+dngfS7mZoSBPUAMaZqpZARUon 8NQA== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a192-20020a6390c9000000b005192614041esi1554074pge.519.2023.05.09.07.52.05; Tue, 09 May 2023 07:52:19 -0700 (PDT) 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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235847AbjEIOXd (ORCPT + 99 others); Tue, 9 May 2023 10:23:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235839AbjEIOX0 (ORCPT ); Tue, 9 May 2023 10:23:26 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4632044AA for ; Tue, 9 May 2023 07:23:25 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 855A9FEC; Tue, 9 May 2023 07:24:09 -0700 (PDT) Received: from e126864.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id DA7993F663; Tue, 9 May 2023 07:23:21 -0700 (PDT) From: Kristina Martsenko To: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev Cc: Catalin Marinas , Will Deacon , Marc Zyngier , Oliver Upton , James Morse , Suzuki K Poulose , Zenghui Yu , Mark Rutland , Mark Brown , Luis Machado , Vladimir Murzin , linux-kernel@vger.kernel.org Subject: [PATCH v2 03/11] KVM: arm64: switch HCRX_EL2 between host and guest Date: Tue, 9 May 2023 15:22:27 +0100 Message-Id: <20230509142235.3284028-4-kristina.martsenko@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230509142235.3284028-1-kristina.martsenko@arm.com> References: <20230509142235.3284028-1-kristina.martsenko@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Switch the HCRX_EL2 register between host and guest configurations, in order to enable different features in the host and guest. Now that there are separate guest flags, we can also remove SMPME from the host flags, as SMPME is used for virtualizing SME priorities and has no use in the host. Signed-off-by: Kristina Martsenko --- arch/arm64/include/asm/kvm_arm.h | 3 ++- arch/arm64/kvm/hyp/include/hyp/switch.h | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/arch/arm64/include/asm/kvm_arm.h b/arch/arm64/include/asm/kvm_arm.h index fb7fe28b8eb8..7bb2fbddda54 100644 --- a/arch/arm64/include/asm/kvm_arm.h +++ b/arch/arm64/include/asm/kvm_arm.h @@ -93,7 +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_HOST_FLAGS (HCRX_EL2_SMPME) +#define HCRX_GUEST_FLAGS (HCRX_EL2_SMPME) +#define HCRX_HOST_FLAGS 0 /* TCR_EL2 Registers bits */ #define TCR_EL2_RES1 ((1U << 31) | (1 << 23)) diff --git a/arch/arm64/kvm/hyp/include/hyp/switch.h b/arch/arm64/kvm/hyp/include/hyp/switch.h index c41166f1a1dd..8f95bcbe6cdf 100644 --- a/arch/arm64/kvm/hyp/include/hyp/switch.h +++ b/arch/arm64/kvm/hyp/include/hyp/switch.h @@ -130,6 +130,9 @@ static inline void ___activate_traps(struct kvm_vcpu *vcpu) if (cpus_have_final_cap(ARM64_HAS_RAS_EXTN) && (hcr & HCR_VSE)) write_sysreg_s(vcpu->arch.vsesr_el2, SYS_VSESR_EL2); + + if (cpus_have_final_cap(ARM64_HAS_HCX)) + write_sysreg_s(HCRX_GUEST_FLAGS, SYS_HCRX_EL2); } static inline void ___deactivate_traps(struct kvm_vcpu *vcpu) @@ -144,6 +147,9 @@ static inline void ___deactivate_traps(struct kvm_vcpu *vcpu) vcpu->arch.hcr_el2 &= ~HCR_VSE; vcpu->arch.hcr_el2 |= read_sysreg(hcr_el2) & HCR_VSE; } + + if (cpus_have_final_cap(ARM64_HAS_HCX)) + write_sysreg_s(HCRX_HOST_FLAGS, SYS_HCRX_EL2); } static inline bool __populate_fault_info(struct kvm_vcpu *vcpu) -- 2.25.1