[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v1 06/14] s390x: introduce s390_get_memory_limit()
From: |
David Hildenbrand |
Subject: |
[PATCH v1 06/14] s390x: introduce s390_get_memory_limit() |
Date: |
Tue, 10 Sep 2024 19:58:01 +0200 |
Let's add s390_get_memory_limit(), to query what has been successfully
set via s390_set_memory_limit(). Allow setting the limit only once.
Signed-off-by: David Hildenbrand <david@redhat.com>
---
target/s390x/cpu-sysemu.c | 19 +++++++++++++++++--
target/s390x/cpu.h | 1 +
2 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/target/s390x/cpu-sysemu.c b/target/s390x/cpu-sysemu.c
index 1cd30c1d84..1915567b3a 100644
--- a/target/s390x/cpu-sysemu.c
+++ b/target/s390x/cpu-sysemu.c
@@ -255,12 +255,27 @@ unsigned int s390_cpu_set_state(uint8_t cpu_state,
S390CPU *cpu)
return s390_count_running_cpus();
}
+static uint64_t memory_limit;
+
int s390_set_memory_limit(uint64_t new_limit, uint64_t *hw_limit)
{
+ int ret = 0;
+
+ if (memory_limit) {
+ return -EBUSY;
+ }
if (kvm_enabled()) {
- return kvm_s390_set_mem_limit(new_limit, hw_limit);
+ ret = kvm_s390_set_mem_limit(new_limit, hw_limit);
+ }
+ if (!ret) {
+ memory_limit = new_limit;
}
- return 0;
+ return ret;
+}
+
+uint64_t s390_get_memory_limit(void)
+{
+ return memory_limit;
}
void s390_set_max_pagesize(uint64_t pagesize, Error **errp)
diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h
index d6b75ad0e0..7a51b606ed 100644
--- a/target/s390x/cpu.h
+++ b/target/s390x/cpu.h
@@ -895,6 +895,7 @@ static inline void s390_do_cpu_load_normal(CPUState *cs,
run_on_cpu_data arg)
/* cpu.c */
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);
void s390_cmma_reset(void);
void s390_enable_css_support(S390CPU *cpu);
--
2.46.0
- Re: [PATCH v1 03/14] s390x/s390-virtio-hcall: prepare for more diag500 hypercalls, (continued)
[PATCH v1 05/14] s390x/s390-virtio-ccw: move setting the maximum guest size from sclp to machine code, David Hildenbrand, 2024/09/10
[PATCH v1 04/14] s390x: rename s390-virtio-hcall* to s390-hypercall*, David Hildenbrand, 2024/09/10
[PATCH v1 06/14] s390x: introduce s390_get_memory_limit(),
David Hildenbrand <=
[PATCH v1 07/14] s390x/s390-hypercall: introduce DIAG500 STORAGE_LIMIT, David Hildenbrand, 2024/09/10