Skip to content

Commit 95c7b07

Browse files
committed
Merge tag 'powerpc-5.12-6' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux
Pull powerpc fixes from Michael Ellerman: "Some some more powerpc fixes for 5.12: - Fix an oops triggered by ptrace when CONFIG_PPC_FPU_REGS=n - Fix an oops on sigreturn when the VDSO is unmapped on 32-bit - Fix vdso_wrapper.o not being rebuilt everytime vdso.so is rebuilt Thanks to Christophe Leroy" * tag 'powerpc-5.12-6' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux: powerpc/vdso: Make sure vdso_wrapper.o is rebuilt everytime vdso.so is rebuilt powerpc/signal32: Fix Oops on sigreturn with unmapped VDSO powerpc/ptrace: Don't return error when getting/setting FP regs without CONFIG_PPC_FPU_REGS
2 parents d5fa1da + 791f9e3 commit 95c7b07

File tree

7 files changed

+32
-30
lines changed

7 files changed

+32
-30
lines changed

arch/powerpc/kernel/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,3 +191,7 @@ $(obj)/prom_init_check: $(src)/prom_init_check.sh $(obj)/prom_init.o FORCE
191191
targets += prom_init_check
192192

193193
clean-files := vmlinux.lds
194+
195+
# Force dependency (incbin is bad)
196+
$(obj)/vdso32_wrapper.o : $(obj)/vdso32/vdso32.so.dbg
197+
$(obj)/vdso64_wrapper.o : $(obj)/vdso64/vdso64.so.dbg

arch/powerpc/kernel/ptrace/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
CFLAGS_ptrace-view.o += -DUTS_MACHINE='"$(UTS_MACHINE)"'
77

88
obj-y += ptrace.o ptrace-view.o
9-
obj-$(CONFIG_PPC_FPU_REGS) += ptrace-fpu.o
9+
obj-y += ptrace-fpu.o
1010
obj-$(CONFIG_COMPAT) += ptrace32.o
1111
obj-$(CONFIG_VSX) += ptrace-vsx.o
1212
ifneq ($(CONFIG_VSX),y)
13-
obj-$(CONFIG_PPC_FPU_REGS) += ptrace-novsx.o
13+
obj-y += ptrace-novsx.o
1414
endif
1515
obj-$(CONFIG_ALTIVEC) += ptrace-altivec.o
1616
obj-$(CONFIG_SPE) += ptrace-spe.o

arch/powerpc/kernel/ptrace/ptrace-decl.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -165,22 +165,8 @@ int ptrace_put_reg(struct task_struct *task, int regno, unsigned long data);
165165
extern const struct user_regset_view user_ppc_native_view;
166166

167167
/* ptrace-fpu */
168-
#ifdef CONFIG_PPC_FPU_REGS
169168
int ptrace_get_fpr(struct task_struct *child, int index, unsigned long *data);
170169
int ptrace_put_fpr(struct task_struct *child, int index, unsigned long data);
171-
#else
172-
static inline int
173-
ptrace_get_fpr(struct task_struct *child, int index, unsigned long *data)
174-
{
175-
return -EIO;
176-
}
177-
178-
static inline int
179-
ptrace_put_fpr(struct task_struct *child, int index, unsigned long data)
180-
{
181-
return -EIO;
182-
}
183-
#endif
184170

185171
/* ptrace-(no)adv */
186172
void ppc_gethwdinfo(struct ppc_debug_info *dbginfo);

arch/powerpc/kernel/ptrace/ptrace-fpu.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,42 @@
88

99
int ptrace_get_fpr(struct task_struct *child, int index, unsigned long *data)
1010
{
11+
#ifdef CONFIG_PPC_FPU_REGS
1112
unsigned int fpidx = index - PT_FPR0;
13+
#endif
1214

1315
if (index > PT_FPSCR)
1416
return -EIO;
1517

18+
#ifdef CONFIG_PPC_FPU_REGS
1619
flush_fp_to_thread(child);
1720
if (fpidx < (PT_FPSCR - PT_FPR0))
1821
memcpy(data, &child->thread.TS_FPR(fpidx), sizeof(long));
1922
else
2023
*data = child->thread.fp_state.fpscr;
24+
#else
25+
*data = 0;
26+
#endif
2127

2228
return 0;
2329
}
2430

2531
int ptrace_put_fpr(struct task_struct *child, int index, unsigned long data)
2632
{
33+
#ifdef CONFIG_PPC_FPU_REGS
2734
unsigned int fpidx = index - PT_FPR0;
35+
#endif
2836

2937
if (index > PT_FPSCR)
3038
return -EIO;
3139

40+
#ifdef CONFIG_PPC_FPU_REGS
3241
flush_fp_to_thread(child);
3342
if (fpidx < (PT_FPSCR - PT_FPR0))
3443
memcpy(&child->thread.TS_FPR(fpidx), &data, sizeof(long));
3544
else
3645
child->thread.fp_state.fpscr = data;
46+
#endif
3747

3848
return 0;
3949
}

arch/powerpc/kernel/ptrace/ptrace-novsx.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,16 @@
2121
int fpr_get(struct task_struct *target, const struct user_regset *regset,
2222
struct membuf to)
2323
{
24+
#ifdef CONFIG_PPC_FPU_REGS
2425
BUILD_BUG_ON(offsetof(struct thread_fp_state, fpscr) !=
2526
offsetof(struct thread_fp_state, fpr[32]));
2627

2728
flush_fp_to_thread(target);
2829

2930
return membuf_write(&to, &target->thread.fp_state, 33 * sizeof(u64));
31+
#else
32+
return membuf_write(&to, &empty_zero_page, 33 * sizeof(u64));
33+
#endif
3034
}
3135

3236
/*
@@ -46,11 +50,15 @@ int fpr_set(struct task_struct *target, const struct user_regset *regset,
4650
unsigned int pos, unsigned int count,
4751
const void *kbuf, const void __user *ubuf)
4852
{
53+
#ifdef CONFIG_PPC_FPU_REGS
4954
BUILD_BUG_ON(offsetof(struct thread_fp_state, fpscr) !=
5055
offsetof(struct thread_fp_state, fpr[32]));
5156

5257
flush_fp_to_thread(target);
5358

5459
return user_regset_copyin(&pos, &count, &kbuf, &ubuf,
5560
&target->thread.fp_state, 0, -1);
61+
#else
62+
return 0;
63+
#endif
5664
}

arch/powerpc/kernel/ptrace/ptrace-view.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -522,13 +522,11 @@ static const struct user_regset native_regsets[] = {
522522
.size = sizeof(long), .align = sizeof(long),
523523
.regset_get = gpr_get, .set = gpr_set
524524
},
525-
#ifdef CONFIG_PPC_FPU_REGS
526525
[REGSET_FPR] = {
527526
.core_note_type = NT_PRFPREG, .n = ELF_NFPREG,
528527
.size = sizeof(double), .align = sizeof(double),
529528
.regset_get = fpr_get, .set = fpr_set
530529
},
531-
#endif
532530
#ifdef CONFIG_ALTIVEC
533531
[REGSET_VMX] = {
534532
.core_note_type = NT_PPC_VMX, .n = 34,

arch/powerpc/kernel/signal_32.c

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,7 @@ int handle_rt_signal32(struct ksignal *ksig, sigset_t *oldset,
775775
else
776776
prepare_save_user_regs(1);
777777

778-
if (!user_write_access_begin(frame, sizeof(*frame)))
778+
if (!user_access_begin(frame, sizeof(*frame)))
779779
goto badframe;
780780

781781
/* Put the siginfo & fill in most of the ucontext */
@@ -809,17 +809,15 @@ int handle_rt_signal32(struct ksignal *ksig, sigset_t *oldset,
809809
unsafe_put_user(PPC_INST_ADDI + __NR_rt_sigreturn, &mctx->mc_pad[0],
810810
failed);
811811
unsafe_put_user(PPC_INST_SC, &mctx->mc_pad[1], failed);
812+
asm("dcbst %y0; sync; icbi %y0; sync" :: "Z" (mctx->mc_pad[0]));
812813
}
813814
unsafe_put_sigset_t(&frame->uc.uc_sigmask, oldset, failed);
814815

815-
user_write_access_end();
816+
user_access_end();
816817

817818
if (copy_siginfo_to_user(&frame->info, &ksig->info))
818819
goto badframe;
819820

820-
if (tramp == (unsigned long)mctx->mc_pad)
821-
flush_icache_range(tramp, tramp + 2 * sizeof(unsigned long));
822-
823821
regs->link = tramp;
824822

825823
#ifdef CONFIG_PPC_FPU_REGS
@@ -844,7 +842,7 @@ int handle_rt_signal32(struct ksignal *ksig, sigset_t *oldset,
844842
return 0;
845843

846844
failed:
847-
user_write_access_end();
845+
user_access_end();
848846

849847
badframe:
850848
signal_fault(tsk, regs, "handle_rt_signal32", frame);
@@ -879,7 +877,7 @@ int handle_signal32(struct ksignal *ksig, sigset_t *oldset,
879877
else
880878
prepare_save_user_regs(1);
881879

882-
if (!user_write_access_begin(frame, sizeof(*frame)))
880+
if (!user_access_begin(frame, sizeof(*frame)))
883881
goto badframe;
884882
sc = (struct sigcontext __user *) &frame->sctx;
885883

@@ -908,11 +906,9 @@ int handle_signal32(struct ksignal *ksig, sigset_t *oldset,
908906
/* Set up the sigreturn trampoline: li r0,sigret; sc */
909907
unsafe_put_user(PPC_INST_ADDI + __NR_sigreturn, &mctx->mc_pad[0], failed);
910908
unsafe_put_user(PPC_INST_SC, &mctx->mc_pad[1], failed);
909+
asm("dcbst %y0; sync; icbi %y0; sync" :: "Z" (mctx->mc_pad[0]));
911910
}
912-
user_write_access_end();
913-
914-
if (tramp == (unsigned long)mctx->mc_pad)
915-
flush_icache_range(tramp, tramp + 2 * sizeof(unsigned long));
911+
user_access_end();
916912

917913
regs->link = tramp;
918914

@@ -935,7 +931,7 @@ int handle_signal32(struct ksignal *ksig, sigset_t *oldset,
935931
return 0;
936932

937933
failed:
938-
user_write_access_end();
934+
user_access_end();
939935

940936
badframe:
941937
signal_fault(tsk, regs, "handle_signal32", frame);

0 commit comments

Comments
 (0)