use we are only interested in HASHCHK if it's a user space trap.
Fixes: 5bcba4e6c13f ("powerpc/dexcr: Handle hashchk exception")
Signed-off-by: Benjamin Gray
---
v1: https://lore.kernel.org/all/20230825014910.488822-1-bg...@linux.ibm.com/
v1 -> v2: Changed commit description to mentio
manipulation
CONFIG_PPC_KUAP_DEBUG
Adds some extra KAUP checks around interrupts/context switching
CONFIG_PPC_RFI_SRR_DEBUG
Adds some extra SSR checks around interrupts/syscalls
Signed-off-by: Benjamin Gray
---
arch/powerpc/configs/debug.config | 4
1 file changed, 4 insertions
On 17/10/23 5:39 pm, Christophe Leroy wrote:
Le 16/10/2023 à 07:01, Benjamin Gray a écrit :
Currently patch_instruction() bases the write length on the value being
written. If the value looks like a prefixed instruction it writes 8 bytes,
otherwise it writes 4 bytes. This makes it potentially
Adds the definitions and generic handler for prctl control of the
PowerPC Dynamic Execution Control Register (DEXCR).
Signed-off-by: Benjamin Gray
---
include/uapi/linux/prctl.h | 13 +
kernel/sys.c | 16
2 files changed, 29 insertions(+)
diff --git
by the hypervisor via
SPR 455. A bitwise OR of these two SPRs will give the effective
DEXCR aspect state of the process.
Signed-off-by: Benjamin Gray
---
arch/powerpc/include/asm/processor.h | 10 +++
arch/powerpc/kernel/Makefile | 1 +
arch/powerpc/kernel/dexcr.c | 128
: Disable DEXCR SBHE sysctl override
0: Override and set DEXCR[SBHE] aspect to 0
1: Override and set DEXCR[SBHE] aspect to 1
Internally, introduces a mechanism to apply arbitrary system wide
overrides on top of the prctl() config.
Signed-off-by: Benjamin Gray
---
arch/powerpc
. If set, don't
report NPHIE as editable via prctl(), as the prctl() value can never
take effect.
Signed-off-by: Benjamin Gray
---
arch/powerpc/Kconfig| 5 +
arch/powerpc/kernel/dexcr.c | 7 ++-
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/arch/powerpc/Kconfig b/arch
interface could still handle that.
[1]:
https://patchwork.ozlabs.org/project/linuxppc-dev/cover/20230616034846.311705-1-bg...@linux.ibm.com/
Benjamin Gray (6):
powerpc/dexcr: Make all aspects CPU features
powerpc/dexcr: Add thread specific DEXCR configuration
prctl: Define PowerPC DEXCR
r accessed or exposed to userspace, so there is no breakage.
Signed-off-by: Benjamin Gray
---
arch/powerpc/include/asm/cputable.h | 6 +-
arch/powerpc/kernel/prom.c | 3 +++
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/arch/powerpc/include/asm/cputable.h
b/arch/power
Add capability to track a DEXCR value per thread.
Nothing actually changes these values yet, but they are correctly
tracked, propagated, and used to set the hardware register.
Signed-off-by: Benjamin Gray
---
arch/powerpc/include/asm/processor.h | 12
arch/powerpc/kernel/process.c
of the code.
Signed-off-by: Benjamin Gray
---
arch/powerpc/sysdev/mpic.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/powerpc/sysdev/mpic.c b/arch/powerpc/sysdev/mpic.c
index ba287abcb008..dabbdd356664 100644
--- a/arch/powerpc/sysdev/mpic.c
+++ b/arch/powerpc/sysdev
instead of continuing to
sit on it indefinitely.
Benjamin Gray (12):
powerpc/xive: Fix endian conversion size
powerpc/pseries: Restructure hvc_get_chars() endianness
powerpc: Explicitly reverse bytes when checking for byte reversal
powerpc: Use NULL instead of 0 for null pointers
powerpc
: 88ec6b93c8e7 ("powerpc/xive: add OPAL extensions for the XIVE native
exploitation support")
Signed-off-by: Benjamin Gray
---
arch/powerpc/sysdev/xive/native.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/powerpc/sysdev/xive/native.c
b/arch/powerpc/sysdev/xive/nati
-by: Benjamin Gray
---
arch/powerpc/include/asm/opal.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/powerpc/include/asm/opal.h b/arch/powerpc/include/asm/opal.h
index a9b31cc258fc..b66b0c615f4f 100644
--- a/arch/powerpc/include/asm/opal.h
+++ b/arch/powerpc/include/asm/opal.h
Sparse reports dereferencing an __iomem pointer. These routines
are clearly low level handlers for IO memory, so force cast away
the __iomem annotation to tell sparse the dereferences are safe.
Signed-off-by: Benjamin Gray
---
arch/powerpc/kernel/io.c | 12 ++--
1 file changed, 6
Sparse reports a warning when casting to an int. There is no need to
cast in the first place, so drop them.
Signed-off-by: Benjamin Gray
---
arch/powerpc/kernel/eeh_driver.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/kernel/eeh_driver.c b/arch/powerpc
Sparse reports dereference of a __user pointer. copy_mc_to_user() takes
a __user pointer, verifies it, then calls the generic copy routine
copy_mc_generic().
As we have verified the pointer, cast out the __user annotation when
passing to copy_mc_generic().
Signed-off-by: Benjamin Gray
---
arch
with cpu_to_be64() and cast lbuf as an
array of __be64 to match the semantics closer.
Signed-off-by: Benjamin Gray
---
arch/powerpc/platforms/pseries/hvconsole.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/arch/powerpc/platforms/pseries/hvconsole.c
b/arch/powerpc
Sparse reports several function implementations annotated with extern.
This is clearly incorrect, likely just copied from an actual extern
declaration in another file.
Fix the sparse warnings by removing extern.
Signed-off-by: Benjamin Gray
---
arch/powerpc/kernel/iommu.c | 8
Sparse reports several uses of 0 for pointer arguments and comparisons.
Replace with NULL to better convey the intent. Remove entirely if a
comparison to follow the kernel style of implicit boolean conversions.
Signed-off-by: Benjamin Gray
---
arch/powerpc/kernel/setup_64.c| 2 +-
arch
ignore it.
Signed-off-by: Benjamin Gray
---
arch/powerpc/platforms/powernv/opal-fadump.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/powerpc/platforms/powernv/opal-fadump.h
b/arch/powerpc/platforms/powernv/opal-fadump.h
index 3f715efb0aa6..5eeb794b5eb1 100644
---
Sparse reports endianness mismatches in the KVM shared regs getter and
setter helpers.
This code has dynamic endianness behind a safe interface, so a force is
warranted here to tell sparse this is OK.
Signed-off-by: Benjamin Gray
---
arch/powerpc/include/asm/kvm_ppc.h | 8
1 file
are introduced by this patch.
Signed-off-by: Benjamin Gray
---
arch/powerpc/include/asm/book3s/64/pgtable.h| 2 +-
arch/powerpc/include/asm/imc-pmu.h | 16
arch/powerpc/kernel/prom_init.c | 2 +-
arch/powerpc/kexec/core_64.c| 4
the compiler can const-propagate it
away.
Signed-off-by: Benjamin Gray
---
v2: * Deduplicate patch_32() definition
* Use u32 for val32
* Remove noinline
---
arch/powerpc/include/asm/code-patching.h | 33
arch/powerpc/lib/code-patching.c | 66 ++--
2
:
* Addressed the v1 review actions
* Removed noinline (for now)
v1:
https://patchwork.ozlabs.org/project/linuxppc-dev/cover/20230207015643.590684-1-bg...@linux.ibm.com/
Benjamin Gray (3):
powerpc/code-patching: Add generic memory patching
powerpc/64: Convert patch_instruction
ink: https://lore.kernel.org/all/20230203004649.1f59dbd4@yea/
Signed-off-by: Benjamin Gray
---
v2: * Added the fixes tag, it seems appropriate even if the subject does
mention a more robust solution being required.
patch_u64() should be more efficient, but judging from the bug report
it doesn't
flushing when patching data).
Signed-off-by: Benjamin Gray
---
arch/powerpc/kernel/static_call.c | 2 +-
arch/powerpc/platforms/powermac/smp.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/kernel/static_call.c
b/arch/powerpc/kernel/static_call.c
index
s_cpu_read() call in thread_change_pc(). However the
existing __this_cpu_read() that runs if a breakpoint does need to be
re-inserted has the same issue.
Signed-off-by: Benjamin Gray
---
There's probably a more idiomatic way to express this. We technically
don't need to disable preemption for
On 29/8/23 4:34 pm, Benjamin Gray wrote:
When enabling debug config options relating to preemption, several bugs
appear in the kernel log. With this series applied, the breakpoint code
no longer prints bugs when running the powerpc/ptrace selftests.
Benjamin Gray (3):
powerpc/watchpoints
because we are
reading the instruction that just triggered the watchpoint trap.
Signed-off-by: Benjamin Gray
---
arch/powerpc/kernel/hw_breakpoint_constraints.c | 7 ++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/arch/powerpc/kernel/hw_breakpoint_constraints.c
b/arch/powerpc
When enabling debug config options relating to preemption, several bugs
appear in the kernel log. With this series applied, the breakpoint code
no longer prints bugs when running the powerpc/ptrace selftests.
Benjamin Gray (3):
powerpc/watchpoints: Disable preemption in thread_change_pc
It can be easy to miss that the notifier mechanism invokes the callbacks
in an atomic context, so add some comments to that effect on the two
handlers we register here.
Signed-off-by: Benjamin Gray
---
arch/powerpc/kernel/hw_breakpoint.c | 9 +
1 file changed, 9 insertions(+)
diff
a user space trap.
Fixes: 5bcba4e6c13f ("powerpc/dexcr: Handle hashchk exception")
Signed-off-by: Benjamin Gray
---
arch/powerpc/kernel/traps.c | 56 -
1 file changed, 36 insertions(+), 20 deletions(-)
diff --git a/arch/powerpc/kernel/traps.c b/ar
necessary info, but I could not find one.
Benjamin Gray (3):
static_call: Move static call selftest to static_call.c
powerpc/64: Add support for out-of-line static calls
powerpc/64: Add tests for out-of-line static calls
Russell Currey (1):
powerpc/code-patching: add patch_memo
rate
local entry point), and so does not insert the appropriate restoration
at the call site.
Signed-off-by: Benjamin Gray
---
arch/powerpc/Kconfig | 13 +++-
arch/powerpc/include/asm/code-patching.h | 1 +
arch/powerpc/include/asm/static_call.h | 45 -
arch/pow
.
Signed-off-by: Russell Currey
Signed-off-by: Benjamin Gray
---
arch/powerpc/include/asm/code-patching.h | 1 +
arch/powerpc/lib/code-patching.c | 65
2 files changed, 66 insertions(+)
diff --git a/arch/powerpc/include/asm/code-patching.h
b/arch/powerpc/include
These tests are out-of-line only, so moving them to the
out-of-line file allows them to be run when an arch does
not implement inline static calls.
Signed-off-by: Benjamin Gray
---
kernel/static_call.c| 43 +
kernel/static_call_inline.c | 43
possible errors can be caught
by this, but it makes certain kinds of errors easier to debug.
Currently the large arg count test is failing due to the trampoline
implementation using the stack.
Signed-off-by: Benjamin Gray
---
arch/powerpc/Kconfig | 10 +
arch/powerpc/kernel
On Thu, 2022-09-01 at 16:46 +, Christophe Leroy wrote:
> Surprisingly, I get worst performance with inline static call than
> with
> out of line static call:
I'm not sure what hackbench is doing, but when microbenchmarking 64 bit
out-of-line calls in a loop I saw a similar thing where adding
On Mon, 2022-09-26 at 14:54 +, Christophe Leroy wrote:
> > diff --git a/arch/powerpc/kernel/static_call.c
> > b/arch/powerpc/kernel/static_call.c
> > index 863a7aa24650..ecbb74e1b4d3 100644
> > --- a/arch/powerpc/kernel/static_call.c
> > +++ b/arch/powerpc/kernel/static_call.c
> > @@ -4,30
On Mon, 2022-09-26 at 14:55 +, Christophe Leroy wrote:
> > +config PPC_STATIC_CALL_KUNIT_TEST
> > + tristate "KUnit tests for PPC64 ELF ABI V2 static calls"
> > + default KUNIT_ALL_TESTS
> > + depends on HAVE_STATIC_CALL && PPC64_ELF_ABI_V2 && KUNIT &&
> > m
>
> Is there a
On Mon, 2022-09-26 at 14:49 +, Christophe Leroy wrote:
> > + /* Replace indirect branch sequence with direct branch
> > where possible */
> > + if (!create_branch(, jump_seq_addr, addr, 0))
> > + if (patch_instruction(jump_seq_addr, direct))
>
> Why not use
On Mon, 2022-09-26 at 14:33 +, Christophe Leroy wrote:
> > +#define patch_memory(addr, val) \
> > +({ \
> > + BUILD_BUG_ON(!__native_word(val)); \
> > + __patch_memory(addr, (unsigned long) val, sizeof(val)); \
> > +})
>
> Can you do a static __always_inline function instead of a
On Mon, 2022-09-26 at 13:16 +, Christophe Leroy wrote:
> Build failure with GCC 5.5 (ppc64le_defconfig):
>
> CC arch/powerpc/kernel/ptrace/ptrace.o
> {standard input}: Assembler messages:
> {standard input}:10: Error: .localentry expression for
> `__SCT__tp_func_sys_enter' is not a
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: Benjamin Gray
---
arch/powerpc/include/asm/book3s/32/tlbflush.h
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-patching.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/arch
/all/20200603051912.23296-1-...@informatik.wtf/
RFC: https://lore.kernel.org/all/20200323045205.20314-1-...@informatik.wtf/
x86:
https://lore.kernel.org/kernel-hardening/20190426232303.28381-1-nadav.a...@gmail.com/
Benjamin Gray (5):
powerpc/code-patching: Use WARN_ON and fix check in poking_init
powerpc/
current_brk[]. Add a pause_breakpoints() function which will
clear the breakpoint registers without touching the state in
current_bkr[]. Add a pair function unpause_breakpoints() which will move
the state in current_brk[] back to the registers.
Signed-off-by: Jordan Niethe
Signed-off-by: Benjamin
le".
Also take this opportunity to fix the failure check in the WARN_ON():
cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, ...) returns a positive integer
on success and a negative integer on failure.
Signed-off-by: Benjamin Gray
---
arch/powerpc/lib/code-patching.c | 13 +
1 file c
ches in a row (e.g.,
as ftrace would).
Signed-off-by: Benjamin Gray
---
arch/powerpc/lib/code-patching.c | 226 ++-
1 file changed, 221 insertions(+), 5 deletions(-)
diff --git a/arch/powerpc/lib/code-patching.c b/arch/powerpc/lib/code-patching.c
index 9b9eba574d7e..eabdd74a
With the isolated mm context support, there is a CPU local variable that
can hold the patch address. Use it instead of adding a level of
indirection through the text_poke_area vm_struct.
Signed-off-by: Benjamin Gray
---
arch/powerpc/lib/code-patching.c | 3 ++-
1 file changed, 2 insertions
.
This removes the need to create a vm_area_struct, which the temporary
patching mm work does not need.
Signed-off-by: Benjamin Gray
---
v9: * Replace book3s/32/tlbflush.h implementation with warning
---
arch/powerpc/include/asm/book3s/32/tlbflush.h | 9 +
arch/powerpc/include/asm
-by: Benjamin Gray
---
v9: * Renamed set_breakpoint to set_hw_breakpoint
* Renamed pause/unpause to suspend/restore
* Removed unrelated whitespace change
---
arch/powerpc/include/asm/debug.h | 2 ++
arch/powerpc/kernel/process.c| 38 +---
2 files
rmatik.wtf/
x86:
https://lore.kernel.org/kernel-hardening/20190426232303.28381-1-nadav.a...@gmail.com/
Benjamin Gray (7):
powerpc: Allow clearing and restoring registers independent of saved
breakpoint state
powerpc/code-patching: Handle RWX patching initialisation error
powerpc/cod
of cpuhp_setup_state() is also >= 0 on success,
so check for < 0.
Signed-off-by: Benjamin Gray
Reviewed-by: Russell Currey
---
v9: * Reword commit message to explain why init failure is not fatal
---
arch/powerpc/lib/code-patching.c | 13 +
1 file changed, 5 insertions(+), 8 del
On Mon, 2022-10-24 at 14:20 +1100, Russell Currey wrote:
> On Fri, 2022-10-21 at 16:22 +1100, Benjamin Gray wrote:
> > diff --git a/arch/powerpc/lib/code-patching.c
> > b/arch/powerpc/lib/code-patching.c
> > index 34fc7ac34d91..9b9eba574d7e 100644
> > --- a/arch/
ignores the AMR (so no need to unlock/lock KUAP) according to
PowerISA v3.0b Figure 35 on Radix.
Based on x86 implementation:
commit 4fc19708b165
("x86/alternatives: Initialize temporary mm for patching")
and:
commit b3fd8e83ada0
("x86/alternatives: Use temporary mm for
-by: Benjamin Gray
---
v9: * Consolidate patching context into single struct
---
arch/powerpc/lib/code-patching.c | 58 ++--
1 file changed, 33 insertions(+), 25 deletions(-)
diff --git a/arch/powerpc/lib/code-patching.c b/arch/powerpc/lib/code-patching.c
index
is
dereferenced.
Signed-off-by: Benjamin Gray
---
v9: * New in v9
---
arch/powerpc/lib/code-patching.c | 8 +++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/arch/powerpc/lib/code-patching.c b/arch/powerpc/lib/code-patching.c
index ad0cf3108dd0..54e145247643 100644
--- a/arch/powerpc
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-patching.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/arch
It occurred to me that we don't require holding a lock when patching
text. Many use cases do hold text_mutex, but it's not required, so it's
possible for this warning to show false positives.
If we do want text_mutex be held, then lockdep_assert_held(_mutex)
ought to be added too.
On Tue, 2022-10-25 at 13:10 +1100, Andrew Donnellan wrote:
> On Mon, 2022-10-10 at 11:29 +1100, Benjamin Gray wrote:
> > > A function symbol may set a value in the st_other field to
> > > indicate
> > > the TOC should be treated as caller-saved. The linker should
&
On Mon, 2022-10-24 at 14:45 +1100, Russell Currey wrote:
> 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
On Mon, 2022-10-24 at 14:30 +1100, Russell Currey wrote:
> 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
On Mon, 2022-09-19 at 07:16 +, Christophe Leroy wrote:
> Why would it be unpredictable ? Only one page is mapped. If it
> crosses
> the boundary, __put_kernel_nofault() will fail in a controled manner.
> I see no point in doing the check before every write.
Oh I didn't see that get_vm_area
On Mon, 2022-09-19 at 06:38 +, Christophe Leroy wrote:
> Le 16/09/2022 à 08:23, Benjamin Gray a écrit :
> > [...]
> > + /* Make sure we aren't patching a freed init section */
> > + if (static_branch_likely(_mem_is_free) &&
>
On Tue, 2022-09-20 at 05:44 +, Christophe Leroy wrote:
>
> As far as I know, cachelines are minimum 64 bytes on PPC64 aren't
> they ?
In practice maybe. I don't know what the convention is in the kernel in
cases where the ISA is less specific than what the supported machines
do.
> > Related
On Thu, 2022-09-01 at 15:58 +1000, Benjamin Gray wrote:
> So not having a local entry point implies not using a TOC
> pointer, which
> implies r2 is volatile if the trampoline does not guarantee that
> it preserves
> r2. However experimenting with such a trampoline show
On Mon, 2022-09-19 at 06:04 +, Christophe Leroy wrote:
> With CONFIG_STRICT_KERNEL_RWX, this patches causes a 15% time
> increase
> for activation/deactivation of ftrace.
It's possible that new alignment check is the cause. I'll see
> Without CONFIG_STRICT_KERNEL_RWX, it doesn't build.
function. This generic implementation allows patching of
arbitrary 64-bit data, whereas the original `patch_instruction` decided
the size based on the 'instruction' opcode, so was not suitable for
arbitrary data.
Signed-off-by: Benjamin Gray
---
arch/powerpc/include/asm/code-patching.h | 7 ++
arch
-volatile
registers in the init hook, but that's incorrect because it returns to
the KUnit framework before the test case is called).
* Some other minor refactoring in other patches
Benjamin Gray (6):
powerpc/code-patching: Implement generic text patching function
powerpc/module: Handle
possible errors can be caught
by this (we can't stop a trampoline from using a bad TOC itself),
but it makes certain errors easier to debug.
Signed-off-by: Benjamin Gray
---
arch/powerpc/Kconfig | 10 +
arch/powerpc/kernel/Makefile | 1 +
arch/powerpc/kernel
call implementation, where modules calling their
own trampolines are called through this stub and the trampoline is
easily within range of a direct branch.
Signed-off-by: Benjamin Gray
---
arch/powerpc/kernel/module_64.c | 13 +
1 file changed, 13 insertions(+)
diff --git a/arch
text, so it's quite expensive.
Signed-off-by: Benjamin Gray
---
arch/powerpc/Kconfig | 2 +-
arch/powerpc/include/asm/code-patching.h | 1 +
arch/powerpc/include/asm/static_call.h | 80 +++--
arch/powerpc/kernel/Makefile | 3 +-
arch/powerpc/ke
These tests are out-of-line only, so moving them to the
their own file allows them to be run when an arch does
not implement inline static calls.
Signed-off-by: Benjamin Gray
---
kernel/Makefile | 1 +
kernel/static_call_inline.c | 43 ---
kernel
not
preserve the TOC.
Signed-off-by: Benjamin Gray
---
arch/powerpc/kernel/module_64.c | 14 +-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/arch/powerpc/kernel/module_64.c b/arch/powerpc/kernel/module_64.c
index 7e45dc98df8a..4d816f7785b4 100644
--- a/arch/powerpc/kernel
. This generic implementation allows patching of
arbitrary 64-bit data, whereas the original `patch_instruction` decided
the size based on the 'instruction' opcode, so was not suitable for
arbitrary data.
Signed-off-by: Benjamin Gray
---
arch/powerpc/include/asm/code-patching.h | 1 +
arch/powerpc/lib
not
preserve the TOC.
Signed-off-by: Benjamin Gray
---
arch/powerpc/kernel/module_64.c | 12 +++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/arch/powerpc/kernel/module_64.c b/arch/powerpc/kernel/module_64.c
index 7e45dc98df8a..3656476097c2 100644
--- a/arch/powerpc/kernel
is the same
as the
enum name it was generated from, which confuses the compiler when it reaches
said enum
definition.
Benjamin Gray (6):
powerpc/code-patching: Implement generic text patching function
powerpc/module: Handle caller-saved TOC in module linker
powerpc/module: Optimise nearby branch
call implementation, where modules calling their
own trampolines are called through this stub and the trampoline is
easily within range of a direct branch.
Signed-off-by: Benjamin Gray
---
arch/powerpc/kernel/module_64.c | 13 +++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff
text, so it's quite expensive.
Signed-off-by: Benjamin Gray
---
arch/powerpc/Kconfig | 12 +++-
arch/powerpc/include/asm/code-patching.h | 1 +
arch/powerpc/include/asm/static_call.h | 80 +++--
arch/powerpc/kernel/Makefile | 3 +-
arch/pow
possible errors can be caught
by this (we can't stop a trampoline from using a bad TOC itself),
but it makes certain errors easier to debug.
Signed-off-by: Benjamin Gray
---
arch/powerpc/Kconfig | 10 +
arch/powerpc/kernel/Makefile | 1 +
arch/powerpc/kernel
These tests are out-of-line only, so moving them to the
their own file allows them to be run when an arch does
not implement inline static calls.
Signed-off-by: Benjamin Gray
---
kernel/Makefile | 1 +
kernel/static_call_inline.c | 43 ---
kernel
ELF V2 ABI the tests try to mitigate the chance of panicking
by restoring the TOC after every static call. Not all possible errors
can be caught by this (we can't stop a trampoline from using a bad TOC
itself), but it makes certain errors easier to debug.
Signed-off-by: Benjamin Gray
---
arch
noinline to prevent a mis-optimisation.
Without noinline, inside patch_branch the compiler may inline all the
way to do_patch_memory, preventing the compiler from inlining
do_patch_memory into patch_int. This would needlessly force patch_int
to be a branch to do_patch_memory.
Signed-off-by: Benjamin
text, so it's quite expensive.
Signed-off-by: Benjamin Gray
---
arch/powerpc/Kconfig | 14 ++-
arch/powerpc/include/asm/code-patching.h | 1 +
arch/powerpc/include/asm/static_call.h | 80 +-
arch/powerpc/kernel/Makefile | 3 +-
arch/powerpc/ke
not
preserve the TOC.
Signed-off-by: Benjamin Gray
---
arch/powerpc/kernel/module_64.c | 14 +-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/arch/powerpc/kernel/module_64.c b/arch/powerpc/kernel/module_64.c
index 7e45dc98df8a..4d816f7785b4 100644
--- a/arch/powerpc/kernel
them in two steps.
[6/6]
* Replaced SAVE_REGS/RESTORE_REGS macros with functions
* Reduced global register usage of tests
* Support running on 32-bit as well
Benjamin Gray (6):
powerpc/code-patching: Implement generic text patching function
powerpc/module: Handle caller-saved TOC in module li
These tests are out-of-line only, so moving them to the
their own file allows them to be run when an arch does
not implement inline static calls.
Signed-off-by: Benjamin Gray
Reviewed-by: Andrew Donnellan
---
kernel/Makefile | 1 +
kernel/static_call_inline.c | 43
call implementation, where modules calling their
own trampolines are called through this stub and the trampoline is
easily within range of a direct branch.
Signed-off-by: Benjamin Gray
---
arch/powerpc/kernel/module_64.c | 12
1 file changed, 12 insertions(+)
diff --git a/arch/powerpc
On Thu, 2022-10-06 at 11:39 +1100, Michael Ellerman wrote:
> Christophe Leroy writes:
> > However, thinking out loudly, I'm wondering, could we make things
> > any
> > simpler when CONFIG_MODULES is not selected, or is that a too much
> > corner case on PPC64 ?
>
> I'd say it's mostly a corner
On Wed, 2022-10-05 at 17:55 +, Christophe Leroy wrote:
> I'm on business trip this week so I can't test it on hardware, but
> the
> generated code looks horrid and sub-optimal, with a stack frame and
> so
> many registers saved into it. That's mpc885_ads_defconfig built with
> GCC
> 12,
On Wed, 2022-10-05 at 19:18 +, Christophe Leroy wrote:
>
>
> Le 05/10/2022 à 07:32, Benjamin Gray a écrit :
> > The callee may set a field in st_other to 1 to indicate r2 should
> > be
> > treated as caller-saved. This means a trampoline must be used to
> >
On Thu, 2022-10-06 at 09:19 +, Christophe Leroy wrote:
>
>
> Le 06/10/2022 à 05:36, Benjamin Gray a écrit :
> > On Wed, 2022-10-05 at 17:55 +, Christophe Leroy wrote:
> > > I'm on business trip this week so I can't test it on hardware,
> > > but
>
not
preserve the TOC.
Signed-off-by: Benjamin Gray
---
arch/powerpc/kernel/module_64.c | 14 +-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/arch/powerpc/kernel/module_64.c b/arch/powerpc/kernel/module_64.c
index 7e45dc98df8a..83a6f6e22e3b 100644
--- a/arch/powerpc
y 64-bit requires
doubleword writes anyway, as ints and longs are the same size on 32-bit.
Signed-off-by: Benjamin Gray
---
arch/powerpc/include/asm/code-patching.h | 29 ++
arch/powerpc/lib/code-patching.c | 73 ++--
2 files changed, 85 insertions(+), 17 d
These tests are out-of-line only, so moving them to the
their own file allows them to be run when an arch does
not implement inline static calls.
Signed-off-by: Benjamin Gray
Reviewed-by: Andrew Donnellan
Reviewed-by: Christophe Leroy
---
kernel/Makefile | 1 +
kernel
text, so it's quite expensive.
Signed-off-by: Benjamin Gray
Reviewed-by: Christophe Leroy
---
arch/powerpc/Kconfig | 14 ++-
arch/powerpc/include/asm/code-patching.h | 1 +
arch/powerpc/include/asm/static_call.h | 80 +-
arch/powerpc/kernel/Make
call implementation, where modules calling their
own trampolines are called through this stub and the trampoline is
easily within range of a direct branch.
Signed-off-by: Benjamin Gray
Reviewed-by: Christophe Leroy
Reviewed-by: Andrew Donnellan
---
arch/powerpc/kernel/module_64.c | 12
* Refactored need r2 save expression. Parens are intentional, C operator
precedence can be difficult to remember, especially when three different
kinds are used in a single expression.
Benjamin Gray (6):
powerpc/code-patching: Implement generic text patching function
powerpc/module: Handle
1 - 100 of 328 matches
Mail list logo