From patchwork Sun May 2 23:18:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 430481 Delivered-To: patch@linaro.org Received: by 2002:a17:907:764d:0:0:0:0 with SMTP id kj13csp1229781ejc; Sun, 2 May 2021 16:35:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxOxP0DLu8K2ldZrdQpc7oByqiZ5PVUn7xzm+BnFo8bcD0BHEyjhucHjdbDy/LFzI20ErY2 X-Received: by 2002:a02:9505:: with SMTP id y5mr15772951jah.27.1619998551133; Sun, 02 May 2021 16:35:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619998551; cv=none; d=google.com; s=arc-20160816; b=L4sVLs9PeUi4dGTUPnAlzBadnwF6OWkfzFtMNkVMNSKWskJiyeAR9SAly8Fm1MVUg2 CHKQiWhop+64jyPf01TGZSkrEtk/fUg3gYRbMs2rq370J9i0Tjhs9/RTEaEBpr06OeaA QccnIteOskDF6MCjrSdXG/LBCS0jtHBNd5g+9zhVMBELqTr8t5nEjorWzfPEdQqvvju1 /nwUzd9YRS6w0Iq8jA/Jt2usYEKUOI8sXAorC5U1N0Kzrc0SsId0yikXVY0QTOiVuOPs KjjXiGlfZh7QydK1e9QhHtGiAOpHq/XdH0bgKESzFBq4KYx8FCZBNa+aZAPev9bNOl05 urZQ== 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=+T1+Qy3MoywAjez6Ef0bmMy71JTW9fUaEucN6MXf9Xc=; b=SNw69mPBHaX7i82tUytEMZTjI6Yix1UskNiApc6IItzYQ16PHVIK+Hyx1/jzK98q0Y TJsQO/PL5MP+/7h3doBRlWy8v12dvr5zafKQq4BAuARKCfc2wzv6iNIevhjPC3+mdY39 o5G8VslLHOpMGVyFawYVmsExJAv0o3yablHn17GjbXx9BUtxwPvmqvmzWejkLDhAk0tU ihl+f7IVQnDuf1v/TFWJFxffFeU/41DsRgnlFBTVlT6cMHzFuG/yCyvd1FfwxyNQHK4f sYW104T93ZYit4skkEZfG8a5AQUOm5++iXwKB5PwvByyNdFLsNsjrFgf4gRSeWm6i4Se ZsIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tWBNMCTH; 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 h25si1182449jam.40.2021.05.02.16.35.50 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 02 May 2021 16:35:51 -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=tWBNMCTH; 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]:54086 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ldLcs-0004DV-H3 for patch@linaro.org; Sun, 02 May 2021 19:35:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37070) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ldLMd-0008Lz-MX for qemu-devel@nongnu.org; Sun, 02 May 2021 19:19:06 -0400 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]:40600) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ldLMb-0002xF-9B for qemu-devel@nongnu.org; Sun, 02 May 2021 19:19:03 -0400 Received: by mail-pj1-x1031.google.com with SMTP id l10-20020a17090a850ab0290155b06f6267so4700332pjn.5 for ; Sun, 02 May 2021 16:19:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=+T1+Qy3MoywAjez6Ef0bmMy71JTW9fUaEucN6MXf9Xc=; b=tWBNMCTHNcU1/pmqgs2oD4oF6MPoTHUel6RgvFpDllUhVcjEsiBYlftsknFFcpTeAX cTl0GQR12zHDo+Jbo6WfJX8qKFan7HQuIMdooU9GFR/G1d1/ljmJtcnxmLh4WbK+xJG1 m3Nr88tyotYXA/HK85uoLD5fA2Aszqsb00iNuwGuNYPkXXYOU7iO9GrBqH4jh+mClwVY 2zo22q/FwK2KsNVICfumYY8SYxAEvRjq3xlj1p3OCpqllfHQmo7kdztnYU/df6fRj2nU 2VEe++WGkQMQ0JOKZ4HsFP1Z3dDizz8wTxinGBP/DvefD7jxrGs45tdGEbFWsJryx95Z NzqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+T1+Qy3MoywAjez6Ef0bmMy71JTW9fUaEucN6MXf9Xc=; b=q3bNr4QsQeXZfpb2UCpoz/2fCPM403nqAR/MPK/ZKof8rHDa9c69mWMh9GBC4FhYEj 9aJVFt+SUuS7J4IBfQFu4SuXrX2QmRXxcGrQ8Fo1vD9Y0yOiK8sYBhPn/AKixHCYUxdb ZGbwFyuO4S0ANYT0tW0gF6uAufZc0EvtoG7JyTX4g/LRA3AAVzgyaY0Pyde+kawpW55o oaCANjWiABVxKot8AnRmSFmTuVhd+rGjoikNcS1ZaxXsK0xjJWH9s7KgeOtBPtzKEheV FEp9MxyHkKsUehouK6DbcI/qFxZrL20jMhNTIhHKqh8cprS7cD1Uy/hYcRtdc7t8tE48 fUhg== X-Gm-Message-State: AOAM531wJWOSVs2SgdzlBAbjxmgI5GL78gL0tR3wSVtMI42P/kcK56bT AARL/V8h9IGLnN6u5om3mQytrErza/TvTg== X-Received: by 2002:a17:90a:e64e:: with SMTP id ep14mr17940878pjb.103.1619997539975; Sun, 02 May 2021 16:18:59 -0700 (PDT) Received: from localhost.localdomain ([71.212.144.24]) by smtp.gmail.com with ESMTPSA id k17sm7146236pfa.68.2021.05.02.16.18.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 May 2021 16:18:59 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 19/28] tcg: Tidy split_cross_256mb Date: Sun, 2 May 2021 16:18:35 -0700 Message-Id: <20210502231844.1977630-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210502231844.1977630-1-richard.henderson@linaro.org> References: <20210502231844.1977630-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1031; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1031.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: , 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 Reviewed-by: Alex Bennée Reviewed-by: Luis Pires diff --git a/tcg/region.c b/tcg/region.c index b44246e1aa..652f328d2c 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 {