From nobody Mon Feb 9 20:30:19 2026 Received: from mail-pg1-f202.google.com (mail-pg1-f202.google.com [209.85.215.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 329A432939A for ; Thu, 13 Nov 2025 22:56:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763074603; cv=none; b=BuuDqq9TLMTf8smv/oGaaEzgt+Xc+noJx3zLRoIOo4N5qIP1X8wJj9TFfeJlWTI9XfpEovpRTNfB6PB9q5PmABB1anokd7bnKtlIK0HcsQkbB5qvuhSvbU1c0ScfY/dyBswBuOngindeZ00s/UC/xZkK9Y37cBb4hUZQWOiWuis= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763074603; c=relaxed/simple; bh=84mlhZ3JM5RfxlKomoAAeHn9Bvqc4zqHVGnlMIN+Dl0=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=uKdGuoOoOqNvEWCAmbMGdyBCmZkR26vyLzKBkzdb/GacBetFfVeSDcxXPgkrIRo2e6Sa+RkEcyWNjbeYKGJGx1SoeQGDWOQ3GZN56gt1WOTzVA/qwbjSfC0hflTobhf59lUOk7mrI2lbYnD5jYRvdz9QMoP/jaU+T62h0NmCil0= 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=jAI+VEn9; arc=none smtp.client-ip=209.85.215.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="jAI+VEn9" Received: by mail-pg1-f202.google.com with SMTP id 41be03b00d2f7-b630753cc38so2978066a12.1 for ; Thu, 13 Nov 2025 14:56:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1763074601; x=1763679401; darn=vger.kernel.org; h=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=yAZ8dC0cSBzCHy+Gncv2WYa1BW9ysI8EoXwobyv3AdE=; b=jAI+VEn9/DCv7c9s80EI/zOj/Tvs3p5UzyZvFsejJTjus68hnNQtEZpGhY34vI2rJt M3diu0V2ar5rxDzXIw03inVQ/kAO+l2p0584qpwnhFENWyUMjRkxf/00aMTe/vaQSuIW OJz7Ksda6rjoqN1OF0eiEAp3gFrjJ20qsbJXMb715CK0zNKAzuEcuAKNyuNFlkOk7Kzs YcWgZy2g4LVe1jZZhqA8v/4zjTWYInc9SYAPQXBHsDgftaTEr9HRB1squX7RWYM8Yo6T QyFllCf7kPhOe/ZqMWktnCM7zncbg3DhofTIg/64XotUPRJJqGdf3/IOL1whi7U+/OHa NBfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763074601; x=1763679401; h=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=yAZ8dC0cSBzCHy+Gncv2WYa1BW9ysI8EoXwobyv3AdE=; b=KCnnfbZLKjrEtzs9ThV6gqiBtWQ7QunejsrAeRtzzjbz/EbLvJpuKJqD1hrPfLt/xe iaI36gu9N3DwY2WApSIL3rXnp1ptW0xrhyMkhysehg2DCbRZDKBdFnjpJztt+s06r06a LUpHXMw2aAWu9BUYtVcY9tEcaU0HNmIK9QB7xlXUaREmAblwRe2keV6BXOebGKsyC3qW EPGHzf/brFTaqxn/YyCr5rB8H5eO7yWxKhaM5sWUMT+P9JSzQCrWIHBxuwBThsY5PH+K xV+ZvUBm8Bc3FXZg17kNTFRkU+qmKO3yRv7PG4d8c2u+fboRnw8nilKwMPcww0I83sA6 +zWw== X-Forwarded-Encrypted: i=1; AJvYcCUtBTn69RM6uFq98arMy58K4SjNITowCfv4DFd9NOQbxOZuVvjH90V2lZk5smMt5POUtM4ezRGbgM8WRNQ=@vger.kernel.org X-Gm-Message-State: AOJu0YyqsORvrz+6kgKjMUWsrkJ8/ed9JB4q8iiK0YV48eEdKbHH9KwX /sB3ySMSTaO6LDX2nkapbWkY5FX14zg8Pyz7P7J9+m64Yz8UWGX/qdqLDifgL5QzeCxypmqqUoq jyHckkA== X-Google-Smtp-Source: AGHT+IF96SyhX4OSFYPPUcMMzzakOIf9y26xhAXkhopdVA6dBw1xWXKKHbc/n2cOWm2tylO2zP96XfNZ/fw= X-Received: from pgdj7.prod.google.com ([2002:a05:6a02:5207:b0:bc5:3be0:b497]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a21:3294:b0:342:5901:fd9f with SMTP id adf61e73a8af0-35ba16a47f6mr1429299637.28.1763074601451; Thu, 13 Nov 2025 14:56:41 -0800 (PST) Reply-To: Sean Christopherson Date: Thu, 13 Nov 2025 14:56:20 -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-9-seanjc@google.com> Subject: [PATCH 8/9] KVM: SVM: Limit incorrect check on SVM_EXIT_ERR to running as a VM 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" Limit KVM's incorrect check for VMXEXIT_INVALID, a.k.a. SVM_EXIT_ERR, to running as a VM, as detected by X86_FEATURE_HYPERVISOR. The exit_code and all failure codes, e.g. VMXEXIT_INVALID, are 64-bit values, and so checking only bits 31:0 could result in false positives when running on non-broken hardware, e.g. in the extremely unlikely scenario exit code 0xffffffffull is ever generated by hardware. Keep the 32-bit check to play nice with running on broken KVM (for years, KVM has not set bits 63:32 when synthesizing nested SVM VM-Exits). Signed-off-by: Sean Christopherson Reviewed-by: Yosry Ahmed --- arch/x86/kvm/svm/svm.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/svm/svm.h b/arch/x86/kvm/svm/svm.h index 31ee4f65dcc2..801dcfc64d0b 100644 --- a/arch/x86/kvm/svm/svm.h +++ b/arch/x86/kvm/svm/svm.h @@ -427,7 +427,10 @@ static __always_inline struct vcpu_svm *to_svm(struct = kvm_vcpu *vcpu) =20 static inline bool svm_is_vmrun_failure(u64 exit_code) { - return (u32)exit_code =3D=3D (u32)SVM_EXIT_ERR; + if (cpu_feature_enabled(X86_FEATURE_HYPERVISOR)) + return (u32)exit_code =3D=3D (u32)SVM_EXIT_ERR; + + return exit_code =3D=3D SVM_EXIT_ERR; } =20 /* --=20 2.52.0.rc1.455.g30608eb744-goog