Skip to content

Commit

Permalink
Automatic merge of 'next' into merge (2024-11-04 17:04)
Browse files Browse the repository at this point in the history
  • Loading branch information
mpe committed Nov 4, 2024
2 parents f09cf1c + bee08a9 commit ad0be02
Show file tree
Hide file tree
Showing 11 changed files with 345 additions and 148 deletions.
4 changes: 2 additions & 2 deletions arch/powerpc/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,8 @@ config PPC
select HAVE_RSEQ
select HAVE_SETUP_PER_CPU_AREA if PPC64
select HAVE_SOFTIRQ_ON_OWN_STACK
select HAVE_STACKPROTECTOR if PPC32 && $(cc-option,-mstack-protector-guard=tls -mstack-protector-guard-reg=r2)
select HAVE_STACKPROTECTOR if PPC64 && $(cc-option,-mstack-protector-guard=tls -mstack-protector-guard-reg=r13)
select HAVE_STACKPROTECTOR if PPC32 && $(cc-option,$(m32-flag) -mstack-protector-guard=tls -mstack-protector-guard-reg=r2 -mstack-protector-guard-offset=0)
select HAVE_STACKPROTECTOR if PPC64 && $(cc-option,$(m64-flag) -mstack-protector-guard=tls -mstack-protector-guard-reg=r13 -mstack-protector-guard-offset=0)
select HAVE_STATIC_CALL if PPC32
select HAVE_SYSCALL_TRACEPOINTS
select HAVE_VIRT_CPU_ACCOUNTING
Expand Down
13 changes: 4 additions & 9 deletions arch/powerpc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,6 @@ KBUILD_AFLAGS += -m$(BITS)
KBUILD_LDFLAGS += -m elf$(BITS)$(LDEMULATION)
endif

cflags-$(CONFIG_STACKPROTECTOR) += -mstack-protector-guard=tls
ifdef CONFIG_PPC64
cflags-$(CONFIG_STACKPROTECTOR) += -mstack-protector-guard-reg=r13
else
cflags-$(CONFIG_STACKPROTECTOR) += -mstack-protector-guard-reg=r2
endif

LDFLAGS_vmlinux-y := -Bstatic
LDFLAGS_vmlinux-$(CONFIG_RELOCATABLE) := -pie
LDFLAGS_vmlinux-$(CONFIG_RELOCATABLE) += -z notext
Expand Down Expand Up @@ -402,9 +395,11 @@ prepare: stack_protector_prepare
PHONY += stack_protector_prepare
stack_protector_prepare: prepare0
ifdef CONFIG_PPC64
$(eval KBUILD_CFLAGS += -mstack-protector-guard-offset=$(shell awk '{if ($$2 == "PACA_CANARY") print $$3;}' include/generated/asm-offsets.h))
$(eval KBUILD_CFLAGS += -mstack-protector-guard=tls -mstack-protector-guard-reg=r13 \
-mstack-protector-guard-offset=$(shell awk '{if ($$2 == "PACA_CANARY") print $$3;}' include/generated/asm-offsets.h))
else
$(eval KBUILD_CFLAGS += -mstack-protector-guard-offset=$(shell awk '{if ($$2 == "TASK_CANARY") print $$3;}' include/generated/asm-offsets.h))
$(eval KBUILD_CFLAGS += -mstack-protector-guard=tls -mstack-protector-guard-reg=r2 \
-mstack-protector-guard-offset=$(shell awk '{if ($$2 == "TASK_CANARY") print $$3;}' include/generated/asm-offsets.h))
endif
endif

Expand Down
7 changes: 7 additions & 0 deletions arch/powerpc/include/asm/fadump.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,11 @@ extern int early_init_dt_scan_fw_dump(unsigned long node, const char *uname,
int depth, void *data);
extern int fadump_reserve_mem(void);
#endif

#if defined(CONFIG_FA_DUMP) && defined(CONFIG_CMA)
void fadump_cma_init(void);
#else
static inline void fadump_cma_init(void) { }
#endif

#endif /* _ASM_POWERPC_FADUMP_H */
8 changes: 6 additions & 2 deletions arch/powerpc/include/asm/kfence.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#define ARCH_FUNC_PREFIX "."
#endif

#ifdef CONFIG_KFENCE
extern bool kfence_early_init;
extern bool kfence_disabled;

static inline void disable_kfence(void)
Expand All @@ -27,7 +27,11 @@ static inline bool arch_kfence_init_pool(void)
{
return !kfence_disabled;
}
#endif

static inline bool kfence_early_init_enabled(void)
{
return IS_ENABLED(CONFIG_KFENCE) && kfence_early_init;
}

#ifdef CONFIG_PPC64
static inline bool kfence_protect_page(unsigned long addr, bool protect)
Expand Down
55 changes: 28 additions & 27 deletions arch/powerpc/kernel/fadump.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,26 +78,38 @@ static struct cma *fadump_cma;
* But for some reason even if it fails we still have the memory reservation
* with us and we can still continue doing fadump.
*/
static int __init fadump_cma_init(void)
void __init fadump_cma_init(void)
{
unsigned long long base, size;
unsigned long long base, size, end;
int rc;

if (!fw_dump.fadump_enabled)
return 0;

if (!fw_dump.fadump_supported || !fw_dump.fadump_enabled ||
fw_dump.dump_active)
return;
/*
* Do not use CMA if user has provided fadump=nocma kernel parameter.
* Return 1 to continue with fadump old behaviour.
*/
if (fw_dump.nocma)
return 1;
if (fw_dump.nocma || !fw_dump.boot_memory_size)
return;

/*
* [base, end) should be reserved during early init in
* fadump_reserve_mem(). No need to check this here as
* cma_init_reserved_mem() already checks for overlap.
* Here we give the aligned chunk of this reserved memory to CMA.
*/
base = fw_dump.reserve_dump_area_start;
size = fw_dump.boot_memory_size;
end = base + size;

if (!size)
return 0;
base = ALIGN(base, CMA_MIN_ALIGNMENT_BYTES);
end = ALIGN_DOWN(end, CMA_MIN_ALIGNMENT_BYTES);
size = end - base;

if (end <= base) {
pr_warn("%s: Too less memory to give to CMA\n", __func__);
return;
}

rc = cma_init_reserved_mem(base, size, 0, "fadump_cma", &fadump_cma);
if (rc) {
Expand All @@ -108,7 +120,7 @@ static int __init fadump_cma_init(void)
* blocked from production system usage. Hence return 1,
* so that we can continue with fadump.
*/
return 1;
return;
}

/*
Expand All @@ -120,15 +132,13 @@ static int __init fadump_cma_init(void)
/*
* So we now have successfully initialized cma area for fadump.
*/
pr_info("Initialized 0x%lx bytes cma area at %ldMB from 0x%lx "
pr_info("Initialized [0x%llx, %luMB] cma area from [0x%lx, %luMB] "
"bytes of memory reserved for firmware-assisted dump\n",
cma_get_size(fadump_cma),
(unsigned long)cma_get_base(fadump_cma) >> 20,
fw_dump.reserve_dump_area_size);
return 1;
cma_get_base(fadump_cma), cma_get_size(fadump_cma) >> 20,
fw_dump.reserve_dump_area_start,
fw_dump.boot_memory_size >> 20);
return;
}
#else
static int __init fadump_cma_init(void) { return 1; }
#endif /* CONFIG_CMA */

/*
Expand Down Expand Up @@ -558,13 +568,6 @@ int __init fadump_reserve_mem(void)
if (!fw_dump.dump_active) {
fw_dump.boot_memory_size =
PAGE_ALIGN(fadump_calculate_reserve_size());
#ifdef CONFIG_CMA
if (!fw_dump.nocma) {
fw_dump.boot_memory_size =
ALIGN(fw_dump.boot_memory_size,
CMA_MIN_ALIGNMENT_BYTES);
}
#endif

bootmem_min = fw_dump.ops->fadump_get_bootmem_min();
if (fw_dump.boot_memory_size < bootmem_min) {
Expand Down Expand Up @@ -637,8 +640,6 @@ int __init fadump_reserve_mem(void)

pr_info("Reserved %lldMB of memory at %#016llx (System RAM: %lldMB)\n",
(size >> 20), base, (memblock_phys_mem_size() >> 20));

ret = fadump_cma_init();
}

return ret;
Expand Down
6 changes: 4 additions & 2 deletions arch/powerpc/kernel/setup-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -997,9 +997,11 @@ void __init setup_arch(char **cmdline_p)
initmem_init();

/*
* Reserve large chunks of memory for use by CMA for KVM and hugetlb. These must
* be called after initmem_init(), so that pageblock_order is initialised.
* Reserve large chunks of memory for use by CMA for fadump, KVM and
* hugetlb. These must be called after initmem_init(), so that
* pageblock_order is initialised.
*/
fadump_cma_init();
kvm_cma_reserve();
gigantic_hugetlb_cma_reserve();

Expand Down
Loading

0 comments on commit ad0be02

Please sign in to comment.