direct-io.hg

changeset 8397:b92a36713192

This patch fix several issue to support >2G 64bit vmx guest in IA-32e
platform, it includes:
1) One fix on xc_vmx_build.c
2) Change ram_size/phys_ram_size in qemu from int to uint64_t
3) One fix on pcnet unsigned short to unsigned long conversion.

Signed-off-by: Yunhong Jiang <yunhong.jiang@intel.com>
Signed-off-by: Xin Li <xin.b.li@intel.com>
author kaf24@firebug.cl.cam.ac.uk
date Tue Dec 20 12:50:09 2005 +0100 (2005-12-20)
parents 3d1c7be170a7
children 870c7e7da81e
files tools/ioemu/cpu-all.h tools/ioemu/exec.c tools/ioemu/hw/pc.c tools/ioemu/hw/pcnet.h tools/ioemu/vl.c tools/ioemu/vl.h tools/libxc/xc_vmx_build.c
line diff
     1.1 --- a/tools/ioemu/cpu-all.h	Tue Dec 20 12:46:56 2005 +0100
     1.2 +++ b/tools/ioemu/cpu-all.h	Tue Dec 20 12:50:09 2005 +0100
     1.3 @@ -668,7 +668,7 @@ static __inline__ void atomic_clear_bit(
     1.4  #endif
     1.5  /* memory API */
     1.6  
     1.7 -extern int phys_ram_size;
     1.8 +extern uint64_t phys_ram_size;
     1.9  extern int phys_ram_fd;
    1.10  extern uint8_t *phys_ram_base;
    1.11  extern uint8_t *phys_ram_dirty;
     2.1 --- a/tools/ioemu/exec.c	Tue Dec 20 12:46:56 2005 +0100
     2.2 +++ b/tools/ioemu/exec.c	Tue Dec 20 12:50:09 2005 +0100
     2.3 @@ -61,7 +61,7 @@ spinlock_t tb_lock = SPIN_LOCK_UNLOCKED;
     2.4  uint8_t code_gen_buffer[CODE_GEN_BUFFER_SIZE];
     2.5  uint8_t *code_gen_ptr;
     2.6  
     2.7 -int phys_ram_size;
     2.8 +uint64_t phys_ram_size;
     2.9  int phys_ram_fd;
    2.10  uint8_t *phys_ram_base;
    2.11  uint8_t *phys_ram_dirty;
     3.1 --- a/tools/ioemu/hw/pc.c	Tue Dec 20 12:46:56 2005 +0100
     3.2 +++ b/tools/ioemu/hw/pc.c	Tue Dec 20 12:50:09 2005 +0100
     3.3 @@ -119,7 +119,7 @@ static void cmos_init_hd(int type_ofs, i
     3.4  }
     3.5  
     3.6  /* hd_table must contain 4 block drivers */
     3.7 -static void cmos_init(int ram_size, int boot_device, BlockDriverState **hd_table)
     3.8 +static void cmos_init(uint64_t ram_size, int boot_device, BlockDriverState **hd_table)
     3.9  {
    3.10      RTCState *s = rtc_state;
    3.11      int val;
    3.12 @@ -375,7 +375,7 @@ static int serial_irq[MAX_SERIAL_PORTS] 
    3.13  #define NOBIOS 1
    3.14  
    3.15  /* PC hardware initialisation */
    3.16 -void pc_init(int ram_size, int vga_ram_size, int boot_device,
    3.17 +void pc_init(uint64_t ram_size, int vga_ram_size, int boot_device,
    3.18               DisplayState *ds, const char **fd_filename, int snapshot,
    3.19               const char *kernel_filename, const char *kernel_cmdline,
    3.20               const char *initrd_filename)
     4.1 --- a/tools/ioemu/hw/pcnet.h	Tue Dec 20 12:46:56 2005 +0100
     4.2 +++ b/tools/ioemu/hw/pcnet.h	Tue Dec 20 12:50:09 2005 +0100
     4.3 @@ -92,7 +92,7 @@
     4.4  #define CSR_NRBA(S)      ((S)->csr[22] | ((S)->csr[23] << 16))
     4.5  #define CSR_BADR(S)      ((S)->csr[24] | ((S)->csr[25] << 16))
     4.6  #define CSR_NRDA(S)      ((S)->csr[26] | ((S)->csr[27] << 16))
     4.7 -#define CSR_CRDA(S)      ((S)->csr[28] | ((S)->csr[29] << 16))
     4.8 +#define CSR_CRDA(S)      ((S)->csr[28] | (((uint32_t)((S)->csr[29])) << 16))
     4.9  #define CSR_BADX(S)      ((S)->csr[30] | ((S)->csr[31] << 16))
    4.10  #define CSR_NXDA(S)      ((S)->csr[32] | ((S)->csr[33] << 16))
    4.11  #define CSR_CXDA(S)      ((S)->csr[34] | ((S)->csr[35] << 16))
    4.12 @@ -102,7 +102,7 @@
    4.13  #define CSR_NXBA(S)      ((S)->csr[64] | ((S)->csr[65] << 16))
    4.14  
    4.15  #define PHYSADDR(S,A) \
    4.16 -  (BCR_SSIZE32(S) ? (A) : (A) | ((0xff00 & (uint32_t)(s)->csr[2])<<16))
    4.17 +  (BCR_SSIZE32(S) ? (A) : (A) | ((0xff00 & (uint32_t)(S)->csr[2])<<16))
    4.18  
    4.19  struct pcnet_initblk16 {
    4.20      uint16_t mode;
     5.1 --- a/tools/ioemu/vl.c	Tue Dec 20 12:46:56 2005 +0100
     5.2 +++ b/tools/ioemu/vl.c	Tue Dec 20 12:50:09 2005 +0100
     5.3 @@ -119,7 +119,7 @@ const char* vncconnect; /* do a reverse 
     5.4  const char* keyboard_layout = 0;
     5.5  int64_t ticks_per_sec;
     5.6  int boot_device = 'c';
     5.7 -int ram_size;
     5.8 +uint64_t ram_size;
     5.9  int domid = -1;
    5.10  static char network_script[1024];
    5.11  int pit_min_timer_count = 0;
    5.12 @@ -2906,7 +2906,7 @@ int main(int argc, char **argv)
    5.13                  help();
    5.14                  break;
    5.15              case QEMU_OPTION_m:
    5.16 -                ram_size = atoi(optarg) * 1024 * 1024;
    5.17 +                ram_size = atol(optarg) * 1024 * 1024;
    5.18                  if (ram_size <= 0)
    5.19                      help();
    5.20                  break;
     6.1 --- a/tools/ioemu/vl.h	Tue Dec 20 12:46:56 2005 +0100
     6.2 +++ b/tools/ioemu/vl.h	Tue Dec 20 12:50:09 2005 +0100
     6.3 @@ -116,7 +116,7 @@ extern int audio_enabled;
     6.4  extern int sb16_enabled;
     6.5  extern int adlib_enabled;
     6.6  extern int gus_enabled;
     6.7 -extern int ram_size;
     6.8 +extern uint64_t ram_size;
     6.9  extern int bios_size;
    6.10  extern int rtc_utc;
    6.11  extern int cirrus_vga_enabled;
    6.12 @@ -649,7 +649,7 @@ int pit_get_gate(PITState *pit, int chan
    6.13  int pit_get_out(PITState *pit, int channel, int64_t current_time);
    6.14  
    6.15  /* pc.c */
    6.16 -void pc_init(int ram_size, int vga_ram_size, int boot_device,
    6.17 +void pc_init(uint64_t ram_size, int vga_ram_size, int boot_device,
    6.18               DisplayState *ds, const char **fd_filename, int snapshot,
    6.19               const char *kernel_filename, const char *kernel_cmdline,
    6.20               const char *initrd_filename);
     7.1 --- a/tools/libxc/xc_vmx_build.c	Tue Dec 20 12:46:56 2005 +0100
     7.2 +++ b/tools/libxc/xc_vmx_build.c	Tue Dec 20 12:50:09 2005 +0100
     7.3 @@ -288,11 +288,11 @@ static int setup_guest(int xc_handle,
     7.4      l2_pgentry_t *vl2tab=NULL, *vl2e=NULL;
     7.5      unsigned long *page_array = NULL;
     7.6  #ifdef __x86_64__
     7.7 -    l3_pgentry_t *vl3tab=NULL, *vl3e=NULL;
     7.8 +    l3_pgentry_t *vl3tab=NULL;
     7.9      unsigned long l3tab;
    7.10  #endif
    7.11 -    unsigned long l2tab;
    7.12 -    unsigned long l1tab;
    7.13 +    unsigned long l2tab = 0;
    7.14 +    unsigned long l1tab = 0;
    7.15      unsigned long count, i;
    7.16      shared_info_t *shared_info;
    7.17      void *e820_page;
    7.18 @@ -323,7 +323,7 @@ static int setup_guest(int xc_handle,
    7.19      }
    7.20  
    7.21      /* memsize is in megabytes */
    7.22 -    v_end              = memsize << 20;
    7.23 +    v_end              = (unsigned long)memsize << 20;
    7.24  
    7.25  #ifdef __i386__
    7.26      nr_pt_pages = 1 + ((memsize + 3) >> 2);
    7.27 @@ -435,15 +435,16 @@ static int setup_guest(int xc_handle,
    7.28              goto error_out;
    7.29          memset(vl2tab, 0, PAGE_SIZE);
    7.30          munmap(vl2tab, PAGE_SIZE);
    7.31 +        vl2tab = NULL;
    7.32          vl3tab[i] = l2tab | L3_PROT;
    7.33      }
    7.34  
    7.35 -    vl3e = &vl3tab[l3_table_offset(0)];
    7.36      for ( count = 0; count < (v_end >> PAGE_SHIFT); count++ )
    7.37      {
    7.38 -        if (!(count & (1 << (L3_PAGETABLE_SHIFT - L1_PAGETABLE_SHIFT)))){
    7.39 +        if ( !(count & ((1 << (L3_PAGETABLE_SHIFT - L1_PAGETABLE_SHIFT)) - 1)) )
    7.40 +        {
    7.41              l2tab = vl3tab[count >> (L3_PAGETABLE_SHIFT - L1_PAGETABLE_SHIFT)]
    7.42 -                & PAGE_MASK;
    7.43 +                    & PAGE_MASK;
    7.44  
    7.45              if (vl2tab != NULL)
    7.46                  munmap(vl2tab, PAGE_SIZE);