From patchwork Thu May 4 00:53:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stafford Horne X-Patchwork-Id: 9710679 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 91B1260362 for ; Thu, 4 May 2017 00:55:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 85F4128678 for ; Thu, 4 May 2017 00:55:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 797A92867D; Thu, 4 May 2017 00:55:22 +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 B598828678 for ; Thu, 4 May 2017 00:55:21 +0000 (UTC) Received: from localhost ([::1]:39197 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d653A-0001Qo-W3 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 03 May 2017 20:55:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56811) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d651n-0001KZ-BS for qemu-devel@nongnu.org; Wed, 03 May 2017 20:53:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d651k-0005wf-8o for qemu-devel@nongnu.org; Wed, 03 May 2017 20:53:55 -0400 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]:35418) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d651k-0005wO-3c for qemu-devel@nongnu.org; Wed, 03 May 2017 20:53:52 -0400 Received: by mail-pf0-x244.google.com with SMTP id o68so716235pfj.2 for ; Wed, 03 May 2017 17:53:51 -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=9mCr71zRIanCxE320hbzHVdcvw954RnaCnMU5tfyVf8=; b=uXFaWGE18qltRrk5JWjArvjcYDMnzTUJX6LhvAFEfu3W/FACAnql9T18u+rynQyhLT eJDO7zyAMN11+xFw8t0jT3at0Y3oiFIW8ZAQaaiVIW9JxbMyO38XkVqCsosGHDO46Kqo 0wukTzI7TVltJ+ALmapZGCF9mRoB2lmQDZDyBQRvhVahsTo/MTWNOeVvT6cfu6tUvgR/ vtjcAi+ToGgOPMfin8z9fEbgSMRG13mR1r/9RlHB2syTDPwqr9coJrvKQqe7eZCO+fh5 zSceTZk8Okz2hc+rk4lifT4iCrcC9BUAHkHyou5EuhM1sqr2Wv0z0SLQMVOPIiKD7dVA t7qw== 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=9mCr71zRIanCxE320hbzHVdcvw954RnaCnMU5tfyVf8=; b=DQwSheLfXZd4uEQVxTFuMBghHHg4/Gf041HWtAnfyQRvjRkYviNuAQEMmUzb5JU2hQ XsS3ENHi9MeVfWYtpQUF6eH6yqM32e43ePs3ZF+6xNj2L0Ro7VtNckXUHiJOofwLMKP7 bN1YzPPvdl/+c/ioKGZJ8c5QnxTfnDvG9MWxG1V/L4jPG4Z1nyuBhr7FHE6+eG9nH5A1 Z8Y17sGwC58LO2CS6WDBZ1thi7h/fCOBbbAYwmUVPhnttAGU5PQcMATBF1fAIFH2PmNi s6J7T+38pq9Py1RgfgPewzC8jUwQWp0dEhbPPxs02IyfTvPdrqVyNIBdoK/bCT/BbUAk ndQw== X-Gm-Message-State: AN3rC/5VDyD/gcihPDrJIrCt/k7rh1RJfsqUf7kL4zwTPTULrRkYzc5I r6ni3xY2h077Hw== X-Received: by 10.84.198.3 with SMTP id o3mr51952785pld.45.1493859231251; Wed, 03 May 2017 17:53:51 -0700 (PDT) Received: from localhost (z209.124-44-183.ppp.wakwak.ne.jp. [124.44.183.209]) by smtp.gmail.com with ESMTPSA id r18sm495219pfk.109.2017.05.03.17.53.50 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 03 May 2017 17:53:50 -0700 (PDT) From: Stafford Horne To: QEMU Development Date: Thu, 4 May 2017 09:53:19 +0900 Message-Id: <461a4b944f7e036b2f6bd1fce83ad4fe09e5e2bc.1493858877.git.shorne@gmail.com> 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:400e:c00::244 Subject: [Qemu-devel] [PULL v2 04/11] 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: Stefan Hajnoczi , Stafford Horne 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 | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/target/openrisc/mmu.c b/target/openrisc/mmu.c index 56b11d3..ce2a29d 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,28 @@ 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)