Subject: port-i386/33659: allow biosbasemem/biosextmem to be modified (again)
To: None <port-i386-maintainer@netbsd.org, gnats-admin@netbsd.org,>
From: None <mrg@eterna.com.au>
List: netbsd-bugs
Date: 06/07/2006 04:15:00
>Number:         33659
>Category:       port-i386
>Synopsis:       allow biosbasemem/biosextmem to be modified (again)
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    port-i386-maintainer
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Jun 07 04:15:00 +0000 2006
>Originator:     matthew green
>Release:        NetBSD 3.99.20
>Organization:
people's front against (bozotic) www (softwar foundation)
>Environment:
System: NetBSD phat-bass.eterna.com.au 3.99.20 NetBSD 3.99.20 (GENERIC) #5: Tue Jun  6 17:25:23 PDT 2006  mrg@lilkev.eterna23.net:/home/obj/i386/usr/src/sys/arch/i386/compile/GENERIC i386
Architecture: i386
Machine: i386
>Description:
	
	the ability to set biosbasemem/biosextmem in the kernel binary and
	have those used has been lost in recent times.  this is because the
	code to deal with them is conditional on their optional definition
	in the kernel confg, not the run-time value of their variables.

>How-To-Repeat:

	want to limit memory in a standard kernel like GENERIC, but fail
	with newer kernels...

>Fix:

	change includes the normal memory checking code when REALBASEMEM
	and REALEXTMEM are defined, but only executes it if both
	biosbasemem and biosextmem are 0.  now once again i can gdb --write
	on /netbd and my changes are actually used.

Index: sys/arch/i386/i386/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/i386/i386/machdep.c,v
retrieving revision 1.573
diff -p -r1.573 machdep.c
*** sys/arch/i386/i386/machdep.c	22 May 2006 13:44:53 -0000	1.573
--- sys/arch/i386/i386/machdep.c	7 Jun 2006 02:03:34 -0000
*************** void	dumpsys(void);
*** 270,278 ****
  void	init386(paddr_t);
  void	initgdt(union descriptor *);
  
- #if !defined(REALBASEMEM) && !defined(REALEXTMEM)
  void	add_mem_cluster(uint64_t, uint64_t, uint32_t);
- #endif /* !defnied(REALBASEMEM) && !defined(REALEXTMEM) */
  
  extern int time_adjusted;
  
--- 270,276 ----
*************** void cpu_init_idt()
*** 1338,1344 ****
  	lidt(&region);
  }
  
- #if !defined(REALBASEMEM) && !defined(REALEXTMEM)
  void
  add_mem_cluster(uint64_t seg_start, uint64_t seg_end, uint32_t type)
  {
--- 1336,1341 ----
*************** add_mem_cluster(uint64_t seg_start, uint
*** 1418,1424 ****
  	physmem += atop(mem_clusters[mem_cluster_cnt].size);
  	mem_cluster_cnt++;
  }
- #endif /* !defined(REALBASEMEM) && !defined(REALEXTMEM) */
  
  void
  initgdt(union descriptor *tgdt)
--- 1415,1420 ----
*************** init386(paddr_t first_avail)
*** 1459,1467 ****
  	union descriptor *tgdt;
  	extern void consinit(void);
  	extern struct extent *iomem_ex;
- #if !defined(REALBASEMEM) && !defined(REALEXTMEM)
  	struct btinfo_memmap *bim;
- #endif
  	struct region_descriptor region;
  	int x, first16q;
  	uint64_t seg_start, seg_end;
--- 1455,1461 ----
*************** init386(paddr_t first_avail)
*** 1554,1566 ****
  	 */
  	pmap_bootstrap((vaddr_t)atdevbase + IOM_SIZE);
  
- #if !defined(REALBASEMEM) && !defined(REALEXTMEM)
  	/*
  	 * Check to see if we have a memory map from the BIOS (passed
  	 * to us by the boot program.
  	 */
! 	bim = lookup_bootinfo(BTINFO_MEMMAP);
! 	if (bim != NULL && bim->num > 0) {
  #ifdef DEBUG_MEMLOAD
  		printf("BIOS MEMORY MAP (%d ENTRIES):\n", bim->num);
  #endif
--- 1548,1559 ----
  	 */
  	pmap_bootstrap((vaddr_t)atdevbase + IOM_SIZE);
  
  	/*
  	 * Check to see if we have a memory map from the BIOS (passed
  	 * to us by the boot program.
  	 */
! 	if (biosbasemem == 0 && biosextmem == 0 &&
! 	    (bim = lookup_bootinfo(BTINFO_MEMMAP)) != NULL && bim->num > 0) {
  #ifdef DEBUG_MEMLOAD
  		printf("BIOS MEMORY MAP (%d ENTRIES):\n", bim->num);
  #endif
*************** init386(paddr_t first_avail)
*** 1618,1624 ****
  				    bim->entry[x].type);
  		}
  	}
! #endif /* ! REALBASEMEM && ! REALEXTMEM */
  	/*
  	 * If the loop above didn't find any valid segment, fall back to
  	 * former code.
--- 1611,1617 ----
  				    bim->entry[x].type);
  		}
  	}
! 
  	/*
  	 * If the loop above didn't find any valid segment, fall back to
  	 * former code.