svn commit: r258176 - in head/sys: amd64/amd64 i386/i386

Justin T. Gibbs gibbs at FreeBSD.org
Fri Nov 15 16:05:56 UTC 2013


Author: gibbs
Date: Fri Nov 15 16:05:55 2013
New Revision: 258176
URL: http://svnweb.freebsd.org/changeset/base/258176

Log:
  Fix accounting for hw.realmem on the i386 and amd64 platforms.
  
  sys/i386/i386/machdep.c:
  sys/amd64/amd64/machdep.c:
  	The value reported by FreeBSD as "real memory" when booting
  	doesn't match what is later reported by sysctl as hw.realmem.
  	This is due to the fact that the value printed during the
  	boot process is fetched from smbios data (when possible),
  	and accounts for holes in physical memory. On the other
  	hand, the value of hw.realmem is unconditionally set to be
  	one larger than the highest page of the physical address
  	space.
  
  	Fix this by setting hw.realmem to the same value printed
  	during boot, this makes hw.realmem honour it's name and
  	account properly for physical memory present in the system.
  
  Submitted by:	Roger Pau Monné
  Reviewed by:	gibbs

Modified:
  head/sys/amd64/amd64/machdep.c
  head/sys/i386/i386/machdep.c

Modified: head/sys/amd64/amd64/machdep.c
==============================================================================
--- head/sys/amd64/amd64/machdep.c	Fri Nov 15 16:03:32 2013	(r258175)
+++ head/sys/amd64/amd64/machdep.c	Fri Nov 15 16:05:55 2013	(r258176)
@@ -256,7 +256,6 @@ cpu_startup(dummy)
 #ifdef PERFMON
 	perfmon_init();
 #endif
-	realmem = Maxmem;
 
 	/*
 	 * Display physical memory if SMBIOS reports reasonable amount.
@@ -270,6 +269,7 @@ cpu_startup(dummy)
 	if (memsize < ptoa((uintmax_t)cnt.v_free_count))
 		memsize = ptoa((uintmax_t)Maxmem);
 	printf("real memory  = %ju (%ju MB)\n", memsize, memsize >> 20);
+	realmem = atop(memsize);
 
 	/*
 	 * Display any holes after the first chunk of extended memory.

Modified: head/sys/i386/i386/machdep.c
==============================================================================
--- head/sys/i386/i386/machdep.c	Fri Nov 15 16:03:32 2013	(r258175)
+++ head/sys/i386/i386/machdep.c	Fri Nov 15 16:05:55 2013	(r258176)
@@ -294,7 +294,6 @@ cpu_startup(dummy)
 #ifdef PERFMON
 	perfmon_init();
 #endif
-	realmem = Maxmem;
 
 	/*
 	 * Display physical memory if SMBIOS reports reasonable amount.
@@ -308,6 +307,7 @@ cpu_startup(dummy)
 	if (memsize < ptoa((uintmax_t)cnt.v_free_count))
 		memsize = ptoa((uintmax_t)Maxmem);
 	printf("real memory  = %ju (%ju MB)\n", memsize, memsize >> 20);
+	realmem = atop(memsize);
 
 	/*
 	 * Display any holes after the first chunk of extended memory.


More information about the svn-src-head mailing list