On 19/03/14 16:39, Paolo Bonzini wrote: > Il 14/03/2014 13:47, James Hogan ha scritto: >> int prom_index = 0; >> + uint64_t (*xlate_to_phys) (void *opaque, uint64_t addr); >> + uint64_t (*xlate_to_kseg0) (void *opaque, uint64_t addr); >> + >> >> #ifdef TARGET_WORDS_BIGENDIAN >> big_endian = 1; >> @@ -781,7 +787,15 @@ static int64_t load_kernel (void) >> big_endian = 0; >> #endif >> >> - if (load_elf(loaderparams.kernel_filename, >> cpu_mips_kseg0_to_phys, NULL, >> + if (kvm_enabled()) { >> + xlate_to_phys = cpu_mips_kvm_um_kseg0_to_phys; >> + xlate_to_kseg0 = cpu_mips_kvm_um_phys_to_kseg0; >> + } else { >> + xlate_to_phys = cpu_mips_kseg0_to_phys; >> + xlate_to_kseg0 = cpu_mips_phys_to_kseg0; >> + } >> + >> + if (load_elf(loaderparams.kernel_filename, xlate_to_phys, NULL, >> (uint64_t *)&kernel_entry, NULL, (uint64_t >> *)&kernel_high, >> big_endian, ELF_MACHINE, 1) < 0) { >> fprintf(stderr, "qemu: could not load kernel '%s'\n", >> @@ -820,7 +834,7 @@ static int64_t load_kernel (void) >> prom_set(prom_buf, prom_index++, "%s", >> loaderparams.kernel_filename); >> if (initrd_size > 0) { >> prom_set(prom_buf, prom_index++, "rd_start=0x%" PRIx64 " >> rd_size=%li %s", >> - cpu_mips_phys_to_kseg0(NULL, initrd_offset), >> initrd_size, >> + xlate_to_kseg0(NULL, initrd_offset), initrd_size, >> loaderparams.kernel_cmdline); >> } else { >> prom_set(prom_buf, prom_index++, "%s", >> loaderparams.kernel_cmdline); >> @@ -829,12 +843,13 @@ static int64_t load_kernel (void) >> prom_set(prom_buf, prom_index++, "memsize"); >> prom_set(prom_buf, prom_index++, "%i", >> MIN(loaderparams.ram_size, 256 << 20)); >> + >> prom_set(prom_buf, prom_index++, "modetty0"); >> prom_set(prom_buf, prom_index++, "38400n8r"); >> prom_set(prom_buf, prom_index++, NULL); >> >> rom_add_blob_fixed("prom", prom_buf, prom_size, >> - cpu_mips_kseg0_to_phys(NULL, ENVP_ADDR)); >> + xlate_to_phys(NULL, ENVP_ADDR)); >> > > Why do you need the function pointers? Can > cpu_mips_kseg0_to_phys/cpu_mips_phys_to_kseg0 just use kvm_enabled()? Maybe because of its use as an argument to load_elf, which presumably calls it multiple times. Although looking at glue(load_elf, SZ) I think it's only used for each load section so I doubt it would make a difference. I'll change it. Cheers James
Attachment:
signature.asc
Description: OpenPGP digital signature