From patchwork Fri Mar 14 12:47:54 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Hogan X-Patchwork-Id: 330294 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 919022C00B5 for ; Fri, 14 Mar 2014 23:50:22 +1100 (EST) Received: from localhost ([::1]:44513 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WORZ6-0005ox-GI for incoming@patchwork.ozlabs.org; Fri, 14 Mar 2014 08:50:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55924) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WORXG-0003VN-GR for qemu-devel@nongnu.org; Fri, 14 Mar 2014 08:48:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WORXB-00061v-8n for qemu-devel@nongnu.org; Fri, 14 Mar 2014 08:48:26 -0400 Received: from mailapp01.imgtec.com ([195.89.28.114]:38967) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WORXB-000619-2v for qemu-devel@nongnu.org; Fri, 14 Mar 2014 08:48:21 -0400 Received: from KLMAIL01.kl.imgtec.org (unknown [192.168.5.35]) by Websense Email Security Gateway with ESMTPS id 8BEEE8EC6EBAD; Fri, 14 Mar 2014 12:48:17 +0000 (GMT) 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.174.1; Fri, 14 Mar 2014 12:48:19 +0000 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.174.1; Fri, 14 Mar 2014 12:48:19 +0000 Received: from jhogan-linux.le.imgtec.org (192.168.154.65) by LEMAIL01.le.imgtec.org (192.168.152.62) with Microsoft SMTP Server (TLS) id 14.3.174.1; Fri, 14 Mar 2014 12:48:18 +0000 From: James Hogan To: Date: Fri, 14 Mar 2014 12:47:54 +0000 Message-ID: <1394801281-18997-4-git-send-email-james.hogan@imgtec.com> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1394801281-18997-1-git-send-email-james.hogan@imgtec.com> References: <1394801281-18997-1-git-send-email-james.hogan@imgtec.com> MIME-Version: 1.0 X-Originating-IP: [192.168.154.65] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 195.89.28.114 Cc: James Hogan , kvm@vger.kernel.org, Gleb Natapov , Sanjay Lal , Paolo Bonzini , Aurelien Jarno Subject: [Qemu-devel] [PATCH v4 03/10] target-mips: get_physical_address: Add defines for segment bases 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 Add preprocessor definitions for 32bit segment bases for use in get_physical_address(). These will also be taken advantage of in the next patch which adds KVM awareness. Signed-off-by: James Hogan Reviewed-by: Aurelien Jarno --- target-mips/helper.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/target-mips/helper.c b/target-mips/helper.c index b28ae9b..2b30fc2 100644 --- a/target-mips/helper.c +++ b/target-mips/helper.c @@ -118,7 +118,13 @@ static int get_physical_address (CPUMIPSState *env, hwaddr *physical, qemu_log("user mode %d h %08x\n", user_mode, env->hflags); #endif - if (address <= (int32_t)0x7FFFFFFFUL) { +#define USEG_LIMIT 0x7FFFFFFFUL +#define KSEG0_BASE 0x80000000UL +#define KSEG1_BASE 0xA0000000UL +#define KSEG2_BASE 0xC0000000UL +#define KSEG3_BASE 0xE0000000UL + + if (address <= USEG_LIMIT) { /* useg */ if (env->CP0_Status & (1 << CP0St_ERL)) { *physical = address & 0xFFFFFFFF; @@ -160,23 +166,23 @@ static int get_physical_address (CPUMIPSState *env, hwaddr *physical, ret = TLBRET_BADADDR; } #endif - } else if (address < (int32_t)0xA0000000UL) { + } else if (address < (int32_t)KSEG1_BASE) { /* kseg0 */ if (kernel_mode) { - *physical = address - (int32_t)0x80000000UL; + *physical = address - (int32_t)KSEG0_BASE; *prot = PAGE_READ | PAGE_WRITE; } else { ret = TLBRET_BADADDR; } - } else if (address < (int32_t)0xC0000000UL) { + } else if (address < (int32_t)KSEG2_BASE) { /* kseg1 */ if (kernel_mode) { - *physical = address - (int32_t)0xA0000000UL; + *physical = address - (int32_t)KSEG1_BASE; *prot = PAGE_READ | PAGE_WRITE; } else { ret = TLBRET_BADADDR; } - } else if (address < (int32_t)0xE0000000UL) { + } else if (address < (int32_t)KSEG3_BASE) { /* sseg (kseg2) */ if (supervisor_mode || kernel_mode) { ret = env->tlb->map_address(env, physical, prot, address, rw, access_type);