From patchwork Tue Apr 28 09:29:21 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhang, Xiantao" X-Patchwork-Id: 20378 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n3S9U5Ee023882 for ; Tue, 28 Apr 2009 09:30:05 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755478AbZD1J37 (ORCPT ); Tue, 28 Apr 2009 05:29:59 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1755575AbZD1J37 (ORCPT ); Tue, 28 Apr 2009 05:29:59 -0400 Received: from mga09.intel.com ([134.134.136.24]:33069 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754952AbZD1J35 (ORCPT ); Tue, 28 Apr 2009 05:29:57 -0400 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP; 28 Apr 2009 02:20:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.40,259,1239001200"; d="scan'208,223";a="407542601" Received: from pgsmsx602.gar.corp.intel.com ([10.221.43.81]) by orsmga002.jf.intel.com with ESMTP; 28 Apr 2009 02:37:49 -0700 Received: from pdsmsx602.ccr.corp.intel.com (172.16.12.184) by pgsmsx602.gar.corp.intel.com (10.221.43.81) with Microsoft SMTP Server (TLS) id 8.1.340.0; Tue, 28 Apr 2009 17:29:23 +0800 Received: from pdsmsx503.ccr.corp.intel.com ([172.16.12.95]) by pdsmsx602.ccr.corp.intel.com ([172.16.12.184]) with mapi; Tue, 28 Apr 2009 17:29:21 +0800 From: "Zhang, Xiantao" To: Avi Kivity , "kvm-ia64@vger.kernel.org" CC: "kvm@vger.kernel.org" Date: Tue, 28 Apr 2009 17:29:21 +0800 Subject: [PATCH 03/04] qemu-kvm: Remove the dependency for phys_ram_base for ipf.c Thread-Topic: [PATCH 03/04] qemu-kvm: Remove the dependency for phys_ram_base for ipf.c Thread-Index: AcnH48+N494g7dA8RGG+835bHNx9lQ== Message-ID: <706158FABBBA044BAD4FE898A02E4BC236A2BC04@pdsmsx503.ccr.corp.intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: yes X-MS-TNEF-Correlator: acceptlanguage: en-US MIME-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From aaf97331da3d6cd34522441218c8c9ab3c1067f6 Mon Sep 17 00:00:00 2001 From: Xiantao Zhang Date: Tue, 28 Apr 2009 16:55:47 +0800 Subject: [PATCH] qemu-kvm: Remove the dependency for phys_ram_base for ipf.c Upstream has dropped phys_ram_base, so ia64 also remove the dependency for that. Signed-off-by: Xiantao Zhang --- hw/ipf.c | 42 +++++++++++++++++++----------------------- target-ia64/firmware.c | 25 +++++++++++++++++-------- target-ia64/firmware.h | 6 +++--- 3 files changed, 39 insertions(+), 34 deletions(-) diff --git a/hw/ipf.c b/hw/ipf.c index 5ed2667..ccd7665 100644 --- a/hw/ipf.c +++ b/hw/ipf.c @@ -54,7 +54,8 @@ static fdctrl_t *floppy_controller; static RTCState *rtc_state; static PCIDevice *i440fx_state; -uint8_t *g_fw_start; +ram_addr_t gfw_start; + static uint32_t ipf_to_legacy_io(target_phys_addr_t addr) { return (uint32_t)(((addr&0x3ffffff) >> 12 << 2)|((addr) & 0x3)); @@ -454,15 +455,15 @@ static void ipf_init1(ram_addr_t ram_size, int vga_ram_size, if (kvm_enabled()) { unsigned long image_size; char *image = NULL; - uint8_t *fw_image_start; + ram_addr_t fw_image_start; unsigned long nvram_addr = 0; unsigned long nvram_fd = 0; unsigned long type = READ_FROM_NVRAM; unsigned long i = 0; - ram_addr_t fw_offset = qemu_ram_alloc(GFW_SIZE); - uint8_t *fw_start = phys_ram_base + fw_offset; - g_fw_start = fw_start; + ram_addr = qemu_ram_alloc(GFW_SIZE); + gfw_start = (ram_addr_t)qemu_get_ram_ptr(ram_addr); + snprintf(buf, sizeof(buf), "%s/%s", bios_dir, FW_FILENAME); image = read_image(buf, &image_size ); if (NULL == image || !image_size) { @@ -470,20 +471,20 @@ static void ipf_init1(ram_addr_t ram_size, int vga_ram_size, fprintf(stderr, "Please check Guest firmware at %s\n", buf); exit(1); } - fw_image_start = fw_start + GFW_SIZE - image_size; - - cpu_register_physical_memory(GFW_START, GFW_SIZE, fw_offset); - memcpy(fw_image_start, image, image_size); - - free(image); + /* Load Guest Firmware to the proper postion. */ + fw_image_start = gfw_start + GFW_SIZE - image_size; + memcpy((void *)fw_image_start, image, image_size); flush_icache_range((unsigned long)fw_image_start, (unsigned long)fw_image_start + image_size); + free(image); + + cpu_register_physical_memory(GFW_START, GFW_SIZE, ram_addr); - nvram_addr = NVRAM_START; if (nvram) { + nvram_addr = NVRAM_START; nvram_fd = kvm_ia64_nvram_init(type); if (nvram_fd != -1) { - kvm_ia64_copy_from_nvram_to_GFW(nvram_fd, g_fw_start); + kvm_ia64_copy_from_nvram_to_GFW(nvram_fd, gfw_start); close(nvram_fd); } i = atexit((void *)kvm_ia64_copy_from_GFW_to_nvram); @@ -491,7 +492,7 @@ static void ipf_init1(ram_addr_t ram_size, int vga_ram_size, fprintf(stderr, "cannot set exit function\n"); } kvm_ia64_build_hob(ram_size + above_4g_mem_size, smp_cpus, - fw_start, nvram_addr); + gfw_start, nvram_addr); } /*Register legacy io address space, size:64M*/ @@ -513,19 +514,15 @@ static void ipf_init1(ram_addr_t ram_size, int vga_ram_size, if (cirrus_vga_enabled) { if (pci_enabled) { - pci_cirrus_vga_init(pci_bus, phys_ram_base + vga_ram_addr, - vga_ram_addr, vga_ram_size); + pci_cirrus_vga_init(pci_bus, vga_ram_size); } else { - isa_cirrus_vga_init(phys_ram_base + vga_ram_addr, - vga_ram_addr, vga_ram_size); + isa_cirrus_vga_init(vga_ram_size); } } else { if (pci_enabled) { - pci_vga_init(pci_bus, phys_ram_base + vga_ram_addr, - vga_ram_addr, vga_ram_size, 0, 0); + pci_vga_init(pci_bus, vga_ram_size, 0, 0); } else { - isa_vga_init(phys_ram_base + vga_ram_addr, - vga_ram_addr, vga_ram_size); + isa_vga_init(vga_ram_size); } } @@ -671,7 +668,6 @@ QEMUMachine ipf_machine = { .name = "itanium", .desc = "Itanium Platform", .init = (QEMUMachineInitFunc *)ipf_init_pci, - .ram_require = (ram_addr_t)(VGA_RAM_SIZE + GFW_SIZE), .max_cpus = 255, }; diff --git a/target-ia64/firmware.c b/target-ia64/firmware.c index 87a8178..2ed2e0d 100644 --- a/target-ia64/firmware.c +++ b/target-ia64/firmware.c @@ -92,11 +92,11 @@ static int build_hob(void *hob_buf, unsigned long hob_buf_size, unsigned long dom_mem_size, unsigned long vcpus, unsigned long nvram_addr); static int load_hob(void *hob_buf, - unsigned long dom_mem_size, void* hob_start); + unsigned long dom_mem_size, ram_addr_t hob_start); int kvm_ia64_build_hob(unsigned long memsize, unsigned long vcpus, - uint8_t *fw_start, unsigned long nvram_addr) + ram_addr_t fw_start, unsigned long nvram_addr) { char *hob_buf; @@ -249,7 +249,7 @@ err_out: return -1; } static int -load_hob(void *hob_buf, unsigned long dom_mem_size, void* hob_start) +load_hob(void *hob_buf, unsigned long dom_mem_size, ram_addr_t hob_start) { int hob_size; @@ -263,7 +263,7 @@ load_hob(void *hob_buf, unsigned long dom_mem_size, void* hob_start) Hob_Output("No enough memory for hob data"); return -1; } - memcpy (hob_start, hob_buf, hob_size); + memcpy ((void *)hob_start, hob_buf, hob_size); return 0; } @@ -644,7 +644,7 @@ out: int kvm_ia64_copy_from_nvram_to_GFW(unsigned long nvram_fd, - const uint8_t *fw_start) + const ram_addr_t fw_start) { struct stat file_stat; if ((fstat(nvram_fd, &file_stat) < 0) || @@ -659,8 +659,13 @@ int kvm_ia64_copy_from_GFW_to_nvram() { unsigned long nvram_fd; + void* real_nvram_start; + target_phys_addr_t nvram_size = NVRAM_SIZE; unsigned long type = WRITE_TO_NVRAM; - unsigned long *nvram_addr = (unsigned long *)(g_fw_start + NVRAM_OFFSET); + unsigned long *nvram_addr = (unsigned long *)(gfw_start + NVRAM_OFFSET); + + + nvram_fd = kvm_ia64_nvram_init(type); if (nvram_fd == -1) goto out; @@ -669,11 +674,15 @@ kvm_ia64_copy_from_GFW_to_nvram() goto out; } lseek(nvram_fd, 0, SEEK_SET); - if (write(nvram_fd, ((void *)(((struct nvram_save_addr *)nvram_addr)->addr + - (char *)phys_ram_base)), NVRAM_SIZE) != NVRAM_SIZE) { + + real_nvram_start = cpu_physical_memory_map(((struct nvram_save_addr*)nvram_addr)->addr, + &nvram_size, 1); + if (write(nvram_fd, real_nvram_start, NVRAM_SIZE) != NVRAM_SIZE) { close(nvram_fd); goto out; } + cpu_physical_memory_unmap(real_nvram_start, NVRAM_SIZE, 1, NVRAM_SIZE); + close(nvram_fd); return 0; out: diff --git a/target-ia64/firmware.h b/target-ia64/firmware.h index c1707ac..548352c 100644 --- a/target-ia64/firmware.h +++ b/target-ia64/firmware.h @@ -52,13 +52,13 @@ struct nvram_save_addr { }; extern const char *nvram; -extern uint8_t *g_fw_start; +extern ram_addr_t gfw_start; extern int kvm_ia64_build_hob(unsigned long memsize, unsigned long vcpus, - uint8_t *fw_start, unsigned long nvram_addr); + ram_addr_t fw_start, unsigned long nvram_addr); extern char *read_image(const char *filename, unsigned long *size); extern int kvm_ia64_copy_from_GFW_to_nvram(void); extern int kvm_ia64_nvram_init(unsigned long type); extern int kvm_ia64_copy_from_nvram_to_GFW(unsigned long nvram_fd, - const uint8_t *fw_start); + const ram_addr_t fw_start); #endif //__FIRM_WARE_