summaryrefslogtreecommitdiffstats
path: root/sys/amd64
diff options
context:
space:
mode:
authorjkim <jkim@FreeBSD.org>2009-08-20 22:58:05 +0000
committerjkim <jkim@FreeBSD.org>2009-08-20 22:58:05 +0000
commitf00e60c6b2379e2575b65c7711080967f3b85594 (patch)
tree0258985c2e088dac669cfb693babe784d3a12413 /sys/amd64
parent3b3396fb4af18410a50db1a9b4062ca57eabb903 (diff)
downloadFreeBSD-src-f00e60c6b2379e2575b65c7711080967f3b85594.zip
FreeBSD-src-f00e60c6b2379e2575b65c7711080967f3b85594.tar.gz
Check whether the SMBIOS reports reasonable amount of memory. If it is
less than "avail memory", fall back to Maxmem to avoid user confusion. We use SMBIOS information to display "real memory" since r190599 but some broken SMBIOS implementation reported only half of actual memory. Tested by: bz Approved by: re (kib)
Diffstat (limited to 'sys/amd64')
-rw-r--r--sys/amd64/amd64/machdep.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c
index 2c54be2..0bfd7ad 100644
--- a/sys/amd64/amd64/machdep.c
+++ b/sys/amd64/amd64/machdep.c
@@ -236,19 +236,21 @@ cpu_startup(dummy)
#ifdef PERFMON
perfmon_init();
#endif
+ realmem = Maxmem;
+
+ /*
+ * Display physical memory if SMBIOS reports reasonable amount.
+ */
+ memsize = 0;
sysenv = getenv("smbios.memory.enabled");
if (sysenv != NULL) {
- memsize = (uintmax_t)strtoul(sysenv, (char **)NULL, 10);
+ memsize = (uintmax_t)strtoul(sysenv, (char **)NULL, 10) << 10;
freeenv(sysenv);
- } else
- memsize = 0;
- if (memsize > 0)
- printf("real memory = %ju (%ju MB)\n", memsize << 10,
- memsize >> 10);
- else
- printf("real memory = %ju (%ju MB)\n", ptoa((uintmax_t)Maxmem),
- ptoa((uintmax_t)Maxmem) / 1048576);
- realmem = Maxmem;
+ }
+ if (memsize < ptoa((uintmax_t)cnt.v_free_count))
+ memsize = ptoa((uintmax_t)Maxmem);
+ printf("real memory = %ju (%ju MB)\n", memsize, memsize >> 20);
+
/*
* Display any holes after the first chunk of extended memory.
*/
OpenPOWER on IntegriCloud