diff mbox series

roms: Support compile the efi bios for loongarch

Message ID 260307952ffe5382a55d66a4999034490e04f7df.1691653307.git.lixianglai@loongson.cn
State New
Headers show
Series roms: Support compile the efi bios for loongarch | expand

Commit Message

Xianglai Li Aug. 10, 2023, 7:42 a.m. UTC
1.Add edk2-platform submodule
2.Added loongarch UEFI BIOS support to compiled scripts.
3.The cross-compilation toolchain on x86 can be obtained from the link below:
https://github.com/loongson/build-tools/tree/2022.09.06

Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>
Cc: "Daniel P. Berrangé" <berrange@redhat.com>
Cc: Thomas Huth <thuth@redhat.com>
Cc: "Philippe Mathieu-Daudé" <philmd@linaro.org>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Xiaojuan Yang <yangxiaojuan@loongson.cn>
Cc: Song Gao <gaosong@loongson.cn>
Cc: Bibo Mao <maobibo@loongson.cn>
Signed-off-by: xianglai li <lixianglai@loongson.cn>
---
 .gitmodules            |  3 +++
 meson.build            |  2 +-
 pc-bios/meson.build    |  2 ++
 roms/edk2-build.config | 14 ++++++++++++++
 roms/edk2-build.py     |  4 ++--
 roms/edk2-platforms    |  1 +
 6 files changed, 23 insertions(+), 3 deletions(-)
 create mode 160000 roms/edk2-platforms

Comments

Bibo Mao Aug. 10, 2023, 9:58 a.m. UTC | #1
Xianglai,

I reply inline.

在 2023/8/10 15:42, xianglai li 写道:
> 1.Add edk2-platform submodule
> 2.Added loongarch UEFI BIOS support to compiled scripts.
The description is somewhat too simple, it should be paragraph. 

> 3.The cross-compilation toolchain on x86 can be obtained from the link below:
> https://github.com/loongson/build-tools/tree/2022.09.06
Fedora38 has LoongArch cross-compiler rpm package, maybe we do not need this.

> 
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>
> Cc: "Daniel P. Berrangé" <berrange@redhat.com>
> Cc: Thomas Huth <thuth@redhat.com>
> Cc: "Philippe Mathieu-Daudé" <philmd@linaro.org>
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Cc: Xiaojuan Yang <yangxiaojuan@loongson.cn>
> Cc: Song Gao <gaosong@loongson.cn>
> Cc: Bibo Mao <maobibo@loongson.cn>
> Signed-off-by: xianglai li <lixianglai@loongson.cn>
> ---
>  .gitmodules            |  3 +++
>  meson.build            |  2 +-
>  pc-bios/meson.build    |  2 ++
>  roms/edk2-build.config | 14 ++++++++++++++
>  roms/edk2-build.py     |  4 ++--
>  roms/edk2-platforms    |  1 +
>  6 files changed, 23 insertions(+), 3 deletions(-)
>  create mode 160000 roms/edk2-platforms
> 
> diff --git a/.gitmodules b/.gitmodules
> index 73cae4cd4d..0cb57123fa 100644
> --- a/.gitmodules
> +++ b/.gitmodules
> @@ -43,3 +43,6 @@
>  [submodule "tests/lcitool/libvirt-ci"]
>  	path = tests/lcitool/libvirt-ci
>  	url = https://gitlab.com/libvirt/libvirt-ci.git
> +[submodule "roms/edk2-platforms"]
> +	path = roms/edk2-platforms
> +	url = https://github.com/tianocore/edk2-platforms.git
> diff --git a/meson.build b/meson.build
> index 98e68ef0b1..b398caf2ce 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -153,7 +153,7 @@ if targetos != 'darwin'
>    modular_tcg = ['i386-softmmu', 'x86_64-softmmu']
>  endif
>  
> -edk2_targets = [ 'arm-softmmu', 'aarch64-softmmu', 'i386-softmmu', 'x86_64-softmmu' ]
> +edk2_targets = [ 'arm-softmmu', 'aarch64-softmmu', 'i386-softmmu', 'x86_64-softmmu', 'loongarch64-softmmu' ]
>  unpack_edk2_blobs = false
>  foreach target : edk2_targets
>    if target in target_dirs
> diff --git a/pc-bios/meson.build b/pc-bios/meson.build
> index a7224ef469..fc73222b6c 100644
> --- a/pc-bios/meson.build
> +++ b/pc-bios/meson.build
> @@ -9,6 +9,8 @@ if unpack_edk2_blobs
>      'edk2-i386-vars.fd',
>      'edk2-x86_64-code.fd',
>      'edk2-x86_64-secure-code.fd',
> +    'edk2-loongarch64-code.fd',
> +    'edk2-loongarch64-vars.fd',
>    ]
>  
>    foreach f : fds
> diff --git a/roms/edk2-build.config b/roms/edk2-build.config
> index 66ef9ffcb9..7960c4c2c5 100644
> --- a/roms/edk2-build.config
> +++ b/roms/edk2-build.config
> @@ -1,5 +1,6 @@
>  [global]
>  core = edk2
> +pkgs = edk2-platforms
>  
>  ####################################################################################
>  # options
> @@ -122,3 +123,16 @@ plat = RiscVVirtQemu
>  dest = ../pc-bios
>  cpy1 = FV/RISCV_VIRT.fd  edk2-riscv.fd
>  pad1 = edk2-riscv.fd     32m
> +
> +####################################################################################
> +# LoongArch64
> +
> +[build.loongach64.qemu]
> +conf = Platform/Loongson/LoongArchQemuPkg/Loongson.dsc
> +arch = LOONGARCH64
> +plat = LoongArchQemu
> +dest = ../pc-bios
> +cpy1 = FV/QEMU_EFI.fd  edk2-loongarch64-code.fd
> +pad1 = edk2-loongarch64-code.fd     4m
> +cpy2 = FV/QEMU_VARS.fd  edk2-loongarch64-vars.fd
> +pad2 = edk2-loongarch64-vars.fd     16m
> diff --git a/roms/edk2-build.py b/roms/edk2-build.py
> index 870893f7c8..dbd641e51e 100755
> --- a/roms/edk2-build.py
> +++ b/roms/edk2-build.py
> @@ -269,8 +269,8 @@ def prepare_env(cfg):
>      # for cross builds
>      if binary_exists('arm-linux-gnu-gcc'):
>          os.environ['GCC5_ARM_PREFIX'] = 'arm-linux-gnu-'
> -    if binary_exists('loongarch64-linux-gnu-gcc'):
> -        os.environ['GCC5_LOONGARCH64_PREFIX'] = 'loongarch64-linux-gnu-'
> +    if binary_exists('loongarch64-unknown-linux-gnu-gcc'):
> +        os.environ['GCC5_LOONGARCH64_PREFIX'] = 'loongarch64-unknown-linux-gnu-'
I think loongarch64-unknown-linux- is not necessary here, loongarch64-linux-gnu-
is default prefix on Fedora38, else there will be too many prefix names :)

Regards
Bibo Mao
>  
>      hostarch = os.uname().machine
>      if binary_exists('aarch64-linux-gnu-gcc') and hostarch != 'aarch64':
> diff --git a/roms/edk2-platforms b/roms/edk2-platforms
> new file mode 160000
> index 0000000000..84ccada592
> --- /dev/null
> +++ b/roms/edk2-platforms
> @@ -0,0 +1 @@
> +Subproject commit 84ccada59257a8151a592a416017fbb03b8ed3cf
Xianglai Li Aug. 10, 2023, 11:20 a.m. UTC | #2
Hi, BiBo

On 8/10/23 5:58 PM, bibo mao wrote:
> Xianglai,
>
> I reply inline.
>
> 在 2023/8/10 15:42, xianglai li 写道:
>> 1.Add edk2-platform submodule
>> 2.Added loongarch UEFI BIOS support to compiled scripts.
> The description is somewhat too simple, it should be paragraph.


Okay, I'll describe it in detail in the next version.


>> 3.The cross-compilation toolchain on x86 can be obtained from the link below:
>> https://github.com/loongson/build-tools/tree/2022.09.06
> Fedora38 has LoongArch cross-compiler rpm package, maybe we do not need this.

Okay, I'll remove it in the next version.


>> Cc: Paolo Bonzini <pbonzini@redhat.com>
>> Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>
>> Cc: "Daniel P. Berrangé" <berrange@redhat.com>
>> Cc: Thomas Huth <thuth@redhat.com>
>> Cc: "Philippe Mathieu-Daudé" <philmd@linaro.org>
>> Cc: Gerd Hoffmann <kraxel@redhat.com>
>> Cc: Xiaojuan Yang <yangxiaojuan@loongson.cn>
>> Cc: Song Gao <gaosong@loongson.cn>
>> Cc: Bibo Mao <maobibo@loongson.cn>
>> Signed-off-by: xianglai li <lixianglai@loongson.cn>
>> ---
>>   .gitmodules            |  3 +++
>>   meson.build            |  2 +-
>>   pc-bios/meson.build    |  2 ++
>>   roms/edk2-build.config | 14 ++++++++++++++
>>   roms/edk2-build.py     |  4 ++--
>>   roms/edk2-platforms    |  1 +
>>   6 files changed, 23 insertions(+), 3 deletions(-)
>>   create mode 160000 roms/edk2-platforms
>>
>> diff --git a/.gitmodules b/.gitmodules
>> index 73cae4cd4d..0cb57123fa 100644
>> --- a/.gitmodules
>> +++ b/.gitmodules
>> @@ -43,3 +43,6 @@
>>   [submodule "tests/lcitool/libvirt-ci"]
>>   	path = tests/lcitool/libvirt-ci
>>   	url = https://gitlab.com/libvirt/libvirt-ci.git
>> +[submodule "roms/edk2-platforms"]
>> +	path = roms/edk2-platforms
>> +	url = https://github.com/tianocore/edk2-platforms.git
>> diff --git a/meson.build b/meson.build
>> index 98e68ef0b1..b398caf2ce 100644
>> --- a/meson.build
>> +++ b/meson.build
>> @@ -153,7 +153,7 @@ if targetos != 'darwin'
>>     modular_tcg = ['i386-softmmu', 'x86_64-softmmu']
>>   endif
>>   
>> -edk2_targets = [ 'arm-softmmu', 'aarch64-softmmu', 'i386-softmmu', 'x86_64-softmmu' ]
>> +edk2_targets = [ 'arm-softmmu', 'aarch64-softmmu', 'i386-softmmu', 'x86_64-softmmu', 'loongarch64-softmmu' ]
>>   unpack_edk2_blobs = false
>>   foreach target : edk2_targets
>>     if target in target_dirs
>> diff --git a/pc-bios/meson.build b/pc-bios/meson.build
>> index a7224ef469..fc73222b6c 100644
>> --- a/pc-bios/meson.build
>> +++ b/pc-bios/meson.build
>> @@ -9,6 +9,8 @@ if unpack_edk2_blobs
>>       'edk2-i386-vars.fd',
>>       'edk2-x86_64-code.fd',
>>       'edk2-x86_64-secure-code.fd',
>> +    'edk2-loongarch64-code.fd',
>> +    'edk2-loongarch64-vars.fd',
>>     ]
>>   
>>     foreach f : fds
>> diff --git a/roms/edk2-build.config b/roms/edk2-build.config
>> index 66ef9ffcb9..7960c4c2c5 100644
>> --- a/roms/edk2-build.config
>> +++ b/roms/edk2-build.config
>> @@ -1,5 +1,6 @@
>>   [global]
>>   core = edk2
>> +pkgs = edk2-platforms
>>   
>>   ####################################################################################
>>   # options
>> @@ -122,3 +123,16 @@ plat = RiscVVirtQemu
>>   dest = ../pc-bios
>>   cpy1 = FV/RISCV_VIRT.fd  edk2-riscv.fd
>>   pad1 = edk2-riscv.fd     32m
>> +
>> +####################################################################################
>> +# LoongArch64
>> +
>> +[build.loongach64.qemu]
>> +conf = Platform/Loongson/LoongArchQemuPkg/Loongson.dsc
>> +arch = LOONGARCH64
>> +plat = LoongArchQemu
>> +dest = ../pc-bios
>> +cpy1 = FV/QEMU_EFI.fd  edk2-loongarch64-code.fd
>> +pad1 = edk2-loongarch64-code.fd     4m
>> +cpy2 = FV/QEMU_VARS.fd  edk2-loongarch64-vars.fd
>> +pad2 = edk2-loongarch64-vars.fd     16m
>> diff --git a/roms/edk2-build.py b/roms/edk2-build.py
>> index 870893f7c8..dbd641e51e 100755
>> --- a/roms/edk2-build.py
>> +++ b/roms/edk2-build.py
>> @@ -269,8 +269,8 @@ def prepare_env(cfg):
>>       # for cross builds
>>       if binary_exists('arm-linux-gnu-gcc'):
>>           os.environ['GCC5_ARM_PREFIX'] = 'arm-linux-gnu-'
>> -    if binary_exists('loongarch64-linux-gnu-gcc'):
>> -        os.environ['GCC5_LOONGARCH64_PREFIX'] = 'loongarch64-linux-gnu-'
>> +    if binary_exists('loongarch64-unknown-linux-gnu-gcc'):
>> +        os.environ['GCC5_LOONGARCH64_PREFIX'] = 'loongarch64-unknown-linux-gnu-'
> I think loongarch64-unknown-linux- is not necessary here, loongarch64-linux-gnu-
> is default prefix on Fedora38, else there will be too many prefix names :)


Ok!I'll fix it in the next version.

Thanks,

xianglai.


>
> Regards
> Bibo Mao
>>   
>>       hostarch = os.uname().machine
>>       if binary_exists('aarch64-linux-gnu-gcc') and hostarch != 'aarch64':
>> diff --git a/roms/edk2-platforms b/roms/edk2-platforms
>> new file mode 160000
>> index 0000000000..84ccada592
>> --- /dev/null
>> +++ b/roms/edk2-platforms
>> @@ -0,0 +1 @@
>> +Subproject commit 84ccada59257a8151a592a416017fbb03b8ed3cf
Philippe Mathieu-Daudé Aug. 10, 2023, 11:34 a.m. UTC | #3
Hi,

On 10/8/23 09:42, xianglai li wrote:
> 1.Add edk2-platform submodule
> 2.Added loongarch UEFI BIOS support to compiled scripts.
> 3.The cross-compilation toolchain on x86 can be obtained from the link below:
> https://github.com/loongson/build-tools/tree/2022.09.06
> 
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>
> Cc: "Daniel P. Berrangé" <berrange@redhat.com>
> Cc: Thomas Huth <thuth@redhat.com>
> Cc: "Philippe Mathieu-Daudé" <philmd@linaro.org>
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Cc: Xiaojuan Yang <yangxiaojuan@loongson.cn>
> Cc: Song Gao <gaosong@loongson.cn>
> Cc: Bibo Mao <maobibo@loongson.cn>
> Signed-off-by: xianglai li <lixianglai@loongson.cn>
> ---
>   .gitmodules            |  3 +++
>   meson.build            |  2 +-
>   pc-bios/meson.build    |  2 ++
>   roms/edk2-build.config | 14 ++++++++++++++
>   roms/edk2-build.py     |  4 ++--
>   roms/edk2-platforms    |  1 +
>   6 files changed, 23 insertions(+), 3 deletions(-)
>   create mode 160000 roms/edk2-platforms
> 
> diff --git a/.gitmodules b/.gitmodules
> index 73cae4cd4d..0cb57123fa 100644
> --- a/.gitmodules
> +++ b/.gitmodules
> @@ -43,3 +43,6 @@
>   [submodule "tests/lcitool/libvirt-ci"]
>   	path = tests/lcitool/libvirt-ci
>   	url = https://gitlab.com/libvirt/libvirt-ci.git
> +[submodule "roms/edk2-platforms"]
> +	path = roms/edk2-platforms
> +	url = https://github.com/tianocore/edk2-platforms.git

See "Topic 4" in [*].

  > We do need to be careful about GPL compliance (making sure users
  > have the source if we provide them the compiled firmware blob
  > for a GPL'd piece of firmware); but we don't need to necessarily
  > ship the sources in the exact same tarball as the blob.

  > [...]

  > Users of QEMU from git don't get a great firmware experience either,
  > since the firmware is in submodules, with all the usual git submodule
  > problems.

edk2-platforms.git use the same license than edk2.git, 
BSD-2-Clause-Patent, which is compatible with GPLv2. At least this is not
edk2-non-osi.git.

Still, we should discuss this generic issue before going forward with
this patch IMO.

Regards,

Phil.

[*] 
https://lore.kernel.org/qemu-devel/CAFEAcA_rziBuSwgJ9cg9m1PS5pNG58eyim+_P9hMu5nF7G70XA@mail.gmail.com/
Jiajie Chen Aug. 10, 2023, 11:48 a.m. UTC | #4
On 2023/8/10 15:42, xianglai li wrote:
> 1.Add edk2-platform submodule
> 2.Added loongarch UEFI BIOS support to compiled scripts.
> 3.The cross-compilation toolchain on x86 can be obtained from the link below:
> https://github.com/loongson/build-tools/tree/2022.09.06
> 
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>
> Cc: "Daniel P. Berrangé" <berrange@redhat.com>
> Cc: Thomas Huth <thuth@redhat.com>
> Cc: "Philippe Mathieu-Daudé" <philmd@linaro.org>
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Cc: Xiaojuan Yang <yangxiaojuan@loongson.cn>
> Cc: Song Gao <gaosong@loongson.cn>
> Cc: Bibo Mao <maobibo@loongson.cn>
> Signed-off-by: xianglai li <lixianglai@loongson.cn>
> ---
>   .gitmodules            |  3 +++
>   meson.build            |  2 +-
>   pc-bios/meson.build    |  2 ++
>   roms/edk2-build.config | 14 ++++++++++++++
>   roms/edk2-build.py     |  4 ++--
>   roms/edk2-platforms    |  1 +
>   6 files changed, 23 insertions(+), 3 deletions(-)
>   create mode 160000 roms/edk2-platforms
> 
> diff --git a/.gitmodules b/.gitmodules
> index 73cae4cd4d..0cb57123fa 100644
> --- a/.gitmodules
> +++ b/.gitmodules
> @@ -43,3 +43,6 @@
>   [submodule "tests/lcitool/libvirt-ci"]
>   	path = tests/lcitool/libvirt-ci
>   	url = https://gitlab.com/libvirt/libvirt-ci.git
> +[submodule "roms/edk2-platforms"]
> +	path = roms/edk2-platforms
> +	url = https://github.com/tianocore/edk2-platforms.git
> diff --git a/meson.build b/meson.build
> index 98e68ef0b1..b398caf2ce 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -153,7 +153,7 @@ if targetos != 'darwin'
>     modular_tcg = ['i386-softmmu', 'x86_64-softmmu']
>   endif
>   
> -edk2_targets = [ 'arm-softmmu', 'aarch64-softmmu', 'i386-softmmu', 'x86_64-softmmu' ]
> +edk2_targets = [ 'arm-softmmu', 'aarch64-softmmu', 'i386-softmmu', 'x86_64-softmmu', 'loongarch64-softmmu' ]
>   unpack_edk2_blobs = false
>   foreach target : edk2_targets
>     if target in target_dirs
> diff --git a/pc-bios/meson.build b/pc-bios/meson.build
> index a7224ef469..fc73222b6c 100644
> --- a/pc-bios/meson.build
> +++ b/pc-bios/meson.build
> @@ -9,6 +9,8 @@ if unpack_edk2_blobs
>       'edk2-i386-vars.fd',
>       'edk2-x86_64-code.fd',
>       'edk2-x86_64-secure-code.fd',
> +    'edk2-loongarch64-code.fd',
> +    'edk2-loongarch64-vars.fd',
>     ]
>   
>     foreach f : fds
> diff --git a/roms/edk2-build.config b/roms/edk2-build.config
> index 66ef9ffcb9..7960c4c2c5 100644
> --- a/roms/edk2-build.config
> +++ b/roms/edk2-build.config
> @@ -1,5 +1,6 @@
>   [global]
>   core = edk2
> +pkgs = edk2-platforms
>   
>   ####################################################################################
>   # options
> @@ -122,3 +123,16 @@ plat = RiscVVirtQemu
>   dest = ../pc-bios
>   cpy1 = FV/RISCV_VIRT.fd  edk2-riscv.fd
>   pad1 = edk2-riscv.fd     32m
> +
> +####################################################################################
> +# LoongArch64
> +
> +[build.loongach64.qemu]

typo: s/loongach64/loongarch64/

> +conf = Platform/Loongson/LoongArchQemuPkg/Loongson.dsc
> +arch = LOONGARCH64
> +plat = LoongArchQemu
> +dest = ../pc-bios
> +cpy1 = FV/QEMU_EFI.fd  edk2-loongarch64-code.fd
> +pad1 = edk2-loongarch64-code.fd     4m
> +cpy2 = FV/QEMU_VARS.fd  edk2-loongarch64-vars.fd
> +pad2 = edk2-loongarch64-vars.fd     16m
> diff --git a/roms/edk2-build.py b/roms/edk2-build.py
> index 870893f7c8..dbd641e51e 100755
> --- a/roms/edk2-build.py
> +++ b/roms/edk2-build.py
> @@ -269,8 +269,8 @@ def prepare_env(cfg):
>       # for cross builds
>       if binary_exists('arm-linux-gnu-gcc'):
>           os.environ['GCC5_ARM_PREFIX'] = 'arm-linux-gnu-'
> -    if binary_exists('loongarch64-linux-gnu-gcc'):
> -        os.environ['GCC5_LOONGARCH64_PREFIX'] = 'loongarch64-linux-gnu-'
> +    if binary_exists('loongarch64-unknown-linux-gnu-gcc'):
> +        os.environ['GCC5_LOONGARCH64_PREFIX'] = 'loongarch64-unknown-linux-gnu-'
>   
>       hostarch = os.uname().machine
>       if binary_exists('aarch64-linux-gnu-gcc') and hostarch != 'aarch64':
> diff --git a/roms/edk2-platforms b/roms/edk2-platforms
> new file mode 160000
> index 0000000000..84ccada592
> --- /dev/null
> +++ b/roms/edk2-platforms
> @@ -0,0 +1 @@
> +Subproject commit 84ccada59257a8151a592a416017fbb03b8ed3cf
Xianglai Li Aug. 10, 2023, 12:27 p.m. UTC | #5
Hi, Jiajie:

On 8/10/23 7:48 PM, Jiajie Chen wrote:
> On 2023/8/10 15:42, xianglai li wrote:
>> 1.Add edk2-platform submodule
>> 2.Added loongarch UEFI BIOS support to compiled scripts.
>> 3.The cross-compilation toolchain on x86 can be obtained from the 
>> link below:
>> https://github.com/loongson/build-tools/tree/2022.09.06
>>
>> Cc: Paolo Bonzini <pbonzini@redhat.com>
>> Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>
>> Cc: "Daniel P. Berrangé" <berrange@redhat.com>
>> Cc: Thomas Huth <thuth@redhat.com>
>> Cc: "Philippe Mathieu-Daudé" <philmd@linaro.org>
>> Cc: Gerd Hoffmann <kraxel@redhat.com>
>> Cc: Xiaojuan Yang <yangxiaojuan@loongson.cn>
>> Cc: Song Gao <gaosong@loongson.cn>
>> Cc: Bibo Mao <maobibo@loongson.cn>
>> Signed-off-by: xianglai li <lixianglai@loongson.cn>
>> ---
>>   .gitmodules            |  3 +++
>>   meson.build            |  2 +-
>>   pc-bios/meson.build    |  2 ++
>>   roms/edk2-build.config | 14 ++++++++++++++
>>   roms/edk2-build.py     |  4 ++--
>>   roms/edk2-platforms    |  1 +
>>   6 files changed, 23 insertions(+), 3 deletions(-)
>>   create mode 160000 roms/edk2-platforms
>>
>> diff --git a/.gitmodules b/.gitmodules
>> index 73cae4cd4d..0cb57123fa 100644
>> --- a/.gitmodules
>> +++ b/.gitmodules
>> @@ -43,3 +43,6 @@
>>   [submodule "tests/lcitool/libvirt-ci"]
>>       path = tests/lcitool/libvirt-ci
>>       url = https://gitlab.com/libvirt/libvirt-ci.git
>> +[submodule "roms/edk2-platforms"]
>> +    path = roms/edk2-platforms
>> +    url = https://github.com/tianocore/edk2-platforms.git
>> diff --git a/meson.build b/meson.build
>> index 98e68ef0b1..b398caf2ce 100644
>> --- a/meson.build
>> +++ b/meson.build
>> @@ -153,7 +153,7 @@ if targetos != 'darwin'
>>     modular_tcg = ['i386-softmmu', 'x86_64-softmmu']
>>   endif
>>   -edk2_targets = [ 'arm-softmmu', 'aarch64-softmmu', 'i386-softmmu', 
>> 'x86_64-softmmu' ]
>> +edk2_targets = [ 'arm-softmmu', 'aarch64-softmmu', 'i386-softmmu', 
>> 'x86_64-softmmu', 'loongarch64-softmmu' ]
>>   unpack_edk2_blobs = false
>>   foreach target : edk2_targets
>>     if target in target_dirs
>> diff --git a/pc-bios/meson.build b/pc-bios/meson.build
>> index a7224ef469..fc73222b6c 100644
>> --- a/pc-bios/meson.build
>> +++ b/pc-bios/meson.build
>> @@ -9,6 +9,8 @@ if unpack_edk2_blobs
>>       'edk2-i386-vars.fd',
>>       'edk2-x86_64-code.fd',
>>       'edk2-x86_64-secure-code.fd',
>> +    'edk2-loongarch64-code.fd',
>> +    'edk2-loongarch64-vars.fd',
>>     ]
>>       foreach f : fds
>> diff --git a/roms/edk2-build.config b/roms/edk2-build.config
>> index 66ef9ffcb9..7960c4c2c5 100644
>> --- a/roms/edk2-build.config
>> +++ b/roms/edk2-build.config
>> @@ -1,5 +1,6 @@
>>   [global]
>>   core = edk2
>> +pkgs = edk2-platforms
>> ####################################################################################
>>   # options
>> @@ -122,3 +123,16 @@ plat = RiscVVirtQemu
>>   dest = ../pc-bios
>>   cpy1 = FV/RISCV_VIRT.fd  edk2-riscv.fd
>>   pad1 = edk2-riscv.fd     32m
>> +
>> +#################################################################################### 
>>
>> +# LoongArch64
>> +
>> +[build.loongach64.qemu]
>
> typo: s/loongach64/loongarch64/


I'm sorry for that, I'll fix it in the next version.

Thanks,

xianglai


>
>> +conf = Platform/Loongson/LoongArchQemuPkg/Loongson.dsc
>> +arch = LOONGARCH64
>> +plat = LoongArchQemu
>> +dest = ../pc-bios
>> +cpy1 = FV/QEMU_EFI.fd  edk2-loongarch64-code.fd
>> +pad1 = edk2-loongarch64-code.fd     4m
>> +cpy2 = FV/QEMU_VARS.fd  edk2-loongarch64-vars.fd
>> +pad2 = edk2-loongarch64-vars.fd     16m
>> diff --git a/roms/edk2-build.py b/roms/edk2-build.py
>> index 870893f7c8..dbd641e51e 100755
>> --- a/roms/edk2-build.py
>> +++ b/roms/edk2-build.py
>> @@ -269,8 +269,8 @@ def prepare_env(cfg):
>>       # for cross builds
>>       if binary_exists('arm-linux-gnu-gcc'):
>>           os.environ['GCC5_ARM_PREFIX'] = 'arm-linux-gnu-'
>> -    if binary_exists('loongarch64-linux-gnu-gcc'):
>> -        os.environ['GCC5_LOONGARCH64_PREFIX'] = 
>> 'loongarch64-linux-gnu-'
>> +    if binary_exists('loongarch64-unknown-linux-gnu-gcc'):
>> +        os.environ['GCC5_LOONGARCH64_PREFIX'] = 
>> 'loongarch64-unknown-linux-gnu-'
>>         hostarch = os.uname().machine
>>       if binary_exists('aarch64-linux-gnu-gcc') and hostarch != 
>> 'aarch64':
>> diff --git a/roms/edk2-platforms b/roms/edk2-platforms
>> new file mode 160000
>> index 0000000000..84ccada592
>> --- /dev/null
>> +++ b/roms/edk2-platforms
>> @@ -0,0 +1 @@
>> +Subproject commit 84ccada59257a8151a592a416017fbb03b8ed3cf
Xianglai Li Aug. 10, 2023, 12:54 p.m. UTC | #6
On 8/10/23 7:34 PM, Philippe Mathieu-Daudé wrote:
> Hi,
>
> On 10/8/23 09:42, xianglai li wrote:
>> 1.Add edk2-platform submodule
>> 2.Added loongarch UEFI BIOS support to compiled scripts.
>> 3.The cross-compilation toolchain on x86 can be obtained from the 
>> link below:
>> https://github.com/loongson/build-tools/tree/2022.09.06
>>
>> Cc: Paolo Bonzini <pbonzini@redhat.com>
>> Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>
>> Cc: "Daniel P. Berrangé" <berrange@redhat.com>
>> Cc: Thomas Huth <thuth@redhat.com>
>> Cc: "Philippe Mathieu-Daudé" <philmd@linaro.org>
>> Cc: Gerd Hoffmann <kraxel@redhat.com>
>> Cc: Xiaojuan Yang <yangxiaojuan@loongson.cn>
>> Cc: Song Gao <gaosong@loongson.cn>
>> Cc: Bibo Mao <maobibo@loongson.cn>
>> Signed-off-by: xianglai li <lixianglai@loongson.cn>
>> ---
>>   .gitmodules            |  3 +++
>>   meson.build            |  2 +-
>>   pc-bios/meson.build    |  2 ++
>>   roms/edk2-build.config | 14 ++++++++++++++
>>   roms/edk2-build.py     |  4 ++--
>>   roms/edk2-platforms    |  1 +
>>   6 files changed, 23 insertions(+), 3 deletions(-)
>>   create mode 160000 roms/edk2-platforms
>>
>> diff --git a/.gitmodules b/.gitmodules
>> index 73cae4cd4d..0cb57123fa 100644
>> --- a/.gitmodules
>> +++ b/.gitmodules
>> @@ -43,3 +43,6 @@
>>   [submodule "tests/lcitool/libvirt-ci"]
>>       path = tests/lcitool/libvirt-ci
>>       url = https://gitlab.com/libvirt/libvirt-ci.git
>> +[submodule "roms/edk2-platforms"]
>> +    path = roms/edk2-platforms
>> +    url = https://github.com/tianocore/edk2-platforms.git
>
> See "Topic 4" in [*].
>
>  > We do need to be careful about GPL compliance (making sure users
>  > have the source if we provide them the compiled firmware blob
>  > for a GPL'd piece of firmware); but we don't need to necessarily
>  > ship the sources in the exact same tarball as the blob.
>
>  > [...]
>
>  > Users of QEMU from git don't get a great firmware experience either,
>  > since the firmware is in submodules, with all the usual git submodule
>  > problems.
>
> edk2-platforms.git use the same license than edk2.git, 
> BSD-2-Clause-Patent, which is compatible with GPLv2. At least this is not
> edk2-non-osi.git.
>
> Still, we should discuss this generic issue before going forward with
> this patch IMO.
>

Okay, I also think that there is no need to include EDK2 source code in 
the tar ball,

you can package the git repository of QEMU for distribution,

and compile the BIOS binary package before release,

so that there is no need to include BIOS code,

QEMU users can also get the source code of BIOS through Git Submodule.

This is only my opinion, and I look forward to the outcome of the final 
discussion.


Thanks,

xianglai


> Regards,
>
> Phil.
>
> [*] 
> https://lore.kernel.org/qemu-devel/CAFEAcA_rziBuSwgJ9cg9m1PS5pNG58eyim+_P9hMu5nF7G70XA@mail.gmail.com/
Xianglai Li Sept. 1, 2023, 8:55 a.m. UTC | #7
ping!


Hi,Philippe Mathieu-Daudé:

Would like to know if there is any progress in the discussion on this issue?


In addition, is the compilation of our UEFI done on the fedora38 
operating system

or on a later version of fedora?


The loongarch cross-compilation tool on the fedora38 operating system is 
a bit old,

and there is a problem with the UEFI of the compiled loongarch,

so I want to ask about the UEFI compilation environment.


Thanks,

xianglai


On 8/10/23 8:54 PM, lixianglai wrote:
>
> On 8/10/23 7:34 PM, Philippe Mathieu-Daudé wrote:
>> Hi,
>>
>> On 10/8/23 09:42, xianglai li wrote:
>>> 1.Add edk2-platform submodule
>>> 2.Added loongarch UEFI BIOS support to compiled scripts.
>>> 3.The cross-compilation toolchain on x86 can be obtained from the 
>>> link below:
>>> https://github.com/loongson/build-tools/tree/2022.09.06
>>>
>>> Cc: Paolo Bonzini <pbonzini@redhat.com>
>>> Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>
>>> Cc: "Daniel P. Berrangé" <berrange@redhat.com>
>>> Cc: Thomas Huth <thuth@redhat.com>
>>> Cc: "Philippe Mathieu-Daudé" <philmd@linaro.org>
>>> Cc: Gerd Hoffmann <kraxel@redhat.com>
>>> Cc: Xiaojuan Yang <yangxiaojuan@loongson.cn>
>>> Cc: Song Gao <gaosong@loongson.cn>
>>> Cc: Bibo Mao <maobibo@loongson.cn>
>>> Signed-off-by: xianglai li <lixianglai@loongson.cn>
>>> ---
>>>   .gitmodules            |  3 +++
>>>   meson.build            |  2 +-
>>>   pc-bios/meson.build    |  2 ++
>>>   roms/edk2-build.config | 14 ++++++++++++++
>>>   roms/edk2-build.py     |  4 ++--
>>>   roms/edk2-platforms    |  1 +
>>>   6 files changed, 23 insertions(+), 3 deletions(-)
>>>   create mode 160000 roms/edk2-platforms
>>>
>>> diff --git a/.gitmodules b/.gitmodules
>>> index 73cae4cd4d..0cb57123fa 100644
>>> --- a/.gitmodules
>>> +++ b/.gitmodules
>>> @@ -43,3 +43,6 @@
>>>   [submodule "tests/lcitool/libvirt-ci"]
>>>       path = tests/lcitool/libvirt-ci
>>>       url = https://gitlab.com/libvirt/libvirt-ci.git
>>> +[submodule "roms/edk2-platforms"]
>>> +    path = roms/edk2-platforms
>>> +    url = https://github.com/tianocore/edk2-platforms.git
>>
>> See "Topic 4" in [*].
>>
>>  > We do need to be careful about GPL compliance (making sure users
>>  > have the source if we provide them the compiled firmware blob
>>  > for a GPL'd piece of firmware); but we don't need to necessarily
>>  > ship the sources in the exact same tarball as the blob.
>>
>>  > [...]
>>
>>  > Users of QEMU from git don't get a great firmware experience either,
>>  > since the firmware is in submodules, with all the usual git submodule
>>  > problems.
>>
>> edk2-platforms.git use the same license than edk2.git, 
>> BSD-2-Clause-Patent, which is compatible with GPLv2. At least this is 
>> not
>> edk2-non-osi.git.
>>
>> Still, we should discuss this generic issue before going forward with
>> this patch IMO.
>>
>
> Okay, I also think that there is no need to include EDK2 source code 
> in the tar ball,
>
> you can package the git repository of QEMU for distribution,
>
> and compile the BIOS binary package before release,
>
> so that there is no need to include BIOS code,
>
> QEMU users can also get the source code of BIOS through Git Submodule.
>
> This is only my opinion, and I look forward to the outcome of the 
> final discussion.
>
>
> Thanks,
>
> xianglai
>
>
>> Regards,
>>
>> Phil.
>>
>> [*] 
>> https://lore.kernel.org/qemu-devel/CAFEAcA_rziBuSwgJ9cg9m1PS5pNG58eyim+_P9hMu5nF7G70XA@mail.gmail.com/
Gerd Hoffmann Sept. 4, 2023, 11:42 a.m. UTC | #8
Hi,

> The loongarch cross-compilation tool on the fedora38 operating system is a
> bit old,

The gcc 12 -> 13 update for the cross compilers landed meanwhile,
right now we have:

    binutils-loongarch64-linux-gnu.x86_64 2.39-4.fc38    @updates
    gcc-loongarch64-linux-gnu.x86_64      13.2.1-1.fc38  @updates

Trying to build the loongarch firmware throws errors
(edk2/edk2-platforms repos, master branch, checkout
being a few days old):

build.py...
/home/kraxel/projects/edk2-platforms/Platform/Loongson/LoongArchQemuPkg/Loongson.dsc(...): error 4000: Instance of library class [AcpiPlatformLib] is not found
	in [/home/kraxel/projects/edk2/OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf] [LOONGARCH64]
	consumed by module [/home/kraxel/projects/edk2/OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf]

take care,
  Gerd
Xianglai Li Sept. 4, 2023, 12:17 p.m. UTC | #9
On 9/4/23 7:42 PM, Gerd Hoffmann wrote:
>    Hi,
>
>> The loongarch cross-compilation tool on the fedora38 operating system is a
>> bit old,
> The gcc 12 -> 13 update for the cross compilers landed meanwhile,
> right now we have:
>
>      binutils-loongarch64-linux-gnu.x86_64 2.39-4.fc38    @updates
>      gcc-loongarch64-linux-gnu.x86_64      13.2.1-1.fc38  @updates

Compile with the compiler of the above version to compile UEFI normally,

but there are some problems running on qemu,

which require a later version of binutils to solve.

It means that we need UEFI compiled by the following version

of the compiler to run properly on qemu:

binutils-loongarch64-linux-gnu-2.40-3.fc39.x86_64
gcc-loongarch64-linux-gnu-13.2.1-1.fc39.x86_64

>
> Trying to build the loongarch firmware throws errors
> (edk2/edk2-platforms repos, master branch, checkout
> being a few days old):
>
> build.py...
> /home/kraxel/projects/edk2-platforms/Platform/Loongson/LoongArchQemuPkg/Loongson.dsc(...): error 4000: Instance of library class [AcpiPlatformLib] is not found
> 	in [/home/kraxel/projects/edk2/OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf] [LOONGARCH64]
> 	consumed by module [/home/kraxel/projects/edk2/OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf]

This compilation error is caused by a change in the AcpiPlatformLib 
position in edk2, which is referenced by loongarch's UEFI.

We have already submitted the patch to the edk2 community and may need a 
day or two to merge.

You can get the corresponding submission from the link below:

https://github.com/tianocore/edk2-platforms/pull/94/files


Thanks,

xianglai


> take care,
>    Gerd
diff mbox series

Patch

diff --git a/.gitmodules b/.gitmodules
index 73cae4cd4d..0cb57123fa 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -43,3 +43,6 @@ 
 [submodule "tests/lcitool/libvirt-ci"]
 	path = tests/lcitool/libvirt-ci
 	url = https://gitlab.com/libvirt/libvirt-ci.git
+[submodule "roms/edk2-platforms"]
+	path = roms/edk2-platforms
+	url = https://github.com/tianocore/edk2-platforms.git
diff --git a/meson.build b/meson.build
index 98e68ef0b1..b398caf2ce 100644
--- a/meson.build
+++ b/meson.build
@@ -153,7 +153,7 @@  if targetos != 'darwin'
   modular_tcg = ['i386-softmmu', 'x86_64-softmmu']
 endif
 
-edk2_targets = [ 'arm-softmmu', 'aarch64-softmmu', 'i386-softmmu', 'x86_64-softmmu' ]
+edk2_targets = [ 'arm-softmmu', 'aarch64-softmmu', 'i386-softmmu', 'x86_64-softmmu', 'loongarch64-softmmu' ]
 unpack_edk2_blobs = false
 foreach target : edk2_targets
   if target in target_dirs
diff --git a/pc-bios/meson.build b/pc-bios/meson.build
index a7224ef469..fc73222b6c 100644
--- a/pc-bios/meson.build
+++ b/pc-bios/meson.build
@@ -9,6 +9,8 @@  if unpack_edk2_blobs
     'edk2-i386-vars.fd',
     'edk2-x86_64-code.fd',
     'edk2-x86_64-secure-code.fd',
+    'edk2-loongarch64-code.fd',
+    'edk2-loongarch64-vars.fd',
   ]
 
   foreach f : fds
diff --git a/roms/edk2-build.config b/roms/edk2-build.config
index 66ef9ffcb9..7960c4c2c5 100644
--- a/roms/edk2-build.config
+++ b/roms/edk2-build.config
@@ -1,5 +1,6 @@ 
 [global]
 core = edk2
+pkgs = edk2-platforms
 
 ####################################################################################
 # options
@@ -122,3 +123,16 @@  plat = RiscVVirtQemu
 dest = ../pc-bios
 cpy1 = FV/RISCV_VIRT.fd  edk2-riscv.fd
 pad1 = edk2-riscv.fd     32m
+
+####################################################################################
+# LoongArch64
+
+[build.loongach64.qemu]
+conf = Platform/Loongson/LoongArchQemuPkg/Loongson.dsc
+arch = LOONGARCH64
+plat = LoongArchQemu
+dest = ../pc-bios
+cpy1 = FV/QEMU_EFI.fd  edk2-loongarch64-code.fd
+pad1 = edk2-loongarch64-code.fd     4m
+cpy2 = FV/QEMU_VARS.fd  edk2-loongarch64-vars.fd
+pad2 = edk2-loongarch64-vars.fd     16m
diff --git a/roms/edk2-build.py b/roms/edk2-build.py
index 870893f7c8..dbd641e51e 100755
--- a/roms/edk2-build.py
+++ b/roms/edk2-build.py
@@ -269,8 +269,8 @@  def prepare_env(cfg):
     # for cross builds
     if binary_exists('arm-linux-gnu-gcc'):
         os.environ['GCC5_ARM_PREFIX'] = 'arm-linux-gnu-'
-    if binary_exists('loongarch64-linux-gnu-gcc'):
-        os.environ['GCC5_LOONGARCH64_PREFIX'] = 'loongarch64-linux-gnu-'
+    if binary_exists('loongarch64-unknown-linux-gnu-gcc'):
+        os.environ['GCC5_LOONGARCH64_PREFIX'] = 'loongarch64-unknown-linux-gnu-'
 
     hostarch = os.uname().machine
     if binary_exists('aarch64-linux-gnu-gcc') and hostarch != 'aarch64':
diff --git a/roms/edk2-platforms b/roms/edk2-platforms
new file mode 160000
index 0000000000..84ccada592
--- /dev/null
+++ b/roms/edk2-platforms
@@ -0,0 +1 @@ 
+Subproject commit 84ccada59257a8151a592a416017fbb03b8ed3cf