From 6074c33c6b2eabc70867ef76d57ca256e9ea9da7 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 21 May 2019 15:20:39 +0900 Subject: MIPS: mark ginvt() as __always_inline To meet the 'i' (immediate) constraint for the asm operands, this function must be always inlined. Signed-off-by: Masahiro Yamada Signed-off-by: Paul Burton Cc: linux-mips@vger.kernel.org Cc: Ralf Baechle Cc: James Hogan Cc: linux-kernel@vger.kernel.org --- arch/mips/include/asm/ginvt.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'arch') diff --git a/arch/mips/include/asm/ginvt.h b/arch/mips/include/asm/ginvt.h index 49c6dbe37338..6eb7c2b94dc7 100644 --- a/arch/mips/include/asm/ginvt.h +++ b/arch/mips/include/asm/ginvt.h @@ -19,7 +19,7 @@ _ASM_MACRO_1R1I(ginvt, rs, type, # define _ASM_SET_GINV #endif -static inline void ginvt(unsigned long addr, enum ginvt_type type) +static __always_inline void ginvt(unsigned long addr, enum ginvt_type type) { asm volatile( ".set push\n" -- cgit v1.2.3-59-g8ed1b From 3dd0aade5911d21abb35fbd4f71c3f52c25891d1 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 21 May 2019 13:03:27 +0900 Subject: MIPS: remove a space after -I to cope with header search paths for VDSO Commit 9cc342f6c4a0 ("treewide: prefix header search paths with $(srctree)/") caused a build error for MIPS VDSO. CC arch/mips/vdso/gettimeofday.o In file included from ../arch/mips/vdso/vdso.h:26, from ../arch/mips/vdso/gettimeofday.c:11: ../arch/mips/include/asm/page.h:12:10: fatal error: spaces.h: No such file or directory #include ^~~~~~~~~~ The cause of the error is a missing space after the compiler flag -I . Kbuild used to have a global restriction "no space after -I", but commit 48f6e3cf5bc6 ("kbuild: do not drop -I without parameter") got rid of it. Having a space after -I is no longer a big deal as far as Kbuild is concerned. It is still a big deal for MIPS because arch/mips/vdso/Makefile filters the header search paths, like this: ccflags-vdso := \ $(filter -I%,$(KBUILD_CFLAGS)) \ ..., which relies on the assumption that there is no space after -I . Fixes: 9cc342f6c4a0 ("treewide: prefix header search paths with $(srctree)/") Reported-by: kbuild test robot Signed-off-by: Masahiro Yamada Signed-off-by: Paul Burton Cc: Ralf Baechle Cc: James Hogan Cc: linux-mips@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- arch/mips/pnx833x/Platform | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'arch') diff --git a/arch/mips/pnx833x/Platform b/arch/mips/pnx833x/Platform index 6b1a847d593f..287260669551 100644 --- a/arch/mips/pnx833x/Platform +++ b/arch/mips/pnx833x/Platform @@ -1,5 +1,5 @@ # NXP STB225 platform-$(CONFIG_SOC_PNX833X) += pnx833x/ -cflags-$(CONFIG_SOC_PNX833X) += -I $(srctree)/arch/mips/include/asm/mach-pnx833x +cflags-$(CONFIG_SOC_PNX833X) += -I$(srctree)/arch/mips/include/asm/mach-pnx833x load-$(CONFIG_NXP_STB220) += 0xffffffff80001000 load-$(CONFIG_NXP_STB225) += 0xffffffff80001000 -- cgit v1.2.3-59-g8ed1b From c5eac1f5326b0b67e50ad5d560d7e68e6c95ef14 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Wed, 22 May 2019 10:15:35 +0200 Subject: MIPS: TXx9: Fix boot crash in free_initmem() On rbtx4927: BUG: Bad page state in process swapper pfn:00001 page:804b7820 refcount:0 mapcount:-128 mapping:00000000 index:0x1 flags: 0x0() raw: 00000000 00000100 00000200 00000000 00000001 00000000 ffffff7f 00000000 page dumped because: nonzero mapcount Modules linked in: CPU: 0 PID: 1 Comm: swapper Not tainted 5.2.0-rc1-rbtx4927-00468-g3c05ea3d4077b756 #141 Stack : 00000000 10008400 8040dc4c 87c1b974 8044af63 8040dc4c 00000001 804a3490 00000001 81000000 0030f231 80148558 00000003 10008400 87c1dd80 3d0f9a2c 00000000 00000000 804b0000 00000000 00000007 00000000 00000081 00000000 62722d31 00000080 804b0000 39347874 00000000 804b7820 8040ce18 81000010 00000001 00000007 00000001 81000000 00000018 8021de24 00000000 804a0000 ... Call Trace: [<8010adec>] show_stack+0x74/0x104 [<801a5e44>] bad_page+0x130/0x138 [<801a654c>] free_pcppages_bulk+0x17c/0x3b0 [<801a789c>] free_unref_page+0x40/0x68 [<801120f4>] free_init_pages+0xec/0x104 [<803bdde8>] free_initmem+0x10/0x58 [<803bdb8c>] kernel_init+0x20/0x100 [<801057c8>] ret_from_kernel_thread+0x14/0x1c As of commit b93ddc4f9156205e ("mips: Reserve memory for the kernel image resources"), bootmem_init() no longer reserves the memory below the kernel, while prom_free_prom_memory() still frees it. Fix this by reverting commit b6263ff2d6e58cc2 ("MIPS: TXx9: Implement prom_free_prom_memory"). Suggested-by: Serge Semin Fixes: b93ddc4f9156205e ("mips: Reserve memory for the kernel image resources") Signed-off-by: Geert Uytterhoeven Reviewed-by: Atsushi Nemoto Signed-off-by: Paul Burton Cc: Ralf Baechle Cc: James Hogan Cc: Mike Rapoport Cc: Maciej W . Rozycki Cc: linux-mips@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- arch/mips/txx9/generic/setup.c | 6 ------ 1 file changed, 6 deletions(-) (limited to 'arch') diff --git a/arch/mips/txx9/generic/setup.c b/arch/mips/txx9/generic/setup.c index 46537c2ca86a..6d0fd0e055b4 100644 --- a/arch/mips/txx9/generic/setup.c +++ b/arch/mips/txx9/generic/setup.c @@ -33,7 +33,6 @@ #include #include #include -#include #include #include #include @@ -343,11 +342,6 @@ void __init prom_init(void) void __init prom_free_prom_memory(void) { - unsigned long saddr = PAGE_SIZE; - unsigned long eaddr = __pa_symbol(&_text); - - if (saddr < eaddr) - free_init_pages("prom memory", saddr, eaddr); } const char *get_system_type(void) -- cgit v1.2.3-59-g8ed1b From 074a1e1167afd82c26f6d03a9a8b997d564bb241 Mon Sep 17 00:00:00 2001 From: Paul Burton Date: Tue, 28 May 2019 17:05:03 +0000 Subject: MIPS: Bounds check virt_addr_valid MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The virt_addr_valid() function is meant to return true iff virt_to_page() will return a valid struct page reference. This is true iff the address provided is found within the unmapped address range between PAGE_OFFSET & MAP_BASE, but we don't currently check for that condition. Instead we simply mask the address to obtain what will be a physical address if the virtual address is indeed in the desired range, shift it to form a PFN & then call pfn_valid(). This can incorrectly return true if called with a virtual address which, after masking, happens to form a physical address corresponding to a valid PFN. For example we may vmalloc an address in the kernel mapped region starting a MAP_BASE & obtain the virtual address: addr = 0xc000000000002000 When masked by virt_to_phys(), which uses __pa() & in turn CPHYSADDR(), we obtain the following (bogus) physical address: addr = 0x2000 In a common system with PHYS_OFFSET=0 this will correspond to a valid struct page which should really be accessed by virtual address PAGE_OFFSET+0x2000, causing virt_addr_valid() to incorrectly return 1 indicating that the original address corresponds to a struct page. This is equivalent to the ARM64 change made in commit ca219452c6b8 ("arm64: Correctly bounds check virt_addr_valid"). This fixes fallout when hardened usercopy is enabled caused by the related commit 517e1fbeb65f ("mm/usercopy: Drop extra is_vmalloc_or_module() check") which removed a check for the vmalloc range that was present from the introduction of the hardened usercopy feature. Signed-off-by: Paul Burton References: ca219452c6b8 ("arm64: Correctly bounds check virt_addr_valid") References: 517e1fbeb65f ("mm/usercopy: Drop extra is_vmalloc_or_module() check") Reported-by: Julien Cristau Reviewed-by: Philippe Mathieu-Daudé Tested-by: YunQiang Su URL: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=929366 Cc: stable@vger.kernel.org # v4.12+ Cc: linux-mips@vger.kernel.org Cc: Yunqiang Su --- arch/mips/mm/mmap.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'arch') diff --git a/arch/mips/mm/mmap.c b/arch/mips/mm/mmap.c index 2f616ebeb7e0..7755a1fad05a 100644 --- a/arch/mips/mm/mmap.c +++ b/arch/mips/mm/mmap.c @@ -203,6 +203,11 @@ unsigned long arch_randomize_brk(struct mm_struct *mm) int __virt_addr_valid(const volatile void *kaddr) { + unsigned long vaddr = (unsigned long)vaddr; + + if ((vaddr < PAGE_OFFSET) || (vaddr >= MAP_BASE)) + return 0; + return pfn_valid(PFN_DOWN(virt_to_phys(kaddr))); } EXPORT_SYMBOL_GPL(__virt_addr_valid); -- cgit v1.2.3-59-g8ed1b From 31875a5432248e7b0fff2f4f4e8cd96e5d82ceb0 Mon Sep 17 00:00:00 2001 From: Paul Burton Date: Tue, 28 May 2019 17:05:04 +0000 Subject: MIPS: Make virt_addr_valid() return bool MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit virt_addr_valid() really returns a boolean value, but currently uses an integer to represent it. Switch to the bool type to make it clearer that we really are returning a true or false value. Signed-off-by: Paul Burton Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé Cc: linux-mips@vger.kernel.org --- arch/mips/include/asm/page.h | 2 +- arch/mips/mm/mmap.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'arch') diff --git a/arch/mips/include/asm/page.h b/arch/mips/include/asm/page.h index 6b31c93b5eaa..a25643d258cb 100644 --- a/arch/mips/include/asm/page.h +++ b/arch/mips/include/asm/page.h @@ -249,7 +249,7 @@ static inline int pfn_valid(unsigned long pfn) #define virt_to_pfn(kaddr) PFN_DOWN(virt_to_phys((void *)(kaddr))) #define virt_to_page(kaddr) pfn_to_page(virt_to_pfn(kaddr)) -extern int __virt_addr_valid(const volatile void *kaddr); +extern bool __virt_addr_valid(const volatile void *kaddr); #define virt_addr_valid(kaddr) \ __virt_addr_valid((const volatile void *) (kaddr)) diff --git a/arch/mips/mm/mmap.c b/arch/mips/mm/mmap.c index 7755a1fad05a..50ee7213b432 100644 --- a/arch/mips/mm/mmap.c +++ b/arch/mips/mm/mmap.c @@ -201,12 +201,12 @@ unsigned long arch_randomize_brk(struct mm_struct *mm) return ret; } -int __virt_addr_valid(const volatile void *kaddr) +bool __virt_addr_valid(const volatile void *kaddr) { unsigned long vaddr = (unsigned long)vaddr; if ((vaddr < PAGE_OFFSET) || (vaddr >= MAP_BASE)) - return 0; + return false; return pfn_valid(PFN_DOWN(virt_to_phys(kaddr))); } -- cgit v1.2.3-59-g8ed1b From e4f2d1af7163becb181419af9dece9206001e0a6 Mon Sep 17 00:00:00 2001 From: Paul Burton Date: Tue, 28 May 2019 17:21:26 +0000 Subject: MIPS: pistachio: Build uImage.gz by default MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The pistachio platform uses the U-Boot bootloader & generally boots a kernel in the uImage format. As such it's useful to build one when building the kernel, but to do so currently requires the user to manually specify a uImage target on the make command line. Make uImage.gz the pistachio platform's default build target, so that the default is to build a kernel image that we can actually boot on a board such as the MIPS Creator Ci40. Marked for stable backport as far as v4.1 where pistachio support was introduced. This is primarily useful for CI systems such as kernelci.org which will benefit from us building a suitable image which can then be booted as part of automated testing, extending our test coverage to the affected stable branches. Signed-off-by: Paul Burton Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Kevin Hilman Tested-by: Kevin Hilman URL: https://groups.io/g/kernelci/message/388 Cc: stable@vger.kernel.org # v4.1+ Cc: linux-mips@vger.kernel.org --- arch/mips/pistachio/Platform | 1 + 1 file changed, 1 insertion(+) (limited to 'arch') diff --git a/arch/mips/pistachio/Platform b/arch/mips/pistachio/Platform index d80cd612df1f..c3592b374ad2 100644 --- a/arch/mips/pistachio/Platform +++ b/arch/mips/pistachio/Platform @@ -6,3 +6,4 @@ cflags-$(CONFIG_MACH_PISTACHIO) += \ -I$(srctree)/arch/mips/include/asm/mach-pistachio load-$(CONFIG_MACH_PISTACHIO) += 0xffffffff80400000 zload-$(CONFIG_MACH_PISTACHIO) += 0xffffffff81000000 +all-$(CONFIG_MACH_PISTACHIO) := uImage.gz -- cgit v1.2.3-59-g8ed1b From f532beeeff0c0a3586cc15538bc52d249eb19e7c Mon Sep 17 00:00:00 2001 From: YueHaibing Date: Sat, 25 May 2019 20:20:24 +0800 Subject: MIPS: uprobes: remove set but not used variable 'epc' Fixes gcc '-Wunused-but-set-variable' warning: arch/mips/kernel/uprobes.c: In function 'arch_uprobe_pre_xol': arch/mips/kernel/uprobes.c:115:17: warning: variable 'epc' set but not used [-Wunused-but-set-variable] It's never used since introduction in commit 40e084a506eb ("MIPS: Add uprobes support.") Signed-off-by: YueHaibing Signed-off-by: Paul Burton Cc: Cc: Cc: Cc: --- arch/mips/kernel/uprobes.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'arch') diff --git a/arch/mips/kernel/uprobes.c b/arch/mips/kernel/uprobes.c index 4aaff3b3175c..6dbe4eab0a0e 100644 --- a/arch/mips/kernel/uprobes.c +++ b/arch/mips/kernel/uprobes.c @@ -112,9 +112,6 @@ int arch_uprobe_pre_xol(struct arch_uprobe *aup, struct pt_regs *regs) */ aup->resume_epc = regs->cp0_epc + 4; if (insn_has_delay_slot((union mips_instruction) aup->insn[0])) { - unsigned long epc; - - epc = regs->cp0_epc; __compute_return_epc_for_insn(regs, (union mips_instruction) aup->insn[0]); aup->resume_epc = regs->cp0_epc; -- cgit v1.2.3-59-g8ed1b