From a26c89d8d42b9971e5e29adbe2aea4243d5c7ff5 Mon Sep 17 00:00:00 2001 From: Fabian Ruhland Date: Fri, 11 Oct 2024 10:25:42 +0200 Subject: [PATCH] Test --- .github/workflows/build.yml | 28 ----------- towboot/src/boot/config_tables.rs | 82 +++++++++++++++++++++---------- towboot/src/boot/mod.rs | 6 ++- 3 files changed, 59 insertions(+), 57 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0d12762..e8ca3f1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,31 +1,5 @@ on: [push] jobs: - test: - # Make sure that everything works on the newest Ubuntu. - runs-on: ubuntu-24.04 - steps: - - uses: actions/checkout@v4 - - name: Install Rust - uses: dtolnay/rust-toolchain@nightly - - name: Cache Cargo - uses: Swatinem/rust-cache@v2 - with: - shared-key: cargo-${{ hashFiles('**/Cargo.lock') }} - cache-all-crates: true - cache-on-failure: true - - name: Install qemu - run: sudo apt-get update && sudo apt-get install -y --no-install-recommends qemu-system-x86 - - name: Enable KVM group perms - run: | - echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules - sudo udevadm control --reload-rules - sudo udevadm trigger --name-match=kvm - # https://github.blog/changelog/2023-02-23-hardware-accelerated-android-virtualization-on-actions-windows-and-linux-larger-hosted-runners/ - - name: Run tests - uses: clechasseur/rs-cargo@v2 - with: - command: test - args: --package tests build: # Applications linked against glibc only work on that version of glibc # (or newer ones), so this is effectively the oldest version the release @@ -35,7 +9,6 @@ jobs: # but Ubuntu 20.04 has OpenSSL 1.1 which newer ones don't have, so we need # to go with at least 22.04. runs-on: ubuntu-22.04 - needs: test steps: - uses: actions/checkout@v4 - name: Install Rust @@ -98,7 +71,6 @@ jobs: # Downloading them requires logging in with an Apple ID, # which is not possible in the CI. The macOS runners include it. runs-on: macos-latest - needs: test steps: - uses: actions/checkout@v4 - name: Install Rust for x86_64-apple and aarch64-apple diff --git a/towboot/src/boot/config_tables.rs b/towboot/src/boot/config_tables.rs index f6fb59f..c718c40 100644 --- a/towboot/src/boot/config_tables.rs +++ b/towboot/src/boot/config_tables.rs @@ -4,7 +4,7 @@ use alloc::collections::BTreeSet; use alloc::slice; use alloc::vec::Vec; -use log::{debug, warn}; +use log::{debug, info, warn}; use multiboot12::information::InfoBuilder; use acpi::rsdp::Rsdp; use smbioslib::{SMBiosEntryPoint32, SMBiosEntryPoint64}; @@ -39,43 +39,71 @@ pub(super) fn parse_for_multiboot(info_builder: &mut InfoBuilder) { handled_guids.insert(table.guid); match table.guid { - ACPI_GUID => handle_acpi(&table, info_builder), - ACPI2_GUID => handle_acpi(&table, info_builder), - DEBUG_IMAGE_INFO_GUID => debug!("ignoring image debug info"), - DXE_SERVICES_GUID => debug!("ignoring dxe services table"), - HAND_OFF_BLOCK_LIST_GUID => debug!("ignoring hand-off block list"), - LZMA_COMPRESS_GUID => debug!("ignoring lzma filesystem"), - MEMORY_STATUS_CODE_RECORD_GUID => debug!("ignoring early memory info"), - MEMORY_TYPE_INFORMATION_GUID => debug!("ignoring early memory info"), - SMBIOS_GUID => handle_smbios(&table, info_builder), - SMBIOS3_GUID => handle_smbios(&table, info_builder), - guid => debug!("ignoring table {guid}"), + ACPI_GUID => { + info!("ACPI {}", table.guid); + handle_acpi(&table, info_builder) + }, + ACPI2_GUID => { + info!("ACPIv2 {}", table.guid); + handle_acpi2(&table, info_builder) + }, + DEBUG_IMAGE_INFO_GUID => info!("ignoring image debug info {}", table.guid), + DXE_SERVICES_GUID => info!("ignoring dxe services table {}", table.guid), + HAND_OFF_BLOCK_LIST_GUID => info!("ignoring hand-off block list {}", table.guid), + LZMA_COMPRESS_GUID => info!("ignoring lzma filesystem {}", table.guid), + MEMORY_STATUS_CODE_RECORD_GUID => info!("ignoring early memory info {}", table.guid), + MEMORY_TYPE_INFORMATION_GUID => info!("ignoring early memory info {}", table.guid), + SMBIOS_GUID => { + info!("SMBIOS {}", table.guid); + handle_smbios(&table, info_builder) + }, + SMBIOS3_GUID => { + info!("SMBIOSv3 {}", table.guid); + handle_smbios(&table, info_builder) + }, + guid => info!("ignoring table {guid}"), } } } -/// Parse the ACPI RSDP and create the Multiboot struct for it. fn handle_acpi(table: &ConfigTableEntry, info_builder: &mut InfoBuilder) { - debug!("handling ACPI RSDP"); + debug!("handling ACPI RSDP version 1"); + let rsdp = unsafe { *(table.address as *const Rsdp) }; + if rsdp.validate().is_err() { + warn!("the RSDP is invalid"); + return; + } + if rsdp.revision() != 0 { + warn!("invalid RSDP revision (expected: 0, got: {})", rsdp.revision()); + return; + } + + info_builder.set_rsdp_v1( + rsdp.signature(), rsdp.checksum(), + rsdp.oem_id().as_bytes()[0..6].try_into().unwrap(), + rsdp.revision(), rsdp.rsdt_address(), + ); +} + +/// Parse the ACPI RSDP and create the Multiboot struct for it. +fn handle_acpi2(table: &ConfigTableEntry, info_builder: &mut InfoBuilder) { + debug!("handling ACPI RSDP version 2"); let rsdp = unsafe { *(table.address as *const Rsdp) }; if rsdp.validate().is_err() { warn!("the RSDP is invalid"); return; } - if rsdp.revision() == 0 { - info_builder.set_rsdp_v1( - rsdp.signature(), rsdp.checksum(), - rsdp.oem_id().as_bytes()[0..6].try_into().unwrap(), - rsdp.revision(), rsdp.rsdt_address(), - ); - } else { - info_builder.set_rsdp_v2( - rsdp.signature(), rsdp.checksum(), - rsdp.oem_id().as_bytes()[0..6].try_into().unwrap(), - rsdp.revision(), rsdp.rsdt_address(), rsdp.length(), - rsdp.xsdt_address(), rsdp.ext_checksum(), - ); + if rsdp.revision() != 0 { + warn!("invalid RSDP revision (expected: >0, got: {})", rsdp.revision()); + return; } + + info_builder.set_rsdp_v2( + rsdp.signature(), rsdp.checksum(), + rsdp.oem_id().as_bytes()[0..6].try_into().unwrap(), + rsdp.revision(), rsdp.rsdt_address(), rsdp.length(), + rsdp.xsdt_address(), rsdp.ext_checksum(), + ); } /// The entry point for SMBIOS. diff --git a/towboot/src/boot/mod.rs b/towboot/src/boot/mod.rs index 27acd89..18d35eb 100644 --- a/towboot/src/boot/mod.rs +++ b/towboot/src/boot/mod.rs @@ -434,13 +434,15 @@ impl EntryPoint { /// Jump to the loaded kernel. /// This requires everything else to be ready and won't return. fn jump(self, signature: u32, info: Vec) -> ! { - if let Self::Uefi(entry_address) = self { + loop {} + + /*if let Self::Uefi(entry_address) = self { self.jump_uefi(entry_address, signature, info) } else if let Self::Multiboot(entry_address) = self { self.jump_multiboot(entry_address, signature, info) } else { panic!("invalid entry point") - } + }*/ } /// Jump to the loaded kernel, UEFI-style, eg. just passing the information.