[PATCH V3 17/17] KVM: compat: riscv: Prevent KVM_COMPAT from being selected

2022-01-19 Thread guoren
From: Guo Ren Current riscv doesn't support the 32bit KVM/arm API. Let's make it clear by not selecting KVM_COMPAT. Signed-off-by: Guo Ren --- virt/kvm/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virt/kvm/Kconfig b/virt/kvm/Kconfig index f4834c20e4a6..a8c5c9f06b

[PATCH V3 16/17] riscv: compat: Add COMPAT Kbuild skeletal support

2022-01-19 Thread guoren
From: Guo Ren Adds initial skeletal COMPAT Kbuild (Runing 32bit U-mode on 64bit S-mode) support. - Setup kconfig & dummy functions for compiling. - Implement compat_start_thread by the way. Signed-off-by: Guo Ren Signed-off-by: Guo Ren Cc: Arnd Bergmann --- arch/riscv/Kconfig | 19

[PATCH V3 15/17] riscv: compat: Add UXL_32 support in start_thread

2022-01-19 Thread guoren
From: Guo Ren If the current task is in COMPAT mode, set SR_UXL_32 in status for returning userspace. Signed-off-by: Guo Ren Signed-off-by: Guo Ren Cc: Arnd Bergmann --- arch/riscv/kernel/process.c | 5 + 1 file changed, 5 insertions(+) diff --git a/arch/riscv/kernel/process.c b/arch/ri

[PATCH V3 14/17] riscv: compat: ptrace: Add compat_arch_ptrace implement

2022-01-19 Thread guoren
From: Guo Ren Now, you can use native gdb on riscv64 for rv32 app debugging. $ uname -a Linux buildroot 5.16.0-rc4-00036-gbef6b82fdf23-dirty #53 SMP Mon Dec 20 23:06:53 CST 2021 riscv64 GNU/Linux $ cat /proc/cpuinfo processor : 0 hart: 0 isa : rv64imafdcsuh mmu

[PATCH V3 13/17] riscv: compat: signal: Add rt_frame implementation

2022-01-19 Thread guoren
From: Guo Ren Implement compat_setup_rt_frame for sigcontext save & restore. The main process is the same with signal, but the rv32 pt_regs' size is different from rv64's, so we needs convert them. Signed-off-by: Guo Ren Signed-off-by: Guo Ren Cc: Arnd Bergmann --- arch/riscv/kernel/Makefile

[PATCH V3 12/17] riscv: compat: vdso: Add setup additional pages implementation

2022-01-19 Thread guoren
From: Guo Ren Reconstruct __setup_additional_pages() by appending vdso info pointer argument to meet compat_vdso_info requirement. And change vm_special_mapping *dm, *cm initialization into static. Signed-off-by: Guo Ren Signed-off-by: Guo Ren Cc: Arnd Bergmann --- arch/riscv/include/asm/elf

[PATCH V3 11/17] riscv: compat: vdso: Add rv32 VDSO base code implementation

2022-01-19 Thread guoren
From: Guo Ren There is no vgettimeofday supported in rv32 that makes simple to generate rv32 vdso code which only needs riscv64 compiler. Other architectures need change compiler or -m (machine parameter) to support vdso32 compiling. If rv32 support vgettimeofday (which cause C compile) in future

[PATCH V3 10/17] riscv: compat: Add elf.h implementation

2022-01-19 Thread guoren
From: Guo Ren Implement necessary type and macro for compat elf. See the code comment for detail. Signed-off-by: Guo Ren Signed-off-by: Guo Ren Cc: Arnd Bergmann --- arch/riscv/include/asm/elf.h | 51 +++- 1 file changed, 50 insertions(+), 1 deletion(-) diff

[PATCH V3 09/17] riscv: compat: syscall: Add entry.S implementation

2022-01-19 Thread guoren
From: Guo Ren Implement the entry of compat_sys_call_table[] in asm. Ref to riscv-privileged spec 4.1.1 Supervisor Status Register (sstatus): BIT[32:33] = UXL[1:0]: - 1:32 - 2:64 - 3:128 Signed-off-by: Guo Ren Signed-off-by: Guo Ren Cc: Arnd Bergmann --- arch/riscv/include/asm/csr.h |

[PATCH V3 08/17] riscv: compat: syscall: Add compat_sys_call_table implementation

2022-01-19 Thread guoren
From: Guo Ren Implement compat_syscall_table.c with compat_sys_call_table & fixup system call such as truncate64,pread64,fallocate which need two regs to indicate 64bit-arg (copied from arm64). Signed-off-by: Guo Ren Signed-off-by: Guo Ren Cc: Arnd Bergmann --- arch/riscv/include/asm/syscall

[PATCH V3 07/17] riscv: compat: Re-implement TASK_SIZE for COMPAT_32BIT

2022-01-19 Thread guoren
From: Guo Ren Make TASK_SIZE from const to dynamic detect TIF_32BIT flag function. Refer to arm64 to implement DEFAULT_MAP_WINDOW_64 for efi-stub. Limit 32-bit compatible process in 0-2GB virtual address range (which is enough for real scenarios), because it could avoid address sign extend probl

[PATCH V3 06/17] riscv: compat: Add basic compat date type implementation

2022-01-19 Thread guoren
From: Guo Ren Implement asm/compat.h for struct compat_xxx, RLIM_INFINITY, OFF_T_MAX, is_compat_task, compat_user_regset, regset convert. Signed-off-by: Guo Ren Signed-off-by: Guo Ren Cc: Arnd Bergmann --- arch/riscv/include/asm/compat.h | 136 +++ arch/riscv/inc

[PATCH V3 05/17] riscv: Fixup difference with defconfig

2022-01-19 Thread guoren
From: Guo Ren Let's follow the origin patch's spirit: The only difference between rv32_defconfig and defconfig is that rv32_defconfig has CONFIG_ARCH_RV32I=y. This is helpful to compare rv64-compat-rv32 v.s. rv32-linux. Fixes: 1b937e8faa87ccfb ("RISC-V: Add separate defconfig for 32bit system

[PATCH V3 04/17] syscalls: compat: Fix the missing part for __SYSCALL_COMPAT

2022-01-19 Thread guoren
From: Guo Ren Make "uapi asm unistd.h" could be used for architectures' COMPAT mode. The __SYSCALL_COMPAT is first used in riscv. Signed-off-by: Guo Ren Signed-off-by: Guo Ren Cc: Arnd Bergmann --- include/uapi/asm-generic/unistd.h | 4 ++-- tools/include/uapi/asm-generic/unistd.h | 4

[PATCH V3 03/17] asm-generic: compat: Cleanup duplicate definitions

2022-01-19 Thread guoren
From: Guo Ren There are 7 64bit architectures that support Linux COMPAT mode to run 32bit applications. A lot of definitions are duplicate: - COMPAT_USER_HZ - COMPAT_RLIM_INFINITY - COMPAT_OFF_T_MAX - __compat_uid_t, __compat_uid_t - compat_dev_t - compat_ipc_pid_t - struct compat_flock -

[PATCH V3 02/17] fs: stat: compat: Add __ARCH_WANT_COMPAT_STAT

2022-01-19 Thread guoren
From: Guo Ren RISC-V doesn't neeed compat_stat, so using __ARCH_WANT_COMPAT_STAT to exclude unnecessary SYSCALL functions. Signed-off-by: Guo Ren Signed-off-by: Guo Ren Reviewed-by: Arnd Bergmann --- arch/arm64/include/asm/unistd.h | 1 + arch/mips/include/asm/unistd.h| 2 ++ arch/pari

[PATCH V3 01/17] kconfig: Add SYSVIPC_COMPAT for all architectures

2022-01-19 Thread guoren
From: Guo Ren The existing per-arch definitions are pretty much historic cruft. Move SYSVIPC_COMPAT into init/Kconfig. Signed-off-by: Guo Ren Signed-off-by: Guo Ren Acked-by: Arnd Bergmann Cc: Christoph Hellwig --- arch/arm64/Kconfig | 4 arch/mips/Kconfig| 5 - arch/parisc/K

[PATCH V3 00/17] riscv: compat: Add COMPAT mode support for rv64

2022-01-19 Thread guoren
From: Guo Ren Currently, most 64-bit architectures (x86, parisc, powerpc, arm64, s390, mips, sparc) have supported COMPAT mode. But they all have history issues and can't use standard linux unistd.h. RISC-V would be first standard __SYSCALL_COMPAT user of include/uapi/asm-generic /unistd.h. The

Re: [PATCH v2 1/2] powerpc: Fix virt_addr_valid() check

2022-01-19 Thread Christophe Leroy
Le 19/01/2022 à 02:15, Kefeng Wang a écrit : > > On 2022/1/11 14:04, Christophe Leroy wrote: >> >> Le 11/01/2022 à 05:37, Nicholas Piggin a écrit : >>> Excerpts from Kefeng Wang's message of January 8, 2022 9:58 pm: Hi PPC maintainers, ping.. >>> Hmm. I might have confused myself about this

Re: [PATCH v2] powerpc: dts: t1040rdb: fix ports names for Seville Ethernet switch

2022-01-19 Thread Michael Ellerman
Maxim writes: > From: Maxim Kiselev > > On board rev A, the network interface labels for the switch ports > written on the front panel are different than on rev B and later. > > This patch fixes network interface names for the switch ports according > to labels that are written on the front panel

[PATCH v2] spi: mpc512x-psc: Convert to use GPIO descriptors

2022-01-19 Thread Linus Walleij
This driver is already relying on the core to provide valid GPIO numbers in spi->cs_gpio through of_spi_get_gpio_numbers(), so we can switch to letting the core use GPIO descriptors instead. The driver was assigning a local function to the custom chipselect callback, but I chose to just open code

Re: [PATCH v3 11/12] lkdtm: Fix execute_[user]_location()

2022-01-19 Thread Kees Cook
On Wed, Jan 19, 2022 at 08:28:54PM +0100, Christophe Leroy wrote: > Hi Kees, > > > Le 17/12/2021 à 12:49, Christophe Leroy a écrit : > > Hi Kees, > > > > Le 17/10/2021 à 14:38, Christophe Leroy a écrit : > > > execute_location() and execute_user_location() intent > > > to copy do_nothing() text

Re: [PATCH v3 11/12] lkdtm: Fix execute_[user]_location()

2022-01-19 Thread Christophe Leroy
Hi Kees, Le 17/12/2021 à 12:49, Christophe Leroy a écrit : Hi Kees, Le 17/10/2021 à 14:38, Christophe Leroy a écrit : execute_location() and execute_user_location() intent to copy do_nothing() text and execute it at a new location. However, at the time being it doesn't copy do_nothing() funct

[PATCH v4 6/7] drivers: virtio_mem: use pageblock size as the minimum virtio_mem size.

2022-01-19 Thread Zi Yan
From: Zi Yan alloc_contig_range() now only needs to be aligned to pageblock_order, drop virtio_mem size requirement that it needs to be the max of pageblock_order and MAX_ORDER. Signed-off-by: Zi Yan --- drivers/virtio/virtio_mem.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-)

[PATCH v4 5/7] mm: cma: use pageblock_order as the single alignment

2022-01-19 Thread Zi Yan
From: Zi Yan Now alloc_contig_range() works at pageblock granularity. Change CMA allocation, which uses alloc_contig_range(), to use pageblock_order alignment. Signed-off-by: Zi Yan --- include/linux/mmzone.h | 5 + kernel/dma/contiguous.c | 2 +- mm/cma.c| 6 ++ mm/pa

[PATCH v4 7/7] arch: powerpc: adjust fadump alignment to be pageblock aligned.

2022-01-19 Thread Zi Yan
From: Zi Yan CMA only requires pageblock alignment now. Change CMA alignment in fadump too. Signed-off-by: Zi Yan --- arch/powerpc/include/asm/fadump-internal.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/arch/powerpc/include/asm/fadump-internal.h b/arch/powerpc/inc

[PATCH v4 1/7] mm: page_alloc: avoid merging non-fallbackable pageblocks with others.

2022-01-19 Thread Zi Yan
From: Zi Yan This is done in addition to MIGRATE_ISOLATE pageblock merge avoidance. It prepares for the upcoming removal of the MAX_ORDER-1 alignment requirement for CMA and alloc_contig_range(). MIGRARTE_HIGHATOMIC should not merge with other migratetypes like MIGRATE_ISOLATE and MIGRARTE_CMA[1

[PATCH v4 4/7] mm: make alloc_contig_range work at pageblock granularity

2022-01-19 Thread Zi Yan
From: Zi Yan alloc_contig_range() worked at MAX_ORDER-1 granularity to avoid merging pageblocks with different migratetypes. It might unnecessarily convert extra pageblocks at the beginning and at the end of the range. Change alloc_contig_range() to work at pageblock granularity. It is done by r

[PATCH v4 3/7] mm: page_isolation: check specified range for unmovable pages

2022-01-19 Thread Zi Yan
From: Zi Yan Enable set_migratetype_isolate() to check specified sub-range for unmovable pages during isolation. Page isolation is done at max(MAX_ORDER_NR_PAEGS, pageblock_nr_pages) granularity, but not all pages within that granularity are intended to be isolated. For example, alloc_contig_rang

[PATCH v4 0/7] Use pageblock_order for cma and alloc_contig_range alignment.

2022-01-19 Thread Zi Yan
From: Zi Yan Hi all, This patchset tries to remove the MAX_ORDER-1 alignment requirement for CMA and alloc_contig_range(). It prepares for my upcoming changes to make MAX_ORDER adjustable at boot time[1]. It is on top of mmotm-2021-12-29-20-07. Changelog from RFC === 1. Dropped two irrelevant p

[PATCH v4 2/7] mm: page_isolation: move has_unmovable_pages() to mm/page_isolation.c

2022-01-19 Thread Zi Yan
From: Zi Yan has_unmovable_pages() is only used in mm/page_isolation.c. Move it from mm/page_alloc.c and make it static. Signed-off-by: Zi Yan --- include/linux/page-isolation.h | 2 - mm/page_alloc.c| 119 - mm/page_isolation.c| 11

Re: [PATCH] powerpc/process, kasan: Silence KASAN warnings in __get_wchan()

2022-01-19 Thread Kees Cook
On Tue, Jan 18, 2022 at 08:50:25PM -0500, He Ying wrote: > The following KASAN warning was reported in our kernel. > > BUG: KASAN: stack-out-of-bounds in get_wchan+0x188/0x250 > Read of size 4 at addr d216f958 by task ps/14437 > > CPU: 3 PID: 14437 Comm: ps Tainted: G O 5.10.

Re: [RFC PATCH 1/2] powerpc/64: remove system call instruction emulation

2022-01-19 Thread Naveen N. Rao
Nicholas Piggin wrote: emulate_step instruction emulation including sc instruction emulation initially appeared in xmon. It then emulation code was then moved into sstep.c where kprobes could use it too, and later hw_breakpoint and uprobes started to use it. Until uprobes, the only instruction e

Re: [PATCH v3] powerpc/papr_scm: Implement initial support for injecting smart errors

2022-01-19 Thread Vaibhav Jain
Hi Ira, Thanks for reviewing this patch. Ira Weiny writes: > On Thu, Jan 13, 2022 at 05:32:52PM +0530, Vaibhav Jain wrote: > [snip] > >> >> +/* Inject a smart error Add the dirty-shutdown-counter value to the pdsm */ >> +static int papr_pdsm_smart_inject(struct papr_scm_priv *p, >> +

Re: [PATCH v2 1/3] mm: vmalloc: Let user to control huge vmalloc default behavior

2022-01-19 Thread Matthew Wilcox
On Wed, Jan 19, 2022 at 09:44:20PM +0800, Kefeng Wang wrote: > > On 2022/1/19 21:22, Matthew Wilcox wrote: > > On Wed, Jan 19, 2022 at 08:57:58PM +0800, Kefeng Wang wrote: > > > Only parts of our products wants this feature,  we add some interfaces > > > which > > > only > > > > > > alloc hugevm

Re: [PATCH v2 1/3] mm: vmalloc: Let user to control huge vmalloc default behavior

2022-01-19 Thread Matthew Wilcox
On Wed, Jan 19, 2022 at 08:57:58PM +0800, Kefeng Wang wrote: > Only parts of our products wants this feature,  we add some interfaces which > only > > alloc hugevmalloc for them, eg, > vmap_hugepage/vmalloc_hugepage/remap_vmalloc_hugepage_range.. > > for our products, but it's not the choice of m

Re: [PATCH v3 2/2] powerpc: Add set_memory_{p/np}() and remove set_memory_attr()

2022-01-19 Thread Christophe Leroy
Hi Michael, Can we get this series in fixes as well ? Thanks Christophe Le 24/12/2021 à 12:07, Christophe Leroy a écrit : > set_memory_attr() was implemented by commit 4d1755b6a762 ("powerpc/mm: > implement set_memory_attr()") because the set_memory_xx() couldn't > be used at that time to modify

Re: [PATCH] powerpc/603: Fix boot failure with DEBUG_PAGEALLOC and KFENCE

2022-01-19 Thread Christophe Leroy
Michael, ping. Le 07/12/2021 à 07:10, Christophe Leroy a écrit : > Allthough kernel text is always mapped with BATs, we still have > inittext mapped with pages, so TLB miss handling is required > when CONFIG_DEBUG_PAGEALLOC or CONFIG_KFENCE is set. > > The final solution should be to set a BAT th

Re: [PATCH] powerpc/64s: Mask SRR0 before checking against the masked NIP

2022-01-19 Thread Michael Ellerman
On Mon, 17 Jan 2022 23:44:03 +1000, Nicholas Piggin wrote: > Commit 314f6c23dd8d ("powerpc/64s: Mask NIP before checking against > SRR0") masked off the low 2 bits of the NIP value in the interrupt > stack frame in case they are non-zero and mis-compare against a SRR0 > register value of a CPU whic

Re: [PATCH v3] powerpc/32s: Fix kasan_init_region() for KASAN

2022-01-19 Thread Michael Ellerman
On Mon, 10 Jan 2022 15:29:25 +, Christophe Leroy wrote: > It has been reported some configuration where the kernel doesn't > boot with KASAN enabled. > > This is due to wrong BAT allocation for the KASAN area: > > ---[ Data Block Address Translation ]--- > 0: 0xc000-0xcfff

Re: [PATCH] powerpc/time: Fix build failure due to do_hard_irq_enable() on PPC32

2022-01-19 Thread Michael Ellerman
On Mon, 10 Jan 2022 15:29:53 +, Christophe Leroy wrote: > CC arch/powerpc/kernel/time.o > In file included from : > ./arch/powerpc/include/asm/hw_irq.h: In function 'do_hard_irq_enable': > ././include/linux/compiler_types.h:335:45: error: call to > '__compiletime

Re: [PATCH] powerpc/perf: Fix power_pmu_wants_prompt_pmi to be defined only for CONFIG_PPC64

2022-01-19 Thread Michael Ellerman
On Fri, 14 Jan 2022 08:43:55 +0530, Athira Rajeev wrote: > power_pmu_wants_prompt_pmi is used to decide if PMI should > be taken prompt. This is valid only for ppc64 and is used > in CONFIG_PPC_BOOK3S_64 context. Hence include the function > under config check for PPC64 > > Fixes warning for 32-bi

Re: [PATCH] powerpc/perf: Fix task context setting for trace imc

2022-01-19 Thread Michael Ellerman
Athira Rajeev writes: > Trace IMC (In-Memory collection counters) in powerpc is > useful for application level profiling. For trace_imc, > presently task context (task_ctx_nr) is set to > perf_hw_context. But perf_hw_context is to be used for > cpu PMU. So for trace_imc, even though it is per thre