From patchwork Tue Nov 7 03:02:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 741809 Delivered-To: patch@linaro.org Received: by 2002:adf:fd90:0:b0:32d:baff:b0ca with SMTP id d16csp1420676wrr; Mon, 6 Nov 2023 19:10:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IHNau6JmhlZN9kiUOg0oQDmFs0cab6BQKQ7oYrjAd/El3xdS56DfPOUSZIWXkbYU3hE2t4Z X-Received: by 2002:a05:6214:5005:b0:658:65ed:7e8 with SMTP id jo5-20020a056214500500b0065865ed07e8mr41183878qvb.57.1699326624937; Mon, 06 Nov 2023 19:10:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699326624; cv=none; d=google.com; s=arc-20160816; b=VlEJfTNJJnjxWDHdr4yiz0zttcSotEYkC1gBi5xmj8bMsAz40avUjm0fuy3Kxjo2hz lzs2Kr65jwKzaJhr41FyDOKLcmENGa8jt8geOH8Qco7ghA0AseBzGh62TuI74qiB0qeP jDuFOVk/KisLgSKAkaWxXvkIibGWBLuT1c7a7Uz+DmEzyzwjPc/d7dsE78+L8CqfvZr0 AqP2+C8PZigz5SerqGAg3Aw5wduMveX0HqHcXxFqGrPehlmAUVMVoTNJbXOJ0BiFzjvi DXw54O7SCdlBZ+oijGnFK77kUGSTy+AiHk4nhzOZyVN5Q3+y0ae51rW5J/HmGhKqwaPT dzgQ== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=Ez2Z78a8l3Rct3xuqmIfMNHaaKAnGMRqCCq6D0MIJeY=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=fLxAa/Ex1lX/Q1nMihitRNOb1B30HSku4SPtQd1wV8ctri4DObMmAT4Gy7jTMhALyj f0pDM8/Qdu84zHf88dO9pFwzTvY1qT1mADXm0NUy0Ggabwst/snDuBL8l7fRLSljymUP Il+Hx17PQhTgFUE/GMf1JhRveh3Tvd5IejZKmRo2YuisXpoMQGG1DtuReHxXHu3Kg5qN tzyP3gSkZnIML5w1Y7K7g0J7ccq2KwuIHlCn22+RMTiQI1M3MS3Zs7Q18zFFlA925xUC 66TDo5dPh12O91ppfP4/Jhtuonddk4d4gGnf0nWZPqLaz6Ycd7tWVWJsq9JNL6Dsw3MH 5nzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gvj2zCXK; 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=pass (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 ea2-20020ad458a2000000b0065afec14ae3si6413124qvb.579.2023.11.06.19.10.24 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 06 Nov 2023 19:10:24 -0800 (PST) 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=pass header.i=@linaro.org header.s=google header.b=gvj2zCXK; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0CO4-0006Lh-NI; Mon, 06 Nov 2023 22:04:20 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0CNz-0006KD-Ld for qemu-devel@nongnu.org; Mon, 06 Nov 2023 22:04:16 -0500 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r0CNy-0000dL-0Q for qemu-devel@nongnu.org; Mon, 06 Nov 2023 22:04:15 -0500 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1cc2575dfc7so37447185ad.1 for ; Mon, 06 Nov 2023 19:04:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699326252; x=1699931052; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=Ez2Z78a8l3Rct3xuqmIfMNHaaKAnGMRqCCq6D0MIJeY=; b=gvj2zCXK1VmsMAK/XeXHANcDV5IIea7ZgL5rOnhwLfFVMUGy/sZNloNDAza3RqTFkJ KF4UBVcGD0TjKFuswNJj3jpSWwa2yL7dvIKvWAfWTJlk2X5DWF4ozDlq/gYWusi4ed8L dmwhiL+VYQanQwGLcclaQC1mw6DkfzSHSPAwyTrjqHk6s134BRJXHavmREhJxMY7ck3K ol6ULnl5ucd2BuehyQFF5NUDF436sD4mgITQSvo6lPsqZnZbB86JSfcrrQMlXqGNpGJG CNGB2xk1SyuckUfkWvKokxlk2w/TeU1YUyVLDS8o7CRmddwvTCbpPSPrsg8bkq5TO64v 5JbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699326252; x=1699931052; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Ez2Z78a8l3Rct3xuqmIfMNHaaKAnGMRqCCq6D0MIJeY=; b=LCZyJ/0f5APl1sqwKu29B6F3rttAb/zGUPe7p3uKSWCH+pyZhDYpphgRqHfZfC4y2a IbjXb8RpR8UowVfyNwKxAMmoFca0peIy1bWrCJiJS9NCORzkZ5VEhtdy6+X+2S6fj1Jy lAcOLne8MB3loiBGGpavTm8qBsWsWmZJKbRZxArbqNJNc9CP0JTzhGPT0qK3zgV5jeis YI3WtlBvyQCMVtfTvzlsRSe9DEWwRll28Uqlg+pL7LGFkwONNiOh0vSXbqufkLMUSWtd gEhDJVt3MHRfW+Lu0vadAJKgTJpnZAAOzmZnvRwEcXqENl55qa5aYDCWHR7eMvlOSmi7 gc5A== X-Gm-Message-State: AOJu0YyNLshrbhkoSfkG5xoOk1Ch1CDhkDfJQPsBmBTkleUy8npG6kse Ad9VAjo486odld7Jnb+RhT/O7SJYm9HXR6BiBB8= X-Received: by 2002:a17:902:bc42:b0:1ca:87e0:93e3 with SMTP id t2-20020a170902bc4200b001ca87e093e3mr26241664plz.7.1699326252642; Mon, 06 Nov 2023 19:04:12 -0800 (PST) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id u9-20020a17090282c900b001c72d5e16acsm6518012plz.57.2023.11.06.19.04.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 19:04:12 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 05/85] target/hppa: Split out hppa_flush_tlb_range Date: Mon, 6 Nov 2023 19:02:47 -0800 Message-Id: <20231107030407.8979-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231107030407.8979-1-richard.henderson@linaro.org> References: <20231107030407.8979-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62b; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-bounces+patch=linaro.org@nongnu.org Signed-off-by: Richard Henderson --- target/hppa/mem_helper.c | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/target/hppa/mem_helper.c b/target/hppa/mem_helper.c index 60cae646cc..828cceb29c 100644 --- a/target/hppa/mem_helper.c +++ b/target/hppa/mem_helper.c @@ -67,6 +67,25 @@ static void hppa_flush_tlb_ent(CPUHPPAState *env, HPPATLBEntry *ent, ent->itree.start = -1; } +static HPPATLBEntry *hppa_flush_tlb_range(CPUHPPAState *env, + vaddr va_b, vaddr va_e) +{ + HPPATLBEntry *empty = NULL; + + /* Zap any old entries covering ADDR; notice empty entries on the way. */ + for (int i = HPPA_BTLB_ENTRIES; i < ARRAY_SIZE(env->tlb); ++i) { + HPPATLBEntry *ent = &env->tlb[i]; + + if (!ent->entry_valid) { + empty = ent; + } else if (va_e >= ent->itree.start && va_b <= ent->itree.last) { + hppa_flush_tlb_ent(env, ent, false); + empty = ent; + } + } + return empty; +} + static HPPATLBEntry *hppa_alloc_tlb_ent(CPUHPPAState *env) { HPPATLBEntry *ent; @@ -284,21 +303,11 @@ bool hppa_cpu_tlb_fill(CPUState *cs, vaddr addr, int size, /* Insert (Insn/Data) TLB Address. Note this is PA 1.1 only. */ void HELPER(itlba)(CPUHPPAState *env, target_ulong addr, target_ureg reg) { - HPPATLBEntry *empty = NULL; - int i; + HPPATLBEntry *empty; /* Zap any old entries covering ADDR; notice empty entries on the way. */ - for (i = HPPA_BTLB_ENTRIES; i < ARRAY_SIZE(env->tlb); ++i) { - HPPATLBEntry *ent = &env->tlb[i]; - if (ent->itree.start <= addr && addr <= ent->itree.last) { - if (ent->entry_valid) { - hppa_flush_tlb_ent(env, ent, false); - } - if (!empty) { - empty = ent; - } - } - } + addr &= TARGET_PAGE_MASK; + empty = hppa_flush_tlb_range(env, addr, addr + TARGET_PAGE_SIZE - 1); /* If we didn't see an empty entry, evict one. */ if (empty == NULL) { @@ -306,8 +315,8 @@ void HELPER(itlba)(CPUHPPAState *env, target_ulong addr, target_ureg reg) } /* Note that empty->entry_valid == 0 already. */ - empty->itree.start = addr & TARGET_PAGE_MASK; - empty->itree.last = empty->itree.start + TARGET_PAGE_SIZE - 1; + empty->itree.start = addr; + empty->itree.last = addr + TARGET_PAGE_SIZE - 1; empty->pa = extract32(reg, 5, 20) << TARGET_PAGE_BITS; trace_hppa_tlb_itlba(env, empty, empty->itree.start, empty->itree.last, empty->pa);