From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-185.mta0.migadu.com (out-185.mta0.migadu.com [91.218.175.185]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A72E012F5B8 for ; Fri, 31 May 2024 23:14:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.185 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717197267; cv=none; b=TMv96xa+IEnYZ9iO+ULqkQBFSclwPBWLThZLp58nU1zksV1kqJl7DUssWXQambbzQU04LXnlNqZ8JeVEqnoIwd73eOY7PVRg6xt5ohp/ZbzXtfvMlxHt7AA57Kx6pwdaYWtgZ47biWdg7BEdBwYbVhxPcOnWbYZttO45Ct8zZSo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717197267; c=relaxed/simple; bh=ZYqCChw0hfWIeJR9KxVug6g2WJ+ytT95ljLL0/noKvg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kwwFWdP+5ABssDi5K+XtBazX6/OCenpARvJknEoVPb1u0dtFwz7p88pp14nM/RA2T3/3S4rUh2ZUFmXhxHfIm/RdhrxFb3eE/Oh6e5icD3pEJvxBvfZg0CmTyonfq3nyuZbWiVLB3PR4ph5ZtsW0mS6+kNUwmoSRSb2HOGUQpUc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=ghl/Iskz; arc=none smtp.client-ip=91.218.175.185 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="ghl/Iskz" X-Envelope-To: kvmarm@lists.linux.dev DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1717197264; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QihSmQoz0iowSjFRYFy48HKQHNUekF/0Bi4J8iGu+ks=; b=ghl/Iskz6sOklQTuwb1xCLhhyeG62isYKB8zqePtNtgsUh3OXjaj8LhQrQz1QbLDBdCBHB TZJNKRobvDJopV1f+1jCh1tK7598MqG3SVvR0Ocwh6c2bmzSMXIEKLLRrjOCrga8AnJkK8 w2ROOHBisH0hrbKsjVkRZkWROjytPbg= X-Envelope-To: maz@kernel.org X-Envelope-To: james.morse@arm.com X-Envelope-To: suzuki.poulose@arm.com X-Envelope-To: yuzenghui@huawei.com X-Envelope-To: kvm@vger.kernel.org X-Envelope-To: oliver.upton@linux.dev X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Oliver Upton To: kvmarm@lists.linux.dev Cc: Marc Zyngier , James Morse , Suzuki K Poulose , Zenghui Yu , kvm@vger.kernel.org, Oliver Upton Subject: [PATCH 06/11] KVM: arm64: nv: Save guest's ZCR_EL2 when in hyp context Date: Fri, 31 May 2024 23:13:53 +0000 Message-ID: <20240531231358.1000039-7-oliver.upton@linux.dev> In-Reply-To: <20240531231358.1000039-1-oliver.upton@linux.dev> References: <20240531231358.1000039-1-oliver.upton@linux.dev> Precedence: bulk X-Mailing-List: kvmarm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT When running a guest hypervisor, ZCR_EL2 is an alias for the counterpart EL1 state. Signed-off-by: Oliver Upton --- arch/arm64/kvm/fpsimd.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kvm/fpsimd.c b/arch/arm64/kvm/fpsimd.c index 1807d3a79a8a..53168bbea8a7 100644 --- a/arch/arm64/kvm/fpsimd.c +++ b/arch/arm64/kvm/fpsimd.c @@ -173,7 +173,16 @@ void kvm_arch_vcpu_put_fp(struct kvm_vcpu *vcpu) if (guest_owns_fp_regs()) { if (vcpu_has_sve(vcpu)) { - __vcpu_sys_reg(vcpu, ZCR_EL1) = read_sysreg_el1(SYS_ZCR); + u64 zcr = read_sysreg_el1(SYS_ZCR); + + /* + * If the vCPU is in the hyp context then ZCR_EL1 is + * loaded with its vEL2 counterpart. + */ + if (is_hyp_ctxt(vcpu)) + __vcpu_sys_reg(vcpu, ZCR_EL2) = zcr; + else + __vcpu_sys_reg(vcpu, ZCR_EL1) = zcr; /* * Restore the VL that was saved when bound to the CPU, -- 2.45.1.288.g0e0cd299f1-goog