From patchwork Sun Apr 23 22:40:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stafford Horne X-Patchwork-Id: 9695305 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3D0C4601AE for ; Sun, 23 Apr 2017 22:42:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3FB6125F31 for ; Sun, 23 Apr 2017 22:42:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3479B262AE; Sun, 23 Apr 2017 22:42:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9827025F31 for ; Sun, 23 Apr 2017 22:42:36 +0000 (UTC) Received: from localhost ([::1]:40830 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d2QDD-0000VE-Op for patchwork-qemu-devel@patchwork.kernel.org; Sun, 23 Apr 2017 18:42:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55861) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d2QC2-0000SL-BP for qemu-devel@nongnu.org; Sun, 23 Apr 2017 18:41:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d2QC1-0000QA-J4 for qemu-devel@nongnu.org; Sun, 23 Apr 2017 18:41:22 -0400 Received: from mail-it0-x243.google.com ([2607:f8b0:4001:c0b::243]:35134) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d2QC1-0000Q2-Dm for qemu-devel@nongnu.org; Sun, 23 Apr 2017 18:41:21 -0400 Received: by mail-it0-x243.google.com with SMTP id e132so11953230ite.2 for ; Sun, 23 Apr 2017 15:41:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=yxHg3XOdD+A+57odxRvo3TC/7WsvaeDBVyL72alOQJg=; b=p5MU1PQUUdxtRgtFGKn4jrQCxv2Fh38DUxAnCoHOBbPyasZp+LXQfeSHDx9cbe3vLU mBQ3J4cV/3RVwPNeY8pMczWmjl3nZOXsR2DIqwxfg6K+pMWAAh6XmFj7PuynitGUaLxU DhrX0udiECWdZPVvnqOoEhPY7b+niR7yepQ0ADYReOtm3WqSSebJnOmJ4OB26Y35x4hN 1qLkCjwOyW4U0ymFspnE9XSU3Yo011LWjRfRD1fKQVz10T590vtUCI8rOWaKH4xqx6Xg nu/a5/Frv/X50ZOj5y5vgLOMLdVEsODaVQqpPsqnneIGsjwFnqWBwmCC868d33u3ir5L GHBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=yxHg3XOdD+A+57odxRvo3TC/7WsvaeDBVyL72alOQJg=; b=TfG+EPwMc3NJsg4YRoRMGQ3qt+xS4JMKHp4VNGZJPvqNbWkcDlLhFPnEqoCqTrl8H8 Gx24IOJT6A7Tg8RvuwqBODTNkzgbwSwXibctHifmenoV1k5tC5WHscclS65X+p0gmMx2 VFfY5wMSFZ1PqTInMsO5lygFCmvyj409TpNRMJsPDiH3nBucjEcudTMDro5f+sxmEcpz E7H1kHZFKes7Or0biF9I0GGMxroPkw5n9s5TiC8gX+otRfj3Hf1TmJx/87ouyL+Ql3a7 vBJvRJYDU4zE7nGPjSUKDJftDNDVdo80QwCWig9tL2zMIGKgXs/ZwC69ZzoP+OQeLSfI 6iPw== X-Gm-Message-State: AN3rC/7BKOskb+tpw8957RjAwdoRW8LgWlDwqTrg6v0TmsL9gbS7jUiW dbhd81VYJsGhtg== X-Received: by 10.99.141.199 with SMTP id z190mr21846763pgd.118.1492987280823; Sun, 23 Apr 2017 15:41:20 -0700 (PDT) Received: from localhost (z64.124-44-184.ppp.wakwak.ne.jp. [124.44.184.64]) by smtp.gmail.com with ESMTPSA id w17sm26887134pfg.75.2017.04.23.15.41.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 23 Apr 2017 15:41:20 -0700 (PDT) From: Stafford Horne To: QEMU Development Date: Mon, 24 Apr 2017 07:40:51 +0900 Message-Id: X-Mailer: git-send-email 2.9.3 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4001:c0b::243 Subject: [Qemu-devel] [PATCH v2 3/9] target/openrisc: Fixes for memory debugging X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stafford Horne , Openrisc , "Tim \\'mithro\\' Ansell" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP When debugging in gdb you might want to inspect instructions in mapped pages or in exception vectors like 0x800 etc. This was previously not possible in qemu since the *get_phys_page_debug() routine only looked into the data tlb. Change to fall back to look into instruction tlb and plain physical pages. Reviewed-by: Richard Henderson Signed-off-by: Stafford Horne --- target/openrisc/mmu.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/target/openrisc/mmu.c b/target/openrisc/mmu.c index 56b11d3..a6d7bcd 100644 --- a/target/openrisc/mmu.c +++ b/target/openrisc/mmu.c @@ -124,7 +124,7 @@ static int cpu_openrisc_get_phys_addr(OpenRISCCPU *cpu, { int ret = TLBRET_MATCH; - if (rw == 2) { /* ITLB */ + if (rw == MMU_INST_FETCH) { /* ITLB */ *physical = 0; ret = cpu->env.tlb->cpu_openrisc_map_address_code(cpu, physical, prot, address, rw); @@ -221,12 +221,27 @@ hwaddr openrisc_cpu_get_phys_page_debug(CPUState *cs, vaddr addr) OpenRISCCPU *cpu = OPENRISC_CPU(cs); hwaddr phys_addr; int prot; + int miss; - if (cpu_openrisc_get_phys_addr(cpu, &phys_addr, &prot, addr, 0)) { - return -1; + /* Check memory for any kind of address, since during debug the + gdb can ask for anything, check data tlb for address */ + miss = cpu_openrisc_get_phys_addr(cpu, &phys_addr, &prot, addr, 0); + + /* Check instruction tlb */ + if (miss) { + miss = cpu_openrisc_get_phys_addr(cpu, &phys_addr, &prot, addr, MMU_INST_FETCH); + } + + /* Last, fall back to a plain address */ + if (miss) { + miss = cpu_openrisc_get_phys_nommu(cpu, &phys_addr, &prot, addr, 0); } - return phys_addr; + if (miss) { + return -1; + } else { + return phys_addr; + } } void cpu_openrisc_mmu_init(OpenRISCCPU *cpu)