From f3621c7bcc04476ba7561e5ecba9269b539a7b5b Mon Sep 17 00:00:00 2001 From: mintsuki Date: Fri, 1 Jul 2022 15:04:57 +0200 Subject: [PATCH] acpi: Add EBDA address sanity checks and work around bogus GCC warning --- .github/workflows/check.yml | 3 +++ common/lib/acpi.h | 14 +++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 20de8938..14d06ab8 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -20,3 +20,6 @@ jobs: - name: Build the bootloader (LLVM) run: ./bootstrap && ./configure TOOLCHAIN=llvm --enable-werror --enable-all && make all && make maintainer-clean + + - name: Build the bootloader (GCC) + run: ./bootstrap && ./configure LIMINE_CC=gcc LIMINE_LD=ld LIMINE_OBJCOPY=objcopy LIMINE_OBJDUMP=objdump LIMINE_READELF=readelf --enable-werror --enable-all && make all && make maintainer-clean diff --git a/common/lib/acpi.h b/common/lib/acpi.h index b1d37c9f..58361e72 100644 --- a/common/lib/acpi.h +++ b/common/lib/acpi.h @@ -3,8 +3,20 @@ #include #include +#include -#define EBDA ((size_t)(*((volatile uint16_t *)0x40e)) * 16) +#define EBDA (ebda_get()) + +static inline uintptr_t ebda_get(void) { + uintptr_t ebda = (uintptr_t)mminw(0x40e) << 4; + + // Sanity checks + if (ebda < 0x80000 || ebda >= 0xa0000) { + ebda = 0x80000; + } + + return ebda; +} struct sdt { char signature[4];