summaryrefslogtreecommitdiff
path: root/arch (follow)
Commit message (Collapse)AuthorAge
...
* | | z2_plus_defconfig: Disable USFHDavide Garberi2022-07-27
| | | | | | | | | | | | | | | | | | | | | * z2_plus uses MMC so let's remove ufsh because it's unused * z2_row uses ufsh so let's keep that but still not remove MMC because it would give building problems with cnss Signed-off-by: Davide Garberi <dade.garberi@gmail.com>
* | | configs: Enable the correct mach for each boardDavide Garberi2022-07-27
| | | | | | | | | | | | Signed-off-by: Davide Garberi <dade.garberi@gmail.com>
* | | configs: Remove MSM_SMP2P_TESTDavide Garberi2022-07-27
| | | | | | | | | | | | | | | | | | * This config doesn't exist anymore, automatically deleted by savedefconfig Change-Id: I14641c09b28eda7bc00e4072d03a228e539fdd2c
* | | configs: Add initial z2 defconfigsDavide Garberi2022-07-27
| | | | | | | | | | | | | | | | | | * Just a copy of msm-perf_defconfig Signed-off-by: Davide Garberi <dade.garberi@gmail.com>
* | | dts: msm8996: Set default GPU freq to 133MHzdianlujitao2022-07-27
| | | | | | | | | | | | | | | Change-Id: I052dedb6c265cbe222c5e067ee4433f6d2e5b635 Signed-off-by: Davide Garberi <dade.garberi@gmail.com>
* | | dts: msm8996: adjust voltages for newer bootloaderYaroslav Furman2022-07-27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * There were 2 messages in kernel log complaining about these voltages: [ 0.180959] qpnp_regulator_check_constraints: pmi8994_s2: regulator min/max(400000/1015000) constraints do not fit within HW configured min/max(475000/1280000) constraints * and same one about pm8994_s11. * Adjust minimal values to "fit within HW configured min/max" Signed-off-by: Yaroslav Furman <yaro330@gmail.com> Signed-off-by: Davide Garberi <dade.garberi@gmail.com> Change-Id: I145c88fcc6db2e7e87582ecd1e2afa02a58f7332
* | | dts: msm8996: Rewrite msm-bus vectors configurationAngelo G. Del Regno2022-07-27
| | | | | | | | | | | | | | | | | | | | | | | | The new arm-smmu driver in k4.4 wants us to write a full msm-bus configuration, instead of just hooking up to the master bus id and hardcoding the ab/ib bandwidth values. Change-Id: I254dbb2a43460d021a92ce85b5c09b10c6bc0179
* | | dts: zuk: set different charge speeds for Plus and ProYaroslav Furman2022-07-27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * According to ZUK kernel source: https://github.com/davidevinavil/android_kernel_zuk_msm8996_old/commit/bceafed8aeb1b7ae516f67407fb7b136bc8107d5#diff-893ea72906335e989f9ee451000dab2cR206 Z2_plus: uses custom charging driver and only allows 2000mA charging Z2_row: default driver, 2400mA. Signed-off-by: Yaroslav Furman <yaro330@gmail.com> Signed-off-by: Davide Garberi <dade.garberi@gmail.com>
* | | dts: zuk: disable more thermal sensorsYaroslav Furman2022-07-27
| | | | | | | | | | | | | | | | | | | | | They all show either -4 or 0. Signed-off-by: Yaroslav Furman <yaro330@gmail.com> Signed-off-by: Davide Garberi <dade.garberi@gmail.com>
* | | dts: zuk: Disable sensor pa_therm0LibXZR2022-07-27
| | | | | | | | | | | | | | | | | | | | | * This sensor is reporting wrong temps, so let's disable it Signed-off-by: LibXZR <xzr467706992@163.com> Signed-off-by: Davide Garberi <dade.garberi@gmail.com>
* | | dts: zuk: Take out qcom,usbin-vadc propertySubhajeet Muhuri2022-07-27
| | | | | | | | | | | | | | | | | | * It is present in msm8996-mtp.dtsi from LA.UM.7.5.2.r1-03200-8x96.0 tag Change-Id: I7211dfa40ba2f2ea4b000a3e63315faa442aa644
* | | dts: zuk: Update ramoops configuration for 4.4Davide Garberi2022-07-27
| | | | | | | | | | | | | | | Signed-off-by: Davide Garberi <dade.garberi@gmail.com> Change-Id: If7062291f3d23b77918614364a7a04b6727bfd56
* | | dts: zuk: Update the fstab configurationDavide Garberi2022-07-27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Do not mount /system as system-as-root, android 10 does it anyway moving the mount on init * Remove vbmeta since that's needed only for AVB devices * Mount factory as /vendor partition * Use android_system and android_vendor links since those are available for msm8996 Signed-off-by: Davide Garberi <dade.garberi@gmail.com> Change-Id: I8f4093bbc43c2f03c0c3f1bf7bd678ce0e609905
* | | dts: zuk: Remove unused nodedavidevinavil2022-07-27
| | | | | | | | | | | | | | | | | | | | | * These nodes are for zuk edge or for z2_row's hearth rate sensor * We will probably never get this to work because of the blobs dependency on ZUK proprietary apks which are outdated and need a lot of shimming or hex editing, so let's nuke it. Signed-off-by: Davide Garberi <dade.garberi@gmail.com>
* | | dts: zuk: z2_row: properly disable tdm nodesYaroslav Furman2022-07-27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These are used by ZUK's sound driver. fixes: [ 3.315143] msm8996-pinctrl 1010000.pinctrl: pin GPIO_58 already requested by soc:qcom,msm-dai-mi2s:qcom,msm-dai-q6-mi2s-quat; cannot claim for soc:qcom,msm-dai-tdm-quat-rx [ 3.316282] msm8996-pinctrl 1010000.pinctrl: pin GPIO_60 already requested by soc:qcom,msm-dai-mi2s:qcom,msm-dai-q6-mi2s-quat; cannot claim for soc:qcom,msm-dai-tdm-quat-tx OG idea by dmd79: https://github.com/davidevinavil/android_kernel_zuk_msm8996/commit/65d8082eac8a77eaf464d89052bff54bd4df5b91 Signed-off-by: Yaroslav Furman <yaro330@gmail.com> Signed-off-by: Davide Garberi <dade.garberi@gmail.com> Change-Id: I87dfa40d2ed0833e677ed6df8e1bd1e54e5f17f6
* | | dts: zuk: common-sound: Add tdm changesSubhajeet Muhuri2022-07-27
| | | | | | | | | | | | | | | | | | * Needed for 4.4 after CAF adding tdm changes in DTS and sound driver Signed-off-by: Davide Garberi <dade.garberi@gmail.com>
* | | dts: zuk: Update common-soundDavide Garberi2022-07-27
| | | | | | | | | | | | | | | Signed-off-by: Davide Garberi <dade.garberi@gmail.com> Change-Id: I88627aa55435a4a50c287eb43b18db610ed6cdb7
* | | dts: zuk: Rename qpnp-labibb-modeDavide Garberi2022-07-27
| | | | | | | | | | | | | | | | | | | | | * qpnp,qpnp-labibb-mode has become qcom,qpnp-labibb-mode Signed-off-by: Davide Garberi <dade.garberi@gmail.com> Change-Id: I07af53c3784ea95ecdf4461ff6cd60ed2776d263
* | | dts: zuk: Fix volume down and power buttonSubhajeet Muhuri2022-07-27
| | | | | | | | | | | | Signed-off-by: Davide Garberi <dade.garberi@gmail.com>
* | | dts: zuk: Move common delete-node to common fileDavide Garberi2022-07-27
| | | | | | | | | | | | Signed-off-by: Davide Garberi <dade.garberi@gmail.com>
* | | dts: zuk: z2_row: Enable OISdavidevinavil2022-07-27
| | | | | | | | | | | | | | | | | | * Also fix its voltages and add the node to camera@0 Change-Id: I69fe42a3d4c6356f8c8eb72549837b73b3f31590
* | | dts: zuk: Fix some indentation errorsDavide Garberi2022-07-27
| | | | | | | | | | | | Signed-off-by: Davide Garberi <dade.garberi@gmail.com>
* | | dts: zuk: Fix some cclogic and haptics locationsDavide Garberi2022-07-27
| | | | | | | | | | | | | | | | | | * Move out of tlmm_gpio_key, as it is supposed to be Signed-off-by: Davide Garberi <dade.garberi@gmail.com>
* | | DTS: Add zuk device treedd3boh2022-07-27
| | | | | | | | | | | | | | | | | | | | | * A collaboration between faizauthar12 (base) and DD3Boh (some important fixes and adaptations for Oreo caf tag) Signed-off-by: dd3boh <dade.garberi@gmail.com> Signed-off-by: Davide Garberi <dade.garberi@gmail.com>
* | | ARM: dts: msm: Fix quality issue in automotive platformViraja Kommaraju2022-07-27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | GPIO 61 is enabled twice on automotive platform as it is added as part of quat_mi2s device tree entry which is shared between QUAT MI2S and QUAT TDM. To avoid this, update gpio61 SD1 line as new device tree entry. CRs-fixed: 1046464 Change-Id: I216ab6a3cf6890a66bd2450b77bf120a2e7b66b9 Signed-off-by: Viraja Kommaraju <virajak@codeaurora.org> Signed-off-by: Davide Garberi <dade.garberi@gmail.com>
* | | ARM: dts: msm: Fix for GPIO conflict issue on MSM8996 and APQ8096Josh Kirsch2022-07-27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Create individual node for MI2S tert SD1 so that it will only be included in the APQ8096 MDM9x55 I2S targets and not conflict with MSM8996. Also, add fix for pinctrl GPIO issue that was causing the codec read and writes to fail. Add support for QUAT SD1 GPIO. CRs-fixed: 1024729 Change-Id: Ib687057c1a72d0b707eab711d17571bf8b1ff474 Signed-off-by: Josh Kirsch <jkirsch@codeaurora.org> Signed-off-by: Davide Garberi <dade.garberi@gmail.com>
* | | ARM: dts: msm: Add support of speed-bin 3 for MSM8996v3haihez2022-07-27
| | | | | | | | | | | | | | | | | | | | | | | | | | | Add speed-bin 3 to support the fmax of 1.8GHz for perf clusters respectively based on speed bin0. Change-Id: I96d301005c5d00a46dcc20eb321b5552249b84c7 Signed-off-by: Haihe Zhang <haihez@codeaurora.org> Signed-off-by: Davide Garberi <dade.garberi@gmail.com>
* | | arm: DT: MSM8996: Rename vfe_stream_clk for VFE0 and VFE1Angelo G. Del Regno2022-07-27
| | | | | | | | | | | | | | | | | | The vfe_stream_clk was renamed to camss_vfe_stream_clk in k4.4. Signed-off-by: Davide Garberi <dade.garberi@gmail.com>
* | | soc: qcom: Remove now unused MSM_SMP2P_TESTAlbert I2022-07-27
|/ / | | | | | | | | | | | | | | | | All related codes have been removed since commit c457926b166c introduced by LA.UM.7.2.r1-05400-sdm660.0 CAF tag. Signed-off-by: Albert I <krascgq@outlook.co.id> Signed-off-by: Davide Garberi <dade.garberi@gmail.com> Change-Id: I3d8e6ac169e2f2712ae839c6a67f8e288a4511de
* | BACKPORT: ANDROID: Remove xt_qtaguid module from new kernels.Chenbo Feng2022-04-19
| | | | | | | | | | | | | | | | | | | | | | | | For new devices ship with 4.9 kernel, the eBPF replacement should cover all the functionalities of xt_qtaguid and it is safe now to remove this android only module from the kernel. Signed-off-by: Chenbo Feng <fengc@google.com> Signed-off-by: Bruno Martins <bgcngm@gmail.com> Bug: 79938294 Test: kernel build Change-Id: I032aecc048f7349f6a0c5192dd381f286fc7e5bf
* | arm64: bpf: optimize LD_ABS, LD_INDZi Shen Lim2022-04-19
| | | | | | | | | | | | | | | | Remove superfluous stack frame, saving us 3 instructions for every LD_ABS or LD_IND. Signed-off-by: Zi Shen Lim <zlim.lnx@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
* | arm64: bpf: optimize JMP_CALLZi Shen Lim2022-04-19
| | | | | | | | | | | | | | | | Remove superfluous stack frame, saving us 3 instructions for every JMP_CALL. Signed-off-by: Zi Shen Lim <zlim.lnx@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
* | ANDROID: arm64: bpf: implement arch_bpf_jit_check_funcSami Tolvanen2022-04-19
| | | | | | | | | | | | | | | | | | | | Implement arch_bpf_jit_check_func to check that pointers to jited BPF functions are correctly aligned and point to the BPF JIT region. This narrows down the attack surface on the stored pointer. Bug: 140377409 Change-Id: I10c448eda6a8b0bf4c16ee591fc65974696216b9 Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
* | bpf, arm64: fix out of bounds access in tail callDaniel Borkmann2022-04-19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | [ upstream commit 16338a9b3ac30740d49f5dfed81bac0ffa53b9c7 ] I recently noticed a crash on arm64 when feeding a bogus index into BPF tail call helper. The crash would not occur when the interpreter is used, but only in case of JIT. Output looks as follows: [ 347.007486] Unable to handle kernel paging request at virtual address fffb850e96492510 [...] [ 347.043065] [fffb850e96492510] address between user and kernel address ranges [ 347.050205] Internal error: Oops: 96000004 [#1] SMP [...] [ 347.190829] x13: 0000000000000000 x12: 0000000000000000 [ 347.196128] x11: fffc047ebe782800 x10: ffff808fd7d0fd10 [ 347.201427] x9 : 0000000000000000 x8 : 0000000000000000 [ 347.206726] x7 : 0000000000000000 x6 : 001c991738000000 [ 347.212025] x5 : 0000000000000018 x4 : 000000000000ba5a [ 347.217325] x3 : 00000000000329c4 x2 : ffff808fd7cf0500 [ 347.222625] x1 : ffff808fd7d0fc00 x0 : ffff808fd7cf0500 [ 347.227926] Process test_verifier (pid: 4548, stack limit = 0x000000007467fa61) [ 347.235221] Call trace: [ 347.237656] 0xffff000002f3a4fc [ 347.240784] bpf_test_run+0x78/0xf8 [ 347.244260] bpf_prog_test_run_skb+0x148/0x230 [ 347.248694] SyS_bpf+0x77c/0x1110 [ 347.251999] el0_svc_naked+0x30/0x34 [ 347.255564] Code: 9100075a d280220a 8b0a002a d37df04b (f86b694b) [...] In this case the index used in BPF r3 is the same as in r1 at the time of the call, meaning we fed a pointer as index; here, it had the value 0xffff808fd7cf0500 which sits in x2. While I found tail calls to be working in general (also for hitting the error cases), I noticed the following in the code emission: # bpftool p d j i 988 [...] 38: ldr w10, [x1,x10] 3c: cmp w2, w10 40: b.ge 0x000000000000007c <-- signed cmp 44: mov x10, #0x20 // #32 48: cmp x26, x10 4c: b.gt 0x000000000000007c 50: add x26, x26, #0x1 54: mov x10, #0x110 // #272 58: add x10, x1, x10 5c: lsl x11, x2, #3 60: ldr x11, [x10,x11] <-- faulting insn (f86b694b) 64: cbz x11, 0x000000000000007c [...] Meaning, the tests passed because commit ddb55992b04d ("arm64: bpf: implement bpf_tail_call() helper") was using signed compares instead of unsigned which as a result had the test wrongly passing. Change this but also the tail call count test both into unsigned and cap the index as u32. Latter we did as well in 90caccdd8cc0 ("bpf: fix bpf_tail_call() x64 JIT") and is needed in addition here, too. Tested on HiSilicon Hi1616. Result after patch: # bpftool p d j i 268 [...] 38: ldr w10, [x1,x10] 3c: add w2, w2, #0x0 40: cmp w2, w10 44: b.cs 0x0000000000000080 48: mov x10, #0x20 // #32 4c: cmp x26, x10 50: b.hi 0x0000000000000080 54: add x26, x26, #0x1 58: mov x10, #0x110 // #272 5c: add x10, x1, x10 60: lsl x11, x2, #3 64: ldr x11, [x10,x11] 68: cbz x11, 0x0000000000000080 [...] Fixes: ddb55992b04d ("arm64: bpf: implement bpf_tail_call() helper") Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* | bpf, arm64: fix faulty emission of map access in tail callsDaniel Borkmann2022-04-19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | [ Upstream commit d8b54110ee944de522ccd3531191f39986ec20f9 ] Shubham was recently asking on netdev why in arm64 JIT we don't multiply the index for accessing the tail call map by 8. That led me into testing out arm64 JIT wrt tail calls and it turned out I got a NULL pointer dereference on the tail call. The buggy access is at: prog = array->ptrs[index]; if (prog == NULL) goto out; [...] 00000060: d2800e0a mov x10, #0x70 // #112 00000064: f86a682a ldr x10, [x1,x10] 00000068: f862694b ldr x11, [x10,x2] 0000006c: b40000ab cbz x11, 0x00000080 [...] The code triggering the crash is f862694b. x1 at the time contains the address of the bpf array, x10 offsetof(struct bpf_array, ptrs). Meaning, above we load the pointer to the program at map slot 0 into x10. x10 can then be NULL if the slot is not occupied, which we later on try to access with a user given offset in x2 that is the map index. Fix this by emitting the following instead: [...] 00000060: d2800e0a mov x10, #0x70 // #112 00000064: 8b0a002a add x10, x1, x10 00000068: d37df04b lsl x11, x2, #3 0000006c: f86b694b ldr x11, [x10,x11] 00000070: b40000ab cbz x11, 0x00000084 [...] This basically adds the offset to ptrs to the base address of the bpf array we got and we later on access the map with an index * 8 offset relative to that. The tail call map itself is basically one large area with meta data at the head followed by the array of prog pointers. This makes tail calls working again, tested on Cavium ThunderX ARMv8. Fixes: ddb55992b04d ("arm64: bpf: implement bpf_tail_call() helper") Reported-by: Shubham Bansal <illusionist.neo@gmail.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* | perf, events: add non-linear data support for raw recordsDaniel Borkmann2022-04-19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds support for non-linear data on raw records. It extends raw records to have one or multiple fragments that will be written linearly into the ring slot, where each fragment can optionally have a custom callback handler to walk and extract complex, possibly non-linear data. If a callback handler is provided for a fragment, then the new __output_custom() will be used instead of __output_copy() for the perf_output_sample() part. perf_prepare_sample() does all the size calculation only once, so perf_output_sample() doesn't need to redo the same work anymore, meaning real_size and padding will be cached in the raw record. The raw record becomes 32 bytes in size without holes; to not increase it further and to avoid doing unnecessary recalculations in fast-path, we can reuse next pointer of the last fragment, idea here is borrowed from ZERO_OR_NULL_PTR(), which should keep the perf_output_sample() path for PERF_SAMPLE_RAW minimal. This facility is needed for BPF's event output helper as a first user that will, in a follow-up, add an additional perf_raw_frag to its perf_raw_record in order to be able to more efficiently dump skb context after a linear head meta data related to it. skbs can be non-linear and thus need a custom output function to dump buffers. Currently, the skb data needs to be copied twice; with the help of __output_custom() this work only needs to be done once. Future users could be things like XDP/BPF programs that work on different context though and would thus also have a different callback function. The few users of raw records are adapted to initialize their frag data from the raw record itself, no change in behavior for them. The code is based upon a PoC diff provided by Peter Zijlstra [1]. [1] http://thread.gmane.org/gmane.linux.network/421294 Suggested-by: Peter Zijlstra <peterz@infradead.org> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Acked-by: Alexei Starovoitov <ast@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
* | objtool: Add STACK_FRAME_NON_STANDARD() macroJosh Poimboeuf2022-04-19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a new macro, STACK_FRAME_NON_STANDARD(), which is used to denote a function which does something unusual related to its stack frame. Use of the macro prevents objtool from emitting a false positive warning. Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Andy Lutomirski <luto@kernel.org> Cc: Arnaldo Carvalho de Melo <acme@kernel.org> Cc: Bernd Petrovitsch <bernd@petrovitsch.priv.at> Cc: Borislav Petkov <bp@alien8.de> Cc: Chris J Arges <chris.j.arges@canonical.com> Cc: Jiri Slaby <jslaby@suse.cz> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Michal Marek <mmarek@suse.cz> Cc: Namhyung Kim <namhyung@gmail.com> Cc: Pedro Alves <palves@redhat.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: live-patching@vger.kernel.org Link: http://lkml.kernel.org/r/34487a17b23dba43c50941599d47054a9584b219.1456719558.git.jpoimboe@redhat.com Signed-off-by: Ingo Molnar <mingo@kernel.org> Signed-off-by: Chatur27 <jasonbright2709@gmail.com>
* | arm64: bpf_jit_comp: drop artifactAnay Wadhera2022-04-19
| | | | | | | | Signed-off-by: Chatur27 <jasonbright2709@gmail.com>
* | bpf: get rid of pure_initcall dependency to enable jitsDaniel Borkmann2022-04-19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | commit fa9dd599b4dae841924b022768354cfde9affecb upstream. Having a pure_initcall() callback just to permanently enable BPF JITs under CONFIG_BPF_JIT_ALWAYS_ON is unnecessary and could leave a small race window in future where JIT is still disabled on boot. Since we know about the setting at compilation time anyway, just initialize it properly there. Also consolidate all the individual bpf_jit_enable variables into a single one and move them under one location. Moreover, don't allow for setting unspecified garbage values on them. Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Acked-by: Alexei Starovoitov <ast@kernel.org> Signed-off-by: Alexei Starovoitov <ast@kernel.org> [bwh: Backported to 4.9 as dependency of commit 2e4a30983b0f "bpf: restrict access to core bpf sysctls": - Drop change in arch/mips/net/ebpf_jit.c - Drop change to bpf_jit_kallsyms - Adjust filenames, context] Signed-off-by: Ben Hutchings <ben.hutchings@codethink.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Chatur27 <jasonbright2709@gmail.com>
* | arm64: bpf: implement bpf_tail_call() helperZi Shen Lim2022-04-19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add support for JMP_CALL_X (tail call) introduced by commit 04fd61ab36ec ("bpf: allow bpf programs to tail-call other bpf programs"). bpf_tail_call() arguments: ctx - context pointer passed to next program array - pointer to map which type is BPF_MAP_TYPE_PROG_ARRAY index - index inside array that selects specific program to run In this implementation arm64 JIT jumps into callee program after prologue, so callee program reuses the same stack. For tail_call_cnt, we use the callee-saved R26 (which was already saved/restored but previously unused by JIT). With this patch a tail call generates the following code on arm64: if (index >= array->map.max_entries) goto out; 34: mov x10, #0x10 // #16 38: ldr w10, [x1,x10] 3c: cmp w2, w10 40: b.ge 0x0000000000000074 if (tail_call_cnt > MAX_TAIL_CALL_CNT) goto out; tail_call_cnt++; 44: mov x10, #0x20 // #32 48: cmp x26, x10 4c: b.gt 0x0000000000000074 50: add x26, x26, #0x1 prog = array->ptrs[index]; if (prog == NULL) goto out; 54: mov x10, #0x68 // #104 58: ldr x10, [x1,x10] 5c: ldr x11, [x10,x2] 60: cbz x11, 0x0000000000000074 goto *(prog->bpf_func + prologue_size); 64: mov x10, #0x20 // #32 68: ldr x10, [x11,x10] 6c: add x10, x10, #0x20 70: br x10 74: Signed-off-by: Zi Shen Lim <zlim.lnx@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Chatur27 <jasonbright2709@gmail.com>
* | bpf: arm64: remove callee-save registers use for tmp registersYang Shi2022-04-19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In the current implementation of ARM64 eBPF JIT, R23 and R24 are used for tmp registers, which are callee-saved registers. This leads to variable size of JIT prologue and epilogue. The latest blinding constant change prefers to constant size of prologue and epilogue. AAPCS reserves R9 ~ R15 for temp registers which not need to be saved/restored during function call. So, replace R23 and R24 to R10 and R11, and remove tmp_used flag to save 2 instructions for some jited BPF program. CC: Daniel Borkmann <daniel@iogearbox.net> Acked-by: Zi Shen Lim <zlim.lnx@gmail.com> Signed-off-by: Yang Shi <yang.shi@linaro.org> Acked-by: Catalin Marinas <catalin.marinas@arm.com> Acked-by: Daniel Borkmann <daniel@iogearbox.net> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Chatur27 <jasonbright2709@gmail.com>
* | bpf, arm64: add support for constant blindingDaniel Borkmann2022-04-19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds recently added constant blinding helpers into the arm64 eBPF JIT. In the bpf_int_jit_compile() path, requirements are to utilize bpf_jit_blind_constants()/bpf_jit_prog_release_other() pair for rewriting the program into a blinded one, and to map the BPF_REG_AX register to a CPU register. The mapping is on x9. Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Acked-by: Zi Shen Lim <zlim.lnx@gmail.com> Acked-by: Yang Shi <yang.shi@linaro.org> Tested-by: Yang Shi <yang.shi@linaro.org> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Chatur27 <jasonbright2709@gmail.com>
* | arm64: bpf: add extra pass to handle faulty codegenZi Shen Lim2022-04-19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Code generation functions in arch/arm64/kernel/insn.c previously BUG_ON invalid parameters. Following change of that behavior, now we need to handle the error case where AARCH64_BREAK_FAULT is returned. Instead of error-handling on every emit() in JIT, we add a new validation pass at the end of JIT compilation. There's no point in running JITed code at run-time only to trap due to AARCH64_BREAK_FAULT. Instead, we drop this failed JIT compilation and allow the system to gracefully fallback on the BPF interpreter. Signed-off-by: Zi Shen Lim <zlim.lnx@gmail.com> Suggested-by: Alexei Starovoitov <ast@kernel.org> Acked-by: Alexei Starovoitov <ast@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Chatur27 <jasonbright2709@gmail.com>
* | perf/core: Set event's default ::overflow_handler()Wang Nan2022-04-19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Set a default event->overflow_handler in perf_event_alloc() so don't need to check event->overflow_handler in __perf_event_overflow(). Following commits can give a different default overflow_handler. Initial idea comes from Peter: http://lkml.kernel.org/r/20130708121557.GA17211@twins.programming.kicks-ass.net Since the default value of event->overflow_handler is not NULL, existing 'if (!overflow_handler)' checks need to be changed. is_default_overflow_handler() is introduced for this. No extra performance overhead is introduced into the hot path because in the original code we still need to read this handler from memory. A conditional branch is avoided so actually we remove some instructions. Signed-off-by: Wang Nan <wangnan0@huawei.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: <pi3orama@163.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Alexei Starovoitov <ast@kernel.org> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Brendan Gregg <brendan.d.gregg@gmail.com> Cc: He Kuang <hekuang@huawei.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Vince Weaver <vincent.weaver@maine.edu> Cc: Zefan Li <lizefan@huawei.com> Link: http://lkml.kernel.org/r/1459147292-239310-3-git-send-email-wangnan0@huawei.com Signed-off-by: Ingo Molnar <mingo@kernel.org> Signed-off-by: Chatur27 <jasonbright2709@gmail.com>
* | bpf: fix bpf_tail_call() x64 JITAlexei Starovoitov2022-04-19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | [ upstream commit 90caccdd8cc0215705f18b92771b449b01e2474a ] - bpf prog_array just like all other types of bpf array accepts 32-bit index. Clarify that in the comment. - fix x64 JIT of bpf_tail_call which was incorrectly loading 8 instead of 4 bytes - tighten corresponding check in the interpreter to stay consistent The JIT bug can be triggered after introduction of BPF_F_NUMA_NODE flag in commit 96eabe7a40aa in 4.14. Before that the map_flags would stay zero and though JIT code is wrong it will check bounds correctly. Hence two fixes tags. All other JITs don't have this problem. Signed-off-by: Alexei Starovoitov <ast@kernel.org> Fixes: 96eabe7a40aa ("bpf: Allow selecting numa node during map creation") Fixes: b52f00e6a715 ("x86: bpf_jit: implement bpf_tail_call() helper") Acked-by: Daniel Borkmann <daniel@iogearbox.net> Acked-by: Martin KaFai Lau <kafai@fb.com> Reviewed-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Chatur27 <jasonbright2709@gmail.com>
* | perf core: Pass max stack as a perf_callchain_entry contextArnaldo Carvalho de Melo2022-04-19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This makes perf_callchain_{user,kernel}() receive the max stack as context for the perf_callchain_entry, instead of accessing the global sysctl_perf_event_max_stack. Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Alexei Starovoitov <ast@kernel.org> Cc: Brendan Gregg <brendan.d.gregg@gmail.com> Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: He Kuang <hekuang@huawei.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Masami Hiramatsu <mhiramat@kernel.org> Cc: Milian Wolff <milian.wolff@kdab.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Vince Weaver <vincent.weaver@maine.edu> Cc: Wang Nan <wangnan0@huawei.com> Cc: Zefan Li <lizefan@huawei.com> Link: http://lkml.kernel.org/n/tip-kolmn1yo40p7jhswxwrc7rrd@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Chatur27 <jasonbright2709@gmail.com>
* | bpf: prepare bpf_int_jit_compile/bpf_prog_select_runtime apisDaniel Borkmann2022-04-19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Since the blinding is strictly only called from inside eBPF JITs, we need to change signatures for bpf_int_jit_compile() and bpf_prog_select_runtime() first in order to prepare that the eBPF program we're dealing with can change underneath. Hence, for call sites, we need to return the latest prog. No functional change in this patch. Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Acked-by: Alexei Starovoitov <ast@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Chatur27 <jasonbright2709@gmail.com>
* | perf core: Allow setting up max frame stack depth via sysctlArnaldo Carvalho de Melo2022-04-19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The default remains 127, which is good for most cases, and not even hit most of the time, but then for some cases, as reported by Brendan, 1024+ deep frames are appearing on the radar for things like groovy, ruby. And in some workloads putting a _lower_ cap on this may make sense. One that is per event still needs to be put in place tho. The new file is: # cat /proc/sys/kernel/perf_event_max_stack 127 Chaging it: # echo 256 > /proc/sys/kernel/perf_event_max_stack # cat /proc/sys/kernel/perf_event_max_stack 256 But as soon as there is some event using callchains we get: # echo 512 > /proc/sys/kernel/perf_event_max_stack -bash: echo: write error: Device or resource busy # Because we only allocate the callchain percpu data structures when there is a user, which allows for changing the max easily, its just a matter of having no callchain users at that point. Reported-and-Tested-by: Brendan Gregg <brendan.d.gregg@gmail.com> Reviewed-by: Frederic Weisbecker <fweisbec@gmail.com> Acked-by: Alexei Starovoitov <ast@kernel.org> Acked-by: David Ahern <dsahern@gmail.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: He Kuang <hekuang@huawei.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Masami Hiramatsu <mhiramat@kernel.org> Cc: Milian Wolff <milian.wolff@kdab.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Vince Weaver <vincent.weaver@maine.edu> Cc: Wang Nan <wangnan0@huawei.com> Cc: Zefan Li <lizefan@huawei.com> Link: http://lkml.kernel.org/r/20160426002928.GB16708@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Chatur27 <jasonbright2709@gmail.com> Change-Id: Ic34ecdb4cc1e61257a2926062aa23c960dbd3b8f
* | perf: generalize perf_callchainAlexei Starovoitov2022-04-19
| | | | | | | | | | | | | | | | | | . avoid walking the stack when there is no room left in the buffer . generalize get_perf_callchain() to be called from bpf helper Signed-off-by: Alexei Starovoitov <ast@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Chatur27 <jasonbright2709@gmail.com>
* | soreuseport: setsockopt SO_ATTACH_REUSEPORT_[CE]BPFCraig Gallek2022-04-19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Expose socket options for setting a classic or extended BPF program for use when selecting sockets in an SO_REUSEPORT group. These options can be used on the first socket to belong to a group before bind or on any socket in the group after bind. This change includes refactoring of the existing sk_filter code to allow reuse of the existing BPF filter validation checks. Signed-off-by: Craig Gallek <kraig@google.com> Acked-by: Alexei Starovoitov <ast@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Chatur27 <jasonbright2709@gmail.com> Change-Id: I4433dfd5d865bb69e8d3cab55cc68325829e8b49