From nobody Wed Nov 27 20:44:01 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=1697835048; cv=none; d=zohomail.com; s=zohoarc; b=UAyi6QmvcBO33bSFny6wibJ3+MRodwFgmqxEVu+A45u1unLg+FVVm4AqGBv5QK7C0tQKBljxI0ptUbmlVuHH+0VIQeO7bxUIyr4gJaNeRzoNYMtukoI2WZF/iKNxYj6aJY2CBZuKDCp9Vh8vKsW6l+V+UnIc6dRk5WrUAp2552c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697835048; 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=iceGonzdaVmnQSlk4xLAZNOj4sU0L4Dh8hQYUhsbnsk=; b=GYYiRSLmqz907pc4eeW+Et9xUeFxA3xtex+dpbjhZJ2LuV36qSNz6qla4NFG2q/Sfg2LhvwvN7NiP15nmRAzs6n/ucsw+aFpiE9eumLJFXdIydAnrjtBjluKW01rpnYF9Kt0GAcKGqtKuCQobSrsgQNCFrAMSDFTzv+za/zzQSs= 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 1697835048509730.8795100181837; Fri, 20 Oct 2023 13:50:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qtwOu-0001of-TR; Fri, 20 Oct 2023 16:47: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 1qtwOq-0001mZ-Ul for qemu-devel@nongnu.org; Fri, 20 Oct 2023 16:47:16 -0400 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qtwOo-0001Ag-OQ for qemu-devel@nongnu.org; Fri, 20 Oct 2023 16:47:16 -0400 Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-6bd32d1a040so1216234b3a.3 for ; Fri, 20 Oct 2023 13:47:14 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id u7-20020aa78487000000b00694fee1011asm1946775pfn.208.2023.10.20.13.47.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 13:47:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697834833; x=1698439633; 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=iceGonzdaVmnQSlk4xLAZNOj4sU0L4Dh8hQYUhsbnsk=; b=RUIZOgt8U72/28jbE5LeTnVldja5hDu+KRCmAazFLotW62Mg06DdUcPDJrPv2tZueO MYLdT61K+spYpaxr/yYyYU607dFkmLMjbDieMxrVxuNaAH2Qw0g1IZvYNmFal1ahQONr KlI8fZ5BBwD2VsR/jySAel5/MuGALJa+X/7n5es2zZ1HUineVuIK8NXyq46xGNRvsSr9 cf/Jgvo4Tz5yvB2xxRDn6jXkMHEhXmGDM4lHapL49ucJ0PSmwAXrci9OiEPckRZrWteg Mq6dqVq09h6EUw7gEjrc86725Tk57VuKZqGn9XO77By92cQFlXQU3yePYXKyPKZVhcn0 WT7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697834833; x=1698439633; 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=iceGonzdaVmnQSlk4xLAZNOj4sU0L4Dh8hQYUhsbnsk=; b=NAyaXWPIK7yHSwAB+2f30yfjp9nV29FTGBwkZGN/Ill9ry6xg4LGcVoSkORGxIYjDc 4nAD1RPjZNQt9fbuijDbKI49UWAEx4R1e87Ihpdf6XKeAlWCDxrilg7dvg6KaAQApvyK 2pW/zAHnoODRxBMIsHlFZpwymyMYU3WcU1WOrc9g/Hr/KJ40JOLjFHsVfs3nEJTek69x /x/nlPZg97XwL76hK8tr5aBEWd0HBZGg6d/YGUiX3fSQNSyjvfExJ1GZO5hgtabJ9aV9 lgeDevDvplq90HFf01cAAif00K8tFLfkFUs+SsKohYG6F++SxuzBF+j7l+4oEWJWoiTo FpSA== X-Gm-Message-State: AOJu0Yy6g44+m/20metD0XJkH6eS6qIBSY3C6h1VWBfHakfI3iQkhbDa iycBqdygf66PSP2dKF5A4CRrxu6skbBnGjnWQaI= X-Google-Smtp-Source: AGHT+IGIw8dsdh9CoEJColH8n+ld3/QaZkus9Pm4STZ4qD/bvX93gG5GRd5Xp5KjiMDNrRy6C3DIVQ== X-Received: by 2002:a05:6a21:3889:b0:179:f761:4348 with SMTP id yj9-20020a056a21388900b00179f7614348mr2111249pzb.34.1697834833450; Fri, 20 Oct 2023 13:47:13 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: deller@gmx.de Subject: [PATCH v2 45/65] target/hppa: Implement IDTLBT, IITLBT Date: Fri, 20 Oct 2023 13:43:11 -0700 Message-Id: <20231020204331.139847-46-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231020204331.139847-1-richard.henderson@linaro.org> References: <20231020204331.139847-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::42d; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42d.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: 1697835049134100002 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 1a63717571..356746654c 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 @@ -519,7 +562,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 650f5812dd..2a09e1cdad 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