Skip to content

Commit b35660a

Browse files
committed
Merge tag 'powerpc-5.12-4' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux
Pull powerpc fixes from Michael Ellerman: - Fix a possible stack corruption and subsequent DLPAR failure in the rpadlpar_io PCI hotplug driver - Two build fixes for uncommon configurations Thanks to Christophe Leroy and Tyrel Datwyler. * tag 'powerpc-5.12-4' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux: PCI: rpadlpar: Fix potential drc_name corruption in store functions powerpc: Force inlining of cpu_has_feature() to avoid build failure powerpc/vdso32: Add missing _restgpr_31_x to fix build failure
2 parents 812da4d + cc7a0bb commit b35660a

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed

arch/powerpc/include/asm/cpu_has_feature.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include <linux/bug.h>
88
#include <asm/cputable.h>
99

10-
static inline bool early_cpu_has_feature(unsigned long feature)
10+
static __always_inline bool early_cpu_has_feature(unsigned long feature)
1111
{
1212
return !!((CPU_FTRS_ALWAYS & feature) ||
1313
(CPU_FTRS_POSSIBLE & cur_cpu_spec->cpu_features & feature));
@@ -46,7 +46,7 @@ static __always_inline bool cpu_has_feature(unsigned long feature)
4646
return static_branch_likely(&cpu_feature_keys[i]);
4747
}
4848
#else
49-
static inline bool cpu_has_feature(unsigned long feature)
49+
static __always_inline bool cpu_has_feature(unsigned long feature)
5050
{
5151
return early_cpu_has_feature(feature);
5252
}

arch/powerpc/kernel/vdso32/gettimeofday.S

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,14 @@ V_FUNCTION_END(__kernel_clock_getres)
6565
V_FUNCTION_BEGIN(__kernel_time)
6666
cvdso_call_time __c_kernel_time
6767
V_FUNCTION_END(__kernel_time)
68+
69+
/* Routines for restoring integer registers, called by the compiler. */
70+
/* Called with r11 pointing to the stack header word of the caller of the */
71+
/* function, just beyond the end of the integer restore area. */
72+
_GLOBAL(_restgpr_31_x)
73+
_GLOBAL(_rest32gpr_31_x)
74+
lwz r0,4(r11)
75+
lwz r31,-4(r11)
76+
mtlr r0
77+
mr r1,r11
78+
blr

drivers/pci/hotplug/rpadlpar_sysfs.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,11 @@ static ssize_t add_slot_store(struct kobject *kobj, struct kobj_attribute *attr,
3434
if (nbytes >= MAX_DRC_NAME_LEN)
3535
return 0;
3636

37-
memcpy(drc_name, buf, nbytes);
37+
strscpy(drc_name, buf, nbytes + 1);
3838

3939
end = strchr(drc_name, '\n');
40-
if (!end)
41-
end = &drc_name[nbytes];
42-
*end = '\0';
40+
if (end)
41+
*end = '\0';
4342

4443
rc = dlpar_add_slot(drc_name);
4544
if (rc)
@@ -65,12 +64,11 @@ static ssize_t remove_slot_store(struct kobject *kobj,
6564
if (nbytes >= MAX_DRC_NAME_LEN)
6665
return 0;
6766

68-
memcpy(drc_name, buf, nbytes);
67+
strscpy(drc_name, buf, nbytes + 1);
6968

7069
end = strchr(drc_name, '\n');
71-
if (!end)
72-
end = &drc_name[nbytes];
73-
*end = '\0';
70+
if (end)
71+
*end = '\0';
7472

7573
rc = dlpar_remove_slot(drc_name);
7674
if (rc)

0 commit comments

Comments
 (0)