Re: [PATCH RFC 2/2] powerpc/selftests: add test for papr-vpd

2023-08-23 Thread Russell Currey
On Tue, 2023-08-22 at 16:33 -0500, Nathan Lynch via B4 Relay wrote: > From: Nathan Lynch Hi Nathan, snowpatch has found a compiler error with this patch. Error: papr_vpd.c:346:33: error: passing argument 2 of 'test_harness' discards 'const' qualifier from pointer target type [-Werror=dis

[PATCH] powerpc/pseries: Rework lppaca_shared_proc() to avoid DEBUG_PREEMPT

2023-08-07 Thread Russell Currey
abled. Instead of disabling preemption on the caller side, rework lppaca_shared_proc() to not take a pointer and instead directly access the lppaca, bypassing any potential preemption checks. Fixes: f13c13a00512 ("powerpc: Stop using non-architected shared_proc field in lppaca") Signed-

[PATCH] powerpc/crypto: Add gitignore for generated P10 AES/GCM .S files

2023-07-12 Thread Russell Currey
aesp10-ppc.S and ghashp10-ppc.S are autogenerated and not tracked by git, so they should be ignored. This is doing the same as the P8 files in drivers/crypto/vmx/.gitignore but for the P10 files in arch/powerpc/crypto. Signed-off-by: Russell Currey --- Fixes: 81d358b118dc ("powerpc/crypto

Re: [PATCH] powerpc/security: Fix Speculation_Store_Bypass reporting on Power10

2023-05-17 Thread Russell Currey
ck and expanding the > comment > to cover both cases, rewrite the three cases to be separate so they > can > be commented separately for clarity. > > Fixes: 84ed26fd00c5 ("powerpc/security: Add a security feature for > STF barrier") > Cc: sta...@vger.kernel.org # v5.14+ > Reported-by: Nageswara R Sastry > Signed-off-by: Michael Ellerman Reviewed-by: Russell Currey

Re: [PATCH v2 10/12] selftests/powerpc: Add more utility macros

2023-05-07 Thread Russell Currey
nd ARRAY_SIZE will be used by the following > DEXCR selftests. > > Signed-off-by: Benjamin Gray > I'd prefer if your commit message led with adding FAIL_IF_MSG etc and then mentioned the other changes to support it. It's unintuitive to read as-is. Reviewed-by: Russell Currey

Re: [PATCH v2 09/12] Documentation: Document PowerPC kernel DEXCR interface

2023-05-07 Thread Russell Currey
config >   option > > This documentation is a little bare for now, but will be expanded on > when dynamic DEXCR control is added. Reviewed-by: Russell Currey

Re: [PATCH v2 08/12] powerpc/ptrace: Expose HASHKEYR register to ptrace

2023-05-07 Thread Russell Currey
reased security or migratable ROP > protected processes. This is similar to how ARM exposes its PAC keys. > > Signed-off-by: Benjamin Gray Seems sensible Reviewed-by: Russell Currey

Re: [PATCH v2 07/12] powerpc/ptrace: Expose DEXCR and HDEXCR registers to ptrace

2023-05-07 Thread Russell Currey
DEXCR setting it). > > Signed-off-by: Benjamin Gray > I don't know much about ptrace but this looks sane. Reviewed-by: Russell Currey

Re: [PATCH v2 06/12] powerpc/dexcr: Support custom default DEXCR value

2023-05-07 Thread Russell Currey
em state. > This should be safe, as generally software needs to request these > instructions be included in the first place. > > Signed-off-by: Benjamin Gray > Reviewed-by: Russell Currey > --- > New in v1 > > Preface with: I'm note sure on the best place t

Re: [PATCH v2 05/12] powerpc/dexcr: Support userspace ROP protection

2023-05-07 Thread Russell Currey
reate > valid hash values for a victim process. > > Add support for storing a per-thread hash key, and setting/clearing > HASHKEYR appropriately. > > Signed-off-by: Benjamin Gray Reviewed-by: Russell Currey

Re: [PATCH v2 04/12] powerpc/dexcr: Handle hashchk exception

2023-05-07 Thread Russell Currey
On Thu, 2023-03-30 at 16:50 +1100, Benjamin Gray wrote: > Recognise and pass the appropriate signal to the user program when a > hashchk instruction triggers. This is independent of allowing > configuration of DEXCR[NPHIE], as a hypervisor can enforce this > aspect > regardless of the kernel. > >

Re: [PATCH v2 01/12] powerpc/book3s: Add missing include

2023-05-07 Thread Russell Currey
o a compilation > error when a translation unit does not also include > indirectly. > > Signed-off-by: Benjamin Gray > Reviewed-by: Nicholas Piggin Reviewed-by: Russell Currey

Re: [PATCH v2 03/12] powerpc/dexcr: Add initial Dynamic Execution Control Register (DEXCR) support

2023-05-07 Thread Russell Currey
currently only detect it on pseries. > > Signed-off-by: Benjamin Gray > LGTM. Reviewed-by: Russell Currey

Re: [PATCH v2 02/12] powerpc/ptrace: Add missing include

2023-05-07 Thread Russell Currey
hat tries to inspect ptrace-decl.h by itself. > > Signed-off-by: Benjamin Gray Reviewed-by: Russell Currey

[PATCH] powerpc/iommu: Fix notifiers being shared by PCI and VIO buses

2023-03-21 Thread Russell Currey
Signed-off-by: Russell Currey --- arch/powerpc/kernel/iommu.c | 15 --- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/kernel/iommu.c b/arch/powerpc/kernel/iommu.c index ee95937bdaf1..6f1117fe3870 100644 --- a/arch/powerpc/kernel/iommu.c +++ b/arch

[PATCH] powerpc/mm: Fix false detection of read faults

2023-03-09 Thread Russell Currey
() check for PROT_NONE mappings, and adding a separate check for Radix PROT_EXEC-only mappings. Fixes: 395cac7752b9 ("powerpc/mm: Support execute-only memory on the Radix MMU") Reported-by: Michal Suchánek Tested-by: Benjamin Gray Signed-off-by: Russell Currey --- arch/powerpc/mm/fa

Re: [PATCH v4 1/2] powerpc/mm: Support execute-only memory on the Radix MMU

2023-03-08 Thread Russell Currey
On Wed, 2023-03-08 at 16:27 +0100, Michal Suchánek wrote: > Hello, > > On Wed, Aug 31, 2022 at 11:13:59PM +1000, Michael Ellerman wrote: > > On Wed, 17 Aug 2022 15:06:39 +1000, Russell Currey wrote: > > > Add support for execute-only memory (XOM) for the Radix MMU by >

[PATCH] powerpc/pseries: Avoid hcall in plpks_is_available() on non-pseries

2023-02-21 Thread Russell Currey
fig values, support additional fields") Reported-by: Murphy Zhou Signed-off-by: Russell Currey --- arch/powerpc/platforms/pseries/plpks.c | 4 1 file changed, 4 insertions(+) diff --git a/arch/powerpc/platforms/pseries/plpks.c b/arch/powerpc/platforms/pseries/plpks.c index cdf09e5bd741..6f7b

Re: [PATCH v4 16/24] powerpc/pseries: Implement signed update for PLPKS objects

2023-01-30 Thread Russell Currey
On Mon, 2023-01-30 at 15:43 +1100, Andrew Donnellan wrote: > On Tue, 2023-01-24 at 14:16 +1000, Nicholas Piggin wrote: > > > diff --git a/arch/powerpc/platforms/pseries/plpks.c > > > b/arch/powerpc/platforms/pseries/plpks.c > > > index 1189246b03dc..796ed5544ee5 100644 > > > --- a/arch/powerpc/plat

Re: [PATCH v4 21/24] powerpc/pseries: Pass PLPKS password on kexec

2023-01-30 Thread Russell Currey
On Tue, 2023-01-24 at 14:36 +1000, Nicholas Piggin wrote: > On Fri Jan 20, 2023 at 5:43 PM AEST, Andrew Donnellan wrote: > > From: Russell Currey > > > > Before interacting with the PLPKS, we ask the hypervisor to > > generate a > > password for the current boot

Re: [PATCH v4 24/24] integrity/powerpc: Support loading keys from pseries secvar

2023-01-24 Thread Russell Currey
On Tue, 2023-01-24 at 10:14 -0500, Mimi Zohar wrote: > On Fri, 2023-01-20 at 18:43 +1100, Andrew Donnellan wrote: > > From: Russell Currey > > > > The secvar object format is only in the device tree under powernv. > > We now have an API call to retrieve it in a ge

Re: [PATCH v3 04/24] powerpc/secvar: Handle format string in the consumer

2023-01-19 Thread Russell Currey
On Thu, 2023-01-19 at 11:17 +1000, Nicholas Piggin wrote: > On Wed Jan 18, 2023 at 4:10 PM AEST, Andrew Donnellan wrote: > > From: Russell Currey > > > > The code that handles the format string in secvar-sysfs.c is > > entirely > > OPAL specific, so create a new

Re: [PATCH] powerpc/secvar: Use u64 in secvar_operations

2023-01-11 Thread Russell Currey
> Change all the secvar related routines to use u64. > > Signed-off-by: Michael Ellerman Reviewed-by: Russell Currey

Re: [PATCH v2 7/7] powerpc/pseries: Implement secvars for dynamic secure boot

2023-01-09 Thread Russell Currey
On Mon, 2023-01-09 at 16:20 +1100, Andrew Donnellan wrote: > On Mon, 2023-01-09 at 14:34 +1100, Russell Currey wrote: > > > > > > +static int plpks_secvar_init(void) > > > > +{ > > > > +   if (!plpks_is_availa

Re: [PATCH v2 7/7] powerpc/pseries: Implement secvars for dynamic secure boot

2023-01-08 Thread Russell Currey
On Fri, 2023-01-06 at 21:49 +1100, Michael Ellerman wrote: > Russell Currey writes: > > The pseries platform can support dynamic secure boot (i.e. secure > > boot > > using user-defined keys) using variables contained with the PowerVM > > LPAR > > Platform Key

Re: [PATCH v2 7/7] powerpc/pseries: Implement secvars for dynamic secure boot

2023-01-05 Thread Russell Currey
On Thu, 2023-01-05 at 19:15 +1100, Andrew Donnellan wrote: > On Fri, 2022-12-30 at 15:20 +1100, Russell Currey wrote: > > The pseries platform can support dynamic secure boot (i.e. secure > > boot > > using user-defined keys) using variables contained with the PowerVM

Re: [PATCH v2 6/7] powerpc/secvar: Extend sysfs to include config vars

2023-01-05 Thread Russell Currey
On Fri, 2023-01-06 at 15:15 +1100, Michael Ellerman wrote: > Russell Currey writes: > > The forthcoming pseries consumer of the secvar API wants to expose > > a > > number of config variables.  Allowing secvar implementations to > > provide > > their own s

Re: [PATCH v2 6/7] powerpc/secvar: Extend sysfs to include config vars

2023-01-05 Thread Russell Currey
On Thu, 2023-01-05 at 18:28 +1100, Andrew Donnellan wrote: > On Fri, 2022-12-30 at 15:20 +1100, Russell Currey wrote: > > The forthcoming pseries consumer of the secvar API wants to expose > > a > > number of config variables.  Allowing secvar implementations to > >

Re: [PATCH 4/4] powerpc/pseries: Implement signed update for PLPKS objects

2023-01-03 Thread Russell Currey
On Tue, 2022-12-20 at 18:16 +1100, Andrew Donnellan wrote: > From: Nayna Jain > > The Platform Keystore provides a signed update interface which can be > used > to create, replace or append to certain variables in the PKS in a > secure > fashion, with the hypervisor requiring that the update be s

Re: [PATCH 3/4] powerpc/pseries: Expose PLPKS config values, support additional fields

2023-01-03 Thread Russell Currey
On Tue, 2022-12-20 at 18:16 +1100, Andrew Donnellan wrote: > From: Nayna Jain > > The plpks driver uses the H_PKS_GET_CONFIG hcall to retrieve > configuration > and status information about the PKS from the hypervisor. > > Update _plpks_get_config() to handle some additional fields. Add > getter

Re: [PATCH 2/4] powerpc/pseries: Fix alignment of PLPKS structures and buffers

2023-01-03 Thread Russell Currey
ay > Fixes: 2454a7af0f2a ("powerpc/pseries: define driver for Platform > KeyStore") > Signed-off-by: Andrew Donnellan > Reviewed-by: Russell Currey

Re: [PATCH 1/4] powerpc/pseries: Fix handling of PLPKS object flushing timeout

2023-01-03 Thread Russell Currey
series: define driver for Platform > KeyStore") > Reported-by: Benjamin Gray > Signed-off-by: Andrew Donnellan Tested-by: Russell Currey Reviewed-by: Russell Currey

[PATCH v2 7/7] powerpc/pseries: Implement secvars for dynamic secure boot

2022-12-29 Thread Russell Currey
ff-by: Russell Currey --- v2: Remove unnecessary config vars from sysfs and document the others, thanks to review from Greg. If we end up needing to expose more, we can add them later and update the docs. Use sysfs_emit() instead of sprintf(), thanks to Greg. Change the size o

[PATCH v2 6/7] powerpc/secvar: Extend sysfs to include config vars

2022-12-29 Thread Russell Currey
the config directory will not be created if no attributes are set. Signed-off-by: Russell Currey --- I played around with adding an API call to facilitate a more generic key/value interface for config variables and it seemed like unnecessary complexity. I think this is cleaner. If there was

[PATCH v2 5/7] powerpc/secvar: Handle max object size in the consumer

2022-12-29 Thread Russell Currey
Currently the max object size is handled in the core secvar code with an entirely OPAL-specific implementation, so create a new max_size() op and move the existing implementation into the powernv platform. Should be no functional change. Signed-off-by: Russell Currey --- arch/powerpc/include

[PATCH v2 4/7] powerpc/secvar: Handle format string in the consumer

2022-12-29 Thread Russell Currey
The code that handles the format string in secvar-sysfs.c is entirely OPAL specific, so create a new "format" op in secvar_operations to make the secvar code more generic. No functional change. Signed-off-by: Russell Currey --- arch/powerpc/include/asm/secvar.h| 1 + ar

[PATCH v2 3/7] powerpc/secvar: Use sysfs_emit() instead of sprintf()

2022-12-29 Thread Russell Currey
The secvar format string and object size sysfs files are both ASCII text, and should use sysfs_emit(). No functional change. Suggested-by: Greg Kroah-Hartman Signed-off-by: Russell Currey --- v2: new arch/powerpc/kernel/secvar-sysfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions

[PATCH v2 2/7] powerpc/secvar: WARN_ON_ONCE() if multiple secvar ops are set

2022-12-29 Thread Russell Currey
The secvar code only supports one consumer at a time. Multiple consumers aren't possible at this point in time, but we'd want it to be obvious if it ever could happen. Signed-off-by: Russell Currey --- arch/powerpc/kernel/secvar-ops.c | 4 +++- 1 file changed, 3 insertions(+),

[PATCH v2 0/7] pseries dynamic secure boot interface using secvar

2022-12-29 Thread Russell Currey
06210744.603240-1-na...@linux.ibm.com/ [1]: https://lore.kernel.org/linuxppc-dev/20221220071626.1426786-1-...@linux.ibm.com/ v1: https://lore.kernel.org/linuxppc-dev/20221228072943.429266-1-rus...@russell.cc/ Russell Currey (7): powerpc/pseries: Log hcall return codes for PLPKS debug powerpc/secva

[PATCH v2 1/7] powerpc/pseries: Log hcall return codes for PLPKS debug

2022-12-29 Thread Russell Currey
The plpks code converts hypervisor return codes into their Linux equivalents so that users can understand them. Having access to the original return codes is really useful for debugging, so add a pr_debug() so we don't lose information from the conversion. Signed-off-by: Russell C

[PATCH 3/6] powerpc/secvar: Handle format string in the consumer

2022-12-27 Thread Russell Currey
The code that handles the format string in secvar-sysfs.c is entirely OPAL specific, so create a new "format" op in secvar_operations to make the secvar code more generic. No functional change. Signed-off-by: Russell Currey --- arch/powerpc/include/asm/secvar.h| 1 + ar

[PATCH 5/6] powerpc/secvar: Extend sysfs to include config vars

2022-12-27 Thread Russell Currey
the config directory will not be created if no attributes are set. Signed-off-by: Russell Currey --- I played around with adding an API call to facilitate a more generic key/value interface for config variables and it seemed like unnecessary complexity. I think this is cleaner. If there was

[PATCH 1/6] powerpc/pseries: Log hcall return codes for PLPKS debug

2022-12-27 Thread Russell Currey
The plpks code converts hypervisor return codes into their Linux equivalents so that users can understand them. Having access to the original return codes is really useful for debugging, so add a pr_debug() so we don't lose information from the conversion. Signed-off-by: Russell C

[PATCH 2/6] powerpc/secvar: WARN_ON_ONCE() if multiple secvar ops are set

2022-12-27 Thread Russell Currey
The secvar code only supports one consumer at a time. Multiple consumers aren't possible at this point in time, but we'd want it to be obvious if it ever could happen. Signed-off-by: Russell Currey --- arch/powerpc/kernel/secvar-ops.c | 4 +++- 1 file changed, 3 insertions(+),

[PATCH 0/6] pseries dynamic secure boot interface using secvar

2022-12-27 Thread Russell Currey
e one being added in future. With this series, both powernv and pseries platforms support dynamic secure boot through the same interface. [0]: https://lore.kernel.org/linuxppc-dev/20221106210744.603240-1-na...@linux.ibm.com/ [1]: https://lore.kernel.org/linuxppc-dev/20221220071626.1426786-1-...@lin

[PATCH 6/6] powerpc/pseries: Implement secvars for dynamic secure boot

2022-12-27 Thread Russell Currey
ff-by: Russell Currey --- Documentation/ABI/testing/sysfs-secvar| 8 + arch/powerpc/platforms/pseries/Kconfig| 13 + arch/powerpc/platforms/pseries/Makefile | 4 +- arch/powerpc/platforms/pseries/plpks-secvar.c | 250 ++ 4 files changed, 273 insertions(

[PATCH 4/6] powerpc/secvar: Handle max object size in the consumer

2022-12-27 Thread Russell Currey
Currently the max object size is handled in the core secvar code with an entirely OPAL-specific implementation, so create a new max_size() op and move the existing implementation into the powernv platform. Should be no functional change. Signed-off-by: Russell Currey --- arch/powerpc/include

Re: [RFC PATCH 00/13] Add DEXCR support

2022-11-27 Thread Russell Currey
On Mon, 2022-11-28 at 13:44 +1100, Benjamin Gray wrote: > This series is based on initial work by Chris Riedl that was not sent > to the list. > > Adds a kernel interface for userspace to interact with the DEXCR. > The DEXCR is a SPR that allows control over various execution > 'aspects', such as

Re: [PATCH 2/4] powerpc/64s: Clear gprs on interrupt routine entry on Book3S

2022-11-06 Thread Russell Currey
On Thu, 2022-11-03 at 09:45 +1100, Rohan McLure wrote: > Zero user state in gprs (assign to zero) to reduce the influence of > user > registers on speculation within kernel syscall handlers. Clears occur > at the very beginning of the sc and scv 0 interrupt handlers, with > restores occurring follo

Re: [RFC PATCH 14/19] powerpc: split validate_sp into two functions

2022-11-06 Thread Russell Currey
On Mon, 2022-10-31 at 15:54 +1000, Nicholas Piggin wrote: > Most callers just want to validate an arbitrary kernel stack pointer, > some need a particular size. Make the size case the exceptional one > with an extra function. > > Signed-off-by: Nicholas Piggin > --- >  arch/powerpc/include/asm/pr

Re: [RFC PATCH 4/6] powerpc/powernv: Convert pointers to physical addresses in OPAL call args

2022-11-06 Thread Russell Currey
On Sat, 2022-11-05 at 04:27 +1100, Andrew Donnellan wrote: > A number of OPAL calls take addresses as arguments (e.g. buffers with > strings to print, etc). These addresses need to be physical > addresses, as > OPAL runs in real mode. > > Since the hardware ignores the top two bits of the address

Re: [PATCH v3 3/3] powerpc: mm: support page table check

2022-10-25 Thread Russell Currey
scv support in commit 3fee229a8eb9 ("riscv/mm: enable > ARCH_SUPPORTS_PAGE_TABLE_CHECK") > arm64 in commit 42b2547137f5 ("arm64/mm: enable > ARCH_SUPPORTS_PAGE_TABLE_CHECK") > x86_64 in commit d283d422c6c4 ("x86: mm: add x86_64 support for page > table > check") > > Signed-off-by: Rohan McLure Reviewed-by: Russell Currey

Re: [PATCH] powerpc: replace ternary operator with min()

2022-10-23 Thread Russell Currey
On Sun, 2022-10-23 at 20:44 +0800, KaiLong Wang wrote: > Fix the following coccicheck warning: > > arch/powerpc/xmon/xmon.c:2987: WARNING opportunity for min() > arch/powerpc/xmon/xmon.c:2583: WARNING opportunity for min() > > Signed-off-by: KaiLong Wang Hello, This fails to compile on some pl

Re: [PATCH v8 4/6] powerpc/tlb: Add local flush for page given mm_struct and psize

2022-10-23 Thread Russell Currey
On Fri, 2022-10-21 at 16:22 +1100, Benjamin Gray wrote: > Adds a local TLB flush operation that works given an mm_struct, VA to > flush, and page size representation. > > This removes the need to create a vm_area_struct, which the temporary > patching mm work does not need. > > Signed-off-by: Ben

[PATCH] powerpc/8xx: Fix warning in hw_breakpoint_handler()

2022-10-23 Thread Russell Currey
In hw_breakpoint_handler(), ea is set by wp_get_instr_detail() except for 8xx, leading the variable to be passed uninitialised to wp_check_constraints(). This is safe as wp_check_constraints() returns early without using ea, so just set it to make the compiler happy. Signed-off-by: Russell

Re: [PATCH v8 5/6] powerpc/code-patching: Use temporary mm for Radix MMU

2022-10-23 Thread Russell Currey
On Fri, 2022-10-21 at 16:22 +1100, Benjamin Gray wrote: > From: "Christopher M. Riedl" > > x86 supports the notion of a temporary mm which restricts access to > temporary PTEs to a single CPU. A temporary mm is useful for > situations > where a CPU needs to perform sensitive operations (such as p

Re: [PATCH v8 4/6] powerpc/tlb: Add local flush for page given mm_struct and psize

2022-10-23 Thread Russell Currey
On Fri, 2022-10-21 at 16:22 +1100, Benjamin Gray wrote: > Adds a local TLB flush operation that works given an mm_struct, VA to > flush, and page size representation. > > This removes the need to create a vm_area_struct, which the temporary > patching mm work does not need. > > Signed-off-by: Ben

Re: [PATCH v8 3/6] powerpc/code-patching: Verify instruction patch succeeded

2022-10-23 Thread Russell Currey
On Fri, 2022-10-21 at 16:22 +1100, Benjamin Gray wrote: > Verifies that if the instruction patching did not return an error > then > the value stored at the given address to patch is now equal to the > instruction we patched it to. > > Signed-off-by: Benjamin Gray > --- >  arch/powerpc/lib/code-p

Re: [PATCH v8 2/6] powerpc/code-patching: Use WARN_ON and fix check in poking_init

2022-10-23 Thread Russell Currey
d a negative integer on failure. > > Signed-off-by: Benjamin Gray Reviewed-by: Russell Currey

Re: [PATCH v8 1/6] powerpc: Allow clearing and restoring registers independent of saved breakpoint state

2022-10-23 Thread Russell Currey
On Fri, 2022-10-21 at 16:22 +1100, Benjamin Gray wrote: > From: Jordan Niethe Hi Ben, > For the coming temporary mm used for instruction patching, the > breakpoint registers need to be cleared to prevent them from > accidentally being triggered. As soon as the patching is done, the > breakpoints

Re: [PATCH v3 4/4] powerpc/64s: Enable KFENCE on book3s64

2022-09-26 Thread Russell Currey
> Based on previous work by Christophe Leroy and Jordan Niethe. > > Signed-off-by: Nicholas Miehlbradt LGTM. For the whole series: Reviewed-by: Russell Currey

Re: [PATCH v5] livepatch: Clear relocation targets on a module removal

2022-09-07 Thread Russell Currey
On Thu, 2022-09-01 at 08:42 -0400, Joe Lawrence wrote: > On Thu, Sep 01, 2022 at 01:39:02PM +1000, Michael Ellerman wrote: > > Joe Lawrence writes: > > > On Thu, Sep 01, 2022 at 08:30:44AM +1000, Michael Ellerman wrote: > > > > Joe Lawrence writes: > > ... > > > > > > Hi Michael, > > > > > > Wh

Re: [RFC PATCH 1/4] powerpc/code-patching: add patch_memory() for writing RO text

2022-09-05 Thread Russell Currey
On Thu, 2022-09-01 at 07:01 +, Christophe Leroy wrote: > > > Le 01/09/2022 à 07:58, Benjamin Gray a écrit : > > From: Russell Currey > > > > powerpc allocates a text poke area of one page that is used by > > patch_instruction() to modify read-only text when

[PATCH] powerpc/pasemi: Use strscpy instead of strlcpy

2022-08-26 Thread Russell Currey
find_i2c_driver() contained the last usage of strlcpy() in arch/powerpc. The return value was used to check if strlen(src) >= n, for which strscpy() returns -E2BIG. Signed-off-by: Russell Currey --- arch/powerpc/platforms/pasemi/misc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deleti

[PATCH v4 2/2] selftests/powerpc: Add a test for execute-only memory

2022-08-16 Thread Russell Currey
Miehlbradt Signed-off-by: Russell Currey --- v4: new tools/testing/selftests/powerpc/mm/Makefile | 3 +- .../testing/selftests/powerpc/mm/exec_prot.c | 231 ++ 2 files changed, 233 insertions(+), 1 deletion(-) create mode 100644 tools/testing/selftests/powerpc/mm/exec_prot.c

[PATCH v4 1/2] powerpc/mm: Support execute-only memory on the Radix MMU

2022-08-16 Thread Russell Currey
nally equivalent for non-Radix MMUs, since it follows write and execute checks. For Radix, the change enables detecting faults on execute-only mappings where vma_is_accessible() would return true. Signed-off-by: Russell Currey --- v4: Reword commit message, add changes suggested by Christophe and A

[PATCH] selftests/powerpc: Add missing PMU selftests to .gitignores

2022-08-12 Thread Russell Currey
Some recently added selftests don't have their binaries in .gitignores, so add them. I also alphabetically sorted sampling_tests/.gitignore while I was in there. Signed-off-by: Russell Currey --- .../powerpc/pmu/event_code_tests/.gitignore | 20 +++ .../powerp

[PATCH v2] powerpc/kexec: Fix build failure from uninitialised variable

2022-08-09 Thread Russell Currey
hristophe Leroy Signed-off-by: Russell Currey --- v2: adopt Christophe's suggestion, which is better arch/powerpc/kexec/file_load_64.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/powerpc/kexec/file_load_64.c b/arch/powerpc/kexec/file_load_64.c index 683462

Re: [PATCH v3] powerpc/mm: Support execute-only memory on the Radix MMU

2022-08-08 Thread Russell Currey
On Tue, 2022-08-09 at 05:51 +, Christophe Leroy wrote: > Le 09/08/2022 à 04:44, Russell Currey a écrit : > > The Hash MMU already supports XOM (i.e. mmap with PROT_EXEC only) > > through the execute-only pkey.  A PROT_EXEC-only mapping will > > actually > > map to RX

[PATCH] powerpc/kexec: Fix build failure from uninitialised variable

2022-08-08 Thread Russell Currey
clang 14 won't build because ret is uninitialised and can be returned if both prop and fdtprop are NULL. Fixes: b1fc44eaa9ba ("pseries/iommu/ddw: Fix kdump to work in absence of ibm,dma-window") Signed-off-by: Russell Currey --- Not sure what should be returned here, EINVAL se

[PATCH v3] powerpc/mm: Support execute-only memory on the Radix MMU

2022-08-08 Thread Russell Currey
ve to do to support XOM is expose it. Signed-off-by: Russell Currey --- v3: Incorporate Aneesh's suggestions, leave protection_map untouched Basic test: https://github.com/ruscur/junkcode/blob/main/mmap_test.c arch/powerpc/include/asm/book3s/64/pgtable.h | 2 ++ arch/powerpc/mm/book3s64

Re: [PATCH v2 2/2] powerpc/mm: Support execute-only memory on the Radix MMU

2022-08-08 Thread Russell Currey
On Mon, 2022-08-08 at 18:54 +0530, Aneesh Kumar K V wrote: > On 8/8/22 6:31 PM, Russell Currey wrote: > > The Hash MMU already supports XOM (i.e. mmap with PROT_EXEC only) > > through the execute-only pkey.  A PROT_EXEC-only mapping will > > actually > > map to RX

Re: [PATCH] powerpc/mm: Support execute-only memory on the Radix MMU

2022-08-08 Thread Russell Currey
On Mon, 2022-08-08 at 18:28 +0530, Aneesh Kumar K V wrote: > On 8/8/22 5:28 PM, Russell Currey wrote: > > The Hash MMU already supports XOM (i.e. mmap with PROT_EXEC only) > > through the execute-only pkey.  A PROT_ONLY mapping will actually > > map to > > RX, and then

Re: [PATCH v2 1/2] powerpc/mm: Move vm_get_page_prot() out of book3s64 code

2022-08-08 Thread Russell Currey
On Mon, 2022-08-08 at 14:32 +, Christophe Leroy wrote: > > > Le 08/08/2022 à 15:01, Russell Currey a écrit : > > protection_map is about to be __ro_after_init instead of const, so > > move > > the only non-local function that consumes it to the same file so it >

[PATCH v2 2/2] powerpc/mm: Support execute-only memory on the Radix MMU

2022-08-08 Thread Russell Currey
ve to do to support XOM is expose it. That's not possible with protection_map being const, so make it RO after init instead. Signed-off-by: Russell Currey --- v2: Make protection_map __ro_after_init and set it in an initcall (v1 didn't work, I tested before rebasing on Anshuman's

[PATCH v2 1/2] powerpc/mm: Move vm_get_page_prot() out of book3s64 code

2022-08-08 Thread Russell Currey
protection_map is about to be __ro_after_init instead of const, so move the only non-local function that consumes it to the same file so it can at least be static. Signed-off-by: Russell Currey --- v2: new arch/powerpc/mm/book3s64/pgtable.c | 16 arch/powerpc/mm/pgtable.c

[PATCH] powerpc/mm: Support execute-only memory on the Radix MMU

2022-08-08 Thread Russell Currey
to do to support XOM is expose it. Signed-off-by: Russell Currey --- quick test: https://raw.githubusercontent.com/ruscur/junkcode/main/mmap_test.c I can make it a selftest. arch/powerpc/include/asm/book3s/64/radix.h | 3 +++ arch/powerpc/mm/book3s64/radix_pgtable.c | 4 arch/power

[PATCH] MAINTAINERS: Remove myself as EEH maintainer

2022-08-06 Thread Russell Currey
I haven't touched EEH in a long time I don't have much knowledge of the subsystem at this point either, so it's misleading to have me as a maintainer. I remain grateful to Oliver for picking up my slack over the years. Signed-off-by: Russell Currey --- MAINTAINERS | 1 - 1

[PATCH] selftests/powerpc: Don't run spectre_v2 test by default

2022-08-04 Thread Russell Currey
, the selftest is unreliable as a pass/fail test without the test runner knowing what they expect its behaviour to be. I don't think the selftest is useless so we should keep it around, but we shouldn't have run_tests run it by default. Suggested-by: Eirik Fuller Signed-off-by: Russell Cur

Re: [PATCH kernel] pseries/iommu/ddw: Fix kdump to work in absence of ibm,dma-window

2022-06-26 Thread Russell Currey
  iommu_register_group(ppci->table_group, > pci_domain_nr(bus), 0); >     pr_debug("  created table: %p\n", ppci->table_group); > @@ -1429,16 +1448,22 @@ static bool enable_ddw(struct pci_dev *dev, > struct device_node

Re: [PATCH] powerc: Update asm-prototypes.h comment

2022-06-22 Thread Russell Currey
On Fri, 2022-06-17 at 18:02 +1000, Michael Ellerman wrote: > This header was recently cleaned up in commit 76222808fc25 ("powerpc: > Move C prototypes out of asm-prototypes.h"), update the comment to > reflect it's proper purpose. > > Signed-off-by: Michael Ellerman Hi Michael, subject says "pow

Re: [PATCH 3/5] bpf ppc64: Add instructions for atomic_[cmp]xchg

2022-05-15 Thread Russell Currey
On Thu, 2022-05-12 at 13:15 +0530, Hari Bathini wrote: > This adds two atomic opcodes BPF_XCHG and BPF_CMPXCHG on ppc64, both > of which include the BPF_FETCH flag.  The kernel's atomic_cmpxchg > operation fundamentally has 3 operands, but we only have two register > fields. Therefore the operand w

Re: [PATCH v2 1/2] powerpc/powernv: Get L1D flush requirements from device-tree

2022-04-05 Thread Russell Currey
On Tue, 2022-04-05 at 02:49 +, Joel Stanley wrote: > I booted both patches in this series on a power10 powernv machine, > applied on top of v5.18-rc1: > > $ dmesg |grep -i flush > [    0.00] rfi-flush: fallback displacement flush available > [    0.00] rfi-flush: patched 12 locations

Re: [PATCH] powerpc/powernv: Get more flushing requirements from device-tree

2022-04-04 Thread Russell Currey
On Wed, 2022-03-23 at 16:26 -0300, Murilo Opsfelder Araújo wrote: > Hi, Russell. > > I think this patch could have been split in half with their > corresponding Fixes: tag. > > This may sound nitpicking but doing this would certainly help distros > doing their backports. Hi Murilo, I didn't use

[PATCH v2 1/2] powerpc/powernv: Get L1D flush requirements from device-tree

2022-04-04 Thread Russell Currey
lushes are unnecessarily enabled on those systems. This patch corrects this. Fixes: d02fa40d759f ("powerpc/powernv: Remove POWER9 PVR version check for entry and uaccess flushes") Reported-by: Joel Stanley Signed-off-by: Russell Currey --- arch/powerpc/platforms/powernv/setup.c | 6 ++

[PATCH v2 2/2] powerpc/powernv: Get STF barrier requirements from device-tree

2022-04-04 Thread Russell Currey
e property have been enabling the STF barrier when they have no need for it. This patch fixes this by clearing the STF barrier feature on those systems. Fixes: 84ed26fd00c5 ("powerpc/security: Add a security feature for STF barrier") Reported-by: Joel Stanley Signed-off-by: Russell Curre

[PATCH] powerpc/powernv: Get more flushing requirements from device-tree

2022-03-22 Thread Russell Currey
vice-tree checks for newer processors on powernv, these flushes are unnecessarily enabled on those systems. This patch fixes that too. Reported-by: Joel Stanley Signed-off-by: Russell Currey --- arch/powerpc/platforms/powernv/setup.c | 9 + 1 file changed, 9 insertions(+) diff

Re: [PATCH] powerpc/module_64: fix array_size.cocci warning

2022-02-24 Thread Russell Currey
an sizeof(arr) / sizeof(arr[0]) and more > standard. > > Signed-off-by: Guo Zhengkui Reviewed-by: Russell Currey

Re: [PATCH kernel 3/3] powerpc/llvm/lto: Workaround conditional branches in FTR_SECTION_ELSE

2022-02-10 Thread Russell Currey
On Fri, 2022-02-11 at 13:31 +1100, Alexey Kardashevskiy wrote: > diff --git a/arch/powerpc/lib/memcpy_64.S > b/arch/powerpc/lib/memcpy_64.S > index 016c91e958d8..286c7e2d0883 100644 > --- a/arch/powerpc/lib/memcpy_64.S > +++ b/arch/powerpc/lib/memcpy_64.S > @@ -50,10 +50,11 @@ ALT_FTR_SECTION_END_I

Re: [PATCH]selftests/powerpc: skip tests for unavailable mitigations.

2021-12-14 Thread Russell Currey
gt; Reported-by: Nageswara R Sastry > Signed-off-by: Sachin Sant Reviewed-by: Russell Currey

Re: [PATCH v2 2/2] powerpc/module_64: Use patch_memory() to apply relocations to loaded modules

2021-12-12 Thread Russell Currey
On Sun, 2021-12-12 at 10:41 +, Christophe Leroy wrote: > > > Le 12/12/2021 à 02:03, Russell Currey a écrit : > > Livepatching a loaded module involves applying relocations through > > apply_relocate_add(), which attempts to write to read-only memory > > when >

Re: [PATCH v2 1/2] powerpc/code-patching: add patch_memory() for writing RO text

2021-12-12 Thread Russell Currey
On Sun, 2021-12-12 at 09:08 +, Christophe Leroy wrote: > Le 12/12/2021 à 02:03, Russell Currey a écrit : > > +static int do_patch_memory(void *dest, const void *src, size_t > > size, unsigned long poke_addr) > > +{ > > +   unsigned long patch_addr = poke_add

Re: [PATCH] powerpc: Add set_memory_{p/np}() and remove set_memory_attr()

2021-12-12 Thread Russell Currey
set_memory_attr(). > > Reported-by: Maxime Bizon > Fixes: c988cfd38e48 ("powerpc/32: use set_memory_attr()") > Cc: sta...@vger.kernel.org > Depends-on: 9f7853d7609d ("powerpc/mm: Fix set_memory_*() against > concurrent accesses") > Signed-off-by: Christophe Leroy Rev

[PATCH v2 2/2] powerpc/module_64: Use patch_memory() to apply relocations to loaded modules

2021-12-11 Thread Russell Currey
map/unmap/flush operations when use of patch_memory() is necessary. This patch also contains some trivial whitespace fixes. Fixes: c35717c71e98 ("powerpc: Set ARCH_HAS_STRICT_MODULE_RWX") Reported-by: Joe Lawrence Signed-off-by: Russell Currey --- v2: No changes. Some discussion

[PATCH v2 1/2] powerpc/code-patching: add patch_memory() for writing RO text

2021-12-11 Thread Russell Currey
/unmap, pte flush and syncs. This patch introduces patch_memory(), implementing the same interface as memcpy(), similar to x86's text_poke() and s390's s390_kernel_write(). patch_memory() only needs to map the text poke area once, unless the write would cross a page boundary. Signed-off-b

[PATCH 2/2] powerpc/module_64: Use patch_memory() to apply relocations to loaded modules

2021-12-11 Thread Russell Currey
map/unmap/flush operations when use of patch_memory() is necessary. This patch also contains some trivial whitespace fixes. Fixes: c35717c71e98 ("powerpc: Set ARCH_HAS_STRICT_MODULE_RWX") Reported-by: Joe Lawrence Signed-off-by: Russell Currey --- Some discussion here:https://github.co

[PATCH 1/2] powerpc/code-patching: add patch_memory() for writing RO text

2021-12-11 Thread Russell Currey
/unmap, pte flush and syncs. This patch introduces patch_memory(), implementing the same interface as memcpy(), similar to x86's text_poke() and s390's s390_kernel_write(). patch_memory() only needs to map the text poke area once, unless the write would cross a page boundary. Signed-off-b

Re: [PATCH] powerpc/module_64: Fix livepatching for RO modules

2021-12-07 Thread Russell Currey
On Tue, 2021-12-07 at 09:44 -0500, Joe Lawrence wrote: > On 11/23/21 3:15 AM, Russell Currey wrote: > > [[ cc += livepatching list ]] > > Hi Russell, > > Thanks for writing a minimal fix for stable / backporting.  As I > mentioned on the github issue [1], this avoided

[PATCH] powerpc/module_64: Fix livepatching for RO modules

2021-11-23 Thread Russell Currey
impact, I observed ~15% overhead in module_load() on POWER8 bare metal with checksum verification off. Fixes: c35717c71e98 ("powerpc: Set ARCH_HAS_STRICT_MODULE_RWX") Cc: sta...@vger.kernel.org # v5.14+ Reported-by: Joe Lawrence Signed-off-by: Russell Currey --- Intended to be a minima

Re: ppc64le STRICT_MODULE_RWX and livepatch apply_relocate_add() crashes

2021-11-01 Thread Russell Currey
On Sun, 2021-10-31 at 22:43 -0400, Joe Lawrence wrote: > Starting with 5.14 kernels, I can reliably reproduce a crash [1] on > ppc64le when loading livepatches containing late klp-relocations [2]. > These are relocations, specific to livepatching, that are resolved not > when a livepatch module is

  1   2   3   4   5   >