Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JH7110_VisionFive2_devel: jh7110.dtsi has wrong U-Boot fwenv data pointer #81

Open
strlcat opened this issue Mar 4, 2023 · 7 comments

Comments

@strlcat
Copy link

strlcat commented Mar 4, 2023

At https://doc-en.rvspace.org/VisionFive2/Boot_UG/JH7110_SDK/boot_address_allocation.html
I find that in 16M QSPI, I can reach U-Boot fw env block by reading from

0xF0000	0x10000	U-Boot environment variables

Now,

shows that offset is invalid - it was mistyped and contains extra 0. It shall be defined as:

	data@f0000 {
		reg = <0xf0000 0x10000>;
	};

With this, fw_printenv from Linux succeeds, I can see/edit U-Boot config.

My proposal would also be to define whole QSPI flash:

    partitions {
            compatible = "fixed-partitions";
            #address-cells = <0x01>;    
            #size-cells = <0x01>;       

            spl@0 {
                    reg = <0x00 0x20000>;       
            };

            env@f0000 {
                    reg = <0xf0000 0x10000>;    
            };

            uboot@100000 {
                    reg = <0x100000 0x400000>;  
            };

            bootdata@500000 {           
                    reg = <0x500000 0xb00000>;  
            };

            flashall@0 {
                    reg = <0x00 0x1000000>;     
            };
    };

Especially with flashall, I can read/write whole QSPI if desired.

Please review this. Thank you.

@MichaIng
Copy link

Just linking the related discussion here: https://forum.rvspace.org/t/emmc-boot-though-spi-flash/1320

MichaIng added a commit to MichaIng/linux that referenced this issue Mar 15, 2023
zswap is currently not built, probably due to missing dependency in kernel config.

/dev/mtd2 pointed to a wrong SPI storage address:
https://forum.rvspace.org/t/emmc-boot-though-spi-flash/1320
starfive-tech#81

Signed-off-by: MichaIng <[email protected]>
MichaIng added a commit to MichaIng/linux that referenced this issue Mar 17, 2023
zswap is currently not built, probably due to missing dependency in kernel config.

/dev/mtd2 pointed to a wrong SPI storage address:
https://forum.rvspace.org/t/emmc-boot-though-spi-flash/1320
starfive-tech#81

Signed-off-by: MichaIng <[email protected]>
@MichaIng
Copy link

MichaIng commented Mar 22, 2023

Works perfectly. @electrorys would you mind to open a pull request for this change? At the moment there seems to be no activity regarding reviewing and merging pull requests, probably they are concentrating on mainline integration. However, it cannot hurt.

I'd keep it the minimal correction for now. While it makes generally sense IMO to add all addresses, I'd leave the environment at mtd2 (even that it does not match its logical location after SPL but before U-Boot image), so current guides/instructions floating around and possible existing configs don't get broken.

MichaIng added a commit to MichaIng/linux that referenced this issue Mar 22, 2023
zswap is currently not built, probably due to missing dependency in kernel config.

/dev/mtd2 pointed to a wrong SPI storage address:
https://forum.rvspace.org/t/emmc-boot-though-spi-flash/1320
starfive-tech#81

Signed-off-by: MichaIng <[email protected]>
@strlcat
Copy link
Author

strlcat commented Mar 25, 2023

Hi,

Meh it really took me two days of RTFM to learn how to make my first PR ever. You know, I don't have good git-fu :-)
Please review #91

@MichaIng
Copy link

😄, hopefully you and/or the open source community will benefit from this learning curve. As said

I'd keep it the minimal correction for now.

i.e. the typo correction only, to maximise the chance that it gets merged soon. Then adding the additional areas in a second PR, as this is a matter of discussion, especially when device names change and hence currently published instructions about how to update the bootloader break.

@strlcat
Copy link
Author

strlcat commented Mar 26, 2023

Thanks, I hope aswell 💯
Now you can do whatever you want with it, I don't mind, hopefully this PR will be helpful!

@MichaIng
Copy link

Now you can do whatever you want with it

Just to avoid misunderstanding, I'm not related in any way with StarFive. I just saw your issue here, the related discussion on the rvspace forum, tested data@f00000 => data@f0000 and can verify it is working and without doubt a mandatory bug fix.

So I am not doing anything with this PR, but StarFive are the ones who have to decide whether/what to do with it.

I'm not sure how much efforts StarFive put into reviewing and in case adjusting PRs, so my suggestion to keep it minimal was to eliminate any points which may require discussion and any needs to edit the PR, hence minimising required efforts to merge it and maximising the chance that it will be merged 😉.

@strlcat
Copy link
Author

strlcat commented Mar 26, 2023 via email

MichaIng added a commit to MichaIng/linux that referenced this issue Apr 1, 2023
zswap is currently not built, probably due to missing dependency in kernel config.

/dev/mtd2 pointed to a wrong SPI storage address:
https://forum.rvspace.org/t/emmc-boot-though-spi-flash/1320
starfive-tech#81

Signed-off-by: MichaIng <[email protected]>
MichaIng added a commit to MichaIng/linux that referenced this issue Apr 5, 2023
zswap is currently not built, probably due to missing dependency in kernel config.

/dev/mtd2 pointed to a wrong SPI storage address:
https://forum.rvspace.org/t/emmc-boot-though-spi-flash/1320
starfive-tech#81

Signed-off-by: MichaIng <[email protected]>
MichaIng added a commit to MichaIng/linux that referenced this issue Apr 13, 2023
zswap is currently not built, probably due to missing dependency in kernel config.

/dev/mtd2 pointed to a wrong SPI storage address:
https://forum.rvspace.org/t/emmc-boot-though-spi-flash/1320
starfive-tech#81

Signed-off-by: MichaIng <[email protected]>
MichaIng added a commit to MichaIng/linux that referenced this issue Apr 23, 2023
zswap is currently not built, probably due to missing dependency in kernel config.

/dev/mtd2 pointed to a wrong SPI storage address:
https://forum.rvspace.org/t/emmc-boot-though-spi-flash/1320
starfive-tech#81

Signed-off-by: MichaIng <[email protected]>
MichaIng added a commit to MichaIng/linux that referenced this issue Apr 26, 2023
zswap is currently not built, probably due to missing dependency in kernel config.

/dev/mtd2 pointed to a wrong SPI storage address:
https://forum.rvspace.org/t/emmc-boot-though-spi-flash/1320
starfive-tech#81

Signed-off-by: MichaIng <[email protected]>
MichaIng added a commit to MichaIng/linux that referenced this issue May 1, 2023
zswap is currently not built, probably due to missing dependency in kernel config.

/dev/mtd2 pointed to a wrong SPI storage address:
https://forum.rvspace.org/t/emmc-boot-though-spi-flash/1320
starfive-tech#81

Signed-off-by: MichaIng <[email protected]>
MichaIng added a commit to MichaIng/linux that referenced this issue May 30, 2023
zswap is currently not built, probably due to missing dependency in kernel config.

/dev/mtd2 pointed to a wrong SPI storage address:
https://forum.rvspace.org/t/emmc-boot-though-spi-flash/1320
starfive-tech#81

Signed-off-by: MichaIng <[email protected]>
MichaIng added a commit to MichaIng/linux that referenced this issue Jun 8, 2023
zswap is currently not built, probably due to missing dependency in kernel config.

/dev/mtd2 pointed to a wrong SPI storage address:
https://forum.rvspace.org/t/emmc-boot-though-spi-flash/1320
starfive-tech#81

Signed-off-by: MichaIng <[email protected]>
MichaIng added a commit to MichaIng/linux that referenced this issue Jun 16, 2023
zswap is currently not built, probably due to missing dependency in kernel config.

/dev/mtd2 pointed to a wrong SPI storage address:
https://forum.rvspace.org/t/emmc-boot-though-spi-flash/1320
starfive-tech#81

Signed-off-by: MichaIng <[email protected]>
MichaIng added a commit to MichaIng/linux that referenced this issue Jul 1, 2023
zswap is currently not built, probably due to missing dependency in kernel config.

/dev/mtd2 pointed to a wrong SPI storage address:
https://forum.rvspace.org/t/emmc-boot-though-spi-flash/1320
starfive-tech#81

Signed-off-by: MichaIng <[email protected]>
MichaIng added a commit to MichaIng/linux that referenced this issue Jul 5, 2023
zswap is currently not built, probably due to missing dependency in kernel config.

/dev/mtd2 pointed to a wrong SPI storage address:
https://forum.rvspace.org/t/emmc-boot-though-spi-flash/1320
starfive-tech#81

Signed-off-by: MichaIng <[email protected]>
MichaIng added a commit to MichaIng/linux that referenced this issue Jul 29, 2023
zswap is currently not built, probably due to missing dependency in kernel config.

/dev/mtd2 pointed to a wrong SPI storage address:
https://forum.rvspace.org/t/emmc-boot-though-spi-flash/1320
starfive-tech#81

Signed-off-by: MichaIng <[email protected]>
MichaIng added a commit to MichaIng/linux that referenced this issue Aug 3, 2023
zswap is currently not built, probably due to missing dependency in kernel config.

/dev/mtd2 pointed to a wrong SPI storage address:
https://forum.rvspace.org/t/emmc-boot-though-spi-flash/1320
starfive-tech#81

Signed-off-by: MichaIng <[email protected]>
MichaIng added a commit to MichaIng/linux that referenced this issue Aug 9, 2023
zswap is currently not built, probably due to missing dependency in kernel config.

/dev/mtd2 pointed to a wrong SPI storage address:
https://forum.rvspace.org/t/emmc-boot-though-spi-flash/1320
starfive-tech#81

Signed-off-by: MichaIng <[email protected]>
MichaIng added a commit to MichaIng/linux that referenced this issue Aug 18, 2023
zswap is currently not built, probably due to missing dependency in kernel config.

/dev/mtd2 pointed to a wrong SPI storage address:
https://forum.rvspace.org/t/emmc-boot-though-spi-flash/1320
starfive-tech#81

Signed-off-by: MichaIng <[email protected]>
MichaIng added a commit to MichaIng/linux that referenced this issue Aug 26, 2023
zswap is currently not built, probably due to missing dependency in kernel config.

/dev/mtd2 pointed to a wrong SPI storage address:
https://forum.rvspace.org/t/emmc-boot-though-spi-flash/1320
starfive-tech#81

Signed-off-by: MichaIng <[email protected]>
MichaIng added a commit to MichaIng/linux that referenced this issue Aug 31, 2023
zswap is currently not built, probably due to missing dependency in kernel config.

/dev/mtd2 pointed to a wrong SPI storage address:
https://forum.rvspace.org/t/emmc-boot-though-spi-flash/1320
starfive-tech#81

Signed-off-by: MichaIng <[email protected]>
MichaIng added a commit to MichaIng/linux that referenced this issue Sep 8, 2023
zswap is currently not built, probably due to missing dependency in kernel config.

/dev/mtd2 pointed to a wrong SPI storage address:
https://forum.rvspace.org/t/emmc-boot-though-spi-flash/1320
starfive-tech#81

Signed-off-by: MichaIng <[email protected]>
MichaIng added a commit to MichaIng/linux that referenced this issue Sep 22, 2023
zswap is currently not built, probably due to missing dependency in kernel config.

/dev/mtd2 pointed to a wrong SPI storage address:
https://forum.rvspace.org/t/emmc-boot-though-spi-flash/1320
starfive-tech#81

Signed-off-by: MichaIng <[email protected]>
MichaIng added a commit to MichaIng/linux that referenced this issue Sep 23, 2023
zswap is currently not built, probably due to missing dependency in kernel config.

/dev/mtd2 pointed to a wrong SPI storage address:
https://forum.rvspace.org/t/emmc-boot-though-spi-flash/1320
starfive-tech#81

Signed-off-by: MichaIng <[email protected]>
MichaIng added a commit to MichaIng/linux that referenced this issue Oct 7, 2023
zswap is currently not built, probably due to missing dependency in kernel config.

/dev/mtd2 pointed to a wrong SPI storage address:
https://forum.rvspace.org/t/emmc-boot-though-spi-flash/1320
starfive-tech#81

Signed-off-by: MichaIng <[email protected]>
MichaIng added a commit to MichaIng/linux that referenced this issue Oct 13, 2023
zswap is currently not built, probably due to missing dependency in kernel config.

/dev/mtd2 pointed to a wrong SPI storage address:
https://forum.rvspace.org/t/emmc-boot-though-spi-flash/1320
starfive-tech#81

Signed-off-by: MichaIng <[email protected]>
MichaIng added a commit to MichaIng/linux that referenced this issue Oct 25, 2023
zswap is currently not built, probably due to missing dependency in kernel config.

/dev/mtd2 pointed to a wrong SPI storage address:
https://forum.rvspace.org/t/emmc-boot-though-spi-flash/1320
starfive-tech#81

Signed-off-by: MichaIng <[email protected]>
MichaIng added a commit to MichaIng/linux that referenced this issue Nov 10, 2023
zswap is currently not built, probably due to missing dependency in kernel config.

/dev/mtd2 pointed to a wrong SPI storage address:
https://forum.rvspace.org/t/emmc-boot-though-spi-flash/1320
starfive-tech#81

Signed-off-by: MichaIng <[email protected]>
MichaIng added a commit to MichaIng/linux that referenced this issue Nov 29, 2023
zswap is currently not built, probably due to missing dependency in kernel config.

/dev/mtd2 pointed to a wrong SPI storage address:
https://forum.rvspace.org/t/emmc-boot-though-spi-flash/1320
starfive-tech#81

Signed-off-by: MichaIng <[email protected]>
MichaIng added a commit to MichaIng/linux that referenced this issue Dec 4, 2023
zswap is currently not built, probably due to missing dependency in kernel config.

/dev/mtd2 pointed to a wrong SPI storage address:
https://forum.rvspace.org/t/emmc-boot-though-spi-flash/1320
starfive-tech#81

Signed-off-by: MichaIng <[email protected]>
MichaIng added a commit to MichaIng/linux that referenced this issue Dec 8, 2023
zswap is currently not built, probably due to missing dependency in kernel config.

/dev/mtd2 pointed to a wrong SPI storage address:
https://forum.rvspace.org/t/emmc-boot-though-spi-flash/1320
starfive-tech#81

Signed-off-by: MichaIng <[email protected]>
esmil pushed a commit that referenced this issue Dec 11, 2023
We can see that "Short form of movsx, dst_reg = (s8,s16,s32)src_reg" in
include/linux/filter.h, additionally, for BPF_ALU64 the value of the
destination register is unchanged whereas for BPF_ALU the upper 32 bits
of the destination register are zeroed, so it should clear the upper 32
bits for BPF_ALU.

[root@linux fedora]# echo 1 > /proc/sys/net/core/bpf_jit_enable
[root@linux fedora]# modprobe test_bpf

Before:
test_bpf: #81 ALU_MOVSX | BPF_B jited:1 ret 2 != 1 (0x2 != 0x1)FAIL (1 times)
test_bpf: #82 ALU_MOVSX | BPF_H jited:1 ret 2 != 1 (0x2 != 0x1)FAIL (1 times)

After:
test_bpf: #81 ALU_MOVSX | BPF_B jited:1 6 PASS
test_bpf: #82 ALU_MOVSX | BPF_H jited:1 6 PASS

By the way, the bpf selftest case "./test_progs -t verifier_movsx" can
also be fixed with this patch.

Fixes: f48012f ("LoongArch: BPF: Support sign-extension mov instructions")
Acked-by: Hengqi Chen <[email protected]>
Signed-off-by: Tiezhu Yang <[email protected]>
Signed-off-by: Huacai Chen <[email protected]>
MichaIng added a commit to MichaIng/linux that referenced this issue Dec 15, 2023
zswap is currently not built, probably due to missing dependency in kernel config.

/dev/mtd2 pointed to a wrong SPI storage address:
https://forum.rvspace.org/t/emmc-boot-though-spi-flash/1320
starfive-tech#81

Signed-off-by: MichaIng <[email protected]>
MichaIng added a commit to MichaIng/linux that referenced this issue Dec 22, 2023
zswap is currently not built, probably due to missing dependency in kernel config.

/dev/mtd2 pointed to a wrong SPI storage address:
https://forum.rvspace.org/t/emmc-boot-though-spi-flash/1320
starfive-tech#81

Signed-off-by: MichaIng <[email protected]>
MichaIng added a commit to MichaIng/linux that referenced this issue Dec 23, 2023
zswap is currently not built, probably due to missing dependency in kernel config.

/dev/mtd2 pointed to a wrong SPI storage address:
https://forum.rvspace.org/t/emmc-boot-though-spi-flash/1320
starfive-tech#81

Signed-off-by: MichaIng <[email protected]>
MichaIng added a commit to MichaIng/linux that referenced this issue Jan 7, 2024
zswap is currently not built, probably due to missing dependency in kernel config.

/dev/mtd2 pointed to a wrong SPI storage address:
https://forum.rvspace.org/t/emmc-boot-though-spi-flash/1320
starfive-tech#81

Signed-off-by: MichaIng <[email protected]>
MichaIng added a commit to MichaIng/linux that referenced this issue Jan 19, 2024
zswap is currently not built, probably due to missing dependency in kernel config.

/dev/mtd2 pointed to a wrong SPI storage address:
https://forum.rvspace.org/t/emmc-boot-though-spi-flash/1320
starfive-tech#81

Signed-off-by: MichaIng <[email protected]>
MichaIng added a commit to MichaIng/linux that referenced this issue Jan 28, 2024
zswap is currently not built, probably due to missing dependency in kernel config.

/dev/mtd2 pointed to a wrong SPI storage address:
https://forum.rvspace.org/t/emmc-boot-though-spi-flash/1320
starfive-tech#81

Signed-off-by: MichaIng <[email protected]>
MichaIng added a commit to MichaIng/linux that referenced this issue Feb 23, 2024
zswap is currently not built, probably due to missing dependency in kernel config.

/dev/mtd2 pointed to a wrong SPI storage address:
https://forum.rvspace.org/t/emmc-boot-though-spi-flash/1320
starfive-tech#81

Signed-off-by: MichaIng <[email protected]>
MichaIng added a commit to MichaIng/linux that referenced this issue Mar 1, 2024
zswap is currently not built, probably due to missing dependency in kernel config.

/dev/mtd2 pointed to a wrong SPI storage address:
https://forum.rvspace.org/t/emmc-boot-though-spi-flash/1320
starfive-tech#81

Signed-off-by: MichaIng <[email protected]>
MichaIng added a commit to MichaIng/linux that referenced this issue Mar 9, 2024
zswap is currently not built, probably due to missing dependency in kernel config.

/dev/mtd2 pointed to a wrong SPI storage address:
https://forum.rvspace.org/t/emmc-boot-though-spi-flash/1320
starfive-tech#81

Signed-off-by: MichaIng <[email protected]>
MichaIng added a commit to MichaIng/linux that referenced this issue Mar 27, 2024
zswap is currently not built, probably due to missing dependency in kernel config.

/dev/mtd2 pointed to a wrong SPI storage address:
https://forum.rvspace.org/t/emmc-boot-though-spi-flash/1320
starfive-tech#81

Signed-off-by: MichaIng <[email protected]>
MichaIng added a commit to MichaIng/linux that referenced this issue Apr 13, 2024
zswap is currently not built, probably due to missing dependency in kernel config.

/dev/mtd2 pointed to a wrong SPI storage address:
https://forum.rvspace.org/t/emmc-boot-though-spi-flash/1320
starfive-tech#81

Signed-off-by: MichaIng <[email protected]>
MichaIng added a commit to MichaIng/linux that referenced this issue Apr 18, 2024
zswap is currently not built, probably due to missing dependency in kernel config.

/dev/mtd2 pointed to a wrong SPI storage address:
https://forum.rvspace.org/t/emmc-boot-though-spi-flash/1320
starfive-tech#81

Signed-off-by: MichaIng <[email protected]>
MichaIng added a commit to MichaIng/linux that referenced this issue Apr 29, 2024
zswap is currently not built, probably due to missing dependency in kernel config.

/dev/mtd2 pointed to a wrong SPI storage address:
https://forum.rvspace.org/t/emmc-boot-though-spi-flash/1320
starfive-tech#81

Signed-off-by: MichaIng <[email protected]>
MichaIng added a commit to MichaIng/linux that referenced this issue May 6, 2024
zswap is currently not built, probably due to missing dependency in kernel config.

/dev/mtd2 pointed to a wrong SPI storage address:
https://forum.rvspace.org/t/emmc-boot-though-spi-flash/1320
starfive-tech#81

Signed-off-by: MichaIng <[email protected]>
MichaIng added a commit to MichaIng/linux that referenced this issue May 17, 2024
zswap is currently not built, probably due to missing dependency in kernel config.

/dev/mtd2 pointed to a wrong SPI storage address:
https://forum.rvspace.org/t/emmc-boot-though-spi-flash/1320
starfive-tech#81

Signed-off-by: MichaIng <[email protected]>
MichaIng added a commit to MichaIng/linux that referenced this issue May 29, 2024
zswap is currently not built, probably due to missing dependency in kernel config.

/dev/mtd2 pointed to a wrong SPI storage address:
https://forum.rvspace.org/t/emmc-boot-though-spi-flash/1320
starfive-tech#81

Signed-off-by: MichaIng <[email protected]>
orangecms pushed a commit to orangecms/linux-starfive that referenced this issue Jun 6, 2024
[ Upstream commit fe879bb ]

Current 'bpftool link' command does not show pids, e.g.,
  $ tools/build/bpftool/bpftool link
  ...
  4: tracing  prog 23
        prog_type lsm  attach_type lsm_mac
        target_obj_id 1  target_btf_id 31320

Hack the following change to enable normal libbpf debug output,
#  --- a/tools/bpf/bpftool/pids.c
#  +++ b/tools/bpf/bpftool/pids.c
#  @@ -121,9 +121,9 @@ int build_obj_refs_table(struct hashmap **map, enum bpf_obj_type type)
#          /* we don't want output polluted with libbpf errors if bpf_iter is not
#           * supported
#           */
#  -       default_print = libbpf_set_print(libbpf_print_none);
#  +       /* default_print = libbpf_set_print(libbpf_print_none); */
#          err = pid_iter_bpf__load(skel);
#  -       libbpf_set_print(default_print);
#  +       /* libbpf_set_print(default_print); */

Rerun the above bpftool command:
  $ tools/build/bpftool/bpftool link
  libbpf: prog 'iter': BPF program load failed: Permission denied
  libbpf: prog 'iter': -- BEGIN PROG LOAD LOG --
  0: R1=ctx() R10=fp0
  ; struct task_struct *task = ctx->task; @ pid_iter.bpf.c:69
  0: (79) r6 = *(u64 *)(r1 +8)          ; R1=ctx() R6_w=ptr_or_null_task_struct(id=1)
  ; struct file *file = ctx->file; @ pid_iter.bpf.c:68
  ...
  ; struct bpf_link *link = (struct bpf_link *) file->private_data; @ pid_iter.bpf.c:103
  80: (79) r3 = *(u64 *)(r8 +432)       ; R3_w=scalar() R8=ptr_file()
  ; if (link->type == bpf_core_enum_value(enum bpf_link_type___local, @ pid_iter.bpf.c:105
  81: (61) r1 = *(u32 *)(r3 +12)
  R3 invalid mem access 'scalar'
  processed 39 insns (limit 1000000) max_states_per_insn 0 total_states 3 peak_states 3 mark_read 2
  -- END PROG LOAD LOG --
  libbpf: prog 'iter': failed to load: -13
  ...

The 'file->private_data' returns a 'void' type and this caused subsequent 'link->type'
(insn starfive-tech#81) failed in verification.

To fix the issue, restore the previous BPF_CORE_READ so old kernels can also work.
With this patch, the 'bpftool link' runs successfully with 'pids'.
  $ tools/build/bpftool/bpftool link
  ...
  4: tracing  prog 23
        prog_type lsm  attach_type lsm_mac
        target_obj_id 1  target_btf_id 31320
        pids systemd(1)

Fixes: 44ba7b3 ("bpftool: Use a local copy of BPF_LINK_TYPE_PERF_EVENT in pid_iter.bpf.c")
Signed-off-by: Yonghong Song <[email protected]>
Signed-off-by: Andrii Nakryiko <[email protected]>
Tested-by: Quentin Monnet <[email protected]>
Reviewed-by: Quentin Monnet <[email protected]>
Link: https://lore.kernel.org/bpf/[email protected]
Signed-off-by: Sasha Levin <[email protected]>
MichaIng pushed a commit to MichaIng/linux that referenced this issue Jun 15, 2024
[ Upstream commit fe879bb ]

Current 'bpftool link' command does not show pids, e.g.,
  $ tools/build/bpftool/bpftool link
  ...
  4: tracing  prog 23
        prog_type lsm  attach_type lsm_mac
        target_obj_id 1  target_btf_id 31320

Hack the following change to enable normal libbpf debug output,
#  --- a/tools/bpf/bpftool/pids.c
#  +++ b/tools/bpf/bpftool/pids.c
#  @@ -121,9 +121,9 @@ int build_obj_refs_table(struct hashmap **map, enum bpf_obj_type type)
#          /* we don't want output polluted with libbpf errors if bpf_iter is not
#           * supported
#           */
#  -       default_print = libbpf_set_print(libbpf_print_none);
#  +       /* default_print = libbpf_set_print(libbpf_print_none); */
#          err = pid_iter_bpf__load(skel);
#  -       libbpf_set_print(default_print);
#  +       /* libbpf_set_print(default_print); */

Rerun the above bpftool command:
  $ tools/build/bpftool/bpftool link
  libbpf: prog 'iter': BPF program load failed: Permission denied
  libbpf: prog 'iter': -- BEGIN PROG LOAD LOG --
  0: R1=ctx() R10=fp0
  ; struct task_struct *task = ctx->task; @ pid_iter.bpf.c:69
  0: (79) r6 = *(u64 *)(r1 +8)          ; R1=ctx() R6_w=ptr_or_null_task_struct(id=1)
  ; struct file *file = ctx->file; @ pid_iter.bpf.c:68
  ...
  ; struct bpf_link *link = (struct bpf_link *) file->private_data; @ pid_iter.bpf.c:103
  80: (79) r3 = *(u64 *)(r8 +432)       ; R3_w=scalar() R8=ptr_file()
  ; if (link->type == bpf_core_enum_value(enum bpf_link_type___local, @ pid_iter.bpf.c:105
  81: (61) r1 = *(u32 *)(r3 +12)
  R3 invalid mem access 'scalar'
  processed 39 insns (limit 1000000) max_states_per_insn 0 total_states 3 peak_states 3 mark_read 2
  -- END PROG LOAD LOG --
  libbpf: prog 'iter': failed to load: -13
  ...

The 'file->private_data' returns a 'void' type and this caused subsequent 'link->type'
(insn starfive-tech#81) failed in verification.

To fix the issue, restore the previous BPF_CORE_READ so old kernels can also work.
With this patch, the 'bpftool link' runs successfully with 'pids'.
  $ tools/build/bpftool/bpftool link
  ...
  4: tracing  prog 23
        prog_type lsm  attach_type lsm_mac
        target_obj_id 1  target_btf_id 31320
        pids systemd(1)

Fixes: 44ba7b3 ("bpftool: Use a local copy of BPF_LINK_TYPE_PERF_EVENT in pid_iter.bpf.c")
Signed-off-by: Yonghong Song <[email protected]>
Signed-off-by: Andrii Nakryiko <[email protected]>
Tested-by: Quentin Monnet <[email protected]>
Reviewed-by: Quentin Monnet <[email protected]>
Link: https://lore.kernel.org/bpf/[email protected]
Signed-off-by: Sasha Levin <[email protected]>
MichaIng added a commit to MichaIng/linux that referenced this issue Jul 5, 2024
zswap is currently not built, probably due to missing dependency in kernel config.

/dev/mtd2 pointed to a wrong SPI storage address:
https://forum.rvspace.org/t/emmc-boot-though-spi-flash/1320
starfive-tech#81

Signed-off-by: MichaIng <[email protected]>
MichaIng added a commit to MichaIng/linux that referenced this issue Aug 4, 2024
zswap is currently not built, probably due to missing dependency in kernel config.

/dev/mtd2 pointed to a wrong SPI storage address:
https://forum.rvspace.org/t/emmc-boot-though-spi-flash/1320
starfive-tech#81

Signed-off-by: MichaIng <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants