From patchwork Tue Jan 3 18:38:46 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 134052 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id E5E60B6F99 for ; Wed, 4 Jan 2012 05:31:47 +1100 (EST) Received: from localhost ([::1]:49017 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ri932-0002qN-O7 for incoming@patchwork.ozlabs.org; Tue, 03 Jan 2012 13:25:20 -0500 Received: from eggs.gnu.org ([140.186.70.92]:55299) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ri92J-0000es-L9 for qemu-devel@nongnu.org; Tue, 03 Jan 2012 13:24:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ri92C-0002SK-Ov for qemu-devel@nongnu.org; Tue, 03 Jan 2012 13:24:35 -0500 Received: from cantor2.suse.de ([195.135.220.15]:54558 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ri92C-0002Rk-Fl; Tue, 03 Jan 2012 13:24:28 -0500 Received: from relay1.suse.de (nat.nue.novell.com [195.135.221.2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id 6C8AC8C061; Tue, 3 Jan 2012 19:24:27 +0100 (CET) From: Alexander Graf To: "qemu-devel@nongnu.org Developers" Date: Tue, 3 Jan 2012 19:38:46 +0100 Message-Id: <1325615927-1096-4-git-send-email-agraf@suse.de> X-Mailer: git-send-email 1.7.3.4 In-Reply-To: <1325615927-1096-1-git-send-email-agraf@suse.de> References: <1325615927-1096-1-git-send-email-agraf@suse.de> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6 X-Received-From: 195.135.220.15 Cc: qemu-ppc@nongnu.org, Hollis Blanchard Subject: [Qemu-devel] [PATCH] PPC: Bamboo: Set initial TLB entry 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 Back in the day when the bamboo target got introduced, the initial TLB was dictated by KVM. TCG has been missing initial TLB values ever since, rendering the target unusable for TCG usage. This patch adds linear TLB maps the way Linux expects them, making the target work. Signed-off-by: Alexander Graf --- hw/ppc440_bamboo.c | 27 ++++++++++++++++++++++++++- 1 files changed, 26 insertions(+), 1 deletions(-) diff --git a/hw/ppc440_bamboo.c b/hw/ppc440_bamboo.c index f82d587..c17f6f7 100644 --- a/hw/ppc440_bamboo.c +++ b/hw/ppc440_bamboo.c @@ -103,6 +103,29 @@ out: return ret; } +/* Create reset TLB entries for BookE, spanning the 32bit addr space. */ +static void mmubooke_create_initial_mapping(CPUState *env, + target_ulong va, + target_phys_addr_t pa) +{ + ppcemb_tlb_t *tlb = &env->tlb.tlbe[0]; + + tlb->attr = 0; + tlb->prot = PAGE_VALID | ((PAGE_READ | PAGE_WRITE | PAGE_EXEC) << 4); + tlb->size = 1 << 31; /* up to 0x80000000 */ + tlb->EPN = va & TARGET_PAGE_MASK; + tlb->RPN = pa & TARGET_PAGE_MASK; + tlb->PID = 0; + + tlb = &env->tlb.tlbe[1]; + tlb->attr = 0; + tlb->prot = PAGE_VALID | ((PAGE_READ | PAGE_WRITE | PAGE_EXEC) << 4); + tlb->size = 1 << 31; /* up to 0xffffffff */ + tlb->EPN = 0x80000000 & TARGET_PAGE_MASK; + tlb->RPN = 0x80000000 & TARGET_PAGE_MASK; + tlb->PID = 0; +} + static void main_cpu_reset(void *opaque) { CPUState *env = opaque; @@ -111,6 +134,9 @@ static void main_cpu_reset(void *opaque) env->gpr[1] = (16<<20) - 8; env->gpr[3] = FDT_ADDR; env->nip = entry; + + /* Create a mapping for the kernel. */ + mmubooke_create_initial_mapping(env, 0, 0); } static void bamboo_init(ram_addr_t ram_size, @@ -181,7 +207,6 @@ static void bamboo_init(ram_addr_t ram_size, fprintf(stderr, "couldn't load device tree\n"); exit(1); } - /* XXX we currently depend on KVM to create some initial TLB entries. */ } if (kvm_enabled())