From: Mete Durlu <meted@linux.ibm.com>
To: Heiko Carstens <hca@linux.ibm.com>,
Vasily Gorbik <gor@linux.ibm.com>,
Alexander Gordeev <agordeev@linux.ibm.com>,
Christian Borntraeger <borntraeger@linux.ibm.com>,
Sven Schnelle <svens@linux.ibm.com>,
Sumanth Korikkar <sumanthk@linux.ibm.com>
Cc: linux-s390@vger.kernel.org, Mete Durlu <meted@linux.ibm.com>
Subject: [PATCH 3/3] s390/diag: Add diag204 IOCTL to diag misc device
Date: Wed, 21 Oct 2026 12:28:10 +0200 [thread overview]
Message-ID: <20261021-diag204ioctl-v1-3-25645b97bf4e@linux.ibm.com> (raw)
In-Reply-To: <20261021-diag204ioctl-v1-0-25645b97bf4e@linux.ibm.com>
Add IOCTL implementation necessary to fetch diag204 data from the new
diag misc device under /dev.
Signed-off-by: Mete Durlu <meted@linux.ibm.com>
---
arch/s390/include/uapi/asm/diag.h | 8 +++++++
arch/s390/kernel/diag/diag204.c | 43 ++++++++++++++++++++++++++++++++++++++
arch/s390/kernel/diag/diag_ioctl.h | 3 +++
arch/s390/kernel/diag/diag_misc.c | 10 +++++++++
4 files changed, 64 insertions(+)
diff --git a/arch/s390/include/uapi/asm/diag.h b/arch/s390/include/uapi/asm/diag.h
index b7e6ccb4ff6e..985667b2917a 100644
--- a/arch/s390/include/uapi/asm/diag.h
+++ b/arch/s390/include/uapi/asm/diag.h
@@ -22,11 +22,19 @@ struct diag310_memtop {
__u64 nesting_lvl;
};
+struct diag204_request {
+ __u64 address;
+ int allow_busy;
+ int allow_busy_wait;
+};
+
/* Diag ioctl definitions */
#define DIAG324_GET_PIBBUF _IOWR(DIAG_MAGIC_STR, 0x77, struct diag324_pib)
#define DIAG324_GET_PIBLEN _IOR(DIAG_MAGIC_STR, 0x78, size_t)
#define DIAG310_GET_STRIDE _IOR(DIAG_MAGIC_STR, 0x79, size_t)
#define DIAG310_GET_MEMTOPLEN _IOWR(DIAG_MAGIC_STR, 0x7a, size_t)
#define DIAG310_GET_MEMTOPBUF _IOWR(DIAG_MAGIC_STR, 0x7b, struct diag310_memtop)
+#define DIAG204_GET_LEN _IOR(DIAG_MAGIC_STR, 0x7c, size_t)
+#define DIAG204_GET_BUF _IOWR(DIAG_MAGIC_STR, 0x7d, struct diag204_request)
#endif /* __S390_UAPI_ASM_DIAG_H */
diff --git a/arch/s390/kernel/diag/diag204.c b/arch/s390/kernel/diag/diag204.c
index 8e1909e6caf9..967b6e0bc667 100644
--- a/arch/s390/kernel/diag/diag204.c
+++ b/arch/s390/kernel/diag/diag204.c
@@ -14,6 +14,8 @@
#include <linux/vmalloc.h>
#include <asm/diag.h>
+#include <uapi/asm/diag.h>
+#include "diag_ioctl.h"
struct diag204_info {
int pages; /* number of pages for diag204 data */
@@ -268,6 +270,47 @@ int diag204_store(void *buf, int allow_busy, int allow_busy_wait)
return rc;
}
+long diag204_len(unsigned long arg)
+{
+ if (!diag204_is_available())
+ return -EOPNOTSUPP;
+ if (put_user(diag204_get_buf_size(), (size_t __user *)arg))
+ return -EFAULT;
+ return 0;
+}
+
+long diag204_buf(unsigned long arg)
+{
+ struct diag204_request __user *udata;
+ int rc, allow_busy, allow_busy_wait;
+ u64 address;
+ void *buf;
+
+ if (!diag204_is_available())
+ return -EOPNOTSUPP;
+ udata = (struct diag204_request __user *)arg;
+ if (get_user(address, &udata->address))
+ return -EFAULT;
+ if (get_user(allow_busy, &udata->allow_busy))
+ return -EFAULT;
+ if (get_user(allow_busy_wait, &udata->allow_busy_wait))
+ return -EFAULT;
+ buf = diag204_allocate_buffer();
+ if (!buf)
+ return -ENOMEM;
+ rc = diag204_store(buf, allow_busy, allow_busy_wait);
+ if (rc < 0) {
+ diag204_free_buffer(buf);
+ return rc;
+ }
+ rc = copy_to_user((void __user *)address, buf,
+ diag204_get_buf_size());
+ if (rc < 0)
+ rc = -EFAULT;
+ diag204_free_buffer(buf);
+ return rc;
+}
+
/*
* diag204_probe() has to find out, which type of diagnose 204 implementation
* we have on our machine. Currently there are three possible scanarios:
diff --git a/arch/s390/kernel/diag/diag_ioctl.h b/arch/s390/kernel/diag/diag_ioctl.h
index 7080be946785..7718b57ffe3e 100644
--- a/arch/s390/kernel/diag/diag_ioctl.h
+++ b/arch/s390/kernel/diag/diag_ioctl.h
@@ -4,6 +4,9 @@
#include <linux/types.h>
+long diag204_len(unsigned long arg);
+long diag204_buf(unsigned long arg);
+
long diag324_pibbuf(unsigned long arg);
long diag324_piblen(unsigned long arg);
diff --git a/arch/s390/kernel/diag/diag_misc.c b/arch/s390/kernel/diag/diag_misc.c
index efffe02ea02e..ac263baf8d08 100644
--- a/arch/s390/kernel/diag/diag_misc.c
+++ b/arch/s390/kernel/diag/diag_misc.c
@@ -35,6 +35,16 @@ static long diag_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
case DIAG310_GET_MEMTOPBUF:
rc = diag310_memtop_buf(arg);
break;
+ case DIAG204_GET_LEN:
+ rc = -EPERM;
+ if (capable(CAP_SYS_ADMIN))
+ rc = diag204_len(arg);
+ break;
+ case DIAG204_GET_BUF:
+ rc = -EPERM;
+ if (capable(CAP_SYS_ADMIN))
+ rc = diag204_buf(arg);
+ break;
default:
rc = -ENOIOCTLCMD;
break;
--
2.56.0
next prev parent reply other threads:[~2026-10-21 10:28 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-21 10:28 [PATCH 0/3] s390: Diag204 Rework Mete Durlu
2026-10-21 10:28 ` [PATCH 1/3] s390/diag204: Introduce diag204 rework Mete Durlu
2026-10-21 10:52 ` sashiko-bot
2026-10-21 10:28 ` [PATCH 2/3] s390/diag204: Replace diag204 users with new implementation Mete Durlu
2026-10-21 11:09 ` sashiko-bot
2026-10-21 10:28 ` Mete Durlu [this message]
2026-10-21 11:13 ` [PATCH 3/3] s390/diag: Add diag204 IOCTL to diag misc device sashiko-bot
2026-10-21 14:01 ` Hendrik Brueckner
2026-10-21 14:12 ` Mete Durlu
2026-10-22 7:04 ` [PATCH 0/3] s390: Diag204 Rework Mete Durlu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261021-diag204ioctl-v1-3-25645b97bf4e@linux.ibm.com \
--to=meted@linux.ibm.com \
--cc=agordeev@linux.ibm.com \
--cc=borntraeger@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=linux-s390@vger.kernel.org \
--cc=sumanthk@linux.ibm.com \
--cc=svens@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox