From: Erik van der Kouwe Date: Fri, 5 Nov 2010 21:19:47 +0000 (-0500) Subject: This patch contains various small fixes. Some are MINIX-specific, some are general. X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?p=palacios.git;a=commitdiff_plain;h=b1a5e7177b66fa319c896492d87f6276508bcbce This patch contains various small fixes. Some are MINIX-specific, some are general. --- diff --git a/palacios/include/palacios/vmcs.h b/palacios/include/palacios/vmcs.h index 11309bf..9129d1b 100644 --- a/palacios/include/palacios/vmcs.h +++ b/palacios/include/palacios/vmcs.h @@ -83,7 +83,7 @@ typedef enum { VMCS_LINK_PTR_HIGH = 0x00002801, VMCS_GUEST_DBG_CTL = 0x00002802, VMCS_GUEST_DBG_CTL_HIGH = 0x00002803, - VMCS_GUEST_EFER = 0x00002805, + VMCS_GUEST_EFER = 0x00002806, VMCS_GUEST_EFER_HIGH = 0x00002807, VMCS_GUEST_PERF_GLOBAL_CTRL = 0x00002808, VMCS_GUEST_PERF_GLOBAL_CTRL_HIGH = 0x00002809, diff --git a/palacios/src/devices/8254.c b/palacios/src/devices/8254.c index ecb2fa0..8e7dede 100644 --- a/palacios/src/devices/8254.c +++ b/palacios/src/devices/8254.c @@ -162,12 +162,6 @@ static int handle_crystal_tics(struct vm_device * dev, struct channel * ch, uint reload_val = 0xffff; } - // TODO: Check this.... - // Is this correct??? - if (reload_val == 0) { - reload_val = 1; - } - oscillations -= ch->counter; ch->counter = 0; channel_cycles = 1; @@ -176,6 +170,12 @@ static int handle_crystal_tics(struct vm_device * dev, struct channel * ch, uint reload_val -= reload_val % 2; } + // TODO: Check this.... + // Is this correct??? + if (reload_val == 0) { + reload_val = 1; + } + channel_cycles += oscillations / reload_val; oscillations = oscillations % reload_val; diff --git a/palacios/src/devices/curses_cons.c b/palacios/src/devices/curses_cons.c index 528b6a0..d712a58 100644 --- a/palacios/src/devices/curses_cons.c +++ b/palacios/src/devices/curses_cons.c @@ -27,6 +27,7 @@ #include #include #include +#include #include diff --git a/palacios/src/devices/ide.c b/palacios/src/devices/ide.c index a31aec2..4ad0fa9 100644 --- a/palacios/src/devices/ide.c +++ b/palacios/src/devices/ide.c @@ -390,7 +390,7 @@ static void print_prd_table(struct vm_device * dev, struct ide_channel * channel static int dma_read(struct guest_info * core, struct vm_device * dev, struct ide_channel * channel) { struct ide_drive * drive = get_selected_drive(channel); // This is at top level scope to do the EOT test at the end - struct ide_dma_prd prd_entry; + struct ide_dma_prd prd_entry = {}; uint_t bytes_left = drive->transfer_length; // Read in the data buffer.... @@ -530,7 +530,7 @@ static int dma_read(struct guest_info * core, struct vm_device * dev, struct ide static int dma_write(struct guest_info * core, struct vm_device * dev, struct ide_channel * channel) { struct ide_drive * drive = get_selected_drive(channel); // This is at top level scope to do the EOT test at the end - struct ide_dma_prd prd_entry; + struct ide_dma_prd prd_entry = {}; uint_t bytes_left = drive->transfer_length; diff --git a/palacios/src/devices/serial.c b/palacios/src/devices/serial.c index 961b7ea..ab23c91 100644 --- a/palacios/src/devices/serial.c +++ b/palacios/src/devices/serial.c @@ -503,7 +503,7 @@ static int write_data_port(struct guest_info * core, uint16_t port, if (com_port->stream_ops) { uint8_t c; dequeue_data(&(com_port->tx_buffer), &c, com_port, dev); - com_port->stream_ops->stream_write(&c,1,com_port->backend_data); + com_port->stream_ops->write(&c,1,com_port->backend_data); } } @@ -1000,6 +1000,7 @@ int v3_stream_register_serial(struct vm_device * serial_dev, struct v3_stream_op state->com1.stream_ops = ops; state->com1.backend_data = private_data; /* bind to other ports here */ + return 0; } diff --git a/palacios/src/palacios/vmcs.c b/palacios/src/palacios/vmcs.c index a77de77..154bed8 100644 --- a/palacios/src/palacios/vmcs.c +++ b/palacios/src/palacios/vmcs.c @@ -227,7 +227,14 @@ int v3_vmx_save_vmcs(struct guest_info * info) { check_vmcs_read(VMCS_GUEST_RFLAGS, &(info->ctrl_regs.rflags)); if (((struct vmx_data *)info->vmm_data)->ia32e_avail) { +#ifdef __V3_64BIT__ check_vmcs_read(VMCS_GUEST_EFER, &(info->ctrl_regs.efer)); +#else + uint32_t hi, lo; + check_vmcs_read(VMCS_GUEST_EFER, &hi); + check_vmcs_read(VMCS_GUEST_EFER_HIGH, &lo); + info->ctrl_regs.efer = ((uint64_t) hi << 32) | lo; +#endif } error = v3_read_vmcs_segments(&(info->segments)); diff --git a/palacios/src/palacios/vmx.c b/palacios/src/palacios/vmx.c index d565d1f..3417767 100644 --- a/palacios/src/palacios/vmx.c +++ b/palacios/src/palacios/vmx.c @@ -402,8 +402,12 @@ static int init_vmcs_bios(struct guest_info * info, struct vmx_data * vmx_state) info->dbg_regs.dr7 = 0x400; +#ifdef __V3_64BIT__ vmx_ret |= check_vmcs_write(VMCS_LINK_PTR, (addr_t)0xffffffffffffffffULL); - +#else + vmx_ret |= check_vmcs_write(VMCS_LINK_PTR, (addr_t)0xffffffffUL); + vmx_ret |= check_vmcs_write(VMCS_LINK_PTR_HIGH, (addr_t)0xffffffffUL); +#endif if (v3_update_vmcs_ctrl_fields(info)) { PrintError("Could not write control fields!\n"); diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c index 668a11a..8f1e680 100644 --- a/scripts/basic/fixdep.c +++ b/scripts/basic/fixdep.c @@ -261,6 +261,66 @@ int strrcmp(char *s, char *sub) return memcmp(s + slen - sublen, sub, sublen); } +#ifdef __minix +/* MINIX does not support memory-mapped files; + * fortunately we only need to read the file which means we can just + * use malloc and read to achieve a similar effect + */ +#define mmap mmap_hack +#define munmap munmap_hack + +#include + +static void *mmap(void *start, size_t size, int prot, int flags, int fd, + off_t offset) +{ + void *map; + off_t position; + ssize_t sizeread; + + /* verify that we can handle this request */ + assert(start == NULL); + assert(prot == PROT_READ); + assert(flags == MAP_PRIVATE); + + /* seek to offset, storing old file pointer */ + if ((position = lseek(fd, 0, SEEK_CUR)) == -1 || + lseek(fd, offset, SEEK_SET) != offset) { + perror("fixdep: lseek"); + } + + /* allocate memory for file buffer */ + map = malloc(size); + if (map) { + /* read the file data */ + sizeread = read(fd, map, size); + if (sizeread != size) { + /* read failed or file size not as expected, + * return mmap error code + */ + free(map); + map = (void *) -1L; + } + } else { + /* malloc failed, return mmap error code */ + map = (void *) -1L; + } + + /* restore old file pointer */ + if (lseek(fd, position, SEEK_SET) != position) { + perror("fixdep: lseek"); + } + + return map; +} + +static int munmap(void *start, size_t length) +{ + free(start); + return 0; +} +#endif + void do_config_file(char *filename) { struct stat st;