Skip to content

Commit

Permalink
support 32 bit UEFI firmware on x86_64/i386 architecture (bsc#1208003…
Browse files Browse the repository at this point in the history
…, jsc#PED-2569)
  • Loading branch information
wfeldt committed Feb 14, 2023
1 parent 4455812 commit 2d13f81
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/lib/bootloader/bootloader_factory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def boot_efi?
def proposed_name
return "grub2-efi" if Systeminfo.efi_mandatory?

return "grub2-efi" if Yast::Arch.x86_64 && boot_efi?
return "grub2-efi" if (Yast::Arch.x86_64 || Yast::Arch.i386) && boot_efi?

"grub2" # grub2 works(c) everywhere
end
Expand Down
2 changes: 1 addition & 1 deletion src/lib/bootloader/grub2efi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def name
def packages
res = super

case Yast::Arch.architecture
case Systeminfo.efi_arch
when "i386"
res << "grub2-i386-efi"
when "x86_64"
Expand Down
2 changes: 1 addition & 1 deletion src/lib/bootloader/grub_install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def target
return @target if @target

arch = Yast::Arch.architecture
target = efi ? EFI_TARGETS[arch] : NON_EFI_TARGETS[arch]
target = efi ? EFI_TARGETS[Systeminfo.efi_arch] : NON_EFI_TARGETS[arch]

if !target
raise "unsupported combination of architecture #{arch} and " \
Expand Down
31 changes: 31 additions & 0 deletions src/lib/bootloader/systeminfo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ def secure_boot_active?
#
# @return [Boolean] true if secure boot is (in principle) supported on this system
def secure_boot_supported?
# no shim for i386 (yet)
return false if efi_arch == "i386"

efi_supported? || s390_secure_boot_supported? || ppc_secure_boot_supported?
end

Expand All @@ -36,6 +39,9 @@ def secure_boot_supported?
# @param bootloader_name [String] bootloader name
# @return [Boolean] true if secure boot setting is available with this bootloader
def secure_boot_available?(bootloader_name)
# no shim for i386 (yet)
return false if efi_arch == "i386"

efi_used?(bootloader_name) || s390_secure_boot_available? || ppc_secure_boot_available?
end

Expand Down Expand Up @@ -108,6 +114,31 @@ def shim_needed?(bootloader_name, secure_boot)
secure_boot && efi_used?(bootloader_name)
end

# UEFI platform size (32 or 64 bits).
#
# On x86_64 systems both variants are possible.
#
# @return [Integer] platform size - or 0 if not applicable
def efi_platform_size
bits = File.read("/sys/firmware/efi/fw_platform_size").to_i
log.info "EFI platform size: #{bits}"
bits
rescue StandardError
0
end

# Effective UEFI architecture.
#
# Usually the same as the architecture except on x86_64 where it
# depends on the platform size.
#
# @return [String] architecture name
def efi_arch
arch = Yast::Arch.architecture
arch = "i386" if arch == "x86_64" && efi_platform_size == 32
arch
end

# Check if secure boot is (in principle) available on an s390 machine.
#
# @return [Boolean] true if this is an s390 machine and it has secure boot support
Expand Down

0 comments on commit 2d13f81

Please sign in to comment.