From patchwork Thu Mar 3 20:59:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 547843 Delivered-To: patch@linaro.org Received: by 2002:ac0:f585:0:0:0:0:0 with SMTP id s5csp992031imq; Thu, 3 Mar 2022 13:23:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJzpf6VdLfNXc8p81PEQhd5tCWUU4f8GOJkUwSp9WtWoooupOpP2EafEjxXgeaUhpOYwhiiB X-Received: by 2002:a25:3786:0:b0:628:ae8f:6d49 with SMTP id e128-20020a253786000000b00628ae8f6d49mr8044958yba.571.1646342626049; Thu, 03 Mar 2022 13:23:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646342626; cv=none; d=google.com; s=arc-20160816; b=avbYcLLPdbfGS1bC2a0YX+O3qnb0Wdn7uf+fLH4WxNVDE+NLzz2kYi3az1y4xzdb1g CaXUqZXeBKUjoC7PUCwW/VQYQ12DJmHSpxbA28PFaVAHnQzC9N/yDTjESgqpvs0gUwG2 2ylkdzPtehsxdexlEPcXAR3RwRXXbcb1NyJFpqxQ4VVesNaU0JRWpW191Uh08RjdLH6E 0OxHiXjIqr9164CxZgFv72yF9JRN+YMq/Se8T3s9Hbbv0VvsF4U1wycQohe/nflUr2LY hKdd0UAPGAkf38sbSBEG1xpUAILNLclTc55+AKZXZocYYgiLYcqmUcZp6JtJogUlQpjL rdAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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=1XkfzGvn+ZlmZZNrl7Dk1RW038tolY/tjYs6706uD7c=; b=LqamQQ9RGM3JDpHTJuP4d6uyIEp3ORoqTTk6qVDl6HZTqzFUpXwFUIH3dpk98Bmxpc AqtC3l++lsvJ5GFpQRiDrKI/v611o1lW5lSWCjtL1Z1Qc+9xwbNd0LxgpGlXjksE562q sIBIv/8IDtXNtdLS7oaLtKJLRkhrWmoqliH5BTATR0fSdSkdoPTS8JNKWbsexYogvnWv W2HtXDgr79dEALCue/7Zb0RtXhkESSPbEyAejrBsp+7mHKw1u7ib8sm1L6Gw0/Ah39TJ NYHdOJVPCbP2hMJIIAxocNmfxvmOivUDLoAho59ecHjigjxIxLVPMQkeABT1BEay0E7T OzJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UWfD1YkG; 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 k130-20020a256f88000000b0062469e339c9si2762604ybc.118.2022.03.03.13.23.45 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 03 Mar 2022 13:23:46 -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=UWfD1YkG; 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]:39438 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nPsvJ-0003ke-JH for patch@linaro.org; Thu, 03 Mar 2022 16:23:45 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59290) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPsZ2-0006D9-Cl for qemu-devel@nongnu.org; Thu, 03 Mar 2022 16:00:49 -0500 Received: from [2607:f8b0:4864:20::102f] (port=40746 helo=mail-pj1-x102f.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nPsYq-0004KP-6m for qemu-devel@nongnu.org; Thu, 03 Mar 2022 16:00:37 -0500 Received: by mail-pj1-x102f.google.com with SMTP id em10-20020a17090b014a00b001bc3071f921so8872617pjb.5 for ; Thu, 03 Mar 2022 13:00:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1XkfzGvn+ZlmZZNrl7Dk1RW038tolY/tjYs6706uD7c=; b=UWfD1YkGnU6ZtDvLvGlz8eSLOw1CJ1MYin9WEGe5wLMP/BxizntOJPxFyIBDc6Y3Rn GJMggH2T04KWs8HMAqB4WI/0Nq7z1w/7aLJjAF4Cnp4+ZzxfPxSRHPu8g72FfwyOLQDu vEjo06V3mLCdmxJCWhWJOausjVjCzpFQGawhnSg7bJ2H5HRrxtgNp5kyOOWKav9e9sYf QBxvw8cnfboVM0bCBRTTfL5TI8PnhWlIptkSwzxtQTIASNGe3IHb72XjMjRBGGvUA5BY PUfPIYUSOu1Mc6g1vMfwtYEruIlW6HL+7DhjFWRerZEyqbmya5XDkrEI7k3n2tz9/NUi FK8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1XkfzGvn+ZlmZZNrl7Dk1RW038tolY/tjYs6706uD7c=; b=gnxAUeHTp+wKTgoH7tH3fJgxnEV4iQNH3LXDiQPRnuNd4NIKkfPgL1Q1uEy7FDTvhH YKNuco0BCMrfwDhmo9Po1SGaw2vPIzDGVd28MZLIc6iZBcN1y/lHS0oyELdlLr/WS75Q wyr45prKsGNJNdG2SVVa3b9dWu5WkYko6XiNu7kilFIpmu1DecnQtSN0ciN+EL/smyd8 rTKH3Q6Y4mZYCvclBW5G0FbxynLqE1mlWWPFGylVWpJBQCvU64KuYq5NkcLI8lu7pBy2 SscTZ7t3Ss0RmdHKMxT3oholE5YY4M2oPT4mlJg/sQ7zMfdQJQnXV+5OmmGbJjjOaBxl yNuQ== X-Gm-Message-State: AOAM531DP/Oy223p3sMUJ09o49hEAmni/KSMb1dF8PfLUM/UdFMNrSIV hOCemeohCgUioHi8ushMwYcepCHoOdsWrg== X-Received: by 2002:a17:903:11c9:b0:151:9521:d5c7 with SMTP id q9-20020a17090311c900b001519521d5c7mr11388492plh.73.1646341223486; Thu, 03 Mar 2022 13:00:23 -0800 (PST) Received: from localhost.localdomain (2603-800c-1201-c600-119c-490c-a4ee-08e8.res6.spectrum.com. [2603:800c:1201:c600:119c:490c:a4ee:8e8]) by smtp.gmail.com with ESMTPSA id t8-20020a6549c8000000b00372eb3a7fb3sm2729934pgs.92.2022.03.03.13.00.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Mar 2022 13:00:23 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 24/30] accel/tcg: Support TCG_TARGET_SIGNED_ADDR32 for softmmu Date: Thu, 3 Mar 2022 10:59:38 -1000 Message-Id: <20220303205944.469445-25-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220303205944.469445-1-richard.henderson@linaro.org> References: <20220303205944.469445-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::102f (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::102f; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102f.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: peter.maydell@linaro.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" When TCG_TARGET_SIGNED_ADDR32 is set, adjust the tlb addend to allow the 32-bit guest address to be sign extended within the 64-bit host register instead of zero extended. This will simplify tcg hosts like MIPS, RISC-V, and LoongArch, which naturally sign-extend 32-bit values, in contrast to x86_64 and AArch64 which zero-extend them. Reviewed-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- accel/tcg/cputlb.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index 0e62aa5d7c..0dbc3efbc7 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -40,6 +40,7 @@ #include "qemu/plugin-memory.h" #endif #include "tcg/tcg-ldst.h" +#include "tcg-target-sa32.h" /* DEBUG defines, enable DEBUG_TLB_LOG to log to the CPU_LOG_MMU target */ /* #define DEBUG_TLB */ @@ -93,6 +94,9 @@ static inline size_t sizeof_tlb(CPUTLBDescFast *fast) static inline uintptr_t g2h_tlbe(const CPUTLBEntry *tlb, target_ulong gaddr) { + if (TCG_TARGET_SIGNED_ADDR32 && TARGET_LONG_BITS == 32) { + return tlb->addend + (int32_t)gaddr; + } return tlb->addend + (uintptr_t)gaddr; } @@ -1244,7 +1248,13 @@ void tlb_set_page_with_attrs(CPUState *cpu, target_ulong vaddr, desc->iotlb[index].attrs = attrs; /* Now calculate the new entry */ - tn.addend = addend - vaddr_page; + + if (TCG_TARGET_SIGNED_ADDR32 && TARGET_LONG_BITS == 32) { + tn.addend = addend - (int32_t)vaddr_page; + } else { + tn.addend = addend - vaddr_page; + } + if (prot & PAGE_READ) { tn.addr_read = address; if (wp_flags & BP_MEM_READ) {