[PATCH] powerpc: define the variable 'uaccess_flush' as static
The variable 'uaccess_fulsh' is not referenced outside the file. Perhaps we should define it as static to avoid the warning as follows: arch/powerpc/kernel/setup_64.c:953:6: warning: symbol 'uaccess_flush' was not declared. Should it be static? Reported-by: Hulk Robot Signed-off-by: He Ying --- arch/powerpc/kernel/setup_64.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c index 560ed8b975e7..22aca271496b 100644 --- a/arch/powerpc/kernel/setup_64.c +++ b/arch/powerpc/kernel/setup_64.c @@ -950,7 +950,7 @@ static bool no_entry_flush; static bool no_uaccess_flush; bool rfi_flush; bool entry_flush; -bool uaccess_flush; +static bool uaccess_flush; DEFINE_STATIC_KEY_FALSE(uaccess_flush_key); EXPORT_SYMBOL(uaccess_flush_key); -- 2.17.1
[PATCH] powerpc: Fix missing prototype problems for "arch/powerpc/kernel/setup_64.c"
The variables 'uaccess_fulsh' and 'entry_flush' are not referenced outside the file. So define them as static to avoid the warnings. And add a prototype for the function 'panic_smp_self_stop' for the same purpose. Sparse also warns that 'rfi_flush' should be static. However, it's referenced outside the file. The warnings about the file reported by sparse are as follows: arch/powerpc/kernel/setup_64.c:422:6: warning: symbol 'panic_smp_self_stop' was not declared. Should it be static? arch/powerpc/kernel/setup_64.c:951:6: warning: symbol 'rfi_flush' was not declared. Should it be static? arch/powerpc/kernel/setup_64.c:952:6: warning: symbol 'entry_flush' was not declared. Should it be static? arch/powerpc/kernel/setup_64.c:953:6: warning: symbol 'uaccess_flush' was not declared. Should it be static? Reported-by: Hulk Robot Signed-off-by: He Ying --- arch/powerpc/kernel/setup_64.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c index 560ed8b975e7..603aacd8527b 100644 --- a/arch/powerpc/kernel/setup_64.c +++ b/arch/powerpc/kernel/setup_64.c @@ -71,6 +71,8 @@ #include "setup.h" +extern void panic_smp_self_stop(void); + int spinning_secondaries; u64 ppc64_pft_size; @@ -949,8 +951,8 @@ static bool no_rfi_flush; static bool no_entry_flush; static bool no_uaccess_flush; bool rfi_flush; -bool entry_flush; -bool uaccess_flush; +static bool entry_flush; +static bool uaccess_flush; DEFINE_STATIC_KEY_FALSE(uaccess_flush_key); EXPORT_SYMBOL(uaccess_flush_key); -- 2.17.1
[PATCH] powerpc: arch/powerpc/kernel/setup_64.c - cleanup warnings
warning: symbol 'rfi_flush' was not declared. warning: symbol 'entry_flush' was not declared. warning: symbol 'uaccess_flush' was not declared. We found warnings above in arch/powerpc/kernel/setup_64.c by using sparse tool. Define 'entry_flush' and 'uaccess_flush' as static because they are not referenced outside the file. Include asm/security_features.h in which 'rfi_flush' is declared. Reported-by: Hulk Robot Signed-off-by: He Ying --- arch/powerpc/kernel/setup_64.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c index 560ed8b975e7..f92d72a7e7ce 100644 --- a/arch/powerpc/kernel/setup_64.c +++ b/arch/powerpc/kernel/setup_64.c @@ -68,6 +68,7 @@ #include #include #include +#include #include "setup.h" @@ -949,8 +950,8 @@ static bool no_rfi_flush; static bool no_entry_flush; static bool no_uaccess_flush; bool rfi_flush; -bool entry_flush; -bool uaccess_flush; +static bool entry_flush; +static bool uaccess_flush; DEFINE_STATIC_KEY_FALSE(uaccess_flush_key); EXPORT_SYMBOL(uaccess_flush_key); -- 2.17.1
[PATCH -next] powerpc: kernel/time.c - cleanup warnings
We found these warnings in arch/powerpc/kernel/time.c as follows: warning: symbol 'decrementer_max' was not declared. Should it be static? warning: symbol 'rtc_lock' was not declared. Should it be static? warning: symbol 'dtl_consumer' was not declared. Should it be static? Declare 'decrementer_max' in arch/powerpc/include/asm/time.h. And include proper header in which 'rtc_lock' is declared. Move 'dtl_consumer' definition behind "include " because 'dtl_consumer' is declared there. Reported-by: Hulk Robot Signed-off-by: He Ying --- arch/powerpc/include/asm/time.h | 1 + arch/powerpc/kernel/time.c | 7 +++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/powerpc/include/asm/time.h b/arch/powerpc/include/asm/time.h index 8dd3cdb25338..2cd2b50bedda 100644 --- a/arch/powerpc/include/asm/time.h +++ b/arch/powerpc/include/asm/time.h @@ -22,6 +22,7 @@ extern unsigned long tb_ticks_per_jiffy; extern unsigned long tb_ticks_per_usec; extern unsigned long tb_ticks_per_sec; extern struct clock_event_device decrementer_clockevent; +extern u64 decrementer_max; extern void generic_calibrate_decr(void); diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c index b67d93a609a2..409967713ca6 100644 --- a/arch/powerpc/kernel/time.c +++ b/arch/powerpc/kernel/time.c @@ -55,6 +55,7 @@ #include #include #include +#include #include #include @@ -150,10 +151,6 @@ bool tb_invalid; u64 __cputime_usec_factor; EXPORT_SYMBOL(__cputime_usec_factor); -#ifdef CONFIG_PPC_SPLPAR -void (*dtl_consumer)(struct dtl_entry *, u64); -#endif - static void calc_cputime_factors(void) { struct div_result res; @@ -179,6 +176,8 @@ static inline unsigned long read_spurr(unsigned long tb) #include +void (*dtl_consumer)(struct dtl_entry *, u64); + /* * Scan the dispatch trace log and count up the stolen time. * Should be called with interrupts disabled. -- 2.17.1
[PATCH v2 -next] powerpc: kernel/time.c - cleanup warnings
We found these warnings in arch/powerpc/kernel/time.c as follows: warning: symbol 'decrementer_max' was not declared. Should it be static? warning: symbol 'rtc_lock' was not declared. Should it be static? warning: symbol 'dtl_consumer' was not declared. Should it be static? Declare 'decrementer_max' and 'rtc_lock' in powerpc asm/time.h. Rename 'rtc_lock' in drviers/rtc/rtc-vr41xx.c to 'vr41xx_rtc_lock' to avoid the conflict with the variable in powerpc asm/time.h. Move 'dtl_consumer' definition behind "include " because it is declared there. Reported-by: Hulk Robot Signed-off-by: He Ying --- v2: - Instead of including linux/mc146818rtc.h in powerpc kernel/time.c, declare rtc_lock in powerpc asm/time.h. arch/powerpc/include/asm/time.h | 3 +++ arch/powerpc/kernel/time.c | 6 ++ drivers/rtc/rtc-vr41xx.c| 22 +++--- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/arch/powerpc/include/asm/time.h b/arch/powerpc/include/asm/time.h index 8dd3cdb25338..64a3ef0b4270 100644 --- a/arch/powerpc/include/asm/time.h +++ b/arch/powerpc/include/asm/time.h @@ -12,6 +12,7 @@ #ifdef __KERNEL__ #include #include +#include #include #include @@ -22,6 +23,8 @@ extern unsigned long tb_ticks_per_jiffy; extern unsigned long tb_ticks_per_usec; extern unsigned long tb_ticks_per_sec; extern struct clock_event_device decrementer_clockevent; +extern u64 decrementer_max; +extern spinlock_t rtc_lock; extern void generic_calibrate_decr(void); diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c index b67d93a609a2..60b6ac7d3685 100644 --- a/arch/powerpc/kernel/time.c +++ b/arch/powerpc/kernel/time.c @@ -150,10 +150,6 @@ bool tb_invalid; u64 __cputime_usec_factor; EXPORT_SYMBOL(__cputime_usec_factor); -#ifdef CONFIG_PPC_SPLPAR -void (*dtl_consumer)(struct dtl_entry *, u64); -#endif - static void calc_cputime_factors(void) { struct div_result res; @@ -179,6 +175,8 @@ static inline unsigned long read_spurr(unsigned long tb) #include +void (*dtl_consumer)(struct dtl_entry *, u64); + /* * Scan the dispatch trace log and count up the stolen time. * Should be called with interrupts disabled. diff --git a/drivers/rtc/rtc-vr41xx.c b/drivers/rtc/rtc-vr41xx.c index 5a9f9ad86d32..cc31db058197 100644 --- a/drivers/rtc/rtc-vr41xx.c +++ b/drivers/rtc/rtc-vr41xx.c @@ -72,7 +72,7 @@ static void __iomem *rtc2_base; static unsigned long epoch = 1970; /* Jan 1 1970 00:00:00 */ -static DEFINE_SPINLOCK(rtc_lock); +static DEFINE_SPINLOCK(vr41xx_rtc_lock); static char rtc_name[] = "RTC"; static unsigned long periodic_count; static unsigned int alarm_enabled; @@ -101,13 +101,13 @@ static inline time64_t read_elapsed_second(void) static inline void write_elapsed_second(time64_t sec) { - spin_lock_irq(&rtc_lock); + spin_lock_irq(&vr41xx_rtc_lock); rtc1_write(ETIMELREG, (uint16_t)(sec << 15)); rtc1_write(ETIMEMREG, (uint16_t)(sec >> 1)); rtc1_write(ETIMEHREG, (uint16_t)(sec >> 17)); - spin_unlock_irq(&rtc_lock); + spin_unlock_irq(&vr41xx_rtc_lock); } static int vr41xx_rtc_read_time(struct device *dev, struct rtc_time *time) @@ -139,14 +139,14 @@ static int vr41xx_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *wkalrm) unsigned long low, mid, high; struct rtc_time *time = &wkalrm->time; - spin_lock_irq(&rtc_lock); + spin_lock_irq(&vr41xx_rtc_lock); low = rtc1_read(ECMPLREG); mid = rtc1_read(ECMPMREG); high = rtc1_read(ECMPHREG); wkalrm->enabled = alarm_enabled; - spin_unlock_irq(&rtc_lock); + spin_unlock_irq(&vr41xx_rtc_lock); rtc_time64_to_tm((high << 17) | (mid << 1) | (low >> 15), time); @@ -159,7 +159,7 @@ static int vr41xx_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *wkalrm) alarm_sec = rtc_tm_to_time64(&wkalrm->time); - spin_lock_irq(&rtc_lock); + spin_lock_irq(&vr41xx_rtc_lock); if (alarm_enabled) disable_irq(aie_irq); @@ -173,7 +173,7 @@ static int vr41xx_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *wkalrm) alarm_enabled = wkalrm->enabled; - spin_unlock_irq(&rtc_lock); + spin_unlock_irq(&vr41xx_rtc_lock); return 0; } @@ -202,7 +202,7 @@ static int vr41xx_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long static int vr41xx_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) { - spin_lock_irq(&rtc_lock); + spin_lock_irq(&vr41xx_rtc_lock); if (enabled) { if (!alarm_enabled) { enable_irq(aie_irq); @@ -214,7 +214,7 @@ static int vr41xx_rtc_alarm_irq_enable(struct device *dev, unsigned
[PATCH V3 -next] powerpc: kernel/time.c - cleanup warnings
We found these warnings in arch/powerpc/kernel/time.c as follows: warning: symbol 'decrementer_max' was not declared. Should it be static? warning: symbol 'rtc_lock' was not declared. Should it be static? warning: symbol 'dtl_consumer' was not declared. Should it be static? Declare 'decrementer_max' in powerpc asm/time.h. Include linux/mc146818rtc.h in powerpc kernel/time.c where 'rtc_lock' is declared. And remove duplicated declaration of 'rtc_lock' in powerpc platforms/chrp/time.c because it has included linux/mc146818rtc.h. Move 'dtl_consumer' definition behind "include " because it is declared there. Reported-by: Hulk Robot Signed-off-by: He Ying --- V2: - Instead of including linux/mc146818rtc.h in powerpc kernel/time.c, declare rtc_lock in powerpc asm/time.h. V3: - Recover to V1, that is including linux/mc146818rtc.h in powerpc kernel/time.c. And remove duplicated declaration of 'rtc_lock' in powerpc platforms/chrp/time.c because it has included linux/mc146818rtc.h. arch/powerpc/include/asm/time.h| 1 + arch/powerpc/kernel/time.c | 9 - arch/powerpc/platforms/chrp/time.c | 2 -- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/arch/powerpc/include/asm/time.h b/arch/powerpc/include/asm/time.h index 8dd3cdb25338..2cd2b50bedda 100644 --- a/arch/powerpc/include/asm/time.h +++ b/arch/powerpc/include/asm/time.h @@ -22,6 +22,7 @@ extern unsigned long tb_ticks_per_jiffy; extern unsigned long tb_ticks_per_usec; extern unsigned long tb_ticks_per_sec; extern struct clock_event_device decrementer_clockevent; +extern u64 decrementer_max; extern void generic_calibrate_decr(void); diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c index b67d93a609a2..ac81f043bf49 100644 --- a/arch/powerpc/kernel/time.c +++ b/arch/powerpc/kernel/time.c @@ -55,8 +55,9 @@ #include #include #include -#include +#include +#include #include #include #include @@ -150,10 +151,6 @@ bool tb_invalid; u64 __cputime_usec_factor; EXPORT_SYMBOL(__cputime_usec_factor); -#ifdef CONFIG_PPC_SPLPAR -void (*dtl_consumer)(struct dtl_entry *, u64); -#endif - static void calc_cputime_factors(void) { struct div_result res; @@ -179,6 +176,8 @@ static inline unsigned long read_spurr(unsigned long tb) #include +void (*dtl_consumer)(struct dtl_entry *, u64); + /* * Scan the dispatch trace log and count up the stolen time. * Should be called with interrupts disabled. diff --git a/arch/powerpc/platforms/chrp/time.c b/arch/powerpc/platforms/chrp/time.c index acde7bbe0716..b94dfd5090d8 100644 --- a/arch/powerpc/platforms/chrp/time.c +++ b/arch/powerpc/platforms/chrp/time.c @@ -30,8 +30,6 @@ #include -extern spinlock_t rtc_lock; - #define NVRAM_AS0 0x74 #define NVRAM_AS1 0x75 #define NVRAM_DATA 0x77 -- 2.17.1
[PATCH] docs: powerpc: Fix misspellings and grammar errors
Reported-by: Hulk Robot Signed-off-by: He Ying --- Documentation/powerpc/booting.rst| 2 +- Documentation/powerpc/dawr-power9.rst| 2 +- Documentation/powerpc/eeh-pci-error-recovery.rst | 2 +- Documentation/powerpc/elfnote.rst| 2 +- Documentation/powerpc/firmware-assisted-dump.rst | 2 +- Documentation/powerpc/kaslr-booke32.rst | 2 +- Documentation/powerpc/mpc52xx.rst| 2 +- Documentation/powerpc/papr_hcalls.rst| 4 ++-- Documentation/powerpc/transactional_memory.rst | 4 ++-- 9 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Documentation/powerpc/booting.rst b/Documentation/powerpc/booting.rst index 2d0ec2ff2b57..11aa440f98cc 100644 --- a/Documentation/powerpc/booting.rst +++ b/Documentation/powerpc/booting.rst @@ -94,7 +94,7 @@ should: a) add your platform support as a _boolean_ option in arch/powerpc/Kconfig, following the example of PPC_PSERIES, -PPC_PMAC and PPC_MAPLE. The later is probably a good +PPC_PMAC and PPC_MAPLE. The latter is probably a good example of a board support to start from. b) create your main platform file as diff --git a/Documentation/powerpc/dawr-power9.rst b/Documentation/powerpc/dawr-power9.rst index c96ab6befd9c..e55ac6a24b97 100644 --- a/Documentation/powerpc/dawr-power9.rst +++ b/Documentation/powerpc/dawr-power9.rst @@ -4,7 +4,7 @@ DAWR issues on POWER9 On POWER9 the Data Address Watchpoint Register (DAWR) can cause a checkstop if it points to cache inhibited (CI) memory. Currently Linux has no way to -disinguish CI memory when configuring the DAWR, so (for now) the DAWR is +distinguish CI memory when configuring the DAWR, so (for now) the DAWR is disabled by this commit:: commit 9654153158d3e0684a1bdb76dbababdb7111d5a0 diff --git a/Documentation/powerpc/eeh-pci-error-recovery.rst b/Documentation/powerpc/eeh-pci-error-recovery.rst index 438a87ebc095..d6643a91bdf8 100644 --- a/Documentation/powerpc/eeh-pci-error-recovery.rst +++ b/Documentation/powerpc/eeh-pci-error-recovery.rst @@ -73,7 +73,7 @@ return all-ff's (0xff, 0x, 0x for 8/16/32-bit reads). This value was chosen because it is the same value you would get if the device was physically unplugged from the slot. This includes access to PCI memory, I/O space, and PCI config -space. Interrupts; however, will continued to be delivered. +space. Interrupts; however, will continue to be delivered. Detection and recovery are performed with the aid of ppc64 firmware. The programming interfaces in the Linux kernel diff --git a/Documentation/powerpc/elfnote.rst b/Documentation/powerpc/elfnote.rst index 06602248621c..3ec8d61e9a33 100644 --- a/Documentation/powerpc/elfnote.rst +++ b/Documentation/powerpc/elfnote.rst @@ -8,7 +8,7 @@ capabilities and information which can be used by a bootloader or userland. Types and Descriptors - -The types to be used with the "PowerPC" namesapce are defined in [#f1]_. +The types to be used with the "PowerPC" namespace are defined in [#f1]_. 1) PPC_ELFNOTE_CAPABILITIES diff --git a/Documentation/powerpc/firmware-assisted-dump.rst b/Documentation/powerpc/firmware-assisted-dump.rst index 6c0ae070ba67..e363fc48529a 100644 --- a/Documentation/powerpc/firmware-assisted-dump.rst +++ b/Documentation/powerpc/firmware-assisted-dump.rst @@ -207,7 +207,7 @@ Currently the dump will be copied from /proc/vmcore to a new file upon user intervention. The dump data available through /proc/vmcore will be in ELF format. Hence the existing kdump infrastructure (kdump scripts) to save the dump works fine with minor modifications. KDump scripts on -major Distro releases have already been modified to work seemlessly (no +major Distro releases have already been modified to work seamlessly (no user intervention in saving the dump) when FADump is used, instead of KDump, as dump mechanism. diff --git a/Documentation/powerpc/kaslr-booke32.rst b/Documentation/powerpc/kaslr-booke32.rst index 8b259fdfdf03..5681c1d1b65b 100644 --- a/Documentation/powerpc/kaslr-booke32.rst +++ b/Documentation/powerpc/kaslr-booke32.rst @@ -38,5 +38,5 @@ bit of the entropy to decide the index of the 64M zone. Then we chose a kernstart_virt_addr -To enable KASLR, set CONFIG_RANDOMIZE_BASE = y. If KASLR is enable and you +To enable KASLR, set CONFIG_RANDOMIZE_BASE = y. If KASLR is enabled and you want to disable it at runtime, add "nokaslr" to the kernel cmdline. diff --git a/Documentation/powerpc/mpc52xx.rst b/Documentation/powerpc/mpc52xx.rst index 30260707c3fe..5243b1763fad 100644 --- a/Documentation/powerpc/mpc52xx.rst +++ b/Documentation/powerpc/mpc52xx.rst @@ -34,7 +34,7 @@ To compile/use : Some remarks: - The port is named mpc52xxx, and config options are PPC_MPC52xx. The MGT5100 - is not supported, and I'm not sur
[PATCH] powerpc: Fix kernel-jump address for ppc64 wrapper boot
>From "64-bit PowerPC ELF Application Binary Interface Supplement 1.9", we know that the value of a function pointer in a language like C is the address of the function descriptor and the first doubleword of the function descriptor contains the address of the entry point of the function. So, when we want to jump to an address (e.g. addr) to execute for PPC-elf64abi, we should assign the address of addr *NOT* addr itself to the function pointer or system will jump to the wrong address. Link: https://refspecs.linuxfoundation.org/ELF/ppc64/PPC-elf64abi.html#FUNC-DES Signed-off-by: He Ying --- arch/powerpc/boot/main.c | 9 + 1 file changed, 9 insertions(+) diff --git a/arch/powerpc/boot/main.c b/arch/powerpc/boot/main.c index cae31a6e8f02..50fd7f11b642 100644 --- a/arch/powerpc/boot/main.c +++ b/arch/powerpc/boot/main.c @@ -268,7 +268,16 @@ void start(void) if (console_ops.close) console_ops.close(); +#ifdef CONFIG_PPC64_BOOT_WRAPPER + /* +* For PPC-elf64abi, the value of a function pointer is the address +* of the function descriptor. And the first doubleword of a function +* descriptor contains the address of the entry point of the function. +*/ + kentry = (kernel_entry_t) &vmlinux.addr; +#else kentry = (kernel_entry_t) vmlinux.addr; +#endif if (ft_addr) { if(platform_ops.kentry) platform_ops.kentry(ft_addr, vmlinux.addr); -- 2.17.1
Re: [PATCH] powerpc: Fix kernel-jump address for ppc64 wrapper boot
Hello, 在 2021/6/8 13:26, Oliver O'Halloran 写道: On Fri, Jun 4, 2021 at 7:39 PM He Ying wrote: From "64-bit PowerPC ELF Application Binary Interface Supplement 1.9", we know that the value of a function pointer in a language like C is the address of the function descriptor and the first doubleword of the function descriptor contains the address of the entry point of the function. So, when we want to jump to an address (e.g. addr) to execute for PPC-elf64abi, we should assign the address of addr *NOT* addr itself to the function pointer or system will jump to the wrong address. How have you tested this? I tested ppc64-elf big-endian. I changed the Kconfig so that ppc64 big-endian selects PPC64_WRAPPER_BOOT. I used qemu to run the cuImage and found the problem. It made me confused. By applying this patch, I found it works. I thought it works for ppc64le too. So I upstream this patch. IIRC the 64bit wrapper is only used for ppc64le builds. For that case the current code is work because the LE ABI (ABIv2) doesn't use function descriptors. I think even for a BE kernel we need the current behaviour because the vmlinux's entry point is screwed up (i.e. doesn't point a descriptor) and tools in the wild (probably kexec) expect it to be screwed up. Yes, you're right. PPC64_WRAPPER_BOOT is only used for ppc64le builds currently. LE ABI (ABI v2) doesn't use function descriptors. Is that right? I don't test that. If so, this patch should be dropped. But why does ppc64 have different ABIs? So strange. If the wrapper is built to ppc64be, my patch is tested right. The entry point in the ELF header is always right so you can assign the header->e_entry to the function pointer and then jump to the entry by calling the function. But in the ppc wrapper, the address is intialized to 0 or malloced to be an address later. In this situation, I think my patch should be right for ppc64be. ABIv2 (LE) reference: https://openpowerfoundation.org/?resource_lib=64-bit-elf-v2-abi-specification-power-architecture .
Re: [PATCH] powerpc: Fix kernel-jump address for ppc64 wrapper boot
Hello, 在 2021/6/8 12:55, Christophe Leroy 写道: Le 04/06/2021 à 11:22, He Ying a écrit : From "64-bit PowerPC ELF Application Binary Interface Supplement 1.9", we know that the value of a function pointer in a language like C is the address of the function descriptor and the first doubleword of the function descriptor contains the address of the entry point of the function. So, when we want to jump to an address (e.g. addr) to execute for PPC-elf64abi, we should assign the address of addr *NOT* addr itself to the function pointer or system will jump to the wrong address. Link: https://refspecs.linuxfoundation.org/ELF/ppc64/PPC-elf64abi.html#FUNC-DES Signed-off-by: He Ying --- arch/powerpc/boot/main.c | 9 + 1 file changed, 9 insertions(+) diff --git a/arch/powerpc/boot/main.c b/arch/powerpc/boot/main.c index cae31a6e8f02..50fd7f11b642 100644 --- a/arch/powerpc/boot/main.c +++ b/arch/powerpc/boot/main.c @@ -268,7 +268,16 @@ void start(void) if (console_ops.close) console_ops.close(); +#ifdef CONFIG_PPC64_BOOT_WRAPPER This kind of need doesn't desserve a #ifdef, see https://www.kernel.org/doc/html/latest/process/coding-style.html#conditional-compilation You can do: kentry = (kernel_entry_t)(IS_ENABLED(CONFIG_PPC64_BOOT_WRAPPER) ? &vmlinux.addr : vmlinux.addr); Or, if you prefer something less compact: if (IS_ENABLED(CONFIG_PPC64_BOOT_WRAPPER)) kentry = (kernel_entry_t) &vmlinux.addr; else kentry = (kernel_entry_t) vmlinux.addr; Thanks for reviewing. But from Oliver's reply, this patch should be dropped. Because all ppc platforms will not build wrapper to ppc64be ELF currently. And ppc64le uses LE ABI (ABIv2) which doesn't use function descriptors. So this may not be a problem for now. Thanks again. + /* + * For PPC-elf64abi, the value of a function pointer is the address + * of the function descriptor. And the first doubleword of a function + * descriptor contains the address of the entry point of the function. + */ + kentry = (kernel_entry_t) &vmlinux.addr; +#else kentry = (kernel_entry_t) vmlinux.addr; +#endif if (ft_addr) { if(platform_ops.kentry) platform_ops.kentry(ft_addr, vmlinux.addr); .
[PATCH] powerpc/44x/fsp2: Add missing of_node_put in node_irq_request
Early exits from for_each_compatible_node() should decrement the node reference counter. Signed-off-by: He Ying --- arch/powerpc/platforms/44x/fsp2.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/powerpc/platforms/44x/fsp2.c b/arch/powerpc/platforms/44x/fsp2.c index b299e43f5ef9..823397c802de 100644 --- a/arch/powerpc/platforms/44x/fsp2.c +++ b/arch/powerpc/platforms/44x/fsp2.c @@ -208,6 +208,7 @@ static void node_irq_request(const char *compat, irq_handler_t errirq_handler) if (irq == NO_IRQ) { pr_err("device tree node %pOFn is missing a interrupt", np); + of_node_put(np); return; } @@ -215,6 +216,7 @@ static void node_irq_request(const char *compat, irq_handler_t errirq_handler) if (rc) { pr_err("fsp_of_probe: request_irq failed: np=%pOF rc=%d", np, rc); + of_node_put(np); return; } } -- 2.17.1
[PATCH] powerpc: Fix reference leak of node np in opal_lpc_init
When breaking from for_each_compatible_node body, we increase the reference of node np. Then calling isa_bridge_init_non_pci() will assign np to isa_bridge_devnode. It looks good. However, other error paths in the code should put the node np back to avoid the reference leak. Fix the problem by adding missing of_node_put(). Signed-off-by: He Ying --- arch/powerpc/kernel/isa-bridge.c | 10 +- arch/powerpc/platforms/powernv/opal-lpc.c | 6 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/kernel/isa-bridge.c b/arch/powerpc/kernel/isa-bridge.c index 39c625737c09..bcf1d6024f9e 100644 --- a/arch/powerpc/kernel/isa-bridge.c +++ b/arch/powerpc/kernel/isa-bridge.c @@ -192,14 +192,17 @@ void __init isa_bridge_init_non_pci(struct device_node *np) u64 cbase, pbase, size = 0; /* If we already have an ISA bridge, bail off */ - if (isa_bridge_devnode != NULL) + if (isa_bridge_devnode != NULL) { + of_node_put(np); return; + } pna = of_n_addr_cells(np); if (of_property_read_u32(np, "#address-cells", &na) || of_property_read_u32(np, "#size-cells", &ns)) { pr_warn("ISA: Non-PCI bridge %pOF is missing address format\n", np); + of_node_put(np); return; } @@ -207,6 +210,7 @@ void __init isa_bridge_init_non_pci(struct device_node *np) if (na != 2 || ns != 1) { pr_warn("ISA: Non-PCI bridge %pOF has unsupported address format\n", np); + of_node_put(np); return; } rs = na + ns + pna; @@ -216,6 +220,7 @@ void __init isa_bridge_init_non_pci(struct device_node *np) if (ranges == NULL || rlen < rs) { pr_warn("ISA: Non-PCI bridge %pOF has absent or invalid ranges\n", np); + of_node_put(np); return; } @@ -233,6 +238,7 @@ void __init isa_bridge_init_non_pci(struct device_node *np) if (!size || !pbasep) { pr_warn("ISA: Non-PCI bridge %pOF has no usable IO range\n", np); + of_node_put(np); return; } @@ -246,6 +252,7 @@ void __init isa_bridge_init_non_pci(struct device_node *np) if (pbase == OF_BAD_ADDR) { pr_warn("ISA: Non-PCI bridge %pOF failed to translate IO base\n", np); + of_node_put(np); return; } @@ -253,6 +260,7 @@ void __init isa_bridge_init_non_pci(struct device_node *np) if ((cbase & ~PAGE_MASK) || (pbase & ~PAGE_MASK)) { pr_warn("ISA: Non-PCI bridge %pOF has non aligned IO range\n", np); + of_node_put(np); return; } diff --git a/arch/powerpc/platforms/powernv/opal-lpc.c b/arch/powerpc/platforms/powernv/opal-lpc.c index 1e5d51db40f8..5647752b2d6a 100644 --- a/arch/powerpc/platforms/powernv/opal-lpc.c +++ b/arch/powerpc/platforms/powernv/opal-lpc.c @@ -398,8 +398,11 @@ void __init opal_lpc_init(void) opal_lpc_chip_id = of_get_ibm_chip_id(np); break; } - if (opal_lpc_chip_id < 0) + if (opal_lpc_chip_id < 0) { + if (np) + of_node_put(np); return; + } /* Does it support direct mapping ? */ if (of_get_property(np, "ranges", NULL)) { @@ -407,6 +410,7 @@ void __init opal_lpc_init(void) opal_lpc_chip_id); isa_bridge_init_non_pci(np); } else { + of_node_put(np); pr_info("OPAL: Found non-mapped LPC bus on chip %d\n", opal_lpc_chip_id); -- 2.17.1
[PATCH] powerpc/sysdev/of_rtc: Fix possible memory leak in of_instantiate_rtc
If of_address_to_resource() in of_instantiate_rtc() fails, previously allocated memory res is not freed. Add missing kfree() for it. Signed-off-by: He Ying --- arch/powerpc/sysdev/of_rtc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/powerpc/sysdev/of_rtc.c b/arch/powerpc/sysdev/of_rtc.c index 1f408d34a6a7..23b896996c2f 100644 --- a/arch/powerpc/sysdev/of_rtc.c +++ b/arch/powerpc/sysdev/of_rtc.c @@ -44,6 +44,7 @@ void __init of_instantiate_rtc(void) printk(KERN_ERR "OF RTC: Error " "translating resources for %pOF\n", node); + kfree(res); continue; } -- 2.17.1
[PATCH] powerpc/embedded6xx/hlwd-pic: Add missing of_node_put in hlwd_pic_probe
Early exits from for_each_compatible_node() should decrease the node reference count. Signed-off-by: He Ying --- arch/powerpc/platforms/embedded6xx/hlwd-pic.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/powerpc/platforms/embedded6xx/hlwd-pic.c b/arch/powerpc/platforms/embedded6xx/hlwd-pic.c index 15396333a90b..a4b020e4b6af 100644 --- a/arch/powerpc/platforms/embedded6xx/hlwd-pic.c +++ b/arch/powerpc/platforms/embedded6xx/hlwd-pic.c @@ -214,6 +214,7 @@ void hlwd_pic_probe(void) irq_set_chained_handler(cascade_virq, hlwd_pic_irq_cascade); hlwd_irq_host = host; + of_node_put(np); break; } } -- 2.17.1
Re: [PATCH] powerpc/embedded6xx/hlwd-pic: Add missing of_node_put in hlwd_pic_probe
kindly ping... 在 2021/11/3 9:48, He Ying 写道: Early exits from for_each_compatible_node() should decrease the node reference count. Signed-off-by: He Ying --- arch/powerpc/platforms/embedded6xx/hlwd-pic.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/powerpc/platforms/embedded6xx/hlwd-pic.c b/arch/powerpc/platforms/embedded6xx/hlwd-pic.c index 15396333a90b..a4b020e4b6af 100644 --- a/arch/powerpc/platforms/embedded6xx/hlwd-pic.c +++ b/arch/powerpc/platforms/embedded6xx/hlwd-pic.c @@ -214,6 +214,7 @@ void hlwd_pic_probe(void) irq_set_chained_handler(cascade_virq, hlwd_pic_irq_cascade); hlwd_irq_host = host; + of_node_put(np); break; } }