X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fpalacios%2Fvmm_multiboot.c;h=0959c48469fc439330f048596e1502c591207b0e;hb=28cd2d6deca639fe40256c4d3f2c8f9491ec777a;hp=c007291453f64d220ebcb36417841a9684628e72;hpb=ab1cd65da26f4b2cbc3c4d9625546561bf96461f;p=palacios.releases.git diff --git a/palacios/src/palacios/vmm_multiboot.c b/palacios/src/palacios/vmm_multiboot.c index c007291..0959c48 100644 --- a/palacios/src/palacios/vmm_multiboot.c +++ b/palacios/src/palacios/vmm_multiboot.c @@ -144,94 +144,6 @@ int v3_deinit_multiboot_core(struct guest_info *core) #define INFO(fmt, args...) PrintDebug(VM_NONE,VCORE_NONE,"multiboot: " fmt,##args) - -/****************************************************************** - Data contained in the ELF file we will attempt to boot -******************************************************************/ - -#define ELF_MAGIC 0x464c457f -#define MB2_MAGIC 0xe85250d6 - - -/****************************************************************** - Data we will pass to the kernel via rbx -******************************************************************/ - -#define MB2_INFO_MAGIC 0x36d76289 - -typedef struct mb_info_header { - uint32_t totalsize; - uint32_t reserved; -} __attribute__((packed)) mb_info_header_t; - -// A tag of type 0, size 8 indicates last value -// -typedef struct mb_info_tag { - uint32_t type; - uint32_t size; -} __attribute__((packed)) mb_info_tag_t; - - -#define MB_INFO_MEM_TAG 4 -typedef struct mb_info_mem { - mb_info_tag_t tag; - uint32_t mem_lower; // 0..640K in KB - uint32_t mem_upper; // in KB to first hole - 1 MB -} __attribute__((packed)) mb_info_mem_t; - -#define MB_INFO_CMDLINE_TAG 1 -// note alignment of 8 bytes required for each... -typedef struct mb_info_cmdline { - mb_info_tag_t tag; - uint32_t size; // includes zero termination - uint8_t string[]; // zero terminated -} __attribute__((packed)) mb_info_cmdline_t; - - -#define MEM_RAM 1 -#define MEM_ACPI 3 -#define MEM_RESV 4 - -typedef struct mb_info_memmap_entry { - uint64_t base_addr; - uint64_t length; - uint32_t type; - uint32_t reserved; -} __attribute__((packed)) mb_info_memmap_entry_t; - -#define MB_INFO_MEMMAP_TAG 6 -// note alignment of 8 bytes required for each... -typedef struct mb_info_memmap { - mb_info_tag_t tag; - uint32_t entry_size; // multiple of 8 - uint32_t entry_version; // 0 - mb_info_memmap_entry_t entries[]; -} __attribute__((packed)) mb_info_memmap_t; - -#define MB_INFO_HRT_TAG 0xf00df00d -typedef struct mb_info_hrt { - mb_info_tag_t tag; - // apic ids are 0..num_apics-1 - // apic and ioapic addresses are the well known places - uint32_t total_num_apics; - uint32_t first_hrt_apic_id; - uint32_t have_hrt_ioapic; - uint32_t first_hrt_ioapic_entry; - uint64_t first_hrt_addr; -} __attribute__((packed)) mb_info_hrt_t; - - -// We are not doing: -// -// - BIOS Boot Devie -// - Modules -// - ELF symbols -// - Boot Loader name -// - APM table -// - VBE info -// - Framebuffer info -// - static int is_elf(uint8_t *data, uint64_t size) { if (*((uint32_t*)data)==ELF_MAGIC) { @@ -269,7 +181,7 @@ static int checksum4_ok(uint32_t *data, uint64_t size) return sum==0; } -static int parse_multiboot_kernel(uint8_t *data, uint64_t size, mb_data_t *mb) +int v3_parse_multiboot_header(void *data, uint64_t size, mb_data_t *mb) { uint64_t i; @@ -382,7 +294,8 @@ static int parse_multiboot_kernel(uint8_t *data, uint64_t size, mb_data_t *mb) INFO(" size = 0x%x\n", mb_modalign->size); } break; -#if 0 + +#if V3_CONFIG_HVM case MB_TAG_MB64_HRT: { if (mb_mb64_hrt) { ERROR("Multiple mb64_hrt tags found!\n"); @@ -393,7 +306,6 @@ static int parse_multiboot_kernel(uint8_t *data, uint64_t size, mb_data_t *mb) } break; #endif - default: INFO("Unknown tag... Skipping...\n"); break; @@ -415,11 +327,6 @@ static int parse_multiboot_kernel(uint8_t *data, uint64_t size, mb_data_t *mb) } -int v3_parse_multiboot_header(struct v3_cfg_file *file, mb_data_t *result) -{ - return parse_multiboot_kernel(file->data,file->size,result); -} - #define APIC_BASE 0xfee00000 #define IOAPIC_BASE 0xfec00000 @@ -539,13 +446,7 @@ uint64_t v3_build_multiboot_table(struct guest_info *core, uint8_t *dest, uint64 #ifdef V3_CONFIG_HVM if (core->vm_info->hvm_state.is_hvm && v3_is_hvm_hrt_core(core)) { - hrt->tag.type = MB_INFO_HRT_TAG; - hrt->tag.size = sizeof(mb_info_hrt_t); - hrt->total_num_apics = vm->num_cores; - hrt->first_hrt_apic_id = vm->hvm_state.first_hrt_core; - hrt->have_hrt_ioapic=0; - hrt->first_hrt_ioapic_entry=0; - hrt->first_hrt_addr = vm->hvm_state.first_hrt_gpa; + v3_build_hrt_multiboot_tag(core,hrt); } #endif @@ -635,11 +536,11 @@ uint64_t v3_build_multiboot_table(struct guest_info *core, uint8_t *dest, uint64 } -int v3_write_multiboot_kernel(struct v3_vm_info *vm, mb_data_t *mb, struct v3_cfg_file *file, +int v3_write_multiboot_kernel(struct v3_vm_info *vm, mb_data_t *mb, void *data, uint64_t len, void *base, uint64_t limit) { uint32_t offset=0; - uint32_t header_offset = (uint32_t) ((uint64_t)(mb->header) - (uint64_t)(file->data)); + uint32_t header_offset = (uint32_t) ((uint64_t)(mb->header) - (uint64_t)(data)); uint32_t size; if (!mb->addr || !mb->entry) { @@ -657,15 +558,15 @@ int v3_write_multiboot_kernel(struct v3_vm_info *vm, mb_data_t *mb, struct v3_cf offset = header_offset - (mb->addr->header_addr - mb->addr->load_addr); size = mb->addr->load_end_addr - mb->addr->load_addr; - if (size != file->size-offset) { - V3_Print(vm,VCORE_NONE,"multiboot: strange: size computed as %u, but file->size-offset = %llu\n",size,file->size-offset); + if (size != len-offset) { + V3_Print(vm,VCORE_NONE,"multiboot: strange: size computed as %u, but len-offset = %llu\n",size,len-offset); } // We are trying to do as little ELF loading here as humanly possible v3_write_gpa_memory(&vm->cores[0], (addr_t)(mb->addr->load_addr), size, - file->data+offset); + data+offset); PrintDebug(vm,VCORE_NONE, "multiboot: wrote 0x%llx bytes starting at offset 0x%llx to %p\n", @@ -709,11 +610,11 @@ static int setup_multiboot_kernel(struct v3_vm_info *vm) } else { if (find_mb_header(vm->mb_state.mb_file->data,vm->mb_state.mb_file->size)) { PrintDebug(vm,VCORE_NONE,"multiboot: appears to be a multiboot kernel\n"); - if (v3_parse_multiboot_header(vm->mb_state.mb_file,&vm->mb_state.mb_data)) { + if (v3_parse_multiboot_header(vm->mb_state.mb_file->data,vm->mb_state.mb_file->size,&vm->mb_state.mb_data)) { PrintError(vm,VCORE_NONE,"multiboot: cannot parse multiboot kernel header\n"); return -1; } - if (v3_write_multiboot_kernel(vm, &(vm->mb_state.mb_data),vm->mb_state.mb_file,base,limit)) { + if (v3_write_multiboot_kernel(vm, &(vm->mb_state.mb_data),vm->mb_state.mb_file->data,vm->mb_state.mb_file->size,base,limit)) { PrintError(vm,VCORE_NONE,"multiboot: multiboot kernel setup failed\n"); return -1; }