[PATCH v5 0/2] target/riscv: Fix PMP address alignment

Jay Chang posted 2 patches 1 week, 3 days ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20260520063606.36600-1-jay.chang@sifive.com
Maintainers: Palmer Dabbelt <palmer@dabbelt.com>, Alistair Francis <alistair.francis@wdc.com>, Weiwei Li <liwei1518@gmail.com>, Daniel Henrique Barboza <daniel.barboza@oss.qualcomm.com>, Liu Zhiwei <zhiwei_liu@linux.alibaba.com>, Chao Liu <chao.liu.zevorn@gmail.com>
target/riscv/pmp.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
[PATCH v5 0/2] target/riscv: Fix PMP address alignment
Posted by Jay Chang 1 week, 3 days ago
This series fixes PMP address alignment to comply with the RISC-V
specification WARL (Write-Any, Read-Legal) semantics.

When configuring pmpcfg (TOR, NA4, or NAPOT) and pmpaddr, if the
value is smaller than the PMP granularity, it needs to be aligned
to the PMP granularity.

Chagnes in v5:
- Use uint64_t for granule, in preparation for upcoming single-binary work:
  https://lore.kernel.org/qemu-devel/20260515180437.23620-1-anjo@rev.ng/

Changes in v4:
- Rebase riscv-to-apply.next

Changes in v3:
- Use ROUND_UP() macro for NAPOT address alignment

Changes in v2:
- Fixed commit message grammar ("it needs to be aligned")
- Use ROUND_DOWN() macro for TOR address alignment to improve
  code readability

Jay Chang (2):
  target/riscv: Align pmp size to pmp-granularity
  target/riscv: Improve PMP address alignment readability

 target/riscv/pmp.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

-- 
2.48.1
Re: [PATCH v5 0/2] target/riscv: Fix PMP address alignment
Posted by Alistair Francis 4 days, 15 hours ago
On Wed, May 20, 2026 at 4:36 PM Jay Chang <jay.chang@sifive.com> wrote:
>
> This series fixes PMP address alignment to comply with the RISC-V
> specification WARL (Write-Any, Read-Legal) semantics.
>
> When configuring pmpcfg (TOR, NA4, or NAPOT) and pmpaddr, if the
> value is smaller than the PMP granularity, it needs to be aligned
> to the PMP granularity.
>
> Chagnes in v5:
> - Use uint64_t for granule, in preparation for upcoming single-binary work:
>   https://lore.kernel.org/qemu-devel/20260515180437.23620-1-anjo@rev.ng/
>
> Changes in v4:
> - Rebase riscv-to-apply.next
>
> Changes in v3:
> - Use ROUND_UP() macro for NAPOT address alignment
>
> Changes in v2:
> - Fixed commit message grammar ("it needs to be aligned")
> - Use ROUND_DOWN() macro for TOR address alignment to improve
>   code readability
>
> Jay Chang (2):
>   target/riscv: Align pmp size to pmp-granularity
>   target/riscv: Improve PMP address alignment readability

Thanks!

Applied to riscv-to-apply.next

Alistair

>
>  target/riscv/pmp.c | 20 ++++++++++++++------
>  1 file changed, 14 insertions(+), 6 deletions(-)
>
> --
> 2.48.1
>
>
Re: [PATCH v5 0/2] target/riscv: Fix PMP address alignment
Posted by Philippe Mathieu-Daudé 1 week, 3 days ago
On 20/5/26 08:36, Jay Chang wrote:
> This series fixes PMP address alignment to comply with the RISC-V
> specification WARL (Write-Any, Read-Legal) semantics.
> 
> When configuring pmpcfg (TOR, NA4, or NAPOT) and pmpaddr, if the
> value is smaller than the PMP granularity, it needs to be aligned
> to the PMP granularity.
> 
> Chagnes in v5:
> - Use uint64_t for granule, in preparation for upcoming single-binary work:
>    https://lore.kernel.org/qemu-devel/20260515180437.23620-1-anjo@rev.ng/

Thank you! Series LGTM.