From nobody Wed Nov 27 20:47:29 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1697666004; cv=none; d=zohomail.com; s=zohoarc; b=kNLAhXxcG0OUVo3bvZHvzjzvMQIvHZNmXrIUxN/vi+Y/+j7n4Ho7ehYrzZy/UcpalOrrtSJQ6oCFFkMsOz046g30WtEMzMAPlfTZ43aAQLgiXKkb/AdpgiXlf5UxAOWwsqnwHvY8GsclqREtdKXjgYJw70NiGIEHJ4XiBP5ADB8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697666004; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=4w9TuqB+Wh/IgMQszmtMNOuKxNZ/aMG7k6ZFrv3n6zg=; b=ZGLGtANhRnGUZCzFthv7Dy3hcp6Y6PKslJrKhn43o8ihsfTBn4JCEB7rJzOkW6hWrTz75JQOBWQv+/2taAIvq/iOt5fcIAWbql0EWa41Cb1juqlRYEDpR+MYfLe5sAtIP1vEuZAYu/LYVl84KDvoK8lshg0PgOheSlLXcc4TQrI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1697666004122617.6894371765393; Wed, 18 Oct 2023 14:53:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qtESQ-000196-Fz; Wed, 18 Oct 2023 17:52:05 -0400 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 1qtESF-00016t-54 for qemu-devel@nongnu.org; Wed, 18 Oct 2023 17:51:51 -0400 Received: from mail-oo1-xc2e.google.com ([2607:f8b0:4864:20::c2e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qtESC-0004Oq-Lp for qemu-devel@nongnu.org; Wed, 18 Oct 2023 17:51:50 -0400 Received: by mail-oo1-xc2e.google.com with SMTP id 006d021491bc7-57be3d8e738so4124982eaf.1 for ; Wed, 18 Oct 2023 14:51:48 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id w17-20020a63f511000000b005b61a024ec7sm2176380pgh.74.2023.10.18.14.51.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 14:51:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697665907; x=1698270707; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4w9TuqB+Wh/IgMQszmtMNOuKxNZ/aMG7k6ZFrv3n6zg=; b=f1fPYWVYztKEg0hCwjFVvX5Yspy4GcWq+q+jPstbdfPN0Povgw1etSBhXj6F3xm9W0 /zMysTA2j8BRh9WMsxIX/U95/48nBRUY6zgC5FCuK3Fys8wUlj4zN/+6RIwid9etY3+z yVfm53FiDRnaOF+Eia1Y2n0VIe9r3YEZhqH7eGqACGyPinJVPC6MvcV0VCCgvFaYMhEf Xkuhuv2WPz9SJ+ELUtFDCDD7/CRGApyK7TWEJsNpf/1SglCphG7UUV7Z9MHKwjYW7art rGRE7TYhmFEGKFXajHWnHuonsKFovBcQfCYxJ6rXpTmKP0R/KIXqwMF2U5aNdQF4N4gO 6DGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697665907; x=1698270707; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4w9TuqB+Wh/IgMQszmtMNOuKxNZ/aMG7k6ZFrv3n6zg=; b=bZ+545h6MMvk+5/adbfPGJ8jBPVsJuYSP1rxKcZmCuOnKc45OxTde6Xb9gr2J0aiaM ySm2TFILTxZjKcrgUkK9I/AiTuje7fS7F+XTDN/oqns2FI4VdHRxoatoKLg9grOIKJ/3 LQRKmyJ6kOJS3k06ZOdCaCkqgRy3xkQBTxPs0K/ZsH5ErWju4rlYBfwLMxw+W/HBDFwg VeJEr3pwhsSYcCtzFCtHyx1taETzGWu3vxxL71bnbfiooRtePUYKB40tTHZqNRgVnle4 5Ren2zEW7q5rHsQcF5TmIvRJ0TDSjEpaDZano0ukOf5UGb/UNhmaxaZbaP4Sk9zC1Szb Kw/g== X-Gm-Message-State: AOJu0YyCTGQwggZvYtmBoOqUL67CIx9kFbyXkmuFGZsjybeBMIVFQAuy 7lWj4DM3rNyvpGVF9EC8jdko22obAHx7QjpFg5o= X-Google-Smtp-Source: AGHT+IG6etGpjL+sjmEnIMrCxBC4n0MaKCbL5hTWGjxuhouHDEXC1TYejWAe1HvSV7PxPH2edZBmwg== X-Received: by 2002:a05:6358:c683:b0:141:8c:75ad with SMTP id fe3-20020a056358c68300b00141008c75admr262733rwb.28.1697665907467; Wed, 18 Oct 2023 14:51:47 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: deller@gmx.de Subject: [PATCH 13/61] target/hppa: Make HPPA_BTLB_ENTRIES variable Date: Wed, 18 Oct 2023 14:50:47 -0700 Message-Id: <20231018215135.1561375-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231018215135.1561375-1-richard.henderson@linaro.org> References: <20231018215135.1561375-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::c2e; envelope-from=richard.henderson@linaro.org; helo=mail-oo1-xc2e.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 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1697666004393100002 Content-Type: text/plain; charset="utf-8" Depend on !HPPACPU.is_pa20. Signed-off-by: Richard Henderson --- target/hppa/cpu.h | 16 ++++++++-------- hw/hppa/machine.c | 6 +----- target/hppa/cpu.c | 3 +++ target/hppa/mem_helper.c | 41 ++++++++++++++++++++++------------------ 4 files changed, 35 insertions(+), 31 deletions(-) diff --git a/target/hppa/cpu.h b/target/hppa/cpu.h index 743fc90e14..22690e351d 100644 --- a/target/hppa/cpu.h +++ b/target/hppa/cpu.h @@ -210,15 +210,15 @@ typedef struct CPUArchState { target_ureg cr_back[2]; /* back of cr17/cr18 */ target_ureg shadow[7]; /* shadow registers */ =20 - /* ??? The number of entries isn't specified by the architecture. */ -#ifdef TARGET_HPPA64 -#define HPPA_BTLB_FIXED 0 /* BTLBs are not supported in 64-b= it machines */ -#else -#define HPPA_BTLB_FIXED 16 -#endif -#define HPPA_BTLB_VARIABLE 0 + /* + * ??? The number of entries isn't specified by the architecture. + * BTLBs are not supported in 64-bit machines. + */ +#define PA10_BTLB_FIXED 16 +#define PA10_BTLB_VARIABLE 0 +#define HPPA_BTLB_ENTRIES(E) (env_archcpu(E)->is_pa20 ? 0 \ + : PA10_BTLB_FIXED + PA10_BTLB_VARIABLE) #define HPPA_TLB_ENTRIES 256 -#define HPPA_BTLB_ENTRIES (HPPA_BTLB_FIXED + HPPA_BTLB_VARIABLE) =20 /* ??? Implement a unified itlb/dtlb for the moment. */ /* ??? We should use a more intelligent data structure. */ diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c index cf28cb9586..07f8ebeb6a 100644 --- a/hw/hppa/machine.c +++ b/hw/hppa/machine.c @@ -133,7 +133,7 @@ static FWCfgState *create_fw_cfg(MachineState *ms) fw_cfg_add_file(fw_cfg, "/etc/firmware-min-version", g_memdup(&val, sizeof(val)), sizeof(val)); =20 - val =3D cpu_to_le64(HPPA_TLB_ENTRIES - HPPA_BTLB_ENTRIES); + val =3D cpu_to_le64(HPPA_TLB_ENTRIES - HPPA_BTLB_ENTRIES(&cpu[0]->env)= ); fw_cfg_add_file(fw_cfg, "/etc/cpu/tlb_entries", g_memdup(&val, sizeof(val)), sizeof(val)); =20 @@ -429,10 +429,6 @@ static void hppa_machine_reset(MachineState *ms, Shutd= ownCause reason) =20 cs->exception_index =3D -1; cs->halted =3D 0; - - /* clear any existing TLB and BTLB entries */ - memset(cpu[i]->env.tlb, 0, sizeof(cpu[i]->env.tlb)); - cpu[i]->env.tlb_last =3D HPPA_BTLB_ENTRIES; } =20 /* already initialized by machine_hppa_init()? */ diff --git a/target/hppa/cpu.c b/target/hppa/cpu.c index ed5b6afd10..41abdb04d0 100644 --- a/target/hppa/cpu.c +++ b/target/hppa/cpu.c @@ -139,6 +139,9 @@ static void hppa_cpu_realizefn(DeviceState *dev, Error = **errp) HPPACPU *cpu =3D HPPA_CPU(cs); cpu->alarm_timer =3D timer_new_ns(QEMU_CLOCK_VIRTUAL, hppa_cpu_alarm_timer, cpu); + + memset(cpu->env.tlb, 0, sizeof(cpu->env.tlb)); + cpu->env.tlb_last =3D HPPA_BTLB_ENTRIES(&cpu->env); } #endif } diff --git a/target/hppa/mem_helper.c b/target/hppa/mem_helper.c index 350485f619..b2a75f6408 100644 --- a/target/hppa/mem_helper.c +++ b/target/hppa/mem_helper.c @@ -57,7 +57,7 @@ static void hppa_flush_tlb_ent(CPUHPPAState *env, hppa_tl= b_entry *ent, HPPA_MMU_FLUSH_MASK, TARGET_LONG_BITS); =20 /* never clear BTLBs, unless forced to do so. */ - if (ent < &env->tlb[HPPA_BTLB_ENTRIES] && !force_flush_btlb) { + if (ent < &env->tlb[HPPA_BTLB_ENTRIES(env)] && !force_flush_btlb) { return; } =20 @@ -68,11 +68,11 @@ static void hppa_flush_tlb_ent(CPUHPPAState *env, hppa_= tlb_entry *ent, static hppa_tlb_entry *hppa_alloc_tlb_ent(CPUHPPAState *env) { hppa_tlb_entry *ent; - uint32_t i; + uint32_t i, btlb_entries =3D HPPA_BTLB_ENTRIES(env); =20 - if (env->tlb_last < HPPA_BTLB_ENTRIES || env->tlb_last >=3D ARRAY_SIZE= (env->tlb)) { - i =3D HPPA_BTLB_ENTRIES; - env->tlb_last =3D HPPA_BTLB_ENTRIES + 1; + if (env->tlb_last < btlb_entries || env->tlb_last >=3D ARRAY_SIZE(env-= >tlb)) { + i =3D btlb_entries; + env->tlb_last =3D btlb_entries + 1; } else { i =3D env->tlb_last; env->tlb_last++; @@ -279,7 +279,7 @@ void HELPER(itlba)(CPUHPPAState *env, target_ulong addr= , target_ureg reg) int i; =20 /* Zap any old entries covering ADDR; notice empty entries on the way.= */ - for (i =3D HPPA_BTLB_ENTRIES; i < ARRAY_SIZE(env->tlb); ++i) { + for (i =3D HPPA_BTLB_ENTRIES(env); i < ARRAY_SIZE(env->tlb); ++i) { hppa_tlb_entry *ent =3D &env->tlb[i]; if (ent->va_b <=3D addr && addr <=3D ent->va_e) { if (ent->entry_valid) { @@ -363,11 +363,13 @@ void HELPER(ptlb)(CPUHPPAState *env, target_ulong add= r) number of pages/entries (we choose all), and is local to the cpu. */ void HELPER(ptlbe)(CPUHPPAState *env) { + uint32_t btlb_entries =3D HPPA_BTLB_ENTRIES(env); + trace_hppa_tlb_ptlbe(env); qemu_log_mask(CPU_LOG_MMU, "FLUSH ALL TLB ENTRIES\n"); - memset(&env->tlb[HPPA_BTLB_ENTRIES], 0, - sizeof(env->tlb) - HPPA_BTLB_ENTRIES * sizeof(env->tlb[0])); - env->tlb_last =3D HPPA_BTLB_ENTRIES; + memset(&env->tlb[btlb_entries], 0, + sizeof(env->tlb) - btlb_entries * sizeof(env->tlb[0])); + env->tlb_last =3D btlb_entries; tlb_flush_by_mmuidx(env_cpu(env), HPPA_MMU_FLUSH_MASK); } =20 @@ -427,13 +429,16 @@ void HELPER(diag_btlb)(CPUHPPAState *env) hppa_tlb_entry *btlb; uint64_t virt_page; uint32_t *vaddr; + uint32_t btlb_entries; =20 -#ifdef TARGET_HPPA64 /* BTLBs are not supported on 64-bit CPUs */ - env->gr[28] =3D -1; /* nonexistent procedure */ - return; -#endif + if (env_archcpu(env)->is_pa20) { + env->gr[28] =3D -1; /* nonexistent procedure */ + return; + } + env->gr[28] =3D 0; /* PDC_OK */ + btlb_entries =3D HPPA_BTLB_ENTRIES(env); =20 switch (env->gr[25]) { case 0: @@ -446,8 +451,8 @@ void HELPER(diag_btlb)(CPUHPPAState *env) } else { vaddr[0] =3D cpu_to_be32(1); vaddr[1] =3D cpu_to_be32(16 * 1024); - vaddr[2] =3D cpu_to_be32(HPPA_BTLB_FIXED); - vaddr[3] =3D cpu_to_be32(HPPA_BTLB_VARIABLE); + vaddr[2] =3D cpu_to_be32(PA10_BTLB_FIXED); + vaddr[3] =3D cpu_to_be32(PA10_BTLB_VARIABLE); } break; case 1: @@ -464,7 +469,7 @@ void HELPER(diag_btlb)(CPUHPPAState *env) (long long) virt_page << TARGET_PAGE_BITS, (long long) (virt_page + len) << TARGET_PAGE_BITS, (long long) virt_page, phys_page, len, slot); - if (slot < HPPA_BTLB_ENTRIES) { + if (slot < btlb_entries) { btlb =3D &env->tlb[slot]; /* force flush of possibly existing BTLB entry */ hppa_flush_tlb_ent(env, btlb, true); @@ -484,7 +489,7 @@ void HELPER(diag_btlb)(CPUHPPAState *env) slot =3D env->gr[22]; qemu_log_mask(CPU_LOG_MMU, "PDC_BLOCK_TLB: PDC_BTLB_PURGE slot %d\= n", slot); - if (slot < HPPA_BTLB_ENTRIES) { + if (slot < btlb_entries) { btlb =3D &env->tlb[slot]; hppa_flush_tlb_ent(env, btlb, true); } else { @@ -494,7 +499,7 @@ void HELPER(diag_btlb)(CPUHPPAState *env) case 3: /* Purge all BTLB entries */ qemu_log_mask(CPU_LOG_MMU, "PDC_BLOCK_TLB: PDC_BTLB_PURGE_ALL\n"); - for (slot =3D 0; slot < HPPA_BTLB_ENTRIES; slot++) { + for (slot =3D 0; slot < btlb_entries; slot++) { btlb =3D &env->tlb[slot]; hppa_flush_tlb_ent(env, btlb, true); } --=20 2.34.1