powerpc/32: Implement C syscall entry/exit
v4 cover powerpc/32: Implement C syscall entry/exit
This series implements C syscall entry/exit for PPC32. It reuses the work already done for PPC64.
This series is based on Nick's v6 series "powerpc: interrupt wrappers".
Patch 1 is a bug fix submitted separately but this series depends on it. Patches 2-4 are an extract from the series "powerpc/32: Reduce head complexity and re-activate MMU earlier". The changes here are limited to system calls. That series will be respined to only contain exception related changes and the syscall changes will remain in this series. Patches 5-16 are preparatory changes.
Patch 17 is THE patch that changes to C syscall entry/exit Patches 18-23 are optimisations.
In terms on performance we have the following number of cycles on an 8xx running null_syscall benchmark:
- mainline: 296 cycles
- after patch 4: 283 cycles
- after patch 16: 304 cycles
- after patch 17: 348 cycles
- at the end of the series: 320 cycles
So in summary, we have a degradation of performance of 8% on null_syscall.
I think it is not a big degradation, it is worth it.
v4 is the first mature version.
Christophe Leroy (23):
powerpc/32s: Add missing call to kuep_lock on syscall entry powerpc/32: Always enable data translation on syscall entry powerpc/32: On syscall entry, enable instruction translation at the
same time as data
powerpc/32: Reorder instructions to avoid using CTR in syscall entry powerpc/64s: Make kuap_check_amr() and kuap_get_and_check_amr()
generic
powerpc/32s: Create C version of kuap_user/kernel_restore() and
friends
powerpc/8xx: Create C version of kuap_user/kernel_restore() and
friends
powerpc/irq: Add helper to set regs->softe
powerpc/irq: Rework helpers that manipulate MSR[EE/RI] powerpc/irq: Add stub irq_soft_mask_return() for PPC32 powerpc/syscall: Rename syscall_64.c into syscall.c powerpc/syscall: Make syscall.c buildable on PPC32 powerpc/syscall: Use is_compat_task()
powerpc/syscall: Save r3 in regs->orig_r3
powerpc/syscall: Change condition to check MSR_RI powerpc/32: Always save non volatile GPRs at syscall entry powerpc/syscall: implement system call entry/exit logic in C for PPC32 powerpc/32: Remove verification of MSR_PR on syscall in the ASM entry powerpc/syscall: Avoid stack frame in likely part of
system_call_exception()
powerpc/syscall: Do not check unsupported scv vector on PPC32 powerpc/syscall: Remove FULL_REGS verification in
system_call_exception
powerpc/syscall: Optimise checks in beginning of
system_call_exception()
powerpc/syscall: Avoid storing 'current' in another pointer
arch/powerpc/include/asm/book3s/32/kup.h | 33 ++
arch/powerpc/include/asm/book3s/64/kup.h | 24 +-
arch/powerpc/include/asm/hw_irq.h | 91 ++++--
arch/powerpc/include/asm/kup.h | 9 +-
arch/powerpc/include/asm/nohash/32/kup-8xx.h | 27 ++
arch/powerpc/include/asm/reg.h | 1 +
arch/powerpc/kernel/Makefile | 4 +-
arch/powerpc/kernel/entry_32.S | 305 ++----------------
arch/powerpc/kernel/entry_64.S | 1 -
arch/powerpc/kernel/head_32.h | 76 +----
arch/powerpc/kernel/head_booke.h | 27 +-
.../kernel/{syscall_64.c => syscall.c} | 57 ++--
arch/powerpc/kernel/syscalls/syscall.tbl | 20 +-
13 files changed, 225 insertions(+), 450 deletions(-)
rename arch/powerpc/kernel/{syscall_64.c => syscall.c} (90%)Signature · 1 line
2.25.0
PATCH v4 1/23 powerpc/32s: Add missing call to kuep_lock on syscall entry
Userspace Execution protection and fast syscall entry were implemented independently from each other and were both merged in kernel 5.2, leading to syscall entry missing userspace execution protection.
On syscall entry, execution of user space memory must be locked in the same way as on exception entry.
--- arch/powerpc/kernel/entry_32.S | 3 +++ 1 file changed, 3 insertions(+)
arch/powerpc/kernel/entry_32.S +3 -0
@@ -351,6 +351,9 @@ trace_syscall_entry_irq_off: .globl transfer_to_syscall transfer_to_syscall: +#ifdef CONFIG_PPC_BOOK3S_32 + kuep_lock r11, r12 +#endif #ifdef CONFIG_TRACE_IRQFLAGS andi. r12,r9,MSR_EE beq- trace_syscall_entry_irq_off
Signature · 1 line
2.25.0
PATCH v4 2/23 powerpc/32: Always enable data translation on syscall entry
In reply to Christophe LeroyIf the code can use a stack in vm area, it can also use a stack in linear space.
Simplify code by removing old non VMAP stack code on PPC32 in syscall.
That means the data translation is now re-enabled early in syscall entry in all cases, not only when using VMAP stacks.
--- arch/powerpc/kernel/head_32.h | 23 +---------------------- arch/powerpc/kernel/head_booke.h | 2 -- 2 files changed, 1 insertion(+), 24 deletions(-)
arch/powerpc/kernel/head_32.h +1 -22
@@ -118,7 +118,6 @@ .macro SYSCALL_ENTRY trapno mfspr r12,SPRN_SPRG_THREAD mfspr r9, SPRN_SRR1 -#ifdef CONFIG_VMAP_STACK mfspr r11, SPRN_SRR0 mtctr r11 andi. r11, r9, MSR_PR
@@ -126,30 +125,16 @@ lwz r1,TASK_STACK-THREAD(r12) beq- 99f addi r1, r1, THREAD_SIZE - INT_FRAME_SIZE - li r10, MSR_KERNEL & ~(MSR_IR | MSR_RI) /* can take DTLB miss */ + LOAD_REG_IMMEDIATE(r10, MSR_KERNEL & ~(MSR_IR | MSR_RI)) /* can take DTLB miss */ mtmsr r10 isync tovirt(r12, r12) stw r11,GPR1(r1) stw r11,0(r1) mr r11, r1 -#else - andi. r11, r9, MSR_PR - lwz r11,TASK_STACK-THREAD(r12) - beq- 99f - addi r11, r11, THREAD_SIZE - INT_FRAME_SIZE - tophys(r11, r11) - stw r1,GPR1(r11) - stw r1,0(r11) - tovirt(r1, r11) /* set new kernel sp */ -#endif mflr r10 stw r10, _LINK(r11) -#ifdef CONFIG_VMAP_STACK mfctr r10 -#else - mfspr r10,SPRN_SRR0 -#endif stw r10,_NIP(r11) mfcr r10 rlwinm r10,r10,0,4,2 /* Clear SO bit in CR */
@@ -157,11 +142,7 @@#ifdef CONFIG_40x rlwinm r9,r9,0,14,12 /* clear MSR_WE (necessary?) */ #else -#ifdef CONFIG_VMAP_STACK LOAD_REG_IMMEDIATE(r10, MSR_KERNEL & ~MSR_IR) /* can take exceptions */ -#else - LOAD_REG_IMMEDIATE(r10, MSR_KERNEL & ~(MSR_IR|MSR_DR)) /* can take exceptions */ -#endif mtmsr r10 /* (except for mach check in rtas) */ #endif lis r10,STACK_FRAME_REGS_MARKER@ha /* exception frame marker */
@@ -190,7 +171,6 @@ li r12,-1 /* clear all pending debug events */ mtspr SPRN_DBSR,r12 lis r11,global_dbcr0@ha - tophys(r11,r11) addi r11,r11,global_dbcr0@l lwz r12,0(r11) mtspr SPRN_DBCR0,r12
@@ -200,7 +180,6 @@#endif 3: -tovirt_novmstack r2, r2/* set r2 to current */ lis r11, transfer_to_syscall@h ori r11, r11, transfer_to_syscall@l #ifdef CONFIG_TRACE_IRQFLAGS
arch/powerpc/kernel/head_booke.h +0 -2
@@ -144,7 +144,6 @@ ALT_FTR_SECTION_END_IFSET(CPU_FTR_EMB_HV) li r12,-1 /* clear all pending debug events */ mtspr SPRN_DBSR,r12 lis r11,global_dbcr0@ha - tophys(r11,r11) addi r11,r11,global_dbcr0@l #ifdef CONFIG_SMP lwz r10, TASK_CPU(r2)
@@ -158,7 +157,6 @@ ALT_FTR_SECTION_END_IFSET(CPU_FTR_EMB_HV) stw r12,4(r11) 3: - tovirt(r2, r2) /* set r2 to current */ lis r11, transfer_to_syscall@h ori r11, r11, transfer_to_syscall@l #ifdef CONFIG_TRACE_IRQFLAGS
Signature · 1 line
2.25.0
PATCH v4 3/23 powerpc/32: On syscall entry, enable instruction translation at the same time as data
In reply to Christophe LeroyOn 40x and 8xx, kernel text is pinned.
On book3s/32, kernel text is mapped by BATs.
Enable instruction translation at the same time as data translation, it makes things simpler.
MSR_RI can also be set at the same time because srr0/srr1 are already saved and r1 is set properly.
On booke, translation is always on, so at the end all PPC32 have translation on early.
This reduces null_syscall benchmark by 13 cycles on 8xx (296 ==> 283 cycles).
--- arch/powerpc/kernel/head_32.h | 26 +++++++++----------------- arch/powerpc/kernel/head_booke.h | 7 ++----- 2 files changed, 11 insertions(+), 22 deletions(-)
arch/powerpc/kernel/head_32.h +9 -17
@@ -125,9 +125,13 @@ lwz r1,TASK_STACK-THREAD(r12) beq- 99f addi r1, r1, THREAD_SIZE - INT_FRAME_SIZE - LOAD_REG_IMMEDIATE(r10, MSR_KERNEL & ~(MSR_IR | MSR_RI)) /* can take DTLB miss */ - mtmsr r10 - isync + LOAD_REG_IMMEDIATE(r10, MSR_KERNEL) /* can take exceptions */ + mtspr SPRN_SRR1, r10 + lis r10, 1f@h + ori r10, r10, 1f@l + mtspr SPRN_SRR0, r10 + rfi +1: tovirt(r12, r12) stw r11,GPR1(r1) stw r11,0(r1)
@@ -141,9 +145,6 @@ stw r10,_CCR(r11) /* save registers */#ifdef CONFIG_40x rlwinm r9,r9,0,14,12 /* clear MSR_WE (necessary?) */ -#else - LOAD_REG_IMMEDIATE(r10, MSR_KERNEL & ~MSR_IR) /* can take exceptions */ - mtmsr r10 /* (except for mach check in rtas) */ #endif lis r10,STACK_FRAME_REGS_MARKER@ha /* exception frame marker */ stw r2,GPR2(r11)
@@ -180,8 +181,6 @@#endif 3: - lis r11, transfer_to_syscall@h - ori r11, r11, transfer_to_syscall@l#ifdef CONFIG_TRACE_IRQFLAGS /* * If MSR is changing we need to keep interrupts disabled at this point
@@ -193,15 +192,8 @@#else LOAD_REG_IMMEDIATE(r10, MSR_KERNEL | MSR_EE)#endif -#if defined(CONFIG_PPC_8xx) && defined(CONFIG_PERF_EVENTS ) - mtspr SPRN_NRI, r0 -#endif -mtspr SPRN_SRR1 ,r10 - mtspr SPRN_SRR0,r11 - rfi /* jump to handler, enable MMU */ -#ifdef CONFIG_40x - b . /* Prevent prefetch past rfi */ -#endif + mtmsr r10 +b transfer_to_syscall/* jump to handler */ 99: b ret_from_kernel_syscall .endm
arch/powerpc/kernel/head_booke.h +2 -5
@@ -157,8 +157,6 @@ ALT_FTR_SECTION_END_IFSET(CPU_FTR_EMB_HV) stw r12,4(r11) 3: - lis r11, transfer_to_syscall@h - ori r11, r11, transfer_to_syscall@l#ifdef CONFIG_TRACE_IRQFLAGS /* * If MSR is changing we need to keep interrupts disabled at this point
@@ -172,9 +170,8 @@ ALT_FTR_SECTION_END_IFSET(CPU_FTR_EMB_HV) lis r10, (MSR_KERNEL | MSR_EE)@h ori r10, r10, (MSR_KERNEL | MSR_EE)@l #endif - mtspr SPRN_SRR1,r10 - mtspr SPRN_SRR0,r11 - rfi /* jump to handler, enable MMU */ + mtmsr r10 + b transfer_to_syscall /* jump to handler */ 99: b ret_from_kernel_syscall .endm
Signature · 1 line
2.25.0
PATCH v4 4/23 powerpc/32: Reorder instructions to avoid using CTR in syscall entry
In reply to Christophe LeroyNow that we are using rfi instead of mtmsr to reactivate MMU, it is possible to reorder instructions and avoid the need to use CTR for stashing SRR0.
null_syscall on 8xx is reduced by 3 cycles (283 => 280 cycles).
--- arch/powerpc/kernel/head_32.h | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-)
arch/powerpc/kernel/head_32.h +10 -12
@@ -116,30 +116,28 @@ .endm .macro SYSCALL_ENTRY trapno - mfspr r12,SPRN_SPRG_THREAD mfspr r9, SPRN_SRR1 - mfspr r11, SPRN_SRR0 - mtctr r11 + mfspr r10, SPRN_SRR0 andi. r11, r9, MSR_PR + beq- 99f + LOAD_REG_IMMEDIATE(r11, MSR_KERNEL) /* can take exceptions */ + lis r12, 1f@h + ori r12, r12, 1f@l + mtspr SPRN_SRR1, r11 + mtspr SPRN_SRR0, r12 + mfspr r12,SPRN_SPRG_THREAD mr r11, r1 lwz r1,TASK_STACK-THREAD(r12) - beq- 99f + tovirt(r12, r12) addi r1, r1, THREAD_SIZE - INT_FRAME_SIZE - LOAD_REG_IMMEDIATE(r10, MSR_KERNEL) /* can take exceptions */ - mtspr SPRN_SRR1, r10 - lis r10, 1f@h - ori r10, r10, 1f@l - mtspr SPRN_SRR0, r10 rfi 1: - tovirt(r12, r12) stw r11,GPR1(r1) stw r11,0(r1) mr r11, r1 + stw r10,_NIP(r11) mflr r10 stw r10, _LINK(r11) - mfctr r10 - stw r10,_NIP(r11) mfcr r10 rlwinm r10,r10,0,4,2 /* Clear SO bit in CR */ stw r10,_CCR(r11) /* save registers */
Signature · 1 line
2.25.0
PATCH v4 5/23 powerpc/64s: Make kuap_check_amr() and kuap_get_and_check_amr() generic
In reply to Christophe LeroyIn preparation of porting powerpc32 to C syscall entry/exit, rename kuap_check_amr() and kuap_get_and_check_amr() as kuap_check() and kuap_get_and_check(), and move in the generic asm/kup.h the stub for when CONFIG_PPC_KUAP is not selected.
--- arch/powerpc/include/asm/book3s/64/kup.h | 24 ++---------------------- arch/powerpc/include/asm/kup.h | 9 ++++++++- arch/powerpc/kernel/syscall_64.c | 12 ++++++------ 3 files changed, 16 insertions(+), 29 deletions(-)
arch/powerpc/include/asm/book3s/64/kup.h +2 -22
@@ -281,7 +281,7 @@ static inline void kuap_kernel_restore(struct pt_regs *regs,*/ } -static inline unsigned long kuap_get_and_check_amr (void ) +static inline unsigned long kuap_get_and_check (void ) {if (mmu_has_feature (MMU_FTR_BOOK3S_KUAP )) {unsigned long amr =mfspr (SPRN_AMR );
@@ -292,27 +292,7 @@ static inline unsigned long kuap_get_and_check_amr(void)return 0 ; } -#else /* CONFIG_PPC_PKEY */ - -static inline void kuap_user_restore (struct pt_regs *regs) -{ -} - -static inline void kuap_kernel_restore (struct pt_regs *regs,unsigned long amr) -{ -} - -static inline unsigned long kuap_get_and_check_amr (void ) -{ -return 0 ; -} - -#endif /* CONFIG_PPC_PKEY */ - - -#ifdef CONFIG_PPC_KUAP - -static inline void kuap_check_amr (void ) +static inline void kuap_check (void ) {if (IS_ENABLED (CONFIG_PPC_KUAP_DEBUG ) &&mmu_has_feature (MMU_FTR_BOOK3S_KUAP ))WARN_ON_ONCE (mfspr (SPRN_AMR ) !=AMR_KUAP_BLOCKED );
arch/powerpc/include/asm/kup.h +8 -1
@@ -66,7 +66,14 @@ bad_kuap_fault(struct pt_regs *regs, unsigned long address, bool is_write)return false; } -static inline void kuap_check_amr (void ) { } +static inline void kuap_check (void ) { } +static inline void kuap_user_restore (struct pt_regs *regs) { } +static inline void kuap_kernel_restore (struct pt_regs *regs,unsigned long amr) { } + +static inline unsigned long kuap_get_and_check (void ) +{ +return 0 ; +}/* * book3s/64/kup-radix.h defines these functions for the !KUAP case to flush
arch/powerpc/kernel/syscall_64.c +6 -6
@@ -65,7 +65,7 @@ notrace long system_call_exception(long r3, long r4, long r5,isync (); } else#endif -kuap_check_amr (); +kuap_check ();account_cpu_user_entry ();
@@ -181,7 +181,7 @@ notrace unsigned long syscall_exit_prepare(unsigned long r3,CT_WARN_ON (ct_state () ==CONTEXT_USER ); -kuap_check_amr (); +kuap_check (); regs->result = r3;
@@ -303,7 +303,7 @@ notrace unsigned long interrupt_exit_user_prepare(struct pt_regs *regs, unsigned* We don't need to restore AMR on the way back to userspace for KUAP. * AMR can only have been unlocked if we interrupted the kernel. */ -kuap_check_amr (); +kuap_check ();local_irq_save (flags);
@@ -381,7 +381,7 @@ notrace unsigned long interrupt_exit_kernel_prepare(struct pt_regs *regs, unsignunsigned long *ti_flagsp = ¤t_thread_info ()->flags;unsigned long flags;unsigned long ret =0 ; -unsigned long amr; +unsigned long kuap;if (IS_ENABLED (CONFIG_PPC_BOOK3S ) &&unlikely (!(regs->msr &MSR_RI )))unrecoverable_exception (regs);
@@ -394,7 +394,7 @@ notrace unsigned long interrupt_exit_kernel_prepare(struct pt_regs *regs, unsignif (TRAP (regs) !=0x700 )CT_WARN_ON (ct_state () ==CONTEXT_USER ); - amr =kuap_get_and_check_amr (); + kuap =kuap_get_and_check ();if (unlikely (*ti_flagsp & _TIF_EMULATE_STACK_STORE)) {clear_bits (_TIF_EMULATE_STACK_STORE, ti_flagsp);
@@ -446,7 +446,7 @@ notrace unsigned long interrupt_exit_kernel_prepare(struct pt_regs *regs, unsign* which would cause Read-After-Write stalls. Hence, we take the AMR * value from the check above. */ -kuap_kernel_restore (regs, amr); +kuap_kernel_restore (regs, kuap);return ret; }
Signature · 1 line
2.25.0
PATCH v4 6/23 powerpc/32s: Create C version of kuap_user/kernel_restore() and friends
In reply to Christophe LeroyIn preparation of porting PPC32 to C syscall entry/exit, create C version of kuap_user_restore() and kuap_kernel_restore() and kuap_check() and kuap_get_and_check() on book3s/32.
--- arch/powerpc/include/asm/book3s/32/kup.h | 33 ++++++++++++++++++++++++ 1 file changed, 33 insertions(+)
arch/powerpc/include/asm/book3s/32/kup.h +33 -0
@@ -103,6 +103,39 @@ static inline void kuap_update_sr(u32 sr, u32 addr, u32 end)isync ();/* Context sync required after mtsrin() */ } +static inline void kuap_user_restore (struct pt_regs *regs) +{ +} + +static inline void kuap_kernel_restore (struct pt_regs *regs,unsigned long kuap) +{ +u32 addr = kuap &0xf0000000 ; +u32 end = kuap <<28 ; + +if (unlikely (!kuap)) +return ; + + current->thread.kuap =0 ; +kuap_update_sr (mfsrin (addr) & ~SR_KS , addr, end);/* Clear Ks */ +} + +static inline void kuap_check (void ) +{ +if (!IS_ENABLED (CONFIG_PPC_KUAP_DEBUG )) +return ; + +WARN_ON_ONCE (current->thread.kuap !=0 ); +} + +static inline unsigned long kuap_get_and_check (void ) +{ +unsigned long kuap = current->thread.kuap; + +WARN_ON_ONCE (IS_ENABLED (CONFIG_PPC_KUAP_DEBUG ) && kuap !=0 ); + +return kuap; +} + static __always_inline void allow_user_access(void __user *to, const void __user *from,u32 size,unsigned long dir) {
Signature · 1 line
2.25.0
PATCH v4 7/23 powerpc/8xx: Create C version of kuap_user/kernel_restore() and friends
In reply to Christophe LeroyIn preparation of porting PPC32 to C syscall entry/exit, create C version of kuap_user_restore() and kuap_kernel_restore() and kuap_check() and kuap_get_and_check() on 8xx
--- arch/powerpc/include/asm/nohash/32/kup-8xx.h | 27 ++++++++++++++++++++ 1 file changed, 27 insertions(+)
arch/powerpc/include/asm/nohash/32/kup-8xx.h +27 -0
@@ -34,6 +34,33 @@#include <asm/reg.h> +static inline void kuap_user_restore (struct pt_regs *regs) +{ +} + +static inline void kuap_kernel_restore (struct pt_regs *regs,unsigned long kuap) +{ +mtspr (SPRN_MD_AP , kuap); +} + +static inline void kuap_check (void ) +{ +if (!IS_ENABLED (CONFIG_PPC_KUAP_DEBUG )) +return ; + +WARN_ON_ONCE (mfspr (SPRN_MD_AP ) >>16 !=MD_APG_KUAP >>16 ); +} + +static inline unsigned long kuap_get_and_check (void ) +{ +unsigned long kuap =mfspr (SPRN_MD_AP ); + +if (IS_ENABLED (CONFIG_PPC_KUAP_DEBUG )) +WARN_ON_ONCE (mfspr (SPRN_MD_AP ) >>16 !=MD_APG_KUAP >>16 ); + +return kuap; +} +static inline void allow_user_access (void __user *to,const void __user *from,unsigned long size,unsigned long dir) {
Signature · 1 line
2.25.0
PATCH v4 8/23 powerpc/irq: Add helper to set regs->softe
In reply to Christophe Leroyregs->softe doesn't exist on PPC32.
Add irq_soft_mask_regs_set_state() helper to set regs->softe. This helper will void on PPC32.
--- arch/powerpc/include/asm/hw_irq.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
arch/powerpc/include/asm/hw_irq.h +9 -2
@@ -38,6 +38,8 @@#define PACA_IRQ_MUST_HARD_MASK (PACA_IRQ_EE)#endif +#endif /* CONFIG_PPC64 */ +/* * flags for paca->irq_soft_mask */
@@ -46,8 +48,6 @@#define IRQS_PMI_DISABLED 2#define IRQS_ALL_DISABLED (IRQS_DISABLED | IRQS_PMI_DISABLED) -#endif /* CONFIG_PPC64 */ -#ifndef __ASSEMBLY__#ifdef CONFIG_PPC64
@@ -287,6 +287,10 @@ extern void irq_set_pending_from_srr1(unsigned long srr1);extern void force_external_irq_replay (void ); +static inline void irq_soft_mask_regs_set_state (struct pt_regs *regs,unsigned long val) +{ + regs->softe = val; +}#else /* CONFIG_PPC64 */ static inline unsigned long arch_local_save_flags (void )
@@ -355,6 +359,9 @@ static inline bool arch_irq_disabled_regs(struct pt_regs *regs)static inline void may_hard_irq_enable (void ) { } +static inline void irq_soft_mask_regs_set_state (struct pt_regs *regs,unsigned long val) +{ +}#endif /* CONFIG_PPC64 */ #define ARCH_IRQ_INIT_FLAGS IRQ_NOREQUEST
Signature · 1 line
2.25.0
PATCH v4 9/23 powerpc/irq: Rework helpers that manipulate MSR[EE/RI]
In reply to Christophe LeroyIn preparation of porting PPC32 to C syscall entry/exit, rewrite the following helpers as static inline functions and add support for PPC32 in them:
__hard_irq_enable() __hard_irq_disable() __hard_EE_RI_disable() __hard_RI_enable()
Then use them in PPC32 version of arch_local_irq_disable() and arch_local_irq_enable() to avoid code duplication.
--- arch/powerpc/include/asm/hw_irq.h | 75 +++++++++++++++++++++---------- arch/powerpc/include/asm/reg.h | 1 + 2 files changed, 52 insertions(+), 24 deletions(-)
arch/powerpc/include/asm/hw_irq.h +51 -24
@@ -50,6 +50,55 @@#ifndef __ASSEMBLY__ +static inline void __hard_irq_enable (void ) +{ +if (IS_ENABLED (CONFIG_BOOKE ) ||IS_ENABLED (CONFIG_40x)) +wrtee (MSR_EE ); +else if (IS_ENABLED (CONFIG_PPC_8xx)) +wrtspr (SPRN_EIE ); +else if (IS_ENABLED (CONFIG_PPC_BOOK3S_64 )) +__mtmsrd (MSR_EE |MSR_RI ,1 ); +else +mtmsr (mfmsr () |MSR_EE ); +} + +static inline void __hard_irq_disable (void ) +{ +if (IS_ENABLED (CONFIG_BOOKE ) ||IS_ENABLED (CONFIG_40x)) +wrtee (0 ); +else if (IS_ENABLED (CONFIG_PPC_8xx)) +wrtspr (SPRN_EID ); +else if (IS_ENABLED (CONFIG_PPC_BOOK3S_64 )) +__mtmsrd (MSR_RI ,1 ); +else +mtmsr (mfmsr () & ~MSR_EE ); +} + +static inline void __hard_EE_RI_disable (void ) +{ +if (IS_ENABLED (CONFIG_BOOKE ) ||IS_ENABLED (CONFIG_40x)) +wrtee (0 ); +else if (IS_ENABLED (CONFIG_PPC_8xx)) +wrtspr (SPRN_NRI ); +else if (IS_ENABLED (CONFIG_PPC_BOOK3S_64 )) +__mtmsrd (0 ,1 ); +else +mtmsr (mfmsr () & ~(MSR_EE |MSR_RI )); +} + +static inline void __hard_RI_enable (void ) +{ +if (IS_ENABLED (CONFIG_BOOKE ) ||IS_ENABLED (CONFIG_40x)) +return ; + +if (IS_ENABLED (CONFIG_PPC_8xx)) +wrtspr (SPRN_EID ); +else if (IS_ENABLED (CONFIG_PPC_BOOK3S_64 )) +__mtmsrd (MSR_RI ,1 ); +else +mtmsr (mfmsr () |MSR_RI ); +} +#ifdef CONFIG_PPC64 #include <asm/paca.h>
@@ -212,18 +261,6 @@ static inline bool arch_irqs_disabled(void)#endif /* CONFIG_PPC_BOOK3S */ -#ifdef CONFIG_PPC_BOOK3E -#define __hard_irq_enable () wrtee(MSR_EE) -#define __hard_irq_disable () wrtee(0) -#define __hard_EE_RI_disable () wrtee(0) -#define __hard_RI_enable () do { } while (0) -#else -#define __hard_irq_enable () __mtmsrd(MSR_EE|MSR_RI, 1) -#define __hard_irq_disable () __mtmsrd(MSR_RI, 1) -#define __hard_EE_RI_disable () __mtmsrd(0, 1) -#define __hard_RI_enable () __mtmsrd(MSR_RI, 1) -#endif -#define hard_irq_disable () do { \ unsigned long flags; \ __hard_irq_disable(); \
@@ -322,22 +359,12 @@ static inline unsigned long arch_local_irq_save(void)static inline void arch_local_irq_disable (void ) { -if (IS_ENABLED (CONFIG_BOOKE )) -wrtee (0 ); -else if (IS_ENABLED (CONFIG_PPC_8xx)) -wrtspr (SPRN_EID ); -else -mtmsr (mfmsr () & ~MSR_EE ); +__hard_irq_disable (); }static inline void arch_local_irq_enable (void ) { -if (IS_ENABLED (CONFIG_BOOKE )) -wrtee (MSR_EE ); -else if (IS_ENABLED (CONFIG_PPC_8xx)) -wrtspr (SPRN_EIE ); -else -mtmsr (mfmsr () |MSR_EE ); +__hard_irq_enable (); }static inline bool arch_irqs_disabled_flags (unsigned long flags)
arch/powerpc/include/asm/reg.h +1 -0
@@ -1375,6 +1375,7 @@#define mtmsr (v) asm volatile("mtmsr %0" : \ : "r" ((unsigned long)(v)) \ : "memory") +#define __mtmsrd (v, l) BUILD_BUG()#define __MTMSR "mtmsr"#endif
Signature · 1 line
2.25.0
PATCH v4 10/23 powerpc/irq: Add stub irq_soft_mask_return() for PPC32
In reply to Christophe LeroyTo allow building syscall_64.c smoothly on PPC32, add stub version of irq_soft_mask_return().
--- arch/powerpc/include/asm/hw_irq.h | 5 +++++ 1 file changed, 5 insertions(+)
arch/powerpc/include/asm/hw_irq.h +5 -0
@@ -330,6 +330,11 @@ static inline void irq_soft_mask_regs_set_state(struct pt_regs *regs, unsigned l }#else /* CONFIG_PPC64 */ +static inline notrace unsigned long irq_soft_mask_return (void ) +{ +return 0 ; +} +static inline unsigned long arch_local_save_flags (void ) {return mfmsr ();
Signature · 1 line
2.25.0
PATCH v4 11/23 powerpc/syscall: Rename syscall_64.c into syscall.c
In reply to Christophe Leroysyscall_64.c will be reused almost as is for PPC32.
Rename it syscall.c
---
arch/powerpc/kernel/Makefile | 2 +-
arch/powerpc/kernel/{syscall_64.c => syscall.c} | 0
2 files changed, 1 insertion(+), 1 deletion(-)
rename arch/powerpc/kernel/{syscall_64.c => syscall.c} (100%)arch/powerpc/kernel/Makefile +1 -1
@@ -49,7 +49,7 @@ obj-y := cputable.o syscalls.o \ hw_breakpoint_constraints.o obj-y += ptrace/ obj-$(CONFIG_PPC64) += setup_64.o \ - paca.o nvram_64.o note.o syscall_64.o + paca.o nvram_64.o note.o syscall.o obj-$(CONFIG_COMPAT) += sys_ppc32.o signal_32.o obj-$(CONFIG_VDSO32) += vdso32/ obj-$(CONFIG_PPC_WATCHDOG) += watchdog.o
arch/powerpc/kernel/syscall.c renamed from arch/powerpc/kernel/syscall_64.c +0 -0
Signature · 1 line
2.25.0
Nicholas Piggin
reviewerRe: [PATCH v4 11/23] powerpc/syscall: Rename syscall_64.c into syscall.c
Excerpts from Christophe Leroy's message of January 26, 2021 12:48 am:
Quoted 3 lines
syscall_64.cwill be reused almost as is for PPC32.Rename it
syscall.c
Could you rename it to interrupt.c instead? A system call is an interrupt, and the file now also has code to return from other interrupts as well, and it matches the new asm/interrupt.h from the interrupts series.
Thanks,
Nick
RE: [PATCH v4 11/23] powerpc/syscall: Rename syscall_64.c into syscall.c
From: Nicholas Piggin
Quoted 11 lines
Sent: 26 January 2021 10:21
Excerpts from Christophe Leroy's message of January 26, 2021 12:48 am:
Quoted 3 lines
syscall_64.cwill be reused almost as is for PPC32.Rename it
syscall.cCould you rename it to
interrupt.cinstead? A system call is an interrupt, and the file now also has code to return from other interrupts as well, and it matches the newasm/interrupt.hfrom the interrupts series.
Hmmm....
That might make it harder for someone looking for the system call entry code to find it.
In some sense interrupts are the simpler case.
Especially when comparing with other architectures which have special instructions for syscall entry.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
Nicholas Piggin
reviewerRE: [PATCH v4 11/23] powerpc/syscall: Rename syscall_64.c into syscall.c
Excerpts from David Laight's message of January 26, 2021 8:28 pm:
Quoted 13 lines
From: Nicholas Piggin
Quoted 11 lines
Sent: 26 January 2021 10:21
Excerpts from Christophe Leroy's message of January 26, 2021 12:48 am:
Quoted 3 lines
syscall_64.cwill be reused almost as is for PPC32.Rename it
syscall.cCould you rename it to
interrupt.cinstead? A system call is an interrupt, and the file now also has code to return from other interrupts as well, and it matches the newasm/interrupt.hfrom the interrupts series.
Quoted 4 lines
Hmmm....
That might make it harder for someone looking for the system call entry code to find it.
It's very grep'able.
Quoted 4 lines
In some sense interrupts are the simpler case.
Especially when comparing with other architectures which have special instructions for syscall entry.
powerpc does have a special instruction for syscall, and it causes a system call interrupt.
I'm not sure about other architectures, but for powerpc its more sensible to call it interrupt.c than syscall.c.
Thanks,
Nick
Re: [PATCH v4 11/23] powerpc/syscall: Rename syscall_64.c into syscall.c
Le 28/01/2021 à 00:50, Nicholas Piggin a écrit :
Quoted 23 lines
Excerpts from David Laight's message of January 26, 2021 8:28 pm:
Quoted 13 lines
From: Nicholas Piggin
Quoted 11 lines
Sent: 26 January 2021 10:21
Excerpts from Christophe Leroy's message of January 26, 2021 12:48 am:
Quoted 3 lines
syscall_64.cwill be reused almost as is for PPC32.Rename it
syscall.cCould you rename it to
interrupt.cinstead? A system call is an interrupt, and the file now also has code to return from other interrupts as well, and it matches the newasm/interrupt.hfrom the interrupts series.Quoted 4 lines
Hmmm....
That might make it harder for someone looking for the system call entry code to find it.
It's very grep'able.
Quoted 2 lines
In some sense interrupts are the simpler case.
Quoted 8 lines
Quoted 2 lines
Especially when comparing with other architectures which have special instructions for syscall entry.
powerpc does have a special instruction for syscall, and it causes a system call interrupt.
I'm not sure about other architectures, but for powerpc its more sensible to call it
interrupt.cthansyscall.c.
Many other architectures have a syscall.c but for a different purpose: it contains arch specific system calls. We have that in powerpc as well, it is called syscalls.c
So to avoid confusion, I'll rename it. But I think "interrupt" is maybe not the right name. An interrupt most of the time refers to IRQ. For me system call is not an interrupt in the way it doesn't unexpectedly interrupt a program flow. In powerpc manuals it is generally called exceptions, no I'm more inclined to call it exception.c
Christophe
Nicholas Piggin
reviewerRe: [PATCH v4 11/23] powerpc/syscall: Rename syscall_64.c into syscall.c
Excerpts from Christophe Leroy's message of February 2, 2021 4:15 pm:
Quoted 32 lines
Le 28/01/2021 à 00:50, Nicholas Piggin a écrit :
Quoted 29 lines
Excerpts from David Laight's message of January 26, 2021 8:28 pm:
Quoted 13 lines
From: Nicholas Piggin
Quoted 11 lines
Sent: 26 January 2021 10:21
Excerpts from Christophe Leroy's message of January 26, 2021 12:48 am:
Quoted 3 lines
syscall_64.cwill be reused almost as is for PPC32.Rename it
syscall.cCould you rename it to
interrupt.cinstead? A system call is an interrupt, and the file now also has code to return from other interrupts as well, and it matches the newasm/interrupt.hfrom the interrupts series.Quoted 4 lines
Hmmm....
That might make it harder for someone looking for the system call entry code to find it.
It's very grep'able.
Quoted 4 lines
In some sense interrupts are the simpler case.
Especially when comparing with other architectures which have special instructions for syscall entry.
powerpc does have a special instruction for syscall, and it causes a system call interrupt.
Quoted 8 lines
Quoted 2 lines
I'm not sure about other architectures, but for powerpc its more sensible to call it
interrupt.cthansyscall.c.Many other architectures have a
syscall.cbut for a different purpose: it contains arch specific system calls. We have that in powerpc as well, it is calledsyscalls.cSo to avoid confusion, I'll rename it. But I think "interrupt" is maybe not the right name. An interrupt most of the time refers to IRQ.
That depends what you mean by interrupt and IRQ.
Linux kind of considers any asynchronous maskable interrupt an irq (local_irq_disable()). But if you say irq it's more likely to mean a device interrupt, and "interrupt" usually refres to the asynch ones.
But Linux doesn't really assign names to synchronous interrupts in core code. It doesn't say they aren't interrupts, it just doesn't really have a convention for them at all.
Other architectures e.g., x86 also have things like interrupt descriptor table for synchronous interrupts as well. That's where I got the interrupt wrappers code from actually.
So it's really fine to use the proper arch-specific names for things in arch code. I'm trying to slowly change names from exception to interrupt.
Quoted 3 lines
For me system call is not an interrupt in the way it
doesn't unexpectedly interrupt a program flow. In powerpc manuals it is generally called exceptions, no I'm more inclined to call itexception.c
Actually that's backwards. Powerpc manuals (at least the one I look at) calls them all interrupts including system calls, and also the system call interrupt is actually the only one that doesn't appear to be associated with an exception.
Also there is no distinction about expecte/unexpected -- a data storage interrupt is expected if you access a location without the right access permissions for example, but it is still an interrupt.
These handlers very specifically deal with the change to execution flow (i.e., the interrupt), they do *not* deal with the exception which may be associated with it (that is the job of the handler).
And on the other hand you can deal with exceptions in some cases without taking an interrupt at all. For example if you had MSR[EE]=0 you could change the decrementer or execute msgclr or change HMER SPR etc to clear various exceptions without ever taking the interrupt.
Thanks,
Nick
Re: [PATCH v4 11/23] powerpc/syscall: Rename syscall_64.c into syscall.c
Le 02/02/2021 à 07:38, Nicholas Piggin a écrit :
Quoted 74 lines
Excerpts from Christophe Leroy's message of February 2, 2021 4:15 pm:
Quoted 32 lines
Le 28/01/2021 à 00:50, Nicholas Piggin a écrit :
Quoted 29 lines
Excerpts from David Laight's message of January 26, 2021 8:28 pm:
Quoted 13 lines
From: Nicholas Piggin
Quoted 11 lines
Sent: 26 January 2021 10:21
Excerpts from Christophe Leroy's message of January 26, 2021 12:48 am:
Quoted 3 lines
syscall_64.cwill be reused almost as is for PPC32.Rename it
syscall.cCould you rename it to
interrupt.cinstead? A system call is an interrupt, and the file now also has code to return from other interrupts as well, and it matches the newasm/interrupt.hfrom the interrupts series.Quoted 4 lines
Hmmm....
That might make it harder for someone looking for the system call entry code to find it.
It's very grep'able.
Quoted 4 lines
In some sense interrupts are the simpler case.
Especially when comparing with other architectures which have special instructions for syscall entry.
powerpc does have a special instruction for syscall, and it causes a system call interrupt.
Quoted 8 lines
Quoted 2 lines
I'm not sure about other architectures, but for powerpc its more sensible to call it
interrupt.cthansyscall.c.Many other architectures have a
syscall.cbut for a different purpose: it contains arch specific system calls. We have that in powerpc as well, it is calledsyscalls.cSo to avoid confusion, I'll rename it. But I think "interrupt" is maybe not the right name. An interrupt most of the time refers to IRQ.
That depends what you mean by interrupt and IRQ.
Linux kind of considers any asynchronous maskable interrupt an irq (
local_irq_disable()). But if you say irq it's more likely to mean a device interrupt, and "interrupt" usually refres to the asynch ones.But Linux doesn't really assign names to synchronous interrupts in core code. It doesn't say they aren't interrupts, it just doesn't really have a convention for them at all.
Other architectures e.g., x86 also have things like interrupt descriptor table for synchronous interrupts as well. That's where I got the interrupt wrappers code from actually.
So it's really fine to use the proper arch-specific names for things in arch code. I'm trying to slowly change names from exception to interrupt.
Quoted 3 lines
For me system call is not an interrupt in the way it
doesn't unexpectedly interrupt a program flow. In powerpc manuals it is generally called exceptions, no I'm more inclined to call itexception.cActually that's backwards. Powerpc manuals (at least the one I look at) calls them all interrupts including system calls, and also the system call interrupt is actually the only one that doesn't appear to be associated with an exception.
Also there is no distinction about expecte/unexpected -- a data storage interrupt is expected if you access a location without the right access permissions for example, but it is still an interrupt.
Quoted 9 lines
These handlers very specifically deal with the change to execution flow (i.e., the interrupt), they do *not* deal with the exception which may be associated with it (that is the job of the handler).
And on the other hand you can deal with exceptions in some cases without taking an interrupt at all. For example if you had MSR[EE]=0 you could change the decrementer or execute msgclr or change HMER SPR etc to clear various exceptions without ever taking the interrupt.
Ok, let's call it interrupt.c then, to be consistant with the interrupt wrapper story.
Christophe
Re: [PATCH v4 11/23] powerpc/syscall: Rename syscall_64.c into syscall.c
In reply to Nicholas PigginQuoted 4 lines · Nicholas Piggin
Quoted 2 lines
So to avoid confusion, I'll rename it. But I think "interrupt" is maybe not the right name. An interrupt most of the time refers to IRQ.
That depends what you mean by interrupt and IRQ.
In the PowerPC architecture, an exception is an abnormal condition, and that can often cause an interrupt. What Christophe colloquially calls an "IRQ" here is called an external exception c.q. external interrupt.
Quoted 3 lines
But if you say irq it's more likely to mean
a device interrupt, and "interrupt" usually refres to the asynch ones.
Power talks about "instruction-caused interrupts", for one aspect of the difference here; and "precise" / "imprecise" interrupts for another.
Quoted 3 lines
So it's really fine to use the proper arch-specific names for things in arch code. I'm trying to slowly change names from exception to interrupt.
Thanks :-)
Quoted 8 lines
Quoted 3 lines
For me system call is not an interrupt in the way it
doesn't unexpectedly interrupt a program flow. In powerpc manuals it is generally called exceptions, no I'm more inclined to call itexception.cActually that's backwards. Powerpc manuals (at least the one I look at) calls them all interrupts including system calls, and also the system call interrupt is actually the only one that doesn't appear to be associated with an exception.
Yeah. You could easily make such an exception, which is set when you execute a system call instruction, and cleared when the interrupt is taken, of course; but the architecture doesn't.
Quoted 4 lines
And on the other hand you can deal with exceptions in some cases without taking an interrupt at all. For example if you had MSR[EE]=0 you could change the decrementer or execute msgclr or change HMER SPR etc to clear various exceptions without ever taking the interrupt.
A well-known example is the exception bits in the FPSCR, which do not cause an interrupt unless the corresponding enable bits are also set.
Segher
Re: [PATCH v4 11/23] powerpc/syscall: Rename syscall_64.c into syscall.c
In reply to Nicholas PigginLe 26/01/2021 à 11:21, Nicholas Piggin a écrit :
Quoted 10 lines
Excerpts from Christophe Leroy's message of January 26, 2021 12:48 am:
Quoted 3 lines
syscall_64.cwill be reused almost as is for PPC32.Rename it
syscall.cCould you rename it to
interrupt.cinstead? A system call is an interrupt, and the file now also has code to return from other interrupts as well, and it matches the newasm/interrupt.hfrom the interrupts series.
Done in v5
Christophe
PATCH v4 12/23 powerpc/syscall: Make syscall.c buildable on PPC32
In reply to Christophe Leroyifdef out specific PPC64 stuff to allow buildingsyscall.c on PPC32.
Modify Makefile to always build syscall.o
--- arch/powerpc/kernel/Makefile | 4 ++-- arch/powerpc/kernel/syscall.c | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-)
arch/powerpc/kernel/Makefile +2 -2
@@ -46,10 +46,10 @@ obj-y := cputable.o syscalls.o \ prom.o traps.o setup-common.o \ udbg.o misc.o io.o misc_$(BITS).o \ of_platform.o prom_parse.o firmware.o \ - hw_breakpoint_constraints.o + hw_breakpoint_constraints.o syscall.o obj-y += ptrace/ obj-$(CONFIG_PPC64) += setup_64.o \ - paca.o nvram_64.o note.o syscall.o + paca.o nvram_64.o note.o obj-$(CONFIG_COMPAT) += sys_ppc32.o signal_32.o obj-$(CONFIG_VDSO32) += vdso32/ obj-$(CONFIG_PPC_WATCHDOG) += watchdog.o
arch/powerpc/kernel/syscall.c +5 -4
@@ -39,7 +39,7 @@ notrace long system_call_exception(long r3, long r4, long r5,BUG_ON (!(regs->msr &MSR_RI ));BUG_ON (!(regs->msr &MSR_PR ));BUG_ON (!FULL_REGS (regs)); -BUG_ON (regs->softe !=IRQS_ENABLED ); +BUG_ON (arch_irq_disabled_regs (regs));#ifdef CONFIG_PPC_PKEY if (mmu_has_feature (MMU_FTR_PKEY )) {
@@ -77,7 +77,7 @@ notrace long system_call_exception(long r3, long r4, long r5,* frame, or if the unwinder was taught the first stack frame always * returns to user with IRQS_ENABLED, this store could be avoided! */ - regs->softe =IRQS_ENABLED ; +irq_soft_mask_regs_set_state (regs,IRQS_ENABLED );local_irq_enable ();
@@ -147,6 +147,7 @@ static notrace inline bool prep_irq_for_enabled_exit(bool clear_ri)__hard_EE_RI_disable (); else__hard_irq_disable (); +#ifdef CONFIG_PPC64 if (unlikely (lazy_irq_pending_nocheck ())) {/* Took an interrupt, may have more exit work to do. */ if (clear_ri)
@@ -158,7 +159,7 @@ static notrace inline bool prep_irq_for_enabled_exit(bool clear_ri) } local_paca->irq_happened =0 ;irq_soft_mask_set (IRQS_ENABLED ); - +#endif return true; }
@@ -281,7 +282,7 @@ notrace unsigned long syscall_exit_prepare(unsigned long r3,return ret; } -#ifdef CONFIG_PPC_BOOK3S /* BOOK3E not yet using this */ +#ifdef CONFIG_PPC_BOOK3S_64 /* BOOK3E not yet using this */ notrace unsigned long interrupt_exit_user_prepare (struct pt_regs *regs,unsigned long msr) {#ifdef CONFIG_PPC_BOOK3E
Signature · 1 line
2.25.0
PATCH v4 13/23 powerpc/syscall: Use is_compat_task()
In reply to Christophe LeroyInstead of hard comparing task flags with _TIF_32BIT, use is_compat_task(). The advantage is that it returns 0 on PPC32 allthough _TIF_32BIT is always set.
--- arch/powerpc/kernel/syscall.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/powerpc/kernel/syscall.c +3 -1
@@ -2,6 +2,8 @@#include <linux/context_tracking.h> #include <linux/err.h> +#include <linux/compat.h> +#include <asm/asm-prototypes.h> #include <asm/kup.h> #include <asm/cputime.h>
@@ -116,7 +118,7 @@ notrace long system_call_exception(long r3, long r4, long r5,/* May be faster to do array_index_nospec? */ barrier_nospec (); -if (unlikely (is_32bit_task ())) { +if (unlikely (is_compat_task ())) { f = (void *)compat_sys_call_table[r0]; r3 &=0x00000000ffffffffULL ;
Signature · 1 line
2.25.0
PATCH v4 14/23 powerpc/syscall: Save r3 in regs->orig_r3
In reply to Christophe LeroySave r3 in regs->orig_r3 in system_call_exception()
--- arch/powerpc/kernel/entry_64.S | 1 - arch/powerpc/kernel/syscall.c | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-)
arch/powerpc/kernel/entry_64.S +0 -1
@@ -278,7 +278,6 @@ END_BTB_FLUSH_SECTION std r10,_LINK(r1) std r11,_TRAP(r1) std r12,_CCR(r1) - std r3,ORIG_GPR3(r1) addi r10,r1,STACK_FRAME_OVERHEAD ld r11,exception_marker@toc(r2) std r11,-16(r10) /* "regshere" marker */
arch/powerpc/kernel/syscall.c +2 -0
@@ -29,6 +29,8 @@ notrace long system_call_exception(long r3, long r4, long r5, {syscall_fn f; + regs->orig_gpr3 = r3; +if (IS_ENABLED (CONFIG_PPC_IRQ_SOFT_MASK_DEBUG ))BUG_ON (irq_soft_mask_return () !=IRQS_ALL_DISABLED );
Signature · 1 line
2.25.0
Nicholas Piggin
reviewerRe: [PATCH v4 14/23] powerpc/syscall: Save r3 in regs->orig_r3
Excerpts from Christophe Leroy's message of January 26, 2021 12:48 am:
Quoted 13 lines
Save r3 in
regs->orig_r3insystem_call_exception()Signed-off-by Christophe Leroy <[email protected]>--- arch/powerpc/kernel/entry_64.S | 1 - arch/powerpc/kernel/syscall.c | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-)arch/powerpc/kernel/entry_64.S +0
-0
arch/powerpc/kernel/entry_64.S END_BTB_FLUSH_SECTION · line 283
Quoted 7 lines
arch/powerpc/kernel/entry_64.S +0
-1@@ -278,7 +278,6 @@ END_BTB_FLUSH_SECTION std r10,_LINK(r1) std r11,_TRAP(r1) std r12,_CCR(r1) - std r3,ORIG_GPR3(r1) addi r10,r1,STACK_FRAME_OVERHEAD ld r11,exception_marker@toc(r2) std r11,-16(r10) /* "regshere" marker */
This misses system_call_vectored.
Thanks,
Nick
Quoted 17 lines
arch/powerpc/kernel/syscall.c +2
-0@@ -29,6 +29,8 @@ notrace long system_call_exception(long r3, long r4, long r5, {syscall_fn f; + regs->orig_gpr3 = r3; +if (IS_ENABLED (CONFIG_PPC_IRQ_SOFT_MASK_DEBUG ))BUG_ON (irq_soft_mask_return () !=IRQS_ALL_DISABLED );Signature · 1 line
2.25.0
Re: [PATCH v4 14/23] powerpc/syscall: Save r3 in regs->orig_r3
Le 26/01/2021 à 11:18, Nicholas Piggin a écrit :
Quoted 9 lines
Excerpts from Christophe Leroy's message of January 26, 2021 12:48 am:
Quoted 8 lines
Save r3 in
regs->orig_r3insystem_call_exception()Signed-off-by Christophe Leroy <[email protected]>--- arch/powerpc/kernel/entry_64.S | 1 - arch/powerpc/kernel/syscall.c | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-)
Quoted 14 lines
arch/powerpc/kernel/entry_64.S END_BTB_FLUSH_SECTION · line 283
Quoted 12 lines
arch/powerpc/kernel/entry_64.S +0
-1@@ -278,7 +278,6 @@ END_BTB_FLUSH_SECTION std r10,_LINK(r1) std r11,_TRAP(r1) std r12,_CCR(r1) - std r3,ORIG_GPR3(r1) addi r10,r1,STACK_FRAME_OVERHEAD ld r11,exception_marker@toc(r2) std r11,-16(r10) /* "regshere" marker */This misses
system_call_vectored.
Oops yes, this patch was cooked before SCV where introduced. Fixes in v5.
Thanks
Christophe
PATCH v4 15/23 powerpc/syscall: Change condition to check MSR_RI
In reply to Christophe LeroyIn system_call_exception(), MSR_RI also needs to be checked on 8xx. Only booke and 40x doesn't have MSR_RI.
--- arch/powerpc/kernel/syscall.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/kernel/syscall.c +1 -1
@@ -39,7 +39,7 @@ notrace long system_call_exception(long r3, long r4, long r5,trace_hardirqs_off ();/* finish reconciling */ -if (IS_ENABLED (CONFIG_PPC_BOOK3S )) +if (!IS_ENABLED (CONFIG_BOOKE ) && !IS_ENABLED (CONFIG_40x))BUG_ON (!(regs->msr &MSR_RI ));BUG_ON (!(regs->msr &MSR_PR ));BUG_ON (!FULL_REGS (regs));
Signature · 1 line
2.25.0
PATCH v4 16/23 powerpc/32: Always save non volatile GPRs at syscall entry
In reply to Christophe LeroyIn preparation for porting syscall entry/exit to C, inconditionally save non volatile general purpose registers.
Commit 965dd3ad3076 ("powerpc/64/syscall: Remove non-volatile GPR save optimisation") provides detailed explanation.
This increases the number of cycles by 24 cycles on 8xx with null_syscall benchmark (280 => 304 cycles)
--- arch/powerpc/kernel/entry_32.S | 46 +----------------------- arch/powerpc/kernel/head_32.h | 2 +- arch/powerpc/kernel/head_booke.h | 2 +- arch/powerpc/kernel/syscalls/syscall.tbl | 20 +++-------- 4 files changed, 8 insertions(+), 62 deletions(-)
arch/powerpc/kernel/entry_32.S +1 -45
@@ -351,6 +351,7 @@ trace_syscall_entry_irq_off: .globl transfer_to_syscall transfer_to_syscall: + SAVE_NVGPRS(r1) #ifdef CONFIG_PPC_BOOK3S_32 kuep_lock r11, r12 #endif
@@ -614,51 +615,6 @@ ret_from_kernel_syscall: #endif _ASM_NOKPROBE_SYMBOL(ret_from_kernel_syscall) -/* - * The fork/clone functions need to copy the full register set into - * the child process. Therefore we need to save all the nonvolatile - * registers (r13 - r31) before calling the C code. - */ - .globl ppc_fork -ppc_fork: - SAVE_NVGPRS(r1) - lwz r0,_TRAP(r1) - rlwinm r0,r0,0,0,30 /* clear LSB to indicate full */ - stw r0,_TRAP(r1) /* register set saved */ - b sys_fork - - .globl ppc_vfork -ppc_vfork: - SAVE_NVGPRS(r1) - lwz r0,_TRAP(r1) - rlwinm r0,r0,0,0,30 /* clear LSB to indicate full */ - stw r0,_TRAP(r1) /* register set saved */ - b sys_vfork - - .globl ppc_clone -ppc_clone: - SAVE_NVGPRS(r1) - lwz r0,_TRAP(r1) - rlwinm r0,r0,0,0,30 /* clear LSB to indicate full */ - stw r0,_TRAP(r1) /* register set saved */ - b sys_clone - - .globl ppc_clone3 -ppc_clone3: - SAVE_NVGPRS(r1) - lwz r0,_TRAP(r1) - rlwinm r0,r0,0,0,30 /* clear LSB to indicate full */ - stw r0,_TRAP(r1) /* register set saved */ - b sys_clone3 - - .globl ppc_swapcontext -ppc_swapcontext: - SAVE_NVGPRS(r1) - lwz r0,_TRAP(r1) - rlwinm r0,r0,0,0,30 /* clear LSB to indicate full */ - stw r0,_TRAP(r1) /* register set saved */ - b sys_swapcontext - /* * Top-level page fault handling. * This is in assembler because if do_page_fault tells us that
arch/powerpc/kernel/head_32.h +1 -1
@@ -148,7 +148,7 @@ stw r2,GPR2(r11) addi r10,r10,STACK_FRAME_REGS_MARKER@l stw r9,_MSR(r11) - li r2, \trapno + 1 + li r2, \trapno stw r10,8(r11) stw r2,_TRAP(r11) SAVE_GPR(0, r11)
arch/powerpc/kernel/head_booke.h +1 -1
@@ -124,7 +124,7 @@ ALT_FTR_SECTION_END_IFSET(CPU_FTR_EMB_HV) stw r2,GPR2(r11) addi r12, r12, STACK_FRAME_REGS_MARKER@l stw r9,_MSR(r11) - li r2, \trapno + 1 + li r2, \trapno stw r12, 8(r11) stw r2,_TRAP(r11) SAVE_GPR(0, r11)
arch/powerpc/kernel/syscalls/syscall.tbl +5 -15
@@ -9,9 +9,7 @@ # 0 nospu restart_syscall sys_restart_syscall 1 nospu exit sys_exit -2 32 fork ppc_fork sys_fork -2 64 fork sys_fork -2 spu fork sys_ni_syscall +2 nospu fork sys_fork 3 common read sys_read 4 common write sys_write 5 common open sys_open compat_sys_open
@@ -160,9 +158,7 @@ 119 32 sigreturn sys_sigreturn compat_sys_sigreturn 119 64 sigreturn sys_ni_syscall 119 spu sigreturn sys_ni_syscall -120 32 clone ppc_clone sys_clone -120 64 clone sys_clone -120 spu clone sys_ni_syscall +120 nospu clone sys_clone 121 common setdomainname sys_setdomainname 122 common uname sys_newuname 123 common modify_ldt sys_ni_syscall
@@ -244,9 +240,7 @@ 186 spu sendfile sys_sendfile64 187 common getpmsg sys_ni_syscall 188 common putpmsg sys_ni_syscall -189 32 vfork ppc_vfork sys_vfork -189 64 vfork sys_vfork -189 spu vfork sys_ni_syscall +189 nospu vfork sys_vfork 190 common ugetrlimit sys_getrlimit compat_sys_getrlimit 191 common readahead sys_readahead compat_sys_readahead 192 32 mmap2 sys_mmap2 compat_sys_mmap2
@@ -322,9 +316,7 @@ 248 32 clock_nanosleep sys_clock_nanosleep_time32 248 64 clock_nanosleep sys_clock_nanosleep 248 spu clock_nanosleep sys_clock_nanosleep -249 32 swapcontext ppc_swapcontext compat_sys_swapcontext -249 64 swapcontext sys_swapcontext -249 spu swapcontext sys_ni_syscall +249 nospu swapcontext sys_swapcontext compat_sys_swapcontext 250 common tgkill sys_tgkill 251 32 utimes sys_utimes_time32 251 64 utimes sys_utimes
@@ -522,9 +514,7 @@ 432 common fsmount sys_fsmount 433 common fspick sys_fspick 434 common pidfd_open sys_pidfd_open -435 32 clone3 ppc_clone3 sys_clone3 -435 64 clone3 sys_clone3 -435 spu clone3 sys_ni_syscall +435 nospu clone3 sys_clone3 436 common close_range sys_close_range 437 common openat2 sys_openat2 438 common pidfd_getfd sys_pidfd_getfd
Signature · 1 line
2.25.0
PATCH v4 17/23 powerpc/syscall: implement system call entry/exit logic in C for PPC32
In reply to Christophe LeroyThat's port of PPC64 syscall entry/exit logic in C to PPC32.
Performancewise on 8xx:
Before : 304 cycles on null_syscall
After : 348 cycles on null_syscall
--- arch/powerpc/kernel/entry_32.S | 227 ++++--------------------------- arch/powerpc/kernel/head_32.h | 16 --- arch/powerpc/kernel/head_booke.h | 15 -- 3 files changed, 29 insertions(+), 229 deletions(-)
arch/powerpc/kernel/entry_32.S +29 -198
@@ -329,117 +329,22 @@ stack_ovf: _ASM_NOKPROBE_SYMBOL(stack_ovf) #endif -#ifdef CONFIG_TRACE_IRQFLAGS -trace_syscall_entry_irq_off: - /* - * Syscall shouldn't happen while interrupts are disabled, - * so let's do a warning here. - */ -0: trap - EMIT_BUG_ENTRY 0b,__FILE__,__LINE__, BUGFLAG_WARNING - bl trace_hardirqs_on - - /* Now enable for real */ - LOAD_REG_IMMEDIATE(r10, MSR_KERNEL | MSR_EE) - mtmsr r10 - - REST_GPR(0, r1) - REST_4GPRS(3, r1) - REST_2GPRS(7, r1) - b DoSyscall -#endif /* CONFIG_TRACE_IRQFLAGS */ - .globl transfer_to_syscall transfer_to_syscall: SAVE_NVGPRS(r1) #ifdef CONFIG_PPC_BOOK3S_32 kuep_lock r11, r12 #endif -#ifdef CONFIG_TRACE_IRQFLAGS - andi. r12,r9,MSR_EE - beq- trace_syscall_entry_irq_off -#endif /* CONFIG_TRACE_IRQFLAGS */ -/* - * Handle a system call. - */ - .stabs "arch/powerpc/kernel/",N_SO,0,0,0f - .stabs "entry_32.S",N_SO,0,0,0f -0: - -_GLOBAL(DoSyscall) - stw r3,ORIG_GPR3(r1) - li r12,0 - stw r12,RESULT(r1) -#ifdef CONFIG_TRACE_IRQFLAGS - /* Make sure interrupts are enabled */ - mfmsr r11 - andi. r12,r11,MSR_EE - /* We came in with interrupts disabled, we WARN and mark them enabled - * for lockdep now */ -0: tweqi r12, 0 - EMIT_BUG_ENTRY 0b,__FILE__,__LINE__, BUGFLAG_WARNING -#endif /* CONFIG_TRACE_IRQFLAGS */ - lwz r11,TI_FLAGS(r2) - andi. r11,r11,_TIF_SYSCALL_DOTRACE - bne- syscall_dotrace -syscall_dotrace_cont: - cmplwi 0,r0,NR_syscalls - lis r10,sys_call_table@h - ori r10,r10,sys_call_table@l - slwi r0,r0,2 - bge- 66f - - barrier_nospec_asm - /* - * Prevent the load of the handler below (based on the user-passed - * system call number) being speculatively executed until the test - * against NR_syscalls and branch to .66f above has - * committed. - */ + /* Calling convention has r9 = orig r0, r10 = regs */ + mr r9,r0 + addi r10,r1,STACK_FRAME_OVERHEAD + bl system_call_exception - lwzx r10,r10,r0 /* Fetch system call handler [ptr] */ - mtlr r10 - addi r9,r1,STACK_FRAME_OVERHEAD - PPC440EP_ERR42 - blrl /* Call handler */ - .globl ret_from_syscall ret_from_syscall: -#ifdef CONFIG_DEBUG_RSEQ - /* Check whether the syscall is issued inside a restartable sequence */ - stw r3,GPR3(r1) - addi r3,r1,STACK_FRAME_OVERHEAD - bl rseq_syscall - lwz r3,GPR3(r1) -#endif - mr r6,r3 - /* disable interrupts so current_thread_info()->flags can't change */ - LOAD_REG_IMMEDIATE(r10,MSR_KERNEL) /* doesn't include MSR_EE */ - /* Note: We don't bother telling lockdep about it */ - mtmsr r10 - lwz r9,TI_FLAGS(r2) - li r8,-MAX_ERRNO - andi. r0,r9,(_TIF_SYSCALL_DOTRACE|_TIF_SINGLESTEP|_TIF_USER_WORK_MASK|_TIF_PERSYSCALL_MASK) - bne- syscall_exit_work - cmplw 0,r3,r8 - blt+ syscall_exit_cont - lwz r11,_CCR(r1) /* Load CR */ - neg r3,r3 - oris r11,r11,0x1000 /* Set SO bit in CR */ - stw r11,_CCR(r1) -syscall_exit_cont: - lwz r8,_MSR(r1) -#ifdef CONFIG_TRACE_IRQFLAGS - /* If we are going to return from the syscall with interrupts - * off, we trace that here. It shouldn't normally happen. - */ - andi. r10,r8,MSR_EE - bne+ 1f - stw r3,GPR3(r1) - bl trace_hardirqs_off - lwz r3,GPR3(r1) -1: -#endif /* CONFIG_TRACE_IRQFLAGS */ + addi r4,r1,STACK_FRAME_OVERHEAD + li r5,0 + bl syscall_exit_prepare #if defined(CONFIG_4xx) || defined(CONFIG_BOOKE) /* If the process has its own DBCR0 value, load it up. The internal debug mode bit tells us that dbcr0 should be loaded. */
@@ -453,34 +358,39 @@ syscall_exit_cont: cmplwi cr0,r5,0 bne- 2f #endif /* CONFIG_PPC_47x */ -1: -BEGIN_FTR_SECTION - lwarx r7,0,r1 -END_FTR_SECTION_IFSET(CPU_FTR_NEED_PAIRED_STWCX) - stwcx. r0,0,r1 /* to clear the reservation */ - ACCOUNT_CPU_USER_EXIT(r2, r5, r7) #ifdef CONFIG_PPC_BOOK3S_32 kuep_unlock r5, r7 #endif - kuap_check r2, r4 lwz r4,_LINK(r1) lwz r5,_CCR(r1) mtlr r4 - mtcr r5 lwz r7,_NIP(r1) - lwz r2,GPR2(r1) - lwz r1,GPR1(r1) + lwz r8,_MSR(r1) + cmpwi r3,0 + lwz r3,GPR3(r1) syscall_exit_finish: -#if defined(CONFIG_PPC_8xx) && defined(CONFIG_PERF_EVENTS) - mtspr SPRN_NRI, r0 -#endif mtspr SPRN_SRR0,r7 mtspr SPRN_SRR1,r8 + + bne 3f + mtcr r5 + +1: lwz r2,GPR2(r1) + lwz r1,GPR1(r1) rfi -#ifdef CONFIG_40x - b . /* Prevent prefetch past rfi */ -#endif -_ASM_NOKPROBE_SYMBOL(syscall_exit_finish) + +3: mtcr r5 + lwz r4,_CTR(r1) + lwz r5,_XER(r1) + REST_NVGPRS(r1) + mtctr r4 + mtxer r5 + lwz r0,GPR0(r1) + lwz r3,GPR3(r1) + REST_8GPRS(4,r1) + lwz r12,GPR12(r1) + b 1b + #ifdef CONFIG_44x 2: li r7,0 iccci r0,r0
@@ -488,9 +398,6 @@ _ASM_NOKPROBE_SYMBOL(syscall_exit_finish) b 1b #endif /* CONFIG_44x */ -66: li r3,-ENOSYS - b ret_from_syscall - .globl ret_from_fork ret_from_fork: REST_NVGPRS(r1)
@@ -509,82 +416,6 @@ ret_from_kernel_thread: li r3,0 b ret_from_syscall -/* Traced system call support */ -syscall_dotrace: - SAVE_NVGPRS(r1) - li r0,0xc00 - stw r0,_TRAP(r1) - addi r3,r1,STACK_FRAME_OVERHEAD - bl do_syscall_trace_enter - /* - * Restore argument registers possibly just changed. - * We use the return value of do_syscall_trace_enter - * for call number to look up in the table (r0). - */ - mr r0,r3 - lwz r3,GPR3(r1) - lwz r4,GPR4(r1) - lwz r5,GPR5(r1) - lwz r6,GPR6(r1) - lwz r7,GPR7(r1) - lwz r8,GPR8(r1) - REST_NVGPRS(r1) - - cmplwi r0,NR_syscalls - /* Return code is already in r3 thanks to do_syscall_trace_enter() */ - bge- ret_from_syscall - b syscall_dotrace_cont - -syscall_exit_work: - andi. r0,r9,_TIF_RESTOREALL - beq+ 0f - REST_NVGPRS(r1) - b 2f -0: cmplw 0,r3,r8 - blt+ 1f - andi. r0,r9,_TIF_NOERROR - bne- 1f - lwz r11,_CCR(r1) /* Load CR */ - neg r3,r3 - oris r11,r11,0x1000 /* Set SO bit in CR */ - stw r11,_CCR(r1) - -1: stw r6,RESULT(r1) /* Save result */ - stw r3,GPR3(r1) /* Update return value */ -2: andi. r0,r9,(_TIF_PERSYSCALL_MASK) - beq 4f - - /* Clear per-syscall TIF flags if any are set. */ - - li r11,_TIF_PERSYSCALL_MASK - addi r12,r2,TI_FLAGS -3: lwarx r8,0,r12 - andc r8,r8,r11 - stwcx. r8,0,r12 - bne- 3b - -4: /* Anything which requires enabling interrupts? */ - andi. r0,r9,(_TIF_SYSCALL_DOTRACE|_TIF_SINGLESTEP) - beq ret_from_except - - /* Re-enable interrupts. There is no need to trace that with - * lockdep as we are supposed to have IRQs on at this point - */ - ori r10,r10,MSR_EE - mtmsr r10 - - /* Save NVGPRS if they're not saved already */ - lwz r4,_TRAP(r1) - andi. r4,r4,1 - beq 5f - SAVE_NVGPRS(r1) - li r4,0xc00 - stw r4,_TRAP(r1) -5: - addi r3,r1,STACK_FRAME_OVERHEAD - bl do_syscall_trace_leave - b ret_from_except_full - /* * System call was called from kernel. We get here with SRR1 in r9. * Mark the exception as recoverable once we have retrieved SRR0,
arch/powerpc/kernel/head_32.h +0 -16
@@ -162,9 +162,6 @@internal debug mode bit to do this. */ lwz r12,THREAD_DBCR0(r12) andis. r12,r12,DBCR0_IDM@h -#endif - ACCOUNT_CPU_USER_ENTRY(r2, r11, r12) -#if defined(CONFIG_40x) beq+ 3f/* From user and task is ptraced - load up global dbcr0 */ li r12,-1 /* clear all pending debug events */
@@ -176,21 +173,8 @@ lwz r12,4(r11) addi r12,r12,-1 stw r12,4(r11) -#endif - 3: -#ifdef CONFIG_TRACE_IRQFLAGS -/* -* If MSR is changing we need to keep interrupts disabled at this point -* otherwise we might risk taking an interrupt before we tell lockdep -* they are enabled. -*/ - LOAD_REG_IMMEDIATE(r10, MSR_KERNEL) - rlwimi r10, r9, 0, MSR_EE -#else - LOAD_REG_IMMEDIATE(r10, MSR_KERNEL | MSR_EE)#endif - mtmsr r10b transfer_to_syscall/* jump to handler */ 99: b ret_from_kernel_syscall .endm
arch/powerpc/kernel/head_booke.h +0 -15
@@ -138,7 +138,6 @@ ALT_FTR_SECTION_END_IFSET(CPU_FTR_EMB_HV)internal debug mode bit to do this. */ lwz r12,THREAD_DBCR0(r10) andis. r12,r12,DBCR0_IDM@h - ACCOUNT_CPU_USER_ENTRY(r2, r11, r12) beq+ 3f/* From user and task is ptraced - load up global dbcr0 */ li r12,-1 /* clear all pending debug events */
@@ -157,20 +156,6 @@ ALT_FTR_SECTION_END_IFSET(CPU_FTR_EMB_HV) stw r12,4(r11) 3: -#ifdef CONFIG_TRACE_IRQFLAGS -/* -* If MSR is changing we need to keep interrupts disabled at this point -* otherwise we might risk taking an interrupt before we tell lockdep -* they are enabled. -*/ - lis r10, MSR_KERNEL@h - ori r10, r10, MSR_KERNEL@l - rlwimi r10, r9, 0, MSR_EE -#else - lis r10, (MSR_KERNEL | MSR_EE)@h - ori r10, r10, (MSR_KERNEL | MSR_EE)@l -#endif - mtmsr r10b transfer_to_syscall/* jump to handler */ 99: b ret_from_kernel_syscall .endm
Signature · 1 line
2.25.0
PATCH v4 18/23 powerpc/32: Remove verification of MSR_PR on syscall in the ASM entry
In reply to Christophe Leroysystem_call_exception() checks MSR_PR and BUGs if a syscall is issued from kernel mode.
No need to handle it anymore from the ASM entry code.
null_syscall reduction 2 cycles (348 => 346 cycles)
--- arch/powerpc/kernel/entry_32.S | 30 ------------------------------ arch/powerpc/kernel/head_32.h | 3 --- arch/powerpc/kernel/head_booke.h | 3 --- 3 files changed, 36 deletions(-)
arch/powerpc/kernel/entry_32.S +0 -30
@@ -416,36 +416,6 @@ ret_from_kernel_thread: li r3,0 b ret_from_syscall - /* - * System call was called from kernel. We get here with SRR1 in r9. - * Mark the exception as recoverable once we have retrieved SRR0, - * trap a warning and return ENOSYS with CR[SO] set. - */ - .globl ret_from_kernel_syscall -ret_from_kernel_syscall: - mfspr r9, SPRN_SRR0 - mfspr r10, SPRN_SRR1 -#if !defined(CONFIG_4xx) && !defined(CONFIG_BOOKE) - LOAD_REG_IMMEDIATE(r11, MSR_KERNEL & ~(MSR_IR|MSR_DR)) - mtmsr r11 -#endif - -0: trap - EMIT_BUG_ENTRY 0b,__FILE__,__LINE__, BUGFLAG_WARNING - - li r3, ENOSYS - crset so -#if defined(CONFIG_PPC_8xx) && defined(CONFIG_PERF_EVENTS) - mtspr SPRN_NRI, r0 -#endif - mtspr SPRN_SRR0, r9 - mtspr SPRN_SRR1, r10 - rfi -#ifdef CONFIG_40x - b . /* Prevent prefetch past rfi */ -#endif -_ASM_NOKPROBE_SYMBOL(ret_from_kernel_syscall) - /* * Top-level page fault handling. * This is in assembler because if do_page_fault tells us that
arch/powerpc/kernel/head_32.h +0 -3
@@ -118,8 +118,6 @@ .macro SYSCALL_ENTRY trapno mfspr r9, SPRN_SRR1 mfspr r10, SPRN_SRR0 - andi. r11, r9, MSR_PR - beq- 99f LOAD_REG_IMMEDIATE(r11, MSR_KERNEL) /* can take exceptions */ lis r12, 1f@h ori r12, r12, 1f@l
@@ -176,7 +174,6 @@ 3:#endif b transfer_to_syscall/* jump to handler */ -99: b ret_from_kernel_syscall .endm .macro save_dar_dsisr_on_stack reg1, reg2, sp
arch/powerpc/kernel/head_booke.h +0 -3
@@ -106,10 +106,8 @@ ALT_FTR_SECTION_END_IFSET(CPU_FTR_EMB_HV)#endif mfspr r9, SPRN_SRR1 BOOKE_CLEAR_BTB(r11) - andi. r11, r9, MSR_PR lwz r11, TASK_STACK - THREAD(r10) rlwinm r12,r12,0,4,2 /* Clear SO bit in CR */ - beq- 99f ALLOC_STACK_FRAME(r11, THREAD_SIZE - INT_FRAME_SIZE) stw r12, _CCR(r11) /* save various registers */ mflr r12
@@ -157,7 +155,6 @@ ALT_FTR_SECTION_END_IFSET(CPU_FTR_EMB_HV) 3:b transfer_to_syscall/* jump to handler */ -99: b ret_from_kernel_syscall .endm/* To handle the additional exception priority levels on 40x and Book-E
Signature · 1 line
2.25.0
PATCH v4 19/23 powerpc/syscall: Avoid stack frame in likely part of system_call_exception()
In reply to Christophe LeroyWhen r3 is not modified, reload it from regs->orig_r3 to free volatile registers. This avoids a stack frame for the likely part of system_call_exception()
Before the patch:
c000b4d4 <system_call_exception>:
c000b4d4: 7c 08 02 a6 mflr r0 c000b4d8: 94 21 ff e0 stwu r1,-32(r1) c000b4dc: 93 e1 00 1c stw r31,28(r1) c000b4e0: 90 01 00 24 stw r0,36(r1) c000b4e4: 90 6a 00 88 stw r3,136(r10) c000b4e8: 81 6a 00 84 lwz r11,132(r10) c000b4ec: 69 6b 00 02 xori r11,r11,2 c000b4f0: 55 6b ff fe rlwinm r11,r11,31,31,31 c000b4f4: 0f 0b 00 00 twnei r11,0 c000b4f8: 81 6a 00 a0 lwz r11,160(r10) c000b4fc: 55 6b 07 fe clrlwi r11,r11,31 c000b500: 0f 0b 00 00 twnei r11,0 c000b504: 7c 0c 42 e6 mftb r0 c000b508: 83 e2 00 08 lwz r31,8(r2) c000b50c: 81 82 00 28 lwz r12,40(r2) c000b510: 90 02 00 24 stw r0,36(r2) c000b514: 7d 8c f8 50 subf r12,r12,r31 c000b518: 7c 0c 02 14 add r0,r12,r0 c000b51c: 90 02 00 08 stw r0,8(r2) c000b520: 7c 10 13 a6 mtspr 80,r0 c000b524: 81 62 00 70 lwz r11,112(r2) c000b528: 71 60 86 91 andi. r0,r11,34449 c000b52c: 40 82 00 34 bne c000b560 <system_call_exception+0x8c> c000b530: 2b 89 01 b6 cmplwi cr7,r9,438 c000b534: 41 9d 00 64 bgt cr7,c000b598 <system_call_exception+0xc4> c000b538: 3d 40 c0 5c lis r10,-16292 c000b53c: 55 29 10 3a rlwinm r9,r9,2,0,29 c000b540: 39 4a 41 e8 addi r10,r10,16872 c000b544: 80 01 00 24 lwz r0,36(r1) c000b548: 7d 2a 48 2e lwzx r9,r10,r9 c000b54c: 7c 08 03 a6 mtlr r0 c000b550: 7d 29 03 a6 mtctr r9 c000b554: 83 e1 00 1c lwz r31,28(r1) c000b558: 38 21 00 20 addi r1,r1,32
c000b55c: 4e 80 04 20 bctr
After the patch:
c000b4d4 <system_call_exception>:
c000b4d4: 81 6a 00 84 lwz r11,132(r10) c000b4d8: 90 6a 00 88 stw r3,136(r10) c000b4dc: 69 6b 00 02 xori r11,r11,2 c000b4e0: 55 6b ff fe rlwinm r11,r11,31,31,31 c000b4e4: 0f 0b 00 00 twnei r11,0 c000b4e8: 80 6a 00 a0 lwz r3,160(r10) c000b4ec: 54 63 07 fe clrlwi r3,r3,31 c000b4f0: 0f 03 00 00 twnei r3,0 c000b4f4: 7d 6c 42 e6 mftb r11 c000b4f8: 81 82 00 08 lwz r12,8(r2) c000b4fc: 80 02 00 28 lwz r0,40(r2) c000b500: 91 62 00 24 stw r11,36(r2) c000b504: 7c 00 60 50 subf r0,r0,r12 c000b508: 7d 60 5a 14 add r11,r0,r11 c000b50c: 91 62 00 08 stw r11,8(r2) c000b510: 7c 10 13 a6 mtspr 80,r0 c000b514: 80 62 00 70 lwz r3,112(r2) c000b518: 70 6b 86 91 andi. r11,r3,34449 c000b51c: 40 82 00 28 bne c000b544 <system_call_exception+0x70> c000b520: 2b 89 01 b6 cmplwi cr7,r9,438 c000b524: 41 9d 00 84 bgt cr7,c000b5a8 <system_call_exception+0xd4> c000b528: 80 6a 00 88 lwz r3,136(r10) c000b52c: 3d 40 c0 5c lis r10,-16292 c000b530: 55 29 10 3a rlwinm r9,r9,2,0,29 c000b534: 39 4a 41 e4 addi r10,r10,16868 c000b538: 7d 2a 48 2e lwzx r9,r10,r9 c000b53c: 7d 29 03 a6 mtctr r9
c000b540: 4e 80 04 20 bctr
--- arch/powerpc/kernel/syscall.c | 3 +++ 1 file changed, 3 insertions(+)
arch/powerpc/kernel/syscall.c +3 -0
@@ -115,6 +115,9 @@ notrace long system_call_exception(long r3, long r4, long r5,return regs->gpr[3 ]; }return -ENOSYS ; + }else { +/* Restore r3 from orig_gpr3 to free up a volatile reg */ + r3 = regs->orig_gpr3; }/* May be faster to do array_index_nospec? */
Signature · 1 line
2.25.0
Nicholas Piggin
reviewerRe: [PATCH v4 19/23] powerpc/syscall: Avoid stack frame in likely part of system_call_exception()
Excerpts from Christophe Leroy's message of January 26, 2021 12:48 am:
Quoted 86 lines
When r3 is not modified, reload it from
regs->orig_r3to free volatile registers. This avoids a stack frame for the likely part ofsystem_call_exception()Before the patch:
c000b4d4<system_call_exception>:c000b4d4: 7c 08 02 a6 mflr r0 c000b4d8: 94 21 ff e0 stwu r1,-32(r1) c000b4dc: 93 e1 00 1c stw r31,28(r1) c000b4e0: 90 01 00 24 stw r0,36(r1) c000b4e4: 90 6a 00 88 stw r3,136(r10) c000b4e8: 81 6a 00 84 lwz r11,132(r10) c000b4ec: 69 6b 00 02 xori r11,r11,2 c000b4f0: 55 6b ff fe rlwinm r11,r11,31,31,31 c000b4f4: 0f 0b 00 00 twnei r11,0 c000b4f8: 81 6a 00 a0 lwz r11,160(r10) c000b4fc: 55 6b 07 fe clrlwi r11,r11,31 c000b500: 0f 0b 00 00 twnei r11,0 c000b504: 7c 0c 42 e6 mftb r0 c000b508: 83 e2 00 08 lwz r31,8(r2) c000b50c: 81 82 00 28 lwz r12,40(r2) c000b510: 90 02 00 24 stw r0,36(r2) c000b514: 7d 8c f8 50 subf r12,r12,r31 c000b518: 7c 0c 02 14 add r0,r12,r0 c000b51c: 90 02 00 08 stw r0,8(r2) c000b520: 7c 10 13 a6 mtspr 80,r0 c000b524: 81 62 00 70 lwz r11,112(r2) c000b528: 71 60 86 91 andi. r0,r11,34449 c000b52c: 40 82 00 34 bne c000b560 <system_call_exception+0x8c> c000b530: 2b 89 01 b6 cmplwi cr7,r9,438 c000b534: 41 9d 00 64 bgt cr7,c000b598 <system_call_exception+0xc4> c000b538: 3d 40 c0 5c lis r10,-16292 c000b53c: 55 29 10 3a rlwinm r9,r9,2,0,29 c000b540: 39 4a 41 e8 addi r10,r10,16872 c000b544: 80 01 00 24 lwz r0,36(r1) c000b548: 7d 2a 48 2e lwzx r9,r10,r9 c000b54c: 7c 08 03 a6 mtlr r0 c000b550: 7d 29 03 a6 mtctr r9 c000b554: 83 e1 00 1c lwz r31,28(r1) c000b558: 38 21 00 20 addi r1,r1,32
c000b55c: 4e 80 04 20 bctrAfter the patch:
c000b4d4<system_call_exception>:c000b4d4: 81 6a 00 84 lwz r11,132(r10) c000b4d8: 90 6a 00 88 stw r3,136(r10) c000b4dc: 69 6b 00 02 xori r11,r11,2 c000b4e0: 55 6b ff fe rlwinm r11,r11,31,31,31 c000b4e4: 0f 0b 00 00 twnei r11,0 c000b4e8: 80 6a 00 a0 lwz r3,160(r10) c000b4ec: 54 63 07 fe clrlwi r3,r3,31 c000b4f0: 0f 03 00 00 twnei r3,0 c000b4f4: 7d 6c 42 e6 mftb r11 c000b4f8: 81 82 00 08 lwz r12,8(r2) c000b4fc: 80 02 00 28 lwz r0,40(r2) c000b500: 91 62 00 24 stw r11,36(r2) c000b504: 7c 00 60 50 subf r0,r0,r12 c000b508: 7d 60 5a 14 add r11,r0,r11 c000b50c: 91 62 00 08 stw r11,8(r2) c000b510: 7c 10 13 a6 mtspr 80,r0 c000b514: 80 62 00 70 lwz r3,112(r2) c000b518: 70 6b 86 91 andi. r11,r3,34449 c000b51c: 40 82 00 28 bne c000b544 <system_call_exception+0x70> c000b520: 2b 89 01 b6 cmplwi cr7,r9,438 c000b524: 41 9d 00 84 bgt cr7,c000b5a8 <system_call_exception+0xd4> c000b528: 80 6a 00 88 lwz r3,136(r10) c000b52c: 3d 40 c0 5c lis r10,-16292 c000b530: 55 29 10 3a rlwinm r9,r9,2,0,29 c000b534: 39 4a 41 e4 addi r10,r10,16868 c000b538: 7d 2a 48 2e lwzx r9,r10,r9 c000b53c: 7d 29 03 a6 mtctr r9
c000b540: 4e 80 04 20 bctrSigned-off-by Christophe Leroy <[email protected]>--- arch/powerpc/kernel/syscall.c | 3 +++ 1 file changed, 3 insertions(+)arch/powerpc/kernel/syscall.c +0
-0
arch/powerpc/kernel/syscall.c notrace long system_call_exception(long r3, long r4, long r5, · line 123
Quoted 9 lines
arch/powerpc/kernel/syscall.c +3
-0@@ -115,6 +115,9 @@ notrace long system_call_exception(long r3, long r4, long r5,return regs->gpr[3 ]; }return -ENOSYS ; + }else { +/* Restore r3 from orig_gpr3 to free up a volatile reg */ + r3 = regs->orig_gpr3; }/* May be faster to do array_index_nospec? */
Nice optimisation, great analysis and catch. I'll have to test it on ppc64.
Thanks,
Nick
PATCH v4 20/23 powerpc/syscall: Do not check unsupported scv vector on PPC32
In reply to Christophe LeroyOnly PPC64 has scv. No need to check the 0x7ff0 trap on PPC32.
And ignore the scv parameter in syscall_exit_prepare (Save 14 cycles 346 => 332 cycles)
--- arch/powerpc/kernel/entry_32.S | 1 - arch/powerpc/kernel/syscall.c | 7 +++++-- 2 files changed, 5 insertions(+), 3 deletions(-)
arch/powerpc/kernel/entry_32.S +0 -1
@@ -343,7 +343,6 @@ transfer_to_syscall: ret_from_syscall: addi r4,r1,STACK_FRAME_OVERHEAD - li r5,0 bl syscall_exit_prepare #if defined(CONFIG_4xx) || defined(CONFIG_BOOKE) /* If the process has its own DBCR0 value, load it up. The internal
arch/powerpc/kernel/syscall.c +5 -2
@@ -86,7 +86,7 @@ notrace long system_call_exception(long r3, long r4, long r5,local_irq_enable ();if (unlikely (current_thread_info ()->flags & _TIF_SYSCALL_DOTRACE)) { -if (unlikely (regs->trap ==0x7ff0 )) { +if (IS_ENABLED (CONFIG_PPC64 ) &&unlikely (regs->trap ==0x7ff0 )) {/* Unsupported scv vector */ _exception (SIGILL , regs,ILL_ILLOPC , regs->nip);return regs->gpr[3 ];
@@ -109,7 +109,7 @@ notrace long system_call_exception(long r3, long r4, long r5, r8 = regs->gpr[8 ]; }else if (unlikely (r0 >= NR_syscalls)) { -if (unlikely (regs->trap ==0x7ff0 )) { +if (IS_ENABLED (CONFIG_PPC64 ) &&unlikely (regs->trap ==0x7ff0 )) {/* Unsupported scv vector */ _exception (SIGILL , regs,ILL_ILLOPC , regs->nip);return regs->gpr[3 ];
@@ -187,6 +187,9 @@ notrace unsigned long syscall_exit_prepare(unsigned long r3,unsigned long ti_flags;unsigned long ret =0 ; +if (IS_ENABLED (CONFIG_PPC32 )) + scv =0 ; +CT_WARN_ON (ct_state () ==CONTEXT_USER );kuap_check ();
Signature · 1 line
2.25.0
Nicholas Piggin
reviewerRe: [PATCH v4 20/23] powerpc/syscall: Do not check unsupported scv vector on PPC32
Excerpts from Christophe Leroy's message of January 26, 2021 12:48 am:
Quoted 37 lines
Only PPC64 has scv. No need to check the
0x7ff0trap on PPC32.And ignore the scv parameter in
syscall_exit_prepare(Save 14 cycles 346 => 332 cycles)Signed-off-by Christophe Leroy <[email protected]>--- arch/powerpc/kernel/entry_32.S | 1 - arch/powerpc/kernel/syscall.c | 7 +++++-- 2 files changed, 5 insertions(+), 3 deletions(-)arch/powerpc/kernel/entry_32.S +0
-1@@ -343,7 +343,6 @@ transfer_to_syscall: ret_from_syscall: addi r4,r1,STACK_FRAME_OVERHEAD - li r5,0 bl syscall_exit_prepare #if defined(CONFIG_4xx) || defined(CONFIG_BOOKE) /* If the process has its own DBCR0 value, load it up. The internalarch/powerpc/kernel/syscall.c +1
-1@@ -86,7 +86,7 @@ notrace long system_call_exception(long r3, long r4, long r5,local_irq_enable ();if (unlikely (current_thread_info ()->flags & _TIF_SYSCALL_DOTRACE)) { -if (unlikely (regs->trap ==0x7ff0 )) { +if (IS_ENABLED (CONFIG_PPC64 ) &&unlikely (regs->trap ==0x7ff0 )) {/* Unsupported scv vector */ _exception (SIGILL , regs,ILL_ILLOPC , regs->nip);return regs->gpr[3 ];
arch/powerpc/kernel/syscall.c notrace long system_call_exception(long r3, long r4, long r5, · line 112
Quoted 5 lines
arch/powerpc/kernel/syscall.c +1
-1@@ -109,7 +109,7 @@ notrace long system_call_exception(long r3, long r4, long r5, r8 = regs->gpr[8 ]; }else if (unlikely (r0 >= NR_syscalls)) { -if (unlikely (regs->trap ==0x7ff0 )) { +if (IS_ENABLED (CONFIG_PPC64 ) &&unlikely (regs->trap ==0x7ff0 )) {
Perhaps this could be hidden behind a function like trap_is_scv()?
trap_is_unsupported_scv() ?
Thanks,
Nick
Re: [PATCH v4 20/23] powerpc/syscall: Do not check unsupported scv vector on PPC32
Le 26/01/2021 à 11:16, Nicholas Piggin a écrit :
Quoted 40 lines
Excerpts from Christophe Leroy's message of January 26, 2021 12:48 am:
Quoted 39 lines
Only PPC64 has scv. No need to check the
0x7ff0trap on PPC32.And ignore the scv parameter in
syscall_exit_prepare(Save 14 cycles 346 => 332 cycles)Signed-off-by Christophe Leroy <[email protected]>--- arch/powerpc/kernel/entry_32.S | 1 - arch/powerpc/kernel/syscall.c | 7 +++++-- 2 files changed, 5 insertions(+), 3 deletions(-)arch/powerpc/kernel/entry_32.S +0
-1@@ -343,7 +343,6 @@ transfer_to_syscall: ret_from_syscall: addi r4,r1,STACK_FRAME_OVERHEAD - li r5,0 bl syscall_exit_prepare #if defined(CONFIG_4xx) || defined(CONFIG_BOOKE) /* If the process has its own DBCR0 value, load it up. The internalarch/powerpc/kernel/syscall.c +1
-1@@ -86,7 +86,7 @@ notrace long system_call_exception(long r3, long r4, long r5,local_irq_enable ();if (unlikely (current_thread_info ()->flags & _TIF_SYSCALL_DOTRACE)) { -if (unlikely (regs->trap ==0x7ff0 )) { +if (IS_ENABLED (CONFIG_PPC64 ) &&unlikely (regs->trap ==0x7ff0 )) {/* Unsupported scv vector */ _exception (SIGILL , regs,ILL_ILLOPC , regs->nip);return regs->gpr[3 ];@@ -109,7 +109,7 @@ notrace long system_call_exception(long r3, long r4, long r5, r8 = regs->gpr[8 ];
Quoted 8 lines
arch/powerpc/kernel/syscall.c notrace long system_call_exception(long r3, long r4, long r5, · line 112
Quoted 3 lines
arch/powerpc/kernel/syscall.c +1
-1}else if (unlikely (r0 >= NR_syscalls)) { -if (unlikely (regs->trap ==0x7ff0 )) { +if (IS_ENABLED (CONFIG_PPC64 ) &&unlikely (regs->trap ==0x7ff0 )) {Perhaps this could be hidden behind a function like
trap_is_scv()?
trap_is_unsupported_scv()?
Ok, I did that in v5
Thanks
Christophe
PATCH v4 21/23 powerpc/syscall: Remove FULL_REGS verification in system_call_exception
In reply to Christophe LeroyFor book3s/64, FULL_REGS() is 'true' at all time, so the test voids. For others, non volatile registers are saved inconditionally.
So the verification is pointless.
Should one fail to do it, it would anyway be caught by the CHECK_FULL_REGS() in copy_thread() as we have removed the special versions ppc_fork() and friends.
null_syscall benchmark reduction 4 cycles (332 => 328 cycles)
--- arch/powerpc/kernel/syscall.c | 1 - 1 file changed, 1 deletion(-)
arch/powerpc/kernel/syscall.c +0 -1
@@ -42,7 +42,6 @@ notrace long system_call_exception(long r3, long r4, long r5,if (!IS_ENABLED (CONFIG_BOOKE ) && !IS_ENABLED (CONFIG_40x))BUG_ON (!(regs->msr &MSR_RI ));BUG_ON (!(regs->msr &MSR_PR )); -BUG_ON (!FULL_REGS (regs));BUG_ON (arch_irq_disabled_regs (regs));#ifdef CONFIG_PPC_PKEY
Signature · 1 line
2.25.0
PATCH v4 22/23 powerpc/syscall: Optimise checks in beginning of system_call_exception()
In reply to Christophe LeroyCombine all tests of regs->msr into a single logical one.
Before the patch:
0: 81 6a 00 84 lwz r11,132(r10) 4: 90 6a 00 88 stw r3,136(r10) 8: 69 60 00 02 xori r0,r11,2 c: 54 00 ff fe rlwinm r0,r0,31,31,31 10: 0f 00 00 00 twnei r0,0 14: 69 63 40 00 xori r3,r11,16384 18: 54 63 97 fe rlwinm r3,r3,18,31,31 1c: 0f 03 00 00 twnei r3,0 20: 69 6b 80 00 xori r11,r11,32768 24: 55 6b 8f fe rlwinm r11,r11,17,31,31 28: 0f 0b 00 00 twnei r11,0
After the patch:
0: 81 6a 00 84 lwz r11,132(r10) 4: 90 6a 00 88 stw r3,136(r10) 8: 7d 6b 58 f8 not r11,r11 c: 71 6b c0 02 andi. r11,r11,49154 10: 0f 0b 00 00 twnei r11,0
6 cycles less on powerpc 8xx (328 => 322 cycles).
--- arch/powerpc/kernel/syscall.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
arch/powerpc/kernel/syscall.c +7 -3
@@ -28,6 +28,7 @@ notrace long system_call_exception(long r3, long r4, long r5, unsigned long r0, struct pt_regs *regs) { syscall_fn f; +unsigned long expected_msr; regs->orig_gpr3 = r3;
@@ -39,10 +40,13 @@ notrace long system_call_exception(long r3, long r4, long r5,trace_hardirqs_off ();/* finish reconciling */ + expected_msr =MSR_PR ;if (!IS_ENABLED (CONFIG_BOOKE ) && !IS_ENABLED (CONFIG_40x)) -BUG_ON (!(regs->msr &MSR_RI )); -BUG_ON (!(regs->msr &MSR_PR )); -BUG_ON (arch_irq_disabled_regs (regs)); + expected_msr |=MSR_RI ; +if (IS_ENABLED (CONFIG_PPC32 )) + expected_msr |=MSR_EE ; +BUG_ON ((regs->msr & expected_msr) ^ expected_msr); +BUG_ON (IS_ENABLED (CONFIG_PPC64 ) &&arch_irq_disabled_regs (regs));#ifdef CONFIG_PPC_PKEY if (mmu_has_feature (MMU_FTR_PKEY )) {
Signature · 1 line
2.25.0
PATCH v4 23/23 powerpc/syscall: Avoid storing 'current' in another pointer
In reply to Christophe LeroyBy saving the pointer pointing to thread_info.flags, gcc copies r2 in a non-volatile register.
We know 'current' doesn't change, so avoid that intermediaite pointer.
Reduces null_syscall benchmark by 2 cycles (322 => 320 cycles)
On PPC64, gcc seems to know that 'current' is not changing, and it keeps it in a non volatile register to avoid multiple read of 'current' in paca.
--- arch/powerpc/kernel/syscall.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
arch/powerpc/kernel/syscall.c +4 -5
@@ -186,7 +186,6 @@ notrace unsigned long syscall_exit_prepare(unsigned long r3, struct pt_regs *regs, long scv) { -unsigned long *ti_flagsp = ¤t_thread_info ()->flags;unsigned long ti_flags;unsigned long ret =0 ;
@@ -202,7 +201,7 @@ notrace unsigned long syscall_exit_prepare(unsigned long r3,/* Check whether the syscall is issued inside a restartable sequence */ rseq_syscall (regs); - ti_flags = *ti_flagsp; + ti_flags =current_thread_info ()->flags;if (unlikely (r3 >= (unsigned long )-MAX_ERRNO ) && !scv) {if (likely (!(ti_flags & (_TIF_NOERROR | _TIF_RESTOREALL)))) {
@@ -216,7 +215,7 @@ notrace unsigned long syscall_exit_prepare(unsigned long r3, ret = _TIF_RESTOREALL; else regs->gpr[3] = r3; -clear_bits (_TIF_PERSYSCALL_MASK, ti_flagsp); +clear_bits (_TIF_PERSYSCALL_MASK, ¤t_thread_info ()->flags); }else { regs->gpr[3 ] = r3; }
@@ -228,7 +227,7 @@ notrace unsigned long syscall_exit_prepare(unsigned long r3, again:local_irq_disable (); - ti_flags =READ_ONCE (*ti_flagsp); + ti_flags =READ_ONCE (current_thread_info ()->flags);while (unlikely (ti_flags & (_TIF_USER_WORK_MASK & ~_TIF_RESTORE_TM))) {local_irq_enable ();if (ti_flags & _TIF_NEED_RESCHED) {
@@ -244,7 +243,7 @@ notrace unsigned long syscall_exit_prepare(unsigned long r3,do_notify_resume (regs, ti_flags); }local_irq_disable (); - ti_flags =READ_ONCE (*ti_flagsp); + ti_flags =READ_ONCE (current_thread_info ()->flags); }if (IS_ENABLED (CONFIG_PPC_BOOK3S ) &&IS_ENABLED (CONFIG_PPC_FPU )) {
Signature · 1 line
2.25.0