From patchwork Sun May 27 14:13:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 137028 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1796473lji; Sun, 27 May 2018 07:30:41 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIKAMqNHdy2Vuc5NA4Pzdzdj0BFmBMF52FSPAFQsRtGm6pXBUKPhJy7jQFLvWET4ZTLuxAu X-Received: by 2002:a0c:f604:: with SMTP id r4-v6mr9059125qvm.138.1527431441262; Sun, 27 May 2018 07:30:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527431441; cv=none; d=google.com; s=arc-20160816; b=m5bWKUZUvC79TKs3zdf6aBfmoYY59PAZA7wl4Ynn03hmksOsl9T/TJ8Vy2j+aM/bgO ixcswZ++oyCrX3XeDB520h1pAsbzU2XuIk38/cInZDlsSRcCNGuL9GKjVxtjPEyV0fxR dhEpMrOoRHLlfs2yyHyECm5vrEk5oXeZcs2bdo5QwxTja16nctHH+AhRCmT8jTNYFxv3 RTBrcXPJSm0Cpb1uxOPkWoLeBIoB2Giyl1CRGgM8Q+unR+XjxXQk8YgKrh07TbGIuj5X G5xFLYwHLgmul51scWzOK0J2DvWd/+DRHyO24GVJBn1v7oUGTglTSYGLB7ENcK8YPu5p 3K1g== 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=v4CJ/+3Lq/AhnRzfAd+D5Kf34+Ue0qdakQgog/y5diw=; b=lQZfloi3M9CkdeYbpTBLFMwiFLXpJnmQaQPpIRnSpCM3R/N8kNemGE5kMYuAGmDzg0 e6kHltC0wFocAGBUZDzMemEo18xYYdigfETm0E1YgujlxKUZT+QKlVDKtZUwEhpkUgLY y90itYRmCtDy7+79XlrPJXMsdgY7JKMJDY2RPvX4/44LM3HIbFm+xVoHmjTDYxViZLKd SM4+enlrj7ychVtj0sTx6JeQ5dOo7GVXmocSBfrjfsAZtzlFVnUQ42siq+hE9Y/PKPne 3RcBRU6HEkNq2eQ37uXrUFW8/fhmiiHn4LkEHISzPPOk5egKUuUrSv4Ecq4neE/+450e eFiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=cN+Xh8Fd; 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 n11-v6si1208393qvk.24.2018.05.27.07.30.41 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 27 May 2018 07:30:41 -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=cN+Xh8Fd; 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]:52280 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fMwgy-0004GR-On for patch@linaro.org; Sun, 27 May 2018 10:30:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57807) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fMwQh-00009n-5E for qemu-devel@nongnu.org; Sun, 27 May 2018 10:13:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fMwQe-0004Qc-0v for qemu-devel@nongnu.org; Sun, 27 May 2018 10:13:51 -0400 Received: from mail-pl0-x22d.google.com ([2607:f8b0:400e:c01::22d]:38768) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fMwQd-0004QS-Rj for qemu-devel@nongnu.org; Sun, 27 May 2018 10:13:47 -0400 Received: by mail-pl0-x22d.google.com with SMTP id c11-v6so5733076plr.5 for ; Sun, 27 May 2018 07:13:47 -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=v4CJ/+3Lq/AhnRzfAd+D5Kf34+Ue0qdakQgog/y5diw=; b=cN+Xh8FdwsKF3lfW7NrDY7EX+/NMq57wzAHJAM2YL/dI5jtvhF1pIntQJk28NBUkhe hebkZCHDZaFdC+HeuAFyqF9W5gSn6ctTdORdzuRKWHy4hCs9hnhmF+i85W2z4NLrNNju 3vBZnIRJCBytgaTU/QXSaGyVVhSyTuIA/5H+c= 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=v4CJ/+3Lq/AhnRzfAd+D5Kf34+Ue0qdakQgog/y5diw=; b=mFcTeb3jm9RdmfFadSmKWJ88AsXl3YvtlnHcjs+pBzuHe1EBLaLsXs1ams5bdT0CZF 5pPA+cl1NH+iuJ+zU2TDYEzVyReY8in4XZQNUFJi7bPfJ4JktHbJCDU+K+Iz9i+xjbaC QxT1Wj3Kga+S2qOaAonleAw5B8OMi6EcVdAxN3PAjmTfvfmbVXhL1gkvZfbkLKKmFJoO AC9VNWcrieRPwEd7GLR7BseXX/O9R6ZNUONNrzUHCf0UbK85cFH9mpziZfC85ZXFkG5r iyqUKcZlu7vQum51YkNoCQUFid5LCH96ooN9/TwpcIF8q2yz/Rs2z0fDPkUTAzD5XHQi 2bQg== X-Gm-Message-State: ALKqPwdPD9QwBX9vnde/IWPHPHAauzN1A24ymrXqX/4tp+l4yRK3DtQk cXkEW5mgSyXpRfJuPSuRh8VHWGR+MSzrkA== X-Received: by 2002:a17:902:b189:: with SMTP id s9-v6mr10081233plr.352.1527430426545; Sun, 27 May 2018 07:13:46 -0700 (PDT) Received: from cloudburst.twiddle.net (50-233-235-3-static.hfc.comcastbusiness.net. [50.233.235.3]) by smtp.gmail.com with ESMTPSA id b89-v6sm66680075pfd.85.2018.05.27.07.13.45 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 27 May 2018 07:13:45 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 27 May 2018 09:13:16 -0500 Message-Id: <20180527141324.11937-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180527141324.11937-1-richard.henderson@linaro.org> References: <20180527141324.11937-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::22d Subject: [Qemu-devel] [PATCH 12/20] 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: Stafford Horne 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.0 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;