[PATCH 2/2] treewide: mark linker list elements with __ll_elem

2024-01-03 Thread Ahmad Fatoum
To fix build with clang while using ASAN, define all linker list elements with __ll_elem. Signed-off-by: Ahmad Fatoum --- drivers/clk/clk.c| 3 +- include/command.h| 4 +-- include/deep-probe.h | 3 +- include/image-metadata.h | 4 +-- include/init.h | 60

[PATCH 1/2] compiler: define __ll_elem for linker list elements

2024-01-03 Thread Ahmad Fatoum
When built with clang + AddressSanitizer, global variables end up with a redzone that breaks linker list elements. The __no_sanitize_address attribute prevents these redzones, but GCC isn't happy about applying it to anything but functions. Therefore define a __ll_elem macro for defining linker

[PATCH 0/2] compiler: fix clang and address sanitizer coexistance

2024-01-03 Thread Ahmad Fatoum
When built with clang + AddressSanitizer, global variables end up with a redzone that can break linker list elements. As clang isn't officially supported (yet), this can go into next. Ahmad Fatoum (2): compiler: define __ll_elem for linker list elements treewide: mark linker list elements

Re: [PATCH 1/4] ARM: boards: i.MX8M: add HAB support

2024-01-03 Thread Sascha Hauer
On Tue, Jan 02, 2024 at 12:01:15PM +0100, Marco Felsch wrote: > The gencsf header is required to build HAB (secure-boot) compatible > images. This commit add the support for this for all i.MX8M boards. > > To finally build HAB compatible images the CONFIG_HABV4 and > CONFIG_HABV4_IMAGE_SIGNED

[PATCH master 2/3] test: self: regulator: depend on REGULATOR_FIXED for test

2024-01-03 Thread Ahmad Fatoum
The regulator self test requires fixed regulator support, which itself already requires REGULATOR && OFDEVICE, which we already depend on. Therefore, just add REGULATOR_FIXED as dependency. Signed-off-by: Ahmad Fatoum --- test/self/Kconfig | 4 ++-- 1 file changed, 2 insertions(+), 2

[PATCH master 1/3] test: self: ramfs: fix null pointer dereference on error

2024-01-03 Thread Ahmad Fatoum
expect_success is meant for return values of functions that return negative error codes and as such compares the first argument to be zero or greater, which means PTR_ERR_OR_ZERO will treat NULL pointers as valid all the same leading to NULL pointer dereferences should the test fail instead of a

[PATCH master] virtio: pci: don't re-enable with 0 as argument

2024-01-03 Thread Ahmad Fatoum
Qemu prints an error during barebox shutdown when virtio-net was used: qemu-system-aarch64: wrong value for queue_enable 0 This warning was added a few years back in Qemu commit 10d35e5819: | virtio-pci: fix queue_enable write | | Spec said: The driver uses this to selectively prevent the

[PATCH master] lib: stackprotector: adjust Kconfig text for barebox

2024-01-03 Thread Ahmad Fatoum
The reference to kernel panic is taken from the original Linux Kconfig help text. Leaving it as-is may be confusing, so adjust it for barebox. Signed-off-by: Ahmad Fatoum --- lib/Kconfig.hardening | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Kconfig.hardening

[PATCH master] ARM: kasan: reserve shadow memory region

2024-01-03 Thread Ahmad Fatoum
We did not have any protection in place to ensure that KASAN shadow memory isn't overwritten during boot. Add that now to avoid strange effects during debugging. Signed-off-by: Ahmad Fatoum --- arch/arm/cpu/start.c | 4 1 file changed, 4 insertions(+) diff --git a/arch/arm/cpu/start.c

[PATCH master 3/3] test: self: mmu: fix message on skipping tests

2024-01-03 Thread Ahmad Fatoum
The message currently reads: "skipping CONFIG_ARCH_HAS_DATA_ABORT_MASK because test_zero_page=n\n" when it should be the other way round. Fix that. Signed-off-by: Ahmad Fatoum --- test/self/mmu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/self/mmu.c

[PATCH 2/2] cdev: add cdev_alloc helper for creating cdevs

2024-01-03 Thread Ahmad Fatoum
We have different helpers for creating cdevs, depending on whether they are loop devices, partitions or links. Create a common cdev_alloc function, so it's easier to instrument cdev creation during debugging. Signed-off-by: Ahmad Fatoum --- fs/devfs-core.c | 21 +++-- 1 file

[PATCH 1/2] cdev: simplify loop in cdev_by_device_node

2024-01-03 Thread Ahmad Fatoum
We don't need to compare the cdev's device node pointer both against NULL and against the searched for device node on each iteration. Instead, it's sufficient to just compare the device nodes directly. To maintain previous behavior, when searching for a NULL device node, we shouldn't return the

[PATCH 6/6] cdev: delete partitions when deleting master cdev

2024-01-03 Thread Ahmad Fatoum
blockdevice_unregister only calls devfs_remove on the root cdev and leaves the partition cdevs dangling. This doesn't break until the block device parent struct device is freed at which time, it will iterate over its cdevs to free them. If there's partitions there, list_del on the partitions

[PATCH 3/6] cdev: export cdevfs_add_partition for general use

2024-01-03 Thread Ahmad Fatoum
__devfs_add_partition was added, so it can internally be used by functions that already have a cdev and don't require looking it up first by file path. This is useful elsewhere as well, so give it a less internal-sounding name and start exporting it. Signed-off-by: Ahmad Fatoum ---

[PATCH 1/6] cdev: make __devfs_add_partition's last argument optional

2024-01-03 Thread Ahmad Fatoum
Follow-up commit will expose __devfs_add_partition after rename to more users. Most of these don't care about the last parameter, so accept NULL to indicate that it won't be read back. Signed-off-by: Ahmad Fatoum --- fs/devfs-core.c | 14 -- 1 file changed, 8 insertions(+), 6

[PATCH 0/6] cdev: delete partitions when deleting master cdev

2024-01-03 Thread Ahmad Fatoum
blockdevice_unregister only calls devfs_remove on the root cdev and leaves the partition cdevs dangling. This doesn't break until the block device parent struct device is freed at which time, it will iterate over its cdevs to free them. If there's partitions there, list_del on the partitions

[PATCH 2/6] driver.h: move devfs_add/del_partition later in file

2024-01-03 Thread Ahmad Fatoum
This groups the function with similar functions and prepares adding variants that take a struct devfs_partition argument, as that's only defined later. Signed-off-by: Ahmad Fatoum --- include/driver.h | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/driver.h

[PATCH 5/6] cdev: export and use cdevfs_del_partition

2024-01-03 Thread Ahmad Fatoum
Like what's the case with cdevfs_add_partition, a couple of users already have a cdev, so it's wasteful to get its name and do a lookup only to arrive at the same cdev. Export a cdevfs_del_partition that directly works on the cdev and start using it instead. Signed-off-by: Ahmad Fatoum ---

[PATCH 4/6] partition: switch to using cdevfs_add_partition

2024-01-03 Thread Ahmad Fatoum
We already have a cdev, so it's wasteful to do a lookup by cdev name using devfs_add_partition. Use the newly exported cdevfs_add_partition helper directly instead. Signed-off-by: Ahmad Fatoum --- common/partitions.c| 12 drivers/of/partition.c | 16 2 files

[PATCH] MIPS: qemu-malta*_defconfig: enable e1000 network driver

2024-01-03 Thread Antony Pavlov
Thanks to Denis Orlov's work on dma_sync_single_for_*() interface and e1000 patches we can enable e1000 support on both 32-bit and 64-bit qemu malta boards. 32-bit malta qemu command line: qemu-system-mips -M malta -cpu 24Kf -m 256M \ -nographic -serial mon:stdio \ -bios

[PATCH 1/2] list: rename debugging hooks

2024-01-03 Thread Ahmad Fatoum
Linux recently renamed the name of these helpers, so have barebox follow suit before implementing them out of line when optional list debugging is enabled. Signed-off-by: Ahmad Fatoum --- include/linux/list.h | 20 ++-- 1 file changed, 10 insertions(+), 10 deletions(-) diff

[PATCH 2/2] lib: add optional linked list debugging

2024-01-03 Thread Ahmad Fatoum
When enabled, this outputs messages like: list_del corruption, 5fe4a9d0->next is LIST_POISON1 (0100) which can be useful when debugging. Signed-off-by: Ahmad Fatoum --- common/Kconfig| 8 + include/linux/bug.h | 17 +++ lib/Kconfig.hardening | 10

Re: [PATCH master] crypto: caam - remove overly verbose debug print

2024-01-03 Thread Sascha Hauer
On Tue, Jan 02, 2024 at 05:55:37PM +0100, Ahmad Fatoum wrote: > We can already read /dev/hwrng to get the randomness as generated by the > device. Printing 32K bytes of randomness to the log (or even worse to > console) is just not useful for debugging. There are debug prints for > the job

Re: [PATCH master] lib: stackprotector: adjust Kconfig text for barebox

2024-01-03 Thread Sascha Hauer
On Wed, Jan 03, 2024 at 11:13:24AM +0100, Ahmad Fatoum wrote: > The reference to kernel panic is taken from the original Linux Kconfig > help text. Leaving it as-is may be confusing, so adjust it for barebox. > > Signed-off-by: Ahmad Fatoum > --- > lib/Kconfig.hardening | 4 ++-- > 1 file

Re: [PATCH master 1/3] test: self: ramfs: fix null pointer dereference on error

2024-01-03 Thread Sascha Hauer
On Wed, Jan 03, 2024 at 11:13:42AM +0100, Ahmad Fatoum wrote: > expect_success is meant for return values of functions that return > negative error codes and as such compares the first argument to be > zero or greater, which means PTR_ERR_OR_ZERO will treat NULL pointers as > valid all the same

Re: [PATCH master] virtio: pci: don't re-enable with 0 as argument

2024-01-03 Thread Sascha Hauer
On Wed, Jan 03, 2024 at 11:13:54AM +0100, Ahmad Fatoum wrote: > Qemu prints an error during barebox shutdown when virtio-net was used: > > qemu-system-aarch64: wrong value for queue_enable 0 > > This warning was added a few years back in Qemu commit 10d35e5819: > > | virtio-pci: fix

Re: [PATCH 2/2] net: Add fsl_enetc network driver support

2024-01-03 Thread Ahmad Fatoum
Hello Sascha, On 03.01.24 15:51, Sascha Hauer wrote: > +static int enetc_ls1028a_write_hwaddr(struct eth_device *edev, const > unsigned char *mac) > +{ > + struct enetc_priv *priv = edev->priv; > + struct pci_dev *pdev = to_pci_dev(priv->dev); > + const int devfn_to_pf[] = {0, 1, 2,

[PATCH 2/2] net: Add fsl_enetc network driver support

2024-01-03 Thread Sascha Hauer
This adds support for the fsl_enetc network controller found on several Layerscape SoCs. The code is originally from U-Boot-2023.10-rc1. Signed-off-by: Sascha Hauer --- drivers/net/Kconfig | 9 + drivers/net/Makefile | 1 + drivers/net/fsl_enetc.c | 602

[PATCH 1/2] net/phy: sync phy_interface_t types with Linux

2024-01-03 Thread Sascha Hauer
This syncs the phy interface modes with Linux as of linux-6.7-rc7. Signed-off-by: Sascha Hauer --- include/linux/phy.h | 55 + 1 file changed, 51 insertions(+), 4 deletions(-) diff --git a/include/linux/phy.h b/include/linux/phy.h index

Re: [PATCH master] ARM: kasan: reserve shadow memory region

2024-01-03 Thread Sascha Hauer
On Wed, Jan 03, 2024 at 11:13:08AM +0100, Ahmad Fatoum wrote: > We did not have any protection in place to ensure that KASAN shadow memory > isn't overwritten during boot. Add that now to avoid strange effects > during debugging. > > Signed-off-by: Ahmad Fatoum > --- > arch/arm/cpu/start.c | 4

[PATCH 2/2] common: Kconfig: TIMESTAMP: fix help

2024-01-03 Thread Antony Pavlov
At the moment CONFIG_TIMESTAMP help text is inherited from U-Boot. Fix it in accordance with barebox realities. Signed-off-by: Antony Pavlov --- common/Kconfig | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/common/Kconfig b/common/Kconfig index

[PATCH 0/2] uImage fixes

2024-01-03 Thread Antony Pavlov
Antony Pavlov (2): uImage: use IS_ENABLED(CONFIG_TIMESTAMP) common: Kconfig: TIMESTAMP: fix help common/Kconfig | 7 +++ common/uimage.c | 22 -- fs/uimagefs.c | 24 ++-- 3 files changed, 25 insertions(+), 28 deletions(-) -- 2.39.0

[PATCH 1/2] uImage: use IS_ENABLED(CONFIG_TIMESTAMP)

2024-01-03 Thread Antony Pavlov
Signed-off-by: Antony Pavlov --- common/uimage.c | 22 -- fs/uimagefs.c | 24 ++-- 2 files changed, 22 insertions(+), 24 deletions(-) diff --git a/common/uimage.c b/common/uimage.c index 72c37b7d15d..3c9a79d9109 100644 --- a/common/uimage.c +++

Re: [PATCH master] ARM: kasan: reserve shadow memory region

2024-01-03 Thread Sascha Hauer
On Wed, Jan 03, 2024 at 11:13:08AM +0100, Ahmad Fatoum wrote: > We did not have any protection in place to ensure that KASAN shadow memory > isn't overwritten during boot. Add that now to avoid strange effects > during debugging. > > Signed-off-by: Ahmad Fatoum > --- > arch/arm/cpu/start.c | 4

[PATCH 023/112] block: record block device type

2024-01-03 Thread Ahmad Fatoum
Software running under EFI can query the type of a block device. For barebox to be able to report this, start assigning types to all block devices it can create. No functional change yet. Signed-off-by: Ahmad Fatoum --- arch/sandbox/board/hostfile.c | 1 + common/block.c| 24

[PATCH 047/112] string: reduce strjoin runtime, drop trailing separator

2024-01-03 Thread Ahmad Fatoum
The implementation of strjoin is a bit suboptimal. The destination string is traversed from the beginning due to strcat and we have a left-over separator at the end, while it should only be in-between. Fix this. Signed-off-by: Ahmad Fatoum --- Originally posted at:

[PATCH 068/112] efi: define efi_handle_t as opaque pointer

2024-01-03 Thread Ahmad Fatoum
Typedef'ing efi_handle_t as void * means that we don't catch instance where we pass a double indirect pointer when a normal pointer is expected. With loader support, we will start to dereference it anyway, so have it point at an opaque type instead. Signed-off-by: Ahmad Fatoum ---

[PATCH 074/112] efi: flesh out EFI definitions in header

2024-01-03 Thread Ahmad Fatoum
We have a lot of function pointer members in the protocols, that were defined as void pointers instead of properly prototyped function pointers. Similarly, a lot of data types are defined to equivalent types that aren't as descriptive, e.g. size_t vs ulong and s16 vs efi_char16_t. Let's switch

[PATCH 084/112] efi: payload: early-mem: simplify error message reporting

2024-01-03 Thread Ahmad Fatoum
Adding a size to the error message means that we can just use a single error message for either error case with no loss of information. While at it, we turn the error string into a code: This file can be built for PBL later on and we won't have efi_strerror there. Signed-off-by: Ahmad Fatoum

[PATCH 027/112] fs: turn creat into static inline helper

2024-01-03 Thread Ahmad Fatoum
creat is a oneliner that can be inlined at no extra cost, so move it into a header. Signed-off-by: Ahmad Fatoum --- fs/fs.c | 6 -- include/fcntl.h | 6 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/fs/fs.c b/fs/fs.c index bd2f0b6294ff..7c4e2f250ea8 100644

[PATCH 089/112] efi: devicepath: implement device_path_to_str_buf variant

2024-01-03 Thread Ahmad Fatoum
Existing device_path_to_str() formats a buffer once to determines the amount of space necessary and then allocates it and formats it again. To make this functionality available as printf format specifier, we need a variant that doesn't allocate memory and that's preferably single pass, which we

[PATCH 112/112] commands: efi_handle_dump: don't ignore failure to parse GUID

2024-01-03 Thread Ahmad Fatoum
simple_strtoul should probably be removed altogether. Let's start by removing it from efi_handle_dump.c, so invalid input is not ignored. Signed-off-by: Ahmad Fatoum --- commands/efi_handle_dump.c | 32 +--- 1 file changed, 17 insertions(+), 15 deletions(-) diff

[PATCH 013/112] efi: payload: image: allocate image via loader if it exceeds malloc area

2024-01-03 Thread Ahmad Fatoum
barebox allocates at maximum 256M for its own use when running as EFI payload. With bigger kernel images and initrds, this may exceed the space barebox has available, especially if decompression needs to happen within barebox. In that case, instead of failing with -ENOMEM, let's ask the EFI

[PATCH 026/112] fs: fix unreaddir, so readdir returns unread dirent first

2024-01-03 Thread Ahmad Fatoum
unreaddir should return a directory entry at the top of the list, so readdir consumes it again, not at the end. Fixes: 7876018f7333 ("fs: implement unreaddir") Signed-off-by: Ahmad Fatoum --- fs/fs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/fs.c b/fs/fs.c index

[PATCH 041/112] fs: support opening /

2024-01-03 Thread Ahmad Fatoum
With open() on / no longer accessing uninitialized memory, it now always fails with errno == ENOENT. This is because d_lookup only compares children of /, but never / itself. Fix this by comparing the parent and while at it, rework the existing code to be more concise. Signed-off-by: Ahmad

[PATCH 072/112] efi-stdio: fix wait_for_event argument

2024-01-03 Thread Ahmad Fatoum
EFI v2.10 documents the following about EFI events: | // EFI_EVENT: Handle to an event structure. Type VOID * | | typedef | EFI_STATUS | (EFIAPI *EFI_WAIT_FOR_EVENT) ( | IN UINTN NumberOfEvents, | IN EFI_EVENT *Event, | OUT UINTN *Index | ); | | typedef struct

[PATCH 100/112] efi: devicepath: move END device node definitions into header

2024-01-03 Thread Ahmad Fatoum
While at it, drop DP_IS_END_TYPE and DP_IS_END_SUBTYPE, which are unused. Signed-off-by: Ahmad Fatoum --- efi/devicepath.c | 12 include/efi/device-path.h | 10 ++ 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/efi/devicepath.c b/efi/devicepath.c

[PATCH 099/112] efi: devicepath: format GUIDs as little endian

2024-01-03 Thread Ahmad Fatoum
The default for %pU is to format as big endian, which isn't the correct representation for EFI GUIDs, which are little endian. Fix the format specifier to avoid the confusion. Signed-off-by: Ahmad Fatoum --- efi/devicepath.c | 13 + 1 file changed, 5 insertions(+), 8 deletions(-)

[PATCH 022/112] commands: stat: display bootable partition table bit info

2024-01-03 Thread Ahmad Fatoum
There's no common code yet, but board code may iterate over cdevs to handle the boot partition specially. Make writing such code easier by adding the new flags to the stat command's output. Signed-off-by: Ahmad Fatoum --- fs/fs.c | 4 1 file changed, 4 insertions(+) diff --git a/fs/fs.c

[PATCH 105/112] efi: devicepath: let compiler worry about unaligned unpacking

2024-01-03 Thread Ahmad Fatoum
Device path nodes are tightly packed and subsequent device nodes may start at any boundary. To parse these, existing code allocated a new buffer and unpacked device paths into it, so they are at a natural boundary (chosen as 8 bytes with x86_64 in mind). We can simplify this by using __packed and

[PATCH 039/112] commands: introduce new findmnt command

2024-01-03 Thread Ahmad Fatoum
EFI loader support will need to map barebox VFS paths to fs_device and back. Make development easier by providing a findmnt command to test the mapping. Signed-off-by: Ahmad Fatoum --- commands/Kconfig | 15 +++ commands/Makefile | 1 + commands/findmnt.c | 108

[PATCH 104/112] efi: devicepath: drop unused macro

2024-01-03 Thread Ahmad Fatoum
This is used no where, so it can just be dropped. Signed-off-by: Ahmad Fatoum --- include/efi/device-path.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/include/efi/device-path.h b/include/efi/device-path.h index 433233f38c0d..39221ca369de 100644 --- a/include/efi/device-path.h +++

[PATCH 096/112] commands: add cpuinfo -s option for stacktrace

2024-01-03 Thread Ahmad Fatoum
While a call to dump_stack() is easily hacked into the code, it can be useful during development to just print the stacktrace from the shell, e.g. to verify that kallsyms sharing for EFI works as intended. Add an option to cpuinfo to provide this functionality. Signed-off-by: Ahmad Fatoum ---

[PATCH 083/112] efi: payload: factor C efi_main into dedicated file

2024-01-03 Thread Ahmad Fatoum
For barebox as EFI payload on ARM, we will not call start_barebox() ourselves as we will be using PBL, which we don't on x86 yet. Therefore move that code out of the common init.c into a new entry-single.c and early-mem.c that can be used as needed. Signed-off-by: Ahmad Fatoum ---

[PATCH 017/112] block: define BLOCKSIZE globally in block.h

2024-01-03 Thread Ahmad Fatoum
For use by EFI loader code that needs to report block size, export the BLOCKSIZE macro. Signed-off-by: Ahmad Fatoum --- common/block.c | 2 -- include/block.h | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/common/block.c b/common/block.c index 3a4a9fb73149..79d277e35ae1

[PATCH 106/112] efi: devicepath: correct formatting of BBS

2024-01-03 Thread Ahmad Fatoum
It's the BIOS boot specification (BBS) and not BSS. Fix the typo in preparation for abusing it. Signed-off-by: Ahmad Fatoum --- efi/devicepath.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/efi/devicepath.c b/efi/devicepath.c index 0df43f222018..23963aa0cbb7

[PATCH 058/112] efi: payload: fix ARM build

2024-01-03 Thread Ahmad Fatoum
So far we only ever built EFI for x86. Prepare building it for ARM by removing the x86-specific attributes. Signed-off-by: Ahmad Fatoum --- efi/payload/image.c | 4 ++-- include/efi/types.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/efi/payload/image.c

[PATCH 020/112] commands: stat: print DT node for cdevs if available

2024-01-03 Thread Ahmad Fatoum
It may not be directly apparent, what device a cdev spawned from. Have stat report this information for debugging purposes. Signed-off-by: Ahmad Fatoum --- fs/fs.c | 5 + 1 file changed, 5 insertions(+) diff --git a/fs/fs.c b/fs/fs.c index 1e357872f6ae..a7097dd3946e 100644 --- a/fs/fs.c

[PATCH 032/112] fs: remove unused member from struct nameidata

2024-01-03 Thread Ahmad Fatoum
A number of members in the struct are either unused or only ever written and never read. Drop them to tidy up the code. Signed-off-by: Ahmad Fatoum --- fs/fs.c | 9 - 1 file changed, 9 deletions(-) diff --git a/fs/fs.c b/fs/fs.c index ca1bcef1adf0..be0b38d8bc30 100644 --- a/fs/fs.c +++

[PATCH 045/112] efi: payload: init: warn if /boot FS is unknown

2024-01-03 Thread Ahmad Fatoum
The initcall's only function is to open /boot/EFI/barebox/state.dtb and to register it as barebox state description. If nothing is mounted at /boot, this will fail anyway, so early exit in that case. Signed-off-by: Ahmad Fatoum --- efi/payload/init.c | 7 +++ 1 file changed, 7 insertions(+)

[PATCH 051/112] efi: don't hide structs, enums or unions behind _t

2024-01-03 Thread Ahmad Fatoum
Kernel coding style is to usually not hide the fact that a type is a struct or enum behind a typedef. Follow that in the EFI code. Besides being more descriptive, this also allows forward declarations, so doesn't have to be included everywhere. No functional change. Signed-off-by: Ahmad Fatoum

[PATCH 092/112] efi: payload: dynamically determine bootloader file name

2024-01-03 Thread Ahmad Fatoum
\EFI\BOOT\BOOTx64.EFI is only the default file path for x86_64. It's different for other architectures and even for x86_64, the EFI loader may be configured to execute a differently named file. Fix this by querying the EFI loader for the file name instead of hardcoding it and while at it, we add

[PATCH 057/112] pbl: introduce CONFIG_PBL_FULLY_PIC

2024-01-03 Thread Ahmad Fatoum
In the quest for making barebox PBL code W^X mappable, we have now taken care to make the ARM64 assembly routines not emit code relocations, so let's do the same for the C code as well. We do this by setting pragma GCC visibility push(hidden) globally. This option is stronger than

[PATCH 066/112] efi: use efi_handle_t where appropriate

2024-01-03 Thread Ahmad Fatoum
efi_handle_t is a typedef for a void pointer. We use either void * directly or unsigned long at places, where a handle would be the more descriptive type. Fix this. Signed-off-by: Ahmad Fatoum --- drivers/serial/efi-stdio.c | 2 +- include/efi.h | 10 +- 2 files changed, 6

[PATCH 028/112] fs: drop unused LOOKUP_ flags

2024-01-03 Thread Ahmad Fatoum
Most flags used during VFS lookup are apparently unused, so let's delete them to make the code easier to reason about. Signed-off-by: Ahmad Fatoum --- fs/fs.c | 11 +-- include/linux/namei.h | 13 - 2 files changed, 1 insertion(+), 23 deletions(-) diff --git

[PATCH 024/112] include: add definitions for UAPI discoverable partitions spec

2024-01-03 Thread Ahmad Fatoum
Now that we remember the Type GUID of block devices, let's import the UUIDs assigned by the UAPI group discoverable partition specification as found in systemd v255's src/systemd/sd-gpt.h. Signed-off-by: Ahmad Fatoum --- include/uapi/spec/dps.h | 370 1

[PATCH 063/112] ARM: make board data definitions accessible to other architectures

2024-01-03 Thread Ahmad Fatoum
struct barebox_arm_boarddata is a way for PBL to handover a machine number instead of a FDT. We will reuse this mechanism to hand over EFI image handle and system table in a later commit, so prepare for that by moving it to a central location and adjust the naming. Signed-off-by: Ahmad Fatoum

[PATCH 059/112] efi: payload: init: restrict barebox mem to first 1G only on x86

2024-01-03 Thread Ahmad Fatoum
When run as EFI payload, barebox will not have full access to DRAM and will have to ask the EFI firmware for memory. It does so once at the beginning and since commit 356aaef5a37d ("efi: improve malloc pool allocation"), the buffer was always placed beneath the 1G boundary. Aforementioned commit

[PATCH 107/112] commands: provide efi_handle_dump in both payload and loader

2024-01-03 Thread Ahmad Fatoum
The efi_handle_dump command is currently used when barebox is built as payload, but it's also useful when running as a loader to list handles and their protocols. Move the code into a common area to make it accessible in both configurations. Signed-off-by: Ahmad Fatoum --- commands/Kconfig

[PATCH 098/112] efi: devicepath: pretty print BBS BEV DeviceType

2024-01-03 Thread Ahmad Fatoum
BBS paths can have multiple types, one of them is the device type, which we will start abusing in a later commit, so make sure it's translated to a readable string. Signed-off-by: Ahmad Fatoum --- efi/devicepath.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/efi/devicepath.c

[PATCH 103/112] efi: devicepath: use flexible array members for trailing strings

2024-01-03 Thread Ahmad Fatoum
When we start using fortified string operations in the future, we will need to replace zero and one sized trailing arrays with flexible arrays where required everywhere, but for now let's just avoid having any in the EFI code. Signed-off-by: Ahmad Fatoum --- include/efi/device-path.h | 8

[PATCH 021/112] partitions: have parsers record bootable bits

2024-01-03 Thread Ahmad Fatoum
barebox as EFI loader can use the information about which partitions are bootable to guide its decision. Record this information. Signed-off-by: Ahmad Fatoum --- common/partitions.c| 4 ++-- common/partitions/dos.c| 10 ++ common/partitions/efi.c| 18 ++

[PATCH 038/112] fs: implement O_CHROOT

2024-01-03 Thread Ahmad Fatoum
For use by EFI file system path resolution, implement an O_CHROOT flag that will map / to the root of the file system the dirfd points to instead of the VFS root. If the dirfd points to a mountpoint, it will be followed to the file system inside. This is similar to Linux openat2 with

[PATCH 060/112] ARM: pbl: add 64K segment alignment for PE/COFF

2024-01-03 Thread Ahmad Fatoum
An EFI stubbed ARM64 kernel can be booted either via EFI or via the normal boot protocol. We'll want barebox to be able to behave the same, so extend section alignment to enable this. Signed-off-by: Ahmad Fatoum --- arch/arm/include/asm/memory.h | 20 arch/arm/lib/pbl.lds.S

[PATCH 071/112] efi: add EFI_WARN constants

2024-01-03 Thread Ahmad Fatoum
These constants can be returned by some of the EFI loader protocols implemented later on. Signed-off-by: Ahmad Fatoum --- include/efi.h | 8 1 file changed, 8 insertions(+) diff --git a/include/efi.h b/include/efi.h index 1749001adb48..7e8b7f0a49b8 100644 --- a/include/efi.h +++

[RFC] uimagefs segmentation fault

2024-01-03 Thread Antony Pavlov
Hi! I have prepared a linux uImage file for testing my uImage-related patches. barebox$ dumpimage -l ./defaultenv/defaultenv-2-base/uImage Image Name: Linux-6.7.0-rc4-3-ge185a416f Created: Wed Jan 3 15:28:27 2024 Image Type: ARM Linux Kernel Image (uncompressed) Data Size:

[PATCH 094/112] efi: payload: protect against buggy EFI implementations

2024-01-03 Thread Ahmad Fatoum
barebox' EFI loaded image handle should have a device path, but on the off-case that it doesn't, we should just return an error code instead of dereferencing a null pointer. Signed-off-by: Ahmad Fatoum --- efi/payload/init.c | 3 +++ 1 file changed, 3 insertions(+) diff --git

[PATCH 090/112] vsprintf: add %pD for printing EFI device path

2024-01-03 Thread Ahmad Fatoum
We already have a few users that will want to print EFI device paths and will gain quite a few more with incoming loader support, so let's allow printing them directly with printf with the %pD format specifier. Signed-off-by: Ahmad Fatoum --- lib/vsprintf.c | 14 ++ 1 file changed,

[PATCH 065/112] common: add PE/COFF loader

2024-01-03 Thread Ahmad Fatoum
EFI loader will need to parse and load PE executables. Add functions to facilitate that. The API is inspired by the already existing ELF API. Signed-off-by: Ahmad Fatoum --- common/Kconfig | 3 + common/Makefile | 1 + common/pe.c | 377

[PATCH 095/112] efi: payload: don't require efi_loaded_image->parent_handle for bootsource detection

2024-01-03 Thread Ahmad Fatoum
This fixes bootsource detection running barebox as EFI payload under EDK2 2020.11. Fixes: 443eb41376d9 ("efi: add bootsource detection") Cc: Enrico Jorns Signed-off-by: Ahmad Fatoum --- drivers/efi/efi-device.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/efi/efi-device.c

[PATCH 040/112] fs: initialize struct nameidata::last

2024-01-03 Thread Ahmad Fatoum
The last member is normally written by link_path_walk(), before being read by __lookup_hash, among others. In the special case of calling open() on "/", link_path_walk() will terminate early without setting the last member, leading __d_alloc called by __lookup_hash to read uninitialized memory.

[PATCH 030/112] fs: factor out opendir iteration

2024-01-03 Thread Ahmad Fatoum
In preparation for supporting fdopendir and rewinddir, add an __opendir helper that is reused in a follow-up commit. Signed-off-by: Ahmad Fatoum --- fs/fs.c | 52 1 file changed, 32 insertions(+), 20 deletions(-) diff --git a/fs/fs.c

[PATCH 109/112] commands: efi_handle_dump: prepare for supporting EFI loader

2024-01-03 Thread Ahmad Fatoum
For debugging, it can be useful to dump handles from within the loader without having to boot barebox as EFI payload first. Prepare for this by removing implicit dependency on being an EFI payload. Signed-off-by: Ahmad Fatoum --- commands/efi_handle_dump.c | 33

[PATCH 102/112] efi: devicepath: namespace definitions

2024-01-03 Thread Ahmad Fatoum
Using a DEVICE_PATH_ prefix everywhere will make it clear what the definitions is about and in part align us with the naming in U-Boot. Signed-off-by: Ahmad Fatoum --- drivers/efi/efi-device.c | 5 +- efi/devicepath.c | 164 +++---

[PATCH 050/112] ARM: mmu-early: gracefully handle already enabled MMU

2024-01-03 Thread Ahmad Fatoum
arm_cpu_lowlevel_init will disable the MMU, but there are valid cases to not call it on startup, e.g. when barebox is being run as EFI payload. To allow booting an EFI-stubbed barebox both as primary bootloader and as EFI payload, teach mmu_early_enable() to bail out when the MMU is already set

[PATCH 075/112] efi: add efi_driver_binding_protocol

2024-01-03 Thread Ahmad Fatoum
We didn't need this for the EFI payload use case, but will need this for the EFI loader use case. Signed-off-by: Ahmad Fatoum --- include/efi.h | 19 +++ 1 file changed, 19 insertions(+) diff --git a/include/efi.h b/include/efi.h index 08cb07c8b946..a6dbc14ff3d9 100644 ---

[PATCH 086/112] ARM64: add optional EFI stub

2024-01-03 Thread Ahmad Fatoum
While very recent binutils releases have dedicated efi-*-aarch targets, we may want to support older toolchains. For this reason, we import the kernel's EFI stub PE fakery, so the same barebox-dt-2nd.img may be loaded as if it were a "normal" or an EFI-stubbed kernel. Signed-off-by: Ahmad Fatoum

[PATCH 042/112] test: self: add dirfd tests

2024-01-03 Thread Ahmad Fatoum
Adding directory fds involved a bit of rework to the VFS layer. We have ramfs tests that check the previous behavior, so add now tests to check that path resolution in openat and statat work as one would expect. As we need a separate file system to test O_CHROOT, the test has a dependency on the

[PATCH 046/112] commands: time: refactor into new strjoin

2024-01-03 Thread Ahmad Fatoum
time concatenates all its remaining arguments with a space in-between and then passes that to the command executor. This can be useful elsewhere as well, so factor it out into a new strjoin function. No functional change. Signed-off-by: Ahmad Fatoum --- commands/time.c | 11 +--

[PATCH 010/112] of: don't report failure to of_read_file twice

2024-01-03 Thread Ahmad Fatoum
of_read_file already prints to log messages when it fails, so duplicating the error message in the caller is needlessly verbose. Signed-off-by: Ahmad Fatoum --- commands/of_diff.c| 5 ++--- commands/of_display_timings.c | 4 +--- commands/of_overlay.c | 4 +---

[PATCH 067/112] efi: block: move definitions into header file

2024-01-03 Thread Ahmad Fatoum
We will need these definitions for the EFI loader as well, so move them into a header. Signed-off-by: Ahmad Fatoum --- drivers/block/efi-block-io.c | 27 --- include/efi.h| 27 +++ 2 files changed, 27 insertions(+), 27 deletions(-)

[PATCH 054/112] efi: efi-guid: add more GUIDs

2024-01-03 Thread Ahmad Fatoum
These GUIDs will be useful for the incoming EFI loader support, so add them all at once. Signed-off-by: Ahmad Fatoum --- efi/guid.c| 35 +- include/efi.h | 59 +++ 2 files changed, 93 insertions(+), 1 deletion(-)

[PATCH 036/112] fs: implement O_PATH

2024-01-03 Thread Ahmad Fatoum
For use with the newly added openat and friends API, add O_PATH file descriptors that are not usable for doing actual I/O, but only for use as dirfd. Signed-off-by: Ahmad Fatoum --- fs/fs.c | 58 + include/fcntl.h | 1 + 2 files changed,

[PATCH 108/112] lib: uuid: implement uuid/guid_parse

2024-01-03 Thread Ahmad Fatoum
We opencode this at least once in EFI code, so import the Linux definition and start using that instead. Signed-off-by: Ahmad Fatoum --- lib/uuid.c | 63 ++ 1 file changed, 63 insertions(+) diff --git a/lib/uuid.c b/lib/uuid.c index

[PATCH 031/112] fs: implement fdopendir and rewinddir

2024-01-03 Thread Ahmad Fatoum
We will be using the incoming O_PATH support to implement the EFI file system protocol for when barebox acts as EFI loader. The protocol also requires being able to rewind iteration, so add support for that too. Signed-off-by: Ahmad Fatoum --- fs/fs.c | 55

[PATCH 110/112] commands: efi_handle_dump: print loaded image devpath

2024-01-03 Thread Ahmad Fatoum
Device Path and Loaded Image Device Path are different things. Print both for maximum utility. Signed-off-by: Ahmad Fatoum --- commands/efi_handle_dump.c | 17 - 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/commands/efi_handle_dump.c

[PATCH 019/112] block: virtio: assign virtio-mmio device tree node to cdevs

2024-01-03 Thread Ahmad Fatoum
All block devices except for virtio-mmio have a pointer to the hardware device tree node if available, so add it to virtio-mmio as well. Signed-off-by: Ahmad Fatoum --- drivers/block/virtio_blk.c | 1 + drivers/virtio/virtio.c| 1 + 2 files changed, 2 insertions(+) diff --git

[PATCH 014/112] efi: payload: image: use assigned barebox loader type on x86

2024-01-03 Thread Ahmad Fatoum
Starting with Linux v6.2, there's a loader type assigned to barebox: commit a27e292b8a54e24f85181d949fac8c51fdec8ff3 Author: Ahmad Fatoum AuthorDate: Sun Oct 2 14:57:53 2022 +0200 Commit: Borislav Petkov CommitDate: Mon Oct 17 11:22:33 2022 +0200 Documentation/x86/boot:

[PATCH 087/112] efi: devicepath: improve const safety

2024-01-03 Thread Ahmad Fatoum
The device path traversal functions don't modify the device path itself, so reflect that in the function prototypes. Signed-off-by: Ahmad Fatoum --- efi/devicepath.c | 140 --- include/efi.h| 10 ++-- 2 files changed, 76 insertions(+), 74

[PATCH 061/112] efi: add efi_is_loader/efi_is_payload helpers

2024-01-03 Thread Ahmad Fatoum
So far, whether we are running under EFI was a compile-time decision. This will change with ARM support, where the same barebox binary can either probe from DT or from EFI. Prepare for this by adding helpers to determine whether barebox is acting as EFI loader or as payload. Signed-off-by: Ahmad

  1   2   >