On 1/29/26 5:54 PM, Farhan Ali wrote:

On 1/27/2026 8:15 AM, [email protected] wrote:
From: Jared Rossi <[email protected]>

Call Logical Processor (CLP) Architecture is used for managing PCI functions on s390x. Define and include the structures and routines needed to interact with
PCI devices during IPL.

Signed-off-by: Jared Rossi <[email protected]>
---
  pc-bios/s390-ccw/Makefile |  2 +-
  pc-bios/s390-ccw/clp.c    | 96 +++++++++++++++++++++++++++++++++++++++
  pc-bios/s390-ccw/clp.h    | 24 ++++++++++
  3 files changed, 121 insertions(+), 1 deletion(-)
  create mode 100644 pc-bios/s390-ccw/clp.c
  create mode 100644 pc-bios/s390-ccw/clp.h

diff --git a/pc-bios/s390-ccw/Makefile b/pc-bios/s390-ccw/Makefile
index 259cff09db..9c29548f84 100644
--- a/pc-bios/s390-ccw/Makefile
+++ b/pc-bios/s390-ccw/Makefile
@@ -35,7 +35,7 @@ QEMU_DGFLAGS = -MMD -MP -MT $@ -MF $(@D)/$(*F).d
    OBJECTS = start.o main.o bootmap.o jump2ipl.o sclp.o menu.o netmain.o \         virtio.o virtio-net.o virtio-scsi.o virtio-blkdev.o cio.o dasd-ipl.o \
-      virtio-ccw.o
+      virtio-ccw.o clp.o
    SLOF_DIR := $(SRC_PATH)/../../roms/SLOF
  diff --git a/pc-bios/s390-ccw/clp.c b/pc-bios/s390-ccw/clp.c
new file mode 100644
index 0000000000..2a14bb9b73
--- /dev/null
+++ b/pc-bios/s390-ccw/clp.c
@@ -0,0 +1,96 @@
+/*
+ * Call Logical Processor (CLP) architecture
+ *
+ * Copyright 2025 IBM Corp.
+ * Author(s): Jared Rossi <[email protected]>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "clp.h"
+#include <stdio.h>
+#include <string.h>
+
+int clp_pci(void *data)
+{
+    struct { uint8_t _[2048]; } *req = data;

The architecture specifies that size of the request + response block size can be maximum of 8192 bytes. If I understand correctly I think QEMU (similar to kernel) uses CLP_BLK_SIZE when calculating the CLP_FH_LIST_NR_ENTRIES, so it assumes that the request + response block is 4096. So we can return more than 2048 bytes here and overflow.

I think we should use at least CLP_BLK_SIZE here instead of 2048 or set this to the maximum possible value of 8192.

Thanks

Farhan

Thanks for pointing that out, I'll fix it.

Regards,
Jared Rossi


+    int cc = 3;
+
+    asm volatile (
+        "     .insn   rrf,0xb9a00000,0,%[req],0,2\n"
+        "     ipm     %[cc]\n"
+        "     srl     %[cc],28\n"
+        : [cc] "+d" (cc), "+m" (*req)
+        : [req] "a" (req)
+        : "cc");
+    return cc;
+}
+



Reply via email to