[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH RFCv3 3/9] s390x: remove hypercall registration mechanism
From: |
David Hildenbrand |
Subject: |
[PATCH RFCv3 3/9] s390x: remove hypercall registration mechanism |
Date: |
Fri, 24 Jul 2020 16:37:44 +0200 |
Nowadays, we only have a single machine type in QEMU, everything is based
on virtio-ccw and the traditional virtio machine does no longer exist. No
need to dynamically register diag500 handlers. Move the two existing
handlers into diag500.c.
Signed-off-by: David Hildenbrand <david@redhat.com>
---
hw/s390x/s390-virtio-ccw.c | 46 -----------------------------
hw/s390x/s390-virtio-hcall.c | 56 ++++++++++++++++++++++++------------
hw/s390x/s390-virtio-hcall.h | 2 --
3 files changed, 38 insertions(+), 66 deletions(-)
diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
index dca8e43001..b481e5e5bd 100644
--- a/hw/s390x/s390-virtio-ccw.c
+++ b/hw/s390x/s390-virtio-ccw.c
@@ -17,7 +17,6 @@
#include "hw/boards.h"
#include "exec/address-spaces.h"
#include "exec/ram_addr.h"
-#include "hw/s390x/s390-virtio-hcall.h"
#include "hw/s390x/sclp.h"
#include "hw/s390x/s390_flic.h"
#include "hw/s390x/ioinst.h"
@@ -116,48 +115,6 @@ static void subsystem_reset(void)
}
}
-static int virtio_ccw_hcall_notify(const uint64_t *args)
-{
- uint64_t subch_id = args[0];
- uint64_t queue = args[1];
- SubchDev *sch;
- int cssid, ssid, schid, m;
-
- if (ioinst_disassemble_sch_ident(subch_id, &m, &cssid, &ssid, &schid)) {
- return -EINVAL;
- }
- sch = css_find_subch(m, cssid, ssid, schid);
- if (!sch || !css_subch_visible(sch)) {
- return -EINVAL;
- }
- if (queue >= VIRTIO_QUEUE_MAX) {
- return -EINVAL;
- }
- virtio_queue_notify(virtio_ccw_get_vdev(sch), queue);
- return 0;
-
-}
-
-static int virtio_ccw_hcall_early_printk(const uint64_t *args)
-{
- uint64_t mem = args[0];
-
- if (mem < ram_size) {
- /* Early printk */
- return 0;
- }
- return -EINVAL;
-}
-
-static void virtio_ccw_register_hcalls(void)
-{
- s390_register_virtio_hypercall(KVM_S390_VIRTIO_CCW_NOTIFY,
- virtio_ccw_hcall_notify);
- /* Tolerate early printk. */
- s390_register_virtio_hypercall(KVM_S390_VIRTIO_NOTIFY,
- virtio_ccw_hcall_early_printk);
-}
-
static void s390_memory_init(MachineState *machine)
{
MemoryRegion *sysmem = get_system_memory();
@@ -284,9 +241,6 @@ static void ccw_init(MachineState *machine)
OBJECT(dev));
sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
- /* register hypercalls */
- virtio_ccw_register_hcalls();
-
s390_enable_css_support(s390_cpu_addr2state(0));
ret = css_create_css_image(VIRTUAL_CSSID, true);
diff --git a/hw/s390x/s390-virtio-hcall.c b/hw/s390x/s390-virtio-hcall.c
index ec7cf8beb3..5e14bd49b7 100644
--- a/hw/s390x/s390-virtio-hcall.c
+++ b/hw/s390x/s390-virtio-hcall.c
@@ -12,30 +12,50 @@
#include "qemu/osdep.h"
#include "cpu.h"
#include "hw/s390x/s390-virtio-hcall.h"
+#include "hw/s390x/ioinst.h"
+#include "hw/s390x/css.h"
+#include "virtio-ccw.h"
-#define MAX_DIAG_SUBCODES 255
-
-static s390_virtio_fn s390_diag500_table[MAX_DIAG_SUBCODES];
-
-void s390_register_virtio_hypercall(uint64_t code, s390_virtio_fn fn)
+static int handle_virtio_notify(uint64_t mem)
{
- assert(code < MAX_DIAG_SUBCODES);
- assert(!s390_diag500_table[code]);
-
- s390_diag500_table[code] = fn;
+ if (mem < ram_size) {
+ /* Tolerate early printk. */
+ return 0;
+ }
+ return -EINVAL;
}
-int s390_virtio_hypercall(CPUS390XState *env)
+static int handle_virtio_ccw_notify(uint64_t subch_id, uint64_t queue)
{
- s390_virtio_fn fn;
+ SubchDev *sch;
+ int cssid, ssid, schid, m;
- if (env->regs[1] < MAX_DIAG_SUBCODES) {
- fn = s390_diag500_table[env->regs[1]];
- if (fn) {
- env->regs[2] = fn(&env->regs[2]);
- return 0;
- }
+ if (ioinst_disassemble_sch_ident(subch_id, &m, &cssid, &ssid, &schid)) {
+ return -EINVAL;
}
+ sch = css_find_subch(m, cssid, ssid, schid);
+ if (!sch || !css_subch_visible(sch)) {
+ return -EINVAL;
+ }
+ if (queue >= VIRTIO_QUEUE_MAX) {
+ return -EINVAL;
+ }
+ virtio_queue_notify(virtio_ccw_get_vdev(sch), queue);
+ return 0;
+}
- return -EINVAL;
+int s390_virtio_hypercall(CPUS390XState *env)
+{
+ const uint64_t subcode = env->regs[1];
+
+ switch (subcode) {
+ case KVM_S390_VIRTIO_NOTIFY:
+ env->regs[2] = handle_virtio_notify(env->regs[2]);
+ return 0;
+ case KVM_S390_VIRTIO_CCW_NOTIFY:
+ env->regs[2] = handle_virtio_ccw_notify(env->regs[2], env->regs[3]);
+ return 0;
+ default:
+ return -EINVAL;
+ }
}
diff --git a/hw/s390x/s390-virtio-hcall.h b/hw/s390x/s390-virtio-hcall.h
index 9800c4b351..67e11ea39a 100644
--- a/hw/s390x/s390-virtio-hcall.h
+++ b/hw/s390x/s390-virtio-hcall.h
@@ -17,7 +17,5 @@
/* The only thing that we need from the old kvm_virtio.h file */
#define KVM_S390_VIRTIO_NOTIFY 0
-typedef int (*s390_virtio_fn)(const uint64_t *args);
-void s390_register_virtio_hypercall(uint64_t code, s390_virtio_fn fn);
int s390_virtio_hypercall(CPUS390XState *env);
#endif /* HW_S390_VIRTIO_HCALL_H */
--
2.26.2
- Re: [PATCH RFCv3 6/9] s390x/diag: subcode to query device memory region, (continued)
- Re: [PATCH RFCv3 6/9] s390x/diag: subcode to query device memory region, David Hildenbrand, 2020/07/27
- Re: [PATCH RFCv3 6/9] s390x/diag: subcode to query device memory region, Cornelia Huck, 2020/07/27
- Re: [PATCH RFCv3 6/9] s390x/diag: subcode to query device memory region, David Hildenbrand, 2020/07/27
- Re: [PATCH RFCv3 6/9] s390x/diag: subcode to query device memory region, Heiko Carstens, 2020/07/27
- Re: [PATCH RFCv3 6/9] s390x/diag: subcode to query device memory region, David Hildenbrand, 2020/07/27
- Re: [PATCH RFCv3 6/9] s390x/diag: subcode to query device memory region, Cornelia Huck, 2020/07/28
- Re: [PATCH RFCv3 6/9] s390x/diag: subcode to query device memory region, David Hildenbrand, 2020/07/29
- Re: [PATCH RFCv3 6/9] s390x/diag: subcode to query device memory region, Cornelia Huck, 2020/07/29
- Re: [PATCH RFCv3 6/9] s390x/diag: subcode to query device memory region, David Hildenbrand, 2020/07/29
- Re: [PATCH RFCv3 6/9] s390x/diag: subcode to query device memory region, Cornelia Huck, 2020/07/29
[PATCH RFCv3 3/9] s390x: remove hypercall registration mechanism,
David Hildenbrand <=
[PATCH RFCv3 9/9] s390x: initial support for virtio-mem, David Hildenbrand, 2020/07/24
[PATCH RFCv3 8/9] s390x: implement virtio-mem-ccw, David Hildenbrand, 2020/07/24