From nobody Wed Nov 27 10:01:12 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=1699896860; cv=none; d=zohomail.com; s=zohoarc; b=dbXzmdHPqO6AOeFMj/HuVRnlS60ksPwjm6zVlS6djjM5lJT13/kXS1MjNsrphrS3jyB2Lia7tawDNfj4a7orAMuKHS2jWIJor/kucJ0QBDi79w1v4FtZlmRWENukv9BW6xW1eFy7gTGyDh/NnSTlRNyImPm0S86hqsM05DFs3DQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699896860; h=Content-Transfer-Encoding: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:Cc; bh=osIK/2PUKxHJZqiG0Ph90IvOHQ+akZXlmSPjI1L4ukk=; b=IlZ/fDOQDnodAQAQXrrLCLMVYGHw5I6LEHOtGM81NJlIfCTyINDBGVRRGyPfYreLoXxjKKzeuxu3lpdsI1DjtdZ63Hg+2NBKIGI1deJ0DsZszuxLLW5Ecu9JRwYTibxApTjK6ellzfAuxrVlDSH5pYrIJCf8f1SL5RkBdeueYZc= 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 1699896860481422.2152665521721; Mon, 13 Nov 2023 09:34:20 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r2ao5-0001YA-4Q; Mon, 13 Nov 2023 12:33:05 -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 1r2anv-0001Tu-GL for qemu-devel@nongnu.org; Mon, 13 Nov 2023 12:32:57 -0500 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r2anm-0000vY-Q9 for qemu-devel@nongnu.org; Mon, 13 Nov 2023 12:32:54 -0500 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1cc3216b2a1so34835995ad.2 for ; Mon, 13 Nov 2023 09:32:45 -0800 (PST) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id e6-20020a170902d38600b001c731b62403sm4271910pld.218.2023.11.13.09.32.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Nov 2023 09:32:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699896764; x=1700501564; 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=osIK/2PUKxHJZqiG0Ph90IvOHQ+akZXlmSPjI1L4ukk=; b=T37hyV8NGOP7lwUmbsGCBTvYiZ8Qd32+fnFeZ1CdUlz9W8fa1dNsv2kUuJce6XuDH6 ZvvSqHB7dgiyt+PF4+hSBVTKjlQGlj6cJrH8QYiy64lXqQPdZUQs/VpwM+5DeV8Gau9/ I/kt26IHzqTqKa+uyjX4t/dTkNHT50gUkJEBt3Fj0QpNMk6yen0Mg51HYnz2e4FfVG8I gqGSA6YmKh3G7M1ZQFCbKNOcnieZnJOnPUBpVOKcO8wPiHzfoVxE3gAXMUFyfzbs84y/ Eb+DUBdn3sxjQU4bR8H+SgxYX/4WvcxgK+89UM6s6C+19PBkC4mjzqxMrWvk6McVxCdb epsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699896764; x=1700501564; 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=osIK/2PUKxHJZqiG0Ph90IvOHQ+akZXlmSPjI1L4ukk=; b=H+zm/dxxoUCZ5fp7dDZfRdriXNvMdSlNjqSFwskJGO8aZS1d9bcwiN02criMhrv7PT XiofplmIm2W6uddNUWtu6dKB2dHMa1Y/wQnYl2lQTATjUYlfAW3++iILO5cZ63Arr9oh arL9cNDuS8tvbSBt5SnRLWPAk+S8/IGmk8fwwWwubtncAmVLtDs/4YZRHNl4DxCb4lI4 kBwnHvtP2/ZvFA0IruwgnESry0RUKPoaSzf+aLBJkg3/j848qcWFXyqBHdnLZwyPykB5 mPXhQbhXmNh0qln6Z1F6lITKpIeaSAIKI4dT+E+swvr/jdlVvqFqeN8wZrGxbejOUd4A I9rg== X-Gm-Message-State: AOJu0Yx+ZqsWBxtwOTnXH+D+wjpG06FfwrJho8b644C7H/NMP8c0rmsz aIdZMl3Dpuj0OLtFrvLw1yMu/GHAtmyLbSdpbz4= X-Google-Smtp-Source: AGHT+IEnXdPIPkCHDKjbqMJT8pV0Bl23lNybLTR9/volZ3v19x22sB+7MUOR0tDtHWiNkIlobLQp2A== X-Received: by 2002:a17:903:1210:b0:1cc:4fbe:9278 with SMTP id l16-20020a170903121000b001cc4fbe9278mr224539plh.50.1699896764376; Mon, 13 Nov 2023 09:32:44 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 07/12] target/hppa: Replace MMU_PHYS_IDX with MMU_ABS_IDX, MMU_ABS_W_IDX Date: Mon, 13 Nov 2023 09:32:32 -0800 Message-Id: <20231113173237.48233-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231113173237.48233-1-richard.henderson@linaro.org> References: <20231113173237.48233-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::630; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x630.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1699896861930100007 Content-Type: text/plain; charset="utf-8" Align the language with pa2.0, separating absolute and physical. The translation from absolute to physical depends on PSW.W, and we prefer not to flush between changes, therefore use 2 mmu_idx. Signed-off-by: Richard Henderson --- target/hppa/cpu.h | 26 +++++++++++++------------ target/hppa/mem_helper.c | 41 ++++++++++++++++++++-------------------- target/hppa/translate.c | 6 +++--- 3 files changed, 38 insertions(+), 35 deletions(-) diff --git a/target/hppa/cpu.h b/target/hppa/cpu.h index 6c0f104661..bcfed04f7c 100644 --- a/target/hppa/cpu.h +++ b/target/hppa/cpu.h @@ -31,24 +31,25 @@ basis. It's probably easier to fall back to a strong memory model. */ #define TCG_GUEST_DEFAULT_MO TCG_MO_ALL =20 -#define MMU_KERNEL_IDX 7 -#define MMU_KERNEL_P_IDX 8 -#define MMU_PL1_IDX 9 -#define MMU_PL1_P_IDX 10 -#define MMU_PL2_IDX 11 -#define MMU_PL2_P_IDX 12 -#define MMU_USER_IDX 13 -#define MMU_USER_P_IDX 14 -#define MMU_PHYS_IDX 15 +#define MMU_ABS_W_IDX 6 +#define MMU_ABS_IDX 7 +#define MMU_KERNEL_IDX 8 +#define MMU_KERNEL_P_IDX 9 +#define MMU_PL1_IDX 10 +#define MMU_PL1_P_IDX 11 +#define MMU_PL2_IDX 12 +#define MMU_PL2_P_IDX 13 +#define MMU_USER_IDX 14 +#define MMU_USER_P_IDX 15 =20 -#define MMU_IDX_MMU_DISABLED(MIDX) ((MIDX) =3D=3D MMU_PHYS_IDX) +#define MMU_IDX_MMU_DISABLED(MIDX) ((MIDX) < MMU_KERNEL_IDX) #define MMU_IDX_TO_PRIV(MIDX) (((MIDX) - MMU_KERNEL_IDX) / 2) #define MMU_IDX_TO_P(MIDX) (((MIDX) - MMU_KERNEL_IDX) & 1) #define PRIV_P_TO_MMU_IDX(PRIV, P) ((PRIV) * 2 + !!(P) + MMU_KERNEL_IDX) =20 #define TARGET_INSN_START_EXTRA_WORDS 2 =20 -/* No need to flush MMU_PHYS_IDX */ +/* No need to flush MMU_ABS*_IDX */ #define HPPA_MMU_FLUSH_MASK \ (1 << MMU_KERNEL_IDX | 1 << MMU_KERNEL_P_IDX | \ 1 << MMU_PL1_IDX | 1 << MMU_PL1_P_IDX | \ @@ -288,7 +289,8 @@ static inline int cpu_mmu_index(CPUHPPAState *env, bool= ifetch) if (env->psw & (ifetch ? PSW_C : PSW_D)) { return PRIV_P_TO_MMU_IDX(env->iaoq_f & 3, env->psw & PSW_P); } - return MMU_PHYS_IDX; /* mmu disabled */ + /* mmu disabled */ + return env->psw & PSW_W ? MMU_ABS_W_IDX : MMU_ABS_IDX; #endif } =20 diff --git a/target/hppa/mem_helper.c b/target/hppa/mem_helper.c index af8e86699d..7bc456d4ee 100644 --- a/target/hppa/mem_helper.c +++ b/target/hppa/mem_helper.c @@ -53,17 +53,6 @@ hwaddr hppa_abs_to_phys_pa2_w0(vaddr addr) return (addr & MAKE_64BIT_MASK(0, 24)) | MAKE_64BIT_MASK(60, 4); } =20 -static hwaddr hppa_abs_to_phys(CPUHPPAState *env, vaddr addr) -{ - if (!hppa_is_pa20(env)) { - return addr; - } else if (env->psw & PSW_W) { - return hppa_abs_to_phys_pa2_w1(addr); - } else { - return hppa_abs_to_phys_pa2_w0(addr); - } -} - static HPPATLBEntry *hppa_find_tlb(CPUHPPAState *env, vaddr addr) { IntervalTreeNode *i =3D interval_tree_iter_first(&env->tlb_root, addr,= addr); @@ -161,9 +150,22 @@ int hppa_get_physical_address(CPUHPPAState *env, vaddr= addr, int mmu_idx, *tlb_entry =3D NULL; } =20 - /* Virtual translation disabled. Direct map virtual to physical. */ - if (mmu_idx =3D=3D MMU_PHYS_IDX) { - phys =3D addr; + /* Virtual translation disabled. Map absolute to physical. */ + if (MMU_IDX_MMU_DISABLED(mmu_idx)) { + switch (mmu_idx) { + case MMU_ABS_W_IDX: + phys =3D hppa_abs_to_phys_pa2_w1(addr); + break; + case MMU_ABS_IDX: + if (hppa_is_pa20(env)) { + phys =3D hppa_abs_to_phys_pa2_w0(addr); + } else { + phys =3D (uint32_t)addr; + } + break; + default: + g_assert_not_reached(); + } prot =3D PAGE_READ | PAGE_WRITE | PAGE_EXEC; goto egress; } @@ -261,7 +263,7 @@ int hppa_get_physical_address(CPUHPPAState *env, vaddr = addr, int mmu_idx, } =20 egress: - *pphys =3D phys =3D hppa_abs_to_phys(env, phys); + *pphys =3D phys; *pprot =3D prot; trace_hppa_tlb_get_physical_address(env, ret, prot, addr, phys); return ret; @@ -271,16 +273,15 @@ hwaddr hppa_cpu_get_phys_page_debug(CPUState *cs, vad= dr addr) { HPPACPU *cpu =3D HPPA_CPU(cs); hwaddr phys; - int prot, excp; + int prot, excp, mmu_idx; =20 /* If the (data) mmu is disabled, bypass translation. */ /* ??? We really ought to know if the code mmu is disabled too, in order to get the correct debugging dumps. */ - if (!(cpu->env.psw & PSW_D)) { - return hppa_abs_to_phys(&cpu->env, addr); - } + mmu_idx =3D (cpu->env.psw & PSW_D ? MMU_KERNEL_IDX : + cpu->env.psw & PSW_W ? MMU_ABS_W_IDX : MMU_ABS_IDX); =20 - excp =3D hppa_get_physical_address(&cpu->env, addr, MMU_KERNEL_IDX, 0, + excp =3D hppa_get_physical_address(&cpu->env, addr, mmu_idx, 0, &phys, &prot, NULL); =20 /* Since we're translating for debugging, the only error that is a diff --git a/target/hppa/translate.c b/target/hppa/translate.c index 727dd8a829..4a4830c3e3 100644 --- a/target/hppa/translate.c +++ b/target/hppa/translate.c @@ -3172,7 +3172,7 @@ static bool trans_lda(DisasContext *ctx, arg_ldst *a) int hold_mmu_idx =3D ctx->mmu_idx; =20 CHECK_MOST_PRIVILEGED(EXCP_PRIV_OPR); - ctx->mmu_idx =3D MMU_PHYS_IDX; + ctx->mmu_idx =3D ctx->tb_flags & PSW_W ? MMU_ABS_W_IDX : MMU_ABS_IDX; trans_ld(ctx, a); ctx->mmu_idx =3D hold_mmu_idx; return true; @@ -3183,7 +3183,7 @@ static bool trans_sta(DisasContext *ctx, arg_ldst *a) int hold_mmu_idx =3D ctx->mmu_idx; =20 CHECK_MOST_PRIVILEGED(EXCP_PRIV_OPR); - ctx->mmu_idx =3D MMU_PHYS_IDX; + ctx->mmu_idx =3D ctx->tb_flags & PSW_W ? MMU_ABS_W_IDX : MMU_ABS_IDX; trans_st(ctx, a); ctx->mmu_idx =3D hold_mmu_idx; return true; @@ -4435,7 +4435,7 @@ static void hppa_tr_init_disas_context(DisasContextBa= se *dcbase, CPUState *cs) ctx->privilege =3D (ctx->tb_flags >> TB_FLAG_PRIV_SHIFT) & 3; ctx->mmu_idx =3D (ctx->tb_flags & PSW_D ? PRIV_P_TO_MMU_IDX(ctx->privilege, ctx->tb_flags & PS= W_P) - : MMU_PHYS_IDX); + : ctx->tb_flags & PSW_W ? MMU_ABS_W_IDX : MMU_ABS_IDX); =20 /* Recover the IAOQ values from the GVA + PRIV. */ uint64_t cs_base =3D ctx->base.tb->cs_base; --=20 2.34.1