Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp557720pxb; Wed, 25 Aug 2021 09:23:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyqFwJNAq0q3epLYKYDZHPfz9e//iizJcgMo0Yo6amUaBImNtmXutGThUQg1zNTBF8jZIUQ X-Received: by 2002:aa7:ce87:: with SMTP id y7mr49777413edv.306.1629908622526; Wed, 25 Aug 2021 09:23:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629908622; cv=none; d=google.com; s=arc-20160816; b=G3cN4o6fcSMlGsdqpW8mlAc8u1OQy43UsfNGweHNAWCmP5wH4I1H0uP0doaQNpQT7U I+vfO3Rqo7FjRk0Ju+nEKhN3bN8nseqrnGdwgg10VJonKcHKZ0XXkGR2KAY4e8FGWzCA 0Jb2lyUPh3rOQ7r5YpHf06VHfEyb5JRVR28ktVHoBoFySim46GZWvaWcX4SDMs1NImHB syQyXHXnw3SyquZgo5TL+PYt0R70AL6Nb6j0mEWwirvD/nJjHIXQ28ZUop/PJ9aA0i0M fry7CLRODNpUYep8lLSFgEHQqW81iAsKq37Sj4lcyGtxi7trvKS8FaxbZnX2ymjlz3M3 B+/g== 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:to:from; bh=ua1B8tV5Ap0LisxJ1O67GOQ53A57WCj3Q99v1nxngao=; b=V2GpJRo3ct4xHkGds/xozKCYm7Cxt+zfbG12uoN64yHhqfr9zivddmKgYJ/h8NY2uX Q1nK2AsNavtqGXb567L8uxjki9537f76hXnb9El40OIWq9soB/OjfW3QKzQ7xzsueQIc syu82XXsKGT5ER9ATJc/5P5GbizzIjx6eUuP+S+YCBhdi1e082BEBVVq4fX+cNSw37jh JWAuCpfVbE1S252Dp/HDvLkjANNBPhRlX4vZeYVrOeO8g9hj7LrdOReLLBZTBuFEvTbl z6ddQkn8gvs3qCyYOeSsbCps2aPFoF0NxRFkaDY55L+kxzHkSjI7uEhvGqhzYs1Cqtpu eLpw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h6si239464eje.225.2021.08.25.09.23.15; Wed, 25 Aug 2021 09:23:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S242071AbhHYQTJ (ORCPT + 99 others); Wed, 25 Aug 2021 12:19:09 -0400 Received: from foss.arm.com ([217.140.110.172]:54870 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241165AbhHYQSj (ORCPT ); Wed, 25 Aug 2021 12:18:39 -0400 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 D1D3513A1; Wed, 25 Aug 2021 09:17:52 -0700 (PDT) Received: from monolith.cable.virginm.net (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 84A133F66F; Wed, 25 Aug 2021 09:17:51 -0700 (PDT) From: Alexandru Elisei To: maz@kernel.org, james.morse@arm.com, suzuki.poulose@arm.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, will@kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH v4 25/39] KVM: arm64: Move the write to MDCR_EL2 out of __activate_traps_common() Date: Wed, 25 Aug 2021 17:18:01 +0100 Message-Id: <20210825161815.266051-26-alexandru.elisei@arm.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210825161815.266051-1-alexandru.elisei@arm.com> References: <20210825161815.266051-1-alexandru.elisei@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org To run a guest with SPE, MDCR_EL2 must be configured such that the buffer owning regime is EL1&0. With VHE enabled, the guest runs at EL2 and changing the owning regime to EL1&0 too early in vcpu_put() would mean creating an extended blackout window for the host. Move the MDCR_EL2 write out of __activate_traps_common() to prepare for executing it later in the run loop in the VHE case. This also makes __activate_traps_common() look more like __deactivate_traps_common(), which does not touch the register. No functional change intended. Signed-off-by: Alexandru Elisei --- arch/arm64/kvm/hyp/include/hyp/switch.h | 1 - arch/arm64/kvm/hyp/nvhe/switch.c | 2 ++ arch/arm64/kvm/hyp/vhe/switch.c | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kvm/hyp/include/hyp/switch.h b/arch/arm64/kvm/hyp/include/hyp/switch.h index e4a2f295a394..5084a54d012e 100644 --- a/arch/arm64/kvm/hyp/include/hyp/switch.h +++ b/arch/arm64/kvm/hyp/include/hyp/switch.h @@ -92,7 +92,6 @@ static inline void __activate_traps_common(struct kvm_vcpu *vcpu) write_sysreg(0, pmselr_el0); write_sysreg(ARMV8_PMU_USERENR_MASK, pmuserenr_el0); } - write_sysreg(vcpu->arch.mdcr_el2, mdcr_el2); } static inline void __deactivate_traps_common(void) diff --git a/arch/arm64/kvm/hyp/nvhe/switch.c b/arch/arm64/kvm/hyp/nvhe/switch.c index f7af9688c1f7..0c70d897a493 100644 --- a/arch/arm64/kvm/hyp/nvhe/switch.c +++ b/arch/arm64/kvm/hyp/nvhe/switch.c @@ -41,6 +41,8 @@ static void __activate_traps(struct kvm_vcpu *vcpu) ___activate_traps(vcpu); __activate_traps_common(vcpu); + write_sysreg(vcpu->arch.mdcr_el2, mdcr_el2); + val = CPTR_EL2_DEFAULT; val |= CPTR_EL2_TTA | CPTR_EL2_TAM; if (!update_fp_enabled(vcpu)) { diff --git a/arch/arm64/kvm/hyp/vhe/switch.c b/arch/arm64/kvm/hyp/vhe/switch.c index 86d4c8c33f3e..983ba1570d72 100644 --- a/arch/arm64/kvm/hyp/vhe/switch.c +++ b/arch/arm64/kvm/hyp/vhe/switch.c @@ -89,6 +89,8 @@ NOKPROBE_SYMBOL(__deactivate_traps); void activate_traps_vhe_load(struct kvm_vcpu *vcpu) { __activate_traps_common(vcpu); + + write_sysreg(vcpu->arch.mdcr_el2, mdcr_el2); } void deactivate_traps_vhe_put(void) -- 2.33.0