Skip to contentSkip to conversation

exec: Ensure variable page size is only used with TARGET_PAGE_BITS_VARY

PATCH In review Philippe Mathieu-Daudé 2 participants 5 messages Nov 4, 2020 – Nov 24, 2020

lore
Share & tools
lore
#0 lore raw

cover exec: Ensure variable page size is only used with TARGET_PAGE_BITS_VARY

Simple patch while trying to figure out Fuloong-2E 16KB page size. Better safe than sorry =)

Philippe Mathieu-Daudé (2):
MAINTAINERS: Cover exec-vary.c (variable page size)
exec: Ensure variable page size is only used with
TARGET_PAGE_BITS_VARY

 include/qemu-common.h | 4 +++-
 exec-vary.c           | 4 +++-
 MAINTAINERS           | 1 +
 3 files changed, 7 insertions(+), 2 deletions(-)
Signature · 1 line
2.26.2
#1 lore raw

PATCH 1/2 MAINTAINERS: Cover exec-vary.c (variable page size)

Add exec-vary.c to the 'Overall TCG CPUs' section.

---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
index dd16606bcdc..466898d3dbd 100644
@@ -117,6 +117,7 @@ R: Paolo Bonzini <[email protected]>
 S: Maintained
 F: softmmu/cpus.c
 F: cpus-common.c
+F: exec-vary.c
 F: accel/tcg/
 F: accel/stubs/tcg-stub.c
 F: scripts/decodetree.py
Signature · 1 line
2.26.2
#2 lore raw

PATCH 2/2 exec: Ensure variable page size is only used with TARGET_PAGE_BITS_VARY

In reply to Philippe Mathieu-Daudé

If TARGET_PAGE_BITS_VARY is not supported, machines should not intent to modify the target page size.
As set_preferred_target_page_bits() is supposed to return 'false' on failure (documented in "qemu-common.h"), return false to indicate failure if this ever happens.

---
 include/qemu-common.h | 4 +++-
 exec-vary.c           | 4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)
include/qemu-common.h +3 -1
index fda7dc6ca77..3ea616d4567 100644
@@ -70,7 +70,9 @@ void cpu_exec_step_atomic(CPUState *cpu);
  * size may be smaller than any given CPU's preference).
  * Returns true on success, false on failure (which can only happen
  * if this is called after the system has already finalized its
- * choice of page size and the requested page size is smaller than that).
+ * choice of page size and the requested page size is smaller than
+ * that). Only target supporting variable page size should set a
+ * preferred target page size.
  */
 bool set_preferred_target_page_bits(int bits);
 
exec-vary.c +3 -1
index ff905f2a8fb..4b0b7f193af 100644
@@ -86,8 +86,10 @@ bool set_preferred_target_page_bits(int bits)
         }
         init_target_page.bits = bits;
     }
-#endif
     return true;
+#else
+    return false;
+#endif
 }
 
 void finalize_target_page_bits(void)
Signature · 1 line
2.26.2
Reviewed-by on v1 2/2
#3 lore raw
Quoted 32 lines · Philippe Mathieu-Daudé

If TARGET_PAGE_BITS_VARY is not supported, machines should not intent to modify the target page size.
As set_preferred_target_page_bits() is supposed to return 'false' on failure (documented in "qemu-common.h"), return false to indicate failure if this ever happens.

---
 include/qemu-common.h | 4 +++-
 exec-vary.c           | 4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)
include/qemu-common.h +3 -1
index fda7dc6ca77..3ea616d4567 100644
@@ -70,7 +70,9 @@ void cpu_exec_step_atomic(CPUState *cpu);
  * size may be smaller than any given CPU's preference).
  * Returns true on success, false on failure (which can only happen
  * if this is called after the system has already finalized its
- * choice of page size and the requested page size is smaller than that).
+ * choice of page size and the requested page size is smaller than
+ * that). Only target supporting variable page size should set a
+ * preferred target page size.
  */
 bool set_preferred_target_page_bits(int bits);
 
exec-vary.c +0 -0
index ff905f2a8fb..4b0b7f193af 100644

exec-vary.c bool set_preferred_target_page_bits(int bits) · line 92

Quoted 8 lines
exec-vary.c +3 -1
@@ -86,8 +86,10 @@ bool set_preferred_target_page_bits(int bits)
         }
         init_target_page.bits = bits;
     }
-#endif
     return true;
+#else
+    return false;
+#endif

I guess the only generic caller is the one in softmmu/vl.c, which is protected by machine_class->minimum_page_bits != 0. So this affects exactly one machine outside arm -- fuloong2e.

Certainly we should not allow an impossible setting. I wonder if it is worth doing return bits == TARGET_PAGE_BITS?

Either way,

r~

#4 lore raw
In reply to Philippe Mathieu-Daudé

ping?

Quoted 13 lines · Philippe Mathieu-Daudé

Simple patch while trying to figure out Fuloong-2E 16KB page size. Better safe than sorry =)

Philippe Mathieu-Daudé (2):
MAINTAINERS: Cover exec-vary.c (variable page size)
exec: Ensure variable page size is only used with
TARGET_PAGE_BITS_VARY

 include/qemu-common.h | 4 +++-
 exec-vary.c           | 4 +++-
 MAINTAINERS           | 1 +
 3 files changed, 7 insertions(+), 2 deletions(-)