From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796415171; b=1Z86/BD4UnO/atmtbz1r6Soj5cPS072x5QXUogG2TcZC/Lnq1AxLLe9lUvFPKwceAumY ZZ63ET7VT0/a+CgAprldgoiOeB58TaFK75AC2tuldWSSBAfghlfA8oGfoK1KWok6OfvCg J6c3KXylucDVbHITUc/0d8HWo+B6reoTAogbmniu6I8ZnHHqj/vbtJAyIrITJIhtWe4WG OGmqrTPwnjZAgVonbsmZ+Xat6gKS8thdQsHTs7eK+5ND+EkOJqLKWYIHmNpB58FEWbHuT kyJ+xVBChR5mne/+9pUiSLeCw86sjnPcbmG2lenAvJLHk47M6yndYaKUxljzfqcmgDw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796415171; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition: Content-Transfer-Encoding:In-Reply-To; bh=bndZ1LFzNbdP99FcKbVUmUcTZP2nmAekFGFnVnLGgBo=; b=sjbW23sJqFXa+vDat+QGwpE91zAK/5j1DUeEIkOGbdKmQFfx37/BHqkx7xPbreQQbZxw IklsPR2dFjWnunYV45JYdr3CjtKFp0ezk1/hnmo1L2xi5236Jp778xmtLH1ptkUZGOlax WCpVTUZnbaVgvrpHzds8FVDQMqrur5tSBmR2jxfqkd1uHPIZyq0oEwaZgu20KEs+lNuSw FKr9dIN5izUZbxuWR/2rzCmvkCOZ5NeSXYyEi31LIkm29ZzzFOXVFGiN9cXcTWFp7O8+X mN0KmwqZZbKP6R0U7ng2NDJ/o0IFE/6H3an0/8EY82o//hDvbDkCXSRd7J8Nd0QHDNA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=BOtAZii+; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0C48F606A322; Fri, 4 Dec 2026 20:12:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=BOtAZii+ Received: by smtp.kernel.org (Postfix) with ESMTPSA id 945BE1F00936; Fri, 4 Dec 2026 20:12:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796415170; bh=bndZ1LFzNbdP99FcKbVUmUcTZP2nmAekFGFnVnLGgBo=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=BOtAZii+5gRBMCrBWiG/FHgQ84OpiPny4dgCeas0tj/ijp19r7W9t40sc0MhGiYsv ott6V1qlqOOK1j1uZPJusFFEFMbPO/McTNOhjd93TNXwLvpDY3DfuZzlLoMXoQ1gjf Eg7OKmpMYSA7X91kLHAkoJYWIenMLVWaT7vcyjAVZjFPGVm4sJzLaJXvXIy9iIo7s+ 4T75eTNGgE6T8zfyq4BenEyWULga/+OUE9nKSfVt80LAo3ff8p7wVvq57Ftab/rftw TpZ89oo5npDmycfikOj8KfGaeBNmvgoymGNENFXN9BA4m8bnH6vOG5liYZdBrwo1WP Jhmz596VGF97w== Date: Fri, 4 Dec 2026 20:12:49 +0000 From: Yosry Ahmed To: Sean Christopherson Cc: Paolo Bonzini , Jim Mattson , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 0/4] KVM: x86/mmu: Don't sync cached roots created for a different MMU context Message-ID: References: <20261013231728.883001-1-yosry@kernel.org> X-Mailing-List: kvm@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: 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 PM Yosry Ahmed wrote: > > > > > > When invalidating an address, KVM walks and syncs cached roots using the > > > current MMU context, but cached roots may have been created for a > > > different context after a nested transition. With TDP disabled, this > > > 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 prep > > > 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 patch 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 INVVPID > > > > Do I need to send a new version for this? > > No, just give me a comment for patch 1 I can squash. This? 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 = PT32E_ROOT_LEVEL; if (iterator->level == 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 valid here */ if (WARN_ON_ONCE(root != vcpu->arch.mmu->root.hpa)) goto error;