Il Sun, Aug 12, 2007 at 12:26:15PM -0700, Izik Eidus ha scritto: > this is a request for comment for patchs that allow kvm to run with more than > 2 giga. > there are 4 patchs. > the first patch(biospatch): is for the bios:now the bios know how to map > memory about the 0xf0000000-0xffffffff hole. > > the second patch(qemu_change_types_patch):is for qemu ram_size types:it > change the variables that hold the ram_size to unsigned long, > and it is based on patch from the qemu-devel list that targeted sparc. > > the third patch(kvm_userspace_memmap):is for kvm and add to it another memory > slot that hold the new memory region.
Hi, can you use text/plain when attaching patches please (or better, put them inline)? I've a few minor comments: > diff --git a/qemu/exec.c b/qemu/exec.c > index f5cce06..e54711e 100644 > --- a/qemu/exec.c > +++ b/qemu/exec.c > @@ -69,7 +69,7 @@ > #define TARGET_PHYS_ADDR_SPACE_BITS 42 > #else > /* Note: for compatibility with kqemu, we use 32 bits for x86_64 */ > -#define TARGET_PHYS_ADDR_SPACE_BITS 32 > +#define TARGET_PHYS_ADDR_SPACE_BITS 42 > #endif Comment is no more correct. > #ifdef USE_KVM > diff --git a/qemu/hw/pc.c b/qemu/hw/pc.c > index 7bec234..f938fd0 100644 > --- a/qemu/hw/pc.c > +++ b/qemu/hw/pc.c > @@ -163,16 +163,18 @@ 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 */ > > /* memory size */ > + if (ram_size > 0xf0000000) > val = 640; /* base memory in K */ Missing indentation? > rtc_set_memory(s, 0x15, val); > rtc_set_memory(s, 0x16, val >> 8); > @@ -184,7 +186,12 @@ static void cmos_init(unsigned long ram_size, int > boot_device, BlockDriverState > rtc_set_memory(s, 0x18, val >> 8); > 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,14 +472,17 @@ 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; > int piix3_devfn = -1; > CPUState *env; > NICInfo *nd; > - > + if (ram_size + (phys_ram_size - ram_size) >= 0xf0000000 ) { > + above_bios_mem_size = ram_size - 0xf0000000;; Extra ; at the on the statement > + ram_size = 0xf0000000 - (phys_ram_size - ram_size); > + } You're mixing tab and spaces (style in QEMU seems to be 4 spaces for tab). I've seen the same thing in biospatch btw. > 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); Spurious change. > + if (above_bios_mem_size > 0) > + cpu_register_physical_memory(0x100000000, above_bios_mem_size , 0x0); ^^ Style. > /* 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); style (space before comma) > } else { > isa_cirrus_vga_init(ds, phys_ram_base + ram_size, ram_size, > @@ -687,7 +698,6 @@ static void pc_init1(unsigned long ram_size, int > vga_ram_size, int boot_device, > vga_ram_size); > } > } > - > rtc_state = rtc_init(0x70, 8); > > register_ioport_read(0x92, 1, 1, ioport92_read, NULL); > @@ -756,7 +766,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); ditto > > if (pci_enabled && usb_enabled) { > usb_uhci_init(pci_bus, piix3_devfn + 2); > @@ -0,0 +1,178 @@ > +diff --git a/qemu/exec.c b/qemu/exec.c > +index f5cce06..e54711e 100644 > +--- a/qemu/exec.c > ++++ b/qemu/exec.c > +@@ -69,7 +69,7 @@ > + #define TARGET_PHYS_ADDR_SPACE_BITS 42 > + #else > + /* Note: for compatibility with kqemu, we use 32 bits for x86_64 */ > +-#define TARGET_PHYS_ADDR_SPACE_BITS 32 > ++#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..f938fd0 100644 > +--- a/qemu/hw/pc.c > ++++ b/qemu/hw/pc.c [cut] Hum, something went wrong with the patch here... > diff --git a/qemu/vl.c b/qemu/vl.c > index 5dd6eec..b7d4c9f 100644 > --- a/qemu/vl.c > +++ b/qemu/vl.c > @@ -7546,6 +7546,7 @@ int main(int argc, char **argv) > exit(1); > } > } else { > + phys_ram_size += KVM_EXTRA_PAGES * 4096; Tabs instead of spaces > phys_ram_base = qemu_vmalloc(phys_ram_size); > if (!phys_ram_base) { > fprintf(stderr, "Could not allocate physical memory\n"); > 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) { Luca -- La differenza fra l'intelligenza e la stupidita`? All'intelligenza c'e` un limite. ------------------------------------------------------------------------- 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@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel