From patchwork Sun Oct 10 17:43:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 515595 Delivered-To: patch@linaro.org Received: by 2002:ac0:b5cc:0:0:0:0:0 with SMTP id x12csp3815832ime; Sun, 10 Oct 2021 10:46:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyK7VipZa3WV6k9DpwWLegMWmN5GAjwgszKULNWlPrFv5ofOb4/eKyyY8AeS6pYaBdBVQV2 X-Received: by 2002:a05:622a:206:: with SMTP id b6mr10266750qtx.81.1633888000065; Sun, 10 Oct 2021 10:46:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633888000; cv=none; d=google.com; s=arc-20160816; b=S/VHrQGZ6cBEKhHHbgijqP3q9H+Bf0kPXIYdvaos4MkMdn0qxnKYkeHI8Lyd4/+tKY XlRij4NR1VB0hic/mMmhA0Tzy+hNKLJu+aWy6yumapA38CXKN1bcBkDuwk94OTlJ31T1 vwkFff4jB7gm717qpw35o1ecS+oqCglzvFreUT8cljW7yph29vgKW24QF7QwMjtC7vdC elIP6Ju5BvV59/SGOPRAOCe15iw3mCQzbSPX1rv9R1yGo0IDRdKm7tF8EABVT4XgZKlx JpUdE6nobfF3kt+jGJMbMMXyUhwSUPKNkSefbPGY7C+Di5faqB4X3VfQu1Ew0kFP2xGT 3+HQ== 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=Im+b1+SE02Qv2KjU8guCaDLdxStcEkFqEbgLcsDJx9w=; b=YxyCgBnFXY8pV4/2e5OPqhAVYgpQTywjweTRr+t8dm8IwCeKcawNEcrLUHWS6MaKMv d+svOWvSKIRGVqEKfNvJH5FGzjNKPeh4GlKY0624WWqoRR8YH5CWOuvoXo3ufVDv6SBs EuKi5ZOWXlAF/jDe9Iy0Q/3TXz+W8A9pybBCgDCPs4fdDLOsI6naNWTuAnZBkVSPVtnW jcC6WGRlSRqIrwc3g5KJClmfm/Cg4N78zqNBLWlr8frBDWYFDNHXVaZikDDAXmCpZlKL ZHI4DVs4IofP0FJzuUt9zTQDUmDjik2pkMciASNiTYw+Lb4lHiucwwzLZf9pfF1qG05e AzWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=I4ZYoZfO; 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=fail (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 f18si417074qte.5.2021.10.10.10.46.40 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 10 Oct 2021 10:46:40 -0700 (PDT) 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=fail header.i=@linaro.org header.s=google header.b=I4ZYoZfO; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:55846 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mZcuF-0000XC-I6 for patch@linaro.org; Sun, 10 Oct 2021 13:46:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50834) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mZcru-0000Tz-Jc for qemu-devel@nongnu.org; Sun, 10 Oct 2021 13:44:18 -0400 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]:39720) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mZcrs-0005p1-9w for qemu-devel@nongnu.org; Sun, 10 Oct 2021 13:44:14 -0400 Received: by mail-pl1-x62e.google.com with SMTP id c4so9685896pls.6 for ; Sun, 10 Oct 2021 10:44:11 -0700 (PDT) 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=Im+b1+SE02Qv2KjU8guCaDLdxStcEkFqEbgLcsDJx9w=; b=I4ZYoZfOncX7quOp3ibiSVKLECgadO7FAbEwwVFrKHIPLpSAPj5EV8CIYgL4R7BR0L hbzF/FKBEdqeVQ+JHX51Ppezq4SwvmTPJpxD7C52M5VDTpQjpxUD8bhiKzEWPh1ZywpS AWwR2ybocxiJP3pzJsYOCBaNSK2Sli8mLas/vo/8vEsWcTda8bFjaZ7G6M3dWnspUlcM rF272yh6YuYlF2+gDSUlTiqm4nXvTtOXiCfnt9lqFhST5HzkINGAHmJ3fLwrlVaK2q3t 0ZP5O1epQZR2BYDDaasTww6dKsUFVRl7uvw46epJDO4ESxeZhWuFQcNN8UDPs3Ssnl97 39KA== 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=Im+b1+SE02Qv2KjU8guCaDLdxStcEkFqEbgLcsDJx9w=; b=VQKmLI9SEJNbqbu34nE68VrqNht5XWc5H8A1po+SH6V0dyxqNBmV9K2ZtwpF1s465r jNDiiolgwV/0peCVFY8ZTpc2ZPTFrOTYTqAbXH1tjlREE7jTWZe7zujV8Am7yzMLI2Zc +2sV2uy2WePJ4uPjgzlCb6hxccBJ8I5GTfK14V/+uzus3NgR4M+6Cr731c5dfLi2ToZn F714LlmXmnwd/2nAIL9TrTsDd53d+tKcyXnCxWgmZ4T/d4OPIlvBbRSKucTPT7eUem4+ n0+QqzNy8ykuGiJIm9YpfLo6vzrJTcIu4r3mXno48pjfRJN1TMXynz2K9yRyo+9z4EOH L4sQ== X-Gm-Message-State: AOAM530A2nJRPiKbwum6qPJhkvpl5pPxEnvE52SGka9pZnhUDuMorhcg wJFRSKcP9ij9McZWarW6VcaWb5s6BGE9bvW4 X-Received: by 2002:a17:90b:4b89:: with SMTP id lr9mr25019163pjb.11.1633887850945; Sun, 10 Oct 2021 10:44:10 -0700 (PDT) Received: from localhost.localdomain (068-185-026-038.biz.spectrum.com. [68.185.26.38]) by smtp.gmail.com with ESMTPSA id 18sm5095391pfh.115.2021.10.10.10.44.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Oct 2021 10:44:10 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 3/8] accel/tcg: Support TCG_TARGET_SIGNED_ADDR32 for softmmu Date: Sun, 10 Oct 2021 10:43:56 -0700 Message-Id: <20211010174401.141339-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211010174401.141339-1-richard.henderson@linaro.org> References: <20211010174401.141339-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62e; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62e.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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: git@xen0n.name, Alistair.Francis@wdc.com, f4bug@amsat.org 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. Signed-off-by: Richard Henderson --- accel/tcg/cputlb.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) -- 2.25.1 diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index 761f726722..d12621c60e 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -39,6 +39,7 @@ #ifdef CONFIG_PLUGIN #include "qemu/plugin-memory.h" #endif +#include "tcg-target-sa32.h" /* DEBUG defines, enable DEBUG_TLB_LOG to log to the CPU_LOG_MMU target */ /* #define DEBUG_TLB */ @@ -92,6 +93,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; } @@ -1234,7 +1238,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 < TCG_TARGET_REG_BITS) { + 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) {