From patchwork Tue Sep 21 02:25:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 514384 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp2638670jao; Mon, 20 Sep 2021 19:27:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzvytCRiJwAggf1mKSb0OF5XyMZGYQX1UZmm/C4aqpqTthiEUIhgLoUxoxiwUeo89rVGokR X-Received: by 2002:a05:6e02:1a8d:: with SMTP id k13mr18488107ilv.70.1632191228935; Mon, 20 Sep 2021 19:27:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632191228; cv=none; d=google.com; s=arc-20160816; b=jdTrHqCrcLpazr7I0x1qRsSBJh0hNakEerSzeQgNcYiL2faXIgA+uvcWF0ccC0v3ac ePQzHLd1FEK8ACD9Q0OClchs+NJmfXNhjGWTumpP1OGNqhDdET4KUW+P4JKXSzvBn3ck 1RI2kIIonrws4X985qBYOQog3HAGTVpI9hQbxYgTDlP27srMkkpYSEII9KueIOEBCyhU Aql2v+dH3ECd4sZLnBPI0F8bvzwnsoZOjJRsl+0VxERR9ClUPZjolnUl949gPGSdiLrm Ll8Mw4xHm4EaB4x+O7PKvLMrkdcloeZzVj65AEBn5RhiUmCYkM1pSHM5dEPPhRXI+K/i 1rdQ== 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=zxXZyIG+Pw01TAIshh/v24ac5SJa+rYMBmTa7I6pYe8=; b=P99I4/zkpm0ZPFBiECWZSzBPXK5Oqw74NoXsrL/MQIKRzmInKK9xvFDZbKst0lujGs HDBgOPSJxbGdPKWIc4QyzT5M6dHHyPtgLje7JZ4vla+2tUYMMZjxu+nNj2RhRNZFYPRd I04gRcEp/GSUfRIUR/tgzrt0jwLVm/xFmp5+4D1lC/eFkC1+/smqe4lJV4+DDi8boD2F 7e0fajnqRUhYuFYatBKjaxs8MF9On4PL+Is9cb6U1CR2xqLtIc9FdePCUat+W1xIdsZn wACPn99ecVNfVkuhQl3ZyRrSJzDqpFUz1wUdPeSSkphovmGQRUVBDVy+7/X/0wtvmToA sH7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tMsuVb0c; 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 h2si1301675iow.79.2021.09.20.19.27.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 20 Sep 2021 19:27:08 -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=pass header.i=@linaro.org header.s=google header.b=tMsuVb0c; 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]:59658 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mSVUy-0005gJ-C3 for patch@linaro.org; Mon, 20 Sep 2021 22:27:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43318) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mSVTe-0005cd-3s for qemu-devel@nongnu.org; Mon, 20 Sep 2021 22:25:46 -0400 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]:52107) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mSVTa-0006GQ-1v for qemu-devel@nongnu.org; Mon, 20 Sep 2021 22:25:45 -0400 Received: by mail-pj1-x102b.google.com with SMTP id dw14so13362323pjb.1 for ; Mon, 20 Sep 2021 19:25:41 -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=zxXZyIG+Pw01TAIshh/v24ac5SJa+rYMBmTa7I6pYe8=; b=tMsuVb0c7DPDVCHzKFDcDtDIl/ZWI+ikUQA6kaXWcjHV2g0zrmCp1scoINEIzwat2B il7i2IuVgvAvxzDisdORXbxu9QnoOS+VTP6UKL3O6jUqtgGPDkQLP9uh7FpN5CtydvgL yX/Ox2m1LpCxz7P/fVhxml/Mil7Qfnd8VmtkIe/g079a5ymQd6sDQHvNAIiqG1at+Rdl Tf9jdC+apPcuVxDc8oqXuVBe0je/np50kXSVg5p9pd+dICMUc36maqmmNQyxh52ngtId QEGNvqo5unH771LurX2VwVZXrUtR6Dl7rqkDiVt2Hma8bcvtGSxvivW6OEhTrCe4rUS2 ZvyA== 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=zxXZyIG+Pw01TAIshh/v24ac5SJa+rYMBmTa7I6pYe8=; b=AvwiQaQV2bVTNGFtG3zPwS86c4mFpSM4NybdbWzhABBqu9D7IuqvC7uEu4sr9epirp JAEHsc2r0PtlwHWUXI6NQqkg+IvBwMVcameYnzZ9zO+srRlDXq1xoF9WKU4XmNivyYQM 6eSCK7HnaSAx+S5X7H0vHCag2EimLoRMGl4iuVedjNFbgUfCBc1nE5wnmFiJVkao8Oko rA5j53JrwVDAbqxtcYSceRfmGB38B6j8GpYQVypkewU/7LPBwq7sQBIShMSOzt4UqLLo /doSx/DOdrPBGvA36+UFynPUXFWfeNQAlepjS5KLpQCxnp9JPB/3sgbXWue/wLKWqBRb jFNQ== X-Gm-Message-State: AOAM530BogRni7UwKSJmqagD9GqDdQg7uwbflD0VUDmTgTcVziQghIEu 3QPB9UdW84KpWRhsTYcYlng/yuHiUVE5ww== X-Received: by 2002:a17:902:ed8a:b0:13b:7a09:5215 with SMTP id e10-20020a170902ed8a00b0013b7a095215mr25354753plj.56.1632191140637; Mon, 20 Sep 2021 19:25:40 -0700 (PDT) Received: from localhost.localdomain ([71.212.134.125]) by smtp.gmail.com with ESMTPSA id n9sm15297621pff.37.2021.09.20.19.25.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Sep 2021 19:25:40 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 06/10] tcg/mips: Drop special alignment for code_gen_buffer Date: Mon, 20 Sep 2021 19:25:30 -0700 Message-Id: <20210921022534.365291-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210921022534.365291-1-richard.henderson@linaro.org> References: <20210921022534.365291-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102b; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102b.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: 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" Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- tcg/region.c | 91 ---------------------------------------------------- 1 file changed, 91 deletions(-) -- 2.25.1 diff --git a/tcg/region.c b/tcg/region.c index e64c3ea230..9cc30d4922 100644 --- a/tcg/region.c +++ b/tcg/region.c @@ -467,38 +467,6 @@ static size_t tcg_n_regions(size_t tb_size, unsigned max_cpus) (DEFAULT_CODE_GEN_BUFFER_SIZE_1 < MAX_CODE_GEN_BUFFER_SIZE \ ? DEFAULT_CODE_GEN_BUFFER_SIZE_1 : MAX_CODE_GEN_BUFFER_SIZE) -#ifdef __mips__ -/* - * In order to use J and JAL within the code_gen_buffer, we require - * that the buffer not cross a 256MB boundary. - */ -static inline bool cross_256mb(void *addr, size_t size) -{ - return ((uintptr_t)addr ^ ((uintptr_t)addr + size)) & ~0x0ffffffful; -} - -/* - * We weren't able to allocate a buffer without crossing that boundary, - * so make do with the larger portion of the buffer that doesn't cross. - * Returns the new base and size of the buffer in *obuf and *osize. - */ -static inline void split_cross_256mb(void **obuf, size_t *osize, - void *buf1, size_t size1) -{ - void *buf2 = (void *)(((uintptr_t)buf1 + size1) & ~0x0ffffffful); - size_t size2 = buf1 + size1 - buf2; - - size1 = buf2 - buf1; - if (size1 < size2) { - size1 = size2; - buf1 = buf2; - } - - *obuf = buf1; - *osize = size1; -} -#endif - #ifdef USE_STATIC_CODE_GEN_BUFFER static uint8_t static_code_gen_buffer[DEFAULT_CODE_GEN_BUFFER_SIZE] __attribute__((aligned(CODE_GEN_ALIGN))); @@ -526,12 +494,6 @@ static int alloc_code_gen_buffer(size_t tb_size, int splitwx, Error **errp) size = QEMU_ALIGN_DOWN(tb_size, qemu_real_host_page_size); } -#ifdef __mips__ - if (cross_256mb(buf, size)) { - split_cross_256mb(&buf, &size, buf, size); - } -#endif - region.start_aligned = buf; region.total_size = size; @@ -573,39 +535,6 @@ static int alloc_code_gen_buffer_anon(size_t size, int prot, return -1; } -#ifdef __mips__ - if (cross_256mb(buf, size)) { - /* - * Try again, with the original still mapped, to avoid re-acquiring - * the same 256mb crossing. - */ - size_t size2; - void *buf2 = mmap(NULL, size, prot, flags, -1, 0); - switch ((int)(buf2 != MAP_FAILED)) { - case 1: - if (!cross_256mb(buf2, size)) { - /* Success! Use the new buffer. */ - munmap(buf, size); - break; - } - /* Failure. Work with what we had. */ - munmap(buf2, size); - /* fallthru */ - default: - /* Split the original buffer. Free the smaller half. */ - split_cross_256mb(&buf2, &size2, buf, size); - if (buf == buf2) { - munmap(buf + size2, size - size2); - } else { - munmap(buf, size - size2); - } - size = size2; - break; - } - buf = buf2; - } -#endif - region.start_aligned = buf; region.total_size = size; return prot; @@ -620,35 +549,15 @@ static bool alloc_code_gen_buffer_splitwx_memfd(size_t size, Error **errp) void *buf_rw = NULL, *buf_rx = MAP_FAILED; int fd = -1; -#ifdef __mips__ - /* Find space for the RX mapping, vs the 256MiB regions. */ - if (alloc_code_gen_buffer_anon(size, PROT_NONE, - MAP_PRIVATE | MAP_ANONYMOUS | - MAP_NORESERVE, errp) < 0) { - return false; - } - /* The size of the mapping may have been adjusted. */ - buf_rx = region.start_aligned; - size = region.total_size; -#endif - buf_rw = qemu_memfd_alloc("tcg-jit", size, 0, &fd, errp); if (buf_rw == NULL) { goto fail; } -#ifdef __mips__ - void *tmp = mmap(buf_rx, size, PROT_READ | PROT_EXEC, - MAP_SHARED | MAP_FIXED, fd, 0); - if (tmp != buf_rx) { - goto fail_rx; - } -#else buf_rx = mmap(NULL, size, PROT_READ | PROT_EXEC, MAP_SHARED, fd, 0); if (buf_rx == MAP_FAILED) { goto fail_rx; } -#endif close(fd); region.start_aligned = buf_rw;