public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* kvm with above 2 giga (new clean patchs)
@ 2007-08-14 15:00 Izik Eidus
       [not found] ` <1187103640.5854.11.camel-wV29XY6ncz+I84jL4+POOYeT0m0igiSA0E9HWUfgJXw@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Izik Eidus @ 2007-08-14 15:00 UTC (permalink / raw)
  To: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

Hello,
this are clean patch's for the above 2giga issue.
nothing really new,
thanks for Luca, Anthony, and Ryan for their comments, i tired to fix
the issues they talked about.

anyway what we have is:

bochs_bios_ram_patch: this patch add another mapping to the bios at the
e820.

qemu_typedefs_fix: this patch fix some typedefs at qemu and allow it to
run with up to 3.75 giga ram.

qemu_new_memory_map: teach qemu and kvmctl, how to use this new kind of
memory maping.

rmode_tss_base_typedef_bugfix: fix typedef bug in the rmode_tss_base
function.

kvm_new_slot_patch: add new slot to kvm.


enjoy! :)





-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: kvm with above 2 giga (new clean patchs)
       [not found] ` <1187103640.5854.11.camel-wV29XY6ncz+I84jL4+POOYeT0m0igiSA0E9HWUfgJXw@public.gmane.org>
@ 2007-08-14 15:17   ` Izik Eidus
       [not found]     ` <1187104635.11302.5.camel-wV29XY6ncz+I84jL4+POOYeT0m0igiSA0E9HWUfgJXw@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Izik Eidus @ 2007-08-14 15:17 UTC (permalink / raw)
  To: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

[-- Attachment #1: Type: text/plain, Size: 745 bytes --]

sorry, the patchs are here.

On Tue, 2007-08-14 at 18:00 +0300, Izik Eidus wrote:
> Hello,
> this are clean patch's for the above 2giga issue.
> nothing really new,
> thanks for Luca, Anthony, and Ryan for their comments, i tired to fix
> the issues they talked about.
> 
> anyway what we have is:
> 
> bochs_bios_ram_patch: this patch add another mapping to the bios at the
> e820.
> 
> qemu_typedefs_fix: this patch fix some typedefs at qemu and allow it to
> run with up to 3.75 giga ram.
> 
> qemu_new_memory_map: teach qemu and kvmctl, how to use this new kind of
> memory maping.
> 
> rmode_tss_base_typedef_bugfix: fix typedef bug in the rmode_tss_base
> function.
> 
> kvm_new_slot_patch: add new slot to kvm.
> 
> 
> enjoy! :)
> 
> 
> 

[-- Attachment #2: bochs_bios_ram_patch --]
[-- Type: text/x-patch, Size: 7259 bytes --]

Index: rombios.c
===================================================================
RCS file: /cvsroot/bochs/bochs/bios/rombios.c,v
retrieving revision 1.182
diff -u -r1.182 rombios.c
--- rombios.c	1 Aug 2007 17:09:51 -0000	1.182
+++ rombios.c	14 Aug 2007 10:33:39 -0000
@@ -4077,24 +4077,32 @@
 }
 #endif
 
+struct MemoryMap {
+    Bit32u start;
+    Bit16u extra_start;
+    Bit32u end;
+    Bit8u extra_end;
+};
+
+typedef struct MemoryMap *MemoryMap_t;
 
-void set_e820_range(ES, DI, start, end, type)
+void set_e820_range(ES, DI, MemMap, type)
      Bit16u ES;
      Bit16u DI;
-     Bit32u start;
-     Bit32u end;
+     MemoryMap_t MemMap;
      Bit16u type;
 {
-    write_word(ES, DI, start);
-    write_word(ES, DI+2, start >> 16);
-    write_word(ES, DI+4, 0x00);
-    write_word(ES, DI+6, 0x00);
-
-    end -= start;
-    write_word(ES, DI+8, end);
-    write_word(ES, DI+10, end >> 16);
-    write_word(ES, DI+12, 0x0000);
-    write_word(ES, DI+14, 0x0000);
+    write_word(ES, DI, MemMap->start);
+    write_word(ES, DI+2, MemMap->start >> 16);
+    write_word(ES, DI+4, MemMap->extra_start);
+    write_word(ES, DI+6, 0x0);
+
+    MemMap->end -= MemMap->start;
+    MemMap->extra_end -= MemMap->extra_start;
+    write_word(ES, DI+8, MemMap->end);
+    write_word(ES, DI+10, MemMap->end >> 16);
+    write_word(ES, DI+12, MemMap->extra_end);
+    write_word(ES, DI+14, 0x0);
 
     write_word(ES, DI+16, type);
     write_word(ES, DI+18, 0x0);
@@ -4105,8 +4113,11 @@
   pushad_regs_t regs; // REGS pushed via pushad
   Bit16u ES, DS, FLAGS;
 {
+  struct MemoryMap MemMap;
   Bit32u  extended_memory_size=0; // 64bits long
+  Bit32u  extra_lowbits_memory_size=0;
   Bit16u  CX,DX;
+  Bit8u  extra_highbits_memory_size=0;
 
 BX_DEBUG_INT15("int15 AX=%04x\n",regs.u.r16.ax);
 
@@ -4179,11 +4190,21 @@
                     extended_memory_size *= 1024;
                 }
 
+                extra_lowbits_memory_size = inb_cmos(0x5c);
+                extra_lowbits_memory_size <<= 8;
+                extra_lowbits_memory_size |= inb_cmos(0x5b);
+                extra_lowbits_memory_size *= 64;
+                extra_lowbits_memory_size *= 1024;
+                extra_highbits_memory_size = inb_cmos(0x5d);
+                
                 switch(regs.u.r16.bx)
                 {
                     case 0:
-                        set_e820_range(ES, regs.u.r16.di,
-                                       0x0000000L, 0x0009fc00L, 1);
+                        MemMap.start = 0x0000000L;
+                        MemMap.extra_start = 0;
+                        MemMap.end = 0x0009fc00L;
+                        MemMap.extra_end = 0;
+                        set_e820_range(ES, regs.u.r16.di, &MemMap, 1);
                         regs.u.r32.ebx = 1;
                         regs.u.r32.eax = 0x534D4150;
                         regs.u.r32.ecx = 0x14;
@@ -4191,8 +4212,11 @@
                         return;
                         break;
                     case 1:
-                        set_e820_range(ES, regs.u.r16.di,
-                                       0x0009fc00L, 0x000a0000L, 2);
+                        MemMap.start = 0x0009fc00L;
+                        MemMap.extra_start = 0;
+                        MemMap.end = 0x000a0000L;
+                        MemMap.extra_end = 0;
+                        set_e820_range(ES, regs.u.r16.di, &MemMap, 2);
                         regs.u.r32.ebx = 2;
                         regs.u.r32.eax = 0x534D4150;
                         regs.u.r32.ecx = 0x14;
@@ -4200,18 +4224,23 @@
                         return;
                         break;
                     case 2:
-                        set_e820_range(ES, regs.u.r16.di,
-                                       0x000e8000L, 0x00100000L, 2);
-                        regs.u.r32.ebx = 3;
+                        MemMap.start = 0x000e8000L;
+                        MemMap.extra_start = 0;
+                        MemMap.end = 0x00100000L;
+                        MemMap.extra_end = 0;
+                        set_e820_range(ES, regs.u.r16.di, &MemMap, 2);
                         regs.u.r32.eax = 0x534D4150;
                         regs.u.r32.ecx = 0x14;
                         CLEAR_CF();
                         return;
                         break;
                     case 3:
+                        MemMap.start = 0x00100000L;
+                        MemMap.extra_start = 0;
+                        MemMap.end = extended_memory_size - ACPI_DATA_SIZE;
+                        MemMap.extra_end = 0;
                         set_e820_range(ES, regs.u.r16.di,
-                                       0x00100000L,
-                                       extended_memory_size - ACPI_DATA_SIZE, 1);
+                                       &MemMap, 1);
                         regs.u.r32.ebx = 4;
                         regs.u.r32.eax = 0x534D4150;
                         regs.u.r32.ecx = 0x14;
@@ -4219,9 +4248,12 @@
                         return;
                         break;
                     case 4:
+                        MemMap.start = extended_memory_size - ACPI_DATA_SIZE;
+                        MemMap.extra_start = 0;
+                        MemMap.end = extended_memory_size;
+                        MemMap.extra_end = 0;
                         set_e820_range(ES, regs.u.r16.di,
-                                       extended_memory_size - ACPI_DATA_SIZE,
-                                       extended_memory_size, 3); // ACPI RAM
+                                       &MemMap, 3); // ACPI RAM
                         regs.u.r32.ebx = 5;
                         regs.u.r32.eax = 0x534D4150;
                         regs.u.r32.ecx = 0x14;
@@ -4230,8 +4262,26 @@
                         break;
                     case 5:
                         /* 256KB BIOS area at the end of 4 GB */
-                        set_e820_range(ES, regs.u.r16.di,
-                                       0xfffc0000L, 0x00000000L, 2);
+                        MemMap.start = 0xfffc0000L;
+                        MemMap.extra_start = 0;
+                        MemMap.end = 0x00000000L;
+                        MemMap.extra_end = 0;
+                        set_e820_range(ES, regs.u.r16.di, &MemMap, 2);
+                        if (extra_highbits_memory_size || extra_lowbits_memory_size)
+                                regs.u.r32.ebx = 6;
+                        else 
+                                regs.u.r32.ebx = 0;
+                        regs.u.r32.eax = 0x534D4150;
+                        regs.u.r32.ecx = 0x14;
+                        CLEAR_CF();
+                        return;
+                    case 6:
+                        /* Maping of memory above 4 GB */
+                        MemMap.start = 0x0;
+                        MemMap.extra_start = 0x1;
+                        MemMap.end = extra_lowbits_memory_size + MemMap.start;
+                        MemMap.extra_end = extra_highbits_memory_size + MemMap.extra_start;
+                        set_e820_range(ES, regs.u.r16.di, &MemMap, 1);
                         regs.u.r32.ebx = 0;
                         regs.u.r32.eax = 0x534D4150;
                         regs.u.r32.ecx = 0x14;

[-- Attachment #3: kvm_new_slot_patch --]
[-- Type: text/x-patch, Size: 352 bytes --]

diff --git a/drivers/kvm/kvm.h b/drivers/kvm/kvm.h
index fc27c2f..ac3fa1c 100644
--- a/drivers/kvm/kvm.h
+++ b/drivers/kvm/kvm.h
@@ -39,7 +39,7 @@
 
 #define KVM_MAX_VCPUS 4
 #define KVM_ALIAS_SLOTS 4
-#define KVM_MEMORY_SLOTS 4
+#define KVM_MEMORY_SLOTS 5
 #define KVM_NUM_MMU_PAGES 1024
 #define KVM_MIN_FREE_MMU_PAGES 5
 #define KVM_REFILL_PAGES 25

[-- Attachment #4: qemu_new_memory_map --]
[-- Type: text/x-patch, Size: 5502 bytes --]

diff --git a/qemu/exec.c b/qemu/exec.c
index f5cce06..750cc08 100644
--- a/qemu/exec.c
+++ b/qemu/exec.c
@@ -67,9 +67,11 @@
 #define TARGET_PHYS_ADDR_SPACE_BITS 41
 #elif defined(TARGET_PPC64)
 #define TARGET_PHYS_ADDR_SPACE_BITS 42
-#else
+#elif USE_KQEMU
 /* Note: for compatibility with kqemu, we use 32 bits for x86_64 */
 #define TARGET_PHYS_ADDR_SPACE_BITS 32
+#else
+#define TARGET_PHYS_ADDR_SPACE_BITS 42
 #endif
 
 #ifdef USE_KVM
diff --git a/qemu/hw/pc.c b/qemu/hw/pc.c
index 7bec234..7b767c0 100644
--- a/qemu/hw/pc.c
+++ b/qemu/hw/pc.c
@@ -163,12 +163,13 @@ static void cmos_init_hd(int type_ofs, int info_ofs, BlockDriverState *hd)
 }
 
 /* hd_table must contain 4 block drivers */
-static void cmos_init(unsigned long ram_size, int boot_device, BlockDriverState **hd_table)
+static void cmos_init(unsigned long ram_size, unsigned long above_bios_ram_size, int boot_device, BlockDriverState **hd_table)
 {
     RTCState *s = rtc_state;
     int val;
     int fd0, fd1, nb;
     int i;
+    unsigned long above_bios_mem_bits;
 
     /* various important CMOS locations needed by PC/Bochs bios */
 
@@ -185,6 +186,11 @@ static void cmos_init(unsigned long ram_size, int boot_device, BlockDriverState
     rtc_set_memory(s, 0x30, val);
     rtc_set_memory(s, 0x31, val >> 8);
 
+    val = (unsigned int)above_bios_ram_size / 65536;
+    rtc_set_memory(s, 0x5b, val);
+    rtc_set_memory(s, 0x5c, val >> 8);
+    rtc_set_memory(s, 0x5d, above_bios_ram_size/0x100000000);
+    
     if (ram_size > (16 * 1024 * 1024))
         val = (ram_size / 65536) - ((16 * 1024 * 1024) / 65536);
     else
@@ -465,7 +471,7 @@ static void pc_init1(unsigned long ram_size, int vga_ram_size, int boot_device,
 {
     char buf[1024];
     int ret, linux_boot, initrd_size, i;
-    unsigned long bios_offset, vga_bios_offset, option_rom_offset;
+    unsigned long bios_offset, vga_bios_offset, option_rom_offset, above_bios_mem_size = 0;
     ram_addr_t initrd_offset;
     int bios_size, isa_bios_size;
     PCIBus *pci_bus;
@@ -473,6 +479,10 @@ static void pc_init1(unsigned long ram_size, int vga_ram_size, int boot_device,
     CPUState *env;
     NICInfo *nd;
 
+    if (ram_size + (phys_ram_size - ram_size) >= 0xf0000000 ) {
+        above_bios_mem_size = ram_size - 0xf0000000 + (phys_ram_size - ram_size);
+        ram_size = 0xf0000000 - (phys_ram_size - ram_size);
+    }
     linux_boot = (kernel_filename != NULL);
 
     /* init CPUs */
@@ -492,7 +502,9 @@ static void pc_init1(unsigned long ram_size, int vga_ram_size, int boot_device,
     }
 
     /* allocate RAM */
-    cpu_register_physical_memory(0, ram_size, 0);
+    cpu_register_physical_memory(0, ram_size , 0);
+    if (above_bios_mem_size > 0)
+        cpu_register_physical_memory(0x100000000, above_bios_mem_size, 0x0);
 
     /* BIOS load */
     bios_offset = ram_size + vga_ram_size;
@@ -668,11 +680,10 @@ static void pc_init1(unsigned long ram_size, int vga_ram_size, int boot_device,
     register_ioport_write(0x80, 1, 1, ioport80_write, NULL);
 
     register_ioport_write(0xf0, 1, 1, ioportF0_write, NULL);
-
     if (cirrus_vga_enabled) {
         if (pci_enabled) {
             pci_cirrus_vga_init(pci_bus, 
-                                ds, phys_ram_base + ram_size, ram_size, 
+                                ds, phys_ram_base + ram_size, ram_size,
                                 vga_ram_size);
         } else {
             isa_cirrus_vga_init(ds, phys_ram_base + ram_size, ram_size, 
@@ -756,7 +767,7 @@ static void pc_init1(unsigned long ram_size, int vga_ram_size, int boot_device,
 
     floppy_controller = fdctrl_init(6, 2, 0, 0x3f0, fd_table);
 
-    cmos_init(ram_size, boot_device, bs_table);
+    cmos_init(ram_size , above_bios_mem_size, boot_device, bs_table);
 
     if (pci_enabled && usb_enabled) {
         usb_uhci_init(pci_bus, piix3_devfn + 2);
diff --git a/user/kvmctl.c b/user/kvmctl.c
index 43b374d..b07f8a8 100644
--- a/user/kvmctl.c
+++ b/user/kvmctl.c
@@ -43,7 +43,7 @@ static int kvm_abi = EXPECTED_KVM_API_VERSION;
 
 /* FIXME: share this number with kvm */
 /* FIXME: or dynamically alloc/realloc regions */
-#define KVM_MAX_NUM_MEM_REGIONS 4u
+#define KVM_MAX_NUM_MEM_REGIONS 5u
 #define MAX_VCPUS 4
 
 /**
@@ -236,6 +236,7 @@ int kvm_create(kvm_context_t kvm, unsigned long memory, void **vm_mem)
 {
 	unsigned long dosmem = 0xa0000;
 	unsigned long exmem = 0xc0000;
+	unsigned long pcimem = 0xf0000000;
 	int fd = kvm->fd;
 	int zfd;
 	int r;
@@ -249,6 +250,14 @@ int kvm_create(kvm_context_t kvm, unsigned long memory, void **vm_mem)
 		.memory_size = memory < exmem ? 0 : memory - exmem,
 		.guest_phys_addr = exmem,
 	};
+	struct kvm_memory_region above_bios_memory = {
+		.slot = 4,
+		.memory_size = memory < pcimem ? 0 : memory - pcimem,
+		.guest_phys_addr = 0x100000000,
+	};
+
+	if (extended_memory.memory_size > pcimem)
+		extended_memory.memory_size = pcimem - exmem;
 
 	kvm->vcpu_fd[0] = -1;
 
@@ -273,8 +282,17 @@ int kvm_create(kvm_context_t kvm, unsigned long memory, void **vm_mem)
 		}
 	}
 
+	if (above_bios_memory.memory_size) {
+		r = ioctl(fd, KVM_SET_MEMORY_REGION, &above_bios_memory);
+		if (r == -1) {
+			fprintf(stderr, "kvm_create_memory_region: %m\n");
+			return -1;
+		}
+	}
+
 	kvm_memory_region_save_params(kvm, &low_memory);
 	kvm_memory_region_save_params(kvm, &extended_memory);
+	kvm_memory_region_save_params(kvm, &above_bios_memory);
 
 	*vm_mem = mmap(NULL, memory, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
 	if (*vm_mem == MAP_FAILED) {

[-- Attachment #5: qemu_typedefs_fix --]
[-- Type: text/x-patch, Size: 5159 bytes --]

diff --git a/qemu/cpu-all.h b/qemu/cpu-all.h
index a325e05..90e4351 100644
--- a/qemu/cpu-all.h
+++ b/qemu/cpu-all.h
@@ -822,7 +822,7 @@ int cpu_inl(CPUState *env, int addr);
 
 /* memory API */
 
-extern int phys_ram_size;
+extern unsigned long phys_ram_size;
 extern int phys_ram_fd;
 extern uint8_t *phys_ram_base;
 extern uint8_t *phys_ram_dirty;
diff --git a/qemu/exec.c b/qemu/exec.c
index 2b050d1..f5cce06 100644
--- a/qemu/exec.c
+++ b/qemu/exec.c
@@ -85,7 +85,7 @@ spinlock_t tb_lock = SPIN_LOCK_UNLOCKED;
 uint8_t code_gen_buffer[CODE_GEN_BUFFER_SIZE] __attribute__((aligned (32)));
 uint8_t *code_gen_ptr;
 
-int phys_ram_size;
+unsigned long phys_ram_size;
 int phys_ram_fd;
 uint8_t *phys_ram_base;
 uint8_t *phys_ram_dirty;
@@ -111,7 +111,7 @@ typedef struct PageDesc {
 
 typedef struct PhysPageDesc {
     /* offset in host memory of the page + io_index in the low 12 bits */
-    uint32_t phys_offset;
+    unsigned long phys_offset;
 } PhysPageDesc;
 
 #define L2_BITS 10
diff --git a/qemu/hw/pc.c b/qemu/hw/pc.c
index ae92173..7bec234 100644
--- a/qemu/hw/pc.c
+++ b/qemu/hw/pc.c
@@ -163,7 +163,7 @@ static void cmos_init_hd(int type_ofs, int info_ofs, BlockDriverState *hd)
 }
 
 /* hd_table must contain 4 block drivers */
-static void cmos_init(int ram_size, int boot_device, BlockDriverState **hd_table)
+static void cmos_init(unsigned long ram_size, int boot_device, BlockDriverState **hd_table)
 {
     RTCState *s = rtc_state;
     int val;
@@ -457,7 +457,7 @@ extern int kvm_allowed;
 #endif
 
 /* PC hardware initialisation */
-static void pc_init1(int ram_size, int vga_ram_size, int boot_device,
+static void pc_init1(unsigned long ram_size, int vga_ram_size, int boot_device,
                      DisplayState *ds, const char **fd_filename, int snapshot,
                      const char *kernel_filename, const char *kernel_cmdline,
                      const char *initrd_filename,
@@ -794,7 +794,7 @@ static void pc_init1(int ram_size, int vga_ram_size, int boot_device,
 #endif
 }
 
-static void pc_init_pci(int ram_size, int vga_ram_size, int boot_device,
+static void pc_init_pci(unsigned long ram_size, int vga_ram_size, int boot_device,
                         DisplayState *ds, const char **fd_filename, 
                         int snapshot, 
                         const char *kernel_filename, 
@@ -807,7 +807,7 @@ static void pc_init_pci(int ram_size, int vga_ram_size, int boot_device,
              initrd_filename, 1);
 }
 
-static void pc_init_isa(int ram_size, int vga_ram_size, int boot_device,
+static void pc_init_isa(unsigned long ram_size, int vga_ram_size, int boot_device,
                         DisplayState *ds, const char **fd_filename, 
                         int snapshot, 
                         const char *kernel_filename, 
diff --git a/qemu/hw/vga.c b/qemu/hw/vga.c
index fcb19b0..c1edd88 100644
--- a/qemu/hw/vga.c
+++ b/qemu/hw/vga.c
@@ -1399,10 +1399,11 @@ extern int kvm_allowed;
 static void vga_draw_graphic(VGAState *s, int full_update)
 {
     int y1, y, update, page_min, page_max, linesize, y_start, double_scan, mask;
-    int width, height, shift_control, line_offset, page0, page1, bwidth;
+    int width, height, shift_control, line_offset, bwidth;
     int disp_width, multi_scan, multi_run;
     uint8_t *d;
     uint32_t v, addr1, addr;
+    unsigned long page0, page1;
     vga_draw_line_func *vga_draw_line;
     
 #ifdef USE_KVM
diff --git a/qemu/vl.c b/qemu/vl.c
index b14233c..5dd6eec 100644
--- a/qemu/vl.c
+++ b/qemu/vl.c
@@ -101,8 +101,11 @@
 
 //#define DEBUG_UNUSED_IOPORT
 //#define DEBUG_IOPORT
-
+#if HOST_LONG_BITS < 64
 #define PHYS_RAM_MAX_SIZE (2047 * 1024 * 1024)
+#else
+#define PHYS_RAM_MAX_SIZE (2047 * 1024 * 1024 * 1024ULL)
+#endif
 
 #ifdef TARGET_PPC
 #define DEFAULT_RAM_SIZE 144
@@ -135,7 +138,7 @@ int nographic;
 const char* keyboard_layout = NULL;
 int64_t ticks_per_sec;
 int boot_device = 'c';
-int ram_size;
+unsigned long ram_size;
 int pit_min_timer_count = 0;
 int nb_nics;
 NICInfo nd_table[MAX_NICS];
@@ -7182,7 +7185,7 @@ int main(int argc, char **argv)
                 help();
                 break;
             case QEMU_OPTION_m:
-                ram_size = atoi(optarg) * 1024 * 1024;
+                ram_size = (unsigned long)atoi(optarg) * 1024 * 1024;
                 if (ram_size <= 0)
                     help();
                 if (ram_size > PHYS_RAM_MAX_SIZE) {
diff --git a/qemu/vl.h b/qemu/vl.h
index 43f56bd..d35b47f 100644
--- a/qemu/vl.h
+++ b/qemu/vl.h
@@ -153,7 +153,7 @@ void qemu_system_powerdown(void);
 
 void main_loop_wait(int timeout);
 
-extern int ram_size;
+extern unsigned long ram_size;
 extern int bios_size;
 extern int rtc_utc;
 extern int cirrus_vga_enabled;
@@ -716,7 +716,7 @@ void path_combine(char *dest, int dest_size,
 
 #ifndef QEMU_TOOL
 
-typedef void QEMUMachineInitFunc(int ram_size, int vga_ram_size, 
+typedef void QEMUMachineInitFunc(unsigned long ram_size, int vga_ram_size, 
                                  int boot_device,
              DisplayState *ds, const char **fd_filename, int snapshot,
              const char *kernel_filename, const char *kernel_cmdline,

[-- Attachment #6: rmode_tss_base_typedef_bugfix --]
[-- Type: text/x-patch, Size: 444 bytes --]

diff --git a/drivers/kvm/vmx.c b/drivers/kvm/vmx.c
index dac2f93..1613f23 100644
--- a/drivers/kvm/vmx.c
+++ b/drivers/kvm/vmx.c
@@ -905,7 +905,7 @@ static void enter_pmode(struct kvm_vcpu *vcpu)
 	vmcs_write32(GUEST_CS_AR_BYTES, 0x9b);
 }
 
-static int rmode_tss_base(struct kvm* kvm)
+static gva_t rmode_tss_base(struct kvm* kvm)
 {
 	gfn_t base_gfn = kvm->memslots[0].base_gfn + kvm->memslots[0].npages - 3;
 	return base_gfn << PAGE_SHIFT;

[-- Attachment #7: Type: text/plain, Size: 315 bytes --]

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/

[-- Attachment #8: Type: text/plain, Size: 186 bytes --]

_______________________________________________
kvm-devel mailing list
kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/kvm-devel

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: kvm with above 2 giga (new clean patchs)
       [not found]     ` <1187104635.11302.5.camel-wV29XY6ncz+I84jL4+POOYeT0m0igiSA0E9HWUfgJXw@public.gmane.org>
@ 2007-08-14 19:11       ` Ryan Harper
  0 siblings, 0 replies; 3+ messages in thread
From: Ryan Harper @ 2007-08-14 19:11 UTC (permalink / raw)
  To: Izik Eidus; +Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

* Izik Eidus <izike-atKUWr5tajBWk0Htik3J/w@public.gmane.org> [2007-08-14 10:22]:
> Index: rombios.c
> ===================================================================
> RCS file: /cvsroot/bochs/bochs/bios/rombios.c,v
> retrieving revision 1.182
> diff -u -r1.182 rombios.c
> --- rombios.c	1 Aug 2007 17:09:51 -0000	1.182
> +++ rombios.c	14 Aug 2007 10:33:39 -0000
> @@ -4077,24 +4077,32 @@
>  }
>  #endif
> 
> +struct MemoryMap {

Style.  Nothing else in rombios.c uses MixedCase.

struct memory_map

> +    Bit32u start;
> +    Bit16u extra_start;
> +    Bit32u end;
> +    Bit8u extra_end;
> +};
> +
> +typedef struct MemoryMap *MemoryMap_t;

typedef struct memory_map memory_map_t;

> diff --git a/qemu/hw/pc.c b/qemu/hw/pc.c
> index 7bec234..7b767c0 100644
> --- a/qemu/hw/pc.c
> +++ b/qemu/hw/pc.c
> @@ -163,12 +163,13 @@ static void cmos_init_hd(int type_ofs, int info_ofs, BlockDriverState *hd)
>  }
> 
>  /* hd_table must contain 4 block drivers */
> -static void cmos_init(unsigned long ram_size, int boot_device, BlockDriverState **hd_table)
> +static void cmos_init(unsigned long ram_size, unsigned long above_bios_ram_size, int boot_device, BlockDriverState **hd_table)
>  {
>      RTCState *s = rtc_state;
>      int val;
>      int fd0, fd1, nb;
>      int i;
> +    unsigned long above_bios_mem_bits;
> 
>      /* various important CMOS locations needed by PC/Bochs bios */
> 
> @@ -185,6 +186,11 @@ static void cmos_init(unsigned long ram_size, int boot_device, BlockDriverState
>      rtc_set_memory(s, 0x30, val);
>      rtc_set_memory(s, 0x31, val >> 8);
> 
> +    val = (unsigned int)above_bios_ram_size / 65536;
> +    rtc_set_memory(s, 0x5b, val);
> +    rtc_set_memory(s, 0x5c, val >> 8);
> +    rtc_set_memory(s, 0x5d, above_bios_ram_size/0x100000000);

above_bios_ram_size >> 32 ?

> +    
>      if (ram_size > (16 * 1024 * 1024))
>          val = (ram_size / 65536) - ((16 * 1024 * 1024) / 65536);
>      else
> @@ -465,7 +471,7 @@ static void pc_init1(unsigned long ram_size, int vga_ram_size, int boot_device,
>  {
>      char buf[1024];
>      int ret, linux_boot, initrd_size, i;
> -    unsigned long bios_offset, vga_bios_offset, option_rom_offset;
> +    unsigned long bios_offset, vga_bios_offset, option_rom_offset, above_bios_mem_size = 0;
>      ram_addr_t initrd_offset;
>      int bios_size, isa_bios_size;
>      PCIBus *pci_bus;
> @@ -473,6 +479,10 @@ static void pc_init1(unsigned long ram_size, int vga_ram_size, int boot_device,
>      CPUState *env;
>      NICInfo *nd;
> 
> +    if (ram_size + (phys_ram_size - ram_size) >= 0xf0000000 ) {
> +        above_bios_mem_size = ram_size - 0xf0000000 + (phys_ram_size - ram_size);
> +        ram_size = 0xf0000000 - (phys_ram_size - ram_size);
> +    }

0xf0000000 is magic number, but related to the Cirrus VGA VRAM base
addr, maybe:

#define VGA_VRAM_BASE 0xf0000000 


>      linux_boot = (kernel_filename != NULL);
> 
>      /* init CPUs */
> @@ -492,7 +502,9 @@ static void pc_init1(unsigned long ram_size, int vga_ram_size, int boot_device,
>      }
> 
>      /* allocate RAM */
> -    cpu_register_physical_memory(0, ram_size, 0);
> +    cpu_register_physical_memory(0, ram_size , 0);

whitespace damage, note the comma after ram_size.

> +    if (above_bios_mem_size > 0)
> +        cpu_register_physical_memory(0x100000000, above_bios_mem_size, 0x0);
> 
>      /* BIOS load */
>      bios_offset = ram_size + vga_ram_size;
> @@ -668,11 +680,10 @@ static void pc_init1(unsigned long ram_size, int vga_ram_size, int boot_device,
>      register_ioport_write(0x80, 1, 1, ioport80_write, NULL);
> 
>      register_ioport_write(0xf0, 1, 1, ioportF0_write, NULL);
> -

whitespace.

>      if (cirrus_vga_enabled) {
>          if (pci_enabled) {
>              pci_cirrus_vga_init(pci_bus, 
> -                                ds, phys_ram_base + ram_size, ram_size, 
> +                                ds, phys_ram_base + ram_size, ram_size,

whitespace

>                                  vga_ram_size);
>          } else {
>              isa_cirrus_vga_init(ds, phys_ram_base + ram_size, ram_size, 
> @@ -756,7 +767,7 @@ static void pc_init1(unsigned long ram_size, int vga_ram_size, int boot_device,
> 
>      floppy_controller = fdctrl_init(6, 2, 0, 0x3f0, fd_table);
> 
> -    cmos_init(ram_size, boot_device, bs_table);
> +    cmos_init(ram_size , above_bios_mem_size, boot_device, bs_table);

note the comma after ram_size.

> 
>      if (pci_enabled && usb_enabled) {
>          usb_uhci_init(pci_bus, piix3_devfn + 2);
> diff --git a/user/kvmctl.c b/user/kvmctl.c
> index 43b374d..b07f8a8 100644
> --- a/user/kvmctl.c
> +++ b/user/kvmctl.c
> @@ -43,7 +43,7 @@ static int kvm_abi = EXPECTED_KVM_API_VERSION;
> 
>  /* FIXME: share this number with kvm */
>  /* FIXME: or dynamically alloc/realloc regions */
> -#define KVM_MAX_NUM_MEM_REGIONS 4u
> +#define KVM_MAX_NUM_MEM_REGIONS 5u
>  #define MAX_VCPUS 4
> 
>  /**
> @@ -236,6 +236,7 @@ int kvm_create(kvm_context_t kvm, unsigned long memory, void **vm_mem)
>  {
>  	unsigned long dosmem = 0xa0000;
>  	unsigned long exmem = 0xc0000;
> +	unsigned long pcimem = 0xf0000000;
>  	int fd = kvm->fd;
>  	int zfd;
>  	int r;
> @@ -249,6 +250,14 @@ int kvm_create(kvm_context_t kvm, unsigned long memory, void **vm_mem)
>  		.memory_size = memory < exmem ? 0 : memory - exmem,
>  		.guest_phys_addr = exmem,
>  	};
> +	struct kvm_memory_region above_bios_memory = {
> +		.slot = 4,
> +		.memory_size = memory < pcimem ? 0 : memory - pcimem,
> +		.guest_phys_addr = 0x100000000,
> +	};
> +
> +	if (extended_memory.memory_size > pcimem)
> +		extended_memory.memory_size = pcimem - exmem;
> 
>  	kvm->vcpu_fd[0] = -1;
> 
> @@ -273,8 +282,17 @@ int kvm_create(kvm_context_t kvm, unsigned long memory, void **vm_mem)
>  		}
>  	}
> 
> +	if (above_bios_memory.memory_size) {
> +		r = ioctl(fd, KVM_SET_MEMORY_REGION, &above_bios_memory);
> +		if (r == -1) {
> +			fprintf(stderr, "kvm_create_memory_region: %m\n");
> +			return -1;
> +		}
> +	}
> +
>  	kvm_memory_region_save_params(kvm, &low_memory);
>  	kvm_memory_region_save_params(kvm, &extended_memory);
> +	kvm_memory_region_save_params(kvm, &above_bios_memory);
> 
>  	*vm_mem = mmap(NULL, memory, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
>  	if (*vm_mem == MAP_FAILED) {

> diff --git a/qemu/cpu-all.h b/qemu/cpu-all.h
> index a325e05..90e4351 100644
> --- a/qemu/cpu-all.h
> +++ b/qemu/cpu-all.h
> @@ -822,7 +822,7 @@ int cpu_inl(CPUState *env, int addr);
> 
>  /* memory API */
> 
> -extern int phys_ram_size;
> +extern unsigned long phys_ram_size;
>  extern int phys_ram_fd;
>  extern uint8_t *phys_ram_base;
>  extern uint8_t *phys_ram_dirty;
> diff --git a/qemu/exec.c b/qemu/exec.c
> index 2b050d1..f5cce06 100644
> --- a/qemu/exec.c
> +++ b/qemu/exec.c
> @@ -85,7 +85,7 @@ spinlock_t tb_lock = SPIN_LOCK_UNLOCKED;
>  uint8_t code_gen_buffer[CODE_GEN_BUFFER_SIZE] __attribute__((aligned (32)));
>  uint8_t *code_gen_ptr;
> 
> -int phys_ram_size;
> +unsigned long phys_ram_size;
>  int phys_ram_fd;
>  uint8_t *phys_ram_base;
>  uint8_t *phys_ram_dirty;
> @@ -111,7 +111,7 @@ typedef struct PageDesc {
> 
>  typedef struct PhysPageDesc {
>      /* offset in host memory of the page + io_index in the low 12 bits */
> -    uint32_t phys_offset;
> +    unsigned long phys_offset;
>  } PhysPageDesc;
> 
>  #define L2_BITS 10
> diff --git a/qemu/hw/pc.c b/qemu/hw/pc.c
> index ae92173..7bec234 100644
> --- a/qemu/hw/pc.c
> +++ b/qemu/hw/pc.c
> @@ -163,7 +163,7 @@ static void cmos_init_hd(int type_ofs, int info_ofs, BlockDriverState *hd)
>  }
> 
>  /* hd_table must contain 4 block drivers */
> -static void cmos_init(int ram_size, int boot_device, BlockDriverState **hd_table)
> +static void cmos_init(unsigned long ram_size, int boot_device, BlockDriverState **hd_table)
>  {
>      RTCState *s = rtc_state;
>      int val;
> @@ -457,7 +457,7 @@ extern int kvm_allowed;
>  #endif
> 
>  /* PC hardware initialisation */
> -static void pc_init1(int ram_size, int vga_ram_size, int boot_device,
> +static void pc_init1(unsigned long ram_size, int vga_ram_size, int boot_device,
>                       DisplayState *ds, const char **fd_filename, int snapshot,
>                       const char *kernel_filename, const char *kernel_cmdline,
>                       const char *initrd_filename,
> @@ -794,7 +794,7 @@ static void pc_init1(int ram_size, int vga_ram_size, int boot_device,
>  #endif
>  }
> 
> -static void pc_init_pci(int ram_size, int vga_ram_size, int boot_device,
> +static void pc_init_pci(unsigned long ram_size, int vga_ram_size, int boot_device,
>                          DisplayState *ds, const char **fd_filename, 
>                          int snapshot, 
>                          const char *kernel_filename, 
> @@ -807,7 +807,7 @@ static void pc_init_pci(int ram_size, int vga_ram_size, int boot_device,
>               initrd_filename, 1);
>  }
> 
> -static void pc_init_isa(int ram_size, int vga_ram_size, int boot_device,
> +static void pc_init_isa(unsigned long ram_size, int vga_ram_size, int boot_device,
>                          DisplayState *ds, const char **fd_filename, 
>                          int snapshot, 
>                          const char *kernel_filename, 
> diff --git a/qemu/hw/vga.c b/qemu/hw/vga.c
> index fcb19b0..c1edd88 100644
> --- a/qemu/hw/vga.c
> +++ b/qemu/hw/vga.c
> @@ -1399,10 +1399,11 @@ extern int kvm_allowed;
>  static void vga_draw_graphic(VGAState *s, int full_update)
>  {
>      int y1, y, update, page_min, page_max, linesize, y_start, double_scan, mask;
> -    int width, height, shift_control, line_offset, page0, page1, bwidth;
> +    int width, height, shift_control, line_offset, bwidth;
>      int disp_width, multi_scan, multi_run;
>      uint8_t *d;
>      uint32_t v, addr1, addr;
> +    unsigned long page0, page1;
>      vga_draw_line_func *vga_draw_line;
>      
>  #ifdef USE_KVM
> diff --git a/qemu/vl.c b/qemu/vl.c
> index b14233c..5dd6eec 100644
> --- a/qemu/vl.c
> +++ b/qemu/vl.c
> @@ -101,8 +101,11 @@
> 
>  //#define DEBUG_UNUSED_IOPORT
>  //#define DEBUG_IOPORT
> -

whitespace damage.

> +#if HOST_LONG_BITS < 64
>  #define PHYS_RAM_MAX_SIZE (2047 * 1024 * 1024)
> +#else
> +#define PHYS_RAM_MAX_SIZE (2047 * 1024 * 1024 * 1024ULL)
> +#endif
> 
>  #ifdef TARGET_PPC
>  #define DEFAULT_RAM_SIZE 144
> @@ -135,7 +138,7 @@ int nographic;
>  const char* keyboard_layout = NULL;
>  int64_t ticks_per_sec;
>  int boot_device = 'c';
> -int ram_size;
> +unsigned long ram_size;
>  int pit_min_timer_count = 0;
>  int nb_nics;
>  NICInfo nd_table[MAX_NICS];
> @@ -7182,7 +7185,7 @@ int main(int argc, char **argv)
>                  help();
>                  break;
>              case QEMU_OPTION_m:
> -                ram_size = atoi(optarg) * 1024 * 1024;
> +                ram_size = (unsigned long)atoi(optarg) * 1024 * 1024;
>                  if (ram_size <= 0)
>                      help();
>                  if (ram_size > PHYS_RAM_MAX_SIZE) {
> diff --git a/qemu/vl.h b/qemu/vl.h
> index 43f56bd..d35b47f 100644
> --- a/qemu/vl.h
> +++ b/qemu/vl.h
> @@ -153,7 +153,7 @@ void qemu_system_powerdown(void);
> 
>  void main_loop_wait(int timeout);
> 
> -extern int ram_size;
> +extern unsigned long ram_size;
>  extern int bios_size;
>  extern int rtc_utc;
>  extern int cirrus_vga_enabled;
> @@ -716,7 +716,7 @@ void path_combine(char *dest, int dest_size,
> 
>  #ifndef QEMU_TOOL
> 
> -typedef void QEMUMachineInitFunc(int ram_size, int vga_ram_size, 
> +typedef void QEMUMachineInitFunc(unsigned long ram_size, int vga_ram_size, 
>                                   int boot_device,
>               DisplayState *ds, const char **fd_filename, int snapshot,
>               const char *kernel_filename, const char *kernel_cmdline,

> diff --git a/drivers/kvm/vmx.c b/drivers/kvm/vmx.c
> index dac2f93..1613f23 100644
> --- a/drivers/kvm/vmx.c
> +++ b/drivers/kvm/vmx.c
> @@ -905,7 +905,7 @@ static void enter_pmode(struct kvm_vcpu *vcpu)
>  	vmcs_write32(GUEST_CS_AR_BYTES, 0x9b);
>  }
> 
> -static int rmode_tss_base(struct kvm* kvm)
> +static gva_t rmode_tss_base(struct kvm* kvm)
>  {
>  	gfn_t base_gfn = kvm->memslots[0].base_gfn + kvm->memslots[0].npages - 3;
>  	return base_gfn << PAGE_SHIFT;

> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc.
> Still grepping through log files to find problems?  Stop.
> Now Search log events and configuration files using AJAX and a browser.
> Download your FREE copy of Splunk now >>  http://get.splunk.com/
> _______________________________________________
> kvm-devel mailing list
> kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
> https://lists.sourceforge.net/lists/listinfo/kvm-devel

-- 
Ryan Harper
Software Engineer; Linux Technology Center
IBM Corp., Austin, Tx
(512) 838-9253   T/L: 678-9253
ryanh-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-08-14 19:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-14 15:00 kvm with above 2 giga (new clean patchs) Izik Eidus
     [not found] ` <1187103640.5854.11.camel-wV29XY6ncz+I84jL4+POOYeT0m0igiSA0E9HWUfgJXw@public.gmane.org>
2007-08-14 15:17   ` Izik Eidus
     [not found]     ` <1187104635.11302.5.camel-wV29XY6ncz+I84jL4+POOYeT0m0igiSA0E9HWUfgJXw@public.gmane.org>
2007-08-14 19:11       ` Ryan Harper

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox