From nobody Mon Feb 9 11:47:53 2026 Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6C1383271E0 for ; Thu, 13 Nov 2025 22:56:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763074595; cv=none; b=R8ZxZnMjwwrB1oMpygkKe6M3FfGDMg841KwQD0K5h28ysZ7HRa34IsqWn9bLPh9rZ3mrmGOZP7TXdXdQPYt0ZTAt/re3snBr4s5NHqDVdK11mozZQuUPnfsJtqVrlCNcPdcpoiMAlSGEwKeq7pCyVLwZDjDGUAm6xncbRZaKKO4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763074595; c=relaxed/simple; bh=dooIsaMHUN0qX+ajs8N5jkyY00eEMse5x1PsDaesgCc=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=TbigQFfyFS3V208O328d5LpUqexrKFzN68KetS4MwWnqAff1Ap1nPlsDRoxJE/jQva35rEeXmorU2VvaXB44vVfDS4XlTiy5nRu0oTSJRZeOQkVmM2lMWjEXLLhwPQxw7V/sz45HHlBVJaeyVdWFQbiNbQ3ArR8rzNiQ5mUJ3/M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=M1btft1o; arc=none smtp.client-ip=209.85.214.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="M1btft1o" Received: by mail-pl1-f202.google.com with SMTP id d9443c01a7336-2956a694b47so16878745ad.1 for ; Thu, 13 Nov 2025 14:56:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1763074592; x=1763679392; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:reply-to:from:to:cc:subject:date :message-id:reply-to; bh=uTfLPg3dHJBu/ZKUp1ze2yjCBpHKVd90r/rQFmyW4xA=; b=M1btft1o5Tcm9ACBdEOq9U3KnJOBB+220wcDFk/m0pc+Cu5OZIZ3+gvyfFvuoihwS5 nZJCUi9rPrEdqSHtTstzOIatR8CaaS8rUI7yrqLvzY85PzHkO+d6CT4QMQx96GgUc+UH /YAuV3lOt+1UJn+EAVcg1RecfYKAA098/nnlAjucI5ysnjJL4ULhh8mzQiuvgs28zKdZ KTz/cAsfocuL849pS7iQ2hA2nts/0iTFFmxpCdAW2xR3FqYFSjpV4dSAt61Ft4lZKRkD wqKDbUTlrqgQ1eQmtRs25II+lKaSGk4x9wwjPSxjJXe3w5JDETP0yfMDsywM4Wb5U2zZ V0KA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763074592; x=1763679392; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:reply-to:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=uTfLPg3dHJBu/ZKUp1ze2yjCBpHKVd90r/rQFmyW4xA=; b=OeggM3mzyCbzHnHamxxlMYbIwuN2k/Uk7rdUdgXPblCd4enDkGQOacAzMtbl5OoTru n/9nAylKviJOUBvaDUJOIB3IXh+Y/aPAApe3jBtJVk0+6SU3WWNRiD+O3xoERflRx7QJ pDG7l6pg0ES25/f7ER1Gh61ILOGs6YyejO+7S19GpeTEW2tj617yb+RVJe17I4lB4HGT 3quIsZVL6i0YOA/5YD7zgw+OKSeDiiYGoMpwGW0/7yjCa2CGTo8l8jrD0bafhEav0kvo 42uHSv2bV/wdo7+T8sWG5oHdgIXLGL1JIW8ci49uKxZq4z+o+b1xsJHQgrcRnLTf/AZB w3MQ== X-Forwarded-Encrypted: i=1; AJvYcCXO9gvPXGu4HNN890dW4Q/e5zVgch1YbCTLaJnca7Eb4TGkudDsWqwL//76vpHAWBTH0jw/aSzivDrVVsE=@vger.kernel.org X-Gm-Message-State: AOJu0Yx1DNhPAJ1UHir/b2H3hf7VcqniIL+vndhUKMZHgJnHdeJ0X0yQ Q5Jr3jeWpDoPxEnAp7IQ4N0gBitI/pLhflgcgxjmeut+7Ghb9afMA7qYL6l4GFEtJUXNhq5VLxT BbbBpBA== X-Google-Smtp-Source: AGHT+IGqaleYBrBpIZDDEVOSXWg82pvZBfh9IfeZ7WNXzFngQTkVikEu8YA5GvKWL3ExVT05ZqFLMjWDxSE= X-Received: from pgnn15.prod.google.com ([2002:a05:6a02:4f0f:b0:bc2:9d07:6db1]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:903:2406:b0:295:24ab:fb06 with SMTP id d9443c01a7336-2986a6ceb22mr6800465ad.22.1763074591763; Thu, 13 Nov 2025 14:56:31 -0800 (PST) Reply-To: Sean Christopherson Date: Thu, 13 Nov 2025 14:56:14 -0800 In-Reply-To: <20251113225621.1688428-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20251113225621.1688428-1-seanjc@google.com> X-Mailer: git-send-email 2.52.0.rc1.455.g30608eb744-goog Message-ID: <20251113225621.1688428-3-seanjc@google.com> Subject: [PATCH 2/9] KVM: nSVM: Set exit_code_hi to -1 when synthesizing SVM_EXIT_ERR (failed VMRUN) From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini , Vitaly Kuznetsov , "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui Cc: kvm@vger.kernel.org, linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, Jim Mattson , Yosry Ahmed Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Set exit_code_hi to -1u as a temporary band-aid to fix a long-standing (effectively since KVM's inception) bug where KVM treats the exit code as a 32-bit value, when in reality it's a 64-bit value. Per the APM, offset 0x70 is a single 64-bit value: 070h 63:0 EXITCODE And a sane reading of the error values defined in "Table C-1. SVM Intercept Codes" is that negative values use the full 64 bits: =E2=80=931 VMEXIT_INVALID Invalid guest state in VMCB. =E2=80=932 VMEXIT_BUSYBUSY bit was set in the VMSA =E2=80=933 VMEXIT_IDLE_REQUIREDThe sibling thread is not in an idle state -4 VMEXIT_INVALID_PMC Invalid PMC state And that interpretation is confirmed by testing on Milan and Turin (by setting bits in CR0[63:32] to generate VMEXIT_INVALID on VMRUN). Furthermore, Xen has treated exitcode as a 64-bit value since HVM support was adding in 2006 (see Xen commit d1bd157fbc ("Big merge the HVM full-virtualisation abstractions.")). Cc: Jim Mattson Cc: Yosry Ahmed Cc: stable@vger.kernel.org Signed-off-by: Sean Christopherson Reviewed-by: Yosry Ahmed --- arch/x86/kvm/svm/nested.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c index c81005b24522..ba0f11c68372 100644 --- a/arch/x86/kvm/svm/nested.c +++ b/arch/x86/kvm/svm/nested.c @@ -985,7 +985,7 @@ int nested_svm_vmrun(struct kvm_vcpu *vcpu) if (!nested_vmcb_check_save(vcpu) || !nested_vmcb_check_controls(vcpu)) { vmcb12->control.exit_code =3D SVM_EXIT_ERR; - vmcb12->control.exit_code_hi =3D 0; + vmcb12->control.exit_code_hi =3D -1u; vmcb12->control.exit_info_1 =3D 0; vmcb12->control.exit_info_2 =3D 0; goto out; @@ -1018,7 +1018,7 @@ int nested_svm_vmrun(struct kvm_vcpu *vcpu) svm->soft_int_injected =3D false; =20 svm->vmcb->control.exit_code =3D SVM_EXIT_ERR; - svm->vmcb->control.exit_code_hi =3D 0; + svm->vmcb->control.exit_code_hi =3D -1u; svm->vmcb->control.exit_info_1 =3D 0; svm->vmcb->control.exit_info_2 =3D 0; =20 --=20 2.52.0.rc1.455.g30608eb744-goog