Re: [PATCH v2 11/13] lkdtm: Fix lkdtm_EXEC_RODATA()

2021-10-17 Thread Christophe Leroy
Le 16/10/2021 à 08:41, Christophe Leroy a écrit : Le 15/10/2021 à 23:32, Kees Cook a écrit : On Thu, Oct 14, 2021 at 07:50:00AM +0200, Christophe Leroy wrote: Behind its location, lkdtm_EXEC_RODATA() executes lkdtm_rodata_do_nothing() which is a real function, not a copy of do_nothing().

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

2021-10-17 Thread Christophe Leroy
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() function but do_nothing() function descriptor which still points to the original text. So at the end it still executes

Re: [V3 0/4] powerpc/perf: Add instruction and data address registers to extended regs

2021-10-17 Thread Michael Ellerman
On Thu, 7 Oct 2021 12:25:01 +0530, Athira Rajeev wrote: > Patch set adds PMU registers namely Sampled Instruction Address Register > (SIAR) and Sampled Data Address Register (SDAR) as part of extended regs > in PowerPC. These registers provides the instruction/data address and > adding these to

Re: [V2] powerpc/perf: Fix cycles/instructions as PM_CYC/PM_INST_CMPL in power10

2021-10-17 Thread Michael Ellerman
On Thu, 7 Oct 2021 13:21:21 +0530, Athira Rajeev wrote: > From: Athira Rajeev > > In power9 and before platforms, the default event used for cyles and > instructions is PM_CYC (0x0001e) and PM_INST_CMPL (0x2) respectively. > These events uses two programmable PMCs and by default will count >

Re: [PATCH] powerpc: Set max_mapnr correctly

2021-10-17 Thread Michael Ellerman
On Tue, 12 Oct 2021 12:40:37 +0200, Christophe Leroy wrote: > max_mapnr is used by virt_addr_valid() to check if a linear > address is valid. > > It must only include lowmem PFNs, like other architectures. > > Problem detected on a system with 1G mem (Only 768M are mapped), with >

[GIT PULL] Please pull powerpc/linux.git powerpc-5.15-4 tag

2021-10-17 Thread Michael Ellerman
-BEGIN PGP SIGNED MESSAGE- Hash: SHA256 Hi Linus, Please pull some more powerpc fixes for 5.15: The following changes since commit eb8257a12192f43ffd41bd90932c39dade958042: pseries/eeh: Fix the kdump kernel crash during eeh_pseries_init (2021-10-07 23:37:22 +1100) are available in

[RFC PATCH] lkdtm: Replace lkdtm_rodata_do_nothing() by do_nothing()

2021-10-17 Thread Christophe Leroy
All EXEC tests are based on running a copy of do_nothing() except lkdtm_EXEC_RODATA which uses a different function called lkdtm_rodata_do_nothing(). On architectures using function descriptors, EXEC tests are performed using execute_location() which is a function that most of the time copies

Re: [PATCH] powerpc/eeh: Fix docstrings in eeh.c

2021-10-17 Thread Michael Ellerman
On Sat, 9 Oct 2021 12:16:30 +0800, Kai Song wrote: > We fix the following warnings when building kernel with W=1: > arch/powerpc/kernel/eeh.c:598: warning: Function parameter or member > 'function' not described in 'eeh_pci_enable' > arch/powerpc/kernel/eeh.c:774: warning: Function parameter or

Re: [PATCH] powerpc/boot: Use CONFIG_PPC_POWERNV to compile OPAL support

2021-10-17 Thread Michael Ellerman
On Mon, 11 Oct 2021 09:03:56 +0200, Cédric Le Goater wrote: > CONFIG_PPC64_BOOT_WRAPPER is selected by CPU_LITTLE_ENDIAN which is > used to compile support for other platforms such as Microwatt. There > is no need for OPAL calls on these. > > Applied to powerpc/next. [1/1] powerpc/boot: Use

[PATCH v3 02/12] powerpc: Use 'struct func_desc' instead of 'struct ppc64_opd_entry'

2021-10-17 Thread Christophe Leroy
'struct ppc64_opd_entry' is somehow redundant with 'struct func_desc', the later is more correct/complete as it includes the third field which is unused. So use 'struct func_desc' instead of 'struct ppc64_opd_entry' Reviewed-by: Kees Cook Reviewed-by: Daniel Axtens Reviewed-by: Nicholas Piggin

[PATCH v3 05/12] ia64: Rename 'ip' to 'addr' in 'struct fdesc'

2021-10-17 Thread Christophe Leroy
There are three architectures with function descriptors, try to have common names for the address they contain in order to refactor some functions into generic functions later. powerpc has 'entry' ia64 has 'ip' parisc has 'addr' Vote for 'addr' and update 'struct fdesc' accordingly.

[PATCH v3 10/12] lkdtm: Really write into kernel text in WRITE_KERN

2021-10-17 Thread Christophe Leroy
WRITE_KERN is supposed to overwrite some kernel text, namely do_overwritten() function. But at the time being it overwrites do_overwritten() function descriptor, not function text. Fix it by dereferencing the function descriptor to obtain function text pointer. And make do_overwritten()

[PATCH v3 03/12] powerpc: Remove 'struct ppc64_opd_entry'

2021-10-17 Thread Christophe Leroy
'struct ppc64_opd_entry' doesn't belong to uapi/asm/elf.h It was initially in module_64.c and commit 2d291e902791 ("Fix compile failure with non modular builds") moved it into asm/elf.h But it was by mistake added outside of __KERNEL__ section, therefore commit c3617f72036c ("UAPI: (Scripted)

[PATCH v3 09/12] lkdtm: Force do_nothing() out of line

2021-10-17 Thread Christophe Leroy
LKDTM tests display that the run do_nothing() at a given address, but in reality do_nothing() is inlined into the caller. Force it out of line so that it really runs text at the displayed address. Acked-by: Kees Cook Signed-off-by: Christophe Leroy --- drivers/misc/lkdtm/perms.c | 4 ++-- 1

[PATCH v3 01/12] powerpc: Move and rename func_descr_t

2021-10-17 Thread Christophe Leroy
There are three architectures with function descriptors, try to have common names for the address they contain in order to refactor some functions into generic functions later. powerpc has 'entry' ia64 has 'ip' parisc has 'addr' Vote for 'addr' and update 'func_descr_t' accordingly. Move it in

Re: [PATCH] powerpc/xive: Discard disabled interrupts in get_irqchip_state()

2021-10-17 Thread Michael Ellerman
On Mon, 11 Oct 2021 09:02:03 +0200, Cédric Le Goater wrote: > When an interrupt is passed through, the KVM XIVE device calls the > set_vcpu_affinity() handler which raises the P bit to mask the > interrupt and to catch any in-flight interrupts while routing the > interrupt to the guest. > > On

Re: [PATCH 1/2] KVM: PPC: Book3S HV: Fix stack handling in idle_kvm_start_guest()

2021-10-17 Thread Michael Ellerman
On Sat, 16 Oct 2021 00:39:28 +1100, Michael Ellerman wrote: > In commit 10d91611f426 ("powerpc/64s: Reimplement book3s idle code in > C") kvm_start_guest() became idle_kvm_start_guest(). The old code > allocated a stack frame on the emergency stack, but didn't use the > frame to store anything,

[PATCH v3 06/12] asm-generic: Define CONFIG_HAVE_FUNCTION_DESCRIPTORS

2021-10-17 Thread Christophe Leroy
Replace HAVE_DEREFERENCE_FUNCTION_DESCRIPTOR by a config option named CONFIG_HAVE_FUNCTION_DESCRIPTORS and use it instead of 'dereference_function_descriptor' macro to know whether an arch has function descriptors. To limit churn in one of the following patches, use an #ifdef/#else construct with

[PATCH v3 08/12] asm-generic: Refactor dereference_[kernel]_function_descriptor()

2021-10-17 Thread Christophe Leroy
dereference_function_descriptor() and dereference_kernel_function_descriptor() are identical on the three architectures implementing them. Make them common and put them out-of-line in kernel/extable.c which is one of the users and has similar type of functions. Reviewed-by: Kees Cook

[PATCH v3 07/12] asm-generic: Define 'func_desc_t' to commonly describe function descriptors

2021-10-17 Thread Christophe Leroy
We have three architectures using function descriptors, each with its own type and name. Add a common typedef that can be used in generic code. Also add a stub typedef for architecture without function descriptors, to avoid a forest of #ifdefs. It replaces the similar 'func_desc_t' previously

[PATCH v3 00/12] Fix LKDTM for PPC64/IA64/PARISC

2021-10-17 Thread Christophe Leroy
PPC64/IA64/PARISC have function descriptors. LKDTM doesn't work on those three architectures because LKDTM messes up function descriptors with functions. This series does some cleanup in the three architectures and refactors function descriptors so that it can then easily use it in a generic way

[PATCH v3 12/12] lkdtm: Add a test for function descriptors protection

2021-10-17 Thread Christophe Leroy
Add WRITE_OPD to check that you can't modify function descriptors. Gives the following result when function descriptors are not protected: lkdtm: Performing direct entry WRITE_OPD lkdtm: attempting bad 16 bytes write at c269b358 lkdtm: FAIL: survived bad write

[PATCH v3 04/12] powerpc: Prepare func_desc_t for refactorisation

2021-10-17 Thread Christophe Leroy
In preparation of making func_desc_t generic, change the ELFv2 version to a struct containing 'addr' element. This allows using single helpers common to ELFv1 and ELFv2. Signed-off-by: Christophe Leroy --- arch/powerpc/kernel/module_64.c | 32 ++-- 1 file changed,

Re: [PATCH 00/13] block: add_disk() error handling stragglers

2021-10-17 Thread Geoff Levand
Hi Luis, On 10/15/21 4:52 PM, Luis Chamberlain wrote: > This patch set consists of al the straggler drivers for which we have > have no patch reviews done for yet. I'd like to ask for folks to please > consider chiming in, specially if you're the maintainer for the driver. > Additionally if you

[PATCH v4 0/2] fix & prevent the missing preemption disabling

2021-10-17 Thread 王贇
The testing show that perf_ftrace_function_call() are using smp_processor_id() with preemption enabled, all the checking on CPU could be wrong after preemption. As Peter point out, the section between ftrace_test_recursion_trylock/unlock() pair require the preemption to be disabled as

Re: [PATCH v3 0/4] Add mem_hops field in perf_mem_data_src structure

2021-10-17 Thread Michael Ellerman
Peter Zijlstra writes: > On Wed, Oct 06, 2021 at 07:36:50PM +0530, Kajol Jain wrote: > >> Kajol Jain (4): >> perf: Add comment about current state of PERF_MEM_LVL_* namespace and >> remove an extra line >> perf: Add mem_hops field in perf_mem_data_src structure >> tools/perf: Add

Re: [GIT PULL] Please pull powerpc/linux.git powerpc-5.15-4 tag

2021-10-17 Thread pr-tracker-bot
The pull request you sent on Sun, 17 Oct 2021 23:36:20 +1100: > https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git > tags/powerpc-5.15-4 has been merged into torvalds/linux.git: https://git.kernel.org/torvalds/c/be9eb2f00fa7245116d49f76614054cce8e07af8 Thank you! --

Re: [PATCH v3 01/12] powerpc: Move and rename func_descr_t

2021-10-17 Thread Nicholas Piggin
Excerpts from Christophe Leroy's message of October 17, 2021 10:38 pm: > There are three architectures with function descriptors, try to > have common names for the address they contain in order to > refactor some functions into generic functions later. > > powerpc has 'entry' > ia64 has 'ip' >

[PATCH v4 1/2] ftrace: disable preemption when recursion locked

2021-10-17 Thread 王贇
As the documentation explained, ftrace_test_recursion_trylock() and ftrace_test_recursion_unlock() were supposed to disable and enable preemption properly, however currently this work is done outside of the function, which could be missing by mistake. And since the internal using of

[PATCH v4 2/2] ftrace: do CPU checking after preemption disabled

2021-10-17 Thread 王贇
With CONFIG_DEBUG_PREEMPT we observed reports like: BUG: using smp_processor_id() in preemptible caller is perf_ftrace_function_call+0x6f/0x2e0 CPU: 1 PID: 680 Comm: a.out Not tainted Call Trace: dump_stack_lvl+0x8d/0xcf check_preemption_disabled+0x104/0x110 ?

[PATCH] powerpc/kexec_file: Add of_node_put() before goto

2021-10-17 Thread Wan Jiabing
Fix following coccicheck warning: ./arch/powerpc/kexec/file_load_64.c:698:1-22: WARNING: Function for_each_node_by_type should have of_node_put() before goto Early exits from for_each_node_by_type should decrement the node reference counter. Signed-off-by: Wan Jiabing ---

[powerpc:fixes-test] BUILD SUCCESS 6c44be1b8e2d8c0161ac39d5d39ea4dff39da71c

2021-10-17 Thread kernel test robot
randconfig-c002-20211017 i386 randconfig-c001-20211017 x86_64 randconfig-c001-20211017 ia64 allmodconfig ia64 allyesconfig nios2 defconfig arc

[powerpc:merge] BUILD SUCCESS ec39a6fbda87af02313146b0c951342749e507af

2021-10-17 Thread kernel test robot
sh7763rdp_defconfig arm u8500_defconfig powerpc tqm8xx_defconfig arm mainstone_defconfig sh r7785rp_defconfig arm randconfig-c002-20211017 i386

[powerpc:next-test] BUILD SUCCESS 84bd5be941806ec9d18a071efa093efc244a3dd9

2021-10-17 Thread kernel test robot
-20211017 i386 randconfig-c001-20211017 x86_64 randconfig-c001-20211017 ia64 allmodconfig ia64 allyesconfig m68k allmodconfig m68k allyesconfig nios2

[powerpc:fixes] BUILD SUCCESS cdeb5d7d890e14f3b70e8087e745c4a6a7d9f337

2021-10-17 Thread kernel test robot
randconfig-c002-20211017 i386 randconfig-c001-20211017 x86_64 randconfig-c001-20211017 ia64 allmodconfig ia64 allyesconfig nios2 defconfig arc