public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM TDP MMU FIXES- Replaced unsafe panic calls with proper error handling
@ 2026-04-02  5:19 BraveProgrammer
  2026-04-02 19:34 ` Sean Christopherson
  0 siblings, 1 reply; 2+ messages in thread
From: BraveProgrammer @ 2026-04-02  5:19 UTC (permalink / raw)
  To: seanjc, pbonzini
  Cc: yan.y.zhao, kai.huang, binbin.wu, vipinsh, kvm, linux-kernel,
	BraveProgrammer

Unsafe Panic Calls Converted to BUG() AND BUG_ON()
AND
Added Proper error handling: Using WARN_ON_ONCE(), pr_err()

Signed-off-by: BraveProgrammer <spujari79@gmail.com>
---
 arch/x86/kvm/mmu/tdp_mmu.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/arch/x86/kvm/mmu/tdp_mmu.c b/arch/x86/kvm/mmu/tdp_mmu.c
index 9c26038f6b77..3396bf157716 100644
--- a/arch/x86/kvm/mmu/tdp_mmu.c
+++ b/arch/x86/kvm/mmu/tdp_mmu.c
@@ -590,14 +590,15 @@ static void handle_changed_spte(struct kvm *kvm, int as_id, gfn_t gfn,
 		pr_err("Invalid SPTE change: cannot replace a present leaf\n"
 		       "SPTE with another present leaf SPTE mapping a\n"
 		       "different PFN!\n"
-		       "as_id: %d gfn: %llx old_spte: %llx new_spte: %llx level: %d",
+		       "as_id: %d gfn: %llx old_spte: %llx new_spte: %llx level: %d\n",
 		       as_id, gfn, old_spte, new_spte, level);
 
 		/*
-		 * Crash the host to prevent error propagation and guest data
-		 * corruption.
+		 * Return early to prevent invalid SPTE from being set.
+		 * This prevents guest data corruption while allowing the VM to continue
+		 * in a degraded state for debugging purposes.
 		 */
-		BUG();
+		return;
 	}
 
 	if (old_spte == new_spte)
@@ -1453,9 +1454,12 @@ static bool wrprot_gfn_range(struct kvm *kvm, struct kvm_mmu_page *root,
 	u64 new_spte;
 	bool spte_set = false;
 
-	rcu_read_lock();
+	if (WARN_ON_ONCE(min_level > KVM_MAX_HUGEPAGE_LEVEL)) {
+		pr_err("Invalid min_level %d for write protection range operation\n", min_level);
+		return false;
+	}
 
-	BUG_ON(min_level > KVM_MAX_HUGEPAGE_LEVEL);
+	rcu_read_lock();
 
 	for_each_tdp_pte_min_level(iter, kvm, root, min_level, start, end) {
 retry:
@@ -1887,7 +1891,10 @@ static bool write_protect_gfn(struct kvm *kvm, struct kvm_mmu_page *root,
 	u64 new_spte;
 	bool spte_set = false;
 
-	BUG_ON(min_level > KVM_MAX_HUGEPAGE_LEVEL);
+	if (WARN_ON_ONCE(min_level > KVM_MAX_HUGEPAGE_LEVEL)) {
+		pr_err("Invalid min_level %d for write protection operation\n", min_level);
+		return false;
+	}
 
 	rcu_read_lock();
 
-- 
2.52.0.windows.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] KVM TDP MMU FIXES- Replaced unsafe panic calls with proper error handling
  2026-04-02  5:19 [PATCH] KVM TDP MMU FIXES- Replaced unsafe panic calls with proper error handling BraveProgrammer
@ 2026-04-02 19:34 ` Sean Christopherson
  0 siblings, 0 replies; 2+ messages in thread
From: Sean Christopherson @ 2026-04-02 19:34 UTC (permalink / raw)
  To: BraveProgrammer
  Cc: pbonzini, yan.y.zhao, kai.huang, binbin.wu, vipinsh, kvm,
	linux-kernel

On Thu, Apr 02, 2026, BraveProgrammer wrote:
> Unsafe Panic Calls Converted to BUG() AND BUG_ON()
> AND
> Added Proper error handling: Using WARN_ON_ONCE(), pr_err()

This isn't "proper error handling", it's sweeping potentiall catastrophic bugs
under the rug.

> Signed-off-by: BraveProgrammer <spujari79@gmail.com>

Given the name and email, I assume this is trolling or AI slop, but just to be
clear:

NAK.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-04-02 19:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-02  5:19 [PATCH] KVM TDP MMU FIXES- Replaced unsafe panic calls with proper error handling BraveProgrammer
2026-04-02 19:34 ` Sean Christopherson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox