From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.161.70 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796417262; b=EimIlofWyuVWzWxY5nquy3z9+e86VcBKam+2mWpRgUxhhMpPKVQ6Gt5azeq5xA+CgLRh /7etKg/UBLRiBbuYNA4j2FdbTfL1SsRPj3siB0aR9ewsg3YPDzH+xo/aKVBkA/4jHeRel lrzSLLttkSGoVxs4BhnycgDUQwW6Qt13+0lcLPK/iow61R522oKvnsb9vGeKzXR/d4S+7 EJQ/Yo0QLH2I2CqE1MoD1VcPIx8JeAgXEDLnyKAyD+bvUFHldOrRW/lhySGf4TI64vWtR elbFl3noXgG0a+5H4CqWkhXwOdiY+iTrfxYld8+K2JVdpRBo4CkW/2jjC/IYuMkA6MA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796417262; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Received:Date:In-Reply-To: Mime-Version:References:Message-ID:Subject:From:To:Cc:Content-Type: Content-Transfer-Encoding; bh=PS5jx3omBt79ijOJvhfZc2YH6Os03UrWV8rZlhXmfPs=; b=SMCamau2eUCWSE1bh/hk0SrSqqanXSQeoFWkOToud+Fo0v0boo4FnTNhMPoJUrQqAuaA 6r2oLWgkl5knxZeBgo4lXXkSmn0StNzUaa5iX0siGvmQLcPFThQdTSziU3wuqMIxwuX3U 300JdjuwsobUikpF+cysNxQU5MstqKYzJxjTJfGpCc41Qku0cIDLc1q62LieRyywbgOUJ NyhvKdBI5JYuz+v9JMFSGJHfFANnvG6lzjmm5VXcro0W1Pe/Jf8t1WBws1t8On2cIZLyo nMYUPRSksTaLAbjd3qUBS+/R2NuUBF87ZOrTDy5Y4oRfV/Kc6pCd22qABfkHv3nZhkQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=Igd47uM7; arc=none smtp.remote-ip=209.85.161.70 Received: from mail-oo1-f70.google.com (mail-oo1-f70.google.com [209.85.161.70]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A4FC0606A32C for ; Fri, 4 Dec 2026 20:47:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A4FC0606A32C 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.a=rsa-sha256 header.s=20260707 header.b=Igd47uM7 Received: by mail-oo1-f70.google.com with SMTP id 006d021491bc7-71aefbef495so1520602eaf.2 for ; Fri, 04 Dec 2026 12:47:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796417260; x=1797022060; darn=vger.kernel.org; h=content-transfer-encoding:content-type:cc:to:from:subject :message-id:references:mime-version:in-reply-to:date:from:to:cc :subject:date:message-id:reply-to:content-type; bh=PS5jx3omBt79ijOJvhfZc2YH6Os03UrWV8rZlhXmfPs=; b=Igd47uM7DxKfACuKi7KpOyrmBHMj7nLmDs6E4XZdBXzhOi7dZzlkf9SPQLotc25pDW LrCq1bx/k7ssDp0c+X21KCc0MOopp6v8Im8sT+OalznghCyj2skvrUl7/dMKdJAKjq0B UNNEUWjCl5/YsUovO8DOJoYYWG06g0tx/+0oDm6kAlFomcT1YY60zZ9s5ZHcTGuC3qnS TAc+vKzmgdA+TntoOyRwphzMG1IoGW4A69Lgkj7TXswK+6luNqrqMYy6Jha3Cl3YCNWK dSyAYRU4Wi46DbN5v9ki8siOKn5qgGDlFtN2nTipidKX0hqj5MkR0Wl51QXiv9Ce6pI9 RDOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796417260; x=1797022060; h=content-transfer-encoding:content-type:cc:to:from:subject :message-id:references:mime-version:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=PS5jx3omBt79ijOJvhfZc2YH6Os03UrWV8rZlhXmfPs=; b=kRq7d/vvCCENYguqvCE3PMe6EtaoRMA9Mzz+3aPhpSQjhYS1upA7Fux7uX9sQecB88 vvQANB9rDETtN9rsjAVDpldfkwTRa85gCKzDFLAwT2QL3azvzSqBVeW3Y/NjQSyb3zuA Ri9nBOWwqFOv7TztPjA05BX4hSs4jmzU2XEl2O4qDKhBZXtziHIHsFsujATcpW9S8+RS wdqI9hUslaJEnS+9bQ6VacsWmEd0FBFTi6UQCAvozvbkx13W9xcA04+VowBn9mvAA/SM m12n8ByBhgFK9zim8AMsy5qhjLqcf5G0blKtTOk/E1+byaK4b80VCfldAGItU3QymfL9 x82A== X-Forwarded-Encrypted: i=1; AL+hErHzChQQPTf+/iOTRbvwkUkV15uNZlc/GWYw4cM79UNULzO5stfJSsHntThU+VxIhkH3UDn/YoKsvGYko9A=@vger.kernel.org X-Gm-Message-State: APuU4Z8MlYwkH+JQMpZNBkovNrclVHtVyrFCZREz/8jZroqoM8d+QRJP RGELebkJaJZKW4XCPTeEQsiRygZ4H+VquF4PGv2nToc+Ena7494YhJO0x3xrprLq89q621HEK2M DPVugLg== X-Received: from jahp12-n2.prod.google.com ([2002:a05:6638:6c8c:20b0:622:dce6:4c06]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6820:1384:b0:71b:788a:985c with SMTP id 006d021491bc7-71bf18d502cmr2996133eaf.0.1796417260391; Fri, 04 Dec 2026 12:47:40 -0800 (PST) Date: Fri, 4 Dec 2026 12:47:39 -0800 In-Reply-To: X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 References: <20261013231728.883001-1-yosry@kernel.org> Message-ID: Subject: Re: [PATCH 0/4] KVM: x86/mmu: Don't sync cached roots created for a different MMU context From: Sean Christopherson To: Yosry Ahmed Cc: Paolo Bonzini , Jim Mattson , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable On Fri, Dec 04, 2026, Yosry Ahmed wrote: > On Fri, Dec 04, 2026 at 11:22:10AM -0800, Sean Christopherson wrote: > > On Thu, Dec 03, 2026, Yosry Ahmed wrote: > > > On Tue, Oct 13, 2026 at 4:17=E2=80=AFPM Yosry Ahmed wrote: > > > > > > > > When invalidating an address, KVM walks and syncs cached roots usin= g the > > > > current MMU context, but cached roots may have been created for a > > > > different context after a nested transition. With TDP disabled, th= is > > > > lets a guest trigger a BUG_ON() and crash the host (see patch 3 for > > > > details). > > > > > > > > Patch 1 downgrades the BUG_ON() to a WARN_ON_ONCE(), patch 2 is pre= p > > > > work, patch 3 is the fix, and patch 4 drops a TODO that isn't worth > > > > pursuing. > > > > > > > > Sashiko flagged the issue while reviewing the INVLPGA emulation pat= ch in > > > > my nested SVM TLB series [1]. The host crash is easy to reproduce = with an > > > > AI-generated repro (with TDP disabled), and no longer triggers with= this > > > > series. > > > > > > > > [1] https://lore.kernel.org/kvm/sashiko-outbox-163479@kernel.org/ > > > > > > > > Yosry Ahmed (4): > > > > KVM: x86/mmu: WARN, don't BUG, when walking a cached root with a = PAE > > > > MMU > > > > KVM: x86/mmu: Drop for_each_shadow_entry_using_root() > > > > KVM: x86/mmu: Don't sync cached roots created for a different MMU > > > > context > > > > KVM: nVMX: Drop the TODO to sync only the affected SPTEs for INVV= PID > > >=20 > > > Do I need to send a new version for this? > >=20 > > No, just give me a comment for patch 1 I can squash. >=20 > This? >=20 > diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c > index 0b78c56f771b7..9289c7cd836b3 100644 > --- a/arch/x86/kvm/mmu/mmu.c > +++ b/arch/x86/kvm/mmu/mmu.c > @@ -2576,10 +2576,7 @@ static void shadow_walk_init_using_root(struct kvm= _shadow_walk_iterator *iterato > iterator->level =3D PT32E_ROOT_LEVEL; >=20 > if (iterator->level =3D=3D PT32E_ROOT_LEVEL) { > - /* > - * prev_root is currently only used for 64-bit hosts. So = only > - * the active root_hpa is valid here. > - */ > + /* PAE roots aren't cached, so only the active root is va= lid here */ > if (WARN_ON_ONCE(root !=3D vcpu->arch.mmu->root.hpa)) > goto error; LOL, your assertion that I only agree with you when it's other people's cod= e is holding true. "valid here" is confusing because I though it was saying the= only the current root could be valid (see the out-of-sight VALID_PAGE() checks). I'm going with this, unless you hate it: /* * KVM doesn't cache PAE roots, so it should be impossible to * reach this point with anything other than the current root. */