Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 21C2638399A; Tue, 21 Jul 2026 17:16:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784654207; cv=none; b=JU48qGZ+bGKRecnww7ojzwDS13FCdRVZykshqwd3bmEpV66LgOMiP9ZyFzIB3Cs2rzPMzBdMuH7HXs0b/PEPt7lqHMM6mKOF7dOawQnqmuRflKVYjpGpzOh+KbJC0gY0D6VSOQejAKnZbObHT0Y4C9kpp1YAgYJvM0oXKPN3Luo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784654207; c=relaxed/simple; bh=4ZBLHNThIIrTUV2OW6fjSZN6UAEyeU02LdW4KZ04rZk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HVzauHwStbvXdc0x74uuvmuFUEnhkHQzwmIA9L+ZKYELCKnuW1VslD+WOkkIFMvZ8kZxVBJ5rLf21KVrrzeMRKNFLg0hqSRqYAP58K14Z2AsUDzZGHr8DfpPkOztBstNQTSo18p0qXY3NO+qojybLNxvfToaD0m4daebpRaDpyQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=fST5qqUA; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="fST5qqUA" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 897FF1F000E9; Tue, 21 Jul 2026 17:16:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784654206; bh=wuyqnUCAb6GPi39Ci02XfawjcgUDDSbeM755XxqLW4c=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=fST5qqUAfdtOhBIla/Pj4yY4rKkCk8YccsLAsAQo76DbIHbfgrz99T2m/oxeJQdGP Y5d5R1sDurPM02Rp5KFZlIg6W2jVWg9ZALHh0sL/1VGBTVaR6rU4r3g2sEO4pa9I6W MzkRh5kPUEUvIyK1uD/5GOKYhZUF8aTgPjqE+FQw= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Zhong Wang , Xuanqing Shi , Weiming Shi , Marc Zyngier Subject: [PATCH 7.1 1574/2077] KVM: arm64: nv: Fix SPSR_EL2 restore in kvm_hyp_handle_mops() Date: Tue, 21 Jul 2026 17:20:47 +0200 Message-ID: <20260721152629.903793846@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152552.646164743@linuxfoundation.org> References: <20260721152552.646164743@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Weiming Shi commit ff1022c3de46753eb7eba2f6efd990569e66ff95 upstream. kvm_hyp_handle_mops() resets the single-step state machine as part of rewinding state for a MOPS exception by modifying vcpu_cpsr() and writing the result directly into hardware. In the case of nested virtualization, vcpu_cpsr() is a synthetic value such that the rest of KVM can deal with vEL2 cleanly. That means the value requires translation before being written into hardware, which is unfortunately missing from the MOPS handler. Fix it by directly modifying SPSR_EL2 and avoiding the synthetic state altogether, which will be resynchronized on the next 'full' exit back to KVM. Fixes: 2de451a329cf ("KVM: arm64: Add handler for MOPS exceptions") Reported-by: Zhong Wang Reported-by: Xuanqing Shi Link: https://lore.kernel.org/all/ajE4lHQevXNHpl1M@Air.local/ Cc: stable@vger.kernel.org Signed-off-by: Weiming Shi Link: https://patch.msgid.link/20260617040820.2194831-2-bestswngs@gmail.com Signed-off-by: Marc Zyngier Signed-off-by: Greg Kroah-Hartman --- arch/arm64/kvm/hyp/include/hyp/switch.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) --- a/arch/arm64/kvm/hyp/include/hyp/switch.h +++ b/arch/arm64/kvm/hyp/include/hyp/switch.h @@ -448,16 +448,19 @@ static inline bool __populate_fault_info static inline bool kvm_hyp_handle_mops(struct kvm_vcpu *vcpu, u64 *exit_code) { + u64 spsr; + *vcpu_pc(vcpu) = read_sysreg_el2(SYS_ELR); arm64_mops_reset_regs(vcpu_gp_regs(vcpu), vcpu->arch.fault.esr_el2); write_sysreg_el2(*vcpu_pc(vcpu), SYS_ELR); /* * Finish potential single step before executing the prologue - * instruction. + * instruction. Modify the hardware SPSR_EL2 directly, as vcpu_cpsr() + * may hold a synthetic (vEL2) value for a guest hypervisor. */ - *vcpu_cpsr(vcpu) &= ~DBG_SPSR_SS; - write_sysreg_el2(*vcpu_cpsr(vcpu), SYS_SPSR); + spsr = read_sysreg_el2(SYS_SPSR); + write_sysreg_el2(spsr & ~DBG_SPSR_SS, SYS_SPSR); return true; }