Skip to content

Commit 629d18b

Browse files
committed
SUNLIGHT: Stable 11/19/2023 - KERNEL.ORG - RT
Description: - Stable 11/19/2023 - KERNEL.ORG - RT Change-Id: I0566795cbf7ef76460856f685778c6d05ab9cbab Signed-off-by: Ionut Nechita <ionut_n2001@yahoo.com>
2 parents 53a1b69 + 5cc961e commit 629d18b

File tree

164 files changed

+5060
-1505
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

164 files changed

+5060
-1505
lines changed

arch/arm/Kconfig

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ config ARM
3434
select ARCH_OPTIONAL_KERNEL_RWX_DEFAULT if CPU_V7
3535
select ARCH_SUPPORTS_ATOMIC_RMW
3636
select ARCH_SUPPORTS_HUGETLBFS if ARM_LPAE
37+
select ARCH_SUPPORTS_RT if HAVE_POSIX_CPU_TIMERS_TASK_WORK
3738
select ARCH_USE_BUILTIN_BSWAP
3839
select ARCH_USE_CMPXCHG_LOCKREF
3940
select ARCH_USE_MEMTEST
@@ -73,7 +74,7 @@ config ARM
7374
select HAS_IOPORT
7475
select HAVE_ARCH_AUDITSYSCALL if AEABI && !OABI_COMPAT
7576
select HAVE_ARCH_BITREVERSE if (CPU_32v7M || CPU_32v7) && !CPU_32v6
76-
select HAVE_ARCH_JUMP_LABEL if !XIP_KERNEL && !CPU_ENDIAN_BE32 && MMU
77+
select HAVE_ARCH_JUMP_LABEL if !XIP_KERNEL && !CPU_ENDIAN_BE32 && MMU && !PREEMPT_RT
7778
select HAVE_ARCH_KFENCE if MMU && !XIP_KERNEL
7879
select HAVE_ARCH_KGDB if !CPU_ENDIAN_BE32 && MMU
7980
select HAVE_ARCH_KASAN if MMU && !XIP_KERNEL
@@ -118,6 +119,7 @@ config ARM
118119
select HAVE_PERF_EVENTS
119120
select HAVE_PERF_REGS
120121
select HAVE_PERF_USER_STACK_DUMP
122+
select HAVE_POSIX_CPU_TIMERS_TASK_WORK if !KVM
121123
select MMU_GATHER_RCU_TABLE_FREE if SMP && ARM_LPAE
122124
select HAVE_REGS_AND_STACK_ACCESS_API
123125
select HAVE_RSEQ

arch/arm/mm/fault.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,9 @@ do_translation_fault(unsigned long addr, unsigned int fsr,
404404
if (addr < TASK_SIZE)
405405
return do_page_fault(addr, fsr, regs);
406406

407+
if (interrupts_enabled(regs))
408+
local_irq_enable();
409+
407410
if (user_mode(regs))
408411
goto bad_area;
409412

@@ -474,6 +477,9 @@ do_translation_fault(unsigned long addr, unsigned int fsr,
474477
static int
475478
do_sect_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
476479
{
480+
if (interrupts_enabled(regs))
481+
local_irq_enable();
482+
477483
do_bad_area(addr, fsr, regs);
478484
return 0;
479485
}

arch/arm/vfp/vfpmodule.c

Lines changed: 53 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,34 @@ extern unsigned int VFP_arch_feroceon __alias(VFP_arch);
5555
*/
5656
union vfp_state *vfp_current_hw_state[NR_CPUS];
5757

58+
/*
59+
* Claim ownership of the VFP unit.
60+
*
61+
* The caller may change VFP registers until vfp_unlock() is called.
62+
*
63+
* local_bh_disable() is used to disable preemption and to disable VFP
64+
* processing in softirq context. On PREEMPT_RT kernels local_bh_disable() is
65+
* not sufficient because it only serializes soft interrupt related sections
66+
* via a local lock, but stays preemptible. Disabling preemption is the right
67+
* choice here as bottom half processing is always in thread context on RT
68+
* kernels so it implicitly prevents bottom half processing as well.
69+
*/
70+
static void vfp_lock(void)
71+
{
72+
if (!IS_ENABLED(CONFIG_PREEMPT_RT))
73+
local_bh_disable();
74+
else
75+
preempt_disable();
76+
}
77+
78+
static void vfp_unlock(void)
79+
{
80+
if (!IS_ENABLED(CONFIG_PREEMPT_RT))
81+
local_bh_enable();
82+
else
83+
preempt_enable();
84+
}
85+
5886
/*
5987
* Is 'thread's most up to date state stored in this CPUs hardware?
6088
* Must be called from non-preemptible context.
@@ -240,16 +268,15 @@ static void vfp_panic(char *reason, u32 inst)
240268
/*
241269
* Process bitmask of exception conditions.
242270
*/
243-
static void vfp_raise_exceptions(u32 exceptions, u32 inst, u32 fpscr, struct pt_regs *regs)
271+
static int vfp_raise_exceptions(u32 exceptions, u32 inst, u32 fpscr)
244272
{
245273
int si_code = 0;
246274

247275
pr_debug("VFP: raising exceptions %08x\n", exceptions);
248276

249277
if (exceptions == VFP_EXCEPTION_ERROR) {
250278
vfp_panic("unhandled bounce", inst);
251-
vfp_raise_sigfpe(FPE_FLTINV, regs);
252-
return;
279+
return FPE_FLTINV;
253280
}
254281

255282
/*
@@ -277,8 +304,7 @@ static void vfp_raise_exceptions(u32 exceptions, u32 inst, u32 fpscr, struct pt_
277304
RAISE(FPSCR_OFC, FPSCR_OFE, FPE_FLTOVF);
278305
RAISE(FPSCR_IOC, FPSCR_IOE, FPE_FLTINV);
279306

280-
if (si_code)
281-
vfp_raise_sigfpe(si_code, regs);
307+
return si_code;
282308
}
283309

284310
/*
@@ -324,6 +350,8 @@ static u32 vfp_emulate_instruction(u32 inst, u32 fpscr, struct pt_regs *regs)
324350
static void VFP_bounce(u32 trigger, u32 fpexc, struct pt_regs *regs)
325351
{
326352
u32 fpscr, orig_fpscr, fpsid, exceptions;
353+
int si_code2 = 0;
354+
int si_code = 0;
327355

328356
pr_debug("VFP: bounce: trigger %08x fpexc %08x\n", trigger, fpexc);
329357

@@ -369,8 +397,8 @@ static void VFP_bounce(u32 trigger, u32 fpexc, struct pt_regs *regs)
369397
* unallocated VFP instruction but with FPSCR.IXE set and not
370398
* on VFP subarch 1.
371399
*/
372-
vfp_raise_exceptions(VFP_EXCEPTION_ERROR, trigger, fpscr, regs);
373-
return;
400+
si_code = vfp_raise_exceptions(VFP_EXCEPTION_ERROR, trigger, fpscr);
401+
goto exit;
374402
}
375403

376404
/*
@@ -394,14 +422,14 @@ static void VFP_bounce(u32 trigger, u32 fpexc, struct pt_regs *regs)
394422
*/
395423
exceptions = vfp_emulate_instruction(trigger, fpscr, regs);
396424
if (exceptions)
397-
vfp_raise_exceptions(exceptions, trigger, orig_fpscr, regs);
425+
si_code2 = vfp_raise_exceptions(exceptions, trigger, orig_fpscr);
398426

399427
/*
400428
* If there isn't a second FP instruction, exit now. Note that
401429
* the FPEXC.FP2V bit is valid only if FPEXC.EX is 1.
402430
*/
403431
if ((fpexc & (FPEXC_EX | FPEXC_FP2V)) != (FPEXC_EX | FPEXC_FP2V))
404-
return;
432+
goto exit;
405433

406434
/*
407435
* The barrier() here prevents fpinst2 being read
@@ -413,7 +441,13 @@ static void VFP_bounce(u32 trigger, u32 fpexc, struct pt_regs *regs)
413441
emulate:
414442
exceptions = vfp_emulate_instruction(trigger, orig_fpscr, regs);
415443
if (exceptions)
416-
vfp_raise_exceptions(exceptions, trigger, orig_fpscr, regs);
444+
si_code = vfp_raise_exceptions(exceptions, trigger, orig_fpscr);
445+
exit:
446+
vfp_unlock();
447+
if (si_code2)
448+
vfp_raise_sigfpe(si_code2, regs);
449+
if (si_code)
450+
vfp_raise_sigfpe(si_code, regs);
417451
}
418452

419453
static void vfp_enable(void *unused)
@@ -512,11 +546,9 @@ static inline void vfp_pm_init(void) { }
512546
*/
513547
void vfp_sync_hwstate(struct thread_info *thread)
514548
{
515-
unsigned int cpu = get_cpu();
549+
vfp_lock();
516550

517-
local_bh_disable();
518-
519-
if (vfp_state_in_hw(cpu, thread)) {
551+
if (vfp_state_in_hw(raw_smp_processor_id(), thread)) {
520552
u32 fpexc = fmrx(FPEXC);
521553

522554
/*
@@ -527,8 +559,7 @@ void vfp_sync_hwstate(struct thread_info *thread)
527559
fmxr(FPEXC, fpexc);
528560
}
529561

530-
local_bh_enable();
531-
put_cpu();
562+
vfp_unlock();
532563
}
533564

534565
/* Ensure that the thread reloads the hardware VFP state on the next use. */
@@ -683,7 +714,7 @@ static int vfp_support_entry(struct pt_regs *regs, u32 trigger)
683714
if (!user_mode(regs))
684715
return vfp_kmode_exception(regs, trigger);
685716

686-
local_bh_disable();
717+
vfp_lock();
687718
fpexc = fmrx(FPEXC);
688719

689720
/*
@@ -748,6 +779,7 @@ static int vfp_support_entry(struct pt_regs *regs, u32 trigger)
748779
* replay the instruction that trapped.
749780
*/
750781
fmxr(FPEXC, fpexc);
782+
vfp_unlock();
751783
} else {
752784
/* Check for synchronous or asynchronous exceptions */
753785
if (!(fpexc & (FPEXC_EX | FPEXC_DEX))) {
@@ -762,17 +794,17 @@ static int vfp_support_entry(struct pt_regs *regs, u32 trigger)
762794
if (!(fpscr & FPSCR_IXE)) {
763795
if (!(fpscr & FPSCR_LENGTH_MASK)) {
764796
pr_debug("not VFP\n");
765-
local_bh_enable();
797+
vfp_unlock();
766798
return -ENOEXEC;
767799
}
768800
fpexc |= FPEXC_DEX;
769801
}
770802
}
771803
bounce: regs->ARM_pc += 4;
804+
/* VFP_bounce() will invoke vfp_unlock() */
772805
VFP_bounce(trigger, fpexc, regs);
773806
}
774807

775-
local_bh_enable();
776808
return 0;
777809
}
778810

@@ -819,7 +851,7 @@ void kernel_neon_begin(void)
819851
unsigned int cpu;
820852
u32 fpexc;
821853

822-
local_bh_disable();
854+
vfp_lock();
823855

824856
/*
825857
* Kernel mode NEON is only allowed outside of hardirq context with
@@ -850,7 +882,7 @@ void kernel_neon_end(void)
850882
{
851883
/* Disable the NEON/VFP unit. */
852884
fmxr(FPEXC, fmrx(FPEXC) & ~FPEXC_EN);
853-
local_bh_enable();
885+
vfp_unlock();
854886
}
855887
EXPORT_SYMBOL(kernel_neon_end);
856888

arch/arm64/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ config ARM64
9797
select ARCH_SUPPORTS_NUMA_BALANCING
9898
select ARCH_SUPPORTS_PAGE_TABLE_CHECK
9999
select ARCH_SUPPORTS_PER_VMA_LOCK
100+
select ARCH_SUPPORTS_RT
100101
select ARCH_WANT_BATCHED_UNMAP_TLB_FLUSH
101102
select ARCH_WANT_COMPAT_IPC_PARSE_VERSION if COMPAT
102103
select ARCH_WANT_DEFAULT_BPF_JIT

arch/powerpc/Kconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ config PPC
166166
select ARCH_STACKWALK
167167
select ARCH_SUPPORTS_ATOMIC_RMW
168168
select ARCH_SUPPORTS_DEBUG_PAGEALLOC if PPC_BOOK3S || PPC_8xx || 40x
169+
select ARCH_SUPPORTS_RT if HAVE_POSIX_CPU_TIMERS_TASK_WORK
169170
select ARCH_USE_BUILTIN_BSWAP
170171
select ARCH_USE_CMPXCHG_LOCKREF if PPC64
171172
select ARCH_USE_MEMTEST
@@ -268,6 +269,7 @@ config PPC
268269
select HAVE_PERF_USER_STACK_DUMP
269270
select HAVE_REGS_AND_STACK_ACCESS_API
270271
select HAVE_RELIABLE_STACKTRACE
272+
select HAVE_POSIX_CPU_TIMERS_TASK_WORK if !KVM
271273
select HAVE_RSEQ
272274
select HAVE_SETUP_PER_CPU_AREA if PPC64
273275
select HAVE_SOFTIRQ_ON_OWN_STACK

arch/powerpc/include/asm/stackprotector.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,13 @@
1919
*/
2020
static __always_inline void boot_init_stack_canary(void)
2121
{
22-
unsigned long canary = get_random_canary();
22+
unsigned long canary;
2323

24+
#ifndef CONFIG_PREEMPT_RT
25+
canary = get_random_canary();
26+
#else
27+
canary = ((unsigned long)&canary) & CANARY_MASK;
28+
#endif
2429
current->stack_canary = canary;
2530
#ifdef CONFIG_PPC64
2631
get_paca()->canary = canary;

arch/powerpc/kernel/traps.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,12 +261,17 @@ static char *get_mmu_str(void)
261261

262262
static int __die(const char *str, struct pt_regs *regs, long err)
263263
{
264+
const char *pr = "";
265+
264266
printk("Oops: %s, sig: %ld [#%d]\n", str, err, ++die_counter);
265267

268+
if (IS_ENABLED(CONFIG_PREEMPTION))
269+
pr = IS_ENABLED(CONFIG_PREEMPT_RT) ? " PREEMPT_RT" : " PREEMPT";
270+
266271
printk("%s PAGE_SIZE=%luK%s%s%s%s%s%s %s\n",
267272
IS_ENABLED(CONFIG_CPU_LITTLE_ENDIAN) ? "LE" : "BE",
268273
PAGE_SIZE / 1024, get_mmu_str(),
269-
IS_ENABLED(CONFIG_PREEMPT) ? " PREEMPT" : "",
274+
pr,
270275
IS_ENABLED(CONFIG_SMP) ? " SMP" : "",
271276
IS_ENABLED(CONFIG_SMP) ? (" NR_CPUS=" __stringify(NR_CPUS)) : "",
272277
debug_pagealloc_enabled() ? " DEBUG_PAGEALLOC" : "",

arch/powerpc/kvm/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ config KVM_E500MC
224224
config KVM_MPIC
225225
bool "KVM in-kernel MPIC emulation"
226226
depends on KVM && PPC_E500
227+
depends on !PREEMPT_RT
227228
select HAVE_KVM_IRQCHIP
228229
select HAVE_KVM_IRQFD
229230
select HAVE_KVM_IRQ_ROUTING

arch/powerpc/perf/imc-pmu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ static int trace_imc_mem_size;
5151
* core and trace-imc
5252
*/
5353
static struct imc_pmu_ref imc_global_refc = {
54-
.lock = __SPIN_LOCK_INITIALIZER(imc_global_refc.lock),
54+
.lock = __SPIN_LOCK_UNLOCKED(imc_global_refc.lock),
5555
.id = 0,
5656
.refc = 0,
5757
};

arch/powerpc/platforms/pseries/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
config PPC_PSERIES
33
depends on PPC64 && PPC_BOOK3S
44
bool "IBM pSeries & new (POWER5-based) iSeries"
5+
select GENERIC_ALLOCATOR
56
select HAVE_PCSPKR_PLATFORM
67
select MPIC
78
select OF_DYNAMIC

0 commit comments

Comments
 (0)