From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f202.google.com (mail-pf1-f202.google.com [209.85.210.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 44C6F29DB99 for ; Tue, 30 Dec 2025 21:13:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767129232; cv=none; b=fHC0zBZJb1JzLTC+HcSyikySZjmAenMKFgyP3CXsnb5YhrNneuuNtI4EX8nWQrmVAhGea0+onpFbS97d5QdVbbjdqGJnA7EP842J3HOwA586W842ich6QFzujiniBX9RS35hZFdmAzOrkcxP8dRdPmuqNDISnwQzKxh/Q3wsoqY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767129232; c=relaxed/simple; bh=4OWHt1L/RDgnDQRLTt+NWAyepoS1oss9mzxFrCY79ZA=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=Q6Kqx5vhXwIoBgsZEhXcfT9854QXeO75rniY3Zr8lEgMiGoIlQPswwB4SprrrFPnwBTkKf6pRKsJR5tcGUMLNnlqhwxgZnNd2J9ZlPzTXMrX/9jeg57hQ/utFNmNZDq6khYpFl8kLcbl5ImA1mbh3hc53XI38NTLH/pY/e6cj+4= 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=4l5riIPy; arc=none smtp.client-ip=209.85.210.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="4l5riIPy" Received: by mail-pf1-f202.google.com with SMTP id d2e1a72fcca58-7b80de683efso19156821b3a.3 for ; Tue, 30 Dec 2025 13:13:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1767129230; x=1767734030; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:reply-to:from:to:cc :subject:date:message-id:reply-to; bh=bC/ABOQDwqmqKyjeXHvximAm8LHGaEor3j6gODQEP7s=; b=4l5riIPyNa6BUQnIZuPdOa81eG+0ok+FJvFc9cq80VHsMct3njpbT21GSLKg7g5IC2 BpWKnzxvkuVIz2EKe8Di8dzOWX5COyOiXwTIlz2YJHWIhjP6hiS5gd25MUTMrgQl1b3c MpLwNZJjV3ZQZnsrXxIJAZ+RddBq/jlQmGwM2C1DzR8oZ5zjSw66bj3CzzT9/wuSHvwz j1T6fTbbjgLb63usMayWZfzjbuYzeNAebo4eyXDt3rhjo8gnoJphYMCe8I+Jnj0vKhFs KfNSruHg9CNaL8YWK1wlYgIWKww70JykvND0WT/zTRyvVm1mWsuiUs9LG+75J2LfSIfX sqMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767129230; x=1767734030; h=cc:to:from:subject:message-id:mime-version:date:reply-to :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=bC/ABOQDwqmqKyjeXHvximAm8LHGaEor3j6gODQEP7s=; b=tBJSb0HsYKlBZz9JsEMPrERzbAS4tOLXQizeRQDCUtv4dxAo9NTcU7SefIrXD6jKtD tnGz8Dkdg6L5wnYRVwVy6fXd6sfSg19s1Q6fisHuzNbkp4Ikb4e2XjlL40pFh4bj+zJk ZsJR3V0Di+Ygg1bNrT+X0HFoe+e/fA3KJIt2nR8PfYU2IMVWzSQs8XOl3M+LSe8yjO55 zW5f1iw8ZmobNJLkEI2FHsQAyT4219T4unS/n4iNdlWYAhm7bWdxbLECrDjbCIgkMgLo JQRhrt9xOfZn8Pyzne3hFXRBgZM+nR2fV7OB1I783ASeoK5LZAZJBemRmLgsJYo30RoB CLKQ== X-Forwarded-Encrypted: i=1; AJvYcCVu2xAtmLALzn7LR2TfqFM8HWS9iLEt4XBRZBvNHqbkgZxdvRDawQEfCspI829/2PK+mSb7DPpoYSjSjaQ=@vger.kernel.org X-Gm-Message-State: AOJu0Ywp/S3fXwIG/pkrZts9MR36Wch98dVTdgah4ZNMv5748oVAz0uu cKycqkzhblupCksFwjOwkeGNNhIBkoTmdVp3+hwF3xxq1I8HVJQsxFffOWyFFxK8AnPN7WOsE0e NTRmFkA== X-Google-Smtp-Source: AGHT+IG0Ik/Hr8l5UuIdJnzPjNgFwG5kojDgcf3tUWg2De+x89zJIYlfXghp0RGHfAZfITkx2zj4lCz2W10= X-Received: from pjbmy15.prod.google.com ([2002:a17:90b:4c8f:b0:34c:e366:3f3f]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a20:e293:b0:341:d5f3:f1ac with SMTP id adf61e73a8af0-376a9de5b1fmr32717049637.41.1767129230504; Tue, 30 Dec 2025 13:13:50 -0800 (PST) Reply-To: Sean Christopherson Date: Tue, 30 Dec 2025 13:13:39 -0800 Precedence: bulk X-Mailing-List: linux-hyperv@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.52.0.351.gbe84eed79e-goog Message-ID: <20251230211347.4099600-1-seanjc@google.com> Subject: [PATCH v2 0/8] KVM: SVM: Fix exit_code bugs From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini , Vitaly Kuznetsov , "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Long Li Cc: kvm@vger.kernel.org, linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, Jim Mattson , Yosry Ahmed Content-Type: text/plain; charset="UTF-8" Fix (mostly benign) bugs in SVM where KVM treats exit codes as 32-bit values instead of 64-bit values. The most dangerous aspect of the mess is that simply fixing KVM would likely break KVM-on-KVM setups if only L1 is patched. To try and avoid such breakage while also fixing KVM, I opted to have KVM retain its checks on only bits 31:0 if KVM is running as a VM (as detected by X86_FEATURE_HYPERVISOR). v2: - Drop the nSVM #VMEXIT fixes (already merged). - Collect reviews. [Yosry] - Fix inverted svm_is_vmrun_failure() check. [Yosry] - Use __print_symbolic_u64() and __print_flags_u64() in tracepoints. [Test Bot] - Track exit_code as a u64 in KVM selftests. - Make HV_SVM_EXITCODE_ENL an ull like everything else. [Michael] - Add a compile-time assertion to verify HV_SVM_EXITCODE_ENL == SVM_EXIT_SW. v1: https://lore.kernel.org/all/20251113225621.1688428-1-seanjc@google.com Sean Christopherson (8): KVM: SVM: Add a helper to detect VMRUN failures KVM: SVM: Open code handling of unexpected exits in svm_invoke_exit_handler() KVM: SVM: Check for an unexpected VM-Exit after RETPOLINE "fast" handling KVM: SVM: Filter out 64-bit exit codes when invoking exit handlers on bare metal KVM: SVM: Treat exit_code as an unsigned 64-bit value through all of KVM KVM: SVM: Limit incorrect check on SVM_EXIT_ERR to running as a VM KVM: SVM: Harden exit_code against being used in Spectre-like attacks KVM: SVM: Assert that Hyper-V's HV_SVM_EXITCODE_ENL == SVM_EXIT_SW arch/x86/include/asm/svm.h | 3 +- arch/x86/include/uapi/asm/svm.h | 32 ++++++------ arch/x86/kvm/svm/hyperv.c | 7 ++- arch/x86/kvm/svm/nested.c | 29 ++++------- arch/x86/kvm/svm/sev.c | 36 +++++-------- arch/x86/kvm/svm/svm.c | 51 +++++++++++-------- arch/x86/kvm/svm/svm.h | 12 +++-- arch/x86/kvm/trace.h | 6 +-- include/hyperv/hvgdk.h | 2 +- tools/testing/selftests/kvm/include/x86/svm.h | 3 +- .../kvm/x86/svm_nested_soft_inject_test.c | 4 +- 11 files changed, 90 insertions(+), 95 deletions(-) base-commit: 9448598b22c50c8a5bb77a9103e2d49f134c9578 -- 2.52.0.351.gbe84eed79e-goog