[PATCH v2 00/21] accel/tcg: Introduce tlb_fill_align hook

Richard Henderson posted 21 patches 1 month, 2 weeks ago
There is a newer version of this series
include/exec/memop.h           |  47 +++++++++++
include/hw/core/tcg-cpu-ops.h  |  25 ++++++
include/tcg/tcg.h              |  23 ------
target/arm/internals.h         |   9 ++-
target/hppa/cpu.h              |   5 +-
accel/tcg/cputlb.c             | 142 +++++++++++++++++----------------
accel/tcg/user-exec.c          |   4 +-
target/alpha/cpu.c             |   1 +
target/arm/cpu.c               |   1 +
target/arm/helper.c            |   4 +-
target/arm/ptw.c               | 141 ++++++++++++++++++--------------
target/arm/tcg/cpu-v7m.c       |   1 +
target/arm/tcg/m_helper.c      |   8 +-
target/arm/tcg/tlb_helper.c    |  27 ++++++-
target/arm/tcg/translate-a64.c |   4 +-
target/avr/cpu.c               |   1 +
target/hppa/cpu.c              |   1 +
target/hppa/int_helper.c       |   2 +-
target/hppa/mem_helper.c       |  50 ++++++++----
target/hppa/op_helper.c        |   2 +-
target/i386/tcg/tcg-cpu.c      |   1 +
target/loongarch/cpu.c         |   1 +
target/m68k/cpu.c              |   1 +
target/microblaze/cpu.c        |   1 +
target/mips/cpu.c              |   1 +
target/openrisc/cpu.c          |   1 +
target/ppc/cpu_init.c          |   1 +
target/riscv/tcg/tcg-cpu.c     |   1 +
target/rx/cpu.c                |   1 +
target/s390x/cpu.c             |   1 +
target/sh4/cpu.c               |   1 +
target/sparc/cpu.c             |   1 +
target/tricore/cpu.c           |   1 +
target/xtensa/cpu.c            |   1 +
target/xtensa/translate.c      |   2 +-
tcg/tcg-op-ldst.c              |   6 +-
tcg/tcg.c                      |   2 +-
tcg/arm/tcg-target.c.inc       |   4 +-
tcg/sparc64/tcg-target.c.inc   |   2 +-
39 files changed, 329 insertions(+), 199 deletions(-)
[PATCH v2 00/21] accel/tcg: Introduce tlb_fill_align hook
Posted by Richard Henderson 1 month, 2 weeks ago
This new hook will allow targets to recognize an alignment
fault with the correct priority with respect to other faults
that can be raised by paging.

This should fix several hppa fault priority issues, most
importantly that access permissions come before alignment.

[ Helge, I find that my old hppa system images would not boot,
  and a scratch re-install of debian 12 failed (networking error?).
  Would you please test?  It would be nice to have a self-contained
  regression test for this, using a port of the multiarch/system
  minilib, but that's a larger job.]

This should fix the documented error in the Arm alignment
fault due to memory type.

[ Also untested.  I should be possible to leverate aarch64/system/boot.S
  to manage this, but it's still tricky. ]

Changes for v2:
  - Include the arm_cpu_tlb_fill_align patch.  Oops!
  - Improve some commentary in target/arm/ptw.c.


r~


Richard Henderson (21):
  accel/tcg: Assert noreturn from write-only page for atomics
  accel/tcg: Expand tlb_fill for 3 callers
  include/exec/memop: Move get_alignment_bits from tcg.h
  include/exec/memop: Rename get_alignment_bits
  include/exec/memop: Introduce memop_atomicity_bits
  hw/core/tcg-cpu-ops: Introduce tlb_fill_align hook
  accel/tcg: Use the tlb_fill_align hook
  target/hppa: Add MemOp argument to hppa_get_physical_address
  target/hppa: Perform access rights before protection id check
  target/hppa: Fix priority of T, D, and B page faults
  target/hppa: Handle alignment faults in hppa_get_physical_address
  target/hppa: Add hppa_cpu_tlb_fill_align
  target/arm: Pass MemOp to get_phys_addr
  target/arm: Pass MemOp to get_phys_addr_with_space_nogpc
  target/arm: Pass MemOp to get_phys_addr_gpc
  target/arm: Pass MemOp to get_phys_addr_nogpc
  target/arm: Pass MemOp through get_phys_addr_twostage
  target/arm: Pass MemOp to get_phys_addr_lpae
  target/arm: Move device detection earlier in get_phys_addr_lpae
  target/arm: Add arm_cpu_tlb_fill_align
  target/arm: Fix alignment fault priority in get_phys_addr_lpae

 include/exec/memop.h           |  47 +++++++++++
 include/hw/core/tcg-cpu-ops.h  |  25 ++++++
 include/tcg/tcg.h              |  23 ------
 target/arm/internals.h         |   9 ++-
 target/hppa/cpu.h              |   5 +-
 accel/tcg/cputlb.c             | 142 +++++++++++++++++----------------
 accel/tcg/user-exec.c          |   4 +-
 target/alpha/cpu.c             |   1 +
 target/arm/cpu.c               |   1 +
 target/arm/helper.c            |   4 +-
 target/arm/ptw.c               | 141 ++++++++++++++++++--------------
 target/arm/tcg/cpu-v7m.c       |   1 +
 target/arm/tcg/m_helper.c      |   8 +-
 target/arm/tcg/tlb_helper.c    |  27 ++++++-
 target/arm/tcg/translate-a64.c |   4 +-
 target/avr/cpu.c               |   1 +
 target/hppa/cpu.c              |   1 +
 target/hppa/int_helper.c       |   2 +-
 target/hppa/mem_helper.c       |  50 ++++++++----
 target/hppa/op_helper.c        |   2 +-
 target/i386/tcg/tcg-cpu.c      |   1 +
 target/loongarch/cpu.c         |   1 +
 target/m68k/cpu.c              |   1 +
 target/microblaze/cpu.c        |   1 +
 target/mips/cpu.c              |   1 +
 target/openrisc/cpu.c          |   1 +
 target/ppc/cpu_init.c          |   1 +
 target/riscv/tcg/tcg-cpu.c     |   1 +
 target/rx/cpu.c                |   1 +
 target/s390x/cpu.c             |   1 +
 target/sh4/cpu.c               |   1 +
 target/sparc/cpu.c             |   1 +
 target/tricore/cpu.c           |   1 +
 target/xtensa/cpu.c            |   1 +
 target/xtensa/translate.c      |   2 +-
 tcg/tcg-op-ldst.c              |   6 +-
 tcg/tcg.c                      |   2 +-
 tcg/arm/tcg-target.c.inc       |   4 +-
 tcg/sparc64/tcg-target.c.inc   |   2 +-
 39 files changed, 329 insertions(+), 199 deletions(-)

-- 
2.43.0
Re: [PATCH v2 00/21] accel/tcg: Introduce tlb_fill_align hook
Posted by Helge Deller 1 month, 2 weeks ago
On 10/5/24 22:05, Richard Henderson wrote:
> This new hook will allow targets to recognize an alignment
> fault with the correct priority with respect to other faults
> that can be raised by paging.
>
> This should fix several hppa fault priority issues, most
> importantly that access permissions come before alignment.

I can confirm that this patchset fixes the access permissions
before the alignment checks on hppa.
I used the testcase from the description of this bug report:
https://bugzilla.kernel.org/show_bug.cgi?id=219339#c0
Maybe you could add a reference to this BZ in your commit message?

> [ Helge, I find that my old hppa system images would not boot,
>    and a scratch re-install of debian 12 failed (networking error?).

A new debian-sid qemu image is here:
http://www.dellerweb.de/qemu/debian-sid-hdd-2024.img.bz2

>    Would you please test?  It would be nice to have a self-contained
>    regression test for this, using a port of the multiarch/system
>    minilib, but that's a larger job.]

I think the C example from the BZ might help for such a testcase.

Helge


> This should fix the documented error in the Arm alignment
> fault due to memory type.
>
> [ Also untested.  I should be possible to leverate aarch64/system/boot.S
>    to manage this, but it's still tricky. ]
>
> Changes for v2:
>    - Include the arm_cpu_tlb_fill_align patch.  Oops!
>    - Improve some commentary in target/arm/ptw.c.
>
>
> r~
>
>
> Richard Henderson (21):
>    accel/tcg: Assert noreturn from write-only page for atomics
>    accel/tcg: Expand tlb_fill for 3 callers
>    include/exec/memop: Move get_alignment_bits from tcg.h
>    include/exec/memop: Rename get_alignment_bits
>    include/exec/memop: Introduce memop_atomicity_bits
>    hw/core/tcg-cpu-ops: Introduce tlb_fill_align hook
>    accel/tcg: Use the tlb_fill_align hook
>    target/hppa: Add MemOp argument to hppa_get_physical_address
>    target/hppa: Perform access rights before protection id check
>    target/hppa: Fix priority of T, D, and B page faults
>    target/hppa: Handle alignment faults in hppa_get_physical_address
>    target/hppa: Add hppa_cpu_tlb_fill_align
>    target/arm: Pass MemOp to get_phys_addr
>    target/arm: Pass MemOp to get_phys_addr_with_space_nogpc
>    target/arm: Pass MemOp to get_phys_addr_gpc
>    target/arm: Pass MemOp to get_phys_addr_nogpc
>    target/arm: Pass MemOp through get_phys_addr_twostage
>    target/arm: Pass MemOp to get_phys_addr_lpae
>    target/arm: Move device detection earlier in get_phys_addr_lpae
>    target/arm: Add arm_cpu_tlb_fill_align
>    target/arm: Fix alignment fault priority in get_phys_addr_lpae
>
>   include/exec/memop.h           |  47 +++++++++++
>   include/hw/core/tcg-cpu-ops.h  |  25 ++++++
>   include/tcg/tcg.h              |  23 ------
>   target/arm/internals.h         |   9 ++-
>   target/hppa/cpu.h              |   5 +-
>   accel/tcg/cputlb.c             | 142 +++++++++++++++++----------------
>   accel/tcg/user-exec.c          |   4 +-
>   target/alpha/cpu.c             |   1 +
>   target/arm/cpu.c               |   1 +
>   target/arm/helper.c            |   4 +-
>   target/arm/ptw.c               | 141 ++++++++++++++++++--------------
>   target/arm/tcg/cpu-v7m.c       |   1 +
>   target/arm/tcg/m_helper.c      |   8 +-
>   target/arm/tcg/tlb_helper.c    |  27 ++++++-
>   target/arm/tcg/translate-a64.c |   4 +-
>   target/avr/cpu.c               |   1 +
>   target/hppa/cpu.c              |   1 +
>   target/hppa/int_helper.c       |   2 +-
>   target/hppa/mem_helper.c       |  50 ++++++++----
>   target/hppa/op_helper.c        |   2 +-
>   target/i386/tcg/tcg-cpu.c      |   1 +
>   target/loongarch/cpu.c         |   1 +
>   target/m68k/cpu.c              |   1 +
>   target/microblaze/cpu.c        |   1 +
>   target/mips/cpu.c              |   1 +
>   target/openrisc/cpu.c          |   1 +
>   target/ppc/cpu_init.c          |   1 +
>   target/riscv/tcg/tcg-cpu.c     |   1 +
>   target/rx/cpu.c                |   1 +
>   target/s390x/cpu.c             |   1 +
>   target/sh4/cpu.c               |   1 +
>   target/sparc/cpu.c             |   1 +
>   target/tricore/cpu.c           |   1 +
>   target/xtensa/cpu.c            |   1 +
>   target/xtensa/translate.c      |   2 +-
>   tcg/tcg-op-ldst.c              |   6 +-
>   tcg/tcg.c                      |   2 +-
>   tcg/arm/tcg-target.c.inc       |   4 +-
>   tcg/sparc64/tcg-target.c.inc   |   2 +-
>   39 files changed, 329 insertions(+), 199 deletions(-)
>