Let's add a way to return the value (successfully) set via s390_set_max_pagesize() previously. This will be helpful to reject hotplugged memory devices that would exceed this initially set page size.
Signed-off-by: David Hildenbrand <da...@redhat.com> --- target/s390x/cpu-sysemu.c | 16 ++++++++++++++++ target/s390x/cpu.h | 1 + 2 files changed, 17 insertions(+) diff --git a/target/s390x/cpu-sysemu.c b/target/s390x/cpu-sysemu.c index 1915567b3a..bee5d6c2ee 100644 --- a/target/s390x/cpu-sysemu.c +++ b/target/s390x/cpu-sysemu.c @@ -278,11 +278,27 @@ uint64_t s390_get_memory_limit(void) return memory_limit; } +static uint64_t max_pagesize; + void s390_set_max_pagesize(uint64_t pagesize, Error **errp) { + ERRP_GUARD(); + + if (max_pagesize) { + error_setg(errp, "Maximum page size can only be set once"); + return; + } if (kvm_enabled()) { kvm_s390_set_max_pagesize(pagesize, errp); } + if (!*errp) { + max_pagesize = pagesize; + } +} + +uint64_t s390_get_max_pagesize(void) +{ + return max_pagesize; } void s390_cmma_reset(void) diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h index 7a51b606ed..37845e0d9d 100644 --- a/target/s390x/cpu.h +++ b/target/s390x/cpu.h @@ -897,6 +897,7 @@ void s390_crypto_reset(void); int s390_set_memory_limit(uint64_t new_limit, uint64_t *hw_limit); uint64_t s390_get_memory_limit(void); void s390_set_max_pagesize(uint64_t pagesize, Error **errp); +uint64_t s390_get_max_pagesize(void); void s390_cmma_reset(void); void s390_enable_css_support(S390CPU *cpu); void s390_do_cpu_set_diag318(CPUState *cs, run_on_cpu_data arg); -- 2.46.0