From patchwork Mon Jun 18 18:40:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 139050 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp4284592lji; Mon, 18 Jun 2018 11:47:27 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJpPn+1DBr8kF6zQmPwR7LWwThmxaNu3Ih1Yfs0LRxnBx2mg2qhe38UaUJ+uJ6QDF+NNlGZ X-Received: by 2002:a37:9804:: with SMTP id a4-v6mr10911595qke.371.1529347647456; Mon, 18 Jun 2018 11:47:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529347647; cv=none; d=google.com; s=arc-20160816; b=mXT+9quepYAyfrIeRu20f5lBNBV+X8YoX75zZPF3ndNlMBzuqivJT31vDBra/7IXQq jQYe8+kT06+rONluf14B4wNyeE1E3cIw28QxCIvs4TrjYzyWNsNZlptmUlIomy0iTMt2 9nLbfExinw2DapOfGIqM8h7KVH6IIG0cLaVSmmKYpeC2Tgp5sH+PbbGySycVwSeedWE8 XI+OMEpvlfAelRJC7kcqZuRW8ntscxD2Pu583KD/C2qp+Kk8vyBj39Z0mvOPO193Aqso sx6V41Yvsh2RT8xOdnGHBQllOt8QPr38u/b9OJyFzskUn2E4KUguR5RYuGPIRzNLgZMH o06A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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:arc-authentication-results; bh=5z97SVwjEk4sNEX969oQIopbF5FDZsjnXfc9pzcx1EA=; b=LVb/Ygk6q0SpDmLjy0YE8wnCB8bfo/uCzSrycmxvAnL35Hi/ShZw3qQ3aoxCqdbiXA Vv1f9DCQ5eY+yJP3igG8Wm3KB2918n4lmc9wra4cU5vmSimBrDx/zxZSXozuK0N2Ur1A aWCfv4nyIojqAYpbhLEVfwWoBQkK/BvaLB6/rD/xrf8TjWMwfBh/1Osyyz43W4joCcZq 2/rS+QjwdA+dU1/9QUEsvJtVcdSLW6/5wSgGJL78M+kCOQVJKEWdvI0b4zKbfzvBERA8 SP9h/LPrnX4VT/oR0M8jaTprKfewkbWWS1pAax8nPg5qrBfG6IuhSfAdGOqOokAbmp34 /EGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Vr311plR; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id m41-v6si3066636qvc.214.2018.06.18.11.47.27 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 18 Jun 2018 11:47:27 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Vr311plR; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:36497 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUzBW-0000Aq-Sh for patch@linaro.org; Mon, 18 Jun 2018 14:47:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57377) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUz5W-0003VQ-FJ for qemu-devel@nongnu.org; Mon, 18 Jun 2018 14:41:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fUz5V-0004qI-EN for qemu-devel@nongnu.org; Mon, 18 Jun 2018 14:41:14 -0400 Received: from mail-pl0-x233.google.com ([2607:f8b0:400e:c01::233]:35869) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fUz5V-0004pW-8t for qemu-devel@nongnu.org; Mon, 18 Jun 2018 14:41:13 -0400 Received: by mail-pl0-x233.google.com with SMTP id a7-v6so9500246plp.3 for ; Mon, 18 Jun 2018 11:41:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=5z97SVwjEk4sNEX969oQIopbF5FDZsjnXfc9pzcx1EA=; b=Vr311plRX3TPKnnVInCjrFVf38k55izZuRJGEMcpiUwohS30IMoZiErXwym1xaZcRm r0jFdao+3f2n8FyzSBVXnRVbdT2bdb/uMS1CuIQqokxStsx0lzS6KjN6MfIFN0ZqNEha +vk6GkuCqfH3Otz3Isbg+vCYaXdlCM6W1VjvU= 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=5z97SVwjEk4sNEX969oQIopbF5FDZsjnXfc9pzcx1EA=; b=Q6N8jQUV8/sO4sOUCYoK3MT1HB4qHJaYY1cK398fd9YcXKKCPfWVEgPqvR3E6WfjAM R6krVkMR0RKfEi8j+RSWXjM04ehVE6XKDyWjD65t4gfPq0Fh8I2U/FgBabhvKy1gRLc6 W/h4nHqXLLLPu8Vb90rlASPu7Q1kad2PHVVXh8oA3B1+qY05/0XtrL1OhVzpje7rFmQj jWUnydWUMePIUHS527pNIpngr1CaJv46DgR0lhZQgKS+fekKWfKUpPaIufO73ZinN3q9 myPpj+qs2/+AUTB8M7PWm9xvhCmYX77KVcFiTk87pbCE86tA/OTMNyfwrwzYe6D0S7aI bXkg== X-Gm-Message-State: APt69E3pTc+lP5Bz2v7g/MME6yJ7qV4MN0mfeM1E6Qr5QWj3RIxp+IVa cft4OW5caGqoB/16gHLTVeXoVhhd5M8= X-Received: by 2002:a17:902:70ca:: with SMTP id l10-v6mr2332822plt.174.1529347272034; Mon, 18 Jun 2018 11:41:12 -0700 (PDT) Received: from cloudburst.twiddle.net (mta-98-147-121-51.hawaii.rr.com. [98.147.121.51]) by smtp.gmail.com with ESMTPSA id i65-v6sm49457254pfd.17.2018.06.18.11.41.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 11:41:11 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 08:40:36 -1000 Message-Id: <20180618184046.6270-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180618184046.6270-1-richard.henderson@linaro.org> References: <20180618184046.6270-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::233 Subject: [Qemu-devel] [PATCH v2 12/22] target/openrisc: Fix tlb flushing in mtspr 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: shorne@gmail.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The previous code was confused, avoiding the flush of the old entry if the new entry is invalid. We need to flush the old page if the old entry is valid and the new page if the new entry is valid. This bug was masked by over-flushing elsewhere. Signed-off-by: Richard Henderson --- target/openrisc/sys_helper.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) -- 2.17.1 diff --git a/target/openrisc/sys_helper.c b/target/openrisc/sys_helper.c index 8ad7a7d898..e00aaa332e 100644 --- a/target/openrisc/sys_helper.c +++ b/target/openrisc/sys_helper.c @@ -32,6 +32,7 @@ void HELPER(mtspr)(CPUOpenRISCState *env, target_ulong spr, target_ulong rb) #ifndef CONFIG_USER_ONLY OpenRISCCPU *cpu = openrisc_env_get_cpu(env); CPUState *cs = CPU(cpu); + target_ulong mr; int idx; switch (spr) { @@ -84,12 +85,15 @@ void HELPER(mtspr)(CPUOpenRISCState *env, target_ulong spr, target_ulong rb) case TO_SPR(1, 512) ... TO_SPR(1, 512+DTLB_SIZE-1): /* DTLBW0MR 0-127 */ idx = spr - TO_SPR(1, 512); - if (!(rb & 1)) { - tlb_flush_page(cs, env->tlb.dtlb[idx].mr & TARGET_PAGE_MASK); + mr = env->tlb.dtlb[idx].mr; + if (mr & 1) { + tlb_flush_page(cs, mr & TARGET_PAGE_MASK); + } + if (rb & 1) { + tlb_flush_page(cs, rb & TARGET_PAGE_MASK); } env->tlb.dtlb[idx].mr = rb; break; - case TO_SPR(1, 640) ... TO_SPR(1, 640+DTLB_SIZE-1): /* DTLBW0TR 0-127 */ idx = spr - TO_SPR(1, 640); env->tlb.dtlb[idx].tr = rb; @@ -101,14 +105,18 @@ void HELPER(mtspr)(CPUOpenRISCState *env, target_ulong spr, target_ulong rb) case TO_SPR(1, 1280) ... TO_SPR(1, 1407): /* DTLBW3MR 0-127 */ case TO_SPR(1, 1408) ... TO_SPR(1, 1535): /* DTLBW3TR 0-127 */ break; + case TO_SPR(2, 512) ... TO_SPR(2, 512+ITLB_SIZE-1): /* ITLBW0MR 0-127 */ idx = spr - TO_SPR(2, 512); - if (!(rb & 1)) { - tlb_flush_page(cs, env->tlb.itlb[idx].mr & TARGET_PAGE_MASK); + mr = env->tlb.itlb[idx].mr; + if (mr & 1) { + tlb_flush_page(cs, mr & TARGET_PAGE_MASK); + } + if (rb & 1) { + tlb_flush_page(cs, rb & TARGET_PAGE_MASK); } env->tlb.itlb[idx].mr = rb; break; - case TO_SPR(2, 640) ... TO_SPR(2, 640+ITLB_SIZE-1): /* ITLBW0TR 0-127 */ idx = spr - TO_SPR(2, 640); env->tlb.itlb[idx].tr = rb; @@ -120,6 +128,7 @@ void HELPER(mtspr)(CPUOpenRISCState *env, target_ulong spr, target_ulong rb) case TO_SPR(2, 1280) ... TO_SPR(2, 1407): /* ITLBW3MR 0-127 */ case TO_SPR(2, 1408) ... TO_SPR(2, 1535): /* ITLBW3TR 0-127 */ break; + case TO_SPR(5, 1): /* MACLO */ env->mac = deposit64(env->mac, 0, 32, rb); break;