All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Paolo Bonzini" <pbonzini@redhat.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH 5.15.y v2 3/8] KVM: x86/mmu: Derive shadow MMU page role from parent
Date: Fri, 26 Jun 2026 18:07:58 +0000	[thread overview]
Message-ID: <20260626180759.2A08C1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260626174620.1819772-4-pbonzini@redhat.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Direct shadow pages can be allocated with `gpte_is_8_bytes = false`, violating KVM MMU invariants.
--

commit 0b01cee575924096aea0e7bca6d1f776d55aa386
Author: Paolo Bonzini <pbonzini@redhat.com>

KVM: x86/mmu: Derive shadow MMU page role from parent

This patch refactors how shadow page roles are computed, deriving most
information from the parent shadow page rather than calculating it from
scratch. This eliminates the dependency on the vCPU root role when
allocating shadow page tables.

> diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
> --- a/arch/x86/kvm/mmu/mmu.c
> +++ b/arch/x86/kvm/mmu/mmu.c
[ ... ]
> @@ -2171,6 +2153,54 @@ static struct kvm_mmu_page *kvm_mmu_get_page(struct kvm_vcpu *vcpu,
> +static union kvm_mmu_page_role kvm_mmu_child_role(u64 *sptep, bool direct, unsigned int access)
> +{
> +	struct kvm_mmu_page *parent_sp = sptep_to_sp(sptep);
> +	union kvm_mmu_page_role role;
> +
> +	role = parent_sp->role;
> +	role.level--;
> +	role.access = access;
> +	role.direct = direct;
[ ... ]
> +	if (!role.gpte_is_8_bytes) {
> +		WARN_ON_ONCE(role.level != PG_LEVEL_4K);
> +		role.quadrant = (sptep - parent_sp->spt) % 2;
> +	}
> +
> +	return role;
> +}

[Severity: High]
Will this result in direct pages inheriting an incorrect quadrant and byte size?

When breaking down a huge page for a 32-bit non-PAE guest, FNAME(fetch) calls
kvm_mmu_get_child_sp() with direct set to true. kvm_mmu_child_role() derives
the role from the indirect parent, leaving gpte_is_8_bytes as false. It then
incorrectly calculates a quadrant for the direct page. Does this violate the
core MMU invariant that direct pages must always use 8-byte PTE semantics?

[ ... ]
> @@ -3408,13 +3437,18 @@ static int mmu_check_root(struct kvm_vcpu *vcpu, gfn_t root_gfn)
> -static hpa_t mmu_alloc_root(struct kvm_vcpu *vcpu, gfn_t gfn, gva_t gva,
> +static hpa_t mmu_alloc_root(struct kvm_vcpu *vcpu, gfn_t gfn, int quadrant,
>  			    u8 level)
>  {
> -	bool direct = vcpu->arch.mmu->mmu_role.base.direct;
> +	union kvm_mmu_page_role role = vcpu->arch.mmu->mmu_role.base;
>  	struct kvm_mmu_page *sp;
>  
> -	sp = kvm_mmu_get_page(vcpu, gfn, gva, level, direct, ACC_ALL);
> +	role.level = level;
> +
> +	if (!role.gpte_is_8_bytes)
> +		role.quadrant = quadrant;
> +
> +	sp = kvm_mmu_get_page(vcpu, gfn, role);

[Severity: High]
Could this cause issues for non-paging guests?

For non-paging guests where TDP is disabled, the base role has direct
set to true but gpte_is_8_bytes set to false. This role is passed
unmodified to mmu_alloc_root(), which seems like it might propagate the
inconsistent state (direct with 4-byte PTEs) to the root allocation.
If a later check asserts that all direct pages use 8-byte PTEs, would
this trigger a host warning or panic on boot?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260626174620.1819772-1-pbonzini@redhat.com?part=3

  reply	other threads:[~2026-06-26 18:07 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-26 17:46 [PATCH 5.15.y v2 0/8] KVM: fixes for CVE-2026-46113 and related issues Paolo Bonzini
2026-06-26 17:46 ` [PATCH 5.15.y v2 1/8] KVM: x86/mmu: Use a bool for direct Paolo Bonzini
2026-06-26 17:46 ` [PATCH 5.15.y v2 2/8] KVM: x86/mmu: Stop passing "direct" to mmu_alloc_root() Paolo Bonzini
2026-06-26 17:46 ` [PATCH 5.15.y v2 3/8] KVM: x86/mmu: Derive shadow MMU page role from parent Paolo Bonzini
2026-06-26 18:07   ` sashiko-bot [this message]
2026-06-26 17:46 ` [PATCH 5.15.y v2 4/8] KVM: x86/mmu: Always pass 0 for @quadrant when gptes are 8 bytes Paolo Bonzini
2026-06-26 17:58   ` sashiko-bot
2026-06-26 17:46 ` [PATCH 5.15.y v2 5/8] KVM: x86/mmu: pull call to drop_large_spte() into __link_shadow_page() Paolo Bonzini
2026-06-26 17:59   ` sashiko-bot
2026-06-26 17:46 ` [PATCH 5.15.y v2 6/8] KVM: x86: Fix shadow paging use-after-free due to unexpected GFN Paolo Bonzini
2026-06-26 17:46 ` [PATCH 5.15.y v2 7/8] KVM: x86: Fix shadow paging use-after-free due to unexpected role Paolo Bonzini
2026-06-26 17:46 ` [PATCH 5.15.y v2 8/8] KVM: x86/mmu: Ensure hugepage is in by slot before checking max mapping level Paolo Bonzini
2026-06-27 16:35 ` [PATCH 5.15.y v2 0/8] KVM: fixes for CVE-2026-46113 and related issues Sasha Levin
2026-07-10  5:52   ` Kenta Akagi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260626180759.2A08C1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.