From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40219) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WxxfR-0007wA-Lm for qemu-devel@nongnu.org; Fri, 20 Jun 2014 08:11:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WxxfM-0001y5-TK for qemu-devel@nongnu.org; Fri, 20 Jun 2014 08:11:41 -0400 Received: from mail-wi0-x234.google.com ([2a00:1450:400c:c05::234]:34025) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WxxfM-0001xz-Ma for qemu-devel@nongnu.org; Fri, 20 Jun 2014 08:11:36 -0400 Received: by mail-wi0-f180.google.com with SMTP id hi2so686915wib.7 for ; Fri, 20 Jun 2014 05:11:35 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Fri, 20 Jun 2014 14:11:13 +0200 Message-Id: <1403266283-1517-5-git-send-email-pbonzini@redhat.com> In-Reply-To: <1403266283-1517-1-git-send-email-pbonzini@redhat.com> References: <1403266283-1517-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PULL 04/14] hw/mips: Add API to convert KVM guest KSEG0 <-> GPA List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Sanjay Lal , James Hogan , Aurelien Jarno From: Sanjay Lal 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 Signed-off-by: James Hogan Cc: Aurelien Jarno Signed-off-by: Paolo Bonzini --- hw/mips/addr.c | 7 ++++++- include/hw/mips/cpudevs.h | 2 ++ 2 files changed, 8 insertions(+), 1 deletions(-) diff --git a/hw/mips/addr.c b/hw/mips/addr.c index 99488f1..ff3b952 100644 --- a/hw/mips/addr.c +++ b/hw/mips/addr.c @@ -25,10 +25,15 @@ 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; +} diff --git a/include/hw/mips/cpudevs.h b/include/hw/mips/cpudevs.h index 6bea24b..b2626f2 100644 --- a/include/hw/mips/cpudevs.h +++ b/include/hw/mips/cpudevs.h @@ -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); -- 1.7.1