[PATCH v2] powerpc/pseries/lparcfg: drop error message from guest name lookup

2024-05-24 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch It's not an error or exceptional situation when the hosting environment does not expose a name for the LP/guest via RTAS or the device tree. This happens with qemu when run without the '-name' option. The message also lacks a newline. Remove it. Signed-off-by: Nathan Lynch

[PATCH] powerpc/pseries: Enforce hcall result buffer validity and size

2024-04-08 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch plpar_hcall(), plpar_hcall9(), and related functions expect callers to provide valid result buffers of certain minimum size. Currently this is communicated only through comments in the code and the compiler has no idea. For example, if I write a bug like this: long

[PATCH v2] selftests/powerpc/papr-vpd: Fix missing variable initialization

2024-04-04 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch The "close handle without consuming VPD" testcase has inconsistent results because it fails to initialize the location code object it passes to ioctl() to create a VPD handle. Initialize the location code to the empty string as intended. Signed-off-by: Nathan Lynch

[PATCH] selftests/powerpc/papr-vpd: Fix missing variable initialization

2024-04-04 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch The "close handle without consuming VPD" testcase has inconsistent results because it fails to initialize the location code object it passes to ioctl() to create a VPD handle. Initialize the location code to the empty string as intended. Signed-off-by: Nathan Lynch ---

[PATCH] powerpc/rtas: use correct function name for resetting TCE tables

2024-02-22 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch The PAPR spec spells the function name as "ibm,reset-pe-dma-windows" but in practice firmware uses the singular form: "ibm,reset-pe-dma-window" in the device tree. Since we have the wrong spelling in the RTAS function table, reverse lookups (token -> name) fail and

[PATCH] powerpc/pseries/papr-sysparm: use u8 arrays for payloads

2024-02-02 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch Some PAPR system parameter values are formatted by firmware as nul-terminated strings (e.g. LPAR name, shared processor attributes). But the values returned for other parameters, such as processor module info and TLB block invalidate characteristics, are binary data with

[PATCH RFC 0/5] dump_stack: Allow runtime updates of the hardware description

2024-01-18 Thread Nathan Lynch via B4 Relay
When the kernel emits a stack trace, typically it includes a hardware description string, e.g. Kernel panic - not syncing: sysrq triggered crash CPU: 6 PID: 46433 Comm: bash Tainted: GW 6.7.0-rc2+ #83 > Hardware name: IBM,9040-MR9 POWER9 (architected) 0x4e2102 0xf05 >

[PATCH RFC 5/5] powerpc/pseries: Update hardware description string after migration

2024-01-18 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch Introduce code that rebuilds the short hardware description printed by stack traces. This sort of duplicates some code from boot (prom.c mainly), but that code populates the string as early as possible using APIs that aren't available later. So sharing all the code between the

[PATCH RFC 2/5] dump_stack: Allow update of arch description string at runtime

2024-01-18 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch The IBM PowerVM platform (targeted by powerpc/pseries) exposes the physical machine model and firmware version to partitions (guests), and this information is used to populate the arch description string, e.g. IBM,8408-E8E POWER8E (raw) 0x4b0201 0xf04 \

[PATCH RFC 3/5] powerpc/prom: Add CPU info to hardware description string later

2024-01-18 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch cur_cpu_spec->cpu_name is appended to ppc_hw_desc before cur_cpu_spec has taken on its final value. This is illustrated on pseries by comparing the CPU name as reported at boot ("POWER8E (raw)") to the contents of /proc/cpuinfo ("POWER8 (architected)"): $ dmesg | grep

[PATCH RFC 4/5] powerpc/pseries: Prepare pseries_add_hw_description() for runtime use

2024-01-18 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch pseries_add_hw_description() will be used after boot to update the hardware description string emitted in stack dumps. Remove the __init and make it take a seq_buf * parameter instead of referencing ppc_hw_desc directly. Signed-off-by: Nathan Lynch ---

[PATCH RFC 1/5] dump_stack: Make arch description buffer __ro_after_init

2024-01-18 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch The static hardware description buffer is populated by arch code during boot and should not change afterwards, so mark it __ro_after_init. Signed-off-by: Nathan Lynch --- lib/dump_stack.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/dump_stack.c

[PATCH RFC] powerpc/pseries: exploit H_PAGE_SET_UNUSED for partition migration

2024-01-11 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch Although the H_PAGE_INIT hcall's H_PAGE_SET_UNUSED historically has been tied to the cooperative memory overcommit (CMO) platform feature, the flag also is treated by the PowerVM hypervisor as a hint that the page contents need not be copied to the destination during a live

[PATCH] powerpc/pseries/lparcfg: drop error message from guest name lookup

2024-01-04 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch It's not an error or exceptional situation when the hosting environment does not expose a name for the LP/guest via RTAS or the device tree. This happens with qemu when run without the '-name' option. The message also lacks a newline. Remove it. Signed-off-by: Nathan Lynch

[PATCH v6 13/13] powerpc/selftests: Add test for papr-sysparm

2023-12-12 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch Consistently testing system parameter access is a bit difficult by nature -- the set of parameters available depends on the model and system configuration, and updating a parameter should be considered a destructive operation reserved for the admin. So we validate some of the

[PATCH v6 12/13] powerpc/selftests: Add test for papr-vpd

2023-12-12 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch Add selftests for /dev/papr-vpd, exercising the common expected use cases: * Retrieve all VPD by passing an empty location code. * Retrieve the "system VPD" by passing a location code derived from DT root node properties, as done by the vpdupdate command. The tests also

[PATCH v6 11/13] powerpc/pseries/papr-sysparm: Expose character device to user space

2023-12-12 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch Until now the papr_sysparm APIs have been kernel-internal. But user space needs access to PAPR system parameters too. The only method available to user space today to get or set system parameters is using sys_rtas() and /dev/mem to pass RTAS-addressable buffers between user

[PATCH v6 06/13] powerpc/rtas: Facilitate high-level call sequences

2023-12-12 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch On RTAS platforms there is a general restriction that the OS must not enter RTAS on more than one CPU at a time. This low-level serialization requirement is satisfied by holding a spin lock (rtas_lock) across most RTAS function invocations. However, some pseries RTAS

[PATCH v6 10/13] powerpc/pseries/papr-sysparm: Validate buffer object lengths

2023-12-12 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch The ability to get and set system parameters will be exposed to user space, so let's get a little more strict about malformed papr_sysparm_buf objects. * Create accessors for the length field of struct papr_sysparm_buf. The length is always stored in MSB order and this is

[PATCH v6 09/13] powerpc/pseries: Add papr-vpd character driver for VPD retrieval

2023-12-12 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch PowerVM LPARs may retrieve Vital Product Data (VPD) for system components using the ibm,get-vpd RTAS function. We can expose this to user space with a /dev/papr-vpd character device, where the programming model is: struct papr_location_code plc = { .str = "", }; /* obtain

[PATCH v6 08/13] powerpc/rtas: Warn if per-function lock isn't held

2023-12-12 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch If the function descriptor has a populated lock member, then callers are required to hold it across calls. Now that the firmware activation sequence is appropriately guarded, we can warn when the requirement isn't satisfied. __do_enter_rtas_trace() gets reorganized a bit as a

[PATCH v6 02/13] powerpc/rtas: Add for_each_rtas_function() iterator

2023-12-12 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch Add a convenience macro for iterating over every element of the internal function table and convert the one site that can use it. An additional user of the macro is anticipated in changes to follow. Reviewed-by: Aneesh Kumar K.V (IBM) Signed-off-by: Nathan Lynch ---

[PATCH v6 04/13] powerpc/rtas: Add function return status constants

2023-12-12 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch Not all of the generic RTAS function statuses specified in PAPR have symbolic constants and descriptions in rtas.h. Fix this, providing a little more background, slightly updating the existing wording, and improving the formatting. Reviewed-by: Aneesh Kumar K.V (IBM)

[PATCH v6 03/13] powerpc/rtas: Fall back to linear search on failed token->function lookup

2023-12-12 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch Enabling any of the powerpc:rtas_* tracepoints at boot is likely to result in an oops on RTAS platforms. For example, booting a QEMU pseries model with 'trace_event=powerpc:rtas_input' in the command line leads to: BUG: Kernel NULL pointer dereference on read at 0x0008

[PATCH v6 00/13] powerpc/pseries: New character devices for system parameters and VPD

2023-12-12 Thread Nathan Lynch via B4 Relay
Add character devices that expose PAPR-specific system parameters and VPD to user space. The problem: important platform features are enabled on Linux VMs through the powerpc-specific rtas() syscall in combination with writeable mappings of /dev/mem. In typical usage, this is encapsulated behind

[PATCH v6 01/13] powerpc/rtas: Avoid warning on invalid token argument to sys_rtas()

2023-12-12 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch rtas_token_to_function() WARNs when passed an invalid token; it's meant to catch bugs in kernel-based users of RTAS functions. However, user space controls the token value passed to rtas_token_to_function() by block_rtas_call(), so user space with sufficient privilege to use

[PATCH v6 07/13] powerpc/rtas: Serialize firmware activation sequences

2023-12-12 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch Use rtas_ibm_activate_firmware_lock to prevent interleaving call sequences of the ibm,activate-firmware RTAS function, which typically requires multiple calls to complete the update. While the spec does not specifically prohibit interleaved sequences, there's almost certainly

[PATCH v6 05/13] powerpc/rtas: Move token validation from block_rtas_call() to sys_rtas()

2023-12-12 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch The rtas system call handler sys_rtas() delegates certain input validation steps to a helper function: block_rtas_call(). One of these steps ensures that the user-supplied token value maps to a known RTAS function. This is done by performing a "reverse" token-to-function

[PATCH v5 09/13] powerpc/pseries: Add papr-vpd character driver for VPD retrieval

2023-12-07 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch PowerVM LPARs may retrieve Vital Product Data (VPD) for system components using the ibm,get-vpd RTAS function. We can expose this to user space with a /dev/papr-vpd character device, where the programming model is: struct papr_location_code plc = { .str = "", }; /* obtain

[PATCH v5 12/13] powerpc/selftests: Add test for papr-vpd

2023-12-07 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch Add selftests for /dev/papr-vpd, exercising the common expected use cases: * Retrieve all VPD by passing an empty location code. * Retrieve the "system VPD" by passing a location code derived from DT root node properties, as done by the vpdupdate command. The tests also

[PATCH v5 13/13] powerpc/selftests: Add test for papr-sysparm

2023-12-07 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch Consistently testing system parameter access is a bit difficult by nature -- the set of parameters available depends on the model and system configuration, and updating a parameter should be considered a destructive operation reserved for the admin. So we validate some of the

[PATCH v5 00/13] powerpc/pseries: New character devices for system parameters and VPD

2023-12-07 Thread Nathan Lynch via B4 Relay
Add character devices that expose PAPR-specific system parameters and VPD to user space. The problem: important platform features are enabled on Linux VMs through the powerpc-specific rtas() syscall in combination with writeable mappings of /dev/mem. In typical usage, this is encapsulated behind

[PATCH v5 03/13] powerpc/rtas: Fall back to linear search on failed token->function lookup

2023-12-07 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch Enabling any of the powerpc:rtas_* tracepoints at boot is likely to result in an oops on RTAS platforms. For example, booting a QEMU pseries model with 'trace_event=powerpc:rtas_input' in the command line leads to: BUG: Kernel NULL pointer dereference on read at 0x0008

[PATCH v5 05/13] powerpc/rtas: Move token validation from block_rtas_call() to sys_rtas()

2023-12-07 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch The rtas system call handler sys_rtas() delegates certain input validation steps to a helper function: block_rtas_call(). One of these steps ensures that the user-supplied token value maps to a known RTAS function. This is done by performing a "reverse" token-to-function

[PATCH v5 11/13] powerpc/pseries/papr-sysparm: Expose character device to user space

2023-12-07 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch Until now the papr_sysparm APIs have been kernel-internal. But user space needs access to PAPR system parameters too. The only method available to user space today to get or set system parameters is using sys_rtas() and /dev/mem to pass RTAS-addressable buffers between user

[PATCH v5 07/13] powerpc/rtas: Serialize firmware activation sequences

2023-12-07 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch Use rtas_ibm_activate_firmware_lock to prevent interleaving call sequences of the ibm,activate-firmware RTAS function, which typically requires multiple calls to complete the update. While the spec does not specifically prohibit interleaved sequences, there's almost certainly

[PATCH v5 01/13] powerpc/rtas: Avoid warning on invalid token argument to sys_rtas()

2023-12-07 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch rtas_token_to_function() WARNs when passed an invalid token; it's meant to catch bugs in kernel-based users of RTAS functions. However, user space controls the token value passed to rtas_token_to_function() by block_rtas_call(), so user space with sufficient privilege to use

[PATCH v5 02/13] powerpc/rtas: Add for_each_rtas_function() iterator

2023-12-07 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch Add a convenience macro for iterating over every element of the internal function table and convert the one site that can use it. An additional user of the macro is anticipated in changes to follow. Reviewed-by: Aneesh Kumar K.V (IBM) Signed-off-by: Nathan Lynch ---

[PATCH v5 10/13] powerpc/pseries/papr-sysparm: Validate buffer object lengths

2023-12-07 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch The ability to get and set system parameters will be exposed to user space, so let's get a little more strict about malformed papr_sysparm_buf objects. * Create accessors for the length field of struct papr_sysparm_buf. The length is always stored in MSB order and this is

[PATCH v5 08/13] powerpc/rtas: Warn if per-function lock isn't held

2023-12-07 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch If the function descriptor has a populated lock member, then callers are required to hold it across calls. Now that the firmware activation sequence is appropriately guarded, we can warn when the requirement isn't satisfied. __do_enter_rtas_trace() gets reorganized a bit as a

[PATCH v5 04/13] powerpc/rtas: Add function return status constants

2023-12-07 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch Not all of the generic RTAS function statuses specified in PAPR have symbolic constants and descriptions in rtas.h. Fix this, providing a little more background, slightly updating the existing wording, and improving the formatting. Reviewed-by: Aneesh Kumar K.V (IBM)

[PATCH v5 06/13] powerpc/rtas: Facilitate high-level call sequences

2023-12-07 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch On RTAS platforms there is a general restriction that the OS must not enter RTAS on more than one CPU at a time. This low-level serialization requirement is satisfied by holding a spin lock (rtas_lock) across most RTAS function invocations. However, some pseries RTAS

[PATCH] powerpc/rtas_pci: rename and properly expose config access APIs

2023-11-27 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch The rtas_read_config() and rtas_write_config() functions in kernel/rtas_pci.c have external linkage and two users in arch/powerpc: the rtas_pci code itself and the pseries platform's "enhanced error handling" (EEH) support code. The prototypes for these functions in

[PATCH v4 04/13] powerpc/rtas: Factor out function descriptor lookup

2023-11-17 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch Move the function descriptor table lookup out of rtas_function_token() into a separate routine for use in new code to follow. No functional change. Signed-off-by: Nathan Lynch --- arch/powerpc/kernel/rtas.c | 31 +++ 1 file changed, 19

[PATCH v4 02/13] powerpc/rtas: Fall back to linear search on failed token->function lookup

2023-11-17 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch Enabling any of the powerpc:rtas_* tracepoints at boot is likely to result in an oops on RTAS platforms. For example, booting a QEMU pseries model with 'trace_event=powerpc:rtas_input' in the command line leads to: BUG: Kernel NULL pointer dereference on read at 0x0008

[PATCH v4 08/13] powerpc/uapi: Export papr-miscdev.h header

2023-11-17 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch Allocate one identifying code (the first column of the ioctl-number table) for the collection of PAPR miscdev drivers to share. Signed-off-by: Nathan Lynch --- arch/powerpc/include/uapi/asm/papr-miscdev.h | 9 + 1 file changed, 9 insertions(+) diff --git

[PATCH v4 06/13] powerpc/rtas: Serialize firmware activation sequences

2023-11-17 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch Use the function lock API to prevent interleaving call sequences of the ibm,activate-firmware RTAS function, which typically requires multiple calls to complete the update. While the spec does not specifically prohibit interleaved sequences, there's almost certainly no

[PATCH v4 09/13] powerpc/pseries: Add papr-vpd character driver for VPD retrieval

2023-11-17 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch PowerVM LPARs may retrieve Vital Product Data (VPD) for system components using the ibm,get-vpd RTAS function. We can expose this to user space with a /dev/papr-vpd character device, where the programming model is: struct papr_location_code plc = { .str = "", }; /* obtain

[PATCH v4 11/13] powerpc/pseries/papr-sysparm: Expose character device to user space

2023-11-17 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch Until now the papr_sysparm APIs have been kernel-internal. But user space needs access to PAPR system parameters too. The only method available to user space today to get or set system parameters is using sys_rtas() and /dev/mem to pass RTAS-addressable buffers between user

[PATCH v4 12/13] powerpc/selftests: Add test for papr-vpd

2023-11-17 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch Add selftests for /dev/papr-vpd, exercising the common expected use cases: * Retrieve all VPD by passing an empty location code. * Retrieve the "system VPD" by passing a location code derived from DT root node properties, as done by the vpdupdate command. The tests also

[PATCH v4 13/13] powerpc/selftests: Add test for papr-sysparm

2023-11-17 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch Consistently testing system parameter access is a bit difficult by nature -- the set of parameters available depends on the model and system configuration, and updating a parameter should be considered a destructive operation reserved for the admin. So we validate some of the

[PATCH v4 01/13] powerpc/rtas: Add for_each_rtas_function() iterator

2023-11-17 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch Add a convenience macro for iterating over every element of the internal function table and convert the one site that can use it. An additional user of the macro is anticipated in changes to follow. Signed-off-by: Nathan Lynch --- arch/powerpc/kernel/rtas.c | 9 +++-- 1

[PATCH v4 00/13] powerpc/pseries: New character devices for system parameters and VPD

2023-11-17 Thread Nathan Lynch via B4 Relay
Add character devices that expose PAPR-specific system parameters and VPD to user space. The problem: important platform features are enabled on Linux VMs through the powerpc-specific rtas() syscall in combination with writeable mappings of /dev/mem. In typical usage, this is encapsulated behind

[PATCH v4 05/13] powerpc/rtas: Facilitate high-level call sequences

2023-11-17 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch On RTAS platforms there is a general restriction that the OS must not enter RTAS on more than one CPU at a time. This low-level serialization requirement is satisfied by holding a spin lock (rtas_lock) across most RTAS function invocations. However, some pseries RTAS

[PATCH v4 03/13] powerpc/rtas: Add function return status constants

2023-11-17 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch Not all of the generic RTAS function statuses specified in PAPR have symbolic constants and descriptions in rtas.h. Fix this, providing a little more background, slightly updating the existing wording, and improving the formatting. Signed-off-by: Nathan Lynch ---

[PATCH v4 10/13] powerpc/pseries/papr-sysparm: Validate buffer object lengths

2023-11-17 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch The ability to get and set system parameters will be exposed to user space, so let's get a little more strict about malformed papr_sysparm_buf objects. * Create accessors for the length field of struct papr_sysparm_buf. The length is always stored in MSB order and this is

[PATCH v4 07/13] powerpc/rtas: Warn if per-function lock isn't held

2023-11-17 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch If the function descriptor has a populated lock member, then callers are required to hold it across calls. Now that the firmware activation sequence is appropriately guarded, we can warn when the requirement isn't satisfied. __do_enter_rtas_trace() gets reorganized a bit as a

[PATCH v2 2/5] powerpc/rtas: Remove unused rtas_service_present()

2023-11-14 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch rtas_service_present() has no more users. rtas_function_implemented() is now the appropriate API for determining whether a given RTAS function is available to call. Signed-off-by: Nathan Lynch --- arch/powerpc/include/asm/rtas.h | 1 - arch/powerpc/kernel/rtas.c | 5

[PATCH v2 5/5] powerpc/rtas: Remove 'extern' from function declarations in rtas.h

2023-11-14 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch This header occasionally gains new function declarations without the leading extern in accordance with current style rules. Leaving the legacy externs in place is making the header more difficult to read over time because of the inconsistency. Remove them, fixing up checkpatch

[PATCH v2 3/5] powerpc/rtas: Move post_mobility_fixup() declaration to pseries

2023-11-14 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch This is a pseries-specific function declaration that doesn't belong in rtas.h. Move it to the pseries platform code and adjust pseries/suspend.c accordingly. Signed-off-by: Nathan Lynch --- arch/powerpc/include/asm/rtas.h | 1 -

[PATCH v2 0/5] powerpc/rtas: Trivial and coding style fixes

2023-11-14 Thread Nathan Lynch via B4 Relay
* Make minor coding style adjustments for readability. * Remove rtas_service_present() and an old call_rtas() declaration. * Move a pseries-specific function prototype to pseries code. --- Changes in v2: - Address various checkpatch issues missed in v1. - Drop kernel-doc fixes already applied. -

[PATCH v2 1/5] powerpc/rtas: Drop declaration of undefined call_rtas() function

2023-11-14 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch The call_rtas() function has never been a part of arch/powerpc, and its implementation was removed from arch/ppc by commit 0a26b1364f14 ("ppc: Remove CHRP, POWER3 and POWER4 support from arch/ppc"). Signed-off-by: Nathan Lynch --- arch/powerpc/include/asm/rtas.h | 2 -- 1

[PATCH v2 4/5] powerpc/rtas: Remove trailing space

2023-11-14 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch Use scripts/cleanfile to remove instances of trailing space in the core RTAS code and header. Signed-off-by: Nathan Lynch --- arch/powerpc/include/asm/rtas.h | 6 +++--- arch/powerpc/kernel/rtas.c | 18 +- 2 files changed, 12 insertions(+), 12

[PATCH 0/3] powerpc/pseries/memhp: Fix minor bugs and improve error logging

2023-11-14 Thread Nathan Lynch via B4 Relay
This includes a fix for an array bounds read overrun that can be triggered when debug messages are enabled. --- Nathan Lynch (3): powerpc/pseries/memhp: Fix access beyond end of drmem array powerpc/pseries/memhp: Remove unbalanced dlpar_release_drc() call powerpc/pseries/memhp:

[PATCH 3/3] powerpc/pseries/memhp: Log more error conditions in add path

2023-11-14 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch When an add operation for multiple LMBs fails, there is currently little indication from the kernel of what went wrong. Be a little more verbose about error conditions in the add paths. Signed-off-by: Nathan Lynch --- arch/powerpc/platforms/pseries/hotplug-memory.c | 7

[PATCH 1/3] powerpc/pseries/memhp: Fix access beyond end of drmem array

2023-11-14 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch dlpar_memory_remove_by_index() may access beyond the bounds of the drmem lmb array when the LMB lookup fails to match an entry with the given DRC index. When the search fails, the cursor is left pointing to _info->lmbs[drmem_info->n_lmbs], which is one element past the last

[PATCH 2/3] powerpc/pseries/memhp: Remove unbalanced dlpar_release_drc() call

2023-11-14 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch Callers of dlpar_add_lmb() are responsible for first acquiring the DRC and releasing it if dlpar_add_lmb() fails. However, dlpar_add_lmb() performs a dlpar_release_drc() in one error branch. There is no corresponding dlpar_acquire_drc() in the function, nor is there any

[PATCH 5/7] powerpc/rtas: Move post_mobility_fixup() declaration to pseries

2023-11-06 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch This is a pseries-specific function declaration that doesn't belong in rtas.h. Move it to the pseries platform code and adjust pseries/suspend.c accordingly. Signed-off-by: Nathan Lynch --- arch/powerpc/include/asm/rtas.h | 1 -

[PATCH 3/7] powerpc/rtas: Drop declaration of undefined call_rtas() function

2023-11-06 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch The call_rtas() function has never been a part of arch/powerpc, and its implementation was removed from arch/ppc by 0a26b1364f14 ("ppc: Remove CHRP, POWER3 and POWER4 support from arch/ppc"). Signed-off-by: Nathan Lynch --- arch/powerpc/include/asm/rtas.h | 2 -- 1 file

[PATCH 0/7] powerpc/rtas: Trivial, coding style, and kernel-doc fixes

2023-11-06 Thread Nathan Lynch via B4 Relay
* Fix recently introduced kernel-doc warnings. * Make minor coding style adjustments for readability. * Remove rtas_service_present() and an old call_rtas() declaration. * Move a pseries-specific function prototype to pseries code. --- Nathan Lynch (7): powerpc/pseries/rtas-work-area: Fix

[PATCH 6/7] powerpc/rtas: Remove trailing space

2023-11-06 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch Use scripts/cleanfile to remove instances of trailing space in the core RTAS code and header. Signed-off-by: Nathan Lynch --- arch/powerpc/include/asm/rtas.h | 6 +++--- arch/powerpc/kernel/rtas.c | 18 +- 2 files changed, 12 insertions(+), 12

[PATCH 4/7] powerpc/rtas: Remove unused rtas_service_present()

2023-11-06 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch rtas_service_present() has no more users. rtas_function_implemented() is now the appropriate API for determining whether a given RTAS function is available to call. Signed-off-by: Nathan Lynch --- arch/powerpc/include/asm/rtas.h | 1 - arch/powerpc/kernel/rtas.c | 5

[PATCH 1/7] powerpc/pseries/rtas-work-area: Fix rtas_work_area_reserve_arena() kernel-doc

2023-11-06 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch >From a W=1 build: >> arch/powerpc/platforms/pseries/rtas-work-area.c:189: warning: Function >> parameter or member 'limit' not >> described in 'rtas_work_area_reserve_arena' Add the missing description of the limit parameter. Signed-off-by: Nathan Lynch Reported-by:

[PATCH 7/7] powerpc/rtas: Remove 'extern' from function declarations in rtas.h

2023-11-06 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch This header occasionally gains new function declarations without the leading extern in accordance with current style rules. Leaving the legacy externs in place is making the header more difficult to read over time because of the inconsistency. Remove them. Signed-off-by:

[PATCH 2/7] powerpc/rtas: Fix ppc_rtas_rmo_buf_show() kernel-doc

2023-11-06 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch >From a W=1 build: >> arch/powerpc/kernel/rtas-proc.c:771: warning: Function parameter or member >> 'm' not described in >> 'ppc_rtas_rmo_buf_show' >> arch/powerpc/kernel/rtas-proc.c:771: warning: Function parameter or member >> 'v' not described in >>

[PATCH v3 10/10] powerpc/selftests: Add test for papr-sysparm

2023-10-25 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch Consistently testing system parameter access is a bit difficult by nature -- the set of parameters available depends on the model and system configuration, and updating a parameter should be considered a destructive operation reserved for the admin. So we validate some of the

[PATCH v3 04/10] powerpc/rtas: Warn if per-function lock isn't held

2023-10-25 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch If the function descriptor has a populated lock member, then callers are required to hold it across calls. Now that the firmware activation sequence is appropriately guarded, we can warn when the requirement isn't satisfied. __do_enter_rtas_trace() gets reorganized a bit as a

[PATCH v3 06/10] powerpc/pseries: Add papr-vpd character driver for VPD retrieval

2023-10-25 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch PowerVM LPARs may retrieve Vital Product Data (VPD) for system components using the ibm,get-vpd RTAS function. We can expose this to user space with a /dev/papr-vpd character device, where the programming model is: struct papr_location_code plc = { .str = "", }; /* obtain

[PATCH v3 03/10] powerpc/rtas: Serialize firmware activation sequences

2023-10-25 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch Use the function lock API to prevent interleaving call sequences of the ibm,activate-firmware RTAS function, which typically requires multiple calls to complete the update. While the spec does not specifically prohibit interleaved sequences, there's almost certainly no

[PATCH v3 00/10] powerpc/pseries: New character devices for system parameters and VPD

2023-10-25 Thread Nathan Lynch via B4 Relay
Add character devices that expose PAPR-specific system parameters and VPD to user space. The problem: important platform features are enabled on Linux VMs through the powerpc-specific rtas() syscall in combination with writeable mappings of /dev/mem. In typical usage, this is encapsulated behind

[PATCH v3 01/10] powerpc/rtas: Factor out function descriptor lookup

2023-10-25 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch Move the function descriptor table lookup out of rtas_function_token() into a separate routine for use in new code to follow. No functional change. Signed-off-by: Nathan Lynch --- arch/powerpc/kernel/rtas.c | 31 +++ 1 file changed, 19

[PATCH v3 09/10] powerpc/selftests: Add test for papr-vpd

2023-10-25 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch Add selftests for /dev/papr-vpd, exercising the common expected use cases: * Retrieve all VPD by passing an empty location code. * Retrieve the "system VPD" by passing a location code derived from DT root node properties, as done by the vpdupdate command. The tests also

[PATCH v3 02/10] powerpc/rtas: Facilitate high-level call sequences

2023-10-25 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch On RTAS platforms there is a general restriction that the OS must not enter RTAS on more than one CPU at a time. This low-level serialization requirement is satisfied by holding a spin lock (rtas_lock) across most RTAS function invocations. However, some pseries RTAS

[PATCH v3 07/10] powerpc/pseries/papr-sysparm: Validate buffer object lengths

2023-10-25 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch The ability to get and set system parameters will be exposed to user space, so let's get a little more strict about malformed papr_sysparm_buf objects. * Create accessors for the length field of struct papr_sysparm_buf. The length is always stored in MSB order and this is

[PATCH v3 05/10] powerpc/uapi: Export papr-miscdev.h header

2023-10-25 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch Allocate one identifying code (the first column of the ioctl-number table) for the collection of PAPR miscdev drivers to share. Signed-off-by: Nathan Lynch --- arch/powerpc/include/uapi/asm/papr-miscdev.h | 9 + 1 file changed, 9 insertions(+) diff --git

[PATCH v3 08/10] powerpc/pseries/papr-sysparm: Expose character device to user space

2023-10-25 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch Until now the papr_sysparm APIs have been kernel-internal. But user space needs access to PAPR system parameters too. The only method available to user space today to get or set system parameters is using sys_rtas() and /dev/mem to pass RTAS-addressable buffers between user

[PATCH v2 7/7] powerpc/selftests: add test for papr-sysparm

2023-10-13 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch Consistently testing system parameter access is a bit difficult by nature -- the set of parameters available depends on the model and system configuration, and updating a parameter should be considered a destructive operation reserved for the admin. So we validate some of the

[PATCH v2 2/7] powerpc/pseries: papr-vpd char driver for VPD retrieval

2023-10-13 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch PowerVM LPARs may retrieve Vital Product Data (VPD) for system components using the ibm,get-vpd RTAS function. We can expose this to user space with a /dev/papr-vpd character device, where the programming model is: struct papr_location_code plc = { .str = "", }; /* obtain

[PATCH v2 5/7] powerpc/pseries/papr-sysparm: expose chardev API to user space

2023-10-13 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch Until now the papr_sysparm APIs have been kernel-internal. But user space needs access to PAPR system parameters too. The only method available to user space today to get or set system parameters is using sys_rtas() and /dev/mem to pass RTAS-addressable buffers between user

[PATCH v2 4/7] powerpc/pseries/papr-sysparm: validate buffer object lengths

2023-10-13 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch The ability to get and set system parameters will be exposed to user space, so let's get a little more strict about malformed papr_sysparm_buf objects. * Create accessors for the length field of struct papr_sysparm_buf. The length is always stored in MSB order and this is

[PATCH v2 1/7] powerpc/uapi: export papr-miscdev.h header

2023-10-13 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch Allocate one identifying code (the first column of the ioctl-number table) for the collection of PAPR miscdev drivers to share. Signed-off-by: Nathan Lynch --- arch/powerpc/include/uapi/asm/papr-miscdev.h | 9 + 1 file changed, 9 insertions(+) diff --git

[PATCH v2 6/7] powerpc/selftests: add test for papr-vpd

2023-10-13 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch Add selftests for /dev/papr-vpd, exercising the common expected use cases: * Retrieve all VPD by passing an empty location code. * Retrieve the "system VPD" by passing a location code derived from DT root node properties, as done by the vpdupdate command. The tests also

[PATCH v2 3/7] powerpc/rtas: serialize ibm,get-vpd service with papr-vpd sequences

2023-10-13 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch Take the papr-vpd driver's internal mutex when sys_rtas performs ibm,get-vpd calls. This prevents sys_rtas(ibm,get-vpd) calls from interleaving with sequences performed by the driver, ensuring that such sequences are not disrupted. However, it cannot prevent the driver from

[PATCH v2 0/7] powerpc/pseries: new character devices for system parameters and VPD

2023-10-13 Thread Nathan Lynch via B4 Relay
Add character devices that expose PAPR-specific system parameters and VPD to user space. The problem: important platform features are enabled on Linux VMs through the powerpc-specific rtas() syscall in combination with writeable mappings of /dev/mem. In typical usage, this is encapsulated behind

[PATCH 3/7] powerpc/rtas: serialize ibm,get-vpd service with papr-vpd sequences

2023-10-06 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch Take the papr-vpd driver's internal mutex when sys_rtas performs ibm,get-vpd calls. This prevents sys_rtas(ibm,get-vpd) calls from interleaving with sequences performed by the driver, ensuring that such sequences are not disrupted. However, it cannot prevent the driver from

[PATCH 5/7] powerpc/pseries/papr-sysparm: expose chardev API to user space

2023-10-06 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch Until now the papr_sysparm APIs have been kernel-internal. But user space needs access to PAPR system parameters too. The only method available to user space today to get or set system parameters is using sys_rtas() and /dev/mem to pass RTAS-addressable buffers between user

[PATCH 4/7] powerpc/pseries/papr-sysparm: validate buffer object lengths

2023-10-06 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch The ability to get and set system parameters will be exposed to user space, so let's get a little more strict about malformed papr_sysparm_buf objects. * Create accessors for the length field of struct papr_sysparm_buf. The length is always stored in MSB order and this is

[PATCH 6/7] powerpc/selftests: add test for papr-vpd

2023-10-06 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch Add selftests for /dev/papr-vpd, exercising the common expected use cases: * Retrieve all VPD by passing an empty location code. * Retrieve the "system VPD" by passing a location code derived from DT root node properties, as done by the vpdupdate command. The tests also

[PATCH 7/7] powerpc/selftests: add test for papr-sysparm

2023-10-06 Thread Nathan Lynch via B4 Relay
From: Nathan Lynch Consistently testing system parameter access is a bit difficult by nature -- the set of parameters available depends on the model and system configuration, and updating a parameter should be considered a destructive operation reserved for the admin. So we validate some of the

[PATCH 0/7] powerpc/pseries: new character devices for system parameters and VPD

2023-10-06 Thread Nathan Lynch via B4 Relay
Add character devices that expose PAPR-specific system parameters and VPD to user space. The problem: important platform features are enabled on Linux VMs through the powerpc-specific rtas() syscall in combination with writeable mappings of /dev/mem. In typical usage, this is encapsulated behind

  1   2   >