[PATCH 1/6] powerpc/pseries: Define common functions for RTAS sequence HCALLs
The RTAS call can be normal where retrieves the data form the hypervisor with one HCALL or sequence based HCALL which has to issue multiple times until the complete data is obtained. For some of these sequence HCALLs, the OS should not interleave calls with different input until the sequence is completed. The data is collected for each HCALL and copy to the buffer for the entire sequence during ioctl() handle and then expose this buffer to the user space with read() handle. One such sequence RTAS call is ibm,get-vpd and its support is already included in the current code. To add the similar support for other sequence HCALLs, move the common functions in to separate file and update papr_rtas_sequence struct with the following callbacks so that HCALL specific code will be defined and executed to complete the sequence. struct papr_rtas_sequence { int error; void params; void (*begin) (struct papr_rtas_sequence *, void *); void (*end) (struct papr_rtas_sequence *); const char * (*work) (struct papr_rtas_sequence *, size_t *); }; params: Input parameters used to pass for HCALL. Begin: HCALL specific function to initialize data including work area allocation. End:HCALL specific function to free up resources (free work area) after the sequence is completed. Work: The actual HCALL specific function which collects the data from the hypervisor. Signed-off-by: Haren Myneni --- arch/powerpc/platforms/pseries/Makefile | 2 +- .../platforms/pseries/papr-rtas-common.c | 243 .../platforms/pseries/papr-rtas-common.h | 45 +++ arch/powerpc/platforms/pseries/papr-vpd.c | 266 +++--- 4 files changed, 333 insertions(+), 223 deletions(-) create mode 100644 arch/powerpc/platforms/pseries/papr-rtas-common.c create mode 100644 arch/powerpc/platforms/pseries/papr-rtas-common.h diff --git a/arch/powerpc/platforms/pseries/Makefile b/arch/powerpc/platforms/pseries/Makefile index 7bf506f6b8c8..697c216b70dc 100644 --- a/arch/powerpc/platforms/pseries/Makefile +++ b/arch/powerpc/platforms/pseries/Makefile @@ -3,7 +3,7 @@ ccflags-$(CONFIG_PPC_PSERIES_DEBUG) += -DDEBUG obj-y := lpar.o hvCall.o nvram.o reconfig.o \ of_helpers.o rtas-work-area.o papr-sysparm.o \ - papr-vpd.o \ + papr-rtas-common.o papr-vpd.o \ setup.o iommu.o event_sources.o ras.o \ firmware.o power.o dlpar.o mobility.o rng.o \ pci.o pci_dlpar.o eeh_pseries.o msi.o \ diff --git a/arch/powerpc/platforms/pseries/papr-rtas-common.c b/arch/powerpc/platforms/pseries/papr-rtas-common.c new file mode 100644 index ..0209ec09d1fd --- /dev/null +++ b/arch/powerpc/platforms/pseries/papr-rtas-common.c @@ -0,0 +1,243 @@ +// SPDX-License-Identifier: GPL-2.0-only + +#define pr_fmt(fmt) "papr-common: " fmt + +#include +#include +#include +#include +#include +#include +#include +#include +#include "papr-rtas-common.h" + +/* + * Sequence based RTAS HCALL has to issue multiple times to retrieve + * complete data from the hypervisor. For some of these RTAS calls, + * the OS should not interleave calls with different input until the + * sequence is completed. So data is collected for these calls during + * ioctl handle and export to user space with read() handle. + * This file provides common functions needed for such sequence based + * RTAS calls Ex: ibm,get-vpd and ibm,get-indices. + */ + +bool papr_rtas_blob_has_data(const struct papr_rtas_blob *blob) +{ + return blob->data && blob->len; +} + +void papr_rtas_blob_free(const struct papr_rtas_blob *blob) +{ + if (blob) { + kvfree(blob->data); + kfree(blob); + } +} + +/** + * papr_rtas_blob_extend() - Append data to a &struct papr_rtas_blob. + * @blob: The blob to extend. + * @data: The new data to append to @blob. + * @len: The length of @data. + * + * Context: May sleep. + * Return: -ENOMEM on allocation failure, 0 otherwise. + */ +static int papr_rtas_blob_extend(struct papr_rtas_blob *blob, + const char *data, size_t len) +{ + const size_t new_len = blob->len + len; + const size_t old_len = blob->len; + const char *old_ptr = blob->data; + char *new_ptr; + + new_ptr = kvrealloc(old_ptr, new_len, GFP_KERNEL_ACCOUNT); + if (!new_ptr) + return -ENOMEM; + + memcpy(&new_ptr[old_len], data, len); + blob->data = new_ptr; + blob->len = new_len; + return 0; +} + +/** + * papr_rtas_blob_generate() - Construct a new &struct papr_rtas_blob. + * @seq: work function of the caller that is called to obtain + * data with the caller RTAS call. + * + * The @work callback is invoked until it returns NULL. @seq is + * passed to @work in its first argument on each call. When + *
[PATCH 6/6] 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 HCALLs. 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 HCALL 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 --- .../include/uapi/asm/papr-platform-dump.h | 15 + arch/powerpc/platforms/pseries/Makefile | 1 + .../platforms/pseries/papr-platform-dump.c| 408 ++ 3 files changed, 424 insertions(+) create mode 100644 arch/powerpc/include/uapi/asm/papr-platform-dump.h create mode 100644 arch/powerpc/platforms/pseries/papr-platform-dump.c diff --git a/arch/powerpc/include/uapi/asm/papr-platform-dump.h b/arch/powerpc/include/uapi/asm/papr-platform-dump.h new file mode 100644 index ..3a0f152e3ce8 --- /dev/null +++ b/arch/powerpc/include/uapi/asm/papr-platform-dump.h @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef _UAPI_PAPR_PLATFORM_DUMP_H_ +#define _UAPI_PAPR_PLATFORM_DUMP_H_ + +#include +#include + +/* + * ioctl for /dev/papr-platform-dump. Returns a VPD handle fd corresponding to + * the location code. + */ +#define PAPR_PLATFORM_DUMP_IOC_CREATE_HANDLE _IOW(PAPR_MISCDEV_IOC_ID, 6, __u64) +#define PAPR_PLATFORM_DUMP_IOC_INVALIDATE_IOW(PAPR_MISCDEV_IOC_ID, 7, __u64) + +#endif /* _UAPI_PAPR_PLATFORM_DUMP_H_ */ diff --git a/arch/powerpc/platforms/pseries/Makefile b/arch/powerpc/platforms/pseries/Makefile index e1db61877bb9..c82c94e0a73c 100644 --- a/arch/powerpc/platforms/pseries/Makefile +++ b/arch/powerpc/platforms/pseries/Makefile @@ -4,6 +4,7 @@ ccflags-$(CONFIG_PPC_PSERIES_DEBUG) += -DDEBUG obj-y := lpar.o hvCall.o nvram.o reconfig.o \ of_helpers.o rtas-work-area.o papr-sysparm.o \ papr-rtas-common.o papr-vpd.o papr-indices.o \ + papr-platform-dump.o \ setup.o iommu.o event_sources.o ras.o \ firmware.o power.o dlpar.o mobility.o rng.o \ pci.o pci_dlpar.o eeh_pseries.o msi.o \ diff --git a/arch/powerpc/platforms/pseries/papr-platform-dump.c b/arch/powerpc/platforms/pseries/papr-platform-dump.c new file mode 100644 index ..a78a20ec983e --- /dev/null +++ b/arch/powerpc/platforms/pseries/papr-platform-dump.c @@ -0,0 +1,408 @@ +// SPDX-License-Identifier: GPL-2.0-only + +#define pr_fmt(fmt) "papr-platform-dump: " fmt + +#include +#include +
[PATCH 3/6] powerpc/pseries: Add papr-indices char driver for ibm,get-indices HCALL
The RTAS call ibm,get-indices is used to obtain indices and location codes for a specified indicator or sensor token. The current implementation uses rtas_get_indices() API provided by librtas library which allocates RMO buffer and issue this RTAS call in the user space. But writable mapping /dev/mem access by the user space is prohibited under system lockdown. To overcome the restricted access in the user space, the kernel provide interfaces to collect indices data from the hypervisor. This patch adds papr-indices character driver and expose standard interfaces such as open / ioctl/ read to user space in ways that are compatible with lockdown. PAPR (2.13 7.3.17 ibm,get-indices RTAS Call) describes the following steps to retrieve all indices data: - User input parameters to the RTAS call: sensor or indicator, and indice type - ibm,get-indices is sequence RTAS call which means has to issue multiple times to get the entire list of indicators or sensors of a particular type. The hypervisor expects the first RTAS call with the sequence 1 and the subsequent calls with the sequence number returned from the previous calls. - The OS may not interleave calls to ibm,get-indices for different indicator or sensor types. Means other RTAS calls with different type should not be issued while the previous type sequence is in progress. So collect the entire list of indices and copied to buffer BLOB during ioctl() and expose this buffer to the user space with the file descriptor. - The hypervisor fills the work area with a specific format but does not return the number of bytes written to the buffer. Instead of parsing the data for each call to determine the data length, copy the work area size (RTAS_GET_INDICES_BUF_SIZE) to the buffer. Return work-area size of data to the user space for each read() call. Expose these interfaces to user space with a /dev/papr-indices character device using the following programming model: int devfd = open("/dev/papr-indices", O_RDONLY); int fd = ioctl(devfd, PAPR_INDICES_IOC_GET, struct papr_indices_io_block) - Collect all indices data for the specified token to the buffer char *buf = malloc(RTAS_GET_INDICES_BUF_SIZE); length = read(fd, buf, RTAS_GET_INDICES_BUF_SIZE) - RTAS_GET_INDICES_BUF_SIZE of data is returned to the user space. - The user space retrieves the indices and their location codes from the buffer - Should issue multiple read() calls until reaches the end of BLOB buffer. The read() should use the file descriptor obtained from ioctl to get the data that is exposed to file descriptor. Implemented support in librtas (rtas_get_indices()) for this new ABI for system lockdown. Signed-off-by: Haren Myneni --- arch/powerpc/include/asm/rtas.h | 1 + arch/powerpc/kernel/rtas.c| 2 +- arch/powerpc/platforms/pseries/Makefile | 2 +- arch/powerpc/platforms/pseries/papr-indices.c | 369 ++ 4 files changed, 372 insertions(+), 2 deletions(-) create mode 100644 arch/powerpc/platforms/pseries/papr-indices.c diff --git a/arch/powerpc/include/asm/rtas.h b/arch/powerpc/include/asm/rtas.h index 04406162fc5a..7dc527a5aaac 100644 --- a/arch/powerpc/include/asm/rtas.h +++ b/arch/powerpc/include/asm/rtas.h @@ -515,6 +515,7 @@ extern char rtas_data_buf[RTAS_DATA_BUF_SIZE]; extern unsigned long rtas_rmo_buf; extern struct mutex rtas_ibm_get_vpd_lock; +extern struct mutex rtas_ibm_get_indices_lock; #define GLOBAL_INTERRUPT_QUEUE 9005 diff --git a/arch/powerpc/kernel/rtas.c b/arch/powerpc/kernel/rtas.c index d31c9799cab2..76c634b92cb2 100644 --- a/arch/powerpc/kernel/rtas.c +++ b/arch/powerpc/kernel/rtas.c @@ -93,11 +93,11 @@ struct rtas_function { */ static DEFINE_MUTEX(rtas_ibm_activate_firmware_lock); static DEFINE_MUTEX(rtas_ibm_get_dynamic_sensor_state_lock); -static DEFINE_MUTEX(rtas_ibm_get_indices_lock); static DEFINE_MUTEX(rtas_ibm_lpar_perftools_lock); static DEFINE_MUTEX(rtas_ibm_physical_attestation_lock); static DEFINE_MUTEX(rtas_ibm_set_dynamic_indicator_lock); DEFINE_MUTEX(rtas_ibm_get_vpd_lock); +DEFINE_MUTEX(rtas_ibm_get_indices_lock); static struct rtas_function rtas_function_table[] __ro_after_init = { [RTAS_FNIDX__CHECK_EXCEPTION] = { diff --git a/arch/powerpc/platforms/pseries/Makefile b/arch/powerpc/platforms/pseries/Makefile index 697c216b70dc..e1db61877bb9 100644 --- a/arch/powerpc/platforms/pseries/Makefile +++ b/arch/powerpc/platforms/pseries/Makefile @@ -3,7 +3,7 @@ ccflags-$(CONFIG_PPC_PSERIES_DEBUG) += -DDEBUG obj-y := lpar.o hvCall.o nvram.o reconfig.o \ of_helpers.o rtas-work-area.o papr-sysparm.o \ - papr-rtas-common.o papr-vpd.o \ + papr-rtas-common.o papr-vpd.o papr-indices.o \ setup.o iommu.o event_sources.o ras.o \ firmware.o power.o dlpar.o mobilit
[PATCH 4/6] powerpc/pseries: Add ibm,set-dynamic-indicator RTAS call support
The RTAS call ibm,set-dynamic-indicator is used to set the new indicator state identified by a location code. The current implementation uses rtas_set_dynamic_indicator() API provided by librtas library which allocates RMO buffer and issue this RTAS call in the user space. But /dev/mem access by the user space is prohibited under system lockdown. This patch provides an interface with new ioctl PAPR_DYNAMIC_INDICATOR_IOC_SET to the papr-indices character driver and expose this interface to the user space that is compatible with lockdown. Refer PAPR 7.3.18 ibm,set-dynamic-indicator for more information on this RTAS call. - User input parameters to the RTAS call: location code string, indicator token and new state Expose these interfaces to user space with a /dev/papr-indices character device using the following programming model: int fd = open("/dev/papr-indices", O_RDWR); int ret = ioctl(fd, PAPR_DYNAMIC_INDICATOR_IOC_SET, struct papr_indices_io_block) - The user space passes input parameters in papr_indices_io_block struct Signed-off-by: Haren Myneni --- arch/powerpc/include/asm/rtas.h | 1 + arch/powerpc/kernel/rtas.c| 2 +- arch/powerpc/platforms/pseries/papr-indices.c | 119 ++ 3 files changed, 121 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/include/asm/rtas.h b/arch/powerpc/include/asm/rtas.h index 7dc527a5aaac..2da52f59e4c6 100644 --- a/arch/powerpc/include/asm/rtas.h +++ b/arch/powerpc/include/asm/rtas.h @@ -516,6 +516,7 @@ extern unsigned long rtas_rmo_buf; extern struct mutex rtas_ibm_get_vpd_lock; extern struct mutex rtas_ibm_get_indices_lock; +extern struct mutex rtas_ibm_set_dynamic_indicator_lock; #define GLOBAL_INTERRUPT_QUEUE 9005 diff --git a/arch/powerpc/kernel/rtas.c b/arch/powerpc/kernel/rtas.c index 76c634b92cb2..88fa416730af 100644 --- a/arch/powerpc/kernel/rtas.c +++ b/arch/powerpc/kernel/rtas.c @@ -95,9 +95,9 @@ static DEFINE_MUTEX(rtas_ibm_activate_firmware_lock); static DEFINE_MUTEX(rtas_ibm_get_dynamic_sensor_state_lock); static DEFINE_MUTEX(rtas_ibm_lpar_perftools_lock); static DEFINE_MUTEX(rtas_ibm_physical_attestation_lock); -static DEFINE_MUTEX(rtas_ibm_set_dynamic_indicator_lock); DEFINE_MUTEX(rtas_ibm_get_vpd_lock); DEFINE_MUTEX(rtas_ibm_get_indices_lock); +DEFINE_MUTEX(rtas_ibm_set_dynamic_indicator_lock); static struct rtas_function rtas_function_table[] __ro_after_init = { [RTAS_FNIDX__CHECK_EXCEPTION] = { diff --git a/arch/powerpc/platforms/pseries/papr-indices.c b/arch/powerpc/platforms/pseries/papr-indices.c index d73aa329bd70..30dfd928d192 100644 --- a/arch/powerpc/platforms/pseries/papr-indices.c +++ b/arch/powerpc/platforms/pseries/papr-indices.c @@ -27,6 +27,15 @@ #define RTAS_IBM_GET_INDICES_MORE_DATA 1 /* More data is available. */ #define RTAS_IBM_GET_INDICES_START_OVER -4 /* Indices list changed, restart call sequence. */ +/* + * Function-specific return values for ibm,set-dynamic-indicator and + * ibm,get-dynamic-sensor-state RTAS calls, drived from PAPR+ + * v2.13 7.3.18 and 7.3.19. + */ +#define RTAS_IBM_DYNAMIC_INDICE_SUCCESS0 +#define RTAS_IBM_DYNAMIC_INDICE_HW_ERROR -1 +#define RTAS_IBM_DYNAMIC_INDICE_NO_INDICATOR -3 + /** * struct rtas_ibm_get_indices_params - Parameters (in and out) for * ibm,get-indices. @@ -328,6 +337,107 @@ static long papr_indices_create_handle(struct papr_indices_io_block __user *ubuf return fd; } +/** + * Create work area with the input parameters. This function is used + * for both ibm,set-dynamic-indicator and ibm,get-dynamic-sensor-state + * RTAS Calls. + */ +static struct rtas_work_area * +papr_dynamic_indice_buf_from_user(struct papr_indices_io_block __user *ubuf, + struct papr_indices_io_block *kbuf) +{ + struct rtas_work_area *work_area; + u32 length; + __be32 len_be; + + if (copy_from_user(kbuf, ubuf, sizeof(*kbuf))) + return ERR_PTR(-EFAULT); + + + if (!string_is_terminated(kbuf->dynamic_param.location_code_str, + ARRAY_SIZE(kbuf->dynamic_param.location_code_str))) + return ERR_PTR(-EINVAL); + + /* +* The input data in the work area should be as follows: +* - 32-bit integer length of the location code string, +* including NULL. +* - Location code string, NULL terminated, identifying the +* token (sensor or indicator). +* PAPR 2.13 - R1–7.3.18–5 ibm,set-dynamic-indicator +* - R1–7.3.19–5 ibm,get-dynamic-sensor-state +*/ + /* +* Length that user space passed should also include NULL +* terminator. +*/ + length = strlen(kbuf->dynamic_param.location_code_str) + 1; + if (length > LOC_CODE_SIZE) + return ERR_PTR(-EINVAL); + + len_be = cpu_to_be32(length); + + work_
[PATCH 0/6] Add character devices for indices and platform-dump RTAS
Several APIs such as rtas_get_indices(), rtas_get_dynamic_sensor(), rtas_set_dynamic_indicator() and rtas_platform_dump() provided by librtas library are implemented in user space using rtas syscall in combination with writable mappings of /dev/mem. But this implementation is not compatible with system lockdown which prohibits /dev/mem access. The current kernel already provides char based driver interfaces for several RTAS calls such as VPD and system parameters to support lockdown feature. This patch series adds new char based drivers, /dev/papr-indices for ibm,get-indices, ibm,get-dynamic-sensor-state and ibm,set-dynamic-indicator RTAS Calls. and /dev/papr-platform-dump for ibm,platform-dump. Providing the similar open/ioctl/read interfaces to the user space as in the case of VPD and system parameters. I have made changes to librtas library to use the new kernel interfaces if the corresponding device entry is available. This patch series has the following patches: powerpc/pseries: Define common functions for RTAS sequence HCALLs - For some of sequence based RTAS calls, the OS should not start another sequence with different input until the previous sequence is completed. So the sequence should be completed during ioctl() and expose the entire buffer during read(). ibm,get-indices is sequence based RTAS function similar to ibm,get-vpd and we already have the corresponding implementation for VPD driver. So update papr_rtas_sequence struct for RTAS call specific functions and move the top level sequence functions in to a separate file. powerpc/pseries: Define papr_indices_io_block for papr-indices ioctls - /dev/papr-indices driver supports ibm,get-indices, ibm,get-dynamic-sensor-state and ibm,set-dynamic-indicator RTAS Calls. papr-indices.h introduces 3 different ioctls for these RTAS calls and the corresponding ioctl input buffer. powerpc/pseries: Add papr-indices char driver for ibm,get-indices HCALL - Introduce /dev/papr-indices char based driver and add support for get-indices RTAS function powerpc/pseries: Add ibm,set-dynamic-indicator RTAS call support - Update /dev/papr-indices for set-dynamic-indicator RTAS function powerpc/pseries: Add ibm,get-dynamic-sensor-state RTAS call support - Update /dev/papr-indices for get-dynamic-sensor-state RTAS function powerpc/pseries: Add papr-platform-dump character driver for dump retrieval - Introduce /dev/papr-platform-dump char driver and adds support for ibm,platform-dump. Received suggestions from the previous post as a separate patch - Updated the patch with invalidating the dump using a separate ioctl. Haren Myneni (6): powerpc/pseries: Define common functions for RTAS sequence HCALLs powerpc/pseries: Define papr_indices_io_block for papr-indices ioctls powerpc/pseries: Add papr-indices char driver for ibm,get-indices HCALL powerpc/pseries: Add ibm,set-dynamic-indicator RTAS call support powerpc/pseries: Add ibm,get-dynamic-sensor-state RTAS call support powerpc/pseries: Add papr-platform-dump character driver for dump retrieval arch/powerpc/include/asm/rtas.h | 3 + arch/powerpc/include/uapi/asm/papr-indices.h | 41 ++ .../include/uapi/asm/papr-platform-dump.h | 15 + arch/powerpc/kernel/rtas.c| 6 +- arch/powerpc/platforms/pseries/Makefile | 3 +- arch/powerpc/platforms/pseries/papr-indices.c | 552 ++ .../platforms/pseries/papr-platform-dump.c| 408 + .../platforms/pseries/papr-rtas-common.c | 243 .../platforms/pseries/papr-rtas-common.h | 45 ++ arch/powerpc/platforms/pseries/papr-vpd.c | 266 ++--- 10 files changed, 1356 insertions(+), 226 deletions(-) create mode 100644 arch/powerpc/include/uapi/asm/papr-indices.h create mode 100644 arch/powerpc/include/uapi/asm/papr-platform-dump.h create mode 100644 arch/powerpc/platforms/pseries/papr-indices.c create mode 100644 arch/powerpc/platforms/pseries/papr-platform-dump.c create mode 100644 arch/powerpc/platforms/pseries/papr-rtas-common.c create mode 100644 arch/powerpc/platforms/pseries/papr-rtas-common.h -- 2.43.5
[PATCH 2/6] powerpc/pseries: Define papr_indices_io_block for papr-indices ioctls
To issue ibm,get-indices, ibm,set-dynamic-indicator and ibm,get-dynamic-sensor-state in the user space, the RMO buffer is allocated for the work area which is restricted under system lockdown. So instead of user space execution, the kernel will provide /dev/papr-indices interface to execute these RTAS HCALLs. The user space assigns data in papr_indices_io_block struct depends on the specific HCALL and passes to the following ioctls: PAPR_INDICES_IOC_GET: Use for ibm,get-indices. Returns a get-indices handle fd to read data. PAPR_DYNAMIC_SENSOR_IOC_GET:Use for ibm,get-dynamic-sensor-state. Updates the sensor state in papr_indices_io_block.dynamic_param.state PAPR_DYNAMIC_INDICATOR_IOC_SET: Use for ibm,set-dynamic-indicator. Sets the new state for the input indicator. Signed-off-by: Haren Myneni --- arch/powerpc/include/uapi/asm/papr-indices.h | 41 1 file changed, 41 insertions(+) create mode 100644 arch/powerpc/include/uapi/asm/papr-indices.h diff --git a/arch/powerpc/include/uapi/asm/papr-indices.h b/arch/powerpc/include/uapi/asm/papr-indices.h new file mode 100644 index ..c580025fe201 --- /dev/null +++ b/arch/powerpc/include/uapi/asm/papr-indices.h @@ -0,0 +1,41 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef _UAPI_PAPR_INDICES_H_ +#define _UAPI_PAPR_INDICES_H_ + +#include +#include +#include + +#define LOC_CODE_SIZE 80 +#define RTAS_GET_INDICES_BUF_SIZE SZ_4K + +struct papr_indices_io_block { + union { + struct { + __u8 is_sensor; /* 0 for indicator and 1 for sensor */ + __u32 indice_type; + } indices; + struct { + __u32 token; /* Sensor or indicator token */ + __u32 state; /* get / set state */ + /* +* PAPR+ 12.3.2.4 Converged Location Code Rules - Length +* Restrictions. 79 characters plus null. +*/ + char location_code_str[LOC_CODE_SIZE]; /* location code */ + } dynamic_param; + }; +}; + +/* + * ioctls for /dev/papr-indices. + * PAPR_INDICES_IOC_GET: Returns a get-indices handle fd to read data + * PAPR_DYNAMIC_SENSOR_IOC_GET:Gets the state of the input sensor + * PAPR_DYNAMIC_INDICATOR_IOC_SET: Sets the new state for the input indicator + */ +#define PAPR_INDICES_IOC_GET _IOW(PAPR_MISCDEV_IOC_ID, 3, struct papr_indices_io_block) +#define PAPR_DYNAMIC_SENSOR_IOC_GET_IOWR(PAPR_MISCDEV_IOC_ID, 4, struct papr_indices_io_block) +#define PAPR_DYNAMIC_INDICATOR_IOC_SET _IOW(PAPR_MISCDEV_IOC_ID, 5, struct papr_indices_io_block) + + +#endif /* _UAPI_PAPR_INDICES_H_ */ -- 2.43.5
[PATCH 5/6] powerpc/pseries: Add ibm,get-dynamic-sensor-state RTAS call support
The RTAS call ibm,get-dynamic-sensor-state is used to get the sensor state identified by the location code and the sensor token. The librtas library provides an API rtas_get_dynamic_sensor() which uses /dev/mem access for work area allocation but is restricted under system lockdown. This patch provides an interface with new ioctl PAPR_DYNAMIC_SENSOR_IOC_GET to the papr-indices character driver which executes this HCALL and copies the sensor state in the user specified ioctl buffer. Refer PAPR 7.3.19 ibm,get-dynamic-sensor-state for more information on this RTAS call. - User input parameters to the RTAS call: location code string and the sensor token Expose these interfaces to user space with a /dev/papr-indices character device using the following programming model: int fd = open("/dev/papr-indices", O_RDWR); int ret = ioctl(fd, PAPR_DYNAMIC_SENSOR_IOC_GET, struct papr_indices_io_block) - The user space specifies input parameters in papr_indices_io_block struct - Returned state for the specified sensor is copied to papr_indices_io_block.dynamic_param.state Signed-off-by: Haren Myneni --- arch/powerpc/include/asm/rtas.h | 1 + arch/powerpc/kernel/rtas.c| 2 +- arch/powerpc/platforms/pseries/papr-indices.c | 64 +++ 3 files changed, 66 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/include/asm/rtas.h b/arch/powerpc/include/asm/rtas.h index 2da52f59e4c6..fcd822f0e1d7 100644 --- a/arch/powerpc/include/asm/rtas.h +++ b/arch/powerpc/include/asm/rtas.h @@ -517,6 +517,7 @@ extern unsigned long rtas_rmo_buf; extern struct mutex rtas_ibm_get_vpd_lock; extern struct mutex rtas_ibm_get_indices_lock; extern struct mutex rtas_ibm_set_dynamic_indicator_lock; +extern struct mutex rtas_ibm_get_dynamic_sensor_state_lock; #define GLOBAL_INTERRUPT_QUEUE 9005 diff --git a/arch/powerpc/kernel/rtas.c b/arch/powerpc/kernel/rtas.c index 88fa416730af..a4848e7f248e 100644 --- a/arch/powerpc/kernel/rtas.c +++ b/arch/powerpc/kernel/rtas.c @@ -92,12 +92,12 @@ struct rtas_function { * Per-function locks for sequence-based RTAS functions. */ static DEFINE_MUTEX(rtas_ibm_activate_firmware_lock); -static DEFINE_MUTEX(rtas_ibm_get_dynamic_sensor_state_lock); static DEFINE_MUTEX(rtas_ibm_lpar_perftools_lock); static DEFINE_MUTEX(rtas_ibm_physical_attestation_lock); DEFINE_MUTEX(rtas_ibm_get_vpd_lock); DEFINE_MUTEX(rtas_ibm_get_indices_lock); DEFINE_MUTEX(rtas_ibm_set_dynamic_indicator_lock); +DEFINE_MUTEX(rtas_ibm_get_dynamic_sensor_state_lock); static struct rtas_function rtas_function_table[] __ro_after_init = { [RTAS_FNIDX__CHECK_EXCEPTION] = { diff --git a/arch/powerpc/platforms/pseries/papr-indices.c b/arch/powerpc/platforms/pseries/papr-indices.c index 30dfd928d192..079e01d0427c 100644 --- a/arch/powerpc/platforms/pseries/papr-indices.c +++ b/arch/powerpc/platforms/pseries/papr-indices.c @@ -438,6 +438,64 @@ static long papr_dynamic_indicator_ioc_set(struct papr_indices_io_block __user * return ret; } +/** + * papr_dynamic_sensor_ioc_get - ibm,get-dynamic-sensor-state RTAS Call + * PAPR 2.13 7.3.19 + * + * @ubuf: Input parameters to RTAS call such as sensor token + *Copies the state in user space buffer. + * + * + * Returns success or -errno. + */ + +static long papr_dynamic_sensor_ioc_get(struct papr_indices_io_block __user *ubuf) +{ + struct papr_indices_io_block kbuf; + struct rtas_work_area *work_area; + s32 fwrc, token, ret; + u32 rets; + + token = rtas_function_token(RTAS_FN_IBM_GET_DYNAMIC_SENSOR_STATE); + if (token == RTAS_UNKNOWN_SERVICE) + return -ENOENT; + + mutex_lock(&rtas_ibm_get_dynamic_sensor_state_lock); + work_area = papr_dynamic_indice_buf_from_user(ubuf, &kbuf); + if (IS_ERR(work_area)) + return PTR_ERR(work_area); + + do { + fwrc = rtas_call(token, 2, 2, &rets, + kbuf.dynamic_param.token, + rtas_work_area_phys(work_area)); + } while (rtas_busy_delay(fwrc)); + + rtas_work_area_free(work_area); + mutex_unlock(&rtas_ibm_get_dynamic_sensor_state_lock); + + switch (fwrc) { + case RTAS_IBM_DYNAMIC_INDICE_SUCCESS: + if (put_user(rets, &ubuf->dynamic_param.state)) + ret = -EFAULT; + else + ret = 0; + break; + case RTAS_IBM_DYNAMIC_INDICE_NO_INDICATOR: /* No such indicator */ + ret = -EOPNOTSUPP; + break; + default: + pr_err("unexpected ibm,get-dynamic-sensor result %d\n", + fwrc); + fallthrough; + case RTAS_IBM_DYNAMIC_INDICE_HW_ERROR: /* Hardware/platform error */ + ret = -EIO; + break; + } + + return ret; +} + /* * Top-level ioctl handler for /dev/pa
Re: [PATCH 1/6] powerpc/pseries: Define common functions for RTAS sequence HCALLs
Hi Haren, kernel test robot noticed the following build warnings: [auto build test WARNING on powerpc/next] [also build test WARNING on powerpc/fixes linus/master v6.13-rc5 next-20241220] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Haren-Myneni/powerpc-pseries-Define-common-functions-for-RTAS-sequence-HCALLs/20250105-045010 base: https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git next patch link: https://lore.kernel.org/r/20250104204652.388720-2-haren%40linux.ibm.com patch subject: [PATCH 1/6] powerpc/pseries: Define common functions for RTAS sequence HCALLs config: powerpc64-randconfig-002-20250105 (https://download.01.org/0day-ci/archive/20250105/202501051055.ozdor4fh-...@intel.com/config) compiler: clang version 20.0.0git (https://github.com/llvm/llvm-project 096551537b2a747a3387726ca618ceeb3950e9bc) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250105/202501051055.ozdor4fh-...@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot | Closes: https://lore.kernel.org/oe-kbuild-all/202501051055.ozdor4fh-...@intel.com/ All warnings (new ones prefixed by >>): >> arch/powerpc/platforms/pseries/papr-vpd.c:141: warning: Function parameter >> or struct member 'param' not described in 'vpd_sequence_begin' >> arch/powerpc/platforms/pseries/papr-vpd.c:141: warning: Excess function >> parameter 'loc_code' description in 'vpd_sequence_begin' vim +141 arch/powerpc/platforms/pseries/papr-vpd.c 514f6ff4369a30 Nathan Lynch 2023-12-12 121 514f6ff4369a30 Nathan Lynch 2023-12-12 122 /* 514f6ff4369a30 Nathan Lynch 2023-12-12 123 * Internal VPD sequence APIs. A VPD sequence is a series of calls to 514f6ff4369a30 Nathan Lynch 2023-12-12 124 * ibm,get-vpd for a given location code. The sequence ends when an 514f6ff4369a30 Nathan Lynch 2023-12-12 125 * error is encountered or all VPD for the location code has been 514f6ff4369a30 Nathan Lynch 2023-12-12 126 * returned. 514f6ff4369a30 Nathan Lynch 2023-12-12 127 */ 514f6ff4369a30 Nathan Lynch 2023-12-12 128 514f6ff4369a30 Nathan Lynch 2023-12-12 129 /** 514f6ff4369a30 Nathan Lynch 2023-12-12 130 * vpd_sequence_begin() - Begin a VPD retrieval sequence. 514f6ff4369a30 Nathan Lynch 2023-12-12 131 * @seq: Uninitialized sequence state. 514f6ff4369a30 Nathan Lynch 2023-12-12 132 * @loc_code: Location code that defines the scope of the VPD to return. 514f6ff4369a30 Nathan Lynch 2023-12-12 133 * 514f6ff4369a30 Nathan Lynch 2023-12-12 134 * Initializes @seq with the resources necessary to carry out a VPD 514f6ff4369a30 Nathan Lynch 2023-12-12 135 * sequence. Callers must pass @seq to vpd_sequence_end() regardless 514f6ff4369a30 Nathan Lynch 2023-12-12 136 * of whether the sequence succeeds. 514f6ff4369a30 Nathan Lynch 2023-12-12 137 * 514f6ff4369a30 Nathan Lynch 2023-12-12 138 * Context: May sleep. 514f6ff4369a30 Nathan Lynch 2023-12-12 139 */ 5d8b0014124124 Haren Myneni 2025-01-04 140 static void vpd_sequence_begin(struct papr_rtas_sequence *seq, void *param) 514f6ff4369a30 Nathan Lynch 2023-12-12 @141 { 5d8b0014124124 Haren Myneni 2025-01-04 142 struct rtas_ibm_get_vpd_params *vpd_params; 514f6ff4369a30 Nathan Lynch 2023-12-12 143 /* 514f6ff4369a30 Nathan Lynch 2023-12-12 144 * Use a static data structure for the location code passed to 514f6ff4369a30 Nathan Lynch 2023-12-12 145 * RTAS to ensure it's in the RMA and avoid a separate work 514f6ff4369a30 Nathan Lynch 2023-12-12 146 * area allocation. Guarded by the function lock. 514f6ff4369a30 Nathan Lynch 2023-12-12 147 */ 514f6ff4369a30 Nathan Lynch 2023-12-12 148 static struct papr_location_code static_loc_code; 514f6ff4369a30 Nathan Lynch 2023-12-12 149 514f6ff4369a30 Nathan Lynch 2023-12-12 150 /* 514f6ff4369a30 Nathan Lynch 2023-12-12 151 * We could allocate the work area before acquiring the 514f6ff4369a30 Nathan Lynch 2023-12-12 152 * function lock, but that would allow concurrent requests to 514f6ff4369a30 Nathan Lynch 2023-12-12 153 * exhaust the limited work area pool for no benefit. So 514f6ff4369a30 Nathan Lynch 2023-12-12 154 * allocate the work area under the lock. 514f6ff4369a30 Nathan Lynch 2023-12-12 155 */ 514f6ff4369a30 Nathan Lynch 2023-12-12 156 mutex_lock(&rtas_ibm_get_vpd_lock); 5d8b0014124124 Haren Myneni 2025-01-04 157 static_loc_code = *(struct papr_location_code *)param; 5d8b0014124124 Haren Myneni 2025-01-04 158 vpd_params = (struct rtas_ibm_get_vpd_params *)seq->params; 5d8b0014124124 Haren Myneni 2025-01-04 159 vpd_para
[PATCH v2 5/5] crash: Remove KEXEC_CORE_NOTE_NAME
Now KEXEC_CORE_NOTE_NAME is only used at one place and it does not seem to provide any value anymore. Replace the remaining usage with the literal and remove the macro. Signed-off-by: Akihiko Odaki --- arch/s390/kernel/crash_dump.c | 2 +- include/linux/kexec.h | 2 -- include/linux/vmcore_info.h | 1 - 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/arch/s390/kernel/crash_dump.c b/arch/s390/kernel/crash_dump.c index cd0c93a8fb8b..4a9817489e35 100644 --- a/arch/s390/kernel/crash_dump.c +++ b/arch/s390/kernel/crash_dump.c @@ -253,7 +253,7 @@ static const char *nt_name(Elf64_Word type) const char *name = "LINUX"; if (type == NT_PRPSINFO || type == NT_PRSTATUS || type == NT_PRFPREG) - name = KEXEC_CORE_NOTE_NAME; + name = "CORE"; return name; } diff --git a/include/linux/kexec.h b/include/linux/kexec.h index f0e9f8eda7a3..c840431eadda 100644 --- a/include/linux/kexec.h +++ b/include/linux/kexec.h @@ -68,8 +68,6 @@ extern note_buf_t __percpu *crash_notes; #define KEXEC_CRASH_MEM_ALIGN PAGE_SIZE #endif -#define KEXEC_CORE_NOTE_NAME CRASH_CORE_NOTE_NAME - /* * This structure is used to hold the arguments that are used when loading * kernel binaries. diff --git a/include/linux/vmcore_info.h b/include/linux/vmcore_info.h index 1672801fd98c..37e003ae5262 100644 --- a/include/linux/vmcore_info.h +++ b/include/linux/vmcore_info.h @@ -6,7 +6,6 @@ #include #include -#define CRASH_CORE_NOTE_NAME "CORE" #define CRASH_CORE_NOTE_HEAD_BYTES ALIGN(sizeof(struct elf_note), 4) #define CRASH_CORE_NOTE_NAME_BYTES ALIGN(sizeof(NN_PRSTATUS), 4) #define CRASH_CORE_NOTE_DESC_BYTES ALIGN(sizeof(struct elf_prstatus), 4) -- 2.47.1
[PATCH v2 0/5] elf: Define note name macros
elf.h had a comment saying: > Notes used in ET_CORE. Architectures export some of the arch register > sets using the corresponding note types via the PTRACE_GETREGSET and > PTRACE_SETREGSET requests. > The note name for these types is "LINUX", except NT_PRFPREG that is > named "CORE". However, NT_PRSTATUS is also named "CORE". It is also unclear what "these types" refers to. To fix these problems, define a name for each note type. The added definitions are macros so the kernel and userspace can directly refer to them. Signed-off-by: Akihiko Odaki --- Changes in v2: - Added a macro definition for each note type instead of trying to describe in a comment. - Link to v1: https://lore.kernel.org/r/20241225-elf-v1-1-79e940350...@daynix.com --- Akihiko Odaki (5): elf: Define note name macros binfmt_elf: Use note name macros powwerpc: Use note name macros crash: Use note name macros crash: Remove KEXEC_CORE_NOTE_NAME arch/powerpc/kernel/fadump.c | 2 +- arch/powerpc/platforms/powernv/opal-core.c | 8 +-- arch/s390/kernel/crash_dump.c | 2 +- fs/binfmt_elf.c| 21 fs/binfmt_elf_fdpic.c | 8 +-- fs/proc/kcore.c| 12 ++--- include/linux/kexec.h | 2 - include/linux/vmcore_info.h| 3 +- include/uapi/linux/elf.h | 86 -- kernel/crash_core.c| 2 +- 10 files changed, 111 insertions(+), 35 deletions(-) --- base-commit: a32e14f8aef69b42826cf0998b068a43d486a9e9 change-id: 20241210-elf-b80ea3949c39 Best regards, -- Akihiko Odaki
[PATCH v2 1/5] elf: Define note name macros
elf.h had a comment saying: > Notes used in ET_CORE. Architectures export some of the arch register > sets using the corresponding note types via the PTRACE_GETREGSET and > PTRACE_SETREGSET requests. > The note name for these types is "LINUX", except NT_PRFPREG that is > named "CORE". However, NT_PRSTATUS is also named "CORE". It is also unclear what "these types" refers to. To fix these problems, define a name for each note type. The added definitions are macros so the kernel and userspace can directly refer to them. Signed-off-by: Akihiko Odaki --- include/uapi/linux/elf.h | 86 ++-- 1 file changed, 83 insertions(+), 3 deletions(-) diff --git a/include/uapi/linux/elf.h b/include/uapi/linux/elf.h index b44069d29cec..014b705b97d7 100644 --- a/include/uapi/linux/elf.h +++ b/include/uapi/linux/elf.h @@ -372,8 +372,6 @@ typedef struct elf64_shdr { * Notes used in ET_CORE. Architectures export some of the arch register sets * using the corresponding note types via the PTRACE_GETREGSET and * PTRACE_SETREGSET requests. - * The note name for these types is "LINUX", except NT_PRFPREG that is named - * "CORE". */ #define NT_PRSTATUS1 #define NT_PRFPREG 2 @@ -460,9 +458,91 @@ typedef struct elf64_shdr { #define NT_LOONGARCH_HW_BREAK 0xa05 /* LoongArch hardware breakpoint registers */ #define NT_LOONGARCH_HW_WATCH 0xa06 /* LoongArch hardware watchpoint registers */ -/* Note types with note name "GNU" */ +/* Note used in ET_EXEC and ET_DYN. */ #define NT_GNU_PROPERTY_TYPE_0 5 +/* Note names */ +#define NN_PRSTATUS"CORE" +#define NN_PRFPREG "CORE" +#define NN_PRPSINFO"CORE" +#define NN_TASKSTRUCT "CORE" +#define NN_AUXV"CORE" +#define NN_SIGINFO "CORE" +#define NN_FILE"CORE" +#define NN_PRXFPREG"LINUX" +#define NN_PPC_VMX "LINUX" +#define NN_PPC_SPE "LINUX" +#define NN_PPC_VSX "LINUX" +#define NN_PPC_TAR "LINUX" +#define NN_PPC_PPR "LINUX" +#define NN_PPC_DSCR"LINUX" +#define NN_PPC_EBB "LINUX" +#define NN_PPC_PMU "LINUX" +#define NN_PPC_TM_CGPR "LINUX" +#define NN_PPC_TM_CFPR "LINUX" +#define NN_PPC_TM_CVMX "LINUX" +#define NN_PPC_TM_CVSX "LINUX" +#define NN_PPC_TM_SPR "LINUX" +#define NN_PPC_TM_CTAR "LINUX" +#define NN_PPC_TM_CPPR "LINUX" +#define NN_PPC_TM_CDSCR"LINUX" +#define NN_PPC_PKEY"LINUX" +#define NN_PPC_DEXCR "LINUX" +#define NN_PPC_HASHKEYR"LINUX" +#define NN_386_TLS "LINUX" +#define NN_386_IOPERM "LINUX" +#define NN_X86_XSTATE "LINUX" +#define NN_X86_SHSTK "LINUX" +#define NN_X86_XSAVE_LAYOUT"LINUX" +#define NN_S390_HIGH_GPRS "LINUX" +#define NN_S390_TIMER "LINUX" +#define NN_S390_TODCMP "LINUX" +#define NN_S390_TODPREG"LINUX" +#define NN_S390_CTRS "LINUX" +#define NN_S390_PREFIX "LINUX" +#define NN_S390_LAST_BREAK "LINUX" +#define NN_S390_SYSTEM_CALL"LINUX" +#define NN_S390_TDB"LINUX" +#define NN_S390_VXRS_LOW "LINUX" +#define NN_S390_VXRS_HIGH "LINUX" +#define NN_S390_GS_CB "LINUX" +#define NN_S390_GS_BC "LINUX" +#define NN_S390_RI_CB "LINUX" +#define NN_S390_PV_CPU_DATA"LINUX" +#define NN_ARM_VFP "LINUX" +#define NN_ARM_TLS "LINUX" +#define NN_ARM_HW_BREAK"LINUX" +#define NN_ARM_HW_WATCH"LINUX" +#define NN_ARM_SYSTEM_CALL "LINUX" +#define NN_ARM_SVE "LINUX" +#define NN_ARM_PAC_MASK"LINUX" +#define NN_ARM_PACA_KEYS "LINUX" +#define NN_ARM_PACG_KEYS "LINUX" +#define NN_ARM_TAGGED_ADDR_CTRL"LINUX" +#define NN_ARM_PAC_ENABLED_KEYS"LINUX" +#define NN_ARM_SSVE"LINUX" +#define NN_ARM_ZA "LINUX" +#define NN_ARM_ZT "LINUX" +#define NN_ARM_FPMR"LINUX" +#define NN_ARM_POE "LINUX" +#define NN_ARM_GCS "LINUX" +#define NN_ARC_V2 "LINUX" +#define NN_VMCOREDD"LINUX" +#define NN_MIPS_DSP"LINUX" +#define NN_MIPS_FP_MODE"LINUX" +#define NN_MIPS_MSA"LINUX" +#define NN_RISCV_CSR "LINUX" +#define NN_RISCV_VECTOR"LINUX" +#define NN_RISCV_TAGGED_ADDR_CTRL "LINUX" +#define NN_LOONGARCH_CPUCFG"LINUX" +#define NN_LOONGARCH_CSR "LINUX" +#define NN_LOONGARCH_LSX "LINUX" +#define NN_LOONGARCH_LASX "LINUX" +#define NN_LOONGARCH_LBT "LINUX" +#define NN_LOONGARCH_HW_BREAK "LINUX" +#define NN_LOONGARCH_HW_WATCH "LINUX" +#define NN_GNU_PROPERTY_TYPE_0 "GNU" + /* Note header in a PT_NOTE section */ typedef struct elf32_note { Elf32_Word n_namesz; /* Name size */ -- 2.47.1
[PATCH v2 3/5] powwerpc: Use note name macros
Use note name macros to match with the userspace's expectation. Signed-off-by: Akihiko Odaki --- arch/powerpc/kernel/fadump.c | 2 +- arch/powerpc/platforms/powernv/opal-core.c | 8 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/powerpc/kernel/fadump.c b/arch/powerpc/kernel/fadump.c index 4b371c738213..d44349fe8e2b 100644 --- a/arch/powerpc/kernel/fadump.c +++ b/arch/powerpc/kernel/fadump.c @@ -751,7 +751,7 @@ u32 *__init fadump_regs_to_elf_notes(u32 *buf, struct pt_regs *regs) * prstatus.pr_pid = */ elf_core_copy_regs(&prstatus.pr_reg, regs); - buf = append_elf_note(buf, CRASH_CORE_NOTE_NAME, NT_PRSTATUS, + buf = append_elf_note(buf, NN_PRSTATUS, NT_PRSTATUS, &prstatus, sizeof(prstatus)); return buf; } diff --git a/arch/powerpc/platforms/powernv/opal-core.c b/arch/powerpc/platforms/powernv/opal-core.c index c9a9b759cc92..a379ff86c120 100644 --- a/arch/powerpc/platforms/powernv/opal-core.c +++ b/arch/powerpc/platforms/powernv/opal-core.c @@ -149,7 +149,7 @@ static Elf64_Word *__init auxv_to_elf64_notes(Elf64_Word *buf, /* end of vector */ bufp[idx++] = cpu_to_be64(AT_NULL); - buf = append_elf64_note(buf, CRASH_CORE_NOTE_NAME, NT_AUXV, + buf = append_elf64_note(buf, NN_AUXV, NT_AUXV, oc_conf->auxv_buf, AUXV_DESC_SZ); return buf; } @@ -252,7 +252,7 @@ static Elf64_Word * __init opalcore_append_cpu_notes(Elf64_Word *buf) * crashing CPU's prstatus. */ first_cpu_note = buf; - buf = append_elf64_note(buf, CRASH_CORE_NOTE_NAME, NT_PRSTATUS, + buf = append_elf64_note(buf, NN_PRSTATUS, NT_PRSTATUS, &prstatus, sizeof(prstatus)); for (i = 0; i < oc_conf->num_cpus; i++, bufp += size_per_thread) { @@ -279,7 +279,7 @@ static Elf64_Word * __init opalcore_append_cpu_notes(Elf64_Word *buf) fill_prstatus(&prstatus, thread_pir, ®s); if (thread_pir != oc_conf->crashing_cpu) { - buf = append_elf64_note(buf, CRASH_CORE_NOTE_NAME, + buf = append_elf64_note(buf, NN_PRSTATUS, NT_PRSTATUS, &prstatus, sizeof(prstatus)); } else { @@ -287,7 +287,7 @@ static Elf64_Word * __init opalcore_append_cpu_notes(Elf64_Word *buf) * Add crashing CPU as the first NT_PRSTATUS note for * GDB to process the core file appropriately. */ - append_elf64_note(first_cpu_note, CRASH_CORE_NOTE_NAME, + append_elf64_note(first_cpu_note, NN_PRSTATUS, NT_PRSTATUS, &prstatus, sizeof(prstatus)); } -- 2.47.1
[PATCH v2 4/5] crash: Use note name macros
Use note name macros to match with the userspace's expectation. Signed-off-by: Akihiko Odaki --- fs/proc/kcore.c | 12 ++-- include/linux/vmcore_info.h | 2 +- kernel/crash_core.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c index e376f48c4b8b..e5612313b8b4 100644 --- a/fs/proc/kcore.c +++ b/fs/proc/kcore.c @@ -34,8 +34,6 @@ #include #include "internal.h" -#define CORE_STR "CORE" - #ifndef ELF_CORE_EFLAGS #define ELF_CORE_EFLAGS0 #endif @@ -119,7 +117,9 @@ static size_t get_kcore_size(int *nphdr, size_t *phdrs_len, size_t *notes_len, *phdrs_len = *nphdr * sizeof(struct elf_phdr); *notes_len = (4 * sizeof(struct elf_note) + - 3 * ALIGN(sizeof(CORE_STR), 4) + + ALIGN(sizeof(NN_PRSTATUS), 4) + + ALIGN(sizeof(NN_PRPSINFO), 4) + + ALIGN(sizeof(NN_TASKSTRUCT), 4) + VMCOREINFO_NOTE_NAME_BYTES + ALIGN(sizeof(struct elf_prstatus), 4) + ALIGN(sizeof(struct elf_prpsinfo), 4) + @@ -444,11 +444,11 @@ static ssize_t read_kcore_iter(struct kiocb *iocb, struct iov_iter *iter) goto out; } - append_kcore_note(notes, &i, CORE_STR, NT_PRSTATUS, &prstatus, + append_kcore_note(notes, &i, NN_PRSTATUS, NT_PRSTATUS, &prstatus, sizeof(prstatus)); - append_kcore_note(notes, &i, CORE_STR, NT_PRPSINFO, &prpsinfo, + append_kcore_note(notes, &i, NN_PRPSINFO, NT_PRPSINFO, &prpsinfo, sizeof(prpsinfo)); - append_kcore_note(notes, &i, CORE_STR, NT_TASKSTRUCT, current, + append_kcore_note(notes, &i, NN_TASKSTRUCT, NT_TASKSTRUCT, current, arch_task_struct_size); /* * vmcoreinfo_size is mostly constant after init time, but it diff --git a/include/linux/vmcore_info.h b/include/linux/vmcore_info.h index e1dec1a6a749..1672801fd98c 100644 --- a/include/linux/vmcore_info.h +++ b/include/linux/vmcore_info.h @@ -8,7 +8,7 @@ #define CRASH_CORE_NOTE_NAME "CORE" #define CRASH_CORE_NOTE_HEAD_BYTES ALIGN(sizeof(struct elf_note), 4) -#define CRASH_CORE_NOTE_NAME_BYTES ALIGN(sizeof(CRASH_CORE_NOTE_NAME), 4) +#define CRASH_CORE_NOTE_NAME_BYTES ALIGN(sizeof(NN_PRSTATUS), 4) #define CRASH_CORE_NOTE_DESC_BYTES ALIGN(sizeof(struct elf_prstatus), 4) /* diff --git a/kernel/crash_core.c b/kernel/crash_core.c index 078fe5bc5a74..335b8425dd4b 100644 --- a/kernel/crash_core.c +++ b/kernel/crash_core.c @@ -436,7 +436,7 @@ void crash_save_cpu(struct pt_regs *regs, int cpu) memset(&prstatus, 0, sizeof(prstatus)); prstatus.common.pr_pid = current->pid; elf_core_copy_regs(&prstatus.pr_reg, regs); - buf = append_elf_note(buf, KEXEC_CORE_NOTE_NAME, NT_PRSTATUS, + buf = append_elf_note(buf, NN_PRSTATUS, NT_PRSTATUS, &prstatus, sizeof(prstatus)); final_note(buf); } -- 2.47.1
[PATCH v2 2/5] binfmt_elf: Use note name macros
Use note name macros to match with the userspace's expectation. Signed-off-by: Akihiko Odaki --- fs/binfmt_elf.c | 21 ++--- fs/binfmt_elf_fdpic.c | 8 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index 106f0e8af177..5b4a92e5e508 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c @@ -762,8 +762,7 @@ static int parse_elf_property(const char *data, size_t *off, size_t datasz, } #define NOTE_DATA_SZ SZ_1K -#define GNU_PROPERTY_TYPE_0_NAME "GNU" -#define NOTE_NAME_SZ (sizeof(GNU_PROPERTY_TYPE_0_NAME)) +#define NOTE_NAME_SZ (sizeof(NN_GNU_PROPERTY_TYPE_0)) static int parse_elf_properties(struct file *f, const struct elf_phdr *phdr, struct arch_elf_state *arch) @@ -800,7 +799,7 @@ static int parse_elf_properties(struct file *f, const struct elf_phdr *phdr, if (note.nhdr.n_type != NT_GNU_PROPERTY_TYPE_0 || note.nhdr.n_namesz != NOTE_NAME_SZ || strncmp(note.data + sizeof(note.nhdr), - GNU_PROPERTY_TYPE_0_NAME, n - sizeof(note.nhdr))) + NN_GNU_PROPERTY_TYPE_0, n - sizeof(note.nhdr))) return -ENOEXEC; off = round_up(sizeof(note.nhdr) + NOTE_NAME_SZ, @@ -1603,14 +1602,14 @@ static void fill_auxv_note(struct memelfnote *note, struct mm_struct *mm) do i += 2; while (auxv[i - 2] != AT_NULL); - fill_note(note, "CORE", NT_AUXV, i * sizeof(elf_addr_t), auxv); + fill_note(note, NN_AUXV, NT_AUXV, i * sizeof(elf_addr_t), auxv); } static void fill_siginfo_note(struct memelfnote *note, user_siginfo_t *csigdata, const kernel_siginfo_t *siginfo) { copy_siginfo_to_external(csigdata, siginfo); - fill_note(note, "CORE", NT_SIGINFO, sizeof(*csigdata), csigdata); + fill_note(note, NN_SIGINFO, NT_SIGINFO, sizeof(*csigdata), csigdata); } /* @@ -1706,7 +1705,7 @@ static int fill_files_note(struct memelfnote *note, struct coredump_params *cprm } size = name_curpos - (char *)data; - fill_note(note, "CORE", NT_FILE, size, data); + fill_note(note, NN_FILE, NT_FILE, size, data); return 0; } @@ -1767,7 +1766,7 @@ static int fill_thread_core_info(struct elf_thread_core_info *t, regset_get(t->task, &view->regsets[0], sizeof(t->prstatus.pr_reg), &t->prstatus.pr_reg); - fill_note(&t->notes[0], "CORE", NT_PRSTATUS, + fill_note(&t->notes[0], NN_PRSTATUS, NT_PRSTATUS, PRSTATUS_SIZE, &t->prstatus); info->size += notesize(&t->notes[0]); @@ -1801,7 +1800,7 @@ static int fill_thread_core_info(struct elf_thread_core_info *t, if (is_fpreg) SET_PR_FPVALID(&t->prstatus); - fill_note(&t->notes[note_iter], is_fpreg ? "CORE" : "LINUX", + fill_note(&t->notes[note_iter], is_fpreg ? NN_PRFPREG : "LINUX", note_type, ret, data); info->size += notesize(&t->notes[note_iter]); @@ -1821,7 +1820,7 @@ static int fill_thread_core_info(struct elf_thread_core_info *t, fill_prstatus(&t->prstatus.common, p, signr); elf_core_copy_task_regs(p, &t->prstatus.pr_reg); - fill_note(&t->notes[0], "CORE", NT_PRSTATUS, sizeof(t->prstatus), + fill_note(&t->notes[0], NN_PRSTATUS, NT_PRSTATUS, sizeof(t->prstatus), &(t->prstatus)); info->size += notesize(&t->notes[0]); @@ -1832,7 +1831,7 @@ static int fill_thread_core_info(struct elf_thread_core_info *t, } t->prstatus.pr_fpvalid = 1; - fill_note(&t->notes[1], "CORE", NT_PRFPREG, sizeof(*fpu), fpu); + fill_note(&t->notes[1], NN_PRFPREG, NT_PRFPREG, sizeof(*fpu), fpu); info->size += notesize(&t->notes[1]); return 1; @@ -1852,7 +1851,7 @@ static int fill_note_info(struct elfhdr *elf, int phdrs, psinfo = kmalloc(sizeof(*psinfo), GFP_KERNEL); if (!psinfo) return 0; - fill_note(&info->psinfo, "CORE", NT_PRPSINFO, sizeof(*psinfo), psinfo); + fill_note(&info->psinfo, NN_PRPSINFO, NT_PRPSINFO, sizeof(*psinfo), psinfo); #ifdef CORE_DUMP_USE_REGSET view = task_user_regset_view(dump_task); diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c index f1a7c4875c4a..96bd9d2f23d7 100644 --- a/fs/binfmt_elf_fdpic.c +++ b/fs/binfmt_elf_fdpic.c @@ -1397,7 +1397,7 @@ static struct elf_thread_status *elf_dump_thread_status(long signr, struct task_ regset_get(p, &view->regsets[0], sizeof(t->prstatus.pr_reg), &t->prstatus.pr_reg); - fill_note(&t->notes[0], "CORE", NT_PRSTATUS, sizeof(t->prstatus), + fill_note(&t->notes[0], NN_PRSTATUS, NT_PRSTATUS, sizeof(t->prstatus), &t->prstatus); t->num_notes++; *sz += notesize(&t->notes[0]); @@ -1415,7 +1415,7 @@ static struct elf_thread_status *elf_dum
Re: [PATCH net-next 04/13] net: enetc: add MAC filter for i.MX95 ENETC PF
On Fri, 3 Jan 2025 14:06:00 +0800 Wei Fang wrote: > The i.MX95 ENETC supports both MAC hash filter and MAC exact filter. MAC > hash filter is implenented through a 64-bits hash table to match against > the hashed addresses, PF and VFs each have two MAC hash tables, one is > for unicast and the other one is for multicast. But MAC exact filter is > shared between SIs (PF and VFs), each table entry contains a MAC address > that may be unicast or multicast and the entry also contains an SI bitmap > field that indicates for which SIs the entry is valid. > > For i.MX95 ENETC, MAC exact filter only has 4 entries. According to the > observation of the system default network configuration, the MAC filter > will be configured with multiple multicast addresses, so MAC exact filter > does not have enough entries to implement multicast filtering. Therefore, > the current MAC exact filter is only used for unicast filtering. If the > number of unicast addresses exceeds 4, then MAC hash filter is used. > > Note that both MAC hash filter and MAC exact filter can only be accessed > by PF, VFs can notify PF to set its corresponding MAC filter through the > mailbox mechanism of ENETC. But currently MAC filter is only added for > i.MX95 ENETC PF. The MAC filter support of ENETC VFs will be supported in > subsequent patches. clang reports: drivers/net/ethernet/freescale/enetc/enetc4_pf.c:1158:6: warning: variable 'pf' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized] 1158 | if (err) | ^~~ drivers/net/ethernet/freescale/enetc/enetc4_pf.c:1179:24: note: uninitialized use occurs here 1179 | enetc4_pf_struct_free(pf); | ^~ drivers/net/ethernet/freescale/enetc/enetc4_pf.c:1158:2: note: remove the 'if' if its condition is always false 1158 | if (err) | ^~~~ 1159 | goto err_wq_task_init; | ~ drivers/net/ethernet/freescale/enetc/enetc4_pf.c:1128:21: note: initialize the variable 'pf' to silence this warning 1128 | struct enetc_pf *pf; |^ | = NULL -- pw-bot: cr
Re: [PATCH 14/19] powerpc: mpc83xx: Switch to of_platform_populate
On Thu, Jan 02, 2025 at 12:51:47PM -0600, Rob Herring wrote: > On Thu, Jan 2, 2025 at 12:32 PM J. Neuschäfer via B4 Relay > wrote: > > > > From: "J. Neuschäfer" > > > > Quoting from drivers/of/platform.c: > > > > > of_platform_populate() - [...] > > > Similar to of_platform_bus_probe(), this function walks the device > > > tree and creates devices from nodes. It differs in that it follows > > > the modern convention of requiring all device nodes to have a > > > 'compatible' property, and it is suitable for creating devices which > > > are children of the root node (of_platform_bus_probe will only create > > > children of the root which are selected by the @matches argument). > > > > This is useful for new board ports because it means that the C code does > > not have to anticipate every node that is placed directly under the root. > > > > As a consequence, the of_bus_ids list can be much shorter, and I've > > trimmed it to the necessary parts: > > > > - device-type = "soc" and compatible = "simple-bus" for the SoC bus > > - compatible = "gianfar" for the Ethernet controller (TSEC), which > >may contain an MDIO bus, which needs to be probed, as a subnode > > > > Signed-off-by: J. Neuschäfer > > --- > > arch/powerpc/platforms/83xx/misc.c | 6 +- > > 1 file changed, 1 insertion(+), 5 deletions(-) > > > > diff --git a/arch/powerpc/platforms/83xx/misc.c > > b/arch/powerpc/platforms/83xx/misc.c > > index > > 1135c1ab923cc120f377a0d98767fef686cad1fe..bf522ee007bbb1429233355f668fc8563d8ca4e2 > > 100644 > > --- a/arch/powerpc/platforms/83xx/misc.c > > +++ b/arch/powerpc/platforms/83xx/misc.c > > @@ -94,18 +94,14 @@ void __init mpc83xx_ipic_init_IRQ(void) > > > > static const struct of_device_id of_bus_ids[] __initconst = { > > { .type = "soc", }, > > of_platform_populate() won't work on this match unless there's a > compatible in the node, too. Can we use compatible instead or are > there a bunch of them? In arch/powerpc/boot/dts, I can find the following cases of device_type = "soc" without compatible = "simple-bus": - arch/powerpc/boot/dts/tqm8xx.dts (MPC8xx) - arch/powerpc/boot/dts/mpc885ads.dts(MPC8xx) - arch/powerpc/boot/dts/mpc866ads.dts(MPC8xx) - arch/powerpc/boot/dts/ep88xc.dts (MPC8xx) - arch/powerpc/boot/dts/kuroboxHG.dts(MPC82xx) - arch/powerpc/boot/dts/kuroboxHD.dts(MPC82xx) - arch/powerpc/boot/dts/storcenter.dts (MPC82xx) - arch/powerpc/boot/dts/asp834x-redboot.dts (MPC83xx!) - arch/powerpc/boot/dts/ksi8560.dts (MPC85xx) i.e. there is one affected devicetree. I can simply patch that one in the next iteration. > > > - { .compatible = "soc", }, > > { .compatible = "simple-bus" }, > > { .compatible = "gianfar" }, > > - { .compatible = "gpio-leds", }, > > - { .type = "qe", }, > > - { .compatible = "fsl,qe", }, > > Better still would be if we could move the remaining ones to the > default table and just call of_platform_default_populate(). of_platform_default_populate does sound preferable. I'll investigate why exactly the "gianfar" match is necessary and how to fix it in the corresponding driver (I don't think it's general enough to warrant being listed in of_default_bus_match_table). Best regards, jn
Re: [PATCH 3/6] powerpc/pseries: Add papr-indices char driver for ibm,get-indices HCALL
Hi Haren, kernel test robot noticed the following build warnings: [auto build test WARNING on powerpc/next] [also build test WARNING on powerpc/fixes linus/master v6.13-rc5 next-20241220] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Haren-Myneni/powerpc-pseries-Define-common-functions-for-RTAS-sequence-HCALLs/20250105-045010 base: https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git next patch link: https://lore.kernel.org/r/20250104204652.388720-4-haren%40linux.ibm.com patch subject: [PATCH 3/6] powerpc/pseries: Add papr-indices char driver for ibm,get-indices HCALL config: powerpc64-randconfig-002-20250105 (https://download.01.org/0day-ci/archive/20250105/202501051117.d90y1vns-...@intel.com/config) compiler: clang version 20.0.0git (https://github.com/llvm/llvm-project 096551537b2a747a3387726ca618ceeb3950e9bc) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250105/202501051117.d90y1vns-...@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot | Closes: https://lore.kernel.org/oe-kbuild-all/202501051117.d90y1vns-...@intel.com/ All warnings (new ones prefixed by >>): >> arch/powerpc/platforms/pseries/papr-indices.c:45: warning: expecting >> prototype for struct rtas_ibm_get_indices_params. Prototype was for struct >> rtas_get_indices_params instead >> arch/powerpc/platforms/pseries/papr-indices.c:210: warning: This comment >> starts with '/**', but isn't a kernel-doc comment. Refer >> Documentation/doc-guide/kernel-doc.rst * Work function to be passed to papr_rtas_blob_generate(). >> arch/powerpc/platforms/pseries/papr-indices.c:247: warning: Function >> parameter or struct member 'file' not described in 'papr_indices_handle_read' >> arch/powerpc/platforms/pseries/papr-indices.c:247: warning: Function >> parameter or struct member 'buf' not described in 'papr_indices_handle_read' >> arch/powerpc/platforms/pseries/papr-indices.c:247: warning: Function >> parameter or struct member 'size' not described in 'papr_indices_handle_read' >> arch/powerpc/platforms/pseries/papr-indices.c:247: warning: Function >> parameter or struct member 'off' not described in 'papr_indices_handle_read' vim +45 arch/powerpc/platforms/pseries/papr-indices.c 29 30 /** 31 * struct rtas_ibm_get_indices_params - Parameters (in and out) for 32 * ibm,get-indices. 33 * @is_sensor: In: Caller-provided whether sensor or indicator. 34 * @indice_type:In: Caller-provided indice (sensor or indicator) token 35 * @work_area: In: Caller-provided work area buffer for results. 36 * @next: In: Sequence number. Out: Next sequence number. 37 * @status: Out: RTAS call status. 38 */ 39 struct rtas_get_indices_params { 40 u8 is_sensor; 41 u32 indice_type; 42 struct rtas_work_area *work_area; 43 u32 next; 44 s32 status; > 45 }; 46 47 /** 48 * rtas_ibm_get_indices() - Call ibm,get-indices to fill a work area buffer. 49 * @params: See &struct rtas_ibm_get_indices_params. 50 * 51 * Calls ibm,get-indices until it errors or successfully deposits data 52 * into the supplied work area. Handles RTAS retry statuses. Maps RTAS 53 * error statuses to reasonable errno values. 54 * 55 * The caller is expected to invoke rtas_ibm_get_indices() multiple times 56 * to retrieve all indices data for the provided indice type. Only one 57 * sequence should be in progress at any time; starting a new sequence 58 * will disrupt any sequence already in progress. Serialization of 59 * indices retrieval sequences is the responsibility of the caller. 60 * 61 * The caller should inspect @params.status to determine whether more 62 * calls are needed to complete the sequence. 63 * 64 * Context: May sleep. 65 * Return: -ve on error, 0 otherwise. 66 */ 67 static int rtas_ibm_get_indices(struct rtas_get_indices_params *params) 68 { 69 struct rtas_work_area *work_area = params->work_area; 70 const s32 token = rtas_function_token(RTAS_FN_IBM_GET_INDICES); 71 u32 rets; 72 s32 fwrc; 73 int ret; 74 75 if (token == RTAS_UNKNOWN_SERVICE) 76 return -ENOENT; 77 78 lockdep_assert_held(&rtas_ibm_get_indices_lock); 79 80 do { 81 fwrc = rtas_call(token, 5, 2, &rets, params->is_sensor, 82
Re: [PATCH 13/19] gpio: mpc8xxx: Add MPC8314 support
On Thu, Jan 02, 2025 at 10:38:22PM +0100, Linus Walleij wrote: > On Thu, Jan 2, 2025 at 7:32 PM J. Neuschäfer via B4 Relay > wrote: > > > From: "J. Neuschäfer" > > > > GPIO input, output, and interrupts have been tested on a MPC8314E board. > > > > Signed-off-by: J. Neuschäfer > > Reviewed-by: Linus Walleij > > Can Bartosz simply apply this and the binding patch and get these > two patches off our tail? Yes, I think that's a good idea. I'll update my To/Cc list afterwards. -- jn