Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

shim-15.5: add riscv64 #3

Closed
wants to merge 20 commits into from
Closed

Conversation

xypron
Copy link
Contributor

@xypron xypron commented Aug 24, 2021

Resolves #2

This series contains most patches between gnu-efi 3.0.13 and 3.0.14.
Additional patches adjust the code where shim deviates from upstream gnu-efi.

xypron and others added 18 commits August 24, 2021 17:15
GrowBuffer() expects that parameter Status is initialized.
LibGetVariableAndSize() currently passes random data from the stack.

Initialize variable Status.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Add the RISCV64 architecture

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
For each va_start() there must be a va_end().

Correct LibInstallProtocolInterfaces() and
LibUninstallProtocolInterfaces().

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
As per the PE format specification, relocation blocks must be aligned on 32-bit boundaries. Fix the dummy relocations to obey the alignment constraints.
The hidden visibility #pragma in inc/arm/efibind.h was meant to inform
the compiler that symbols with external linkage are never exported from
shared libraries [and thus never preempted] when executing in UEFI context
(since UEFI does not support shared libraries). This allows the compiler to
generate relative symbol references instead of GOT entries, which is much more
efficient since the latter need to be relocated before invoking the entry
point of the UEFI app.

However, as it turns out, this pragma is leaking into other code that does
not run in UEFI context, but simply needs to access data structures that
UEFI defines. So make the pragma dependent on whether we are building with
-ffreestanding, which is only used for bare metal code such as UEFI.

Last-Update: 2018-08-24

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

Elder versions of sbsigntool failed to build on armhf without the patch,
cf. https://launchpad.net/ubuntu/+source/gnu-efi/3.0.8-0ubuntu1~16.04.1
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
For each va_start() there must be a call to va_end().

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
AllocatePool() may return NULL. We must check the return value before
dereferencing it.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
These values are from the UEFI specification version 2.9.

Signed-off-by: David Michael <fedora.dm0@...>
Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
Add missing definition. It is needed for 'make apps'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
efisetjmp_arch.h is required for 'make apps'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
The size of FrameBufferAddr is architecture dependent. Add the missing
definition for the riscv64 architecture.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Free the buffer allocated to draw boxes.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
When compiling for x64, Visual Studio 2019's Code Analysis produces the following warnings:

C:\Projects\gnu-efi\lib\print.c(1380): warning C26451: Arithmetic overflow: Using operator '+' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator '+' to avoid overflow (io.2).
C:\Projects\gnu-efi\lib\smbios.c(47): warning C26451: Arithmetic overflow: Using operator '+' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator '+' to avoid overflow (io.2).
C:\Projects\gnu-efi\lib\str.c(289): warning C26451: Arithmetic overflow: Using operator '-' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator '-' to avoid overflow (io.2).

Fix these by adding an explicit cast to UINTN.
Acoording to what the spec says about the number of sybols [1]:

"This value should be zero for an image because COFF debugging
information is deprecated."

Changing as if not zero it causes problems to llvm-objcopy. This
affects only the architectures where COFF is not supported by objcopy
and where we build the PE header via assembly code.

[1] https://docs.microsoft.com/en-us/windows/win32/debug/pe-format
There's little reason not to derive the RISCV64 version of efibind.h
from the AARCH64 version, especially as the current version is missing
required macros such as EFI_DRIVER_ENTRY_POINT() which breaks the
compilation of some drivers.

The only major difference we introduce from AARCH64 is to consider
that any toolchain that supports RISCV64 is modern enough to support
<stdint.h>. Also, as we preserve the added definition for BOOLEAN,
we guard it with an ifndef in anticipation of MSVC RISCV64 support.

We validated these changes by confirming that they now allow gnu-efi
to be used to compile a set of UEFI drivers for RISCV64.
Shim has diverged from upstream gnu-efi in using CHAR16 (instead of WCHAR)
and CHAR8.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Shim uses ms_va_end() instead of va_end().

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Shim uses a variable ARCHES which does not exist in upstream gnu-efi.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
The string pointed to by Src will never be changed. So it can be safely
defined as IN CONST VOID*.

This avoids unnecessary conversions by callers.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
* There should be no section overlapping the header.
* The .text and the .data section should be separated.
* The virtual size of the sections should be set correctly.
* On RISC-V we need a .reloc section.

As shim has its own linker script this patch does not adjusts gnu-efi's
one.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
@xypron
Copy link
Contributor Author

xypron commented Apr 13, 2023

Shim 15.5 is obsolete. Hence closing this pull request.

@xypron xypron closed this Apr 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants