Linux-kernel mailing list archive 1998-10,: [patch] 2.1.89, 2GB physical memory, CONFIG_MAX_MEMSIZE

# [patch] 2.1.89, 2GB physical memory, CONFIG_MAX_MEMSIZE

MOLNAR Ingo (mingo@chiara.csoma.elte.hu)
Mon, 9 Mar 1998 03:50:26 +0100 (CET)

- Messages sorted by: [ date ][ thread ][ subject ][ author ]
- Next message: Isaac Connor: "2.1.8* kernels and md raid0"
- Previous message: Andi Kleen: "Re: ip forwarding question"
- Next in thread: H. Peter Anvin: "Re: [patch] 2.1.89, 2GB physical memory, CONFIG_MAX_MEMSIZE"
- Reply: H. Peter Anvin: "Re: [patch] 2.1.89, 2GB physical memory, CONFIG_MAX_MEMSIZE"

On Sat, 7 Mar 1998, Trevor Johnson wrote:

> > Does there exist a patch for 2.0.33 that will permit the use of
> > 2GB of physical memory?
>
> Ingo Molnar made a patch for 2.1.77 or so. I think it only works with the
> Pentium Pro. [...]

the patch works on my 2x P5 SMP board also. Here is a new version against
2.1.89, it removes all those hardcoded constants and adds
CONFIG_MAX_MEMSIZE, max physical memory is settable:

(Pentium/K5/5x86/6x86) Processor family
[ ] Math emulation
[*] More than 1 gigabyte physical memory
(0x80000000) Max physical memory

this constant is properly fed into all other kernel places, there should
be no more 0xc0000000 dependencies left. Both 2G/2G and 3G/1G splits have
been sanity booted and i havent had any problems so far.

[there still seem to be lots of compile-time dependencies on PAGE_OFFSET,
so that making it a config-time option seems to be the right solution.
There would be too much overhead from a run-time setup i think.]

-- mingo

--- linux/arch/i386/config.in.orig Sat Mar 14 11:37:33 1998
+++ linux/arch/i386/config.in Sat Mar 14 13:51:18 1998
@@ -17,6 +17,12 @@
Pentium/K5/5x86/6x86 CONFIG_M586 \
PPro/K6/6x86MX CONFIG_M686" Pentium
bool 'Math emulation' CONFIG_MATH_EMULATION
+bool 'More than 1 gigabyte physical memory' CONFIG_MORE_MEM
+if [ "$CONFIG_MORE_MEM" = "y" ]; then
+hex ' Max physical memory' CONFIG_MAX_MEMSIZE 0x40000000
+else
+CONFIG_MAX_MEMSIZE=0x40000000
+fi
endmenu
mainmenu_option next_comment
--- linux/Documentation/Configure.help.orig Sat Mar 14 13:52:29 1998
+++ linux/Documentation/Configure.help Sat Mar 14 14:00:19 1998
@@ -103,6 +103,19 @@
you are not sure, say Y; apart from resulting in a 45kB bigger
kernel, it won't hurt.
+More than 1 gigabyte physical memory
+CONFIG_MORE_MEM
+ Linux/x86 can use up to 3.8 gigabytes of physical memory. Default is
+ max 1 gigabyte physical memory, thus N is enough for most systems.
+
+Max physical memory
+CONFIG_MAX_MEMSIZE
+ Default (1 GB) is 0x40000000. A system with 2G physical memory should
+ use a value of 0x88000000, a system with 3.8G memory should use
+ something 0xF0000000. A bit of experimentation with the limit wont hurt,
+ the kernel needs a ~128M window for vmalloc() plus PCI space uses up some
+ memory too, thus addresses above FD000000 should rather be kept free.
+
Normal floppy disk support
CONFIG_BLK_DEV_FD
If you want to use your floppy disk drive(s) under Linux, say
--- linux/include/asm-i386/page.h.orig Sat Mar 14 11:41:03 1998
+++ linux/include/asm-i386/page.h Sat Mar 14 14:00:45 1998
@@ -7,6 +7,7 @@
#define PAGE_MASK (~(PAGE_SIZE-1))
#ifdef __KERNEL__
+#ifndef __ASSEMBLY__
#define STRICT_MM_TYPECHECKS
@@ -52,12 +53,13 @@
#define __pgprot(x) (x)
#endif
+#endif /* !__ASSEMBLY__ */
/* to align the pointer to the (next) page boundary */
#define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
/* This handles the memory map.. */
-#define PAGE_OFFSET 0xC0000000
+#define PAGE_OFFSET (0xFFFFFFFF-CONFIG_MAX_MEMSIZE+0x00000001)
#define __pa(x) ((unsigned long)(x)-PAGE_OFFSET)
#define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET))
#define MAP_NR(addr) (__pa(addr) >> PAGE_SHIFT)
--- linux/include/asm-i386/processor.h.orig Sat Mar 14 11:43:02 1998
+++ linux/include/asm-i386/processor.h Sat Mar 14 14:00:45 1998
@@ -10,6 +10,7 @@
#include <asm/vm86.h>
#include <asm/math_emu.h>
#include <asm/segment.h>
+#include <asm/page.h>
/*
* CPU type and hardware bug flags. Kept separately for each CPU.
@@ -71,10 +72,9 @@
extern unsigned int BIOS_revision;
/*
- * User space process size: 3GB. This is hardcoded into a few places,
- * so don't change it unless you know what you are doing.
+ * User space process size: 3GB (default).
*/
-#define TASK_SIZE (0xC0000000UL)
+#define TASK_SIZE (PAGE_OFFSET)
/* This decides where the kernel will search for a free chunk of vm
* space during mmap's.
--- linux/include/asm-i386/uaccess.h.orig Sat Mar 14 11:44:26 1998
+++ linux/include/asm-i386/uaccess.h Sat Mar 14 14:00:58 1998
@@ -5,6 +5,7 @@
* User space memory access functions
*/
#include <linux/sched.h>
+#include <asm/page.h>
#define VERIFY_READ 0
#define VERIFY_WRITE 1
@@ -21,7 +22,7 @@
#define KERNEL_DS MAKE_MM_SEG(0xFFFFFFFF)
-#define USER_DS MAKE_MM_SEG(0xC0000000)
+#define USER_DS MAKE_MM_SEG(PAGE_OFFSET)
#define get_ds() (KERNEL_DS)
#define get_fs() (current->addr_limit)
--- linux/drivers/char/apm_bios.c.orig Sat Mar 14 11:46:01 1998
+++ linux/drivers/char/apm_bios.c Sat Mar 14 11:46:52 1998
@@ -1203,17 +1203,17 @@
* even though they are called in protected mode.
*/
set_base(gdt[APM_40 >> 3],
- 0xc0000000 + ((unsigned long)0x40 << 4));
+ __va((unsigned long)0x40 << 4));
set_limit(gdt[APM_40 >> 3], 4096 - (0x40 << 4));
apm_bios_entry.offset = apm_bios_info.offset;
apm_bios_entry.segment = APM_CS;
set_base(gdt[APM_CS >> 3],
- 0xc0000000 + ((unsigned long)apm_bios_info.cseg << 4));
+ __va((unsigned long)apm_bios_info.cseg << 4));
set_base(gdt[APM_CS_16 >> 3],
- 0xc0000000 + ((unsigned long)apm_bios_info.cseg_16 << 4));
+ __va((unsigned long)apm_bios_info.cseg_16 << 4));
set_base(gdt[APM_DS >> 3],
- 0xc0000000 + ((unsigned long)apm_bios_info.dseg << 4));
+ __va((unsigned long)apm_bios_info.dseg << 4));
if (apm_bios_info.version == 0x100) {
set_limit(gdt[APM_CS >> 3], 64 * 1024);
set_limit(gdt[APM_CS_16 >> 3], 64 * 1024);
--- linux/arch/i386/mm/init.c.orig Sat Mar 14 11:47:31 1998
+++ linux/arch/i386/mm/init.c Sat Mar 14 12:07:46 1998
@@ -204,8 +204,8 @@
/* unmap the original low memory mappings */
pgd_val(pg_dir[0]) = 0;
- /* Map whole memory from 0xC0000000 */
- pg_dir += 768;
+ /* Map whole memory from PAGE_OFFSET */
+ pg_dir += USER_PGD_PTRS;
while (address < end_mem) {
/*
* If we're running on a Pentium CPU, we can use the 4MB
--- linux/arch/i386/kernel/process.c.orig Sat Jan 3 09:44:17 1998
+++ linux/arch/i386/kernel/process.c Sat Mar 14 13:23:30 1998
@@ -314,10 +314,10 @@
/* Remap the kernel at virtual address zero, as well as offset zero
from the kernel segment. This assumes the kernel segment starts at
- virtual address 0xc0000000. */
+ virtual address PAGE_OFFSET. */
- memcpy (swapper_pg_dir, swapper_pg_dir + 768,
- sizeof (swapper_pg_dir [0]) * 256);
+ memcpy (swapper_pg_dir, swapper_pg_dir + USER_PGD_PTRS,
+ sizeof (swapper_pg_dir [0]) * KERNEL_PGD_PTRS);
/* Make sure the first page is mapped to the start of physical memory.
It is normally not mapped, to trap kernel NULL pointer dereferences. */
--- linux/arch/i386/kernel/head.S.orig Sat Mar 14 09:15:59 1998
+++ linux/arch/i386/kernel/head.S Sat Mar 14 15:28:23 1998
@@ -8,9 +8,13 @@
*/
.text
+#include <linux/config.h>
#include <linux/tasks.h>
#include <linux/linkage.h>
#include <asm/segment.h>
+#include <asm/page.h>
+#include <asm/pgtable.h>
+
#define CL_MAGIC_ADDR 0x90020
#define CL_MAGIC 0xA33F
@@ -54,9 +58,9 @@
* be using the global pages.
*
* NOTE! We have to correct for the fact that we're
- * not yet offset 0xC0000000..
+ * not yet offset PAGE_OFFSET..
*/
-#define cr4_bits mmu_cr4_features-0xC0000000
+#define cr4_bits mmu_cr4_features-PAGE_OFFSET
movl %cr4,%eax # Turn on 4Mb pages
orl cr4_bits,%eax
movl %eax,%cr4
@@ -368,7 +372,7 @@
* sets up a idt with 256 entries pointing to
* ignore_int, interrupt gates. It doesn't actually load
* idt - that can be done only after paging has been enabled
- * and the kernel moved to 0xC0000000. Interrupts
+ * and the kernel moved to PAGE_OFFSET. Interrupts
* are enabled elsewhere, when we can be relatively
* sure everything is ok.
*/
@@ -444,14 +448,16 @@
/*
* This is initialized to create a identity-mapping at 0-4M (for bootup
* purposes) and another mapping of the 0-4M area at virtual address
- * 0xC0000000.
+ * PAGE_OFFSET.
*/
.org 0x1000
ENTRY(swapper_pg_dir)
.long 0x00102007
- .fill 767,4,0
+ .fill USER_PGD_PTRS-1,4,0
+ /* default: 767 entries */
.long 0x00102007
- .fill 255,4,0
+ /* default: 255 entries */
+ .fill KERNEL_PGD_PTRS-1,4,0
/*
* The page tables are initialized to only 4MB here - the final page
@@ -614,8 +620,8 @@
.fill 256,8,0 # idt is uninitialized
/*
- * This gdt setup gives the kernel a 1GB address space at virtual
- * address 0xC0000000 - space enough for expansion, I hope.
+ * This gdt setup gives the kernel a CONFIG_MAX_MEMSIZE sized address space at
+ * virtual address PAGE_OFFSET.
*
* This contains up to 8192 quadwords depending on NR_TASKS - 64kB of
* gdt entries. Ugh.
--- linux/arch/i386/kernel/trampoline.S.orig Sat Mar 14 11:51:04 1998
+++ linux/arch/i386/kernel/trampoline.S Sat Mar 14 11:56:53 1998
@@ -26,8 +26,10 @@
* entries except for the gdt one..
*/
+#include <linux/config.h>
#include <linux/linkage.h>
#include <asm/segment.h>
+#include <asm/page.h>
.data
@@ -62,7 +64,7 @@
gdt_48:
.word 0x0800 # gdt limit = 2048, 256 GDT entries
- .long gdt_table-0xc0000000 # gdt base = gdt (first SMP CPU)
+ .long gdt_table-PAGE_OFFSET # gdt base = gdt (first SMP CPU)
.globl SYMBOL_NAME(trampoline_end)
SYMBOL_NAME_LABEL(trampoline_end)
--- linux/arch/i386/Makefile.orig Sat Mar 14 11:31:20 1998
+++ linux/arch/i386/Makefile Sat Mar 14 15:31:37 1998
@@ -58,6 +58,9 @@
DRIVERS := $(DRIVERS) arch/i386/math-emu/math.a
endif
+memsize:
+ @echo "__memsize__ = 0x$(CONFIG_MAX_MEMSIZE);" > arch/i386/.memsize.lds
+
arch/i386/kernel: dummy
$(MAKE) linuxsubdirs SUBDIRS=arch/i386/kernel
@@ -66,27 +69,27 @@
MAKEBOOT = $(MAKE) -C arch/$(ARCH)/boot
-zImage: vmlinux
+zImage: vmlinux memsize
@$(MAKEBOOT) zImage
-bzImage: vmlinux
+bzImage: vmlinux memsize
@$(MAKEBOOT) bzImage
compressed: zImage
-zlilo: vmlinux
+zlilo: vmlinux memsize
@$(MAKEBOOT) BOOTIMAGE=zImage zlilo
-bzlilo: vmlinux
+bzlilo: vmlinux memsize
@$(MAKEBOOT) BOOTIMAGE=bzImage zlilo
-zdisk: vmlinux
+zdisk: vmlinux memsize
@$(MAKEBOOT) BOOTIMAGE=zImage zdisk
-bzdisk: vmlinux
+bzdisk: vmlinux memsize
@$(MAKEBOOT) BOOTIMAGE=bzImage zdisk
-install: vmlinux
+install: vmlinux memsize
@$(MAKEBOOT) BOOTIMAGE=bzImage install
archclean:
--- linux/arch/i386/vmlinux.lds.orig Sat Mar 14 15:45:43 1998
+++ linux/arch/i386/vmlinux.lds Sat Mar 14 13:25:15 1998
@@ -1,12 +1,13 @@
/* ld script to make i386 Linux kernel
* Written by Martin Mares <mj@atrey.karlin.mff.cuni.cz>
*/
+INCLUDE arch/i386/.memsize.lds
OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
OUTPUT_ARCH(i386)
ENTRY(_start)
SECTIONS
{
- . = 0xc0100000;
+ . = (0xffffffff-__memsize__) + 0x00100001;
_text = .; /* Text and read-only data */
.text : {
*(.text)

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu

- Next message: Isaac Connor: "2.1.8* kernels and md raid0"
- Previous message: Andi Kleen: "Re: ip forwarding question"
- Next in thread: H. Peter Anvin: "Re: [patch] 2.1.89, 2GB physical memory, CONFIG_MAX_MEMSIZE"
- Reply: H. Peter Anvin: "Re: [patch] 2.1.89, 2GB physical memory, CONFIG_MAX_MEMSIZE"