* [PATCH 1/4] trinity: Add support for runtime_instr svc
@ 2018-02-13 7:55 Thomas Richter
2018-02-13 7:55 ` [PATCH 2/4] trinity: Add support for s390_pci_mmio_read and write Thomas Richter
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Thomas Richter @ 2018-02-13 7:55 UTC (permalink / raw)
To: trinity, davej; +Cc: brueckner, schwidefsky, heiko.carstens, Thomas Richter
This patch adds support for the s390 specific system
call runtime_instr() for 31 and 64 bit.
Signed-off-by: Thomas Richter <tmricht@linux.vnet.ibm.com>
---
Makefile | 1 +
include/syscalls-s390.h | 2 +-
include/syscalls-s390x.h | 2 +-
syscalls/s390x/runtime_instr.c | 25 +++++++++++++++++++++++++
syscalls/syscalls.h | 1 +
5 files changed, 29 insertions(+), 2 deletions(-)
create mode 100644 syscalls/s390x/runtime_instr.c
diff --git a/Makefile b/Makefile
index 78619064..93e3460d 100644
--- a/Makefile
+++ b/Makefile
@@ -87,6 +87,7 @@ SYSCALLS_ARCH := $(shell case "$(MACHINE)" in \
syscalls/x86/x86_64/*.c;; \
(i?86*) echo syscalls/x86/*.c \
syscalls/x86/i386/*.c;; \
+ (s390x*) echo syscalls/s390x/*.c ;; \
esac)
VERSION_H := include/version.h
diff --git a/include/syscalls-s390.h b/include/syscalls-s390.h
index 682d2030..c02ced94 100644
--- a/include/syscalls-s390.h
+++ b/include/syscalls-s390.h
@@ -349,7 +349,7 @@ struct syscalltable syscalls_s390[] = {
{ .entry = &syscall_setns },
{ .entry = &syscall_process_vm_readv },
{ .entry = &syscall_process_vm_writev },
- { .entry = &syscall_ni_syscall }, /* TODO: s390_runtime_instr */
+ { .entry = &syscall_runtime_instr }, /* s390_runtime_instr svc */
{ .entry = &syscall_kcmp },
{ .entry = &syscall_finit_module },
{ .entry = &syscall_sched_setattr },
diff --git a/include/syscalls-s390x.h b/include/syscalls-s390x.h
index a3e26181..b955ceaa 100644
--- a/include/syscalls-s390x.h
+++ b/include/syscalls-s390x.h
@@ -349,7 +349,7 @@ struct syscalltable syscalls_s390x[] = {
{ .entry = &syscall_setns },
{ .entry = &syscall_process_vm_readv },
{ .entry = &syscall_process_vm_writev },
- { .entry = &syscall_ni_syscall }, /* TODO: s390_runtime_instr */
+ { .entry = &syscall_runtime_instr }, /* s390_runtime_instr svc */
{ .entry = &syscall_kcmp },
{ .entry = &syscall_finit_module },
{ .entry = &syscall_sched_setattr },
diff --git a/syscalls/s390x/runtime_instr.c b/syscalls/s390x/runtime_instr.c
new file mode 100644
index 00000000..aa1f75fb
--- /dev/null
+++ b/syscalls/s390x/runtime_instr.c
@@ -0,0 +1,25 @@
+/*
+ * int runtime_instr(int on_off, int sig_nr)
+ */
+
+#include "sanitise.h"
+
+#define S390_RUNTIME_INSTR_START 0x1
+#define S390_RUNTIME_INSTR_STOP 0x2
+
+static unsigned long syscall_runtime_instr_arg1[] = {
+ 0, S390_RUNTIME_INSTR_START, S390_RUNTIME_INSTR_STOP, 3
+};
+
+struct syscallentry syscall_runtime_instr = {
+ .name = "runtime_instr",
+ .num_args = 2,
+ .arg1name = "on_off",
+ .arg1type = ARG_LIST,
+ .arg1list = ARGLIST(syscall_runtime_instr_arg1),
+ .arg2name = "sig_nr",
+ .arg2type = ARG_RANGE,
+ .low2range = 0,
+ .hi2range = 128,
+ .rettype = RET_ZERO_SUCCESS
+};
diff --git a/syscalls/syscalls.h b/syscalls/syscalls.h
index 38819b37..2260bbf8 100644
--- a/syscalls/syscalls.h
+++ b/syscalls/syscalls.h
@@ -386,5 +386,6 @@ extern struct syscallentry syscall_pkey_mprotect;
extern struct syscallentry syscall_pkey_alloc;
extern struct syscallentry syscall_pkey_free;
extern struct syscallentry syscall_statx;
+extern struct syscallentry syscall_runtime_instr;
unsigned int random_fcntl_setfl_flags(void);
--
2.14.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/4] trinity: Add support for s390_pci_mmio_read and write
2018-02-13 7:55 [PATCH 1/4] trinity: Add support for runtime_instr svc Thomas Richter
@ 2018-02-13 7:55 ` Thomas Richter
2018-02-13 7:55 ` [PATCH 3/4] trinity: Add support for s390_guarded_storage svc Thomas Richter
2018-02-13 7:55 ` [PATCH 4/4] trinity: Add support for s390_sthyi svc Thomas Richter
2 siblings, 0 replies; 4+ messages in thread
From: Thomas Richter @ 2018-02-13 7:55 UTC (permalink / raw)
To: trinity, davej; +Cc: brueckner, schwidefsky, heiko.carstens, Thomas Richter
Add support for s390 specific system calls
s390_pci_mmio_read and 390_pci_mmio_write
for 31 bit and 64 bit.
Signed-off-by: Thomas Richter <tmricht@linux.vnet.ibm.com>
---
include/syscalls-s390.h | 4 +--
include/syscalls-s390x.h | 4 +--
syscalls/s390x/s390_pci_mmio.c | 70 ++++++++++++++++++++++++++++++++++++++++++
syscalls/syscalls.h | 2 ++
4 files changed, 76 insertions(+), 4 deletions(-)
create mode 100644 syscalls/s390x/s390_pci_mmio.c
diff --git a/include/syscalls-s390.h b/include/syscalls-s390.h
index c02ced94..a5a30c9e 100644
--- a/include/syscalls-s390.h
+++ b/include/syscalls-s390.h
@@ -363,8 +363,8 @@ struct syscalltable syscalls_s390[] = {
#else
{ .entry = NULL },
#endif
- { .entry = &syscall_ni_syscall }, /* TODO: s390_pci_mmio_write svc */
- { .entry = &syscall_ni_syscall }, /* TODO: s390_pci_mmio_read svc */
+ { .entry = &syscall_s390_pci_mmio_write },
+ { .entry = &syscall_s390_pci_mmio_read },
{ .entry = &syscall_execveat },
{ .entry = &syscall_userfaultfd },
{ .entry = &syscall_membarrier },
diff --git a/include/syscalls-s390x.h b/include/syscalls-s390x.h
index b955ceaa..e74caa14 100644
--- a/include/syscalls-s390x.h
+++ b/include/syscalls-s390x.h
@@ -363,8 +363,8 @@ struct syscalltable syscalls_s390x[] = {
#else
{ .entry = NULL },
#endif
- { .entry = &syscall_ni_syscall }, /* TODO: s390_pci_mmio_write svc */
- { .entry = &syscall_ni_syscall }, /* TODO: s390_pci_mmio_read svc */
+ { .entry = &syscall_s390_pci_mmio_write },
+ { .entry = &syscall_s390_pci_mmio_read },
{ .entry = &syscall_execveat },
{ .entry = &syscall_userfaultfd },
{ .entry = &syscall_membarrier },
diff --git a/syscalls/s390x/s390_pci_mmio.c b/syscalls/s390x/s390_pci_mmio.c
new file mode 100644
index 00000000..62566ce4
--- /dev/null
+++ b/syscalls/s390x/s390_pci_mmio.c
@@ -0,0 +1,70 @@
+/*
+ * int s390_pci_mmio_read(unsigned long mmio_addr,
+ * void *user_buffer, size_t length);
+ * int s390_pci_mmio_write(unsigned long mmio_addr,
+ * void *user_buffer, size_t length);
+ */
+
+#include "arch.h"
+#include "random.h"
+#include "sanitise.h"
+
+/*
+ * Allocate buffer which fits the svc requirements:
+ * - length must be lower or equal to page size.
+ * - transfer must no cross page boundary.
+ */
+static void sanitise_s390_pci_mmio(struct syscallrecord *rec)
+{
+ size_t offset = rec->a1 % page_size;
+
+ if (offset + rec->a3 > page_size)
+ rec->a3 = page_size - offset;
+ rec->a2 = (unsigned long)malloc(rec->a3);
+}
+
+/* Allocate buffer and generate random data. */
+static void sanitise_s390_pci_mmio_write(struct syscallrecord *rec)
+{
+ sanitise_s390_pci_mmio(rec);
+ if (rec->a2) /* Buffer allocated */
+ generate_rand_bytes((void *)rec->a2, rec->a3);
+}
+
+/* Free buffer, freeptr takes care of NULL */
+static void post_s390_pci_mmio(struct syscallrecord *rec)
+{
+ freeptr(&rec->a2);
+}
+
+struct syscallentry syscall_s390_pci_mmio_read = {
+ .name = "s390_pci_mmio_read",
+ .sanitise = sanitise_s390_pci_mmio,
+ .post = post_s390_pci_mmio,
+ .num_args = 3,
+ .arg1name = "mmio_addr",
+ .arg1type = ARG_UNDEFINED,
+ .arg2name = "user_buffer",
+ .arg2type = ARG_NON_NULL_ADDRESS,
+ .arg3name = "length",
+ .arg3type = ARG_RANGE,
+ .low3range = 0,
+ .hi3range = 1 << PAGE_SHIFT,
+ .rettype = RET_ZERO_SUCCESS
+};
+
+struct syscallentry syscall_s390_pci_mmio_write = {
+ .name = "s390_pci_mmio_write",
+ .sanitise = sanitise_s390_pci_mmio_write,
+ .post = post_s390_pci_mmio,
+ .num_args = 3,
+ .arg1name = "mmio_addr",
+ .arg1type = ARG_UNDEFINED,
+ .arg2name = "user_buffer",
+ .arg2type = ARG_NON_NULL_ADDRESS,
+ .arg3name = "length",
+ .arg3type = ARG_RANGE,
+ .low3range = 0,
+ .hi3range = 1 << PAGE_SHIFT,
+ .rettype = RET_ZERO_SUCCESS
+};
diff --git a/syscalls/syscalls.h b/syscalls/syscalls.h
index 2260bbf8..6564e22e 100644
--- a/syscalls/syscalls.h
+++ b/syscalls/syscalls.h
@@ -387,5 +387,7 @@ extern struct syscallentry syscall_pkey_alloc;
extern struct syscallentry syscall_pkey_free;
extern struct syscallentry syscall_statx;
extern struct syscallentry syscall_runtime_instr;
+extern struct syscallentry syscall_s390_pci_mmio_write;
+extern struct syscallentry syscall_s390_pci_mmio_read;
unsigned int random_fcntl_setfl_flags(void);
--
2.14.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 3/4] trinity: Add support for s390_guarded_storage svc
2018-02-13 7:55 [PATCH 1/4] trinity: Add support for runtime_instr svc Thomas Richter
2018-02-13 7:55 ` [PATCH 2/4] trinity: Add support for s390_pci_mmio_read and write Thomas Richter
@ 2018-02-13 7:55 ` Thomas Richter
2018-02-13 7:55 ` [PATCH 4/4] trinity: Add support for s390_sthyi svc Thomas Richter
2 siblings, 0 replies; 4+ messages in thread
From: Thomas Richter @ 2018-02-13 7:55 UTC (permalink / raw)
To: trinity, davej; +Cc: brueckner, schwidefsky, heiko.carstens, Thomas Richter
Add support for s390 specific system call s390_guarded_storage
for 31 bit and 64 bit.
Signed-off-by: Thomas Richter <tmricht@linux.vnet.ibm.com>
---
include/syscalls-s390.h | 2 +-
include/syscalls-s390x.h | 2 +-
syscalls/s390x/s390_guarded_storage.c | 48 +++++++++++++++++++++++++++++++++++
syscalls/syscalls.h | 1 +
4 files changed, 51 insertions(+), 2 deletions(-)
create mode 100644 syscalls/s390x/s390_guarded_storage.c
diff --git a/include/syscalls-s390.h b/include/syscalls-s390.h
index a5a30c9e..ad2f88c6 100644
--- a/include/syscalls-s390.h
+++ b/include/syscalls-s390.h
@@ -389,7 +389,7 @@ struct syscalltable syscalls_s390[] = {
{ .entry = &syscall_copy_file_range },
{ .entry = &syscall_preadv2 },
{ .entry = &syscall_pwritev2 },
- { .entry = &syscall_ni_syscall }, /* TODO: s390_guarded_storage svc */
+ { .entry = &syscall_s390_guarded_storage },
{ .entry = &syscall_statx },
{ .entry = &syscall_ni_syscall }, /* TODO: s390_sthyi svc */
};
diff --git a/include/syscalls-s390x.h b/include/syscalls-s390x.h
index e74caa14..a83974e4 100644
--- a/include/syscalls-s390x.h
+++ b/include/syscalls-s390x.h
@@ -389,7 +389,7 @@ struct syscalltable syscalls_s390x[] = {
{ .entry = &syscall_copy_file_range },
{ .entry = &syscall_preadv2 },
{ .entry = &syscall_pwritev2 },
- { .entry = &syscall_ni_syscall }, /* TODO: s390_guarded_storage svc */
+ { .entry = &syscall_s390_guarded_storage },
{ .entry = &syscall_statx },
{ .entry = &syscall_ni_syscall }, /* TODO: s390_sthyi svc */
};
diff --git a/syscalls/s390x/s390_guarded_storage.c b/syscalls/s390x/s390_guarded_storage.c
new file mode 100644
index 00000000..290fe626
--- /dev/null
+++ b/syscalls/s390x/s390_guarded_storage.c
@@ -0,0 +1,48 @@
+/*
+ * int s390_guarded_storage(int command, struct gs_cb *gs_cb)
+ */
+
+#include <asm/guarded_storage.h>
+
+#include "random.h"
+#include "sanitise.h"
+
+static unsigned long syscall_s390_guarded_storage_arg1[] = {
+ GS_ENABLE,
+ GS_DISABLE,
+ GS_SET_BC_CB,
+ GS_CLEAR_BC_CB,
+ GS_BROADCAST,
+ GS_BROADCAST + 1,
+ -1
+};
+
+/* Allocate buffer and generate random data. */
+static void sanitise_s390_gs(struct syscallrecord *rec)
+{
+ size_t size = sizeof(struct gs_cb);
+ void *addr = malloc(size);
+
+ if (addr) {
+ generate_rand_bytes(addr, size);
+ rec->a2 = (unsigned long)addr;
+ }
+}
+
+/* Free buffer, freeptr takes care of NULL */
+static void post_s390_gs(struct syscallrecord *rec)
+{
+ freeptr(&rec->a2);
+}
+
+struct syscallentry syscall_s390_guarded_storage = {
+ .name = "s390_guarded_storage",
+ .sanitise = sanitise_s390_gs,
+ .post = post_s390_gs,
+ .num_args = 2,
+ .arg1name = "command",
+ .arg1type = ARG_LIST,
+ .arg1list = ARGLIST(syscall_s390_guarded_storage_arg1),
+ .arg2name = "gs_cb",
+ .arg2type = ARG_NON_NULL_ADDRESS
+};
diff --git a/syscalls/syscalls.h b/syscalls/syscalls.h
index 6564e22e..38271170 100644
--- a/syscalls/syscalls.h
+++ b/syscalls/syscalls.h
@@ -389,5 +389,6 @@ extern struct syscallentry syscall_statx;
extern struct syscallentry syscall_runtime_instr;
extern struct syscallentry syscall_s390_pci_mmio_write;
extern struct syscallentry syscall_s390_pci_mmio_read;
+extern struct syscallentry syscall_s390_guarded_storage;
unsigned int random_fcntl_setfl_flags(void);
--
2.14.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 4/4] trinity: Add support for s390_sthyi svc
2018-02-13 7:55 [PATCH 1/4] trinity: Add support for runtime_instr svc Thomas Richter
2018-02-13 7:55 ` [PATCH 2/4] trinity: Add support for s390_pci_mmio_read and write Thomas Richter
2018-02-13 7:55 ` [PATCH 3/4] trinity: Add support for s390_guarded_storage svc Thomas Richter
@ 2018-02-13 7:55 ` Thomas Richter
2 siblings, 0 replies; 4+ messages in thread
From: Thomas Richter @ 2018-02-13 7:55 UTC (permalink / raw)
To: trinity, davej; +Cc: brueckner, schwidefsky, heiko.carstens, Thomas Richter
Add support for s390 specific system call s390_sthyi
for 31 bit and 64 bit.
Signed-off-by: Thomas Richter <tmricht@linux.vnet.ibm.com>
---
include/syscalls-s390.h | 2 +-
include/syscalls-s390x.h | 2 +-
syscalls/s390x/s390_sthyi.c | 60 +++++++++++++++++++++++++++++++++++++++++++++
syscalls/syscalls.h | 1 +
4 files changed, 63 insertions(+), 2 deletions(-)
create mode 100644 syscalls/s390x/s390_sthyi.c
diff --git a/include/syscalls-s390.h b/include/syscalls-s390.h
index ad2f88c6..07706650 100644
--- a/include/syscalls-s390.h
+++ b/include/syscalls-s390.h
@@ -391,5 +391,5 @@ struct syscalltable syscalls_s390[] = {
{ .entry = &syscall_pwritev2 },
{ .entry = &syscall_s390_guarded_storage },
{ .entry = &syscall_statx },
- { .entry = &syscall_ni_syscall }, /* TODO: s390_sthyi svc */
+ { .entry = &syscall_s390_sthyi },
};
diff --git a/include/syscalls-s390x.h b/include/syscalls-s390x.h
index a83974e4..66f3bc56 100644
--- a/include/syscalls-s390x.h
+++ b/include/syscalls-s390x.h
@@ -391,5 +391,5 @@ struct syscalltable syscalls_s390x[] = {
{ .entry = &syscall_pwritev2 },
{ .entry = &syscall_s390_guarded_storage },
{ .entry = &syscall_statx },
- { .entry = &syscall_ni_syscall }, /* TODO: s390_sthyi svc */
+ { .entry = &syscall_s390_sthyi },
};
diff --git a/syscalls/s390x/s390_sthyi.c b/syscalls/s390x/s390_sthyi.c
new file mode 100644
index 00000000..9bf488a9
--- /dev/null
+++ b/syscalls/s390x/s390_sthyi.c
@@ -0,0 +1,60 @@
+/*
+ * int s390_sthyi(unsigned long function_code, void *resp_buffer,
+ * uint64_t *return_code, unsigned long flags);
+ */
+
+#include <asm/sthyi.h>
+
+#include "arch.h"
+#include "random.h"
+#include "sanitise.h"
+
+static unsigned long syscall_s390_sthyi_arg1[] = {
+ STHYI_FC_CP_IFL_CAP,
+ -1
+};
+
+static u64 syscall_s390_sthyi_return_code;
+
+/* Allocate buffer. */
+static void sanitise_s390_sthyi(struct syscallrecord *rec)
+{
+ size_t size = RAND_RANGE(0, page_size);
+ void *addr = size ? malloc(size) : NULL;
+
+ rec->a2 = (unsigned long)addr;
+
+ /* Use NULL, random or valid address */
+ switch (rnd() % 3) {
+ case 0: rec->a3 = 0;
+ break;
+ case 1: rec->a3 = rnd();
+ break;
+ case 2: rec->a3 = (unsigned long)&syscall_s390_sthyi_return_code;
+ break;
+ }
+}
+
+/* Free buffer, freeptr takes care of NULL */
+static void post_s390_sthyi(struct syscallrecord *rec)
+{
+ freeptr(&rec->a2);
+}
+
+struct syscallentry syscall_s390_sthyi = {
+ .name = "s390_sthyi",
+ .sanitise = sanitise_s390_sthyi,
+ .post = post_s390_sthyi,
+ .num_args = 4,
+ .arg1name = "function_code",
+ .arg1type = ARG_LIST,
+ .arg1list = ARGLIST(syscall_s390_sthyi_arg1),
+ .arg2name = "resp_buffer",
+ .arg2type = ARG_NON_NULL_ADDRESS,
+ .arg3name = "return_code",
+ .arg3type = ARG_ADDRESS,
+ .arg4name = "resp_buffer",
+ .arg4type = ARG_RANGE,
+ .low4range = 0,
+ .hi4range = 128
+};
diff --git a/syscalls/syscalls.h b/syscalls/syscalls.h
index 38271170..3620c4ea 100644
--- a/syscalls/syscalls.h
+++ b/syscalls/syscalls.h
@@ -390,5 +390,6 @@ extern struct syscallentry syscall_runtime_instr;
extern struct syscallentry syscall_s390_pci_mmio_write;
extern struct syscallentry syscall_s390_pci_mmio_read;
extern struct syscallentry syscall_s390_guarded_storage;
+extern struct syscallentry syscall_s390_sthyi;
unsigned int random_fcntl_setfl_flags(void);
--
2.14.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-02-13 7:55 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-13 7:55 [PATCH 1/4] trinity: Add support for runtime_instr svc Thomas Richter
2018-02-13 7:55 ` [PATCH 2/4] trinity: Add support for s390_pci_mmio_read and write Thomas Richter
2018-02-13 7:55 ` [PATCH 3/4] trinity: Add support for s390_guarded_storage svc Thomas Richter
2018-02-13 7:55 ` [PATCH 4/4] trinity: Add support for s390_sthyi svc Thomas Richter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).