From 4319b1c2e5e9dc7d5c6e145b7363124246f7ac54 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sun, 26 Nov 2006 20:01:47 +0000 Subject: 2006-11-26 Samuel Thibault Fix i386's 4GiB overflow. * i386/i386at/model_dep.c (mem_size_init): Truncate memory size to 4GiB. --- i386/i386at/model_dep.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'i386') diff --git a/i386/i386at/model_dep.c b/i386/i386at/model_dep.c index 1546077..9f0a1c7 100644 --- a/i386/i386at/model_dep.c +++ b/i386/i386at/model_dep.c @@ -196,11 +196,18 @@ void db_reset_cpu() void mem_size_init() { + vm_size_t phys_last_kb; + /* Physical memory on all PCs starts at physical address 0. XX make it a constant. */ phys_first_addr = 0; - phys_last_addr = 0x100000 + (boot_info.mem_upper * 0x400); + phys_last_kb = 0x400 + boot_info.mem_upper; + /* Avoid 4GiB overflow. */ + if (phys_last_kb < 0x400 || phys_last_kb >= 0x400000) + phys_last_kb = 0x400000 - 1; + + phys_last_addr = phys_last_kb * 0x400; avail_remaining = phys_last_addr - (0x100000 - (boot_info.mem_lower * 0x400) - 0x1000); -- cgit v1.2.3