1. 23 Aug, 2024 15 commits
  2. 22 Aug, 2024 14 commits
  3. 21 Aug, 2024 11 commits
    • Linus Torvalds's avatar
      Merge tag 'platform-drivers-x86-v6.11-4' of... · 872cf28b
      Linus Torvalds authored
      Merge tag 'platform-drivers-x86-v6.11-4' of git://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86
      
      Pull x86 platform driver fixes from Ilpo Järvinen:
      
       - ISST: Fix an error-handling corner case
      
       - platform/surface: aggregator: Minor corner case fix and new HW
         support
      
      * tag 'platform-drivers-x86-v6.11-4' of git://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86:
        platform/x86: ISST: Fix return value on last invalid resource
        platform/surface: aggregator: Fix warning when controller is destroyed in probe
        platform/surface: aggregator_registry: Add support for Surface Laptop 6
        platform/surface: aggregator_registry: Add fan and thermal sensor support for Surface Laptop 5
        platform/surface: aggregator_registry: Add support for Surface Laptop Studio 2
        platform/surface: aggregator_registry: Add support for Surface Laptop Go 3
        platform/surface: aggregator_registry: Add Support for Surface Pro 10
        platform/x86: asus-wmi: Add quirk for ROG Ally X
      872cf28b
    • Linus Torvalds's avatar
      Merge tag 'erofs-for-6.11-rc5-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs · 5c6154ff
      Linus Torvalds authored
      Pull erofs fixes from Gao Xiang:
       "As I mentioned in the merge window pull request, there is a regression
        which could cause system hang due to page migration. The corresponding
        fix landed upstream through MM tree last week (commit 2e6506e1:
        "mm/migrate: fix deadlock in migrate_pages_batch() on large folios"),
        therefore large folios can be safely allowed for compressed inodes and
        stress tests have been running on my fleet for over 20 days without
        any regression. Users have explicitly requested this for months, so
        let's allow large folios for EROFS full cases now for wider testing.
      
        Additionally, there is a fix which addresses invalid memory accesses
        on a failure path triggered by fault injection and two minor cleanups
        to simplify the codebase.
      
        Summary:
      
         - Allow large folios on compressed inodes
      
         - Fix invalid memory accesses if z_erofs_gbuf_growsize() partially
           fails
      
         - Two minor cleanups"
      
      * tag 'erofs-for-6.11-rc5-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs:
        erofs: fix out-of-bound access when z_erofs_gbuf_growsize() partially fails
        erofs: allow large folios for compressed files
        erofs: get rid of check_layout_compatibility()
        erofs: simplify readdir operation
      5c6154ff
    • Alexei Starovoitov's avatar
      Merge branch '__jited-test-tag-to-check-disassembly-after-jit' · 1a437d35
      Alexei Starovoitov authored
      Eduard Zingerman says:
      
      ====================
      __jited test tag to check disassembly after jit
      
      Some of the logic in the BPF jits might be non-trivial.
      It might be useful to allow testing this logic by comparing
      generated native code with expected code template.
      This patch set adds a macro __jited() that could be used for
      test_loader based tests in a following manner:
      
          SEC("tp")
          __arch_x86_64
          __jited("   endbr64")
          __jited("   nopl    (%rax,%rax)")
          __jited("   xorq    %rax, %rax")
          ...
          __naked void some_test(void) { ... }
      
      Also add a test for jit code generated for tail calls handling to
      demonstrate the feature.
      
      The feature uses LLVM libraries to do the disassembly.
      At selftests compilation time Makefile detects if these libraries are
      available. When libraries are not available tests using __jit_x86()
      are skipped.
      Current CI environment does not include llvm development libraries,
      but changes to add these are trivial.
      
      This was previously discussed here:
      https://lore.kernel.org/bpf/20240718205158.3651529-1-yonghong.song@linux.dev/
      
      Patch-set includes a few auxiliary steps:
      - patches #2 and #3 fix a few bugs in test_loader behaviour;
      - patch #4 replaces __regex macro with ability to specify regular
        expressions in __msg and __xlated using "{{" "}}" escapes;
      - patch #8 updates __xlated to match disassembly lines consequently,
        same way as __jited does.
      
      Changes v2->v3:
      - changed macro name from __jit_x86 to __jited with __arch_* to
        specify disassembly arch (Yonghong);
      - __jited matches disassembly lines consequently with "..."
        allowing to skip some number of lines (Andrii);
      - __xlated matches disassembly lines consequently, same as __jited;
      - "{{...}}" regex brackets instead of __regex macro;
      - bug fixes for old commits.
      
      Changes v1->v2:
      - stylistic changes suggested by Yonghong;
      - fix for -Wformat-truncation related warning when compiled with
        llvm15 (Yonghong).
      
      v1: https://lore.kernel.org/bpf/20240809010518.1137758-1-eddyz87@gmail.com/
      v2: https://lore.kernel.org/bpf/20240815205449.242556-1-eddyz87@gmail.com/
      ====================
      
      Link: https://lore.kernel.org/r/20240820102357.3372779-1-eddyz87@gmail.comSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      1a437d35
    • Eduard Zingerman's avatar
      selftests/bpf: validate __xlated same way as __jited · a038eacd
      Eduard Zingerman authored
      Both __xlated and __jited work with disassembly.
      It is logical to have both work in a similar manner.
      
      This commit updates __xlated macro handling in test_loader.c by making
      it expect matches on sequential lines, same way as __jited operates.
      For example:
      
          __xlated("1: *(u64 *)(r10 -16) = r1")      ;; matched on line N
          __xlated("3: r0 = &(void __percpu *)(r0)") ;; matched on line N+1
      
      Also:
      
          __xlated("1: *(u64 *)(r10 -16) = r1")      ;; matched on line N
          __xlated("...")                            ;; not matched
          __xlated("3: r0 = &(void __percpu *)(r0)") ;; mantched on any
                                                     ;; line >= N
      Signed-off-by: default avatarEduard Zingerman <eddyz87@gmail.com>
      Link: https://lore.kernel.org/r/20240820102357.3372779-10-eddyz87@gmail.comSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      a038eacd
    • Eduard Zingerman's avatar
      selftests/bpf: validate jit behaviour for tail calls · e5bdd6a8
      Eduard Zingerman authored
      A program calling sub-program which does a tail call.
      The idea is to verify instructions generated by jit for tail calls:
      - in program and sub-program prologues;
      - for subprogram call instruction;
      - for tail call itself.
      Signed-off-by: default avatarEduard Zingerman <eddyz87@gmail.com>
      Link: https://lore.kernel.org/r/20240820102357.3372779-9-eddyz87@gmail.comSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      e5bdd6a8
    • Eduard Zingerman's avatar
      selftests/bpf: __jited test tag to check disassembly after jit · 7d743e4c
      Eduard Zingerman authored
      Allow to verify jit behaviour by writing tests as below:
      
          SEC("tp")
          __arch_x86_64
          __jited("   endbr64")
          __jited("   nopl    (%rax,%rax)")
          __jited("   xorq    %rax, %rax")
          ...
          __naked void some_test(void)
          {
              asm volatile (... ::: __clobber_all);
          }
      
      Allow regular expressions in patterns, same way as in __msg.
      By default assume that each __jited pattern has to be matched on the
      next consecutive line of the disassembly, e.g.:
      
          __jited("   endbr64")             # matched on line N
          __jited("   nopl    (%rax,%rax)") # matched on line N+1
      
      If match occurs on a wrong line an error is reported.
      To override this behaviour use __jited("..."), e.g.:
      
          __jited("   endbr64")             # matched on line N
          __jited("...")                    # not matched
          __jited("   nopl    (%rax,%rax)") # matched on any line >= N
      Signed-off-by: default avatarEduard Zingerman <eddyz87@gmail.com>
      Link: https://lore.kernel.org/r/20240820102357.3372779-7-eddyz87@gmail.comSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      7d743e4c
    • Eduard Zingerman's avatar
      selftests/bpf: utility function to get program disassembly after jit · b991fc52
      Eduard Zingerman authored
      This commit adds a utility function to get disassembled text for jited
      representation of a BPF program designated by file descriptor.
      Function prototype looks as follows:
      
          int get_jited_program_text(int fd, char *text, size_t text_sz)
      
      Where 'fd' is a file descriptor for the program, 'text' and 'text_sz'
      refer to a destination buffer for disassembled text.
      Output format looks as follows:
      
          18:	77 06                               	ja	L0
          1a:	50                                  	pushq	%rax
          1b:	48 89 e0                            	movq	%rsp, %rax
          1e:	eb 01                               	jmp	L1
          20:	50                                  L0:	pushq	%rax
          21:	50                                  L1:	pushq	%rax
           ^  ^^^^^^^^                             ^  ^^^^^^^^^^^^^^^^^^
           |  binary insn                          |  textual insn
           |  representation                       |  representation
           |                                       |
          instruction offset              inferred local label name
      
      The code and makefile changes are inspired by jit_disasm.c from bpftool.
      Use llvm libraries to disassemble BPF program instead of libbfd to avoid
      issues with disassembly output stability pointed out in [1].
      
      Selftests makefile uses Makefile.feature to detect if LLVM libraries
      are available. If that is not the case selftests build proceeds but
      the function returns -EOPNOTSUPP at runtime.
      
      [1] commit eb9d1acf ("bpftool: Add LLVM as default library for disassembling JIT-ed programs")
      Acked-by: default avatarYonghong Song <yonghong.song@linux.dev>
      Signed-off-by: default avatarEduard Zingerman <eddyz87@gmail.com>
      Link: https://lore.kernel.org/r/20240820102357.3372779-6-eddyz87@gmail.comSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      b991fc52
    • Eduard Zingerman's avatar
      selftests/bpf: replace __regex macro with "{{...}}" patterns · f8d16175
      Eduard Zingerman authored
      Upcoming changes require a notation to specify regular expression
      matches for regular verifier log messages, disassembly of BPF
      instructions, disassembly of jited instructions.
      
      Neither basic nor extended POSIX regular expressions w/o additional
      escaping are good for this role because of wide use of special
      characters in disassembly, for example:
      
          movq -0x10(%rbp), %rax  ;; () are special characters
          cmpq $0x21, %rax        ;; $ is a special character
      
          *(u64 *)(r10 -16) = r1  ;; * and () are special characters
      
      This commit borrows syntax from LLVM's FileCheck utility.
      It replaces __regex macro with ability to embed regular expressions
      in __msg patters using "{{" "}}" pairs for escaping.
      Syntax for __msg patterns:
      
          pattern := (<verbatim text> | regex)*
          regex := "{{" <posix extended regular expression> "}}"
      
      For example, pattern "foo{{[0-9]+}}" matches strings like
      "foo0", "foo007", etc.
      Signed-off-by: default avatarEduard Zingerman <eddyz87@gmail.com>
      Link: https://lore.kernel.org/r/20240820102357.3372779-5-eddyz87@gmail.comSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      f8d16175
    • Eduard Zingerman's avatar
      selftests/bpf: fix to avoid __msg tag de-duplication by clang · f00bb757
      Eduard Zingerman authored
      __msg, __regex and __xlated tags are based on
      __attribute__((btf_decl_tag("..."))) annotations.
      
      Clang de-duplicates such annotations, e.g. the following
      two sequences of tags are identical in final BTF:
      
          /* seq A */            /* seq B */
          __tag("foo")           __tag("foo")
          __tag("bar")           __tag("bar")
          __tag("foo")
      
      Fix this by adding a unique suffix for each tag using __COUNTER__
      pre-processor macro. E.g. here is a new definition for __msg:
      
          #define __msg(msg) \
            __attribute__((btf_decl_tag("comment:test_expect_msg=" XSTR(__COUNTER__) "=" msg)))
      
      Using this definition the "seq A" from example above is translated to
      BTF as follows:
      
          [..] DECL_TAG 'comment:test_expect_msg=0=foo' type_id=X component_idx=-1
          [..] DECL_TAG 'comment:test_expect_msg=1=bar' type_id=X component_idx=-1
          [..] DECL_TAG 'comment:test_expect_msg=2=foo' type_id=X component_idx=-1
      
      Surprisingly, this bug affects a single existing test:
      verifier_spill_fill/old_stack_misc_vs_cur_ctx_ptr,
      where sequence of identical messages was expected in the log.
      
      Fixes: 537c3f66 ("selftests/bpf: add generic BPF program tester-loader")
      Signed-off-by: default avatarEduard Zingerman <eddyz87@gmail.com>
      Link: https://lore.kernel.org/r/20240820102357.3372779-4-eddyz87@gmail.comSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      f00bb757
    • Eduard Zingerman's avatar
      selftests/bpf: correctly move 'log' upon successful match · d0a29cdb
      Eduard Zingerman authored
      Suppose log="foo bar buz" and msg->substr="bar".
      In such case current match processing logic would update 'log' as
      follows: log += strlen(msg->substr); -> log += 3 -> log=" bar".
      However, the intent behind the 'log' update is to make it point after
      the successful match, e.g. to make log=" buz" in the example above.
      
      Fixes: 4ef5d6af ("selftests/bpf: no need to track next_match_pos in struct test_loader")
      Signed-off-by: default avatarEduard Zingerman <eddyz87@gmail.com>
      Link: https://lore.kernel.org/r/20240820102357.3372779-3-eddyz87@gmail.comSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      d0a29cdb
    • Eduard Zingerman's avatar
      selftests/bpf: less spam in the log for message matching · 7d41dad1
      Eduard Zingerman authored
      When running test_loader based tests in the verbose mode each matched
      message leaves a trace in the stderr, e.g.:
      
          ./test_progs -vvv -t ...
          validate_msgs:PASS:expect_msg 0 nsec
          validate_msgs:PASS:expect_msg 0 nsec
          validate_msgs:PASS:expect_msg 0 nsec
          validate_msgs:PASS:expect_msg 0 nsec
          validate_msgs:PASS:expect_msg 0 nsec
      
      This is not very helpful when debugging such tests and clobbers the
      log a lot.
      Signed-off-by: default avatarEduard Zingerman <eddyz87@gmail.com>
      Link: https://lore.kernel.org/r/20240820102357.3372779-2-eddyz87@gmail.comSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      7d41dad1