Skip to content

Commit f5b2a3e

Browse files
Automatic merge of 'next-test' into merge-test (2026-08-03 18:39)
2 parents c29abb2 + 5458b50 commit f5b2a3e

19 files changed

Lines changed: 200 additions & 86 deletions

File tree

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/* SPDX-License-Identifier: GPL-2.0-only */
2+
3+
#ifndef _ASM_POWERPC_PAPR_WATCHDOG_H
4+
#define _ASM_POWERPC_PAPR_WATCHDOG_H
5+
6+
/*
7+
* H_WATCHDOG Input
8+
*
9+
* R4: "flags":
10+
*
11+
* Bits 48-55: "operation"
12+
*/
13+
#define PSERIES_WDTF_OP_START 0x100UL /* start timer */
14+
#define PSERIES_WDTF_OP_STOP 0x200UL /* stop timer */
15+
#define PSERIES_WDTF_OP_QUERY 0x300UL /* query timer capabilities */
16+
17+
/*
18+
* Bits 56-63: "timeoutAction" (for "Start Watchdog" only)
19+
*/
20+
#define PSERIES_WDTF_ACTION_HARD_POWEROFF 0x1UL /* poweroff */
21+
#define PSERIES_WDTF_ACTION_HARD_RESTART 0x2UL /* restart */
22+
#define PSERIES_WDTF_ACTION_DUMP_RESTART 0x3UL /* dump + restart */
23+
24+
/*
25+
* R5: "watchdogNumber":
26+
* PAPR says use -1 (all ones) to stop all watchdogs.
27+
*/
28+
#define PSERIES_WDT_NUM_ALL ((unsigned long)-1)
29+
30+
/*
31+
* H_WATCHDOG Output
32+
*
33+
* R3: Return code
34+
*
35+
* H_SUCCESS The operation completed.
36+
*
37+
* H_BUSY The hypervisor is too busy; retry the operation.
38+
*
39+
* H_PARAMETER The given "flags" are somehow invalid. Either the
40+
* "operation" or "timeoutAction" is invalid, or a
41+
* reserved bit is set.
42+
*
43+
* H_P2 The given "watchdogNumber" is zero or exceeds the
44+
* supported maximum value.
45+
*
46+
* H_P3 The given "timeoutInMs" is below the supported
47+
* minimum value.
48+
*
49+
* H_NOOP The given "watchdogNumber" is already stopped.
50+
*
51+
* H_HARDWARE The operation failed for ineffable reasons.
52+
*
53+
* H_FUNCTION The H_WATCHDOG hypercall is not supported by this
54+
* hypervisor.
55+
*
56+
* R4:
57+
*
58+
* - For the "Query Watchdog Capabilities" operation, a 64-bit
59+
* structure:
60+
*/
61+
#define PSERIES_WDTQ_MIN_TIMEOUT(cap) (((cap) >> 48) & 0xffff)
62+
#define PSERIES_WDTQ_MAX_NUMBER(cap) (((cap) >> 32) & 0xffff)
63+
64+
#endif /* _ASM_POWERPC_PAPR_WATCHDOG_H */

‎arch/powerpc/include/asm/reg.h‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1357,6 +1357,18 @@
13571357
#define PVR_ARCH_31 0x0f000006
13581358
#define PVR_ARCH_31_P11 0x0f000007
13591359

1360+
/*
1361+
* Kernel-internal sentinel for invalid processor compatibility modes.
1362+
* PAPR specifies that the first byte of a valid logical PVR value is
1363+
* 0x0f. So 0xffffffff lies permanently outside the PAPR-defined range
1364+
* and is safe to repurpose. KVM stores it in vcpu->arch.arch_compat
1365+
* when userspace requests an unsupported compatibility mode (e.g.,
1366+
* Power11 PVR on a Power11 host booted in Power10 compat).
1367+
* kvmppc_sanity_check() detects this and prevents the vCPU from
1368+
* running with an unsupported arch_compat.
1369+
*/
1370+
#define PVR_ARCH_INVALID 0xffffffff
1371+
13601372
/* Macros for setting and retrieving special purpose registers */
13611373
#ifndef __ASSEMBLER__
13621374

‎arch/powerpc/include/asm/syscall.h‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,12 @@ static inline void syscall_set_return_value(struct task_struct *task,
9898
regs->gpr[3] = val;
9999
}
100100
}
101+
/*
102+
* Mark that a return value has been explicitly set by seccomp or
103+
* ptrace so that system_call_exception() can skip the syscall
104+
* unconditionally, even when the user requested syscall(-1).
105+
*/
106+
set_thread_flag(TIF_SYSCALL_RET);
101107
}
102108

103109
static inline void syscall_get_arguments(struct task_struct *task,

‎arch/powerpc/include/asm/thread_info.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ void arch_setup_new_exec(void);
120120
#endif
121121
#define TIF_POLLING_NRFLAG 19 /* true if poll_idle() is polling TIF_NEED_RESCHED */
122122
#define TIF_32BIT 20 /* 32 bit binary */
123+
#define TIF_SYSCALL_RET 21 /* syscall error value set */
123124

124125
/* as above, but as bit values */
125126
#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)

‎arch/powerpc/include/asm/xive.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ static inline bool xive_enabled(void) { return __xive_enabled; }
9191

9292
bool xive_spapr_init(void);
9393
bool xive_native_init(void);
94-
void xive_smp_probe(void);
94+
int xive_smp_probe(void);
9595
int xive_smp_prepare_cpu(unsigned int cpu);
9696
void xive_smp_setup_cpu(void);
9797
void xive_smp_disable_cpu(void);
@@ -153,7 +153,7 @@ static inline bool xive_enabled(void) { return false; }
153153

154154
static inline bool xive_spapr_init(void) { return false; }
155155
static inline bool xive_native_init(void) { return false; }
156-
static inline void xive_smp_probe(void) { }
156+
static inline int xive_smp_probe(void) { return -EINVAL; }
157157
static inline int xive_smp_prepare_cpu(unsigned int cpu) { return -EINVAL; }
158158
static inline void xive_smp_setup_cpu(void) { }
159159
static inline void xive_smp_disable_cpu(void) { }

‎arch/powerpc/kernel/head_64.S‎

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -713,14 +713,18 @@ p_end: .8byte _end - copy_to_here
713713
_GLOBAL(copy_and_flush)
714714
addi r5,r5,-8
715715
addi r6,r6,-8
716-
4: li r0,8 /* Use the smallest common */
717-
/* denominator cache line */
718-
/* size. This results in */
719-
/* extra cache line flushes */
720-
/* but operation is correct. */
721-
/* Can't get cache line size */
722-
/* from NACA as it is being */
723-
/* moved too. */
716+
4: li r0,8 /* r0 is the number of 8-byte words */
717+
/* to copy per cache sync iteration. */
718+
/* 8 words * 8 bytes = 64 bytes. 64B is */
719+
/* the current default cache line size. */
720+
/* This is a loop count, not a byte */
721+
/* count. Increasing it may skip */
722+
/* dcbst/icbi for lines in between and */
723+
/* leave stale instructions in icache. */
724+
/* This results in extra cache line */
725+
/* flushes but operation is correct. */
726+
/* Can't get cache line size from NACA */
727+
/* as it is being moved too. */
724728

725729
mtctr r0 /* put # words/line in ctr */
726730
3: addi r6,r6,8 /* copy a cache line */

‎arch/powerpc/kernel/irq.c‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,12 @@ static __always_inline void call_do_softirq(const void *sp)
217217
[sp] "b" (sp), [offset] "i" (THREAD_SIZE - STACK_FRAME_MIN_SIZE),
218218
[callee] "i" (__do_softirq)
219219
: // Clobbers
220-
"lr", "xer", "ctr", "memory", "cr0", "cr1", "cr5", "cr6",
221-
"cr7", "r0", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10",
220+
"lr", "xer", "ctr", "memory", "cr0", "cr1", "cr5", "cr6", "cr7", "r0",
221+
/* r2 may be clobbered by the callee when using PCREL mode in the ELFv2 ABI. */
222+
#ifdef CONFIG_PPC_KERNEL_PCREL
223+
"r2",
224+
#endif
225+
"r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10",
222226
"r11", "r12"
223227
);
224228
}
@@ -275,8 +279,12 @@ static __always_inline void call_do_irq(struct pt_regs *regs, void *sp)
275279
[sp] "b" (sp), [offset] "i" (THREAD_SIZE - STACK_FRAME_MIN_SIZE),
276280
[callee] "i" (__do_irq)
277281
: // Clobbers
278-
"lr", "xer", "ctr", "memory", "cr0", "cr1", "cr5", "cr6",
279-
"cr7", "r0", "r4", "r5", "r6", "r7", "r8", "r9", "r10",
282+
"lr", "xer", "ctr", "memory", "cr0", "cr1", "cr5", "cr6", "cr7", "r0",
283+
/* r2 may be clobbered by the callee when using PCREL mode in the ELFv2 ABI. */
284+
#ifdef CONFIG_PPC_KERNEL_PCREL
285+
"r2",
286+
#endif
287+
"r4", "r5", "r6", "r7", "r8", "r9", "r10",
280288
"r11", "r12"
281289
);
282290
}

‎arch/powerpc/kernel/smp.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,9 @@ void smp_muxed_ipi_set_message(int cpu, int msg)
289289

290290
void smp_muxed_ipi_message_pass(int cpu, int msg)
291291
{
292+
if (!smp_ops->cause_ipi)
293+
return;
294+
292295
smp_muxed_ipi_set_message(cpu, msg);
293296

294297
/*

‎arch/powerpc/kernel/syscall.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ notrace long system_call_exception(struct pt_regs *regs, unsigned long r0)
2222
add_random_kstack_offset();
2323
r0 = syscall_enter_from_user_mode(regs, r0);
2424

25+
if (unlikely(test_and_clear_thread_flag(TIF_SYSCALL_RET)))
26+
return syscall_get_error(current, regs);
27+
2528
if (unlikely(r0 >= NR_syscalls)) {
2629
if (unlikely(trap_is_unsupported_scv(regs))) {
2730
/* Unsupported scv vector */

‎arch/powerpc/kvm/book3s_hv.c‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,19 @@ static int kvmppc_set_arch_compat(struct kvm_vcpu *vcpu, u32 arch_compat)
446446
guest_pcr_bit = PCR_ARCH_300;
447447
break;
448448
case PVR_ARCH_31:
449+
guest_pcr_bit = PCR_ARCH_31;
450+
break;
449451
case PVR_ARCH_31_P11:
452+
/*
453+
* Need to check this for ISA 3.1, as Power10 and
454+
* Power11 share the same PCR. For any subsequent ISA
455+
* versions, this will be taken care of by the guest vs
456+
* host PCR comparison below.
457+
*/
458+
if (!cpu_has_feature(CPU_FTR_P11_PVR)) {
459+
arch_compat = PVR_ARCH_INVALID;
460+
goto out;
461+
}
450462
guest_pcr_bit = PCR_ARCH_31;
451463
break;
452464
default:
@@ -469,6 +481,7 @@ static int kvmppc_set_arch_compat(struct kvm_vcpu *vcpu, u32 arch_compat)
469481
return -EINVAL;
470482
}
471483

484+
out:
472485
spin_lock(&vc->lock);
473486
vc->arch_compat = arch_compat;
474487
kvmhv_nestedv2_mark_dirty(vcpu, KVMPPC_GSID_LOGICAL_PVR);
@@ -479,7 +492,7 @@ static int kvmppc_set_arch_compat(struct kvm_vcpu *vcpu, u32 arch_compat)
479492
vc->pcr = (host_pcr_bit - guest_pcr_bit) | PCR_MASK;
480493
spin_unlock(&vc->lock);
481494

482-
return 0;
495+
return kvmppc_sanity_check(vcpu);
483496
}
484497

485498
static void kvmppc_dump_regs(struct kvm_vcpu *vcpu)

0 commit comments

Comments
 (0)