[PATCH] riscv: kprobes: Remove redundant kprobe_step_ctx

2021-04-18 Thread Jisheng Zhang
From: Jisheng Zhang Inspired by commit ba090f9cafd5 ("arm64: kprobes: Remove redundant kprobe_step_ctx"), the ss_pending and match_addr of kprobe_step_ctx are redundant because those can be replaced by KPROBE_HIT_SS and _kprobe->ainsn.api.insn[0] + GET_INSN_LENGTH(cur->opco

[PATCH] arm64: remove HAVE_DEBUG_BUGVERBOSE

2021-04-18 Thread Jisheng Zhang
From: Jisheng Zhang After commit 9fb7410f955f ("arm64/BUG: Use BRK instruction for generic BUG traps"), arm64 has switched to generic BUG implementation, so there's no need to select HAVE_DEBUG_BUGVERBOSE. Signed-off-by: Jisheng Zhang --- arch/arm64/Kconfig | 1 - 1 file changed,

[RFT PATCH] riscv: mremap speedup - enable HAVE_MOVE_PUD and HAVE_MOVE_PMD

2021-04-16 Thread Jisheng Zhang
From: Jisheng Zhang HAVE_MOVE_PUD enables remapping pages at the PUD level if both the source and destination addresses are PUD-aligned. HAVE_MOVE_PMD does similar speedup on the PMD level. With HAVE_MOVE_PUD enabled, there is about a 143x improvement on qemu With HAVE_MOVE_PMD enabled

[PATCH v3] drm/i915: Fix "mitigations" parsing if i915 is builtin

2021-04-16 Thread Jisheng Zhang
of kstrdup(). Fixes: 984cadea032b ("drm/i915: Allow the sysadmin to override security mitigations") Signed-off-by: Jisheng Zhang --- Since v2: - Use strscpy() per Ville's suggestion. Since v1: - Ensure "str" is properly terminated. Thanks Ville for pointing thi

Re: [PATCH] x86/kprobes: Simplify alloc_insn_page() with __vmalloc_node_range

2021-04-16 Thread Jisheng Zhang
On Wed, 14 Apr 2021 16:12:23 +0300 Jarkko Sakkinen wrote: > > So kprobes ss ins slot page "must be in the range of relative branching only > > for x86 and arm" > > > > And Jarkko's "arch/x86: kprobes: Remove MODULES dependency" series look > > much better. The last version is v5, I'm not sure

[PATCH v2] init: consolidate trap_init()

2021-04-14 Thread Jisheng Zhang
and sparc32 have real trap_init() implementation but the __init marker is missing, so add it to these three platforms. Signed-off-by: Jisheng Zhang --- Since v1: - add __init marker to trap_init() for alpha, microblaze and sparc32 - adjust the generic weak NOP trap_init() location to make it sits

Re: [PATCH] init: consolidate trap_init()

2021-04-14 Thread Jisheng Zhang
On Wed, 14 Apr 2021 17:27:57 +0800 Jisheng Zhang wrote: > CAUTION: Email originated externally, do not click links or open attachments > unless you recognize the sender and know the content is safe. > > > On Wed, 14 Apr 2021 11:10:42 +0200 > Christophe Leroy wrote: > &g

Re: [PATCH] init: consolidate trap_init()

2021-04-14 Thread Jisheng Zhang
On Wed, 14 Apr 2021 11:10:42 +0200 Christophe Leroy wrote: > > Le 14/04/2021 à 10:58, Jisheng Zhang a écrit : > > Many architectures implement the trap_init() as NOP, since there is > > no such default for trap_init(), this empty stub is duplicated among > > thes

[PATCH] init: consolidate trap_init()

2021-04-14 Thread Jisheng Zhang
Many architectures implement the trap_init() as NOP, since there is no such default for trap_init(), this empty stub is duplicated among these architectures. Provide a generic but weak NOP implementation to drop the empty stubs of trap_init() in these architectures. Signed-off-by: Jisheng Zhang

Re: [PATCH] x86/kprobes: Simplify alloc_insn_page() with __vmalloc_node_range

2021-04-14 Thread Jisheng Zhang
Jisheng Zhang wrote: > > > Hi, Hi > > On Tue, 13 Apr 2021 18:03:24 +0800 > Jisheng Zhang wrote: > > > Use the __vmalloc_node_range() to simplify x86's alloc_insn_page() > > implementation. > > Have you checked this is equivarent to the ori

Re: [PATCH] x86/kprobes: Simplify alloc_insn_page() with __vmalloc_node_range

2021-04-14 Thread Jisheng Zhang
On Tue, 13 Apr 2021 22:00:30 +0900 Masami Hiramatsu wrote: > > > Hi, Hi > > On Tue, 13 Apr 2021 18:03:24 +0800 > Jisheng Zhang wrote: > > > Use the __vmalloc_node_range() to simplify x86's alloc_insn_page() > > implementation. > > Have you che

Re: [PATCH] drm/i915: Fix "mitigations" parsing if i915 is builtin

2021-04-14 Thread Jisheng Zhang
Hi Ville, On Tue, 13 Apr 2021 19:59:34 +0300 Ville Syrjälä wrote: > > > On Tue, Apr 13, 2021 at 05:02:40PM +0800, Jisheng Zhang wrote: > > I met below error during boot with i915 builtin if pass > > "i915.mitigations=off": > > [0.015589] Bootin

Re: [PATCH] drm/i915: Fix "mitigations" parsing if i915 is builtin

2021-04-14 Thread Jisheng Zhang
On Tue, 13 Apr 2021 19:59:34 +0300 Ville Syrjälä wrote: > > On Tue, Apr 13, 2021 at 05:02:40PM +0800, Jisheng Zhang wrote: > > I met below error during boot with i915 builtin if pass > > "i915.mitigations=off": > > [0.015589] Booting kernel: `off

[PATCH v2] drm/i915: Fix "mitigations" parsing if i915 is builtin

2021-04-14 Thread Jisheng Zhang
of kstrdup(). Fixes: 984cadea032b ("drm/i915: Allow the sysadmin to override security mitigations") Signed-off-by: Jisheng Zhang --- Since v1: - Ensure "str" is properly terminated. Thanks Ville for pointing this out. drivers/gpu/drm/i915/i915_mitigations.c | 8 +++- 1 fi

[PATCH] x86/kprobes: Simplify alloc_insn_page() with __vmalloc_node_range

2021-04-13 Thread Jisheng Zhang
Use the __vmalloc_node_range() to simplify x86's alloc_insn_page() implementation. Signed-off-by: Jisheng Zhang --- arch/x86/kernel/kprobes/core.c | 24 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel

[PATCH] drm/i915: Fix "mitigations" parsing if i915 is builtin

2021-04-13 Thread Jisheng Zhang
of kstrdup(). Fixes: 984cadea032b ("drm/i915: Allow the sysadmin to override security mitigations") Signed-off-by: Jisheng Zhang --- drivers/gpu/drm/i915/i915_mitigations.c | 7 ++- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_mitigations.c b/

[PATCH v3 10/10] riscv: Set ARCH_HAS_STRICT_MODULE_RWX if MMU

2021-04-12 Thread Jisheng Zhang
From: Jisheng Zhang Now we can set ARCH_HAS_STRICT_MODULE_RWX for MMU riscv platforms, this is good from security perspective. Signed-off-by: Jisheng Zhang Reviewed-by: Anup Patel --- arch/riscv/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/riscv/Kconfig b/arch/riscv

[PATCH v3 08/10] riscv: bpf: Avoid breaking W^X on RV64

2021-04-12 Thread Jisheng Zhang
From: Jisheng Zhang bpf_jit_binary_lock_ro() in core not only set RO but also set EXEC permission when JIT is done, so no need to allocate RWX from the beginning, and it's not safe. Signed-off-by: Jisheng Zhang --- arch/riscv/net/bpf_jit_comp64.c | 2 +- 1 file changed, 1 insertion(+), 1

[PATCH v3 09/10] riscv: module: Create module allocations without exec permissions

2021-04-12 Thread Jisheng Zhang
From: Jisheng Zhang The core code manages the executable permissions of code regions of modules explicitly, it is not necessary to create the module vmalloc regions with RWX permissions. Create them with RW- permissions instead. Signed-off-by: Jisheng Zhang Reviewed-by: Anup Patel --- arch

[PATCH v3 07/10] riscv: bpf: Write protect JIT code

2021-04-12 Thread Jisheng Zhang
From: Jisheng Zhang Call bpf_jit_binary_lock_ro() to write protect JIT code. Signed-off-by: Jisheng Zhang --- arch/riscv/net/bpf_jit_core.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/riscv/net/bpf_jit_core.c b/arch/riscv/net/bpf_jit_core.c index 3630d447352c..40d5bf113fee 100644

[PATCH v3 06/10] riscv: kprobes: Implement alloc_insn_page()

2021-04-12 Thread Jisheng Zhang
From: Jisheng Zhang Allocate PAGE_KERNEL_READ_EXEC(read only, executable) page for kprobes insn page. This is to prepare for STRICT_MODULE_RWX. Signed-off-by: Jisheng Zhang Reviewed-by: Anup Patel --- arch/riscv/kernel/probes/kprobes.c | 8 1 file changed, 8 insertions(+) diff

[PATCH v3 05/10] riscv: Constify sbi_ipi_ops

2021-04-12 Thread Jisheng Zhang
From: Jisheng Zhang Constify the sbi_ipi_ops so that it will be placed in the .rodata section. This will cause attempts to modify it to fail when strict page permissions are in place. Signed-off-by: Jisheng Zhang Reviewed-by: Anup Patel --- arch/riscv/include/asm/smp.h | 4 ++-- arch/riscv

[PATCH v3 03/10] riscv: Mark some global variables __ro_after_init

2021-04-12 Thread Jisheng Zhang
From: Jisheng Zhang All of these are never modified after init, so they can be __ro_after_init. Signed-off-by: Jisheng Zhang Reviewed-by: Anup Patel --- arch/riscv/kernel/sbi.c | 8 arch/riscv/kernel/smp.c | 4 ++-- arch/riscv/kernel/time.c | 2 +- arch/riscv/kernel/vdso.c | 4

[PATCH v3 01/10] riscv: mm: Remove setup_zero_page()

2021-04-12 Thread Jisheng Zhang
From: Jisheng Zhang The empty_zero_page sits at .bss..page_aligned section, so will be cleared to zero during clearing bss, we don't need to clear it again. Signed-off-by: Jisheng Zhang --- arch/riscv/mm/init.c | 6 -- 1 file changed, 6 deletions(-) diff --git a/arch/riscv/mm/init.c b

[PATCH v3 04/10] riscv: Constify sys_call_table

2021-04-12 Thread Jisheng Zhang
From: Jisheng Zhang Constify the sys_call_table so that it will be placed in the .rodata section. This will cause attempts to modify the table to fail when strict page permissions are in place. Signed-off-by: Jisheng Zhang Reviewed-by: Anup Patel --- arch/riscv/include/asm/syscall.h | 2

[PATCH v3 00/10] riscv: improve self-protection

2021-04-12 Thread Jisheng Zhang
From: Jisheng Zhang patch1 removes the non-necessary setup_zero_page() patch2 is a trivial improvement patch to move some functions to .init section Then following patches improve self-protection by: Marking some variables __ro_after_init Constifing some variables Enabling

[PATCH v3 02/10] riscv: add __init section marker to some functions

2021-04-12 Thread Jisheng Zhang
From: Jisheng Zhang They are not needed after booting, so mark them as __init to move them to the __init section. Signed-off-by: Jisheng Zhang --- arch/riscv/kernel/cpufeature.c | 2 +- arch/riscv/kernel/traps.c | 2 +- arch/riscv/mm/init.c | 4 ++-- arch/riscv/mm/kasan_init.c

Re: [PATCH] riscv/kprobe: fix kernel panic when invoking sys_read traced by kprobe

2021-04-12 Thread Jisheng Zhang
On Fri, 9 Apr 2021 12:16:26 +0800 "liaochang (A)" wrote: > > > 在 2021/4/8 19:20, Jisheng Zhang 写道: > > On Tue, 30 Mar 2021 16:18:48 +0800 > > Liao Chang wrote: > > > > > >> > >> The execution of sys_read end up hitting a BUG_ON()

[PATCH] arm64: kprobes: Restore local irqflag if kprobes is cancelled

2021-04-12 Thread Jisheng Zhang
overwrite the saved_irqflag by calling kprobes_save_local_irqflag(). NOTE, DAIF is masked in this new saved irqflag. After kprobes is serviced, the cpu pstate is retored with DAIF masked. This patch is inspired by one patch for riscv from Liao Chang. Signed-off-by: Jisheng Zhang --- arch/arm64/kernel

Re: [PATCH] implement flush_cache_vmap for RISC-V

2021-04-12 Thread Jisheng Zhang
Hi Jiuyang, On Mon, 12 Apr 2021 00:05:30 + Jiuyang Liu wrote: > > This patch implements flush_cache_vmap for RISC-V, since it modifies PTE. > Without this patch, SFENCE.VMA won't be added to related codes, which > might introduce a bug in the out-of-order micro-architecture >

Re: [PATCH] implement flush_cache_vmap and flush_cache_vunmap for RISC-V

2021-04-12 Thread Jisheng Zhang
On Sun, 11 Apr 2021 14:41:07 -0700 (PDT) Palmer Dabbelt wrote: > > > On Sun, 28 Mar 2021 18:55:09 PDT (-0700), l...@jiuyang.me wrote: > > This patch implements flush_cache_vmap and flush_cache_vunmap for > > RISC-V, since these functions might modify PTE. Without this patch, > > SFENCE.VMA

Re: [PATCH v2 1/9] riscv: add __init section marker to some functions

2021-04-11 Thread Jisheng Zhang
On Fri, 2 Apr 2021 09:38:02 +0530 Anup Patel wrote: > > > On Wed, Mar 31, 2021 at 10:00 PM Jisheng Zhang > wrote: > > > > From: Jisheng Zhang > > > > They are not needed after booting, so mark them as __init to move them > > to the __init sec

[tip: timers/core] clocksource/drivers/arm_arch_timer: Add __ro_after_init and __init

2021-04-09 Thread tip-bot2 for Jisheng Zhang
The following commit has been merged into the timers/core branch of tip: Commit-ID: e2bf384d4329bb478ad003eae1ab644756a42266 Gitweb: https://git.kernel.org/tip/e2bf384d4329bb478ad003eae1ab644756a42266 Author:Jisheng Zhang AuthorDate:Tue, 30 Mar 2021 14:04:44 +08:00

Re: [PATCH] riscv: keep interrupts disabled for BREAKPOINT exception

2021-04-08 Thread Jisheng Zhang
On Sat, 3 Apr 2021 20:30:53 +0200 (CEST) "Maciej W. Rozycki" wrote: > CAUTION: Email originated externally, do not click links or open attachments > unless you recognize the sender and know the content is safe. > > > On Thu, 1 Apr 2021, Masami Hiramatsu wrote: > > > > > > Current riscv's

Re: [PATCH] riscv/kprobe: fix kernel panic when invoking sys_read traced by kprobe

2021-04-08 Thread Jisheng Zhang
On Tue, 30 Mar 2021 16:18:48 +0800 Liao Chang wrote: > > The execution of sys_read end up hitting a BUG_ON() in __find_get_block > after installing kprobe at sys_read, the BUG message like the following: > > [ 65.708663] [ cut here ] > [ 65.709987] kernel BUG at

[irqchip: irq/irqchip-next] irqchip/sifive-plic: Mark two global variables __ro_after_init

2021-04-07 Thread irqchip-bot for Jisheng Zhang
The following commit has been merged into the irq/irqchip-next branch of irqchip: Commit-ID: e03b7c1bcbfad6f27b4682f638b98627c4e416ba Gitweb: https://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms/e03b7c1bcbfad6f27b4682f638b98627c4e416ba Author:Jisheng Zhang

Re: [PATCH] riscv: keep interrupts disabled for BREAKPOINT exception

2021-04-02 Thread Jisheng Zhang
On Thu, 1 Apr 2021 16:49:47 +0800 "liaochang (A)" wrote: > Hi Jisheng, Hi, > > 在 2021/3/31 22:22, Jisheng Zhang 写道: > > On Tue, 30 Mar 2021 18:33:16 +0900 > > Masami Hiramatsu wrote: > > > >> Hi Jisheng, > > > > Hi M

[PATCH] riscv: vdso: fix and clean-up Makefile

2021-04-02 Thread Jisheng Zhang
From: Jisheng Zhang Running "make" on an already compiled kernel tree will rebuild the kernel even without any modifications: CALLlinux/scripts/checksyscalls.sh CALLlinux/scripts/atomic/check-atomics.sh CHK include/generated/compile.h SO2Sarch/riscv/kernel

[PATCH v2 9/9] riscv: Set ARCH_HAS_STRICT_MODULE_RWX if MMU

2021-03-31 Thread Jisheng Zhang
From: Jisheng Zhang Now we can set ARCH_HAS_STRICT_MODULE_RWX for MMU riscv platforms, this is good from security perspective. Signed-off-by: Jisheng Zhang --- arch/riscv/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index 87d7b52f278f

[PATCH v2 8/9] riscv: module: Create module allocations without exec permissions

2021-03-31 Thread Jisheng Zhang
From: Jisheng Zhang The core code manages the executable permissions of code regions of modules explicitly, it is not necessary to create the module vmalloc regions with RWX permissions. Create them with RW- permissions instead. Signed-off-by: Jisheng Zhang --- arch/riscv/kernel/module.c | 10

[PATCH v2 7/9] riscv: bpf: Avoid breaking W^X on RV64

2021-03-31 Thread Jisheng Zhang
From: Jisheng Zhang bpf_jit_binary_lock_ro() in core not only set RO but also set EXEC permission when JIT is done, so no need to allocate RWX from the beginning, and it's not safe. Signed-off-by: Jisheng Zhang --- arch/riscv/net/bpf_jit_comp64.c | 2 +- 1 file changed, 1 insertion(+), 1

[PATCH v2 6/9] riscv: bpf: Write protect JIT code

2021-03-31 Thread Jisheng Zhang
From: Jisheng Zhang Call bpf_jit_binary_lock_ro() to write protect JIT code. Signed-off-by: Jisheng Zhang --- arch/riscv/net/bpf_jit_core.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/riscv/net/bpf_jit_core.c b/arch/riscv/net/bpf_jit_core.c index 3630d447352c..40d5bf113fee 100644

[PATCH v2 5/9] riscv: kprobes: Implement alloc_insn_page()

2021-03-31 Thread Jisheng Zhang
From: Jisheng Zhang Allocate PAGE_KERNEL_READ_EXEC(read only, executable) page for kprobes insn page. This is to prepare for STRICT_MODULE_RWX. Signed-off-by: Jisheng Zhang --- arch/riscv/kernel/probes/kprobes.c | 8 1 file changed, 8 insertions(+) diff --git a/arch/riscv/kernel

[PATCH v2 4/9] riscv: Constify sbi_ipi_ops

2021-03-31 Thread Jisheng Zhang
From: Jisheng Zhang Constify the sbi_ipi_ops so that it will be placed in the .rodata section. This will cause attempts to modify it to fail when strict page permissions are in place. Signed-off-by: Jisheng Zhang --- arch/riscv/include/asm/smp.h | 4 ++-- arch/riscv/kernel/sbi.c | 2

[PATCH v2 3/9] riscv: Constify sys_call_table

2021-03-31 Thread Jisheng Zhang
From: Jisheng Zhang Constify the sys_call_table so that it will be placed in the .rodata section. This will cause attempts to modify the table to fail when strict page permissions are in place. Signed-off-by: Jisheng Zhang --- arch/riscv/include/asm/syscall.h | 2 +- arch/riscv/kernel

[PATCH v2 2/9] riscv: Mark some global variables __ro_after_init

2021-03-31 Thread Jisheng Zhang
From: Jisheng Zhang All of these are never modified after init, so they can be __ro_after_init. Signed-off-by: Jisheng Zhang --- arch/riscv/kernel/sbi.c | 8 arch/riscv/kernel/smp.c | 4 ++-- arch/riscv/kernel/time.c | 2 +- arch/riscv/kernel/vdso.c | 4 ++-- arch/riscv/mm/init.c

[PATCH v2 0/9] riscv: improve self-protection

2021-03-31 Thread Jisheng Zhang
From: Jisheng Zhang patch1 is a trivial improvement patch to move some functions to .init section Then following patches improve self-protection by: Marking some variables __ro_after_init Constifing some variables Enabling ARCH_HAS_STRICT_MODULE_RWX Since v1: - no need to move

[PATCH v2 1/9] riscv: add __init section marker to some functions

2021-03-31 Thread Jisheng Zhang
From: Jisheng Zhang They are not needed after booting, so mark them as __init to move them to the __init section. Signed-off-by: Jisheng Zhang --- arch/riscv/kernel/traps.c | 2 +- arch/riscv/mm/init.c | 6 +++--- arch/riscv/mm/kasan_init.c | 6 +++--- arch/riscv/mm/ptdump.c | 2

Re: [PATCH] riscv: keep interrupts disabled for BREAKPOINT exception

2021-03-31 Thread Jisheng Zhang
On Tue, 30 Mar 2021 18:33:16 +0900 Masami Hiramatsu wrote: > Hi Jisheng, Hi Masami, > > On Tue, 30 Mar 2021 02:16:24 +0800 > Jisheng Zhang wrote: > > > From: Jisheng Zhang > > > > Current riscv's kprobe handlers are run with both preemption and > >

[PATCH] clocksource/arm_arch_timer: add __ro_after_init and __init

2021-03-30 Thread Jisheng Zhang
Some functions are not needed after booting, so mark them as __init to move them to the .init section. Some global variables are never modified after init, so can be __ro_after_init. Signed-off-by: Jisheng Zhang --- drivers/clocksource/arm_arch_timer.c | 23 --- 1 file

[PATCH v2] arm64: Add __init section marker to some functions

2021-03-29 Thread Jisheng Zhang
They are not needed after booting, so mark them as __init to move them to the .init section. Signed-off-by: Jisheng Zhang --- Since v1: - add __init section mark to __vdso_init() and __aarch32_alloc_vdso_pages() arch/arm64/include/asm/ptdump.h | 2 +- arch/arm64/kernel/vdso.c| 4

[PATCH] arm: ptdump: convert to DEFINE_SHOW_ATTRIBUTE

2021-03-29 Thread Jisheng Zhang
Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code. Signed-off-by: Jisheng Zhang --- arch/arm/mm/ptdump_debugfs.c | 13 + 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/arch/arm/mm/ptdump_debugfs.c b/arch/arm/mm/ptdump_debugfs.c index 8df9afac8d81..318de969ae0f

[PATCH] arm: ptdump: add __init section marker to three functions

2021-03-29 Thread Jisheng Zhang
They are not needed after booting, so mark them as __init to move them to the .init section. Signed-off-by: Jisheng Zhang --- arch/arm/mm/dump.c | 4 ++-- arch/arm/mm/ptdump_debugfs.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/arm/mm/dump.c b/arch/arm

[PATCH] arm64: mm: ptdump: Add __init section marker to three functions

2021-03-29 Thread Jisheng Zhang
They are not needed after booting, so mark them as __init to move them to the .init section. Signed-off-by: Jisheng Zhang --- arch/arm64/include/asm/ptdump.h | 2 +- arch/arm64/mm/ptdump.c | 4 ++-- arch/arm64/mm/ptdump_debugfs.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions

[PATCH 9/9] riscv: Set ARCH_HAS_STRICT_MODULE_RWX if MMU

2021-03-29 Thread Jisheng Zhang
From: Jisheng Zhang Now we can set ARCH_HAS_STRICT_MODULE_RWX for MMU riscv platforms, this is good from security perspective. Signed-off-by: Jisheng Zhang --- arch/riscv/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index 87d7b52f278f

[PATCH 8/9] riscv: module: Create module allocations without exec permissions

2021-03-29 Thread Jisheng Zhang
From: Jisheng Zhang The core code manages the executable permissions of code regions of modules explicitly, it is not necessary to create the module vmalloc regions with RWX permissions. Create them with RW- permissions instead. Signed-off-by: Jisheng Zhang --- arch/riscv/kernel/module.c | 2

[PATCH 7/9] riscv: bpf: Avoid breaking W^X

2021-03-29 Thread Jisheng Zhang
From: Jisheng Zhang We allocate Non-executable pages, then call bpf_jit_binary_lock_ro() to enable executable permission after mapping them read-only. This is to prepare for STRICT_MODULE_RWX in following patch. Signed-off-by: Jisheng Zhang --- arch/riscv/net/bpf_jit_core.c | 3 ++- 1 file

[PATCH 6/9] riscv: bpf: Move bpf_jit_alloc_exec() and bpf_jit_free_exec() to core

2021-03-29 Thread Jisheng Zhang
From: Jisheng Zhang We will drop the executable permissions of the code pages from the mapping at allocation time soon. Move bpf_jit_alloc_exec() and bpf_jit_free_exec() to bpf_jit_core.c so that they can be shared by both RV64I and RV32I. Signed-off-by: Jisheng Zhang --- arch/riscv/net

[PATCH 5/9] riscv: kprobes: Implement alloc_insn_page()

2021-03-29 Thread Jisheng Zhang
From: Jisheng Zhang Allocate PAGE_KERNEL_READ_EXEC(read only, executable) page for kprobes insn page. This is to prepare for STRICT_MODULE_RWX. Signed-off-by: Jisheng Zhang --- arch/riscv/kernel/probes/kprobes.c | 8 1 file changed, 8 insertions(+) diff --git a/arch/riscv/kernel

[PATCH 4/9] riscv: Constify sbi_ipi_ops

2021-03-29 Thread Jisheng Zhang
From: Jisheng Zhang Constify the sbi_ipi_ops so that it will be placed in the .rodata section. This will cause attempts to modify it to fail when strict page permissions are in place. Signed-off-by: Jisheng Zhang --- arch/riscv/include/asm/smp.h | 4 ++-- arch/riscv/kernel/sbi.c | 2

[PATCH 3/9] riscv: Constify sys_call_table

2021-03-29 Thread Jisheng Zhang
From: Jisheng Zhang Constify the sys_call_table so that it will be placed in the .rodata section. This will cause attempts to modify the table to fail when strict page permissions are in place. Signed-off-by: Jisheng Zhang --- arch/riscv/include/asm/syscall.h | 2 +- arch/riscv/kernel

[PATCH 2/9] riscv: Mark some global variables __ro_after_init

2021-03-29 Thread Jisheng Zhang
From: Jisheng Zhang All of these are never modified after init, so they can be __ro_after_init. Signed-off-by: Jisheng Zhang --- arch/riscv/kernel/sbi.c | 8 arch/riscv/kernel/smp.c | 4 ++-- arch/riscv/kernel/time.c | 2 +- arch/riscv/kernel/vdso.c | 4 ++-- arch/riscv/mm/init.c

[PATCH 1/9] riscv: add __init section marker to some functions

2021-03-29 Thread Jisheng Zhang
From: Jisheng Zhang They are not needed after booting, so mark them as __init to move them to the __init section. Signed-off-by: Jisheng Zhang --- arch/riscv/kernel/traps.c | 2 +- arch/riscv/mm/init.c | 6 +++--- arch/riscv/mm/kasan_init.c | 6 +++--- arch/riscv/mm/ptdump.c | 2

[PATCH 0/9] riscv: improve self-protection

2021-03-29 Thread Jisheng Zhang
From: Jisheng Zhang patch1 is a trivial improvement patch to move some functions to .init section Then following patches improve self-protection by: Marking some variables __ro_after_init Constifing some variables Enabling ARCH_HAS_STRICT_MODULE_RWX Jisheng Zhang (9): riscv: add __init

[PATCH] riscv: keep interrupts disabled for BREAKPOINT exception

2021-03-29 Thread Jisheng Zhang
From: Jisheng Zhang Current riscv's kprobe handlers are run with both preemption and interrupt enabled, this violates kprobe requirements. Fix this issue by keeping interrupts disabled for BREAKPOINT exception. Fixes: c22b0bcb1dd0 ("riscv: Add kprobes supported") Signed-off-by: Jis

[PATCH] riscv: kprobes/ftrace: Add recursion protection to the ftrace callback

2021-03-29 Thread Jisheng Zhang
From: Jisheng Zhang Currently, the riscv's kprobes(powerred by ftrace) handler is preemptible. Futher check indicates we miss something similar as the commit c536aa1c5b17 ("kprobes/ftrace: Add recursion protection to the ftrace callback"), so do similar modifications as the commit do

[PATCH] riscv: add do_page_fault and do_trap_break into the kprobes blacklist

2021-03-29 Thread Jisheng Zhang
From: Jisheng Zhang These two functions are used to implement the kprobes feature so they can't be kprobed. Fixes: c22b0bcb1dd0 ("riscv: Add kprobes supported") Signed-off-by: Jisheng Zhang --- arch/riscv/kernel/traps.c | 1 + arch/riscv/mm/fault.c | 1 + 2 files changed, 2

[PATCH] irqchip/sifive-plic: Mark two global variables __ro_after_init

2021-03-29 Thread Jisheng Zhang
From: Jisheng Zhang All of these two are never modified after init, so they can be __ro_after_init. Signed-off-by: Jisheng Zhang --- drivers/irqchip/irq-sifive-plic.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/irqchip/irq-sifive-plic.c b/drivers/irqchip

[PATCH] selftests/bpf: add LDFLAGS when building test_verifier

2021-03-29 Thread Jisheng Zhang
From: Jisheng Zhang This is useful for cross compile process to point linker to the correct libelf, libcap, libz path. Signed-off-by: Jisheng Zhang --- tools/testing/selftests/bpf/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/bpf/Makefile

[PATCH] samples/kprobes: Add riscv support

2021-03-29 Thread Jisheng Zhang
From: Jisheng Zhang Add riscv specific info dump in both handler_pre() and handler_post(). Signed-off-by: Jisheng Zhang --- samples/kprobes/kprobe_example.c | 8 1 file changed, 8 insertions(+) diff --git a/samples/kprobes/kprobe_example.c b/samples/kprobes/kprobe_example.c index

[PATCH v3] PCI: dwc: move dw_pcie_msi_init() to dw_pcie_setup_rc()

2021-03-25 Thread Jisheng Zhang
solve this problem by moving dw_pcie_msi_init() to dw_pcie_setup_rc(). Reviewed-by: Rob Herring Signed-off-by: Jisheng Zhang --- Since v2: - rewrite the commit msg Since v1: - collect Reviewed-by tag drivers/pci/controller/dwc/pcie-designware-host.c | 3 ++- 1 file changed, 2 insertions(+), 1

[PATCH] tee: optee: fix build error caused by recent optee tracepoints feature

2021-03-24 Thread Jisheng Zhang
Rostedt Signed-off-by: Jisheng Zhang --- drivers/tee/optee/Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/tee/optee/Makefile b/drivers/tee/optee/Makefile index 56263ae3b1d7..3aa33ea9e6a6 100644 --- a/drivers/tee/optee/Makefile +++ b/drivers/tee/optee/Makefile @@ -6,3 +6,6 @@

Re: [PATCH] tee: optee: add invoke_fn tracepoints

2021-03-24 Thread Jisheng Zhang
On Wed, 24 Mar 2021 10:53:13 -0400 Steven Rostedt wrote: > > On Wed, 24 Mar 2021 07:48:53 -0700 > Guenter Roeck wrote: > > > On Wed, Mar 24, 2021 at 07:34:07AM -0700, Guenter Roeck wrote: > > > On Wed, Feb 10, 2021 at 02:44:09PM +0800, Jisheng Zhang wrote

[PATCH] arm: mm: remove set_kernel_text_r[ow]()

2021-03-24 Thread Jisheng Zhang
After commit 5a735583b764 ("arm/ftrace: Use __patch_text()"), the last and only user of these functions has gone, remove them. Signed-off-by: Jisheng Zhang --- arch/arm/include/asm/set_memory.h | 8 arch/arm/mm/init.c| 21 - 2 files c

[PATCH] mmc: sdhci: replace mmc->parent with mmc_dev() for consistency

2021-03-24 Thread Jisheng Zhang
As pointed out by Ulf, "both "mmc->parent" and mmc_dev(mmc) are being used in the entire c-file". Convert all the mmc->parent usage in all sdhci host driver to mmc_dev() for consistency. Suggested-by: Ulf Hansson Signed-off-by: Jisheng Zhang --- drivers/mmc/h

[PATCH] mmc: sdhci-of-dwcmshc: set MMC_CAP_WAIT_WHILE_BUSY

2021-03-24 Thread Jisheng Zhang
The host supports HW busy detection of the device busy signaling over dat0 line. Set MMC_CAP_wAIT_WHILE_BUSY host capability. Signed-off-by: Jisheng Zhang --- drivers/mmc/host/sdhci-of-dwcmshc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/mmc/host/sdhci-of-dwcmshc.c b/drivers

Re: [PATCH RESEND] PCI: dwc: Fix MSI not work after resume

2021-03-22 Thread Jisheng Zhang
Hi On Mon, 22 Mar 2021 20:24:41 -0500 Bjorn Helgaas wrote: > > [+cc Kishon, Richard, Lucas, Dilip] > > On Mon, Mar 01, 2021 at 11:10:31AM +0800, Jisheng Zhang wrote: > > After we move dw_pcie_msi_init() into core -- dw_pcie_host_init(), the > > MSI stops worki

Re: CLANG LTO compatibility issue with DEBUG_INFO_BTF

2021-03-21 Thread Jisheng Zhang
On Thu, 18 Mar 2021 20:56:46 -0700 Yonghong Song wrote: > > On 3/18/21 8:45 PM, Jisheng Zhang wrote: > > Hi, > > > > When trying the latest 5.12-rc3 with both LTO_CLANG_THIN and DEBUG_INFO_BTF > > enabled, I met lots of warnings such as: > > > > ...

CLANG LTO compatibility issue with DEBUG_INFO_BTF

2021-03-18 Thread Jisheng Zhang
Hi, When trying the latest 5.12-rc3 with both LTO_CLANG_THIN and DEBUG_INFO_BTF enabled, I met lots of warnings such as: ... tag__recode_dwarf_type: couldn't find 0x4a7ade5 type for 0x4ab9f88 (subroutine_type)! ftype__recode_dwarf_types: couldn't find 0x4a7ade5 type for 0x4ab9fa4

[PATCH] mmc: sdhci-pci: Avoid comma separated statements

2021-03-11 Thread Jisheng Zhang
Use semicolons. Signed-off-by: Jisheng Zhang --- drivers/mmc/host/sdhci-pci-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mmc/host/sdhci-pci-core.c b/drivers/mmc/host/sdhci-pci-core.c index 9552708846ca..62799c1d9c0c 100644 --- a/drivers/mmc/host/sdhci-pci

[PATCH] mmc: sdio: fix a typo in the comment of SDIO_SD_REV_3_00

2021-03-11 Thread Jisheng Zhang
I believe "Spev" is typo, should be "Spec". Signed-off-by: Jisheng Zhang --- include/linux/mmc/sdio.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/mmc/sdio.h b/include/linux/mmc/sdio.h index e28769991e82..2a05d1ac4f0e 100644 --- a/incl

[PATCH] mmc: sdhci: Use "mmc" directly rather than "host->mmc"

2021-03-11 Thread Jisheng Zhang
01e61ldr x1, [x19, #56] 900: 1a9f17e3csetw3, eq // eq = none 904: 11000463add w3, w3, #0x1 908: 9400bl 0 ... We saved one ldr instruction: "ldr x0, [x0, #1160]" Signed-off-by: Jisheng Zha

Re: [PATCH v2 5/5] PCI: dwc: Move dw_pcie_msi_init() from each users to designware host

2021-03-10 Thread Jisheng Zhang
On Sun, 7 Mar 2021 23:10:12 +0100 Krzysztof Wilczyński wrote: > > > Hi, > > > Currently, dw_pcie_msi_init() allocates and maps page for msi, then > > program the PCIE_MSI_ADDR_LO and PCIE_MSI_ADDR_HI. The Root Complex > > may lose power during suspend-to-RAM, so when we resume, we want to > >

Re: [PATCH] net: 9p: free what was emitted when read count is 0

2021-03-02 Thread Jisheng Zhang
On Tue, 2 Mar 2021 17:08:13 +0900 Dominique Martinet wrote: > > > Jisheng Zhang wrote on Tue, Mar 02, 2021 at 03:39:40PM +0800: > > > Rather than make an exception for 0, how about just removing the if as > > > follow ? > > > > IMHO, we may need to kee

[PATCH v2] net: 9p: advance iov on empty read

2021-03-02 Thread Jisheng Zhang
: 0001 R14: 0001 R15: [8.295782] ---[ end trace 63317af81b3ca24b ]--- Signed-off-by: Jisheng Zhang --- Since v1: - reword the commit msg - fix the issue by removing exception for 0 code path, thank Dominique! net/9p/client.c | 4 1 file changed

Re: [PATCH] net: 9p: free what was emitted when read count is 0

2021-03-02 Thread Jisheng Zhang
On Tue, 2 Mar 2021 13:38:08 +0900 Dominique Martinet wrote: > > > Jisheng Zhang wrote on Mon, Mar 01, 2021 at 11:01:57AM +0800: > > Per my understanding of iov_iter, we need to call iov_iter_advance() > > even when the read out count is 0. I believe we can see this common

[PATCH RESEND] PCI: dwc: Fix MSI not work after resume

2021-02-28 Thread Jisheng Zhang
_init() into core") Reviewed-by: Rob Herring Signed-off-by: Jisheng Zhang --- Since v1: - collect Reviewed-by tag drivers/pci/controller/dwc/pcie-designware-host.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/

Re: [PATCH] net: 9p: free what was emitted when read count is 0

2021-02-28 Thread Jisheng Zhang
On Mon, 1 Mar 2021 11:51:24 +0900 Dominique Martinet wrote: > > > Jisheng Zhang wrote on Mon, Mar 01, 2021 at 10:33:36AM +0800: > > I met below warning when cating a small size(about 80bytes) txt file > > on 9pfs(msize=2097152 is passed to 9p mount option), the

[PATCH] net: 9p: free what was emitted when read count is 0

2021-02-28 Thread Jisheng Zhang
01 R15: [8.295782] ---[ end trace 63317af81b3ca24b ]--- Signed-off-by: Jisheng Zhang --- net/9p/client.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/9p/client.c b/net/9p/client.c index 4f62f299da0c..6dc01008cd3b 100644 --- a/net/9p/client.c +++ b/net/9p/client.c

Re: [PATCH] tee: optee: add invoke_fn tracepoints

2021-02-23 Thread Jisheng Zhang
On Tue, 23 Feb 2021 08:59:22 +0100 Jens Wiklander wrote: > > Hi Jisheng, Hi Jens, > > On Wed, Feb 10, 2021 at 7:44 AM Jisheng Zhang > wrote: > > > > Add tracepoints to retrieve information about the invoke_fn. This would > > help to measure how many inv

Re: [PATCH v2 16/24] net: stmmac: Use optional reset control API to work with stmmaceth

2021-02-09 Thread Jisheng Zhang
Hi, On Mon, 8 Feb 2021 16:56:00 +0300 Serge Semin wrote: > > Since commit bb3222f71b57 ("net: stmmac: platform: use optional clk/reset > get APIs") a manual implementation of the optional device reset control > functionality has been replaced with using the > devm_reset_control_get_optional()

[PATCH] tee: optee: add invoke_fn tracepoints

2021-02-09 Thread Jisheng Zhang
Add tracepoints to retrieve information about the invoke_fn. This would help to measure how many invoke_fn are triggered and how long it takes to complete one invoke_fn call. Signed-off-by: Jisheng Zhang --- Since v1: - add BUILD_BUG_ON() macro usage to make sure that the size of what is being

[PATCH] tee: optee: add invoke_fn tracepoints

2021-02-09 Thread Jisheng Zhang
Add tracepoints to retrieve information about the invoke_fn. This would help to measure how many invoke_fn are triggered and how long it takes to complete one invoke_fn call. Signed-off-by: Jisheng Zhang --- drivers/tee/optee/call.c| 4 ++ drivers/tee/optee/optee_trace.h | 65

[PATCH v3 2/2] PCI: dwc: al: Remove useless dw_pcie_ops

2021-01-27 Thread Jisheng Zhang
We have removed the dw_pcie_ops always exists assumption in dwc core driver, we can remove the useless dw_pcie_ops now. Signed-off-by: Jisheng Zhang Acked-by: Jonathan Chocron --- drivers/pci/controller/dwc/pcie-al.c | 4 1 file changed, 4 deletions(-) diff --git a/drivers/pci/controller

[PATCH v3 0/2] PCI: dwc: remove useless dw_pcie_ops

2021-01-27 Thread Jisheng Zhang
: - rebase to the latest dwc-next Jisheng Zhang (2): PCI: dwc: Don't assume the ops in dw_pcie always exists PCI: dwc: al: Remove useless dw_pcie_ops drivers/pci/controller/dwc/pcie-al.c | 4 drivers/pci/controller/dwc/pcie-designware-ep.c | 8 +++- drivers/pci/controller

[PATCH v3 1/2] PCI: dwc: Don't assume the ops in dw_pcie always exists

2021-01-27 Thread Jisheng Zhang
Some designware based device driver especially host only driver may work well with the default read_dbi/write_dbi/link_up implementation in pcie-designware.c, thus remove the assumption to simplify those drivers. Signed-off-by: Jisheng Zhang --- drivers/pci/controller/dwc/pcie-designware-ep.c

[PATCH] mmc: sdhci-of-dwcmshc: fix rpmb access

2020-12-29 Thread Jisheng Zhang
ter is redefined as 32bit block count which doesn't support stuff bits of CMD23 argument. Fixes: a44f7cb93732 ("mmc: core: use mrq->sbc when sending CMD23 for RPMB") Signed-off-by: Jisheng Zhang --- drivers/mmc/host/sdhci-of-dwcmshc.c | 27 +++ 1 file changed,

[PATCH v2] PCI: dwc: Fix MSI not work after resume

2020-12-28 Thread Jisheng Zhang
_init() into core") Signed-off-by: Jisheng Zhang --- Since v1: - rebased on 5.11-rc1 - add Fixes tag drivers/pci/controller/dwc/pcie-designware-host.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controlle

Re: [PATCH v9 2/4] ARM: dts: berlin: Fix schema warnings for pwm-leds

2020-12-28 Thread Jisheng Zhang
On Mon, 28 Dec 2020 17:32:15 +0100 Alexander Dahl wrote: > > The node names for devices using the pwm-leds driver follow a certain > naming scheme (now). Parent node name is not enforced, but recommended > by DT project. > > DTC arch/arm/boot/dts/berlin2cd-google-chromecast.dt.yaml >

Re: [PATCH v1 0/5] Enable fw_devlink=on by default

2020-12-21 Thread Jisheng Zhang
On Thu, 17 Dec 2020 19:16:58 -0800 Saravana Kannan wrote: > > > As discussed in LPC 2020, cyclic dependencies in firmware that couldn't > be broken using logic was one of the last remaining reasons > fw_devlink=on couldn't be set by default. > > This series changes fw_devlink so that when a

  1   2   3   4   5   6   7   8   9   10   >