public inbox for linux-doc@vger.kernel.org
 help / color / mirror / Atom feed
From: "Radim Krčmář" <radim.krcmar@oss.qualcomm.com>
To: <fangyu.yu@linux.alibaba.com>, <pbonzini@redhat.com>,
	<corbet@lwn.net>, <anup@brainfault.org>, <atish.patra@linux.dev>,
	<pjw@kernel.org>, <palmer@dabbelt.com>, <aou@eecs.berkeley.edu>,
	<alex@ghiti.fr>, <skhan@linuxfoundation.org>
Cc: <guoren@kernel.org>, <andrew.jones@oss.qualcomm.com>,
	<linux-doc@vger.kernel.org>, <kvm@vger.kernel.org>,
	<kvm-riscv@lists.infradead.org>,
	<linux-riscv@lists.infradead.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v7 3/4] RISC-V: KVM: Detect and expose supported HGATP G-stage modes
Date: Thu, 02 Apr 2026 20:19:48 +0200	[thread overview]
Message-ID: <DHIVKK81LLM2.3VTYW1UXM6USQ@oss.qualcomm.com> (raw)
In-Reply-To: <20260402132303.6252-4-fangyu.yu@linux.alibaba.com>

2026-04-02T21:23:02+08:00, <fangyu.yu@linux.alibaba.com>:
> From: Fangyu Yu <fangyu.yu@linux.alibaba.com>
>
> Extend kvm_riscv_gstage_mode_detect() to record HGATP.MODE values in a
> bitmask. Keep tracking the maximum supported G-stage page table level
> for existing internal users.
>
> Also provide lightweight helpers to retrieve the supported-mode bitmask
> and validate a requested HGATP.MODE against it.
>
> Signed-off-by: Fangyu Yu <fangyu.yu@linux.alibaba.com>
> Reviewed-by: Andrew Jones <andrew.jones@oss.qualcomm.com>
> Reviewed-by: Guo Ren <guoren@kernel.org>
> ---
> diff --git a/arch/riscv/include/asm/kvm_gstage.h b/arch/riscv/include/asm/kvm_gstage.h
> @@ -102,4 +103,14 @@ static inline void kvm_riscv_gstage_init(struct kvm_gstage *gstage, struct kvm *
> +static inline bool kvm_riscv_hgatp_mode_is_valid(unsigned long mode)
> +{
> +	return kvm_riscv_gstage_supported_mode_mask & BIT(mode);

Shifting by more than the bit width is undefined behavior in C.
RV64 effectively translates BIT(mode) to 1UL << (mode & 0x3f), so this
could allow values larger than the mask.

Thanks.

  parent reply	other threads:[~2026-04-02 18:19 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-02 13:22 [PATCH v7 0/4] Support runtime configuration for per-VM's HGATP mode fangyu.yu
2026-04-02 13:23 ` [PATCH v7 1/4] RISC-V: KVM: " fangyu.yu
2026-04-02 18:03   ` Radim Krčmář
2026-04-03  2:13     ` fangyu.yu
2026-04-02 13:23 ` [PATCH v7 2/4] RISC-V: KVM: Cache gstage pgd_levels in struct kvm_gstage fangyu.yu
2026-04-02 13:23 ` [PATCH v7 3/4] RISC-V: KVM: Detect and expose supported HGATP G-stage modes fangyu.yu
2026-04-02 14:40   ` Anup Patel
2026-04-02 18:19   ` Radim Krčmář [this message]
2026-04-03  2:31     ` fangyu.yu
2026-04-02 13:23 ` [PATCH v7 4/4] RISC-V: KVM: add KVM_CAP_RISCV_SET_HGATP_MODE fangyu.yu
2026-04-02 14:50   ` Anup Patel
2026-04-03  1:31     ` fangyu.yu
2026-04-03  2:02       ` fangyu.yu
2026-04-03  6:19         ` Anup Patel
2026-04-03  7:07           ` fangyu.yu
2026-04-03  8:11             ` Anup Patel
2026-04-02 18:27   ` Radim Krčmář
2026-04-03  2:59     ` fangyu.yu

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=DHIVKK81LLM2.3VTYW1UXM6USQ@oss.qualcomm.com \
    --to=radim.krcmar@oss.qualcomm.com \
    --cc=alex@ghiti.fr \
    --cc=andrew.jones@oss.qualcomm.com \
    --cc=anup@brainfault.org \
    --cc=aou@eecs.berkeley.edu \
    --cc=atish.patra@linux.dev \
    --cc=corbet@lwn.net \
    --cc=fangyu.yu@linux.alibaba.com \
    --cc=guoren@kernel.org \
    --cc=kvm-riscv@lists.infradead.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=palmer@dabbelt.com \
    --cc=pbonzini@redhat.com \
    --cc=pjw@kernel.org \
    --cc=skhan@linuxfoundation.org \
    /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