[tip: objtool/core] objtool: Refactor jump table code to support other architectures

2020-09-10 Thread tip-bot2 for Raphael Gault
The following commit has been merged into the objtool/core branch of tip: Commit-ID: d871f7b5a6a2a30f4eba577fd56941fa3657e394 Gitweb: https://git.kernel.org/tip/d871f7b5a6a2a30f4eba577fd56941fa3657e394 Author:Raphael Gault AuthorDate:Fri, 04 Sep 2020 16:30:24 +01:00

Re: [RFC v4 00/18] objtool: Add support for arm64

2019-08-23 Thread Raphael Gault
Hi Josh, On 8/22/19 8:56 PM, Josh Poimboeuf wrote: On Fri, Aug 16, 2019 at 01:23:45PM +0100, Raphael Gault wrote: Hi, Changes since RFC V3: * Rebased on tip/master: Switch/jump table had been refactored * Take Catalin Marinas comments into account regarding the asm macro for marking

[PATCH v4 1/7] perf: arm64: Add test to check userspace access to hardware counters.

2019-08-22 Thread Raphael Gault
cpus in a big.LITTLE environment. Signed-off-by: Raphael Gault --- tools/perf/arch/arm64/include/arch-tests.h | 7 + tools/perf/arch/arm64/tests/Build | 1 + tools/perf/arch/arm64/tests/arch-tests.c | 4 + tools/perf/arch/arm64/tests/user-events.c | 254 + 4

[PATCH v4 4/7] arm64: pmu: Add hook to handle pmu-related undefined instructions

2019-08-22 Thread Raphael Gault
instruction, even if not related to the emulated registers which made the pmu emulation inefficient. Signed-off-by: Raphael Gault --- arch/arm64/kernel/cpufeature.c | 4 +-- arch/arm64/kernel/perf_event.c | 55 ++ 2 files changed, 57 insertions(+), 2 deletions

[PATCH v4 6/7] arm64: perf: Enable pmu counter direct access for perf event on armv8

2019-08-22 Thread Raphael Gault
of the different event opened and de-activate the permissions when all are unmapped. We also need to update the permissions in the context switch code so that tasks keep the right permissions. Signed-off-by: Raphael Gault --- arch/arm64/include/asm/mmu.h | 6 arch/arm64/include/asm

[PATCH v4 7/7] Documentation: arm64: Document PMU counters access from userspace

2019-08-22 Thread Raphael Gault
Add a documentation file to describe the access to the pmu hardware counters from userspace Signed-off-by: Raphael Gault --- .../arm64/pmu_counter_user_access.txt | 42 +++ 1 file changed, 42 insertions(+) create mode 100644 Documentation/arm64

[PATCH v4 2/7] arm64: cpu: Add accessor for boot_cpu_data

2019-08-22 Thread Raphael Gault
Mark boot_cpu_data as read-only after initialization. Define accessor to read boot_cpu_data from outside of boot_cpu_data. Signed-off-by: Raphael Gault --- arch/arm64/include/asm/cpu.h | 2 +- arch/arm64/kernel/cpuinfo.c | 7 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git

[PATCH v4 3/7] arm64: cpufeature: Add feature to detect homogeneous systems

2019-08-22 Thread Raphael Gault
models of CPUs from being hotplugged on, however if such a scenario happens, it will turn off the feature. There is no possibility for the feature to be turned on again by hotplugging off CPUs though. Signed-off-by: Raphael Gault --- arch/arm64/include/asm/cpucaps.h| 3 ++- arch/arm64/include

[PATCH v4 5/7] arm64: pmu: Add function implementation to update event index in userpage.

2019-08-22 Thread Raphael Gault
by the PMU implementation: if no callback is provided, the default behaviour applies, returning 0 as index value. Signed-off-by: Raphael Gault --- arch/arm64/kernel/perf_event.c | 21 + include/linux/perf/arm_pmu.h | 2 ++ 2 files changed, 23 insertions(+) diff --git a/arch

[PATCH v4 0/7] arm64: Enable access to pmu registers by user-space

2019-08-22 Thread Raphael Gault
. The seventh patch adds a short documentation about PMU counters direct access from userspace. [1]: https://lkml.org/lkml/2019/8/20/875 Raphael Gault (7): perf: arm64: Add test to check userspace access to hardware counters. arm64: cpu: Add accessor for boot_cpu_data arm64: cpufeature: Add

[PATCH] arm64: perf_event: Add missing header needed for smp_processor_id()

2019-08-20 Thread Raphael Gault
Acked-by: Mark Rutland Signed-off-by: Raphael Gault --- arch/arm64/kernel/perf_event.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm64/kernel/perf_event.c b/arch/arm64/kernel/perf_event.c index 96e90e270042..24575c0a0065 100644 --- a/arch/arm64/kernel/perf_event.c +++ b/arch

Re: [PATCH v3 2/5] arm64: cpufeature: Add feature to detect heterogeneous systems

2019-08-20 Thread Raphael Gault
Hi Mark, Thank you for your comments. On 8/20/19 4:49 PM, Mark Rutland wrote: On Tue, Aug 20, 2019 at 04:23:17PM +0100, Mark Rutland wrote: Hi Raphael, On Fri, Aug 16, 2019 at 01:59:31PM +0100, Raphael Gault wrote: This feature is required in order to enable PMU counters direct access from

Re: [PATCH v3 4/5] arm64: perf: Enable pmu counter direct access for perf event on armv8

2019-08-19 Thread Raphael Gault
] This patchset was based on linux-next/master and note linus Thanks, -- Raphael Gault

[PATCH v3 2/5] arm64: cpufeature: Add feature to detect heterogeneous systems

2019-08-16 Thread Raphael Gault
This feature is required in order to enable PMU counters direct access from userspace only when the system is homogeneous. This feature checks the model of each CPU brought online and compares it to the boot CPU. If it differs then it is heterogeneous. Signed-off-by: Raphael Gault --- arch

[PATCH v3 1/5] perf: arm64: Add test to check userspace access to hardware counters.

2019-08-16 Thread Raphael Gault
cpus in a big.LITTLE environment. Signed-off-by: Raphael Gault --- tools/perf/arch/arm64/include/arch-tests.h | 7 + tools/perf/arch/arm64/tests/Build | 1 + tools/perf/arch/arm64/tests/arch-tests.c | 4 + tools/perf/arch/arm64/tests/user-events.c | 254 + 4

[PATCH v3 4/5] arm64: perf: Enable pmu counter direct access for perf event on armv8

2019-08-16 Thread Raphael Gault
of the different event opened and de-activate the permissions when all are unmapped. We also need to update the permissions in the context switch code so that tasks keep the right permissions. Signed-off-by: Raphael Gault --- arch/arm64/include/asm/mmu.h | 6 + arch/arm64/include/asm

[PATCH v3 5/5] Documentation: arm64: Document PMU counters access from userspace

2019-08-16 Thread Raphael Gault
Add a documentation file to describe the access to the pmu hardware counters from userspace Signed-off-by: Raphael Gault --- .../arm64/pmu_counter_user_access.txt | 42 +++ 1 file changed, 42 insertions(+) create mode 100644 Documentation/arm64

[PATCH v3 3/5] arm64: pmu: Add function implementation to update event index in userpage.

2019-08-16 Thread Raphael Gault
by the PMU implementation: if no callback is provided, the default behaviour applies, returning 0 as index value. Signed-off-by: Raphael Gault --- arch/arm64/kernel/perf_event.c | 22 ++ include/linux/perf/arm_pmu.h | 2 ++ 2 files changed, 24 insertions(+) diff --git

[PATCH v3 0/5] arm64: Enable access to pmu registers by user-space

2019-08-16 Thread Raphael Gault
access to the hardware counters from userspace when a compatible event is opened using the perf API. The fifth patch adds a short documentation about PMU counters direct access from userspace. Raphael Gault (5): perf: arm64: Add test to check userspace access to hardware counters. arm64

[RFC v4 02/18] objtool: orc: Refactor ORC API for other architectures to implement.

2019-08-16 Thread Raphael Gault
code. Signed-off-by: Raphael Gault --- tools/objtool/Build | 2 - tools/objtool/arch.h| 3 + tools/objtool/arch/x86/Build| 2 + tools/objtool/{ => arch/x86}/orc_dump.c | 4 +- tools/objtool/{ => arch/x86}/orc_gen.c

[RFC v4 16/18] arm64: crypto: Add exceptions for crypto object to prevent stack analysis

2019-08-16 Thread Raphael Gault
to another section or if objtool is tweaked to handle this particular case. Signed-off-by: Raphael Gault --- arch/arm64/crypto/Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/arm64/crypto/Makefile b/arch/arm64/crypto/Makefile index 0435f2a0610e..e2a25919ebaa 100644 --- a/arch

[RFC v4 06/18] objtool: arm64: Adapt the stack frame checks for arm architecture

2019-08-16 Thread Raphael Gault
in a register. The initial stack frame is thus empty when entering a function and 2 push operations are needed to set it up correctly. All the different combinations need to be taken into account. Signed-off-by: Raphael Gault --- tools/objtool/arch.h | 2 + tools/objtool/arch/arm64

[RFC v4 10/18] objtool: arm64: Implement functions to add switch tables alternatives

2019-08-16 Thread Raphael Gault
-by: Raphael Gault --- tools/objtool/arch/arm64/arch_special.c | 132 +- .../objtool/arch/arm64/include/arch_special.h | 10 ++ .../objtool/arch/arm64/include/insn_decode.h | 3 +- tools/objtool/check.c | 6 +- tools/objtool/check.h

[RFC v4 13/18] arm64: sleep: Prevent stack frame warnings from objtool

2019-08-16 Thread Raphael Gault
frames. Signed-off-by: Raphael Gault --- arch/arm64/kernel/sleep.S | 5 + 1 file changed, 5 insertions(+) diff --git a/arch/arm64/kernel/sleep.S b/arch/arm64/kernel/sleep.S index f5b04dd8a710..55c7c099d32c 100644 --- a/arch/arm64/kernel/sleep.S +++ b/arch/arm64/kernel/sleep.S @@ -1,5 +1,6

[RFC v4 09/18] gcc-plugins: objtool: Add plugin to detect switch table on arm64

2019-08-16 Thread Raphael Gault
This plugins comes into play before the final 2 RTL passes of GCC and detects switch-tables that are to be outputed in the ELF and writes information in an "objtool_data" section which will be used by objtool. Signed-off-by: Raphael Gault --- scripts/Makefile.gcc-plugins

[RFC v4 11/18] arm64: alternative: Mark .altinstr_replacement as containing executable instructions

2019-08-16 Thread Raphael Gault
Until now, the section .altinstr_replacement wasn't marked as containing executable instructions on arm64. This patch changes that so that it is coherent with what is done on x86. Signed-off-by: Raphael Gault --- arch/arm64/include/asm/alternative.h | 2 +- 1 file changed, 1 insertion(+), 1

[RFC v4 18/18] objtool: arm64: Enable stack validation for arm64

2019-08-16 Thread Raphael Gault
Signed-off-by: Raphael Gault --- arch/arm64/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 3adcec05b1f6..dc3de85b2502 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -163,6 +163,7 @@ config ARM64 select

[RFC v4 08/18] objtool: Refactor switch-tables code to support other architectures

2019-08-16 Thread Raphael Gault
The way to identify switch-tables and retrieves all the data necessary to handle the different execution branches is not the same on all architecture. In order to be able to add other architecture support, this patch defines arch-dependent functions to process jump-tables. Signed-off-by: Raphael

[RFC v4 14/18] arm64: kvm: Annotate non-standard stack frame functions

2019-08-16 Thread Raphael Gault
Both __guest_entry and __guest_exit functions do not setup a correct stack frame. Because they can be considered as callable functions, even if they are particular cases, we chose to silence the warnings given by objtool by annotating them as non-standard. Signed-off-by: Raphael Gault --- arch

[RFC v4 12/18] arm64: assembler: Add macro to annotate asm function having non standard stack-frame.

2019-08-16 Thread Raphael Gault
Some functions don't have standard stack-frames but are intended this way. In order for objtool to ignore those particular cases we add a macro that enables us to annotate the cases we chose to mark as particular. Signed-off-by: Raphael Gault --- include/linux/frame.h | 19

[RFC v4 17/18] arm64: kernel: Annotate non-standard stack frame functions

2019-08-16 Thread Raphael Gault
Annotate assembler functions which are callable but do not setup a correct stack frame. Signed-off-by: Raphael Gault --- arch/arm64/kernel/hyp-stub.S | 3 +++ arch/arm64/kvm/hyp-init.S| 3 +++ 2 files changed, 6 insertions(+) diff --git a/arch/arm64/kernel/hyp-stub.S b/arch/arm64/kernel

[RFC v4 15/18] arm64: kernel: Add exception on kuser32 to prevent stack analysis

2019-08-16 Thread Raphael Gault
kuser32 being used for compatibility, it contains a32 instructions which are not recognised by objtool when trying to analyse arm64 object files. Thus, we add an exception to skip validation on this particular file. Signed-off-by: Raphael Gault --- arch/arm64/kernel/Makefile | 3 +++ 1 file

[RFC v4 01/18] objtool: Add abstraction for computation of symbols offsets

2019-08-16 Thread Raphael Gault
The jump destination and relocation offset used previously are only reliable on x86_64 architecture. We abstract these computations by calling arch-dependent implementations. Signed-off-by: Raphael Gault --- tools/objtool/arch.h| 6 ++ tools/objtool/arch/x86/decode.c | 11

[RFC v4 03/18] objtool: Move registers and control flow to arch-dependent code

2019-08-16 Thread Raphael Gault
Address). Signed-off-by: Raphael Gault --- tools/objtool/arch/x86/include/arch_special.h | 36 +++ tools/objtool/{ => arch/x86/include}/cfi.h| 0 tools/objtool/check.h | 1 + tools/objtool/special.c | 19 +- 4 fi

[RFC v4 05/18] objtool: special: Adapt special section handling

2019-08-16 Thread Raphael Gault
This patch abstracts the few architecture dependent tests that are perform when handling special section and switch tables. It enables any architecture to ignore a particular CPU feature or not to handle switch tables. Signed-off-by: Raphael Gault --- tools/objtool/arch/arm64/Build

[RFC v4 07/18] objtool: Introduce INSN_UNKNOWN type

2019-08-16 Thread Raphael Gault
be raised if such instructions are uncountered while validating an execution branch. This change doesn't impact the x86 decoding logic since 0 is still used as a way to specify an unknown type, raising the "unknown instruction" warning during the decoding phase still. Signed-off-by: Rapha

[RFC v4 04/18] objtool: arm64: Add required implementation for supporting the aarch64 architecture in objtool.

2019-08-16 Thread Raphael Gault
hvc/smc/svc context switching instructions as nop since we consider that the context is restored correctly. Signed-off-by: Raphael Gault --- tools/objtool/arch.h |7 + tools/objtool/arch/arm64/Build|7 + tools/objtool/arch/arm64/bit_operations.c

[RFC v4 00/18] objtool: Add support for arm64

2019-08-16 Thread Raphael Gault
for arm64. Once we have the base of objtool working the next steps will be to port Peter Z's uaccess validation for arm64. Raphael Gault (18): objtool: Add abstraction for computation of symbols offsets objtool: orc: Refactor ORC API for other architectures to implement. objtool: Move registers

Re: [PATCH v2 0/5] arm64: Enable access to pmu registers by user-space

2019-07-23 Thread Raphael Gault
Hi, Any further comments on this patchset ? Cheers, On 7/5/19 9:55 AM, Raphael Gault wrote: The perf user-space tool relies on the PMU to monitor events. It offers an abstraction layer over the hardware counters since the underlying implementation is cpu-dependent. We want to allow userspace

Re: [RFC V3 00/18] objtool: Add support for arm64

2019-07-10 Thread Raphael Gault
Hi all, Just a gentle ping to see if anyone has comments to make about this version :) On 6/24/19 10:55 AM, Raphael Gault wrote: As of now, objtool only supports the x86_64 architecture but the groundwork has already been done in order to add support for other architectures without too much

Re: [PATCH v2 1/5] perf: arm64: Add test to check userspace access to hardware counters.

2019-07-08 Thread Raphael Gault
Hi Arnaldo, On 7/5/19 3:54 PM, Arnaldo Carvalho de Melo wrote: Em Fri, Jul 05, 2019 at 09:55:37AM +0100, Raphael Gault escreveu: This test relies on the fact that the PMU registers are accessible from userspace. It then uses the perf_event_mmap_page to retrieve the counter index and access

[PATCH v2 1/5] perf: arm64: Add test to check userspace access to hardware counters.

2019-07-05 Thread Raphael Gault
cpus in a big.LITTLE environment. Signed-off-by: Raphael Gault --- tools/perf/arch/arm64/include/arch-tests.h | 6 + tools/perf/arch/arm64/tests/Build | 1 + tools/perf/arch/arm64/tests/arch-tests.c | 4 + tools/perf/arch/arm64/tests/user-events.c | 255 + 4

[PATCH v2 4/5] arm64: perf: Enable pmu counter direct access for perf event on armv8

2019-07-05 Thread Raphael Gault
of the different event opened and de-activate the permissions when all are unmapped. We also need to update the permissions in the context switch code so that tasks keep the right permissions. Signed-off-by: Raphael Gault --- arch/arm64/include/asm/mmu.h | 6 + arch/arm64/include/asm

[PATCH v2 3/5] arm64: pmu: Add function implementation to update event index in userpage.

2019-07-05 Thread Raphael Gault
by the PMU implementation: if no callback is provided, the default behaviour applies, returning 0 as index value. Signed-off-by: Raphael Gault --- arch/arm64/kernel/perf_event.c | 22 ++ include/linux/perf/arm_pmu.h | 2 ++ 2 files changed, 24 insertions(+) diff --git

[PATCH v2 5/5] Documentation: arm64: Document PMU counters access from userspace

2019-07-05 Thread Raphael Gault
Add a documentation file to describe the access to the pmu hardware counters from userspace Signed-off-by: Raphael Gault --- .../arm64/pmu_counter_user_access.txt | 42 +++ 1 file changed, 42 insertions(+) create mode 100644 Documentation/arm64

[PATCH v2 0/5] arm64: Enable access to pmu registers by user-space

2019-07-05 Thread Raphael Gault
reason as above. * Add a cpu feature/capability to detect heterogeneous systems. Raphael Gault (5): perf: arm64: Add test to check userspace access to hardware counters. arm64: cpufeature: Add feature to detect heterogeneous systems arm64: pmu: Add function implementation to update event index

[PATCH v2 2/5] arm64: cpufeature: Add feature to detect heterogeneous systems

2019-07-05 Thread Raphael Gault
-by: Raphael Gault --- arch/arm64/include/asm/cpucaps.h | 3 ++- arch/arm64/kernel/cpufeature.c | 20 arch/arm64/kernel/perf_event.c | 1 + 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/arch/arm64/include/asm/cpucaps.h b/arch/arm64/include/asm/cpucaps.h index

Re: [RFC V3 12/18] arm64: assembler: Add macro to annotate asm function having non standard stack-frame.

2019-07-02 Thread Raphael Gault
Hi, On 7/1/19 3:40 PM, Catalin Marinas wrote: On Mon, Jun 24, 2019 at 10:55:42AM +0100, Raphael Gault wrote: --- a/arch/arm64/include/asm/assembler.h +++ b/arch/arm64/include/asm/assembler.h @@ -752,4 +752,17 @@ USER(\label, icivau, \tmp2)// invalidate I line PoU

Re: [PATCH 3/7] perf: arm64: Use rseq to test userspace access to pmu counters

2019-06-25 Thread Raphael Gault
want to upstream this and have to maintain it afterward. Thanks, -- Raphael Gault

Re: [PATCH 3/7] perf: arm64: Use rseq to test userspace access to pmu counters

2019-06-25 Thread Raphael Gault
Hi Mathieu, Hi Szabolcs, On 6/11/19 8:33 PM, Mathieu Desnoyers wrote: - On Jun 11, 2019, at 6:57 PM, Mark Rutland mark.rutl...@arm.com wrote: Hi Arnaldo, On Tue, Jun 11, 2019 at 11:33:46AM -0300, Arnaldo Carvalho de Melo wrote: Em Tue, Jun 11, 2019 at 01:53:11PM +0100, Raphael Gault

[RFC V3 06/18] objtool: arm64: Adapt the stack frame checks for arm architecture

2019-06-24 Thread Raphael Gault
in a register. The initial stack frame is thus empty when entering a function and 2 push operations are needed to set it up correctly. All the different combinations need to be taken into account. Signed-off-by: Raphael Gault --- tools/objtool/arch.h | 2 + tools/objtool/arch/arm64

[RFC V3 10/18] objtool: arm64: Implement functions to add switch tables alternatives

2019-06-24 Thread Raphael Gault
-by: Raphael Gault --- tools/objtool/arch/arm64/arch_special.c | 142 +- tools/objtool/arch/arm64/decode.c | 2 +- .../objtool/arch/arm64/include/arch_special.h | 10 ++ .../objtool/arch/arm64/include/insn_decode.h | 3 +- tools/objtool/check.c

[RFC V3 04/18] objtool: arm64: Add required implementation for supporting the aarch64 architecture in objtool.

2019-06-24 Thread Raphael Gault
hvc/smc/svc context switching instructions as nop since we consider that the context is restored correctly. Signed-off-by: Raphael Gault --- tools/objtool/arch.h |7 + tools/objtool/arch/arm64/Build|7 + tools/objtool/arch/arm64/bit_operations.c

[RFC V3 02/18] objtool: orc: Refactor ORC API for other architectures to implement.

2019-06-24 Thread Raphael Gault
code. Signed-off-by: Raphael Gault --- tools/objtool/Build | 2 - tools/objtool/arch.h| 3 + tools/objtool/arch/x86/Build| 2 + tools/objtool/{ => arch/x86}/orc_dump.c | 4 +- tools/objtool/{ => arch/x86}/orc_gen.c

[RFC V3 07/18] objtool: Introduce INSN_UNKNOWN type

2019-06-24 Thread Raphael Gault
be raised if such instructions are uncountered while validating an execution branch. This change doesn't impact the x86 decoding logic since 0 is still used as a way to specify an unknown type, raising the "unknown instruction" warning during the decoding phase still. Signed-off-by: Rapha

[RFC V3 05/18] objtool: special: Adapt special section handling

2019-06-24 Thread Raphael Gault
This patch abstracts the few architecture dependent tests that are perform when handling special section and switch tables. It enables any architecture to ignore a particular CPU feature or not to handle switch tables. Signed-off-by: Raphael Gault --- tools/objtool/arch/arm64/Build

[RFC V3 08/18] objtool: Refactor switch-tables code to support other architectures

2019-06-24 Thread Raphael Gault
The way to identify switch-tables and retrieves all the data necessary to handle the different execution branches is not the same on all architecture. In order to be able to add other architecture support, this patch defines arch-dependent functions to process jump-tables. Signed-off-by: Raphael

[RFC V3 03/18] objtool: Move registers and control flow to arch-dependent code

2019-06-24 Thread Raphael Gault
Address). Signed-off-by: Raphael Gault --- tools/objtool/arch/x86/include/arch_special.h | 36 +++ tools/objtool/{ => arch/x86/include}/cfi.h| 0 tools/objtool/check.h | 1 + tools/objtool/special.c | 19 +- 4 fi

[RFC V3 13/18] arm64: sleep: Prevent stack frame warnings from objtool

2019-06-24 Thread Raphael Gault
frames. Signed-off-by: Raphael Gault --- arch/arm64/kernel/sleep.S | 4 1 file changed, 4 insertions(+) diff --git a/arch/arm64/kernel/sleep.S b/arch/arm64/kernel/sleep.S index 3e53ffa07994..eb434525fe82 100644 --- a/arch/arm64/kernel/sleep.S +++ b/arch/arm64/kernel/sleep.S @@ -90,6 +90,7

[RFC V3 09/18] gcc-plugins: objtool: Add plugin to detect switch table on arm64

2019-06-24 Thread Raphael Gault
This plugins comes into play before the final 2 RTL passes of GCC and detects switch-tables that are to be outputed in the ELF and writes information in an "objtool_data" section which will be used by objtool. Signed-off-by: Raphael Gault --- scripts/Makefile.gcc-plugins

[RFC V3 15/18] arm64: kernel: Add exception on kuser32 to prevent stack analysis

2019-06-24 Thread Raphael Gault
kuser32 being used for compatibility, it contains a32 instructions which are not recognised by objtool when trying to analyse arm64 object files. Thus, we add an exception to skip validation on this particular file. Signed-off-by: Raphael Gault --- arch/arm64/kernel/Makefile | 3 +++ 1 file

[RFC V3 16/18] arm64: crypto: Add exceptions for crypto object to prevent stack analysis

2019-06-24 Thread Raphael Gault
to another section or if objtool is tweaked to handle this particular case. Signed-off-by: Raphael Gault --- arch/arm64/crypto/Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/arm64/crypto/Makefile b/arch/arm64/crypto/Makefile index 0435f2a0610e..e2a25919ebaa 100644 --- a/arch

[RFC V3 18/18] objtool: arm64: Enable stack validation for arm64

2019-06-24 Thread Raphael Gault
Signed-off-by: Raphael Gault --- arch/arm64/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index f5eb592b8579..c5fdfb635d3d 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -159,6 +159,7 @@ config ARM64 select

[RFC V3 17/18] arm64: kernel: Annotate non-standard stack frame functions

2019-06-24 Thread Raphael Gault
Annotate assembler functions which are callable but do not setup a correct stack frame. Signed-off-by: Raphael Gault --- arch/arm64/kernel/hyp-stub.S | 2 ++ arch/arm64/kvm/hyp-init.S| 2 ++ 2 files changed, 4 insertions(+) diff --git a/arch/arm64/kernel/hyp-stub.S b/arch/arm64/kernel/hyp

[RFC V3 14/18] arm64: kvm: Annotate non-standard stack frame functions

2019-06-24 Thread Raphael Gault
Both __guest_entry and __guest_exit functions do not setup a correct stack frame. Because they can be considered as callable functions, even if they are particular cases, we chose to silence the warnings given by objtool by annotating them as non-standard. Signed-off-by: Raphael Gault --- arch

[RFC V3 12/18] arm64: assembler: Add macro to annotate asm function having non standard stack-frame.

2019-06-24 Thread Raphael Gault
Some functions don't have standard stack-frames but are intended this way. In order for objtool to ignore those particular cases we add a macro that enables us to annotate the cases we chose to mark as particular. Signed-off-by: Raphael Gault --- arch/arm64/include/asm/assembler.h | 13

[RFC V3 11/18] arm64: alternative: Mark .altinstr_replacement as containing executable instructions

2019-06-24 Thread Raphael Gault
Until now, the section .altinstr_replacement wasn't marked as containing executable instructions on arm64. This patch changes that so that it is coherent with what is done on x86. Signed-off-by: Raphael Gault --- arch/arm64/include/asm/alternative.h | 2 +- 1 file changed, 1 insertion(+), 1

[RFC V3 00/18] objtool: Add support for arm64

2019-06-24 Thread Raphael Gault
/emit_label_before/after. If anyone has some experience with RTL plugins I am all ears for advices. Raphael Gault (18): objtool: Add abstraction for computation of symbols offsets objtool: orc: Refactor ORC API for other architectures to implement. objtool: Move registers and control flow to arch

[RFC V3 01/18] objtool: Add abstraction for computation of symbols offsets

2019-06-24 Thread Raphael Gault
The jump destination and relocation offset used previously are only reliable on x86_64 architecture. We abstract these computations by calling arch-dependent implementations. Signed-off-by: Raphael Gault --- tools/objtool/arch.h| 6 ++ tools/objtool/arch/x86/decode.c | 11

[tip:perf/core] perf tests arm64: Compile tests unconditionally

2019-06-22 Thread tip-bot for Raphael Gault
Commit-ID: 010e3e8fc12b1c13ce19821a11d8930226ebb4b6 Gitweb: https://git.kernel.org/tip/010e3e8fc12b1c13ce19821a11d8930226ebb4b6 Author: Raphael Gault AuthorDate: Tue, 11 Jun 2019 13:53:09 +0100 Committer: Arnaldo Carvalho de Melo CommitDate: Mon, 17 Jun 2019 15:57:16 -0300 perf tests

Re: [PATCH 3/7] perf: arm64: Use rseq to test userspace access to pmu counters

2019-06-13 Thread Raphael Gault
Hi Mathieu, On 6/11/19 8:33 PM, Mathieu Desnoyers wrote: - On Jun 11, 2019, at 6:57 PM, Mark Rutland mark.rutl...@arm.com wrote: Hi Arnaldo, On Tue, Jun 11, 2019 at 11:33:46AM -0300, Arnaldo Carvalho de Melo wrote: Em Tue, Jun 11, 2019 at 01:53:11PM +0100, Raphael Gault escreveu: Add

Re: [RFC V2 00/16] objtool: Add support for Arm64

2019-06-13 Thread Raphael Gault
Hi Josh, On 5/28/19 11:24 PM, Josh Poimboeuf wrote: On Tue, May 21, 2019 at 12:50:57PM +, Raphael Gault wrote: Hi Josh, Thanks for offering your help and sorry for the late answer. My understanding is that a table of offsets is built by GCC, those offsets being scaled by 4 before adding

Re: [PATCH 3/7] perf: arm64: Use rseq to test userspace access to pmu counters

2019-06-13 Thread Raphael Gault
Hi Mathieu, Mark, On 6/11/19 8:33 PM, Mathieu Desnoyers wrote: - On Jun 11, 2019, at 6:57 PM, Mark Rutland mark.rutl...@arm.com wrote: Hi Arnaldo, On Tue, Jun 11, 2019 at 11:33:46AM -0300, Arnaldo Carvalho de Melo wrote: Em Tue, Jun 11, 2019 at 01:53:11PM +0100, Raphael Gault escreveu

[PATCH 2/7] perf: arm64: Add test to check userspace access to hardware counters.

2019-06-11 Thread Raphael Gault
cpus in a big.LITTLE environment. Signed-off-by: Raphael Gault --- tools/perf/arch/arm64/include/arch-tests.h | 6 + tools/perf/arch/arm64/tests/Build | 1 + tools/perf/arch/arm64/tests/arch-tests.c | 4 + tools/perf/arch/arm64/tests/user-events.c | 255 + 4

[PATCH 7/7] Documentation: arm64: Document PMU counters access from userspace

2019-06-11 Thread Raphael Gault
Add a documentation file to describe the access to the pmu hardware counters from userspace Signed-off-by: Raphael Gault --- .../arm64/pmu_counter_user_access.txt | 42 +++ 1 file changed, 42 insertions(+) create mode 100644 Documentation/arm64

[PATCH 6/7] arm64: perf: Enable pmu counter direct access for perf event on armv8

2019-06-11 Thread Raphael Gault
of the different event opened and de-activate the permissions when all are unmapped. We also need to update the permissions in the context switch code so that tasks keep the right permissions. Signed-off-by: Raphael Gault --- arch/arm64/include/asm/mmu.h | 6 + arch/arm64/include/asm

[PATCH 5/7] arm64: pmu: Add hook to handle pmu-related undefined instructions

2019-06-11 Thread Raphael Gault
if not related to the emulated registers which made the pmu emulation inefficient. Signed-off-by: Raphael Gault --- arch/arm64/kernel/cpufeature.c | 4 +-- arch/arm64/kernel/perf_event.c | 55 ++ 2 files changed, 57 insertions(+), 2 deletions(-) diff --git a/arch/arm64

[PATCH 3/7] perf: arm64: Use rseq to test userspace access to pmu counters

2019-06-11 Thread Raphael Gault
did it several times). I ran it once with 1 iterations: `runs: 1, abort: 62.53%, zero: 34.93%, success: 2.54%` Signed-off-by: Raphael Gault --- tools/perf/arch/arm64/include/arch-tests.h| 5 +- tools/perf/arch/arm64/include/rseq-arm64.h| 220 ++ tools/perf/arch

[PATCH 4/7] arm64: pmu: Add function implementation to update event index in userpage.

2019-06-11 Thread Raphael Gault
by the PMU implementation: if no callback is provided, the default behaviour applies, returning 0 as index value. Signed-off-by: Raphael Gault --- arch/arm64/kernel/perf_event.c | 21 + include/linux/perf/arm_pmu.h | 2 ++ 2 files changed, 23 insertions(+) diff --git a/arch

[PATCH 1/7] perf: arm64: Compile tests unconditionally

2019-06-11 Thread Raphael Gault
In order to subsequently add more tests for the arm64 architecture we compile the tests target for arm64 systematically. Signed-off-by: Raphael Gault --- tools/perf/arch/arm64/Build | 2 +- tools/perf/arch/arm64/tests/Build | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff

[PATCH 0/7] arm64: Enable access to pmu registers by user-space

2019-06-11 Thread Raphael Gault
. This is necessary in order to have a coherent behaviour on big.LITTLE environment. The sixth patch put in place callbacks to enable access to the hardware counters from userspace when a compatible event is opened using the perf API. Raphael Gault (7): perf: arm64: Compile tests unconditionally

Re: [RFC 4/7] arm64: pmu: Add function implementation to update event index in userpage.

2019-05-29 Thread Raphael Gault
Hi Peter, On 5/29/19 1:32 PM, Peter Zijlstra wrote: On Wed, May 29, 2019 at 01:25:46PM +0100, Raphael Gault wrote: Hi Robin, Hi Peter, On 5/29/19 11:50 AM, Robin Murphy wrote: On 29/05/2019 11:46, Raphael Gault wrote: Hi Peter, On 5/29/19 10:46 AM, Peter Zijlstra wrote: On Tue, May 28

Re: [RFC 4/7] arm64: pmu: Add function implementation to update event index in userpage.

2019-05-29 Thread Raphael Gault
Hi Robin, Hi Peter, On 5/29/19 11:50 AM, Robin Murphy wrote: On 29/05/2019 11:46, Raphael Gault wrote: Hi Peter, On 5/29/19 10:46 AM, Peter Zijlstra wrote: On Tue, May 28, 2019 at 04:03:17PM +0100, Raphael Gault wrote: +static int armv8pmu_access_event_idx(struct perf_event *event

Re: [RFC 4/7] arm64: pmu: Add function implementation to update event index in userpage.

2019-05-29 Thread Raphael Gault
Hi Peter, On 5/29/19 10:46 AM, Peter Zijlstra wrote: On Tue, May 28, 2019 at 04:03:17PM +0100, Raphael Gault wrote: +static int armv8pmu_access_event_idx(struct perf_event *event) +{ + if (!(event->hw.flags & ARMPMU_EL0_RD_CNTR)) + return 0; + + /* +* W

[RFC 6/7] arm64: perf: Enable pmu counter direct access for perf event on armv8

2019-05-28 Thread Raphael Gault
of the different event opened and de-activate the permissions when all are unmapped. We also need to update the permissions in the context switch code so that tasks keep the right permissions. Signed-off-by: Raphael Gault --- arch/arm64/include/asm/mmu.h | 6 + arch/arm64/include/asm

[RFC 3/7] perf: arm64: Use rseq to test userspace access to pmu counters

2019-05-28 Thread Raphael Gault
did it several times). I ran it once with 1 iterations: `runs: 1, abort: 62.53%, zero: 34.93%, success: 2.54%` Signed-off-by: Raphael Gault --- tools/perf/arch/arm64/include/arch-tests.h| 5 +- tools/perf/arch/arm64/include/rseq-arm64.h| 220 ++ tools/perf/arch

[RFC 5/7] arm64: pmu: Add hook to handle pmu-related undefined instructions

2019-05-28 Thread Raphael Gault
if not related to the emulated registers which made the pmu emulation inefficient. Signed-off-by: Raphael Gault --- arch/arm64/kernel/cpufeature.c | 4 ++-- arch/arm64/kernel/perf_event.c | 41 ++ 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/arch/arm64

[RFC 4/7] arm64: pmu: Add function implementation to update event index in userpage.

2019-05-28 Thread Raphael Gault
by the PMU implementation: if no callback is provided, the default behaviour applies, returning 0 as index value. Signed-off-by: Raphael Gault --- arch/arm64/kernel/perf_event.c | 21 + include/linux/perf/arm_pmu.h | 2 ++ 2 files changed, 23 insertions(+) diff --git a/arch

[RFC 2/7] perf: arm64: Add test to check userspace access to hardware counters.

2019-05-28 Thread Raphael Gault
cpus in a big.LITTLE environment. Signed-off-by: Raphael Gault --- tools/perf/arch/arm64/include/arch-tests.h | 6 + tools/perf/arch/arm64/tests/Build | 1 + tools/perf/arch/arm64/tests/arch-tests.c | 4 + tools/perf/arch/arm64/tests/user-events.c | 255 + 4

[RFC 7/7] Documentation: arm64: Document PMU counters access from userspace

2019-05-28 Thread Raphael Gault
Add a documentation file to describe the access to the pmu hardware counters from userspace Signed-off-by: Raphael Gault --- .../arm64/pmu_counter_user_access.txt | 42 +++ 1 file changed, 42 insertions(+) create mode 100644 Documentation/arm64

[RFC V2 0/7] arm64: Enable access to pmu registers by user-space

2019-05-28 Thread Raphael Gault
if that's indeed not necessary to save it. Changes since V1: Add a test using rseq Raphael Gault (7): perf: arm64: Compile tests unconditionally perf: arm64: Add test to check userspace access to hardware counters. perf: arm64: Use rseq to test userspace access to pmu counters arm64: pmu: Add

[RFC 1/7] perf: arm64: Compile tests unconditionally

2019-05-28 Thread Raphael Gault
In order to subsequently add more tests for the arm64 architecture we compile the tests target for arm64 systematically. Signed-off-by: Raphael Gault --- tools/perf/arch/arm64/Build | 2 +- tools/perf/arch/arm64/tests/Build | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff

Re: [RFC V2 00/16] objtool: Add support for Arm64

2019-05-21 Thread Raphael Gault
, it is needed to find a comparison, which can be optimized out apprently. In that case the end of the array can be found by locating labels pointing to data behind it (which is not 100% safe). On 5/16/19 3:29 PM, Josh Poimboeuf wrote: > On Thu, May 16, 2019 at 11:36:39AM +0100, Raphael Gault wr

Re: [PATCH 4/6] arm64: pmu: Add hook to handle pmu-related undefined instructions

2019-05-17 Thread Raphael Gault
Hi, On 5/17/19 8:10 AM, Peter Zijlstra wrote: > On Thu, May 16, 2019 at 02:21:46PM +0100, Raphael Gault wrote: >> In order to prevent the userspace processes which are trying to access >> the registers from the pmu registers on a big.LITTLE environment we >> introduce a hoo

[PATCH 2/6] perf: arm64: Add test to check userspace access to hardware counters.

2019-05-16 Thread Raphael Gault
cpus in a big.LITTLE environment. Signed-off-by: Raphael Gault --- tools/perf/arch/arm64/include/arch-tests.h | 6 + tools/perf/arch/arm64/tests/Build | 1 + tools/perf/arch/arm64/tests/arch-tests.c | 4 + tools/perf/arch/arm64/tests/user-events.c | 255 + 4

[PATCH 1/6] perf: arm64: Compile tests unconditionally

2019-05-16 Thread Raphael Gault
In order to subsequently add more tests for the arm64 architecture we compile the tests target for arm64 systematically. Signed-off-by: Raphael Gault --- tools/perf/arch/arm64/Build | 2 +- tools/perf/arch/arm64/tests/Build | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff

[PATCH 3/6] arm64: pmu: Add function implementation to update event index in userpage.

2019-05-16 Thread Raphael Gault
In order to be able to access the counter directly for userspace, we need to provide the index of the counter using the userpage. We thus need to override the event_idx function to retrieve and convert the perf_event index to armv8 hardware index. Signed-off-by: Raphael Gault --- arch/arm64

[PATCH 4/6] arm64: pmu: Add hook to handle pmu-related undefined instructions

2019-05-16 Thread Raphael Gault
a SIGILL signal if the permissions are set accordingly. Signed-off-by: Raphael Gault --- arch/arm64/kernel/perf_event.c | 68 ++ 1 file changed, 68 insertions(+) diff --git a/arch/arm64/kernel/perf_event.c b/arch/arm64/kernel/perf_event.c index e6316f99f66b

[PATCH 5/6] arm64: perf: Enable pmu counter direct access for perf event on armv8

2019-05-16 Thread Raphael Gault
of the different event opened and de-activate the permissions when all are unmapped. We also need to update the permissions in the context switch code so that tasks keep the right permissions. Signed-off-by: Raphael Gault --- arch/arm64/include/asm/mmu.h | 6 + arch/arm64/include/asm

[PATCH 6/6] Documentation: arm64: Document PMU counters access from userspace

2019-05-16 Thread Raphael Gault
Add a documentation file to describe the access to the pmu hardware counters from userspace Signed-off-by: Raphael Gault --- .../arm64/pmu_counter_user_access.txt | 42 +++ 1 file changed, 42 insertions(+) create mode 100644 Documentation/arm64

  1   2   >