From patchwork Mon Mar 11 19:15:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Schnelle X-Patchwork-Id: 10848217 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8290F14DE for ; Mon, 11 Mar 2019 19:44:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6B77628E72 for ; Mon, 11 Mar 2019 19:44:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5C206290EF; Mon, 11 Mar 2019 19:44:19 +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=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0B1B428E72 for ; Mon, 11 Mar 2019 19:44:19 +0000 (UTC) Received: from localhost ([127.0.0.1]:39245 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3QqQ-0008QG-DO for patchwork-qemu-devel@patchwork.kernel.org; Mon, 11 Mar 2019 15:44:18 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34407) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3Qb1-0004Gr-MM for qemu-devel@nongnu.org; Mon, 11 Mar 2019 15:28:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h3QPI-0007W2-4E for qemu-devel@nongnu.org; Mon, 11 Mar 2019 15:16:17 -0400 Received: from smtp.duncanthrax.net ([2001:470:70c5:1111::170]:32790) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h3QPH-0007TP-L6 for qemu-devel@nongnu.org; Mon, 11 Mar 2019 15:16:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=duncanthrax.net; s=dkim; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=jda9+Xj972jJQ8j7frsw2IM2mNQIk4qUSDn0d2axkqM=; b=etJYKTPXhnrFc5iaaebzpWHUjW LogcyilxK8u6ewhHFcGbvBG4UQAfqZ4CVATByOoaZepLHLUHIHz56I2U41z1ZtP8kY3ggLOQWNDwh IfrvYXmThkJMXczIGx3O0h30hLyysk4Vgg2a4e6mYgdq7eDKunKitCZDp6t16csVD9Nk=; Received: from [134.3.47.207] (helo=t470p.stackframe.org) by smtp.eurescom.eu with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1h3QPD-0005b3-S9; Mon, 11 Mar 2019 20:16:11 +0100 From: Sven Schnelle To: Richard Henderson Date: Mon, 11 Mar 2019 20:15:53 +0100 Message-Id: <20190311191602.25796-3-svens@stackframe.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190311191602.25796-1-svens@stackframe.org> References: <20190311191602.25796-1-svens@stackframe.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:470:70c5:1111::170 Subject: [Qemu-devel] [PATCH 02/11] target/hppa: fix TLB handling for page 0 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: Sven Schnelle , qemu-devel@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Assume the following sequence: pitlbe r0(sr0,r0) iitlba r4,(sr0,r0) ldil L%3000000,r5 iitlbp r5,(sr0,r0) This will purge the whole TLB and add an entry for page 0. However the current TLB implementation in helper_iitlba() will store to the last empty TLB entry, while helper_iitlbp() will write to the first empty entry. That is because an empty entry will match address 0 in helper_iitlba() Signed-off-by: Sven Schnelle Reviewed-by: Richard Henderson --- target/hppa/mem_helper.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/target/hppa/mem_helper.c b/target/hppa/mem_helper.c index aecf3075f6..f30824f4e1 100644 --- a/target/hppa/mem_helper.c +++ b/target/hppa/mem_helper.c @@ -238,15 +238,17 @@ void HELPER(itlba)(CPUHPPAState *env, target_ulong addr, target_ureg reg) { hppa_tlb_entry *empty = NULL; int i; - /* Zap any old entries covering ADDR; notice empty entries on the way. */ for (i = 0; i < ARRAY_SIZE(env->tlb); ++i) { hppa_tlb_entry *ent = &env->tlb[i]; - if (!ent->entry_valid) { - empty = ent; - } else if (ent->va_b <= addr && addr <= ent->va_e) { - hppa_flush_tlb_ent(env, ent); - empty = ent; + if (ent->va_b <= addr && addr <= ent->va_e) { + if (ent->entry_valid) { + hppa_flush_tlb_ent(env, ent); + } + + if (!empty) { + empty = ent; + } } }