From patchwork Mon Jul 3 06:19:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suraj Jitindar Singh X-Patchwork-Id: 9821981 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 2E09C60246 for ; Mon, 3 Jul 2017 06:21:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2258C2810E for ; Mon, 3 Jul 2017 06:21:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 16F9528505; Mon, 3 Jul 2017 06:21:45 +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 988162810E for ; Mon, 3 Jul 2017 06:21:44 +0000 (UTC) Received: from localhost ([::1]:60526 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dRujv-0008VF-H2 for patchwork-qemu-devel@patchwork.kernel.org; Mon, 03 Jul 2017 02:21:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59714) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dRuiM-00088v-MB for qemu-devel@nongnu.org; Mon, 03 Jul 2017 02:20:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dRuiL-0001K6-NF for qemu-devel@nongnu.org; Mon, 03 Jul 2017 02:20:06 -0400 Received: from mail-pf0-x241.google.com ([2607:f8b0:400e:c00::241]:36819) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dRuiI-0001HG-As; Mon, 03 Jul 2017 02:20:02 -0400 Received: by mail-pf0-x241.google.com with SMTP id z6so24683854pfk.3; Sun, 02 Jul 2017 23:20:02 -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; bh=p/0tO4njJ1h0Ue1UPRHURUqXkPEmwcaw9sTbFDgi/P0=; b=HsT+Nva1JA7aVrXPO+7uOLUo5yszFgpJ/LLv3ivG2umxcW/DqtZUUjFOl+N5/oZI+y dRRTM7G21cXHASF+RWo+Y6s7MugjbUAvwPYezOaTcXe1RQ/ym10gSoQcRbSLnq0tj/uz HeDbBFK76aZmpaRWdOIKmykHuspgJxNZ24xanH8mHrBQjWPlaQqWDkQnkxGiqCTTQEZZ OPgn7/AHxXyxTK0U4BL/QNpTKjYQ70b65z02uFu5sgoc+08ocEhPpFM1geN4tdpiudvO msrfhHMC3/+WOUsHaP4QRQeGElvwZiR4YXMXpH/+MoJ5jNNhHFoY3e5/6rYL+t4wqsHR ri2g== 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; bh=p/0tO4njJ1h0Ue1UPRHURUqXkPEmwcaw9sTbFDgi/P0=; b=Pyirw/UO0llMYI+YcRggthku/gxAsIi293O2ayikkWYzC4r+cchazumOlSPN2actev 6IC9tiurYf5NFPtM8uHGroScXkjLjX6pQ4Vdv3OEIou4fRlsLBMCVwymKO0LVNU+yzkm 0SY1g0BmkPldimr/XSqPHYw2Tp2umdLu9lSDeNOCiB921ammcmd0bXG8iw2gS15qffc8 OXkoeiZ/z8L9li73tt4jf9b7jsXYcBD1fwXVDXbyPyyWIGnE3/sUe/1CLJKWt0L4ZcYj 7zcRAx8n/alVnsDQ1ahzkoi/DfFtlF590KAE2Yuub4HePp70Jvtm3Ez2Q+K2SnUm1N3Q NzxQ== X-Gm-Message-State: AIVw111XMEgg8l8TRDGDpey+Cn6KBzkLumQCKU43gteKcxe9QVvochBz M4DfjFGuwej4XQDQ X-Received: by 10.84.131.74 with SMTP id 68mr8768884pld.8.1499062801282; Sun, 02 Jul 2017 23:20:01 -0700 (PDT) Received: from surajjs1.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id k18sm27313106pgf.5.2017.07.02.23.19.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 02 Jul 2017 23:20:00 -0700 (PDT) From: Suraj Jitindar Singh To: qemu-ppc@nongnu.org Date: Mon, 3 Jul 2017 16:19:46 +1000 Message-Id: <20170703061948.18220-2-sjitindarsingh@gmail.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170703061948.18220-1-sjitindarsingh@gmail.com> References: <20170703061948.18220-1-sjitindarsingh@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::241 Subject: [Qemu-devel] [Qemu-PPC] [PATCH 1/3] target/ppc: Refactor tcg radix mmu code 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: qemu-devel@nongnu.org, bsingharora@gmail.com, agraf@suse.de, Suraj Jitindar Singh , david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The mmu-radix64.c file implements functions to enable the radix mmu emulation in tcg mode. There is a function ppc_radix64_walk_tree() which performs the radix tree walk and also implicitly checks the pte protection. Move the protection checking of the pte from the ppc_radix64_walk_tree() function into the caller. This means the ppc_radix64_walk_tree() function can be used without protection checking which is useful for debugging. ppc_radix64_walk_tree() no longer needs to take the rwx and prot variables. Signed-off-by: Suraj Jitindar Singh --- target/ppc/mmu-radix64.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/target/ppc/mmu-radix64.c b/target/ppc/mmu-radix64.c index 69fde65..1a650fd 100644 --- a/target/ppc/mmu-radix64.c +++ b/target/ppc/mmu-radix64.c @@ -147,11 +147,10 @@ static void ppc_radix64_set_rc(PowerPCCPU *cpu, int rwx, uint64_t pte, } } -static uint64_t ppc_radix64_walk_tree(PowerPCCPU *cpu, int rwx, vaddr eaddr, +static uint64_t ppc_radix64_walk_tree(PowerPCCPU *cpu, vaddr eaddr, uint64_t base_addr, uint64_t nls, hwaddr *raddr, int *psize, - int *fault_cause, int *prot, - hwaddr *pte_addr) + int *fault_cause, hwaddr *pte_addr) { CPUState *cs = CPU(cpu); uint64_t index, pde; @@ -177,10 +176,6 @@ static uint64_t ppc_radix64_walk_tree(PowerPCCPU *cpu, int rwx, vaddr eaddr, uint64_t rpn = pde & R_PTE_RPN; uint64_t mask = (1UL << *psize) - 1; - if (ppc_radix64_check_prot(cpu, rwx, pde, fault_cause, prot)) { - return 0; /* Protection Denied Access */ - } - /* Or high bits of rpn and low bits to ea to form whole real addr */ *raddr = (rpn & ~mask) | (eaddr & mask); *pte_addr = base_addr + (index * sizeof(pde)); @@ -188,9 +183,8 @@ static uint64_t ppc_radix64_walk_tree(PowerPCCPU *cpu, int rwx, vaddr eaddr, } /* Next Level of Radix Tree */ - return ppc_radix64_walk_tree(cpu, rwx, eaddr, pde & R_PDE_NLB, - pde & R_PDE_NLS, raddr, psize, - fault_cause, prot, pte_addr); + return ppc_radix64_walk_tree(cpu, eaddr, pde & R_PDE_NLB, pde & R_PDE_NLS, + raddr, psize, fault_cause, pte_addr); } int ppc_radix64_handle_mmu_fault(PowerPCCPU *cpu, vaddr eaddr, int rwx, @@ -241,11 +235,11 @@ int ppc_radix64_handle_mmu_fault(PowerPCCPU *cpu, vaddr eaddr, int rwx, /* Walk Radix Tree from Process Table Entry to Convert EA to RA */ page_size = PRTBE_R_GET_RTS(prtbe0); - pte = ppc_radix64_walk_tree(cpu, rwx, eaddr & R_EADDR_MASK, + pte = ppc_radix64_walk_tree(cpu, eaddr & R_EADDR_MASK, prtbe0 & PRTBE_R_RPDB, prtbe0 & PRTBE_R_RPDS, - &raddr, &page_size, &fault_cause, &prot, - &pte_addr); - if (!pte) { + &raddr, &page_size, &fault_cause, &pte_addr); + if (!pte || ppc_radix64_check_prot(cpu, rwx, pte, &fault_cause, &prot)) { + /* Couldn't get pte or access denied due to protection */ ppc_radix64_raise_si(cpu, rwx, eaddr, fault_cause); return 1; }