From patchwork Tue Jun 17 22:10:28 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Hogan X-Patchwork-Id: 361210 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id A80B9140081 for ; Wed, 18 Jun 2014 08:17:14 +1000 (EST) Received: from localhost ([::1]:53846 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wx1gm-0004Uq-6r for incoming@patchwork.ozlabs.org; Tue, 17 Jun 2014 18:17:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33790) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wx1e1-0008NT-GT for qemu-devel@nongnu.org; Tue, 17 Jun 2014 18:14:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wx1ds-00007x-4r for qemu-devel@nongnu.org; Tue, 17 Jun 2014 18:14:21 -0400 Received: from mailapp01.imgtec.com ([195.59.15.196]:16592) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wx1dr-00007E-VC for qemu-devel@nongnu.org; Tue, 17 Jun 2014 18:14:12 -0400 Received: from KLMAIL01.kl.imgtec.org (unknown [192.168.5.35]) by Websense Email Security Gateway with ESMTPS id C97807EB09552; Tue, 17 Jun 2014 23:14:03 +0100 (IST) Received: from KLMAIL02.kl.imgtec.org (192.168.5.97) by KLMAIL01.kl.imgtec.org (192.168.5.35) with Microsoft SMTP Server (TLS) id 14.3.181.6; Tue, 17 Jun 2014 23:11:53 +0100 Received: from LEMAIL01.le.imgtec.org (192.168.152.62) by klmail02.kl.imgtec.org (192.168.5.97) with Microsoft SMTP Server (TLS) id 14.3.181.6; Tue, 17 Jun 2014 23:10:46 +0100 Received: from jhogan-linux.le.imgtec.org (192.168.154.101) by LEMAIL01.le.imgtec.org (192.168.152.62) with Microsoft SMTP Server (TLS) id 14.3.174.1; Tue, 17 Jun 2014 23:10:45 +0100 From: James Hogan To: Date: Tue, 17 Jun 2014 23:10:28 +0100 Message-ID: <1403043037-1271-4-git-send-email-james.hogan@imgtec.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1403043037-1271-1-git-send-email-james.hogan@imgtec.com> References: <1403043037-1271-1-git-send-email-james.hogan@imgtec.com> MIME-Version: 1.0 X-Originating-IP: [192.168.154.101] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 195.59.15.196 Cc: James Hogan , kvm@vger.kernel.org, Gleb Natapov , Sanjay Lal , Paolo Bonzini , Aurelien Jarno Subject: [Qemu-devel] [PATCH v5 03/12] hw/mips: Add API to convert KVM guest KSEG0 <-> GPA X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- Changes in v5: - KSEG0 doesn't actually change size, so fix mask in cpu_mips_kseg0_to_phys() instead of having the KVM specific cpu_mips_kvm_um_kseg0_to_phys(). Changes in v2: - Expand commit message - Remove unnecessary include --- hw/mips/addr.c | 7 ++++++- include/hw/mips/cpudevs.h | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/hw/mips/addr.c b/hw/mips/addr.c index 99488f1d2a6f..ff3b952600bb 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 6bea24bf102d..b2626f2922f4 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);