Skip to content

Commit f2b6999

Browse files
author
Mamatha Inamdar
committed
powerpc/pseries: Add papr-platform-dump character driver for dump retrieval
JIRA: https://issues.redhat.com/browse/RHEL-101977 commit 8aa9efc Author: Haren Myneni <haren@linux.ibm.com> Date: Wed Apr 16 15:57:41 2025 -0700 powerpc/pseries: Add papr-platform-dump character driver for dump retrieval ibm,platform-dump RTAS call in combination with writable mapping /dev/mem is issued to collect platform dump from the hypervisor and may need multiple calls to get the complete dump. The current implementation uses rtas_platform_dump() API provided by librtas library to issue these RTAS calls. But /dev/mem access by the user space is prohibited under system lockdown. The solution should be to restrict access to RTAS function in user space and provide kernel interfaces to collect dump. This patch adds papr-platform-dump character driver and expose standard interfaces such as open / ioctl/ read to user space in ways that are compatible with lockdown. PAPR (7.3.3.4.1 ibm,platform-dump) provides a method to obtain the complete dump: - Each dump will be identified by ID called dump tag. - A sequence of RTAS calls have to be issued until retrieve the complete dump. The hypervisor expects the first RTAS call with the sequence 0 and the subsequent calls with the sequence number returned from the previous calls. - The hypervisor returns "dump complete" status once the complete dump is retrieved. But expects one more RTAS call from the partition with the NULL buffer to invalidate dump which means the dump will be removed in the hypervisor. - Sequence of calls are allowed with different dump IDs at the same time but not with the same dump ID. Expose these interfaces to user space with a /dev/papr-platform-dump character device using the following programming model: int devfd = open("/dev/papr-platform-dump", O_RDONLY); int fd = ioctl(devfd,PAPR_PLATFORM_DUMP_IOC_CREATE_HANDLE, &dump_id) - Restrict user space to access with the same dump ID. Typically we do not expect user space requests the dump again for the same dump ID. char *buf = malloc(size); length = read(fd, buf, size); - size should be minimum 1K based on PAPR and <= 4K based on RTAS work area size. It will be restrict to RTAS work area size. Using 4K work area based on the current implementation in librtas library - Each read call issue RTAS call to get the data based on the size requirement and returns bytes returned from the hypervisor - If the previous call returns dump complete status, the next read returns 0 like EOF. ret = ioctl(PAPR_PLATFORM_DUMP_IOC_INVALIDATE, &dump_id) - RTAS call with NULL buffer to invalidates the dump. The read API should use the file descriptor obtained from ioctl based on dump ID so that gets dump contents for the corresponding dump ID. Implemented support in librtas (rtas_platform_dump()) for this new ABI to support system lockdown. Signed-off-by: Haren Myneni <haren@linux.ibm.com> Tested-by: Sathvika Vasireddy <sv@linux.ibm.com> Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com> Link: https://patch.msgid.link/20250416225743.596462-7-haren@linux.ibm.com Signed-off-by: Mamatha Inamdar <minamdar@redhat.com>
1 parent c037e05 commit f2b6999

File tree

4 files changed

+429
-0
lines changed

4 files changed

+429
-0
lines changed

Documentation/userspace-api/ioctl/ioctl-number.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,8 @@ Code Seq# Include File Comments
366366
<mailto:linuxppc-dev>
367367
0xB2 03-05 arch/powerpc/include/uapi/asm/papr-indices.h powerpc/pseries indices API
368368
<mailto:linuxppc-dev>
369+
0xB2 06-07 arch/powerpc/include/uapi/asm/papr-platform-dump.h powerpc/pseries Platform Dump API
370+
<mailto:linuxppc-dev>
369371
0xB3 00 linux/mmc/ioctl.h
370372
0xB4 00-0F linux/gpio.h <mailto:linux-gpio@vger.kernel.org>
371373
0xB5 00-0F uapi/linux/rpmsg.h <mailto:linux-remoteproc@vger.kernel.org>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2+
#ifndef _UAPI_PAPR_PLATFORM_DUMP_H_
3+
#define _UAPI_PAPR_PLATFORM_DUMP_H_
4+
5+
#include <asm/ioctl.h>
6+
#include <asm/papr-miscdev.h>
7+
8+
/*
9+
* ioctl for /dev/papr-platform-dump. Returns a platform-dump handle fd
10+
* corresponding to dump tag.
11+
*/
12+
#define PAPR_PLATFORM_DUMP_IOC_CREATE_HANDLE _IOW(PAPR_MISCDEV_IOC_ID, 6, __u64)
13+
#define PAPR_PLATFORM_DUMP_IOC_INVALIDATE _IOW(PAPR_MISCDEV_IOC_ID, 7, __u64)
14+
15+
#endif /* _UAPI_PAPR_PLATFORM_DUMP_H_ */

arch/powerpc/platforms/pseries/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ ccflags-$(CONFIG_PPC_PSERIES_DEBUG) += -DDEBUG
44
obj-y := lpar.o hvCall.o nvram.o reconfig.o \
55
of_helpers.o rtas-work-area.o papr-sysparm.o \
66
papr-rtas-common.o papr-vpd.o papr-indices.o \
7+
papr-platform-dump.o \
78
setup.o iommu.o event_sources.o ras.o \
89
firmware.o power.o dlpar.o mobility.o rng.o \
910
pci.o pci_dlpar.o eeh_pseries.o msi.o \

0 commit comments

Comments
 (0)