Re: [U-Boot] [PATCH v3 2/3] efi_loader: ARM: run EFI payloads non-secure

2018-09-22 Thread Heinrich Schuchardt
On 09/23/2018 04:39 AM, Jonathan Gray wrote:
> On Sun, Sep 23, 2018 at 01:30:11AM +0200, Heinrich Schuchardt wrote:
>> On 09/01/2018 12:21 PM, Alexander Graf wrote:
>>>
>>>
>>> On 31.08.18 20:45, Mark Kettenis wrote:
> From: Heinrich Schuchardt 
> Date: Fri, 31 Aug 2018 19:37:25 +0200
>
> On 06/14/2018 12:41 AM, Mark Kettenis wrote:
>> If desired (and possible) switch into HYP mode or non-secure SVC mode
>> before calling the entry point of an EFI application.  This allows
>> U-Boot to provide a usable PSCI implementation and makes it possible
>> to boot kernels into hypervisor mode using an EFI bootloader.
>>
>> Based on diffs from Heinrich Schuchardt and Alexander Graf.
>>
>> Signed-off-by: Mark Kettenis 
>
> bootefi hello fails on vexpress_ca15_tc2_defconfig when run on qemu with
>
> QEMU_AUDIO_DRV=none qemu-system-arm \
> -M vexpress-a15 -cpu cortex-a15 -kernel u-boot \
> -net user -net nic,model=lan9118 \
> -m 1024M --nographic \
> -drive if=sd,file=img.vexpress,media=disk,format=raw

 Works for me with:

 $ qemu-system-arm --version
 QEMU emulator version 3.0.0
 Copyright (c) 2003-2017 Fabrice Bellard and the QEMU Project developers

 => bootefi hello
 Scanning disks on mmc...
 MMC Device 1 not found
 MMC Device 2 not found
 MMC Device 3 not found
 Found 3 disks
 WARNING: booting without device tree
 ## Starting EFI application at a0008000 ...
 WARNING: using memory device/image path, this may confuse some payloads!
 Hello, world!
 Running on UEFI 2.7
 Have SMBIOS table
 Load options: 
 ## Application terminated, r = 0

 That is with CONFIG_CMD_BOOTEFI_HELLO=y added to the
 vexpress_ca15_tc2_defconfig of course.

> Bisection points to
> efi_loader: ARM: run EFI payloads non-secure
> commit dc500c369486fbe04000fd325c46bb309e4a1827

 That suggests an issue with emulation if the mode switching
 instructions or HYP support in qemu.  Or a toolchain issue of course.
>>>
>>> Or maybe Heinrich's QEMU version starts up in a different EL mode?
>>>
>>>
>>> Alex
>>> ___
>>> U-Boot mailing list
>>> U-Boot@lists.denx.de
>>> https://lists.denx.de/listinfo/u-boot
>>>
>> The problem is reproducible with qemu 3.0.0.
>>
>> git reset --hard dc500c369486fbe04000fd325c46bb309e4a1827
>>
>> --- a/lib/efi_loader/Kconfig
>> +++ b/lib/efi_loader/Kconfig
>> @@ -2,7 +2,6 @@ config EFI_LOADER
>> bool "Support running EFI Applications in U-Boot"
>> depends on (ARM || X86 || RISCV) && OF_LIBFDT
>> # We do not support bootefi booting ARMv7 in non-secure mode
>> -   depends on !ARMV7_NONSEC
>> # We need EFI_STUB_64BIT to be set on x86_64 with EFI_STUB
>> depends on !EFI_STUB || !X86_64 || EFI_STUB_64BIT
>> # We need EFI_STUB_32BIT to be set on x86_32 with EFI_STUB
>>
>> make vexpress_ca15_tc2_defconfig
>>
>> Set CONFIG_CMD_BOOTEFI_HELLO=y
>>
>> export CROSS_COMPILE=arm-linux-gnueabihf-
>> make
>>
>> QEMU_AUDIO_DRV=none qemu-system-arm \
>> -M vexpress-a15 -cpu cortex-a15 -kernel u-boot \
>> -netdev \
>> user,id=net0,tftp=tftp,net=192.168.76.0/24,dhcpstart=192.168.76.9 \
>> -net nic,model=lan9118,netdev=net0 \
>> -m 1024M --nographic \
>> -drive if=sd,file=img.vexpress,media=disk,format=raw
>>
>> => bootefi hello
>> Scanning disks on mmc...
>> MMC Device 1 not found
>> MMC Device 2 not found
>> MMC Device 3 not found
>> Found 2 disks
>> WARNING: booting without device tree
>> ## Starting EFI application at a0008000 ...
>> WARNING: using memory device/image path, this may confuse some payloads!
>>
>> No further output after this line :(
> 
> bootefi hello works fine with 2018.09 and qemu 3.0 here
> 
> gmake PYTHON=python2.7 CROSS_COMPILE=arm-none-eabi- 
> vexpress_ca15_tc2_defconfig O=build/vexpress
> gmake PYTHON=python2.7 CROSS_COMPILE=arm-none-eabi- O=build/vexpress 
> menuconfig
> gmake PYTHON=python2.7 CROSS_COMPILE=arm-none-eabi- O=build/vexpress all
> 
> $ arm-none-eabi-gcc -v
> Using built-in specs.
> COLLECT_GCC=arm-none-eabi-gcc
> COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/arm-none-eabi/6.3.1/lto-wrapper
> Target: arm-none-eabi
> Configured with: 
> /usr/obj/ports/arm-none-eabi-gcc-linaro-6.3.2017.02-arm/gcc-linaro-6.3-2017.02/configure
>  --enable-languages=c,c++ --enable-multilib --enable-interwork 
> --with-gmp=/usr/local --with-newlib --disable-lto --enable-cpp 
> --target=arm-none-eabi --disable-shared --disable-nls --disable-werror 
> --prefix=/usr/local --sysconfdir=/etc --mandir=/usr/local/man 
> --infodir=/usr/local/info --localstatedir=/var --disable-silent-rules 
> --disable-gtk-doc
> Thread model: single
> gcc version 6.3.1 20170109 (Linaro GCC 6.3-2017.02)
> 
> $ qemu-system-arm --version
> QEMU emulator version 3.0.0
> Copyright (c) 2003-2017 Fabrice Bellard and the QEMU 

Re: [U-Boot] [PATCH v3 2/3] efi_loader: ARM: run EFI payloads non-secure

2018-09-22 Thread Jonathan Gray
On Sun, Sep 23, 2018 at 01:30:11AM +0200, Heinrich Schuchardt wrote:
> On 09/01/2018 12:21 PM, Alexander Graf wrote:
> > 
> > 
> > On 31.08.18 20:45, Mark Kettenis wrote:
> >>> From: Heinrich Schuchardt 
> >>> Date: Fri, 31 Aug 2018 19:37:25 +0200
> >>>
> >>> On 06/14/2018 12:41 AM, Mark Kettenis wrote:
>  If desired (and possible) switch into HYP mode or non-secure SVC mode
>  before calling the entry point of an EFI application.  This allows
>  U-Boot to provide a usable PSCI implementation and makes it possible
>  to boot kernels into hypervisor mode using an EFI bootloader.
> 
>  Based on diffs from Heinrich Schuchardt and Alexander Graf.
> 
>  Signed-off-by: Mark Kettenis 
> >>>
> >>> bootefi hello fails on vexpress_ca15_tc2_defconfig when run on qemu with
> >>>
> >>> QEMU_AUDIO_DRV=none qemu-system-arm \
> >>> -M vexpress-a15 -cpu cortex-a15 -kernel u-boot \
> >>> -net user -net nic,model=lan9118 \
> >>> -m 1024M --nographic \
> >>> -drive if=sd,file=img.vexpress,media=disk,format=raw
> >>
> >> Works for me with:
> >>
> >> $ qemu-system-arm --version
> >> QEMU emulator version 3.0.0
> >> Copyright (c) 2003-2017 Fabrice Bellard and the QEMU Project developers
> >>
> >> => bootefi hello
> >> Scanning disks on mmc...
> >> MMC Device 1 not found
> >> MMC Device 2 not found
> >> MMC Device 3 not found
> >> Found 3 disks
> >> WARNING: booting without device tree
> >> ## Starting EFI application at a0008000 ...
> >> WARNING: using memory device/image path, this may confuse some payloads!
> >> Hello, world!
> >> Running on UEFI 2.7
> >> Have SMBIOS table
> >> Load options: 
> >> ## Application terminated, r = 0
> >>
> >> That is with CONFIG_CMD_BOOTEFI_HELLO=y added to the
> >> vexpress_ca15_tc2_defconfig of course.
> >>
> >>> Bisection points to
> >>> efi_loader: ARM: run EFI payloads non-secure
> >>> commit dc500c369486fbe04000fd325c46bb309e4a1827
> >>
> >> That suggests an issue with emulation if the mode switching
> >> instructions or HYP support in qemu.  Or a toolchain issue of course.
> > 
> > Or maybe Heinrich's QEMU version starts up in a different EL mode?
> > 
> > 
> > Alex
> > ___
> > U-Boot mailing list
> > U-Boot@lists.denx.de
> > https://lists.denx.de/listinfo/u-boot
> > 
> The problem is reproducible with qemu 3.0.0.
> 
> git reset --hard dc500c369486fbe04000fd325c46bb309e4a1827
> 
> --- a/lib/efi_loader/Kconfig
> +++ b/lib/efi_loader/Kconfig
> @@ -2,7 +2,6 @@ config EFI_LOADER
> bool "Support running EFI Applications in U-Boot"
> depends on (ARM || X86 || RISCV) && OF_LIBFDT
> # We do not support bootefi booting ARMv7 in non-secure mode
> -   depends on !ARMV7_NONSEC
> # We need EFI_STUB_64BIT to be set on x86_64 with EFI_STUB
> depends on !EFI_STUB || !X86_64 || EFI_STUB_64BIT
> # We need EFI_STUB_32BIT to be set on x86_32 with EFI_STUB
> 
> make vexpress_ca15_tc2_defconfig
> 
> Set CONFIG_CMD_BOOTEFI_HELLO=y
> 
> export CROSS_COMPILE=arm-linux-gnueabihf-
> make
> 
> QEMU_AUDIO_DRV=none qemu-system-arm \
> -M vexpress-a15 -cpu cortex-a15 -kernel u-boot \
> -netdev \
> user,id=net0,tftp=tftp,net=192.168.76.0/24,dhcpstart=192.168.76.9 \
> -net nic,model=lan9118,netdev=net0 \
> -m 1024M --nographic \
> -drive if=sd,file=img.vexpress,media=disk,format=raw
> 
> => bootefi hello
> Scanning disks on mmc...
> MMC Device 1 not found
> MMC Device 2 not found
> MMC Device 3 not found
> Found 2 disks
> WARNING: booting without device tree
> ## Starting EFI application at a0008000 ...
> WARNING: using memory device/image path, this may confuse some payloads!
> 
> No further output after this line :(

bootefi hello works fine with 2018.09 and qemu 3.0 here

gmake PYTHON=python2.7 CROSS_COMPILE=arm-none-eabi- vexpress_ca15_tc2_defconfig 
O=build/vexpress
gmake PYTHON=python2.7 CROSS_COMPILE=arm-none-eabi- O=build/vexpress menuconfig
gmake PYTHON=python2.7 CROSS_COMPILE=arm-none-eabi- O=build/vexpress all

$ arm-none-eabi-gcc -v
Using built-in specs.
COLLECT_GCC=arm-none-eabi-gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/arm-none-eabi/6.3.1/lto-wrapper
Target: arm-none-eabi
Configured with: 
/usr/obj/ports/arm-none-eabi-gcc-linaro-6.3.2017.02-arm/gcc-linaro-6.3-2017.02/configure
 --enable-languages=c,c++ --enable-multilib --enable-interwork 
--with-gmp=/usr/local --with-newlib --disable-lto --enable-cpp 
--target=arm-none-eabi --disable-shared --disable-nls --disable-werror 
--prefix=/usr/local --sysconfdir=/etc --mandir=/usr/local/man 
--infodir=/usr/local/info --localstatedir=/var --disable-silent-rules 
--disable-gtk-doc
Thread model: single
gcc version 6.3.1 20170109 (Linaro GCC 6.3-2017.02)

$ qemu-system-arm --version
QEMU emulator version 3.0.0
Copyright (c) 2003-2017 Fabrice Bellard and the QEMU Project developers

qemu-system-arm -m 1024 -M vexpress-a15 -kernel build/vexpress/u-boot -serial 
stdio

U-Boot 2018.09-1-g2a9fbd55c3 

[U-Boot] [PATCH 1/1] efi_selftest: test qemu-arm(64)_defconfig

2018-09-22 Thread Heinrich Schuchardt
We should run the EFI selftest on both a 32bit and a 64bit ARM platform on
Travis to catch possible errors.

Signed-off-by: Heinrich Schuchardt 
---
 configs/qemu_arm64_defconfig | 1 +
 configs/qemu_arm_defconfig   | 1 +
 2 files changed, 2 insertions(+)

diff --git a/configs/qemu_arm64_defconfig b/configs/qemu_arm64_defconfig
index d343e98751..3e6b6972ac 100644
--- a/configs/qemu_arm64_defconfig
+++ b/configs/qemu_arm64_defconfig
@@ -8,6 +8,7 @@ CONFIG_DISTRO_DEFAULTS=y
 CONFIG_NR_DRAM_BANKS=1
 # CONFIG_DISPLAY_CPUINFO is not set
 # CONFIG_DISPLAY_BOARDINFO is not set
+CONFIG_CMD_BOOTEFI_SELFTEST=y
 CONFIG_CMD_PCI=y
 CONFIG_CMD_USB=y
 CONFIG_CMD_DATE=y
diff --git a/configs/qemu_arm_defconfig b/configs/qemu_arm_defconfig
index 2d0d55b803..4f48ec00ac 100644
--- a/configs/qemu_arm_defconfig
+++ b/configs/qemu_arm_defconfig
@@ -8,6 +8,7 @@ CONFIG_DISTRO_DEFAULTS=y
 CONFIG_NR_DRAM_BANKS=1
 # CONFIG_DISPLAY_CPUINFO is not set
 # CONFIG_DISPLAY_BOARDINFO is not set
+CONFIG_CMD_BOOTEFI_SELFTEST=y
 CONFIG_CMD_PCI=y
 CONFIG_CMD_USB=y
 CONFIG_CMD_DATE=y
-- 
2.19.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 1/1] efi_loader: avoid out of bound access in efi_get_variable()

2018-09-22 Thread Heinrich Schuchardt
In efi_get_variable() a string is longer than the allocated space which
results in overwriting the linked list of malloc().

The prefixes used for variables are 41 characters long, e.g.
efi_67029eb5-0af2-f6b1-da53-fcb566dd1ce6_

Change PREFIX_LEN to 41.

Fixes: faff21556748 ("efi_loader: remove limit on variable length")
Signed-off-by: Heinrich Schuchardt 
---
 lib/efi_loader/efi_variable.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/efi_loader/efi_variable.c b/lib/efi_loader/efi_variable.c
index 495738884b..a1313fa215 100644
--- a/lib/efi_loader/efi_variable.c
+++ b/lib/efi_loader/efi_variable.c
@@ -44,7 +44,7 @@
  * converted to utf16?
  */
 
-#define PREFIX_LEN (strlen("efi_---_"))
+#define PREFIX_LEN (strlen("efi_----_"))
 
 static int hex(int ch)
 {
-- 
2.19.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 1/1] efi_loader: refactor loaded image handle

2018-09-22 Thread Heinrich Schuchardt
Currently we expect the loaded image handle to point to the loaded image
protocol. Additionally we have appended private fields to the protocol.

With the patch the handle points to a loaded image object and the private
fields are added here. This matches how we handle the net and the gop
object.

Signed-off-by: Heinrich Schuchardt 
---
 cmd/bootefi.c | 14 
 include/efi_api.h |  8 -
 include/efi_loader.h  | 21 ---
 lib/efi_loader/efi_boottime.c | 58 +--
 lib/efi_loader/efi_image_loader.c | 23 ++--
 5 files changed, 62 insertions(+), 62 deletions(-)

diff --git a/cmd/bootefi.c b/cmd/bootefi.c
index 3ca0d588dd..f76f29a7b1 100644
--- a/cmd/bootefi.c
+++ b/cmd/bootefi.c
@@ -343,7 +343,7 @@ static efi_status_t do_bootefi_exec(void *efi,
efi_handle_t mem_handle = NULL;
struct efi_device_path *memdp = NULL;
efi_status_t ret;
-   efi_handle_t image_handle;
+   struct efi_loaded_image_obj *image_handle;
struct efi_loaded_image *loaded_image_info;
 
EFIAPI efi_status_t (*entry)(efi_handle_t image_handle,
@@ -386,7 +386,7 @@ static efi_status_t do_bootefi_exec(void *efi,
/* Transfer environment variable bootargs as load options */
set_load_options(loaded_image_info, "bootargs");
/* Load the EFI payload */
-   entry = efi_load_pe(efi, loaded_image_info);
+   entry = efi_load_pe(image_handle, efi, loaded_image_info);
if (!entry) {
ret = EFI_LOAD_ERROR;
goto exit;
@@ -407,8 +407,8 @@ static efi_status_t do_bootefi_exec(void *efi,
/* Call our payload! */
debug("%s:%d Jumping to 0x%lx\n", __func__, __LINE__, (long)entry);
 
-   if (setjmp(_image_info->exit_jmp)) {
-   ret = loaded_image_info->exit_status;
+   if (setjmp(_handle->exit_jmp)) {
+   ret = image_handle->exit_status;
goto exit;
}
 
@@ -450,7 +450,7 @@ static efi_status_t do_bootefi_exec(void *efi,
 exit:
/* image has returned, loaded-image obj goes *poof*: */
if (image_handle)
-   efi_delete_handle(image_handle);
+   efi_delete_handle(_handle->parent);
if (mem_handle)
efi_delete_handle(mem_handle);
 
@@ -535,7 +535,7 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, 
char * const argv[])
 #endif
 #ifdef CONFIG_CMD_BOOTEFI_SELFTEST
if (!strcmp(argv[1], "selftest")) {
-   efi_handle_t image_handle;
+   struct efi_loaded_image_obj *image_handle;
struct efi_loaded_image *loaded_image_info;
 
/* Construct a dummy device path. */
@@ -558,7 +558,7 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, 
char * const argv[])
r = efi_selftest(image_handle, );
efi_restore_gd();
free(loaded_image_info->load_options);
-   efi_delete_handle(image_handle);
+   efi_delete_handle(_handle->parent);
return r != EFI_SUCCESS;
} else
 #endif
diff --git a/include/efi_api.h b/include/efi_api.h
index 5004f520ff..c42df6900a 100644
--- a/include/efi_api.h
+++ b/include/efi_api.h
@@ -340,14 +340,6 @@ struct efi_loaded_image {
unsigned int image_code_type;
unsigned int image_data_type;
unsigned long unload;
-
-   /* Below are efi loader private fields */
-#ifdef CONFIG_EFI_LOADER
-   void *reloc_base;
-   aligned_u64 reloc_size;
-   efi_status_t exit_status;
-   struct jmp_buf_data exit_jmp;
-#endif
 };
 
 #define DEVICE_PATH_GUID \
diff --git a/include/efi_loader.h b/include/efi_loader.h
index d665627e91..74df070316 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -189,6 +189,20 @@ struct efi_object {
void *handle;
 };
 
+/**
+ * struct efi_loaded_image_obj - handle of a loaded image
+ */
+struct efi_loaded_image_obj {
+   /* Generic EFI object parent class data */
+   struct efi_object parent;
+   void *reloc_base;
+   aligned_u64 reloc_size;
+   efi_status_t exit_status;
+   struct jmp_buf_data exit_jmp;
+   EFIAPI efi_status_t (*entry)(efi_handle_t image_handle,
+struct efi_system_table *st);
+};
+
 /**
  * struct efi_event
  *
@@ -270,7 +284,8 @@ efi_status_t efi_set_watchdog(unsigned long timeout);
 /* Called from places to check whether a timer expired */
 void efi_timer_check(void);
 /* PE loader implementation */
-void *efi_load_pe(void *efi, struct efi_loaded_image *loaded_image_info);
+void *efi_load_pe(struct efi_loaded_image_obj *handle, void *efi,
+ struct efi_loaded_image *loaded_image_info);
 /* Called once to store the pristine gd pointer */
 void efi_save_gd(void);
 /* Special case handler for error/abort that just tries to dtrt to get
@@ -353,12 +368,10 @@ efi_status_t 

Re: [U-Boot] [PATCH v3 2/3] efi_loader: ARM: run EFI payloads non-secure

2018-09-22 Thread Heinrich Schuchardt
On 09/01/2018 12:21 PM, Alexander Graf wrote:
> 
> 
> On 31.08.18 20:45, Mark Kettenis wrote:
>>> From: Heinrich Schuchardt 
>>> Date: Fri, 31 Aug 2018 19:37:25 +0200
>>>
>>> On 06/14/2018 12:41 AM, Mark Kettenis wrote:
 If desired (and possible) switch into HYP mode or non-secure SVC mode
 before calling the entry point of an EFI application.  This allows
 U-Boot to provide a usable PSCI implementation and makes it possible
 to boot kernels into hypervisor mode using an EFI bootloader.

 Based on diffs from Heinrich Schuchardt and Alexander Graf.

 Signed-off-by: Mark Kettenis 
>>>
>>> bootefi hello fails on vexpress_ca15_tc2_defconfig when run on qemu with
>>>
>>> QEMU_AUDIO_DRV=none qemu-system-arm \
>>> -M vexpress-a15 -cpu cortex-a15 -kernel u-boot \
>>> -net user -net nic,model=lan9118 \
>>> -m 1024M --nographic \
>>> -drive if=sd,file=img.vexpress,media=disk,format=raw
>>
>> Works for me with:
>>
>> $ qemu-system-arm --version
>> QEMU emulator version 3.0.0
>> Copyright (c) 2003-2017 Fabrice Bellard and the QEMU Project developers
>>
>> => bootefi hello
>> Scanning disks on mmc...
>> MMC Device 1 not found
>> MMC Device 2 not found
>> MMC Device 3 not found
>> Found 3 disks
>> WARNING: booting without device tree
>> ## Starting EFI application at a0008000 ...
>> WARNING: using memory device/image path, this may confuse some payloads!
>> Hello, world!
>> Running on UEFI 2.7
>> Have SMBIOS table
>> Load options: 
>> ## Application terminated, r = 0
>>
>> That is with CONFIG_CMD_BOOTEFI_HELLO=y added to the
>> vexpress_ca15_tc2_defconfig of course.
>>
>>> Bisection points to
>>> efi_loader: ARM: run EFI payloads non-secure
>>> commit dc500c369486fbe04000fd325c46bb309e4a1827
>>
>> That suggests an issue with emulation if the mode switching
>> instructions or HYP support in qemu.  Or a toolchain issue of course.
> 
> Or maybe Heinrich's QEMU version starts up in a different EL mode?
> 
> 
> Alex
> ___
> U-Boot mailing list
> U-Boot@lists.denx.de
> https://lists.denx.de/listinfo/u-boot
> 
The problem is reproducible with qemu 3.0.0.

git reset --hard dc500c369486fbe04000fd325c46bb309e4a1827

--- a/lib/efi_loader/Kconfig
+++ b/lib/efi_loader/Kconfig
@@ -2,7 +2,6 @@ config EFI_LOADER
bool "Support running EFI Applications in U-Boot"
depends on (ARM || X86 || RISCV) && OF_LIBFDT
# We do not support bootefi booting ARMv7 in non-secure mode
-   depends on !ARMV7_NONSEC
# We need EFI_STUB_64BIT to be set on x86_64 with EFI_STUB
depends on !EFI_STUB || !X86_64 || EFI_STUB_64BIT
# We need EFI_STUB_32BIT to be set on x86_32 with EFI_STUB

make vexpress_ca15_tc2_defconfig

Set CONFIG_CMD_BOOTEFI_HELLO=y

export CROSS_COMPILE=arm-linux-gnueabihf-
make

QEMU_AUDIO_DRV=none qemu-system-arm \
-M vexpress-a15 -cpu cortex-a15 -kernel u-boot \
-netdev \
user,id=net0,tftp=tftp,net=192.168.76.0/24,dhcpstart=192.168.76.9 \
-net nic,model=lan9118,netdev=net0 \
-m 1024M --nographic \
-drive if=sd,file=img.vexpress,media=disk,format=raw

=> bootefi hello
Scanning disks on mmc...
MMC Device 1 not found
MMC Device 2 not found
MMC Device 3 not found
Found 2 disks
WARNING: booting without device tree
## Starting EFI application at a0008000 ...
WARNING: using memory device/image path, this may confuse some payloads!

No further output after this line :(

Best regards

Heinrich
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v2 07/13] x86: Fix signed shift overflow in MSR_IA32_APICBASE_BASE

2018-09-22 Thread Eugeniu Rosca
Hi Bin,

jFYI, I've created https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87392
("UBSAN behavior on left-shifting 1 into the sign bit is dependent on C
standard"), to get some recommendation from GCC guys how to handle
these warnings in U-Boot.

Regards,
Eugeniu.
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v1 0/2] ACPI: Generate SPCR table

2018-09-22 Thread Andy Shevchenko
This is a WIP series (I have no time to continue with it, so, that's why WIP)
to enable SPCR table generation in U-Boot. This table is useful to get early
console in Linux for debugging purposes. The benefit of using it is not only
for x86, but also for arm64 community (actually they introduced support in
Linux kernel).

This PoC implementation has been tested on Intel Edison with enabled ACPI
support.

Known issues:
 - there is no ->getconfig() callback, thus some data is hard coded
 - if serial parameters are changed at run time, SPCR is not regenerated, thus,
   might not produce what user excepts (this is more likely design issue of
   U-Boot itself)
 - implementation is not final and might not utilize best practices in U-Boot

So, if there is any interest, I would be happy to help, but as I mentioned
above I have no capacity to continue this myself.

The patches would be also available through my U-Boot tree on GH.

Andy Shevchenko (2):
  WIP: serial: Introduce ->getinfo() callback
  WIP: x86: acpi: Generate SPCR table

 arch/x86/include/asm/acpi_table.h | 25 ++
 arch/x86/lib/acpi_table.c | 82 +++
 drivers/serial/ns16550.c  | 14 ++
 drivers/serial/serial-uclass.c| 21 
 include/common.h  |  3 ++
 include/serial.h  | 14 ++
 6 files changed, 159 insertions(+)

-- 
2.18.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v1 2/2] WIP: x86: acpi: Generate SPCR table

2018-09-22 Thread Andy Shevchenko
TBD

Signed-off-by: Andy Shevchenko 
---
 arch/x86/include/asm/acpi_table.h | 25 ++
 arch/x86/lib/acpi_table.c | 82 +++
 2 files changed, 107 insertions(+)

diff --git a/arch/x86/include/asm/acpi_table.h 
b/arch/x86/include/asm/acpi_table.h
index 95fae036f6..27435871b9 100644
--- a/arch/x86/include/asm/acpi_table.h
+++ b/arch/x86/include/asm/acpi_table.h
@@ -303,6 +303,31 @@ struct acpi_mcfg_mmconfig {
 /* ACPI global NVS structure */
 struct acpi_global_nvs;
 
+/* SPCR (Serial Port Console Redirection table) */
+struct __packed acpi_spcr {
+   struct acpi_table_header header;/* Common ACPI table header */
+   u8 interface_type;  /* 0=full 16550, 1=subset of 16550 */
+   u8 reserved[3];
+   struct acpi_gen_regaddr serial_port;/* The base address of the 
Serial Port register set */
+   u8 interrupt_type;
+   u8 pc_interrupt;
+   u32 interrupt;  /* Global system interrupt */
+   u8 baud_rate;
+   u8 parity;
+   u8 stop_bits;
+   u8 flow_control;
+   u8 terminal_type;
+   u8 reserved1;
+   u16 pci_device_id;  /* Must be 0x if not PCI device */
+   u16 pci_vendor_id;  /* Must be 0x if not PCI device */
+   u8 pci_bus;
+   u8 pci_device;
+   u8 pci_function;
+   u32 pci_flags;
+   u8 pci_segment;
+   u32 reserved2;
+};
+
 /* These can be used by the target port */
 
 void acpi_fill_header(struct acpi_table_header *header, char *signature);
diff --git a/arch/x86/lib/acpi_table.c b/arch/x86/lib/acpi_table.c
index c6b2026613..551a78b11a 100644
--- a/arch/x86/lib/acpi_table.c
+++ b/arch/x86/lib/acpi_table.c
@@ -12,6 +12,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -338,6 +339,79 @@ static void acpi_create_mcfg(struct acpi_mcfg *mcfg)
header->checksum = table_compute_checksum((void *)mcfg, header->length);
 }
 
+static void acpi_create_spcr(struct acpi_spcr *spcr)
+{
+   struct acpi_table_header *header = &(spcr->header);
+   struct serial_device_info info = {0};
+   int access_size;
+   int ret;
+
+   /* Fill out header fields */
+   acpi_fill_header(header, "SPCR");
+   header->length = sizeof(struct acpi_spcr);
+   header->revision = 2;
+
+   ret = serial_getinfo();
+   if (ret)
+   debug("Can't get information of serial device: %d\n", ret);
+
+   /* Encode baud rate */
+   switch (info.baudrate) {
+   case 9600:
+   spcr->baud_rate = 3;
+   break;
+   case 19200:
+   spcr->baud_rate = 4;
+   break;
+   case 57600:
+   spcr->baud_rate = 6;
+   break;
+   case 115200:
+   spcr->baud_rate = 7;
+   break;
+   default:
+   spcr->baud_rate = 0;
+   break;
+   }
+
+   /* Encode register access size */
+   switch (info.reg_shift) {
+   case 0:
+   access_size = ACPI_ACCESS_SIZE_BYTE_ACCESS;
+   break;
+   case 1:
+   access_size = ACPI_ACCESS_SIZE_WORD_ACCESS;
+   break;
+   case 2:
+   access_size = ACPI_ACCESS_SIZE_DWORD_ACCESS;
+   break;
+   case 3:
+   access_size = ACPI_ACCESS_SIZE_QWORD_ACCESS;
+   break;
+   default:
+   access_size = ACPI_ACCESS_SIZE_UNDEFINED;
+   break;
+   }
+
+   spcr->serial_port.space_id = ACPI_ADDRESS_SPACE_MEMORY;
+   spcr->serial_port.bit_width = info.reg_width;
+   spcr->serial_port.bit_offset = info.reg_offset;
+   spcr->serial_port.access_size = access_size;
+   spcr->serial_port.addrl = info.addr >> 0;
+   spcr->serial_port.addrh = info.addr >> 32;
+
+   /* Hard coded values for now */
+   spcr->parity = 0;
+   spcr->stop_bits = 1;
+
+   /* No PCI devices for now */
+   spcr->pci_device_id = 0x;
+   spcr->pci_vendor_id = 0x;
+
+   /* Fix checksum */
+   header->checksum = table_compute_checksum((void *)spcr, header->length);
+}
+
 /*
  * QEMU's version of write_acpi_tables is defined in drivers/misc/qfw.c
  */
@@ -352,6 +426,7 @@ ulong write_acpi_tables(ulong start)
struct acpi_fadt *fadt;
struct acpi_mcfg *mcfg;
struct acpi_madt *madt;
+   struct acpi_spcr *spcr;
int i;
 
current = start;
@@ -440,6 +515,13 @@ ulong write_acpi_tables(ulong start)
acpi_add_table(rsdp, mcfg);
current = ALIGN(current, 16);
 
+   debug("ACPI:* SPCR\n");
+   spcr = (struct acpi_spcr *)current;
+   acpi_create_spcr(spcr);
+   current += spcr->header.length;
+   acpi_add_table(rsdp, spcr);
+   current = ALIGN(current, 16);
+
debug("current = %x\n", current);
 
acpi_rsdp_addr = (unsigned long)rsdp;
-- 
2.18.0

___
U-Boot mailing list

[U-Boot] [PATCH v1 1/2] WIP: serial: Introduce ->getinfo() callback

2018-09-22 Thread Andy Shevchenko
TBD

Signed-off-by: Andy Shevchenko 
---
 drivers/serial/ns16550.c   | 14 ++
 drivers/serial/serial-uclass.c | 21 +
 include/common.h   |  3 +++
 include/serial.h   | 14 ++
 4 files changed, 52 insertions(+)

diff --git a/drivers/serial/ns16550.c b/drivers/serial/ns16550.c
index f9041aa626..a996446936 100644
--- a/drivers/serial/ns16550.c
+++ b/drivers/serial/ns16550.c
@@ -334,6 +334,19 @@ static int ns16550_serial_setbrg(struct udevice *dev, int 
baudrate)
return 0;
 }
 
+static int ns16550_serial_getinfo(struct udevice *dev, struct 
serial_device_info *info)
+{
+   struct NS16550 *const com_port = dev_get_priv(dev);
+   struct ns16550_platdata *plat = com_port->plat;
+
+   info->addr_space = 0;
+   info->reg_width = 8;
+   info->reg_shift = plat->reg_shift;
+   info->reg_offset = plat->reg_offset;
+   info->addr = plat->base;
+   return 0;
+}
+
 int ns16550_serial_probe(struct udevice *dev)
 {
struct NS16550 *const com_port = dev_get_priv(dev);
@@ -440,6 +453,7 @@ const struct dm_serial_ops ns16550_serial_ops = {
.pending = ns16550_serial_pending,
.getc = ns16550_serial_getc,
.setbrg = ns16550_serial_setbrg,
+   .getinfo = ns16550_serial_getinfo,
 };
 
 #if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)
diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c
index ffdcae0931..4778302e8f 100644
--- a/drivers/serial/serial-uclass.c
+++ b/drivers/serial/serial-uclass.c
@@ -304,6 +304,25 @@ int serial_setconfig(uint config)
return 0;
 }
 
+int serial_getinfo(struct serial_device_info *info)
+{
+   struct dm_serial_ops *ops;
+
+   if (!gd->cur_serial_dev)
+   return -ENODEV;
+
+   if (!info)
+   return -EINVAL;
+
+   info->baudrate = gd->baudrate;
+
+   ops = serial_get_ops(gd->cur_serial_dev);
+   if (ops->getinfo)
+   return ops->getinfo(gd->cur_serial_dev, info);
+
+   return -EINVAL;
+}
+
 void serial_stdio_init(void)
 {
 }
@@ -421,6 +440,8 @@ static int serial_post_probe(struct udevice *dev)
if (ops->loop)
ops->loop += gd->reloc_off
 #endif
+   if (ops->getinfo)
+   ops->getinfo += gd->reloc_off;
 #endif
/* Set the baud rate */
if (ops->setbrg) {
diff --git a/include/common.h b/include/common.h
index 83b3bdc58d..0479f3eac1 100644
--- a/include/common.h
+++ b/include/common.h
@@ -349,6 +349,8 @@ void smp_set_core_boot_addr(unsigned long addr, int corenr);
 void smp_kick_all_cpus(void);
 
 /* $(CPU)/serial.c */
+struct serial_device_info;
+
 intserial_init   (void);
 void   serial_setbrg (void);
 void   serial_putc   (const char);
@@ -357,6 +359,7 @@ voidserial_puts   (const char *);
 intserial_getc   (void);
 intserial_tstc   (void);
 intserial_setconfig(uint config);
+intserial_getinfo(struct serial_device_info *info);
 
 /* $(CPU)/speed.c */
 intget_clocks (void);
diff --git a/include/serial.h b/include/serial.h
index 020cd392e8..c73477b079 100644
--- a/include/serial.h
+++ b/include/serial.h
@@ -111,6 +111,16 @@ enum serial_stop {
SERIAL_8_BITS << SERIAL_BITS_SHIFT | \
SERIAL_ONE_STOP << SERIAL_STOP_SHIFT
 
+/* REVISIT: ACPI GAS specification implied */
+struct serial_device_info {
+   unsigned int baudrate;
+   u8  addr_space; /* 0 - MMIO, 1 - IO */
+   u8  reg_width;
+   u8  reg_offset;
+   u8  reg_shift;
+   u64 addr;
+};
+
 /**
  * struct struct dm_serial_ops - Driver model serial operations
  *
@@ -201,6 +211,10 @@ struct dm_serial_ops {
 * @return 0 if OK, -ve on error
 */
int (*setconfig)(struct udevice *dev, uint serial_config);
+   /**
+* getinfo() - Get serial device information
+*/
+   int (*getinfo)(struct udevice *dev, struct serial_device_info *info);
 };
 
 /**
-- 
2.18.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 02/11] efi_loader: Initial HII protocols

2018-09-22 Thread Heinrich Schuchardt
On 10/10/2017 02:22 PM, Rob Clark wrote:
> From: Leif Lindholm 
> 
> Enough implementation of the following protocols to run Shell.efi and
> SCT.efi:
> 
>   EfiHiiConfigRoutingProtocolGuid
>   EfiHiiDatabaseProtocol
>   EfiHiiStringProtocol

The i386 Shell.efi also tries to open these before failing:

EfiHiiFontProtocol
EfiHiiImageProtocol

Best regards

Heinrich Schuchardt

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v2 2/2] arm: at91: wdt: Convert watchdog config to Kconfig

2018-09-22 Thread Petr Vorel
Hi Prasanthi,

> Convert "CONFIG_AT91SAM9_WATCHDOG" to new "CONFIG_WDT_AT91"
> Kconfig option to support driver model and device tree.

> Signed-off-by: Prasanthi Chellakumar 
> ---
>  README| 3 ---
>  arch/arm/dts/at91sam9260-smartweb.dts | 1 +
>  arch/arm/dts/at91sam9g20-taurus.dts   | 1 +
>  arch/arm/mach-at91/spl.c  | 2 +-
>  arch/arm/mach-at91/spl_at91.c | 2 +-
>  arch/arm/mach-at91/spl_atmel.c| 2 +-
>  common/board_f.c  | 2 +-
>  configs/picosam9g45_defconfig | 2 ++
>  configs/smartweb_defconfig| 2 ++
>  configs/taurus_defconfig  | 2 ++
>  doc/README.at91   | 2 +-
>  doc/README.watchdog   | 2 +-
>  include/configs/picosam9g45.h | 4 
>  include/configs/smartweb.h| 7 ---
>  include/configs/taurus.h  | 7 ---
>  scripts/config_whitelist.txt  | 2 --
>  16 files changed, 14 insertions(+), 29 deletions(-)

Your patch breaks arm926ejs and atmel.

Second you send twice, but it's the same.
https://travis-ci.org/pevik/u-boot/builds/430613730
https://travis-ci.org/pevik/u-boot/builds/430613525


Kind regards,
Petr
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v2 1/2] arm: at91: wdt: Convert watchdog driver to dm/dt

2018-09-22 Thread Petr Vorel
Hi Prasanthi,

> Convert the Watchdog driver for AT91SAM9x processors to support
> the driver model and device tree.

> Signed-off-by: Prasanthi Chellakumar 
> ---
>  arch/arm/mach-at91/include/mach/at91_wdt.h |  12 +++-
>  drivers/watchdog/Kconfig   |   7 ++
>  drivers/watchdog/Makefile  |   2 +-
>  drivers/watchdog/at91sam9_wdt.c| 106 
> +
>  4 files changed, 96 insertions(+), 31 deletions(-)

Your patch breaks arm926ejs and atmel.
https://travis-ci.org/pevik/u-boot/builds/430694055


Kind regards,
Petr
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 2/2] pico-imx6ul, pico-imx7d: Enable USB and PXE boot support

2018-09-22 Thread Otavio Salvador
Signed-off-by: Otavio Salvador 
---

 include/configs/pico-imx6ul.h | 2 ++
 include/configs/pico-imx7d.h  | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/include/configs/pico-imx6ul.h b/include/configs/pico-imx6ul.h
index 0fea2d65dd..8082b74c9c 100644
--- a/include/configs/pico-imx6ul.h
+++ b/include/configs/pico-imx6ul.h
@@ -103,6 +103,8 @@
 
 #define BOOT_TARGET_DEVICES(func) \
func(MMC, mmc, 0) \
+   func(USB, usb, 0) \
+   func(PXE, pxe, na) \
func(DHCP, dhcp, na)
 
 #include 
diff --git a/include/configs/pico-imx7d.h b/include/configs/pico-imx7d.h
index 614be99d93..2bc42a04a0 100644
--- a/include/configs/pico-imx7d.h
+++ b/include/configs/pico-imx7d.h
@@ -92,6 +92,8 @@
 
 #define BOOT_TARGET_DEVICES(func) \
func(MMC, mmc, 0) \
+   func(USB, usb, 0) \
+   func(PXE, pxe, na) \
func(DHCP, dhcp, na)
 
 #include 
-- 
2.19.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 1/2] pico-imx6ul, pico-imx7d: Use eMMC user partition by default

2018-09-22 Thread Otavio Salvador
After discussing with TechNexion about how its default setting, it is
better to install on the eMMC user partition by default, when using
DFU, so it works out of box for majority of users.

Signed-off-by: Otavio Salvador 
---

 include/configs/pico-imx6ul.h | 4 ++--
 include/configs/pico-imx7d.h  | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/configs/pico-imx6ul.h b/include/configs/pico-imx6ul.h
index 3d93205535..0fea2d65dd 100644
--- a/include/configs/pico-imx6ul.h
+++ b/include/configs/pico-imx6ul.h
@@ -56,8 +56,8 @@
 
 #define CONFIG_DFU_ENV_SETTINGS \
"dfu_alt_info=" \
-   "spl raw 0x2 0x400 mmcpart 1;" \
-   "u-boot raw 0x8a 0x400 mmcpart 1;" \
+   "spl raw 0x2 0x400;" \
+   "u-boot raw 0x8a 0x400;" \
"/boot/zImage ext4 0 1;" \
"/boot/imx6ul-pico-hobbit.dtb ext4 0 1;" \
"/boot/imx6ul-pico-pi.dtb ext4 0 1;" \
diff --git a/include/configs/pico-imx7d.h b/include/configs/pico-imx7d.h
index 0e770bf41f..614be99d93 100644
--- a/include/configs/pico-imx7d.h
+++ b/include/configs/pico-imx7d.h
@@ -45,8 +45,8 @@
 
 #define CONFIG_DFU_ENV_SETTINGS \
"dfu_alt_info=" \
-   "spl raw 0x2 0x400 mmcpart 1;" \
-   "u-boot raw 0x8a 0x400 mmcpart 1;" \
+   "spl raw 0x2 0x400;" \
+   "u-boot raw 0x8a 0x400;" \
"/boot/zImage ext4 0 1;" \
"/boot/imx7d-pico-hobbit.dtb ext4 0 1;" \
"/boot/imx7d-pico-pi.dtb ext4 0 1;" \
-- 
2.19.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot