From patchwork Tue Nov 7 03:04:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 741817 Delivered-To: patch@linaro.org Received: by 2002:adf:fd90:0:b0:32d:baff:b0ca with SMTP id d16csp1421015wrr; Mon, 6 Nov 2023 19:11:36 -0800 (PST) X-Google-Smtp-Source: AGHT+IGw81SCxykWbezBU6niSE9ZhK9HzTfFem/FYOeiEGfc+MCGytCsB7FYiRO+5GqphUc2a8c+ X-Received: by 2002:a05:620a:280c:b0:77a:1d5b:2cc4 with SMTP id f12-20020a05620a280c00b0077a1d5b2cc4mr28623884qkp.9.1699326696425; Mon, 06 Nov 2023 19:11:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699326696; cv=none; d=google.com; s=arc-20160816; b=NAK6LsCYQIMDkubPNXDhufTtuuksnN7SID94FERtOYNKzY3B9EXI7UFk/Gma9k+HK/ c1LSmTaJBXvut1ZOcU5Nn/AP6lhe5MCHz/NRfMrdmp1tuNFo13uQEFTb0o40C8zXfd6Q kMSTdg47qspCPaje9C2uD9qp78LF9ozhDf35LcUwPIHcbMJ6EuKBdqFYBADU0hGjH3UC xWZVZdEohxvMDDs3N2jMEgmrDMtOcwYz+vZtUTeQvbkR6V3YPTAaGJLNP9oVKd/jNYzb yHoJO07yYKkcZcVHlsZESTwJqVMGDk2tNkhBEFHXl8Z86xLU+wwiZXXJSVa6PGEHQT3p iuDA== 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=l8fr3+CRJQ2fSyTIfaR9JmF1licLAR+9v7s8wM6sbYc=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=wvTt5WjdYdSty1WH9lgB6vAeBkVnwg0O0owhJMvCElTOMhAet0VQ1EUKEpDMYcj4qV 6CkFI9xuV3uGKeJXW63P2czfy69yCwaqr5Aqln1X12+hNikV16IiQNpOI1iK58987dEg b94T6hralgwlF/9G1/SCBfNGM+xHNaJLvlOk8e/vZHoX6uqy82V8JnK3pkKZDvY0QGqX gWU2vjTjbR3aXXrJ3XL3myBwF8qy33uxeutEav8P9J2jPiN4NxMbccIqg7Pg1fVzEgIz XEtBbZIpgDtVtl8bUqEweWtkeQmeExTijARVmQ9KE9X3LTuIHwBYfGCs/S9HZJc1H2F5 kulg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KMptr+XL; 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 w19-20020a05620a445300b00773d05a13f6si7085814qkp.538.2023.11.06.19.11.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 06 Nov 2023 19:11:36 -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=KMptr+XL; 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 1r0CS2-00069e-0U; Mon, 06 Nov 2023 22:08:26 -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 1r0CRr-0005eC-6d for qemu-devel@nongnu.org; Mon, 06 Nov 2023 22:08:15 -0500 Received: from mail-pg1-x532.google.com ([2607:f8b0:4864:20::532]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r0CRk-0001UA-V9 for qemu-devel@nongnu.org; Mon, 06 Nov 2023 22:08:14 -0500 Received: by mail-pg1-x532.google.com with SMTP id 41be03b00d2f7-5b97ca78da8so3507128a12.3 for ; Mon, 06 Nov 2023 19:08:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699326487; x=1699931287; 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=l8fr3+CRJQ2fSyTIfaR9JmF1licLAR+9v7s8wM6sbYc=; b=KMptr+XLAhlUM72vuWtT/p1e+471HQaOhdvJYufNEnBsu8b9+nW5ku0Zui9Som6XgB BN+s45Pbdtpr1tz1koaUc7CTYqPofy3KKnYJrdLTpqtYqwGZMdeCBibHWusox2ua9MwD +VKJSDINSTVJEJChKtdvyznWpKeD/+hRdSwxtBnCViha4fnP4S604jFJSHnHDkLtgifY OFNRWpXpkErqAcLqrsBEHr2buRB8x8IBbhwj6g/Tr+HcYnpmKgzKXXbFye605kXmfl5c XEBcYDk7EM4rivIgCewJJRkRsuXmdB/OxT1bWPV6XS4MkaOF+frqt22O2jojP2afIwDz 3g4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699326487; x=1699931287; 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=l8fr3+CRJQ2fSyTIfaR9JmF1licLAR+9v7s8wM6sbYc=; b=VNLUQwUkj1rkE8gw20Gv68b02nh56KTvJF2xOki7jBIkLMoMlAE8GyflEG/ZiM2c2T BPdaPnMoIhAJRv/O/lDNKUCHqYrcEU5WsjiWH8eqPxeA9yYSqXtWKiJeM4pxSg/ZHvxj OzfiWrc8t6y6y21IahY2Luuio99Y8l+PbC3eS6rDpOkk/3h+zrrSLlEcw+Wi8NPjqqLg Zo4qp9AfEKrxBpnAeqPtIcnAqw7vYNFZefxGk327zEK5j/jHr8hbhDyYbP4inu/KUTWS U7dBrtZANWqa/xyuNcgzhoLgeLq/SBghLJSW7i4qnEtM3aDnl5EMO99NfmyRqN6aqyJz vyEQ== X-Gm-Message-State: AOJu0YyAKxbkM90RvU/3WsT2540iR38S0JmwPvE0nXdVk4/usVYOOwp2 5Sf5o/wxpFmubFwCkwEJxYFYqgC7ecdeyjnNZEo= X-Received: by 2002:a05:6a20:7487:b0:15e:b8a1:57b0 with SMTP id p7-20020a056a20748700b0015eb8a157b0mr26298031pzd.39.1699326487349; Mon, 06 Nov 2023 19:08:07 -0800 (PST) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id 13-20020a17090a004d00b0027782f611d1sm6744883pjb.36.2023.11.06.19.08.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 19:08:07 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 79/85] target/hppa: Create raise_exception_with_ior Date: Mon, 6 Nov 2023 19:04:01 -0800 Message-Id: <20231107030407.8979-80-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::532; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x532.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 Handle pa2.0 logic for filling in ISR+IOR. Signed-off-by: Richard Henderson --- target/hppa/mem_helper.c | 64 ++++++++++++++++++++++++++++++++-------- 1 file changed, 51 insertions(+), 13 deletions(-) diff --git a/target/hppa/mem_helper.c b/target/hppa/mem_helper.c index 602e6c809f..858ce6ec7f 100644 --- a/target/hppa/mem_helper.c +++ b/target/hppa/mem_helper.c @@ -289,6 +289,53 @@ hwaddr hppa_cpu_get_phys_page_debug(CPUState *cs, vaddr addr) return excp == EXCP_DTLB_MISS ? -1 : phys; } +G_NORETURN static void +raise_exception_with_ior(CPUHPPAState *env, int excp, uintptr_t retaddr, + vaddr addr, bool mmu_disabled) +{ + CPUState *cs = env_cpu(env); + + cs->exception_index = excp; + + if (env->psw & PSW_Q) { + /* + * For pa1.x, the offset and space never overlap, and so we + * simply extract the high and low part of the virtual address. + * + * For pa2.0, the formation of these are described in section + * "Interruption Parameter Registers", page 2-15. + */ + env->cr[CR_IOR] = (uint32_t)addr; + env->cr[CR_ISR] = addr >> 32; + + if (hppa_is_pa20(env)) { + if (mmu_disabled) { + /* + * If data translation was disabled, the ISR contains + * the upper portion of the abs address, zero-extended. + */ + env->cr[CR_ISR] &= 0x3fffffff; + } else { + /* + * If data translation was enabled, the upper two bits + * of the IOR (the b field) are equal to the two space + * bits from the base register used to form the gva. + */ + uint64_t b; + + cpu_restore_state(cs, retaddr); + + b = env->gr[env->unwind_breg]; + b >>= (env->psw & PSW_W ? 62 : 30); + env->cr[CR_IOR] |= b << 62; + + cpu_loop_exit(cs); + } + } + } + cpu_loop_exit_restore(cs, retaddr); +} + bool hppa_cpu_tlb_fill(CPUState *cs, vaddr addr, int size, MMUAccessType type, int mmu_idx, bool probe, uintptr_t retaddr) @@ -318,14 +365,10 @@ bool hppa_cpu_tlb_fill(CPUState *cs, vaddr addr, int size, return false; } trace_hppa_tlb_fill_excp(env, addr, size, type, mmu_idx); + /* Failure. Raise the indicated exception. */ - cs->exception_index = excp; - if (cpu->env.psw & PSW_Q) { - /* ??? Needs tweaking for hppa64. */ - cpu->env.cr[CR_IOR] = addr; - cpu->env.cr[CR_ISR] = addr >> 32; - } - cpu_loop_exit_restore(cs, retaddr); + raise_exception_with_ior(env, excp, retaddr, + addr, mmu_idx == MMU_PHYS_IDX); } trace_hppa_tlb_fill_success(env, addr & TARGET_PAGE_MASK, @@ -553,16 +596,11 @@ target_ulong HELPER(lpa)(CPUHPPAState *env, target_ulong addr) excp = hppa_get_physical_address(env, addr, MMU_KERNEL_IDX, 0, &phys, &prot, NULL); if (excp >= 0) { - if (env->psw & PSW_Q) { - /* ??? Needs tweaking for hppa64. */ - env->cr[CR_IOR] = addr; - env->cr[CR_ISR] = addr >> 32; - } if (excp == EXCP_DTLB_MISS) { excp = EXCP_NA_DTLB_MISS; } trace_hppa_tlb_lpa_failed(env, addr); - hppa_dynamic_excp(env, excp, GETPC()); + raise_exception_with_ior(env, excp, GETPC(), addr, false); } trace_hppa_tlb_lpa_success(env, addr, phys); return phys;