Skip to content

Commit 9d45191

Browse files
committed
Merge tag 'x86_urgent_for_v6.8_rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 fixes from Borislav Petkov: - Make sure 32-bit syscall registers are properly sign-extended - Add detection for AMD's Zen5 generation CPUs and Intel's Clearwater Forest CPU model number - Make a stub function export non-GPL because it is part of the paravirt alternatives and that can be used by non-GPL code * tag 'x86_urgent_for_v6.8_rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/CPU/AMD: Add more models to X86_FEATURE_ZEN5 x86/entry/ia32: Ensure s32 is sign extended to s64 x86/cpu: Add model number for Intel Clearwater Forest processor x86/CPU/AMD: Add X86_FEATURE_ZEN5 x86/paravirt: Make BUG_func() usable by non-GPL modules
2 parents a08ebda + b9328fd commit 9d45191

File tree

6 files changed

+50
-12
lines changed

6 files changed

+50
-12
lines changed

arch/x86/include/asm/cpufeatures.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,8 @@
8181
#define X86_FEATURE_K6_MTRR ( 3*32+ 1) /* AMD K6 nonstandard MTRRs */
8282
#define X86_FEATURE_CYRIX_ARR ( 3*32+ 2) /* Cyrix ARRs (= MTRRs) */
8383
#define X86_FEATURE_CENTAUR_MCR ( 3*32+ 3) /* Centaur MCRs (= MTRRs) */
84-
85-
/* CPU types for specific tunings: */
8684
#define X86_FEATURE_K8 ( 3*32+ 4) /* "" Opteron, Athlon64 */
87-
/* FREE, was #define X86_FEATURE_K7 ( 3*32+ 5) "" Athlon */
85+
#define X86_FEATURE_ZEN5 ( 3*32+ 5) /* "" CPU based on Zen5 microarchitecture */
8886
#define X86_FEATURE_P3 ( 3*32+ 6) /* "" P3 */
8987
#define X86_FEATURE_P4 ( 3*32+ 7) /* "" P4 */
9088
#define X86_FEATURE_CONSTANT_TSC ( 3*32+ 8) /* TSC ticks at a constant rate */

arch/x86/include/asm/intel-family.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@
162162
#define INTEL_FAM6_ATOM_CRESTMONT_X 0xAF /* Sierra Forest */
163163
#define INTEL_FAM6_ATOM_CRESTMONT 0xB6 /* Grand Ridge */
164164

165+
#define INTEL_FAM6_ATOM_DARKMONT_X 0xDD /* Clearwater Forest */
166+
165167
/* Xeon Phi */
166168

167169
#define INTEL_FAM6_XEON_PHI_KNL 0x57 /* Knights Landing */

arch/x86/include/asm/syscall_wrapper.h

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,29 @@ extern long __ia32_sys_ni_syscall(const struct pt_regs *regs);
5858
,,regs->di,,regs->si,,regs->dx \
5959
,,regs->r10,,regs->r8,,regs->r9) \
6060

61+
62+
/* SYSCALL_PT_ARGS is Adapted from s390x */
63+
#define SYSCALL_PT_ARG6(m, t1, t2, t3, t4, t5, t6) \
64+
SYSCALL_PT_ARG5(m, t1, t2, t3, t4, t5), m(t6, (regs->bp))
65+
#define SYSCALL_PT_ARG5(m, t1, t2, t3, t4, t5) \
66+
SYSCALL_PT_ARG4(m, t1, t2, t3, t4), m(t5, (regs->di))
67+
#define SYSCALL_PT_ARG4(m, t1, t2, t3, t4) \
68+
SYSCALL_PT_ARG3(m, t1, t2, t3), m(t4, (regs->si))
69+
#define SYSCALL_PT_ARG3(m, t1, t2, t3) \
70+
SYSCALL_PT_ARG2(m, t1, t2), m(t3, (regs->dx))
71+
#define SYSCALL_PT_ARG2(m, t1, t2) \
72+
SYSCALL_PT_ARG1(m, t1), m(t2, (regs->cx))
73+
#define SYSCALL_PT_ARG1(m, t1) m(t1, (regs->bx))
74+
#define SYSCALL_PT_ARGS(x, ...) SYSCALL_PT_ARG##x(__VA_ARGS__)
75+
76+
#define __SC_COMPAT_CAST(t, a) \
77+
(__typeof(__builtin_choose_expr(__TYPE_IS_L(t), 0, 0U))) \
78+
(unsigned int)a
79+
6180
/* Mapping of registers to parameters for syscalls on i386 */
6281
#define SC_IA32_REGS_TO_ARGS(x, ...) \
63-
__MAP(x,__SC_ARGS \
64-
,,(unsigned int)regs->bx,,(unsigned int)regs->cx \
65-
,,(unsigned int)regs->dx,,(unsigned int)regs->si \
66-
,,(unsigned int)regs->di,,(unsigned int)regs->bp)
82+
SYSCALL_PT_ARGS(x, __SC_COMPAT_CAST, \
83+
__MAP(x, __SC_TYPE, __VA_ARGS__)) \
6784

6885
#define __SYS_STUB0(abi, name) \
6986
long __##abi##_##name(const struct pt_regs *regs); \

arch/x86/kernel/alternative.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ noinstr void BUG_func(void)
403403
{
404404
BUG();
405405
}
406-
EXPORT_SYMBOL_GPL(BUG_func);
406+
EXPORT_SYMBOL(BUG_func);
407407

408408
#define CALL_RIP_REL_OPCODE 0xff
409409
#define CALL_RIP_REL_MODRM 0x15

arch/x86/kernel/cpu/amd.c

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ static void bsp_init_amd(struct cpuinfo_x86 *c)
538538

539539
/* Figure out Zen generations: */
540540
switch (c->x86) {
541-
case 0x17: {
541+
case 0x17:
542542
switch (c->x86_model) {
543543
case 0x00 ... 0x2f:
544544
case 0x50 ... 0x5f:
@@ -554,8 +554,8 @@ static void bsp_init_amd(struct cpuinfo_x86 *c)
554554
goto warn;
555555
}
556556
break;
557-
}
558-
case 0x19: {
557+
558+
case 0x19:
559559
switch (c->x86_model) {
560560
case 0x00 ... 0x0f:
561561
case 0x20 ... 0x5f:
@@ -569,7 +569,20 @@ static void bsp_init_amd(struct cpuinfo_x86 *c)
569569
goto warn;
570570
}
571571
break;
572-
}
572+
573+
case 0x1a:
574+
switch (c->x86_model) {
575+
case 0x00 ... 0x0f:
576+
case 0x20 ... 0x2f:
577+
case 0x40 ... 0x4f:
578+
case 0x70 ... 0x7f:
579+
setup_force_cpu_cap(X86_FEATURE_ZEN5);
580+
break;
581+
default:
582+
goto warn;
583+
}
584+
break;
585+
573586
default:
574587
break;
575588
}
@@ -1039,6 +1052,11 @@ static void init_amd_zen4(struct cpuinfo_x86 *c)
10391052
msr_set_bit(MSR_ZEN4_BP_CFG, MSR_ZEN4_BP_CFG_SHARED_BTB_FIX_BIT);
10401053
}
10411054

1055+
static void init_amd_zen5(struct cpuinfo_x86 *c)
1056+
{
1057+
init_amd_zen_common();
1058+
}
1059+
10421060
static void init_amd(struct cpuinfo_x86 *c)
10431061
{
10441062
u64 vm_cr;
@@ -1084,6 +1102,8 @@ static void init_amd(struct cpuinfo_x86 *c)
10841102
init_amd_zen3(c);
10851103
else if (boot_cpu_has(X86_FEATURE_ZEN4))
10861104
init_amd_zen4(c);
1105+
else if (boot_cpu_has(X86_FEATURE_ZEN5))
1106+
init_amd_zen5(c);
10871107

10881108
/*
10891109
* Enable workaround for FXSAVE leak on CPUs

include/linux/syscalls.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ struct mnt_id_req;
128128
#define __TYPE_IS_LL(t) (__TYPE_AS(t, 0LL) || __TYPE_AS(t, 0ULL))
129129
#define __SC_LONG(t, a) __typeof(__builtin_choose_expr(__TYPE_IS_LL(t), 0LL, 0L)) a
130130
#define __SC_CAST(t, a) (__force t) a
131+
#define __SC_TYPE(t, a) t
131132
#define __SC_ARGS(t, a) a
132133
#define __SC_TEST(t, a) (void)BUILD_BUG_ON_ZERO(!__TYPE_IS_LL(t) && sizeof(t) > sizeof(long))
133134

0 commit comments

Comments
 (0)