Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Sean Christopherson" <seanjc@google.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH 5/6] KVM: PPC: Use CLASS(kvm_vcpu_map_local_readonly) for patching dcbz
Date: Fri, 24 Jul 2026 01:03:34 +0000	[thread overview]
Message-ID: <20260724010336.16FCF1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260724004757.131420-6-seanjc@google.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] The commit title claims to use `CLASS(kvm_vcpu_map_local_readonly)`, but the code uses the writable variant `CLASS(kvm_vcpu_map_local)`.
- [Low] The local variable `r` is declared but never used after the refactoring.
--

--- Patch [5]: [PATCH 5/6] KVM: PPC: Use CLASS(kvm_vcpu_map_local_readonly) for patching dcbz ---
commit 85b6110c0b5859c4a10a2a8a3cab84580d924a43
Author: Sean Christopherson <seanjc@google.com>

KVM: PPC: Use CLASS(kvm_vcpu_map_local_readonly) for patching dcbz

This commit converts the dcbz patching implementation in KVM PPC to use
the new scope-based CLASS(kvm_vcpu_map_local) infrastructure. It eliminates
the open-coded on-stack struct kvm_host_map to help harden the API against
memory leaks.

> KVM: PPC: Use CLASS(kvm_vcpu_map_local_readonly) for patching dcbz

[Severity: Medium]
The commit title mentions using CLASS(kvm_vcpu_map_local_readonly), but the
code below correctly uses the writable variant CLASS(kvm_vcpu_map_local)
since it needs to modify the memory. Should the title be updated to match
the implementation?

> diff --git a/arch/powerpc/kvm/book3s_pr.c b/arch/powerpc/kvm/book3s_pr.c
> --- a/arch/powerpc/kvm/book3s_pr.c
> +++ b/arch/powerpc/kvm/book3s_pr.c

[ ... ]

>  static void kvmppc_patch_dcbz(struct kvm_vcpu *vcpu, struct kvmppc_pte *pte)
>  {
> -	struct kvm_host_map map;
>  	u64 hpage_offset;
>  	u32 *page;
>  	int i, r;

[Severity: Low]
Does this leave the variable r unused in kvmppc_patch_dcbz()?

It looks like the original call to kvm_vcpu_map() was replaced, and nothing
else assigns or reads r. This might cause a compiler warning for configurations
that check for unused variables.

> 
> -	r = kvm_vcpu_map(vcpu, pte->raddr >> PAGE_SHIFT, &map);
> -	if (r)
> +	CLASS(kvm_vcpu_map_local, m)(vcpu, pte->raddr >> PAGE_SHIFT);
> +	if (m.ret)
>  		return;

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260724004757.131420-1-seanjc@google.com?part=5

  reply	other threads:[~2026-07-24  1:03 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-24  0:47 [PATCH 0/6] KVM: Harden kvm_vcpu_map() usage against memory leaks Sean Christopherson
2026-07-24  0:47 ` [PATCH 1/6] KVM: nVMX: Ensure KVM_REQ_GET_NESTED_STATE_PAGES is cleared on VM-Exit Sean Christopherson
2026-07-24  1:07   ` sashiko-bot
2026-07-24  0:47 ` [PATCH 2/6] KVM: nSVM: Add CLASS()es for automagically handling local kvm_vcpu_map() usage Sean Christopherson
2026-07-24  0:47 ` [PATCH 3/6] KVM: nSVM: Use CLASS(kvm_vcpu_map_local) for SMM VMCB mappings Sean Christopherson
2026-07-24  0:47 ` [PATCH 4/6] KVM: nVMX: Use CLASS(kvm_vcpu_map_local_readonly) for MSR bitmap merging Sean Christopherson
2026-07-24  0:47 ` [PATCH 5/6] KVM: PPC: Use CLASS(kvm_vcpu_map_local_readonly) for patching dcbz Sean Christopherson
2026-07-24  1:03   ` sashiko-bot [this message]
2026-07-24  1:15     ` Sean Christopherson
2026-07-24  0:47 ` [PATCH 6/6] KVM: Harden kvm_vcpu_map() against double-mapping and thus leaking references Sean Christopherson
2026-07-24  1:11   ` sashiko-bot

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=20260724010336.16FCF1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=seanjc@google.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox