[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 07/14] s390x/s390-hypercall: introduce DIAG500 STORAGE_LIMIT
From: |
David Hildenbrand |
Subject: |
[PATCH v2 07/14] s390x/s390-hypercall: introduce DIAG500 STORAGE_LIMIT |
Date: |
Tue, 8 Oct 2024 12:54:48 +0200 |
A guest OS that supports memory hotplug / memory devices must during
boot be aware of the maximum possible physical memory address that it might
have to handle at a later stage during its runtime.
For example, the maximum possible memory address might be required to
prepare the kernel virtual address space accordingly (e.g., select page
table hierarchy depth).
On s390x there is currently no such mechanism that is compatible with
paravirtualized memory devices, because the whole SCLP interface was
designed around the idea of "storage increments" and "standby memory".
Paravirtualized memory devices we want to support, such as virtio-mem, have
no intersection with any of that, but could co-exist with them in the
future if ever needed.
In particular, a guest OS must never detect and use device memory
without the help of a proper device driver. Device memory must not be
exposed in any firmware-provided memory map (SCLP or diag260 on s390x).
For this reason, these memory devices will be places in memory *above*
the "maximum storage increment" exposed via SCLP.
Let's provide a new diag500 subcode to query the memory limit determined in
s390_memory_init().
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: David Hildenbrand <david@redhat.com>
---
hw/s390x/s390-hypercall.c | 12 +++++++++++-
hw/s390x/s390-hypercall.h | 1 +
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/hw/s390x/s390-hypercall.c b/hw/s390x/s390-hypercall.c
index f816c2b1ef..ac1b08b2cd 100644
--- a/hw/s390x/s390-hypercall.c
+++ b/hw/s390x/s390-hypercall.c
@@ -11,7 +11,7 @@
#include "qemu/osdep.h"
#include "cpu.h"
-#include "hw/boards.h"
+#include "hw/s390x/s390-virtio-ccw.h"
#include "hw/s390x/s390-hypercall.h"
#include "hw/s390x/ioinst.h"
#include "hw/s390x/css.h"
@@ -57,6 +57,13 @@ static int handle_virtio_ccw_notify(uint64_t subch_id,
uint64_t data)
return 0;
}
+static uint64_t handle_storage_limit(void)
+{
+ S390CcwMachineState *s390ms = S390_CCW_MACHINE(qdev_get_machine());
+
+ return s390_get_memory_limit(s390ms) - 1;
+}
+
void handle_diag_500(S390CPU *cpu, uintptr_t ra)
{
CPUS390XState *env = &cpu->env;
@@ -69,6 +76,9 @@ void handle_diag_500(S390CPU *cpu, uintptr_t ra)
case DIAG500_VIRTIO_CCW_NOTIFY:
env->regs[2] = handle_virtio_ccw_notify(env->regs[2], env->regs[3]);
break;
+ case DIAG500_STORAGE_LIMIT:
+ env->regs[2] = handle_storage_limit();
+ break;
default:
s390_program_interrupt(env, PGM_SPECIFICATION, ra);
}
diff --git a/hw/s390x/s390-hypercall.h b/hw/s390x/s390-hypercall.h
index 2fa81dbfdd..4f07209128 100644
--- a/hw/s390x/s390-hypercall.h
+++ b/hw/s390x/s390-hypercall.h
@@ -18,6 +18,7 @@
#define DIAG500_VIRTIO_RESET 1 /* legacy */
#define DIAG500_VIRTIO_SET_STATUS 2 /* legacy */
#define DIAG500_VIRTIO_CCW_NOTIFY 3 /* KVM_S390_VIRTIO_CCW_NOTIFY */
+#define DIAG500_STORAGE_LIMIT 4
void handle_diag_500(S390CPU *cpu, uintptr_t ra);
--
2.46.1
- [PATCH v2 01/14] s390x/s390-virtio-ccw: don't crash on weird RAM sizes, (continued)
- [PATCH v2 01/14] s390x/s390-virtio-ccw: don't crash on weird RAM sizes, David Hildenbrand, 2024/10/08
- [PATCH v2 02/14] s390x/s390-virtio-hcall: remove hypercall registration mechanism, David Hildenbrand, 2024/10/08
- [PATCH v2 03/14] s390x/s390-virtio-hcall: prepare for more diag500 hypercalls, David Hildenbrand, 2024/10/08
- [PATCH v2 04/14] s390x: rename s390-virtio-hcall* to s390-hypercall*, David Hildenbrand, 2024/10/08
- [PATCH v2 05/14] s390x/s390-virtio-ccw: move setting the maximum guest size from sclp to machine code, David Hildenbrand, 2024/10/08
- [PATCH v2 06/14] s390x: introduce s390_get_memory_limit(), David Hildenbrand, 2024/10/08
- [PATCH v2 08/14] s390x/s390-stattrib-kvm: prepare for memory devices and sparse memory layouts, David Hildenbrand, 2024/10/08
- [PATCH v2 10/14] s390x/s390-virtio-ccw: prepare for memory devices, David Hildenbrand, 2024/10/08
- [PATCH v2 11/14] s390x/pv: prepare for memory devices, David Hildenbrand, 2024/10/08
- [PATCH v2 09/14] s390x/s390-skeys: prepare for memory devices, David Hildenbrand, 2024/10/08
- [PATCH v2 07/14] s390x/s390-hypercall: introduce DIAG500 STORAGE_LIMIT,
David Hildenbrand <=
- [PATCH v2 12/14] s390x: remember the maximum page size, David Hildenbrand, 2024/10/08
- [PATCH v2 14/14] s390x: virtio-mem support, David Hildenbrand, 2024/10/08
- [PATCH v2 13/14] s390x/virtio-ccw: add support for virtio based memory devices, David Hildenbrand, 2024/10/08
- Re: [PATCH v2 00/14] s390x: virtio-mem support, Mario Casquero, 2024/10/10