From mboxrd@z Thu Jan 1 00:00:00 1970 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 0AE8C47010D; Tue, 21 Jul 2026 20:25:07 +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=1784665508; cv=none; b=XVXORTfesuVwWW7qS6aIAyrMDz7WtV9HDRbfAcXzVPZgXJhyWgogBhVq2wOn3CAxgN3AAN931GAFefe+5s0g6WfqBBZbQfiHrPDHnmxVKpkakk3W/maJ6Vm3UDxkYFqo8FxfRjITwqhsSRArZznkaLRmwFcAm3c9KDBIj2HYMsQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784665508; c=relaxed/simple; bh=BKMIf0WMwmhUf1HuQiZ9KXCVmZtbijhE/T4cY88GuHc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fJxYRJEKEPhjodomY4JpMC3N1ybVdHTk6o1aHglKQAbHG0FpImK/cSu/pz+BjvMtp8r4/B3NNdZCaSzcprEzsUaGY0a1ILA/bBdnGhpJet9xbhnT9GKjsl+BWLFb1I5/AfVw2nySGUZBblQPDdMmmm8RGDXAObPFLZQojWbCG10= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=dLHbqJF7; 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="dLHbqJF7" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6F6381F000E9; Tue, 21 Jul 2026 20:25:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784665506; bh=7yzWhdIx837cAcqNPxg/WmhfedotoUEeJSvve7+zlTk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=dLHbqJF7xlxFICuXN/9mf4kgtoIyRuKONbyppnXe4dL7N7LfjXR6g3v/s+8zmF7dh vGMkt6vTkBWrsDP/k+JpT5XuOLkxsl85LnlN8LsxLC6R2H+A1NXtSpWHo/CxjJjwAy GYYZz5KLGgBHswoZkkrYhZvwSmwVRgKRz0rFC0MQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Hyunwoo Kim , Fuad Tabba , Marc Zyngier , Fuad Tabba , Sasha Levin Subject: [PATCH 6.6 0331/1266] KVM: arm64: Clear __hyp_running_vcpu when flushing the pKVM hyp vCPU Date: Tue, 21 Jul 2026 17:12:48 +0200 Message-ID: <20260721152449.239274716@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152441.786066624@linuxfoundation.org> References: <20260721152441.786066624@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 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Hyunwoo Kim commit e8042f6e1d7befb2fb6b10a75918642bcd0acf9a upstream. flush_hyp_vcpu() copies the host vCPU context into the hyp's private vCPU on every run. ctxt_to_vcpu() expects a guest context to have a NULL __hyp_running_vcpu, which is only ever set on the host context, so that it resolves the vCPU via container_of(). While this is generally the case, flush_hyp_vcpu() copies the context verbatim and does not enforce this, so a value provided by the host is dereferenced at EL2 (host -> EL2). Fix by clearing __hyp_running_vcpu after the copy. Cc: stable@vger.kernel.org Fixes: be66e67f1750 ("KVM: arm64: Use the pKVM hyp vCPU structure in handle___kvm_vcpu_run()") Signed-off-by: Hyunwoo Kim Reviewed-by: Fuad Tabba Tested-by: Fuad Tabba Link: https://patch.msgid.link/20260606175614.83273-2-imv4bel@gmail.com Signed-off-by: Marc Zyngier [ tabba: adjust flush_hyp_vcpu() context ] Signed-off-by: Fuad Tabba Signed-off-by: Sasha Levin --- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/arm64/kvm/hyp/nvhe/hyp-main.c b/arch/arm64/kvm/hyp/nvhe/hyp-main.c index aa6c486667e706..ac0d5a0de01496 100644 --- a/arch/arm64/kvm/hyp/nvhe/hyp-main.c +++ b/arch/arm64/kvm/hyp/nvhe/hyp-main.c @@ -33,6 +33,9 @@ static void flush_hyp_vcpu(struct pkvm_hyp_vcpu *hyp_vcpu) hyp_vcpu->vcpu.arch.ctxt = host_vcpu->arch.ctxt; + /* __hyp_running_vcpu must be NULL in a guest context. */ + hyp_vcpu->vcpu.arch.ctxt.__hyp_running_vcpu = NULL; + hyp_vcpu->vcpu.arch.sve_state = kern_hyp_va(host_vcpu->arch.sve_state); hyp_vcpu->vcpu.arch.sve_max_vl = host_vcpu->arch.sve_max_vl; -- 2.53.0