From nobody Wed Nov 27 21:26:10 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=1697666754; cv=none; d=zohomail.com; s=zohoarc; b=VWfaKOMz8FvaovepGlpPHMotuhYUf3g8fDsktb9H+025ZKwq1tHgcd4+QCTqvHyXvcLCiHcQQZQVTI0KUTi2A5D1lWRQ1sWUqd3/3zqiB7vJXQ+XJrtBfxFvaQe+9WKLgC9JZKxKxCbhCWOGwL7RuSu3t+MogG4GW7Zk3fmV2wE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697666754; 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=v5Wi3y3AXC6NylZkbJ54hdYGshwDCMU44E6eCyr9p3Q=; b=gd9NCeXwhbVJHVeMnFNJpm9MFM12ADCUHI56yFAB/clBv/tbzut3pv501755fJOSX53Q7nW0rPmgNoNQ2tTqTlCkCV1mQ15xuj65pn5k6Vjs7+WyXvwxLrJ1jZ1ev+d06ji3HYb7zyB0HNLscWVd9bidlnFrHKDVNhtKPTke33c= 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 1697666753999459.5604335893065; Wed, 18 Oct 2023 15:05:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qtEVd-00026n-4C; Wed, 18 Oct 2023 17:55:21 -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 1qtEVa-0001st-M1 for qemu-devel@nongnu.org; Wed, 18 Oct 2023 17:55:18 -0400 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 1qtEVX-00050h-Is for qemu-devel@nongnu.org; Wed, 18 Oct 2023 17:55:18 -0400 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1c9e95aa02dso1260895ad.0 for ; Wed, 18 Oct 2023 14:55:15 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id r15-20020aa7962f000000b006889348ba6esm3796263pfg.127.2023.10.18.14.55.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 14:55:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697666114; x=1698270914; 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=v5Wi3y3AXC6NylZkbJ54hdYGshwDCMU44E6eCyr9p3Q=; b=EwwSrtsTbxeo5JL11ZpqkHhbonFYBXv/Hgt0gHEfumb0zMCB+JOuPUSayDf6A2PHO1 TwLwR1XLYiJnzlLQya/uv2uDLsvlPtR3ffhcgbAtw8BzaBMBfFIPJkMkpaEVHJWkaHVa QuOOp09/2pWqHuScK/QAlGieftdCvW2mmhC7ccLTCHn2Lj3lUE9q2/cEOs6Ju/mPafMB k/rqTXmpXocW6kbrpWOFFm9VhVq5+itHk/w42nFFdOFjPZrVfDeWVYTYohorhtwPmRPQ +Vs1w3NaMBXeurMcUoNILQYjXDGAXCkUUbyCsIpeGeBRiiRGIVqBUfX/V2nbwwn/4/xo c8ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697666114; x=1698270914; 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=v5Wi3y3AXC6NylZkbJ54hdYGshwDCMU44E6eCyr9p3Q=; b=OYk1TgXtRtLo4Z4w9Hu5Xgv72MI5AOUKuAAVcQpFyhBQVfDvijrSRAg04k4+r8Ec6l A7JyiM5iRk7X5EBHC0ZI41HN11F+py7E/XVteSjBnHu4LoLTHlFC1IZZmq9kA8nkP9i+ HoqUa/XSuqSBGqSuymaptmp55/IsoiOwXUxJhAhI+GrjHvRsIGOiTKUePpE0uwKyd9CO UUsYWPyjQxs3LTOCnksfeKIHT7EENtZvxhhCrMZDetbDjzNnNlOcOxXMK21geQ/L9pvy nEIERyIRVSbdT4bkW9PRwckZYButMp25Iv01WyGhp/c3+F1EKgAnwdjEfiYLwwZ/IDTt TEJA== X-Gm-Message-State: AOJu0YwDlHkkUQU2Xmh//bG9A9bw7mZQrlxcEe9tvOWB6NO4uup7DFFR +L6ttViQTLWB3aAJQitNyBfhncBt+ROPy+/qpII= X-Google-Smtp-Source: AGHT+IFjPlhEbnXLZXS8wtPkA6G+2ffV+jMLAI91rtmc98n7baw9G/qXf4n1U76jDrM/0SNWoDIzRQ== X-Received: by 2002:a17:902:c404:b0:1c3:e2eb:f79d with SMTP id k4-20020a170902c40400b001c3e2ebf79dmr217593plk.8.1697666114241; Wed, 18 Oct 2023 14:55:14 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: deller@gmx.de Subject: [PATCH 45/61] target/hppa: Implement IDTLBT, IITLBT Date: Wed, 18 Oct 2023 14:51:19 -0700 Message-Id: <20231018215135.1561375-46-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::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 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: 1697666755755100003 Content-Type: text/plain; charset="utf-8" Rename the existing insert tlb helpers to emphasize that they are for pa1.1 cpus. Implement a combined i/d tlb for pa2.0. Still missing is the new 'P' tlb bit. Signed-off-by: Richard Henderson --- target/hppa/helper.h | 5 ++-- target/hppa/insns.decode | 4 +++ target/hppa/mem_helper.c | 63 +++++++++++++++++++++++++++++++++------- target/hppa/translate.c | 35 ++++++++++++++++++---- 4 files changed, 89 insertions(+), 18 deletions(-) diff --git a/target/hppa/helper.h b/target/hppa/helper.h index 9920d38ded..58b6754dbe 100644 --- a/target/hppa/helper.h +++ b/target/hppa/helper.h @@ -94,8 +94,9 @@ DEF_HELPER_FLAGS_2(write_interval_timer, TCG_CALL_NO_RWG,= void, env, tr) DEF_HELPER_FLAGS_2(write_eirr, TCG_CALL_NO_RWG, void, env, tr) DEF_HELPER_FLAGS_2(write_eiem, TCG_CALL_NO_RWG, void, env, tr) DEF_HELPER_FLAGS_2(swap_system_mask, TCG_CALL_NO_RWG, tr, env, tr) -DEF_HELPER_FLAGS_3(itlba, TCG_CALL_NO_RWG, void, env, tl, tr) -DEF_HELPER_FLAGS_3(itlbp, TCG_CALL_NO_RWG, void, env, tl, tr) +DEF_HELPER_FLAGS_3(itlba_pa11, TCG_CALL_NO_RWG, void, env, tl, tr) +DEF_HELPER_FLAGS_3(itlbp_pa11, TCG_CALL_NO_RWG, void, env, tl, tr) +DEF_HELPER_FLAGS_3(itlbt_pa20, TCG_CALL_NO_RWG, void, env, tr, tr) DEF_HELPER_FLAGS_2(ptlb, TCG_CALL_NO_RWG, void, env, tl) DEF_HELPER_FLAGS_1(ptlbe, TCG_CALL_NO_RWG, void, env) DEF_HELPER_FLAGS_2(lpa, TCG_CALL_NO_WG, tr, env, tl) diff --git a/target/hppa/insns.decode b/target/hppa/insns.decode index 9d8c6a1a16..db1b9f750f 100644 --- a/target/hppa/insns.decode +++ b/target/hppa/insns.decode @@ -152,6 +152,10 @@ ixtlbx 000001 b:5 r:5 ... 000000 addr:1 0 000= 00 \ # pcxl and pcxl2 Fast TLB Insert instructions ixtlbxf 000001 00000 r:5 00 0 data:1 01000 addr:1 0 00000 =20 +# pa2.0 tlb insert instructions +ixtlbt 000001 r2:5 r1:5 000 1100000 0 00000 # idtlbt +ixtlbt 000001 r2:5 r1:5 000 0100000 0 00000 # iitlbt + pxtlbx 000001 b:5 x:5 sp:2 0100100 local:1 m:1 ----- data=3D1 pxtlbx 000001 b:5 x:5 ... 000100 local:1 m:1 ----- \ sp=3D%assemble_sr3x data=3D0 diff --git a/target/hppa/mem_helper.c b/target/hppa/mem_helper.c index 169e878479..d6f46b18e9 100644 --- a/target/hppa/mem_helper.c +++ b/target/hppa/mem_helper.c @@ -312,7 +312,7 @@ bool hppa_cpu_tlb_fill(CPUState *cs, vaddr addr, int si= ze, } =20 /* Insert (Insn/Data) TLB Address. Note this is PA 1.1 only. */ -void HELPER(itlba)(CPUHPPAState *env, target_ulong addr, target_ureg reg) +void HELPER(itlba_pa11)(CPUHPPAState *env, target_ulong addr, target_ureg = reg) { hppa_tlb_entry *empty =3D NULL; int i; @@ -338,15 +338,12 @@ void HELPER(itlba)(CPUHPPAState *env, target_ulong ad= dr, target_ureg reg) /* Note that empty->entry_valid =3D=3D 0 already. */ empty->va_b =3D addr & TARGET_PAGE_MASK; empty->va_e =3D empty->va_b + TARGET_PAGE_SIZE - 1; - /* - * FIXME: This is wrong, as this is a pa1.1 function. - * But for the moment translate abs address for pa2.0. - */ - empty->pa =3D hppa_abs_to_phys(env, extract32(reg, 5, 20) << TARGET_PA= GE_BITS); + empty->pa =3D extract32(reg, 5, 20) << TARGET_PAGE_BITS; trace_hppa_tlb_itlba(env, empty, empty->va_b, empty->va_e, empty->pa); } =20 -static void set_access_bits(CPUHPPAState *env, hppa_tlb_entry *ent, target= _ureg reg) +static void set_access_bits_pa11(CPUHPPAState *env, hppa_tlb_entry *ent, + target_ureg reg) { ent->access_id =3D extract32(reg, 1, 18); ent->u =3D extract32(reg, 19, 1); @@ -362,7 +359,7 @@ static void set_access_bits(CPUHPPAState *env, hppa_tlb= _entry *ent, target_ureg } =20 /* Insert (Insn/Data) TLB Protection. Note this is PA 1.1 only. */ -void HELPER(itlbp)(CPUHPPAState *env, target_ulong addr, target_ureg reg) +void HELPER(itlbp_pa11)(CPUHPPAState *env, target_ulong addr, target_ureg = reg) { hppa_tlb_entry *ent =3D hppa_find_tlb(env, addr); =20 @@ -370,8 +367,54 @@ void HELPER(itlbp)(CPUHPPAState *env, target_ulong add= r, target_ureg reg) qemu_log_mask(LOG_GUEST_ERROR, "ITLBP not following ITLBA\n"); return; } + set_access_bits_pa11(env, ent, reg); +} =20 - set_access_bits(env, ent, reg); +void HELPER(itlbt_pa20)(CPUHPPAState *env, target_ureg r1, target_ureg r2) +{ + hppa_tlb_entry *ent, *empty =3D NULL; + vaddr va_b, va_e; + uint64_t page_size; + + va_b =3D deposit64(env->cr[CR_IIAOQ], 32, 32, env->cr[CR_IIASQ]); + va_b &=3D TARGET_PAGE_MASK; + page_size =3D TARGET_PAGE_SIZE << (2 * (r1 & 0xf)); + va_e =3D va_b + page_size - 1; + + for (int i =3D 0; i < ARRAY_SIZE(env->tlb); ++i) { + ent =3D &env->tlb[i]; + if (ent->entry_valid) { + if (ent->va_b <=3D va_e && va_b <=3D ent->va_e) { + hppa_flush_tlb_ent(env, ent, false); + empty =3D ent; + } + } else { + empty =3D ent; + } + } + + /* If we didn't see an empty entry, evict one. */ + ent =3D empty ? empty : hppa_alloc_tlb_ent(env); + + ent->va_b =3D va_b; + ent->va_e =3D va_e; + ent->pa =3D (r1 << 7) & TARGET_PAGE_MASK; + ent->t =3D extract64(r2, 61, 1); + ent->d =3D extract64(r2, 60, 1); + ent->b =3D extract64(r2, 59, 1); + ent->ar_type =3D extract64(r2, 56, 3); + ent->ar_pl1 =3D extract64(r2, 54, 2); + ent->ar_pl2 =3D extract64(r2, 52, 2); + ent->u =3D extract64(r2, 51, 1); + /* o =3D bit 50 */ + /* p =3D bit 49 */ + ent->access_id =3D extract64(r2, 1, 31); + ent->entry_valid =3D 1; + + trace_hppa_tlb_itlba(env, ent, ent->va_b, ent->va_e, ent->pa); + trace_hppa_tlb_itlbp(env, ent, ent->access_id, ent->u, + ent->ar_pl2, ent->ar_pl1, ent->ar_type, + ent->b, ent->d, ent->t); } =20 /* Purge (Insn/Data) TLB. This is explicitly page-based, and is @@ -520,7 +563,7 @@ void HELPER(diag_btlb)(CPUHPPAState *env) btlb->va_b =3D virt_page << TARGET_PAGE_BITS; btlb->va_e =3D btlb->va_b + len * TARGET_PAGE_SIZE - 1; btlb->pa =3D phys_page << TARGET_PAGE_BITS; - set_access_bits(env, btlb, env->gr[20]); + set_access_bits_pa11(env, btlb, env->gr[20]); btlb->t =3D 0; btlb->d =3D 1; } else { diff --git a/target/hppa/translate.c b/target/hppa/translate.c index 4a0ae5a772..44dcf310b6 100644 --- a/target/hppa/translate.c +++ b/target/hppa/translate.c @@ -2493,6 +2493,9 @@ static bool trans_probe(DisasContext *ctx, arg_probe = *a) =20 static bool trans_ixtlbx(DisasContext *ctx, arg_ixtlbx *a) { + if (ctx->is_pa20) { + return false; + } CHECK_MOST_PRIVILEGED(EXCP_PRIV_OPR); #ifndef CONFIG_USER_ONLY TCGv_tl addr; @@ -2503,9 +2506,9 @@ static bool trans_ixtlbx(DisasContext *ctx, arg_ixtlb= x *a) form_gva(ctx, &addr, &ofs, a->b, 0, 0, 0, a->sp, 0, false); reg =3D load_gpr(ctx, a->r); if (a->addr) { - gen_helper_itlba(tcg_env, addr, reg); + gen_helper_itlba_pa11(tcg_env, addr, reg); } else { - gen_helper_itlbp(tcg_env, addr, reg); + gen_helper_itlbp_pa11(tcg_env, addr, reg); } =20 /* Exit TB for TLB change if mmu is enabled. */ @@ -2551,6 +2554,9 @@ static bool trans_pxtlbx(DisasContext *ctx, arg_pxtlb= x *a) */ static bool trans_ixtlbxf(DisasContext *ctx, arg_ixtlbxf *a) { + if (ctx->is_pa20) { + return false; + } CHECK_MOST_PRIVILEGED(EXCP_PRIV_OPR); #ifndef CONFIG_USER_ONLY TCGv_tl addr, atl, stl; @@ -2562,8 +2568,6 @@ static bool trans_ixtlbxf(DisasContext *ctx, arg_ixtl= bxf *a) * FIXME: * if (not (pcxl or pcxl2)) * return gen_illegal(ctx); - * - * Note for future: these are 32-bit systems; no hppa64. */ =20 atl =3D tcg_temp_new_tl(); @@ -2581,9 +2585,9 @@ static bool trans_ixtlbxf(DisasContext *ctx, arg_ixtl= bxf *a) =20 reg =3D load_gpr(ctx, a->r); if (a->addr) { - gen_helper_itlba(tcg_env, addr, reg); + gen_helper_itlba_pa11(tcg_env, addr, reg); } else { - gen_helper_itlbp(tcg_env, addr, reg); + gen_helper_itlbp_pa11(tcg_env, addr, reg); } =20 /* Exit TB for TLB change if mmu is enabled. */ @@ -2594,6 +2598,25 @@ static bool trans_ixtlbxf(DisasContext *ctx, arg_ixt= lbxf *a) #endif } =20 +static bool trans_ixtlbt(DisasContext *ctx, arg_ixtlbt *a) +{ + if (!ctx->is_pa20) { + return false; + } + CHECK_MOST_PRIVILEGED(EXCP_PRIV_OPR); +#ifndef CONFIG_USER_ONLY + nullify_over(ctx); + + gen_helper_itlbt_pa20(tcg_env, load_gpr(ctx, a->r1), load_gpr(ctx, a->= r2)); + + /* Exit TB for TLB change if mmu is enabled. */ + if (ctx->tb_flags & PSW_C) { + ctx->base.is_jmp =3D DISAS_IAQ_N_STALE; + } + return nullify_end(ctx); +#endif +} + static bool trans_lpa(DisasContext *ctx, arg_ldst *a) { CHECK_MOST_PRIVILEGED(EXCP_PRIV_OPR); --=20 2.34.1