acpi: Add EBDA address sanity checks and work around bogus GCC warning
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 <stdint.h>
#include <stddef.h>
+#include <sys/cpu.h>
-#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];
