From patchwork Sat Mar 2 15:18:41 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sanjay Lal X-Patchwork-Id: 2207221 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 670513FCF2 for ; Sat, 2 Mar 2013 15:19:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752718Ab3CBPTZ (ORCPT ); Sat, 2 Mar 2013 10:19:25 -0500 Received: from kymasys.com ([64.62.140.43]:58581 "HELO kymasys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1752703Ab3CBPTY (ORCPT ); Sat, 2 Mar 2013 10:19:24 -0500 Received: from agni.kymasys.com ([75.40.23.192]) by kymasys.com for ; Sat, 2 Mar 2013 07:19:22 -0800 Received: by agni.kymasys.com (Postfix, from userid 500) id 08B97630053; Sat, 2 Mar 2013 07:18:50 -0800 (PST) From: Sanjay Lal To: qemu-devel@nongnu.org Cc: kvm@vger.kernel.org, Aurelien Jarno , Gleb Natapov , Marcelo Tosatti , Sanjay Lal Subject: [Qemu-devel][PATCH 06/12] KVM/MIPS: Define APIs to convert Guest KSEG0 <-> Guest Physical addresses. Date: Sat, 2 Mar 2013 07:18:41 -0800 Message-Id: <1362237527-23678-8-git-send-email-sanjayl@kymasys.com> X-Mailer: git-send-email 1.7.11.3 In-Reply-To: <1362237527-23678-1-git-send-email-sanjayl@kymasys.com> References: <1362237527-23678-1-git-send-email-sanjayl@kymasys.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org In trap and emulate mode both the guest kernel and guest userspace execute in UM: Guest User address space: 0x00000000 -> 0x40000000 Guest Kernel Unmapped: 0x40000000 -> 0x60000000 Guest Kernel Mapped: 0x60000000 -> 0x80000000 --- hw/mips_addr.c | 14 ++++++++++++++ hw/mips_cpudevs.h | 4 ++++ 2 files changed, 18 insertions(+) diff --git a/hw/mips_addr.c b/hw/mips_addr.c index aa1c7d8..c24d2d9 100644 --- a/hw/mips_addr.c +++ b/hw/mips_addr.c @@ -22,13 +22,27 @@ #include "hw.h" #include "mips_cpudevs.h" +#include "sysemu/kvm.h" + uint64_t cpu_mips_kseg0_to_phys(void *opaque, uint64_t addr) { return addr & 0x7fffffffll; } + +uint64_t cpu_mips_kvm_um_kseg0_to_phys(void *opaque, uint64_t addr) +{ + return addr & 0x3fffffffll; +} + 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/hw/mips_cpudevs.h b/hw/mips_cpudevs.h index 6bea24b..9e5af37 100644 --- a/hw/mips_cpudevs.h +++ b/hw/mips_cpudevs.h @@ -6,6 +6,10 @@ 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_kseg0_to_phys(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);