Skip to content

Commit 4b6f231

Browse files
committed
Merge tag 'powerpc-5.3-3' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux
Pull powerpc fixes from Michael Ellerman: "Some more powerpc fixes for 5.3: - Wire up the new clone3 syscall. - A fix for the PAPR SCM nvdimm driver, to fix a crash when firmware gives us a device that's attached to a non-online NUMA node. - A fix for a boot failure on 32-bit with KASAN enabled. - Three fixes for implicit fall through warnings, some of which are errors for us due to -Werror. Thanks to: Aneesh Kumar K.V, Christophe Leroy, Kees Cook, Santosh Sivaraj, Stephen Rothwell" * tag 'powerpc-5.3-3' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux: powerpc/kasan: fix early boot failure on PPC32 drivers/macintosh/smu.c: Mark expected switch fall-through powerpc/spe: Mark expected switch fall-throughs powerpc/nvdimm: Pick nearby online node if the device node is not online powerpc/kvm: Fall through switch case explicitly powerpc: Wire up clone3 syscall
2 parents 4c0d228 + d7e23b8 commit 4b6f231

File tree

9 files changed

+53
-5
lines changed

9 files changed

+53
-5
lines changed

arch/powerpc/include/asm/unistd.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
#define __ARCH_WANT_SYS_FORK
5050
#define __ARCH_WANT_SYS_VFORK
5151
#define __ARCH_WANT_SYS_CLONE
52+
#define __ARCH_WANT_SYS_CLONE3
5253

5354
#endif /* __ASSEMBLY__ */
5455
#endif /* _ASM_POWERPC_UNISTD_H_ */

arch/powerpc/kernel/align.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,11 @@ static int emulate_spe(struct pt_regs *regs, unsigned int reg,
176176
ret |= __get_user_inatomic(temp.v[1], p++);
177177
ret |= __get_user_inatomic(temp.v[2], p++);
178178
ret |= __get_user_inatomic(temp.v[3], p++);
179+
/* fall through */
179180
case 4:
180181
ret |= __get_user_inatomic(temp.v[4], p++);
181182
ret |= __get_user_inatomic(temp.v[5], p++);
183+
/* fall through */
182184
case 2:
183185
ret |= __get_user_inatomic(temp.v[6], p++);
184186
ret |= __get_user_inatomic(temp.v[7], p++);
@@ -259,9 +261,11 @@ static int emulate_spe(struct pt_regs *regs, unsigned int reg,
259261
ret |= __put_user_inatomic(data.v[1], p++);
260262
ret |= __put_user_inatomic(data.v[2], p++);
261263
ret |= __put_user_inatomic(data.v[3], p++);
264+
/* fall through */
262265
case 4:
263266
ret |= __put_user_inatomic(data.v[4], p++);
264267
ret |= __put_user_inatomic(data.v[5], p++);
268+
/* fall through */
265269
case 2:
266270
ret |= __put_user_inatomic(data.v[6], p++);
267271
ret |= __put_user_inatomic(data.v[7], p++);

arch/powerpc/kernel/entry_32.S

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,14 @@ ppc_clone:
597597
stw r0,_TRAP(r1) /* register set saved */
598598
b sys_clone
599599

600+
.globl ppc_clone3
601+
ppc_clone3:
602+
SAVE_NVGPRS(r1)
603+
lwz r0,_TRAP(r1)
604+
rlwinm r0,r0,0,0,30 /* clear LSB to indicate full */
605+
stw r0,_TRAP(r1) /* register set saved */
606+
b sys_clone3
607+
600608
.globl ppc_swapcontext
601609
ppc_swapcontext:
602610
SAVE_NVGPRS(r1)

arch/powerpc/kernel/entry_64.S

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,11 @@ _GLOBAL(ppc_clone)
487487
bl sys_clone
488488
b .Lsyscall_exit
489489

490+
_GLOBAL(ppc_clone3)
491+
bl save_nvgprs
492+
bl sys_clone3
493+
b .Lsyscall_exit
494+
490495
_GLOBAL(ppc32_swapcontext)
491496
bl save_nvgprs
492497
bl compat_sys_swapcontext

arch/powerpc/kernel/syscalls/syscall.tbl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,4 +516,4 @@
516516
432 common fsmount sys_fsmount
517517
433 common fspick sys_fspick
518518
434 common pidfd_open sys_pidfd_open
519-
# 435 reserved for clone3
519+
435 nospu clone3 ppc_clone3

arch/powerpc/kvm/book3s_32_mmu.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ static int kvmppc_mmu_book3s_32_xlate_pte(struct kvm_vcpu *vcpu, gva_t eaddr,
239239
case 2:
240240
case 6:
241241
pte->may_write = true;
242+
/* fall through */
242243
case 3:
243244
case 5:
244245
case 7:

arch/powerpc/mm/kasan/kasan_init_32.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ static void kasan_populate_pte(pte_t *ptep, pgprot_t prot)
2121
__set_pte_at(&init_mm, va, ptep, pfn_pte(PHYS_PFN(pa), prot), 0);
2222
}
2323

24-
static int kasan_init_shadow_page_tables(unsigned long k_start, unsigned long k_end)
24+
static int __ref kasan_init_shadow_page_tables(unsigned long k_start, unsigned long k_end)
2525
{
2626
pmd_t *pmd;
2727
unsigned long k_cur, k_next;
@@ -35,7 +35,10 @@ static int kasan_init_shadow_page_tables(unsigned long k_start, unsigned long k_
3535
if ((void *)pmd_page_vaddr(*pmd) != kasan_early_shadow_pte)
3636
continue;
3737

38-
new = pte_alloc_one_kernel(&init_mm);
38+
if (slab_is_available())
39+
new = pte_alloc_one_kernel(&init_mm);
40+
else
41+
new = memblock_alloc(PTE_FRAG_SIZE, PTE_FRAG_SIZE);
3942

4043
if (!new)
4144
return -ENOMEM;

arch/powerpc/platforms/pseries/papr_scm.c

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,12 +275,32 @@ static const struct attribute_group *papr_scm_dimm_groups[] = {
275275
NULL,
276276
};
277277

278+
static inline int papr_scm_node(int node)
279+
{
280+
int min_dist = INT_MAX, dist;
281+
int nid, min_node;
282+
283+
if ((node == NUMA_NO_NODE) || node_online(node))
284+
return node;
285+
286+
min_node = first_online_node;
287+
for_each_online_node(nid) {
288+
dist = node_distance(node, nid);
289+
if (dist < min_dist) {
290+
min_dist = dist;
291+
min_node = nid;
292+
}
293+
}
294+
return min_node;
295+
}
296+
278297
static int papr_scm_nvdimm_init(struct papr_scm_priv *p)
279298
{
280299
struct device *dev = &p->pdev->dev;
281300
struct nd_mapping_desc mapping;
282301
struct nd_region_desc ndr_desc;
283302
unsigned long dimm_flags;
303+
int target_nid, online_nid;
284304

285305
p->bus_desc.ndctl = papr_scm_ndctl;
286306
p->bus_desc.module = THIS_MODULE;
@@ -319,8 +339,10 @@ static int papr_scm_nvdimm_init(struct papr_scm_priv *p)
319339

320340
memset(&ndr_desc, 0, sizeof(ndr_desc));
321341
ndr_desc.attr_groups = region_attr_groups;
322-
ndr_desc.numa_node = dev_to_node(&p->pdev->dev);
323-
ndr_desc.target_node = ndr_desc.numa_node;
342+
target_nid = dev_to_node(&p->pdev->dev);
343+
online_nid = papr_scm_node(target_nid);
344+
ndr_desc.numa_node = online_nid;
345+
ndr_desc.target_node = target_nid;
324346
ndr_desc.res = &p->res;
325347
ndr_desc.of_node = p->dn;
326348
ndr_desc.provider_data = p;
@@ -338,6 +360,9 @@ static int papr_scm_nvdimm_init(struct papr_scm_priv *p)
338360
ndr_desc.res, p->dn);
339361
goto err;
340362
}
363+
if (target_nid != online_nid)
364+
dev_info(dev, "Region registered with target node %d and online node %d",
365+
target_nid, online_nid);
341366

342367
return 0;
343368

drivers/macintosh/smu.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -852,6 +852,7 @@ int smu_queue_i2c(struct smu_i2c_cmd *cmd)
852852
break;
853853
case SMU_I2C_TRANSFER_COMBINED:
854854
cmd->info.devaddr &= 0xfe;
855+
/* fall through */
855856
case SMU_I2C_TRANSFER_STDSUB:
856857
if (cmd->info.sublen > 3)
857858
return -EINVAL;

0 commit comments

Comments
 (0)