return 0;
}
-static long long palacios_file_size(void * file_ptr) {
+static unsigned long long palacios_file_size(void * file_ptr) {
struct palacios_file * pfile = (struct palacios_file *)file_ptr;
struct file * filp = pfile->filp;
struct kstat s;
return s.size;
}
-static long long palacios_file_read(void * file_ptr, void * buffer, long long length, long long offset){
+static unsigned long long palacios_file_read(void * file_ptr, void * buffer, unsigned long long length, unsigned long long offset){
struct palacios_file * pfile = (struct palacios_file *)file_ptr;
struct file * filp = pfile->filp;
ssize_t ret;
set_fs(old_fs);
if (ret <= 0) {
- printk("sys_read of %p for %lld bytes failed\n", filp, length);
+ printk("sys_read of %p for %lld bytes at offset %llu failed (ret=%ld)\n", filp, length, offset, ret);
}
return ret;
}
-static long long palacios_file_write(void * file_ptr, void * buffer, long long length, long long offset) {
+static unsigned long long palacios_file_write(void * file_ptr, void * buffer, unsigned long long length, unsigned long long offset) {
struct palacios_file * pfile = (struct palacios_file *)file_ptr;
struct file * filp = pfile->filp;
mm_segment_t old_fs;
if (ret <= 0) {
- printk("sys_write failed\n");
+ printk("sys_write for %llu bytes at offset %llu failed (ret=%ld)\n", length, offset, ret);
}
return ret;
void * (*open)(const char * path, int mode, void * host_data);
int (*close)(void * fd);
- long long (*size)(void * fd);
+ unsigned long long (*size)(void * fd);
// blocking reads and writes
- long long (*read)(void * fd, void * buffer, long long length, long long offset);
- long long (*write)(void * fd, void * buffer, long long length, long long offset);
+ unsigned long long (*read)(void * fd, void * buffer, unsigned long long length, unsigned long long offset);
+ unsigned long long (*write)(void * fd, void * buffer, unsigned long long length, unsigned long long offset);
};
-static int write_all(v3_file_t fd, char * buf, int offset, int length) {
- int bytes_written = 0;
+static int write_all(v3_file_t fd, char * buf, uint64_t offset, uint64_t length) {
+ uint64_t bytes_written = 0;
- PrintDebug("Writing %d bytes\n", length - bytes_written);
+ PrintDebug("Writing %llu bytes\n", length - bytes_written);
while (bytes_written < length) {
int tmp_bytes = v3_file_write(fd, buf + bytes_written, length - bytes_written, offset + bytes_written);
PrintDebug("Wrote %d bytes\n", tmp_bytes);
}
-static int read_all(v3_file_t fd, char * buf, int offset, int length) {
- int bytes_read = 0;
+static int read_all(v3_file_t fd, char * buf, uint64_t offset, uint64_t length) {
+ uint64_t bytes_read = 0;
- PrintDebug("Reading %d bytes\n", length - bytes_read);
+ PrintDebug("Reading %llu bytes\n", length - bytes_read);
while (bytes_read < length) {
int tmp_bytes = v3_file_read(fd, buf + bytes_read, length - bytes_read, offset + bytes_read);
PrintDebug("Read %d bytes\n", tmp_bytes);
static int read(uint8_t * buf, uint64_t lba, uint64_t num_bytes, void * private_data) {
struct disk_state * disk = (struct disk_state *)private_data;
- PrintDebug("Reading %d bytes from %p to %p\n", (uint32_t)num_bytes, (uint8_t *)(disk->disk_image + lba), buf);
+ PrintDebug("Reading %llu bytes from %p to %p\n", num_bytes, (uint8_t *)(disk->disk_image + lba), buf);
if (lba + num_bytes > disk->capacity) {
PrintError("Out of bounds read: lba=%llu, num_bytes=%llu, capacity=%llu\n",
static int write(uint8_t * buf, uint64_t lba, uint64_t num_bytes, void * private_data) {
struct disk_state * disk = (struct disk_state *)private_data;
- PrintDebug("Writing %d bytes from %p to %p\n", (uint32_t)num_bytes, buf, (uint8_t *)(disk->disk_image + lba));
+ PrintDebug("Writing %llu bytes from %p to %p\n", num_bytes, buf, (uint8_t *)(disk->disk_image + lba));
if (lba + num_bytes > disk->capacity) {
PrintError("Out of bounds read: lba=%llu, num_bytes=%llu, capacity=%llu\n",
static uint64_t get_capacity(void * private_data) {
struct disk_state * disk = (struct disk_state *)private_data;
- PrintDebug("Querying FILEDISK capacity %d\n",
- (uint32_t)(disk->capacity));
+ PrintDebug("Querying FILEDISK capacity %llu\n", disk->capacity);
return disk->capacity;
}
disk->capacity = v3_file_size(disk->fd);
- PrintDebug("Registering FILEDISK %s (path=%s, fd=%lu, size=%lu)\n",
- dev_id, path, file->fd, file->capacity);
+ V3_Print("Registering FILEDISK %s (path=%s, fd=%lu, size=%llu)\n",
+ dev_id, path, (addr_t)disk->fd, disk->capacity);
if (v3_dev_connect_blk(vm, v3_cfg_val(frontend_cfg, "tag"),
#include "ata.h"
-#ifdef V3_CONFIG_DEBUG_IDE
+
static void print_prd_table(struct ide_internal * ide, struct ide_channel * channel) {
struct ide_dma_prd prd_entry;
int index = 0;
- PrintDebug("Dumping PRD table\n");
+ V3_Print("Dumping PRD table\n");
while (1) {
uint32_t prd_entry_addr = channel->dma_prd_addr + (sizeof(struct ide_dma_prd) * index);
return;
}
- PrintDebug("\tPRD Addr: %x, PRD Len: %d, EOT: %d\n",
+ V3_Print("\tPRD Addr: %x, PRD Len: %d, EOT: %d\n",
prd_entry.base_addr,
(prd_entry.size == 0) ? 0x10000 : prd_entry.size,
prd_entry.end_of_table);
return;
}
-#endif
+
/* IO Operations */
static int dma_read(struct guest_info * core, struct ide_internal * ide, struct ide_channel * channel) {
PrintDebug("PRD Addr: %x, PRD Len: %d, EOT: %d\n",
prd_entry.base_addr, prd_entry.size, prd_entry.end_of_table);
- prd_bytes_left = prd_entry.size;
+
+ if (prd_entry.size == 0) {
+ // a size of 0 means 64k
+ prd_bytes_left = 0x10000;
+ } else {
+ prd_bytes_left = prd_entry.size;
+ }
while (prd_bytes_left > 0) {
uint_t bytes_to_write = 0;
if ((prd_entry.end_of_table == 1) && (bytes_left > 0)) {
PrintError("DMA table not large enough for data transfer...\n");
+ PrintError("\t(bytes_left=%u) (transfer_length=%u)...\n",
+ bytes_left, drive->transfer_length);
+ PrintError("PRD Addr: %x, PRD Len: %d, EOT: %d\n",
+ prd_entry.base_addr, prd_entry.size, prd_entry.end_of_table);
+
+ print_prd_table(ide, channel);
return -1;
}
}
memset(&ipi, 0, sizeof(struct v3_gen_ipi));
+ // decode MSI fields into IPI
+
ipi.vector = data->vector + vec.irq;
ipi.mode = data->del_mode;
ipi.logical = addr->dst_mode;
ipi.dst_shorthand = 0;
ipi.dst = addr->dst_id;
- // decode MSI fields into IPI
-
- V3_Print("Decode MSI\n");
v3_apic_send_ipi(dev->vm, &ipi, dev->apic_dev);
data = &(msix_table->entries[vec.irq].data);
addr = &(msix_table->entries[vec.irq].addr);;
+ // decode MSIX fields into IPI
ipi.vector = data->vector + vec.irq;
ipi.mode = data->del_mode;
ipi.logical = addr->dst_mode;
ipi.dst_shorthand = 0;
ipi.dst = addr->dst_id;
- // decode MSIX fields into IPI
+
V3_Print("Decode MSIX\n");
#endif
- //PrintDebug("SVM Returned: Exit Code: %x\n",exit_code);
+
+ // PrintDebug("SVM Returned: Exit Code: %p\n", (void *)exit_code);
switch (exit_code) {
case VMEXIT_IOIO: {
PrintError("SVM Returned: Exit Code: %p\n", (void *)(addr_t)exit_code);
PrintError("io_info1 low = 0x%.8x\n", *(uint_t*)&(exit_info1));
- PrintError("io_info1 high = 0x%.8x\n", *(uint_t *)(((uchar_t *)&(exit_info1)) + 4));
+ PrintError("io_info1 high = 0x%.8x\n", *(uint_t *)(((uint8_t *)&(exit_info1)) + 4));
PrintError("io_info2 low = 0x%.8x\n", *(uint_t*)&(exit_info2));
- PrintError("io_info2 high = 0x%.8x\n", *(uint_t *)(((uchar_t *)&(exit_info2)) + 4));
+ PrintError("io_info2 high = 0x%.8x\n", *(uint_t *)(((uint8_t *)&(exit_info2)) + 4));
if (info->shdw_pg_mode == SHADOW_PAGING) {
int v3_deinit_shdw_impl(struct v3_vm_info * vm) {
struct v3_shdw_pg_impl * impl = vm->shdw_impl.current_impl;
+ if (impl == NULL) {
+ // Shadow paging not implemented
+ return 0;
+ }
+
if (impl->deinit(vm) == -1) {
PrintError("Error deinitializing shadow paging implementation\n");
return -1;