100 lines
3.7 KiB
Diff
100 lines
3.7 KiB
Diff
From 86417a068f24964422d4fd5ea301d70a0f8142d2 Mon Sep 17 00:00:00 2001
|
|
From: David Hildenbrand <david@redhat.com>
|
|
Date: Thu, 19 Dec 2024 15:41:08 +0100
|
|
Subject: [PATCH 16/26] s390x/s390-hypercall: introduce DIAG500 STORAGE_LIMIT
|
|
|
|
RH-Author: Thomas Huth <thuth@redhat.com>
|
|
RH-MergeRequest: 351: Enable virtio-mem support on s390x
|
|
RH-Jira: RHEL-72977
|
|
RH-Acked-by: David Hildenbrand <david@redhat.com>
|
|
RH-Acked-by: Juraj Marcin <None>
|
|
RH-Commit: [16/26] c1c341227388735450ddbba0201e7523e0658c07 (thuth/qemu-kvm-cs)
|
|
|
|
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().
|
|
|
|
Message-ID: <20241219144115.2820241-8-david@redhat.com>
|
|
Acked-by: Michael S. Tsirkin <mst@redhat.com>
|
|
Reviewed-by: Thomas Huth <thuth@redhat.com>
|
|
Signed-off-by: David Hildenbrand <david@redhat.com>
|
|
(cherry picked from commit f7c168657816486527727d860b73747d41f0c5f6)
|
|
Signed-off-by: Thomas Huth <thuth@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.48.1
|
|
|