]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
hw/mips: Add API to convert KVM guest KSEG0 <-> GPA
authorSanjay Lal <sanjayl@kymasys.com>
Tue, 17 Jun 2014 22:10:28 +0000 (23:10 +0100)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 18 Jun 2014 14:58:10 +0000 (16:58 +0200)
Add API for converting physical addresses to KVM guest KSEG0 addresses,
and fix the existing API for converting KSEG0 addresses to physical
addresses to work in the KVM case. Both have the same sized KSEG0, so
it's just a case of fixing the mask.

In KVM trap and emulate mode both the guest kernel and guest userspace
execute in useg:
    Guest User address space:   0x00000000..0x3fffffff
    Guest Kernel Unmapped:      0x40000000..0x5fffffff
    Guest Kernel Mapped:        0x60000000..0x7fffffff

Signed-off-by: Sanjay Lal <sanjayl@kymasys.com>
Signed-off-by: James Hogan <james.hogan@imgtec.com>
Cc: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
hw/mips/addr.c
include/hw/mips/cpudevs.h

index 99488f1d2a6f2a8cff217f59013f93355785c9b8..ff3b952600bbb8403e28c6c03ab97c0b2f860f27 100644 (file)
 
 uint64_t cpu_mips_kseg0_to_phys(void *opaque, uint64_t addr)
 {
-    return addr & 0x7fffffffll;
+    return addr & 0x1fffffffll;
 }
 
 uint64_t cpu_mips_phys_to_kseg0(void *opaque, uint64_t addr)
 {
     return addr | ~0x7fffffffll;
 }
+
+uint64_t cpu_mips_kvm_um_phys_to_kseg0(void *opaque, uint64_t addr)
+{
+    return addr | 0x40000000ll;
+}
index 6bea24bf102db91147ecc08b98c31dc72b075f59..b2626f2922f4c8314fb1b64910752fec4bbdc2a6 100644 (file)
@@ -5,6 +5,8 @@
 /* mips_addr.c */
 uint64_t cpu_mips_kseg0_to_phys(void *opaque, uint64_t addr);
 uint64_t cpu_mips_phys_to_kseg0(void *opaque, uint64_t addr);
+uint64_t cpu_mips_kvm_um_phys_to_kseg0(void *opaque, uint64_t addr);
+
 
 /* mips_int.c */
 void cpu_mips_irq_init_cpu(CPUMIPSState *env);