From patchwork Thu May 9 06:02:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 163674 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:142:0:0:0:0 with SMTP id j2csp548649ilr; Wed, 8 May 2019 23:13:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqwywWWwNwKpCzV2C0SU/hWTF3qhW6FgAu+ubrAW7gBr6l4lSPWR+/BnXYzTJx0aLpf4cI3e X-Received: by 2002:a5d:6ad2:: with SMTP id u18mr1319669wrw.199.1557382385760; Wed, 08 May 2019 23:13:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557382385; cv=none; d=google.com; s=arc-20160816; b=VDjaddSCLzguLeTf08T5fRXcWSts/shC6yGfDxvSxTbiNOnjbZwUn2MduH8LwaapjD oZ4EYWw/xp5McEYYxuEswzR3+YRSO02TkuMrvqKBx66VhFVsRXAthqWdrSNyrnkG5hL4 34ujIF9HS6uV/c7vL0Gb0F09dvI1gD2s4CxlWNiiEnfL7OEEHnOX1K+al7Jug0WTGf+0 9LEtt/0tvFktG0o1L8KGUN+47OOr1Un0yK5fax3koAFsL4S9XHvFv5T+r5pwYrQxgrJX Vtl/Oyqk4HwxOmDyYc3fvNK1q5rM9yVdVNYQ1mfVy9RFE+8woICuqguq1AWqLwmsQxhu 3klA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=vY/1YWeEiK60/Q+L95+DZT+hkMZr8zCGLmiutwycPpc=; b=yOSwoSqQxk02x+T0CqAHeR0cy33AZGt+l1l1/B4aeRkn+eF/BRG1fPt6DxhfFe5ZV9 cXlp7LbWEc7lSrNQcs8LV1mRNs2JhAORePH8ydtJ5IVeaznSgOphqM7oVtxbivnbLzJ/ 0BJaeQqVbIh2MHKqjCMvCB5fcThZVGUMl8STeAXHOFXf1vs2l+D7POmpdrbQBd1MOP/N t9DzdP0crSgYLn0DyW/rd3hAfg/BjJxxjgFzaJTbhbp2K2BcTd2b1ldvJ8st/RzqrwIH t3AP7jE/hzh4SMdnLrzqY3CkX+xPViK+LW5pDqQWrB6r1PDLlB3ZtMch8qmNJAbP+pI2 /Mqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=o+3m03ix; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id j17si936092wru.33.2019.05.08.23.13.05 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 08 May 2019 23:13:05 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=o+3m03ix; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:48706 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hOcIi-0006uZ-KH for patch@linaro.org; Thu, 09 May 2019 02:13:04 -0400 Received: from eggs.gnu.org ([209.51.188.92]:44885) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hOc92-00061i-Q6 for qemu-devel@nongnu.org; Thu, 09 May 2019 02:03:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hOc91-00077G-MH for qemu-devel@nongnu.org; Thu, 09 May 2019 02:03:04 -0400 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]:38102) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hOc91-00076p-GP for qemu-devel@nongnu.org; Thu, 09 May 2019 02:03:03 -0400 Received: by mail-pf1-x442.google.com with SMTP id 10so723256pfo.5 for ; Wed, 08 May 2019 23:03:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=vY/1YWeEiK60/Q+L95+DZT+hkMZr8zCGLmiutwycPpc=; b=o+3m03ixkbB8mIanAIrhVRs+VAyQr4NdM0g1yiyIBKgtXaS3AxZ4Viz2GRMIbD+lT/ wAP1yJj/YD0DB+M77jVPpbsRbwh7OMWBrfcQRDGGkCRC95uSzaf0kmnwSzKXxYa/+9IV UBotNJmhAYTl1ePWmlRA4bpVtzNDzbM8bLse640uo0TOI7evkhCnQUC45IBKfRV8FSRA ZCnvOn9Tq1uMrql5IkTwcLEQB8GKiCIQj0Nk0rI8NNgdVR8vNoLvWLiORLQTPtPV4G3B nNySL9aWvlfjSA8ZxMfh9jICI3YKWnI0uQ9LzEfC0Sn9RrWGVJztwTnIZ/VZz/FBDN0M 8lTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=vY/1YWeEiK60/Q+L95+DZT+hkMZr8zCGLmiutwycPpc=; b=qrrbaIkI9il1rmpgUINtF6PeiMTxVV2sIyQV5aQr3a6WspjjNtJGaGoZDPbVVM/uAh o7cvaZWQ2wx9PvepqZohS/fWw8WiUGVsrZn/gIUTYk57yXwjglcjLxQ0XK/HqtTnJ++B Hnc1zOwhTb6p0p1VOhqRonEDZli5yBsR2Pok2TzHROtHVZJqlrytA0pdt6CfuAWT2fhx BMHIXAmYnr/RRguXeYhEm2M7Z6WC7wM25r/1bg13e38GWhP81XtiQaxywkd2XJOm6+1I 4PraXQGMTAYng4g1qzTUiFrGd2H29NZ6rFEpwGR0ykuDovYlpGvzBMwZJjO87Ow9PeJc gN3Q== X-Gm-Message-State: APjAAAWbcnFU0s9CI9MT5utdeb4KAhiP1Kj9a+8gfMtZUC/AWF7QnJ5Q dEZDzw1s34yJFJrzfhFDQpb1wslgmr8= X-Received: by 2002:a62:56d9:: with SMTP id h86mr2635124pfj.195.1557381782299; Wed, 08 May 2019 23:03:02 -0700 (PDT) Received: from localhost.localdomain (97-113-27-95.tukw.qwest.net. [97.113.27.95]) by smtp.gmail.com with ESMTPSA id n7sm1496109pff.45.2019.05.08.23.03.00 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 May 2019 23:03:01 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 8 May 2019 23:02:30 -0700 Message-Id: <20190509060246.4031-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190509060246.4031-1-richard.henderson@linaro.org> References: <20190509060246.4031-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::442 Subject: [Qemu-devel] [PATCH v2 11/27] target/mips: Tidy control flow in mips_cpu_handle_mmu_fault 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Since the only non-negative TLBRET_* value is TLBRET_MATCH, the subsequent test for ret < 0 is useless. Use early return to allow subsequent blocks to be unindented. Signed-off-by: Richard Henderson --- target/mips/helper.c | 54 ++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 30 deletions(-) -- 2.17.1 Reviewed-by: Philippe Mathieu-Daudé diff --git a/target/mips/helper.c b/target/mips/helper.c index cc7be7703a..86e622efb8 100644 --- a/target/mips/helper.c +++ b/target/mips/helper.c @@ -915,41 +915,35 @@ int mips_cpu_handle_mmu_fault(CPUState *cs, vaddr address, int size, int rw, tlb_set_page(cs, address & TARGET_PAGE_MASK, physical & TARGET_PAGE_MASK, prot | PAGE_EXEC, mmu_idx, TARGET_PAGE_SIZE); - ret = 0; - } else if (ret < 0) -#endif - { -#if !defined(CONFIG_USER_ONLY) + return 0; + } #if !defined(TARGET_MIPS64) - if ((ret == TLBRET_NOMATCH) && (env->tlb->nb_tlb > 1)) { - /* - * Memory reads during hardware page table walking are performed - * as if they were kernel-mode load instructions. - */ - int mode = (env->hflags & MIPS_HFLAG_KSU); - bool ret_walker; - env->hflags &= ~MIPS_HFLAG_KSU; - ret_walker = page_table_walk_refill(env, address, rw, mmu_idx); - env->hflags |= mode; - if (ret_walker) { - ret = get_physical_address(env, &physical, &prot, - address, rw, access_type, mmu_idx); - if (ret == TLBRET_MATCH) { - tlb_set_page(cs, address & TARGET_PAGE_MASK, - physical & TARGET_PAGE_MASK, prot | PAGE_EXEC, - mmu_idx, TARGET_PAGE_SIZE); - ret = 0; - return ret; - } + if ((ret == TLBRET_NOMATCH) && (env->tlb->nb_tlb > 1)) { + /* + * Memory reads during hardware page table walking are performed + * as if they were kernel-mode load instructions. + */ + int mode = (env->hflags & MIPS_HFLAG_KSU); + bool ret_walker; + env->hflags &= ~MIPS_HFLAG_KSU; + ret_walker = page_table_walk_refill(env, address, rw, mmu_idx); + env->hflags |= mode; + if (ret_walker) { + ret = get_physical_address(env, &physical, &prot, + address, rw, access_type, mmu_idx); + if (ret == TLBRET_MATCH) { + tlb_set_page(cs, address & TARGET_PAGE_MASK, + physical & TARGET_PAGE_MASK, prot | PAGE_EXEC, + mmu_idx, TARGET_PAGE_SIZE); + return 0; } } -#endif -#endif - raise_mmu_exception(env, address, rw, ret); - ret = 1; } +#endif +#endif - return ret; + raise_mmu_exception(env, address, rw, ret); + return 1; } #if !defined(CONFIG_USER_ONLY)