From patchwork Sun Mar 14 21:27:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 400141 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp2928462jai; Sun, 14 Mar 2021 14:51:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxtxk3x5I2JE6wCspb9j150ZD2l20QjiLgDJQZgqKImFAaz1cHQV21T/nSCci7dB1s5DeXL X-Received: by 2002:a25:bd89:: with SMTP id f9mr33766064ybh.380.1615758714818; Sun, 14 Mar 2021 14:51:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615758714; cv=none; d=google.com; s=arc-20160816; b=JQUvnRdL81UeIH/nwxOh2Ys+cSAnay2PGJNCewRNs3S+4IvY/Avl2fVsihtb3Y+6bd 9FncjuzdqxZ+b9Y1/QggNdaFMSHRKqcyK9eWDNB0GL6hTAUICd+YiAcG6EHWPDjbXgYv RUGVZ9PRvNDbEMUtq8GOG8zx7nTBDN1th11tQONSppzx1H7DsUZrQHmeJYy3fNa5otqC g1w+huHZqcj7eapDyrFuiP/mWdv44KaIznY4m3u7l0Ya8FDkNNSkrQdIJ9eTX9RFtXP1 a04V9C0QJ5Zy2luH9/v6cytM1c8CIRoVZSv+JnxvhxNI0FeCztROYMECUwGS7QvfQwrt HrVQ== 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=eK04d/bo+QTgBddX7q0xdbozbAL0+oUVhNKLX/4OLZA=; b=oHRevH7ktceux78LAFPzDGkMjpgIuKJOLKJ/c5PwRJ4E7EdydLmxFnjBbYzTKLJgCU d+OMYLnSnxUQtgLuZYC1lbfeYeXuEGqtc4RdQtu5QDC8djUeEzvktH2y5efqERP69L4B vzAtpjaIxJXQ6MyoOLvH4XjmOw0MhcM6YawBS8a2lZv9glU/hdms+hAJqKKBnQMZsYIl o+p0ObC+1iqrdRNKwk6mVY9x3lq7KQy5Frg0Lm4ZrAW2SrTkpbar7tDc5HqrKuwASsYt EqI9IkkXvi1otmrIBvKLivS3WQsbG7wLHoqfYnYxQyEj7+J2djZmP8xS6B2OSYrnkcR/ R7ag== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=zmL8y45J; 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 r10si13064820ybk.242.2021.03.14.14.51.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 14 Mar 2021 14:51:54 -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=zmL8y45J; 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]:57766 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lLYeQ-00064D-AB for patch@linaro.org; Sun, 14 Mar 2021 17:51:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54776) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lLYH8-0006BK-Mo for qemu-devel@nongnu.org; Sun, 14 Mar 2021 17:27:50 -0400 Received: from mail-qk1-x72c.google.com ([2607:f8b0:4864:20::72c]:34582) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lLYH7-0008GN-0L for qemu-devel@nongnu.org; Sun, 14 Mar 2021 17:27:50 -0400 Received: by mail-qk1-x72c.google.com with SMTP id t4so29950123qkp.1 for ; Sun, 14 Mar 2021 14:27:48 -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=eK04d/bo+QTgBddX7q0xdbozbAL0+oUVhNKLX/4OLZA=; b=zmL8y45JHUuZuFhWXxgi/ZsDWCdDLKmNjJdywF8q2VlzzTQh7n+wawJvyaliJAd7NQ LsHFQXoSde6Go3YQbMn9Ci4sWPGTz/HhBZZi+OAa3vOxTQ8rp1fpUkfuMX6jo5FFxY5M +JQEWLSxLL3GImIjDfHBkCYgmdoL9UlWO2hc2ZJWysveDFsfoZ8/TCxvxWNnA43mOmHV jE1mqK+kxLHWXu6IAze7Tb6XXgAlDid71c/DtrpB+fOaHmEdyoI50BXsRmbFcjHHRKkS YRLweATzhQuDiXRdq5gF7ITPUfZCVm9RBX6Da9jL/9CimE4hVmujE601EaqzD2QTIxCi D+OA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=eK04d/bo+QTgBddX7q0xdbozbAL0+oUVhNKLX/4OLZA=; b=JbZANrDqO6IWink3iCFtSBLOAiWjdnhhkZXtCaWE3jcoKU6beKGIbnSxrW0VPYJtCn fZOOCi6Vc6/Kwg/Cyltl/c6A3LRvxSN/kZcv3MxpFXSzLr+qZlY0gIt3llpiHbf3xRUX vFIU8v5XMhF9lFFlUlTd0GXd9dc0HLYYA48shbF0OpyEDjXLy2K+e5OXqjyCpFPE4vI0 ka+egSPqX4j/79EbODOqRruXnYk4U9V0ZWqhxHMB5EdNu8r297KJ72vK8toR0HRApr/X uCz42KT/wA3Lro9hiI5Kc0e/ib+JJnbbJFlJEQPCycU2SCkz2PaZjtLmEh9xaFW1ii/Q Zqqw== X-Gm-Message-State: AOAM532RCTTNp+oYI1kuFVeYD4jpSrTeNtrWXFPOwnkFlL4g5mTrI0gg RoVdtDOWrsZC0xmu8Bo+Nrk6lcOUba9nHCo2 X-Received: by 2002:a37:4690:: with SMTP id t138mr22528857qka.394.1615757268014; Sun, 14 Mar 2021 14:27:48 -0700 (PDT) Received: from localhost.localdomain (fixed-187-189-51-144.totalplay.net. [187.189.51.144]) by smtp.gmail.com with ESMTPSA id t2sm9337749qtd.13.2021.03.14.14.27.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Mar 2021 14:27:47 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 19/29] tcg: Tidy split_cross_256mb Date: Sun, 14 Mar 2021 15:27:14 -0600 Message-Id: <20210314212724.1917075-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210314212724.1917075-1-richard.henderson@linaro.org> References: <20210314212724.1917075-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::72c; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x72c.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: r.bolshakov@yadro.com, j@getutm.app Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Return output buffer and size via output pointer arguments, rather than returning size via tcg_ctx->code_gen_buffer_size. Signed-off-by: Richard Henderson --- tcg/region.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) -- 2.25.1 diff --git a/tcg/region.c b/tcg/region.c index 23b3459c61..45c1178815 100644 --- a/tcg/region.c +++ b/tcg/region.c @@ -467,7 +467,8 @@ static inline bool cross_256mb(void *addr, size_t size) /* 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 of the buffer, and adjusts code_gen_buffer_size. */ -static inline void *split_cross_256mb(void *buf1, size_t size1) +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; @@ -478,8 +479,8 @@ static inline void *split_cross_256mb(void *buf1, size_t size1) buf1 = buf2; } - tcg_ctx->code_gen_buffer_size = size1; - return buf1; + *obuf = buf1; + *osize = size1; } #endif @@ -509,12 +510,10 @@ static bool alloc_code_gen_buffer(size_t tb_size, int splitwx, Error **errp) if (size > tb_size) { size = QEMU_ALIGN_DOWN(tb_size, qemu_real_host_page_size); } - tcg_ctx->code_gen_buffer_size = size; #ifdef __mips__ if (cross_256mb(buf, size)) { - buf = split_cross_256mb(buf, size); - size = tcg_ctx->code_gen_buffer_size; + split_cross_256mb(&buf, &size, buf, size); } #endif @@ -525,6 +524,7 @@ static bool alloc_code_gen_buffer(size_t tb_size, int splitwx, Error **errp) qemu_madvise(buf, size, QEMU_MADV_HUGEPAGE); tcg_ctx->code_gen_buffer = buf; + tcg_ctx->code_gen_buffer_size = size; return true; } #elif defined(_WIN32) @@ -583,8 +583,7 @@ static bool alloc_code_gen_buffer_anon(size_t size, int prot, /* fallthru */ default: /* Split the original buffer. Free the smaller half. */ - buf2 = split_cross_256mb(buf, size); - size2 = tcg_ctx->code_gen_buffer_size; + split_cross_256mb(&buf2, &size2, buf, size); if (buf == buf2) { munmap(buf + size2, size - size2); } else {