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

2024-04-26 Thread Nathan Lynch
Nathan Lynch writes: > Michael Ellerman writes: >> Nathan Lynch via B4 Relay >> writes: >>> >>> plpar_hcall(), plpar_hcall9(), and related functions expect callers to >>> provide valid result buffers of certain minimum size. Currently this >>>

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

2024-04-09 Thread Nathan Lynch
Michael Ellerman writes: > Nathan Lynch via B4 Relay > writes: >> >> 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 a

[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 retbuf

Re: [PATCH] powerpc/pseries: Add pool idle time at LPAR boot

2024-04-05 Thread Nathan Lynch
Shrikanth Hegde writes: > On 4/5/24 6:19 PM, Nathan Lynch wrote: >> Shrikanth Hegde writes: > > Hi Nathan, Thanks for reviewing this. > >>> When there are no options specified for lparstat, it is expected to >>> give reports since LPAR(Logical

Re: [PATCH] powerpc/pseries: Add pool idle time at LPAR boot

2024-04-05 Thread Nathan Lynch
Shrikanth Hegde writes: > When there are no options specified for lparstat, it is expected to > give reports since LPAR(Logical Partition) boot. App is an indicator > for available processor pool in an Shared Processor LPAR(SPLPAR). App is > derived using pool_idle_time which is obtained using

[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

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

2024-04-04 Thread Nathan Lynch
Nathan Lynch via B4 Relay writes: > 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 c

[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: Na

Re: Appropriate liburcu cache line size for Power

2024-03-25 Thread Nathan Lynch
Mathieu Desnoyers writes: > In the powerpc architecture support within the liburcu project [1] > we have a cache line size defined as 256 bytes with the following > comment: > > /* Include size of POWER5+ L3 cache lines: 256 bytes */ > #define CAA_CACHE_LINE_SIZE 256 > > I recently received a

Re: [PATCH] powerpc/kernel: Fix potential spectre v1 in syscall

2024-03-18 Thread Nathan Lynch
Michael Ellerman writes: > Breno Leitao writes: >> On Tue, Mar 12, 2024 at 08:17:42AM +, Christophe Leroy wrote: >>> +Nathan as this is RTAS related. Thanks! >>> Le 21/08/2018 à 20:42, Breno Leitao a écrit : >>> > The rtas syscall reads a value from a user-provided structure and uses it

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

2024-02-23 Thread Nathan Lynch
Michael Ellerman writes: > Nathan Lynch via B4 Relay > writes: >> From: Nathan Lynch >> >> The PAPR spec spells the function name as >> >> "ibm,reset-pe-dma-windows" >> >> but in practice firmware uses the singular form: > >

[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

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

2024-02-20 Thread Nathan Lynch
Michael Ellerman writes: > Nathan Lynch via B4 Relay > writes: >> 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

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

2024-02-19 Thread Nathan Lynch
ive > partition migration. > > Use the "ibm,migratable-partition" root node property to determine > whether this partition/guest can be migrated. Mark freed pages unused > if so (or if CMO is in use, as before). > > Signed-off-by: Nathan Lynch > --- >

Re: [PATCH] selftests: powerpc: Add header symlinks for building papr character device tests

2024-02-15 Thread Nathan Lynch
Michal Suchánek writes: > On Thu, Feb 15, 2024 at 01:13:34PM -0600, Nathan Lynch wrote: >> Michal Suchanek writes: >> > >> > Without the headers the tests don't build. >> > >> > Fixes: 9118c5d32bdd ("powerpc/selftests: Add test for papr-vpd&q

Re: [PATCH] selftests: powerpc: Add header symlinks for building papr character device tests

2024-02-15 Thread Nathan Lynch
Michal Suchanek writes: > > Without the headers the tests don't build. > > Fixes: 9118c5d32bdd ("powerpc/selftests: Add test for papr-vpd") > Fixes: 76b2ec3faeaa ("powerpc/selftests: Add test for papr-sysparm") > Signed-off-by: Michal Suchanek > --- >

[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

Re: [PATCH 8/8] powerpc/rtas: consume retry statuses in sys_rtas()

2024-01-25 Thread Nathan Lynch
Christophe Leroy writes: > Le 25/01/2024 à 17:33, Nathan Lynch a écrit : >> Christophe Leroy writes: >>> Hi Nathan, >>> >>> Le 06/03/2023 à 22:33, Nathan Lynch via B4 Relay a écrit : >>>> From: Nathan Lynch >>>> >>>> T

Re: [PATCH 8/8] powerpc/rtas: consume retry statuses in sys_rtas()

2024-01-25 Thread Nathan Lynch
Christophe Leroy writes: > Hi Nathan, > > Le 06/03/2023 à 22:33, Nathan Lynch via B4 Relay a écrit : >> From: Nathan Lynch >> >> The kernel can handle retrying RTAS function calls in response to >> -2/990x in the sys_rtas() handler instead of relaying the int

Re: [PATCH] powerpc/pseries/iommu: DLPAR ADD of pci device doesn't completely initialize pci_controller structure

2024-01-18 Thread Nathan Lynch
Hi Gaurav, A couple minor comments below. Gaurav Batra writes: > diff --git a/arch/powerpc/include/asm/ppc-pci.h > b/arch/powerpc/include/asm/ppc-pci.h > index ce2b1b5eebdd..55a2ba36e9c4 100644 > --- a/arch/powerpc/include/asm/ppc-pci.h > +++ b/arch/powerpc/include/asm/ppc-pci.h > @@ -29,6

Re: [PATCH v6] powerpc/pseries/vas: Use usleep_range() to support HCALL delay

2024-01-18 Thread Nathan Lynch
> > Instead of msleep(), use usleep_range() to ensure sleep with > the expected value before issuing HCALL again. So since each > task sleep 10 msecs maximum, this patch allow more tasks can > issue open/close VAS calls without any hung traces in the > dmesg. > > Signed-off-by: H

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

2024-01-18 Thread Nathan Lynch via B4 Relay
t reconstructing the hardware description string late in boot matches the one that was built earlier, and 2. fully exercises the update path before any migrations occur. This could be dropped or made configurable in the future. Signed-off-by: Nathan Lynch --- Nathan Lynch (5): dump_stack: Make

[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

[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 \ of:IBM

[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)&qu

[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 --- arch/powerpc

[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

Re: [PATCH v5] powerpc/pseries/vas: Use usleep_range() to support HCALL delay

2024-01-11 Thread Nathan Lynch
Haren Myneni writes: > VAS allocate, modify and deallocate HCALLs returns > H_LONG_BUSY_ORDER_1_MSEC or H_LONG_BUSY_ORDER_10_MSEC for busy > delay and expects OS to reissue HCALL after that delay. But using > msleep() will often sleep at least 20 msecs even though the > hypervisor suggests OS

[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

Re: [PATCH v4] powerpc/pseries/vas: Use usleep_range() to support HCALL delay

2024-01-02 Thread Nathan Lynch
"Aneesh Kumar K.V" writes: > Haren Myneni writes: > >> diff --git a/arch/powerpc/platforms/pseries/vas.c >> b/arch/powerpc/platforms/pseries/vas.c >> index 71d52a670d95..5cf81c564d4b 100644 >> --- a/arch/powerpc/platforms/pseries/vas.c >> +++ b/arch/powerpc/platforms/pseries/vas.c >> @@ -38,7

Re: [Mainline/linux-next-netdev/net-next/scsi]Dlpar remove, drmgr phb and pci remove operations are failing

2024-01-02 Thread Nathan Lynch
Hi, Tasmiya Nalatwad writes: >  [Mainline/linux-next-netdev/net-next/scsi] What does this mean? Are you reporting this issue against four separate trees? > Dlpar remove, drmgr phb and > pci remove operations are failing > > command ---> chhwres -r io --rsubtype slot -m "managed system name"

[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

[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

[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

[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 = "", };

[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

[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 --- arch

[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) Signed

[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
sts. - Add a papr-miscdev.h uapi header. - Prevent sys_rtas() from interfering with papr-vpd call sequences. - Handle -4 ("VPD changed") status in papr-vpd. - Include string_helpers.h in papr-vpd.c, per Michal Suchánek - Link to RFC: https://lore.kernel.org/r/20230822-papr-sys_rtas-vs-lo

[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-t

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

2023-12-12 Thread Nathan Lynch
Nathan Lynch via B4 Relay writes: > +static long papr_sysparm_ioctl(struct file *filp, unsigned int ioctl, > unsigned long arg) > +{ > + void __user *argp = (__force void __user *)arg; > + long ret; > + > + switch (ioctl) { > + case PAPR_SYSPARM_IOC_

[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 = "", };

[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

[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

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

2023-12-07 Thread Nathan Lynch via B4 Relay
uapi header. - Prevent sys_rtas() from interfering with papr-vpd call sequences. - Handle -4 ("VPD changed") status in papr-vpd. - Include string_helpers.h in papr-vpd.c, per Michal Suchánek - Link to RFC: https://lore.kernel.org/r/20230822-papr-sys_rtas-vs-lockdown-v1-0-932623cf3...@linux.ibm.c

[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-t

[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 --- arch

[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

[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

[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) Signed

[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

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

2023-12-05 Thread Nathan Lynch
Nathan Lynch writes: > Michael Ellerman writes: >> Nathan Lynch writes: >>> Michael Ellerman writes: >>>> Nathan Lynch writes: >>>>> Michael Ellerman writes: >>>>>> Nathan Lynch via B4 Relay >>>>>> writes:

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

2023-11-30 Thread Nathan Lynch
Michael Ellerman writes: > Nathan Lynch writes: >> Michael Ellerman writes: >>> Nathan Lynch writes: >>>> Michael Ellerman writes: >>>>> Nathan Lynch via B4 Relay >>>>> writes: >>>>>> From: Nathan Lynch &

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

2023-11-30 Thread Nathan Lynch
Nathan Lynch writes: > Alternatively, sys_rtas() could be refactored into locking and > non-locking paths, e.g. > > static long __do_sys_rtas(struct rtas_function *func) > { > // [ ... acquire rtas_lock, enter RTAS, fetch any error etc ... ] > } Of course this co

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

2023-11-30 Thread Nathan Lynch
Michael Ellerman writes: > Nathan Lynch writes: >> Michael Ellerman writes: >> >>> Nathan Lynch via B4 Relay >>> writes: >>>> From: Nathan Lynch >>>> >>>> On RTAS platforms there is a general restriction that the OS mu

Re: [PATCH v2] powerpc/pseries/vas: Use usleep_range() to support HCALL delay

2023-11-29 Thread Nathan Lynch
gt; So instead of msleep(), use usleep_range() to ensure sleep with > the expected value before issuing HCALL again. > > Signed-off-by: Haren Myneni > Suggested-by: Nathan Lynch > > --- > v1 -> v2: > - Use usleep_range instead of using RTAS sleep routine as >

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

2023-11-28 Thread Nathan Lynch
Michael Ellerman writes: > Nathan Lynch via B4 Relay > writes: >> From: Nathan Lynch >> >> PowerVM LPARs may retrieve Vital Product Data (VPD) for system >> components using the ibm,get-vpd RTAS function. > ... >> >> diff --git a/Documentati

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

2023-11-28 Thread Nathan Lynch
Michael Ellerman writes: > Nathan Lynch via B4 Relay > writes: >> diff --git a/arch/powerpc/kernel/rtas.c b/arch/powerpc/kernel/rtas.c >> index 1fc0b3fffdd1..52f2242d0c28 100644 >> --- a/arch/powerpc/kernel/rtas.c >> +++ b/arch/powerpc/kernel/rtas.c >>

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

2023-11-28 Thread Nathan Lynch
Michael Ellerman writes: > Nathan Lynch via B4 Relay > writes: >> 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

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

2023-11-28 Thread Nathan Lynch
Nathan Lynch writes: > "Aneesh Kumar K.V (IBM)" writes: > >> Nathan Lynch writes: >> >>> "Aneesh Kumar K.V (IBM)" writes: >>>> Nathan Lynch via B4 Relay >>>> writes: >>>> >>>>> >>>

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

2023-11-28 Thread Nathan Lynch
"Aneesh Kumar K.V (IBM)" writes: > Nathan Lynch writes: > >> "Aneesh Kumar K.V (IBM)" writes: >>> Nathan Lynch via B4 Relay >>> writes: >>> >>>> >>>> Use the function lock API to prevent interleaving call

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

2023-11-28 Thread Nathan Lynch
Michal Suchánek writes: > > On Fri, Nov 17, 2023 at 11:14:27PM -0600, Nathan Lynch via B4 Relay wrote: >> +do { >> +blob = papr_vpd_run_sequence(loc_code); >> +if (!IS_ERR(blob)) /* Success. */ >> +break; >> +

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

2023-11-28 Thread Nathan Lynch
"Aneesh Kumar K.V (IBM)" writes: > Nathan Lynch via B4 Relay > writes: >> There should be no perceivable change introduced here except that >> concurrent callers of the same RTAS function via sys_rtas() may block >> on a mutex instead of spinning on rtas_l

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

2023-11-28 Thread Nathan Lynch
"Aneesh Kumar K.V (IBM)" writes: > Nathan Lynch via B4 Relay > writes: > >> >> Use the function lock API to prevent interleaving call sequences of >> the ibm,activate-firmware RTAS function, which typically requires >> multiple calls

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

2023-11-28 Thread Nathan Lynch
is one for now and turn my attention to removing all the high-level rollback logic in this code. There's no reliable way to accomplish what it's trying to do (i.e. restore the original quantity of LMBs) and it just complicates things. > On 11/14/23 11:01, Nathan Lynch via B4 Relay wrote

[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

Re: Powerpc: maple_defconfig: kernel/rtas_pci.c:46:5: error: no previous prototype for function 'rtas_read_config' [-Werror,-Wmissing-prototypes]

2023-11-27 Thread Nathan Lynch
Naresh Kamboju writes: > Following Powerpc maple_defconfig and other builds failed with gcc-13 / 8 > and clang toolchains on Linux next-20231127 tag. > > build: > * gcc-8-cell_defconfig > * gcc-8-maple_defconfig > * gcc-8-tinyconfig > * gcc-13-tinyconfig > *

Re: [PATCH 1/2] powerpc/rtas: Create rtas_busy_sleep function

2023-11-27 Thread Nathan Lynch
Haren Myneni writes: > Move the RTAS delay sleep code to new rtas_busy_sleep(). It can > be called from HCALL delay code that needs to support both usleep() > or msleep() depends on delay value. While there may be some future utility in factoring out the code that handles extended delay

[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 insertions

[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 a/arch

[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

[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 = "", };

[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

[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

[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
e -4 ("VPD changed") status in papr-vpd. - Include string_helpers.h in papr-vpd.c, per Michal Suchánek - Link to RFC: https://lore.kernel.org/r/20230822-papr-sys_rtas-vs-lockdown-v1-0-932623cf3...@linux.ibm.com --- Nathan Lynch (13): powerpc/rtas: Add for_each_rtas_function() it

[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 --- arch

[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

[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

[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 - arch/powerpc/platforms/pseries

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

2023-11-14 Thread Nathan Lynch via B4 Relay
. - Cc recent contributors in this area. - Link to v1: https://lore.kernel.org/r/20231106-rtas-trivial-v1-0-61847655c...@linux.ibm.com --- Nathan Lynch (5): powerpc/rtas: Drop declaration of undefined call_rtas() function powerpc/rtas: Remove unused rtas_service_present() powerpc

[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

[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

  1   2   3   4   5   6   7   8   9   >