Skip to contentSkip to conversation

Fix NB_MMU_MODES to 16

PATCH In review Anton Johansson via 4 participants 31 messages Mar 6, 2023 – Mar 7, 2023 RISC-V

lore
Share & tools
lore
#0 lore raw

cover Fix NB_MMU_MODES to 16

This patchset fixes NB_MMU_MODES to 16 for all targets, meaning the macro is no longer target-specific. 16 mmu modes is large enough to cover all currently supported targets (12 arm, 10 ppc, ...), and is the maxiumum supported by the softmmu tlb api.

As mentioned by Richard in response to our RFC, softmmu tlbs are dynamically resized and so the overhead of an unused mmu index is fairly low.

The grand goal is to allow for heterogeneous QEMU binaries consisting of multiple frontends.

RFC: https://lists.nongnu.org/archive/html/qemu-devel/2022-12/msg04518.html

Anton Johansson (23):
include/exec: Set default NB_MMU_MODES to 16 target/alpha: Remove NB_MMU_MODES define target/arm: Remove NB_MMU_MODES define target/avr: Remove NB_MMU_MODES define target/cris: Remove NB_MMU_MODES define target/hexagon: Remove NB_MMU_MODES define target/hppa: Remove NB_MMU_MODES define target/i386: Remove NB_MMU_MODES define target/loongarch: Remove NB_MMU_MODES define target/m68k: Remove NB_MMU_MODES define target/microblaze: Remove NB_MMU_MODES define target/mips: Remove NB_MMU_MODES define target/nios2: Remove NB_MMU_MODES define target/openrisc: Remove NB_MMU_MODES define target/ppc: Remove NB_MMU_MODES define target/riscv: Remove NB_MMU_MODES define target/rx: Remove NB_MMU_MODES define target/s390x: Remove NB_MMU_MODES define target/sh4: Remove NB_MMU_MODES define target/sparc: Remove NB_MMU_MODES define target/tricore: Remove NB_MMU_MODES define target/xtensa: Remove NB_MMU_MODES define include/exec: Remove guards around NB_MMU_MODES

 include/exec/cpu-defs.h       | 9 ++++++---
 target/alpha/cpu-param.h      | 2 --
 target/arm/cpu-param.h        | 2 --
 target/avr/cpu-param.h        | 1 -
 target/cris/cpu-param.h       | 1 -
 target/hexagon/cpu-param.h    | 2 --
 target/hppa/cpu-param.h       | 1 -
 target/i386/cpu-param.h       | 1 -
 target/loongarch/cpu-param.h  | 1 -
 target/m68k/cpu-param.h       | 1 -
 target/microblaze/cpu-param.h | 1 -
 target/microblaze/cpu.h       | 2 +-
 target/mips/cpu-param.h       | 1 -
 target/nios2/cpu-param.h      | 1 -
 target/openrisc/cpu-param.h   | 1 -
 target/ppc/cpu-param.h        | 1 -
 target/riscv/cpu-param.h      | 1 -
 target/rx/cpu-param.h         | 2 --
 target/s390x/cpu-param.h      | 1 -
 target/sh4/cpu-param.h        | 1 -
 target/sparc/cpu-param.h      | 2 --
 target/tricore/cpu-param.h    | 1 -
 target/xtensa/cpu-param.h     | 1 -
 23 files changed, 7 insertions(+), 30 deletions(-)

--
2.39.1

#1 lore raw

PATCH 1/23 include/exec: Set default `NB_MMU_MODES` to 16

---
 include/exec/cpu-defs.h | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
include/exec/cpu-defs.h +8 -3
index be920d4208..69cd62c19b 100644
@@ -36,9 +36,6 @@
 #ifndef TARGET_LONG_BITS
 # error TARGET_LONG_BITS must be defined in cpu-param.h
 #endif
-#ifndef NB_MMU_MODES
-# error NB_MMU_MODES must be defined in cpu-param.h
-#endif
 #ifndef TARGET_PHYS_ADDR_SPACE_BITS
 # error TARGET_PHYS_ADDR_SPACE_BITS must be defined in cpu-param.h
 #endif
@@ -55,6 +52,14 @@
 # endif
 #endif
 
+/*
+ * Fix the maxiumum number of mmu modes to 16.  This is larger than all current
+ * targets, and also the maximum supported by the softmmu tlb api.
+ */
+#ifndef NB_MMU_MODES
+#define NB_MMU_MODES 16
+#endif
+
 #define TARGET_LONG_SIZE (TARGET_LONG_BITS / 8)
 
 /* target_ulong is the type of a virtual address */
Signature · 1 line
2.39.1
#2 lore raw

Re: [PATCH 01/23] include/exec: Set default `NB_MMU_MODES` to 16

Quoted 20 lines · Anton Johansson
---
  include/exec/cpu-defs.h | 11 ++++++++---
  1 file changed, 8 insertions(+), 3 deletions(-)
include/exec/cpu-defs.h +0 -3
index be920d4208..69cd62c19b 100644
@@ -36,9 +36,6 @@
  #ifndef TARGET_LONG_BITS
  # error TARGET_LONG_BITS must be defined in cpu-param.h
  #endif
-#ifndef NB_MMU_MODES
-# error NB_MMU_MODES must be defined in cpu-param.h
-#endif
  #ifndef TARGET_PHYS_ADDR_SPACE_BITS
  # error TARGET_PHYS_ADDR_SPACE_BITS must be defined in cpu-param.h
  #endif

include/exec/cpu-defs.h line 57

Quoted 6 lines
include/exec/cpu-defs.h +3 -0
@@ -55,6 +52,14 @@
  # endif
  #endif
 
+/*
+ * Fix the maxiumum number of mmu modes to 16.  This is larger than all current
+ * targets, and also the maximum supported by the softmmu tlb api.

Typo "maximum".

I'd keep "larger than all current targets, and also" for the commit description and not commit as comment in the code.

Quoted 8 lines
include/exec/cpu-defs.h +5 -0
+ */
+#ifndef NB_MMU_MODES
+#define NB_MMU_MODES 16
+#endif
+
  #define TARGET_LONG_SIZE (TARGET_LONG_BITS / 8)
 
  /* target_ulong is the type of a virtual address */
#3 lore raw

PATCH 2/23 target/alpha: Remove `NB_MMU_MODES` define

In reply to Anton Johansson via
---
 target/alpha/cpu-param.h | 2 --
 1 file changed, 2 deletions(-)
target/alpha/cpu-param.h +0 -2
index 17cd14e590..68c46f7998 100644
@@ -15,6 +15,4 @@
 #define TARGET_PHYS_ADDR_SPACE_BITS  44
 #define TARGET_VIRT_ADDR_SPACE_BITS  (30 + TARGET_PAGE_BITS)
 
-#define NB_MMU_MODES 3
-
 #endif
Signature · 1 line
2.39.1
#5 lore raw

Re: [PATCH 03/23] target/arm: Remove `NB_MMU_MODES` define

Quoted 10 lines · Anton Johansson
---
  target/arm/cpu-param.h | 2 --
  1 file changed, 2 deletions(-)
target/arm/cpu-param.h +0 -0
index b7bde18986..b3b35f7aa1 100644

target/arm/cpu-param.h line 49

Quoted 5 lines
target/arm/cpu-param.h +0 -2
@@ -45,6 +45,4 @@
      bool guarded;
  #endif
 
-#define NB_MMU_MODES 12
-

We need to update the comment previous to ARMMMUIdx typedef.

#6 lore raw

PATCH 4/23 target/avr: Remove `NB_MMU_MODES` define

In reply to Anton Johansson via
---
 target/avr/cpu-param.h | 1 -
 1 file changed, 1 deletion(-)
target/avr/cpu-param.h +0 -1
index 7ef4e7c679..9a92bc74fc 100644
@@ -31,6 +31,5 @@
 #define TARGET_PAGE_BITS 8
 #define TARGET_PHYS_ADDR_SPACE_BITS 24
 #define TARGET_VIRT_ADDR_SPACE_BITS 24
-#define NB_MMU_MODES 2
 
 #endif
Signature · 1 line
2.39.1
#7 lore raw

PATCH 5/23 target/cris: Remove `NB_MMU_MODES` define

In reply to Anton Johansson via
---
 target/cris/cpu-param.h | 1 -
 1 file changed, 1 deletion(-)
target/cris/cpu-param.h +0 -1
index 12ec22d8df..b31b742c0d 100644
@@ -12,6 +12,5 @@
 #define TARGET_PAGE_BITS 13
 #define TARGET_PHYS_ADDR_SPACE_BITS 32
 #define TARGET_VIRT_ADDR_SPACE_BITS 32
-#define NB_MMU_MODES 2
 
 #endif
Signature · 1 line
2.39.1
#8 lore raw

PATCH 6/23 target/hexagon: Remove `NB_MMU_MODES` define

In reply to Anton Johansson via
---
 target/hexagon/cpu-param.h | 2 --
 1 file changed, 2 deletions(-)
target/hexagon/cpu-param.h +0 -2
index e8ed5468d9..71b4a9b83e 100644
@@ -24,6 +24,4 @@
 #define TARGET_PHYS_ADDR_SPACE_BITS 36
 #define TARGET_VIRT_ADDR_SPACE_BITS 32
 
-#define NB_MMU_MODES 1
-
 #endif
Signature · 1 line
2.39.1
#11 lore raw

PATCH 9/23 target/loongarch: Remove `NB_MMU_MODES` define

In reply to Anton Johansson via
---
 target/loongarch/cpu-param.h | 1 -
 1 file changed, 1 deletion(-)
target/loongarch/cpu-param.h +0 -1
index 414d8fff46..1265dc7cb5 100644
@@ -13,6 +13,5 @@
 #define TARGET_VIRT_ADDR_SPACE_BITS 48
 
 #define TARGET_PAGE_BITS 14
-#define NB_MMU_MODES 5
 
 #endif
Signature · 1 line
2.39.1
#12 lore raw

PATCH 10/23 target/m68k: Remove `NB_MMU_MODES` define

In reply to Anton Johansson via
---
 target/m68k/cpu-param.h | 1 -
 1 file changed, 1 deletion(-)
target/m68k/cpu-param.h +0 -1
index 44a8d193f0..39dcbcece8 100644
@@ -17,6 +17,5 @@
 #define TARGET_PAGE_BITS 12
 #define TARGET_PHYS_ADDR_SPACE_BITS 32
 #define TARGET_VIRT_ADDR_SPACE_BITS 32
-#define NB_MMU_MODES 2
 
 #endif
Signature · 1 line
2.39.1
#13 lore raw

PATCH 11/23 target/microblaze: Remove `NB_MMU_MODES` define

In reply to Anton Johansson via
---
 target/microblaze/cpu-param.h | 1 -
 target/microblaze/cpu.h       | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)
target/microblaze/cpu-param.h +0 -1
index 5e54ea0108..9770b0eb52 100644
@@ -28,6 +28,5 @@
 
 /* FIXME: MB uses variable pages down to 1K but linux only uses 4k.  */
 #define TARGET_PAGE_BITS 12
-#define NB_MMU_MODES 3
 
 #endif
target/microblaze/cpu.h +1 -1
index f66df02226..88324d0bc1 100644
@@ -394,7 +394,7 @@ void mb_tcg_init(void);
 #define MMU_NOMMU_IDX   0
 #define MMU_KERNEL_IDX  1
 #define MMU_USER_IDX    2
-/* See NB_MMU_MODES further up the file.  */
+/* See NB_MMU_MODES in cpu-defs.h. */
 
 #include "exec/cpu-all.h"
 
Signature · 1 line
2.39.1
#16 lore raw

PATCH 14/23 target/openrisc: Remove `NB_MMU_MODES` define

In reply to Anton Johansson via
---
 target/openrisc/cpu-param.h | 1 -
 1 file changed, 1 deletion(-)
target/openrisc/cpu-param.h +0 -1
index 73be699f36..3f08207485 100644
@@ -12,6 +12,5 @@
 #define TARGET_PAGE_BITS 13
 #define TARGET_PHYS_ADDR_SPACE_BITS 32
 #define TARGET_VIRT_ADDR_SPACE_BITS 32
-#define NB_MMU_MODES 3
 
 #endif
Signature · 1 line
2.39.1
#20 lore raw

PATCH 18/23 target/s390x: Remove `NB_MMU_MODES` define

In reply to Anton Johansson via
---
 target/s390x/cpu-param.h | 1 -
 1 file changed, 1 deletion(-)
target/s390x/cpu-param.h +0 -1
index bf951a002e..84ca08626b 100644
@@ -12,6 +12,5 @@
 #define TARGET_PAGE_BITS 12
 #define TARGET_PHYS_ADDR_SPACE_BITS 64
 #define TARGET_VIRT_ADDR_SPACE_BITS 64
-#define NB_MMU_MODES 4
 
 #endif
Signature · 1 line
2.39.1
#22 lore raw

PATCH 20/23 target/sparc: Remove `NB_MMU_MODES` define

In reply to Anton Johansson via
---
 target/sparc/cpu-param.h | 2 --
 1 file changed, 2 deletions(-)
target/sparc/cpu-param.h +0 -2
index 72ddc4a34f..cb11980404 100644
@@ -16,13 +16,11 @@
 # else
 #  define TARGET_VIRT_ADDR_SPACE_BITS 44
 # endif
-# define NB_MMU_MODES 6
 #else
 # define TARGET_LONG_BITS 32
 # define TARGET_PAGE_BITS 12 /* 4k */
 # define TARGET_PHYS_ADDR_SPACE_BITS 36
 # define TARGET_VIRT_ADDR_SPACE_BITS 32
-# define NB_MMU_MODES 3
 #endif
 
 #endif
Signature · 1 line
2.39.1
#23 lore raw

PATCH 21/23 target/tricore: Remove `NB_MMU_MODES` define

In reply to Anton Johansson via
---
 target/tricore/cpu-param.h | 1 -
 1 file changed, 1 deletion(-)
target/tricore/cpu-param.h +0 -1
index 2727913047..e29d551dd6 100644
@@ -12,6 +12,5 @@
 #define TARGET_PAGE_BITS 14
 #define TARGET_PHYS_ADDR_SPACE_BITS 32
 #define TARGET_VIRT_ADDR_SPACE_BITS 32
-#define NB_MMU_MODES 3
 
 #endif
Signature · 1 line
2.39.1
#25 lore raw

PATCH 23/23 include/exec: Remove guards around `NB_MMU_MODES`

In reply to Anton Johansson via
---
 include/exec/cpu-defs.h | 2 --
 1 file changed, 2 deletions(-)
include/exec/cpu-defs.h +0 -2
index 69cd62c19b..40e72c4f08 100644
@@ -56,9 +56,7 @@
  * Fix the maxiumum number of mmu modes to 16.  This is larger than all current
  * targets, and also the maximum supported by the softmmu tlb api.
  */
-#ifndef NB_MMU_MODES
 #define NB_MMU_MODES 16
-#endif
 
 #define TARGET_LONG_SIZE (TARGET_LONG_BITS / 8)
 
Signature · 1 line
2.39.1
Reviewed-by on the v1 series
#26 lore raw
In reply to Anton Johansson via
Quoted 9 lines · Anton Johansson via

This patchset fixes NB_MMU_MODES to 16 for all targets, meaning the macro is no longer target-specific. 16 mmu modes is large enough to cover all currently supported targets (12 arm, 10 ppc, ...), and is the maxiumum supported by the softmmu tlb api.

As mentioned by Richard in response to our RFC, softmmu tlbs are dynamically resized and so the overhead of an unused mmu index is fairly low.

Quoted 5 lines

The grand goal is to allow for heterogeneous QEMU binaries consisting of multiple frontends.

RFC:
https://lists.nongnu.org/archive/html/qemu-devel/2022-12/msg04518.html

LGTM:

Signature · 2 lines
Alex Bennée
Virtualisation Tech Lead @ Linaro
#27 lore raw
In reply to Anton Johansson via
Quoted 30 lines · Anton Johansson

This patchset fixes NB_MMU_MODES to 16 for all targets, meaning the macro is no longer target-specific. 16 mmu modes is large enough to cover all currently supported targets (12 arm, 10 ppc, ...), and is the maxiumum supported by the softmmu tlb api.

As mentioned by Richard in response to our RFC, softmmu tlbs are dynamically resized and so the overhead of an unused mmu index is fairly low.

The grand goal is to allow for heterogeneous QEMU binaries consisting of multiple frontends.

RFC: https://lists.nongnu.org/archive/html/qemu-devel/2022-12/msg04518.html

Anton Johansson (23):
include/exec: Set default NB_MMU_MODES to 16 target/alpha: Remove NB_MMU_MODES define target/arm: Remove NB_MMU_MODES define target/avr: Remove NB_MMU_MODES define target/cris: Remove NB_MMU_MODES define target/hexagon: Remove NB_MMU_MODES define target/hppa: Remove NB_MMU_MODES define target/i386: Remove NB_MMU_MODES define target/loongarch: Remove NB_MMU_MODES define target/m68k: Remove NB_MMU_MODES define target/microblaze: Remove NB_MMU_MODES define target/mips: Remove NB_MMU_MODES define target/nios2: Remove NB_MMU_MODES define target/openrisc: Remove NB_MMU_MODES define target/ppc: Remove NB_MMU_MODES define

Quoted 8 lines

target/riscv: Remove NB_MMU_MODES define target/rx: Remove NB_MMU_MODES define target/s390x: Remove NB_MMU_MODES define target/sh4: Remove NB_MMU_MODES define target/sparc: Remove NB_MMU_MODES define target/tricore: Remove NB_MMU_MODES define target/xtensa: Remove NB_MMU_MODES define include/exec: Remove guards around NB_MMU_MODES

As 24/23 we can remove the assertion in qemu_plugin_get_hwaddr().

Then NB_MMU_MODES is only used by CPUTLB in "exec/cpu-defs.h" and in accel/tcg/cputlb.c.

#28 lore raw
Quoted 40 lines · Philippe Mathieu-Daudé
Quoted 30 lines · Anton Johansson

This patchset fixes NB_MMU_MODES to 16 for all targets, meaning the macro is no longer target-specific.  16 mmu modes is large enough to cover all currently supported targets (12 arm, 10 ppc, ...), and is the maxiumum supported by the softmmu tlb api.

As mentioned by Richard in response to our RFC, softmmu tlbs are dynamically resized and so the overhead of an unused mmu index is fairly low.

The grand goal is to allow for heterogeneous QEMU binaries consisting of multiple frontends.

RFC: https://lists.nongnu.org/archive/html/qemu-devel/2022-12/msg04518.html

Anton Johansson (23):
   include/exec: Set default NB_MMU_MODES to 16 target/alpha: Remove NB_MMU_MODES define target/arm: Remove NB_MMU_MODES define target/avr: Remove NB_MMU_MODES define target/cris: Remove NB_MMU_MODES define target/hexagon: Remove NB_MMU_MODES define target/hppa: Remove NB_MMU_MODES define target/i386: Remove NB_MMU_MODES define target/loongarch: Remove NB_MMU_MODES define target/m68k: Remove NB_MMU_MODES define target/microblaze: Remove NB_MMU_MODES define target/mips: Remove NB_MMU_MODES define target/nios2: Remove NB_MMU_MODES define target/openrisc: Remove NB_MMU_MODES define target/ppc: Remove NB_MMU_MODES define

Quoted 8 lines

   target/riscv: Remove NB_MMU_MODES define target/rx: Remove NB_MMU_MODES define target/s390x: Remove NB_MMU_MODES define target/sh4: Remove NB_MMU_MODES define target/sparc: Remove NB_MMU_MODES define target/tricore: Remove NB_MMU_MODES define target/xtensa: Remove NB_MMU_MODES define include/exec: Remove guards around NB_MMU_MODES

Quoted 4 lines

As 24/23 we can remove the assertion in qemu_plugin_get_hwaddr().

Then NB_MMU_MODES is only used by CPUTLB in "exec/cpu-defs.h" and in accel/tcg/cputlb.c.

I forgot, series:

Reviewed-by on the v1 series
#29 lore raw
In reply to Anton Johansson via
Quoted 30 lines · Anton Johansson

This patchset fixes NB_MMU_MODES to 16 for all targets, meaning the macro is no longer target-specific. 16 mmu modes is large enough to cover all currently supported targets (12 arm, 10 ppc, ...), and is the maxiumum supported by the softmmu tlb api.

As mentioned by Richard in response to our RFC, softmmu tlbs are dynamically resized and so the overhead of an unused mmu index is fairly low.

The grand goal is to allow for heterogeneous QEMU binaries consisting of multiple frontends.

RFC: https://lists.nongnu.org/archive/html/qemu-devel/2022-12/msg04518.html

Anton Johansson (23):
include/exec: Set default NB_MMU_MODES to 16 target/alpha: Remove NB_MMU_MODES define target/arm: Remove NB_MMU_MODES define target/avr: Remove NB_MMU_MODES define target/cris: Remove NB_MMU_MODES define target/hexagon: Remove NB_MMU_MODES define target/hppa: Remove NB_MMU_MODES define target/i386: Remove NB_MMU_MODES define target/loongarch: Remove NB_MMU_MODES define target/m68k: Remove NB_MMU_MODES define target/microblaze: Remove NB_MMU_MODES define target/mips: Remove NB_MMU_MODES define target/nios2: Remove NB_MMU_MODES define target/openrisc: Remove NB_MMU_MODES define target/ppc: Remove NB_MMU_MODES define

Quoted 8 lines

target/riscv: Remove NB_MMU_MODES define target/rx: Remove NB_MMU_MODES define target/s390x: Remove NB_MMU_MODES define target/sh4: Remove NB_MMU_MODES define target/sparc: Remove NB_MMU_MODES define target/tricore: Remove NB_MMU_MODES define target/xtensa: Remove NB_MMU_MODES define include/exec: Remove guards around NB_MMU_MODES

r~

#30 lore raw
In reply to Anton Johansson via
Quoted 30 lines · Anton Johansson

This patchset fixes NB_MMU_MODES to 16 for all targets, meaning the macro is no longer target-specific. 16 mmu modes is large enough to cover all currently supported targets (12 arm, 10 ppc, ...), and is the maxiumum supported by the softmmu tlb api.

As mentioned by Richard in response to our RFC, softmmu tlbs are dynamically resized and so the overhead of an unused mmu index is fairly low.

The grand goal is to allow for heterogeneous QEMU binaries consisting of multiple frontends.

RFC: https://lists.nongnu.org/archive/html/qemu-devel/2022-12/msg04518.html

Anton Johansson (23):
include/exec: Set default NB_MMU_MODES to 16 target/alpha: Remove NB_MMU_MODES define target/arm: Remove NB_MMU_MODES define target/avr: Remove NB_MMU_MODES define target/cris: Remove NB_MMU_MODES define target/hexagon: Remove NB_MMU_MODES define target/hppa: Remove NB_MMU_MODES define target/i386: Remove NB_MMU_MODES define target/loongarch: Remove NB_MMU_MODES define target/m68k: Remove NB_MMU_MODES define target/microblaze: Remove NB_MMU_MODES define target/mips: Remove NB_MMU_MODES define target/nios2: Remove NB_MMU_MODES define target/openrisc: Remove NB_MMU_MODES define target/ppc: Remove NB_MMU_MODES define

Quoted 8 lines

target/riscv: Remove NB_MMU_MODES define target/rx: Remove NB_MMU_MODES define target/s390x: Remove NB_MMU_MODES define target/sh4: Remove NB_MMU_MODES define target/sparc: Remove NB_MMU_MODES define target/tricore: Remove NB_MMU_MODES define target/xtensa: Remove NB_MMU_MODES define include/exec: Remove guards around NB_MMU_MODES

Thanks, queued to tcg-next.

r~