From patchwork Wed Mar 24 01:43:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 407787 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp20716jai; Tue, 23 Mar 2021 18:56:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw4XA1dw0ZtAXEYy2GyFhfE3b3feI1sKVP5oCrC2bO22VXY7KCxJzVl+8MXQVx1oQnPvk0u X-Received: by 2002:a02:ccb2:: with SMTP id t18mr762186jap.123.1616550960233; Tue, 23 Mar 2021 18:56:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616550960; cv=none; d=google.com; s=arc-20160816; b=Mq0wAQkVy1Wul8if2qGkWdIQFQUDYpks++pxKiVbhrISJZXLFvAUTV0e1kxu+oe6sS fkoN1FLOEU5H4S/ILgTciTazkrtum+9GpvsZElMOcx7J53H2jUJEILQ7/7zrVkcxDikW 0wZ3Ye8xocC9XrOvlm6/rc6kbToHR3UKkb1EuEDfEjtrlLmCy60li9Pt2QtawC8EO0qc sSUdCRvbwzFPKfa7HGFlDSpKOHUTcTB8cY4ypYReapt6fmf/4x5J6TGjSqCkbxpNtl1+ hKgvMgvKabFO/VtGs8+j8H+cEZSWZSQj0UXzebJudrwk3R09Dezu4GS61QeH97osRCcq ihaw== 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=TRTvaKGiSvx53wjPubAax9jKEnNNfX7W0YfiA8JJ1s4=; b=XRFTPN65GP1GUBjRNW90X2agK+P3EAquPnMpITUHKgKm7AWdJfd3MDpmnFEx6KTUYU V0TAhxKwH3HeSIAB8UEFCWT2lqyN+4A7T4/0THpnzTz/KKS6T6oPFNGfqpJr36zbzXzr FmrAM8xI2XRTsQ+z0Oaw0dniX/yTohV628YVs6uevriiynWf0mXgbzMTDPZpcosElsUd 2YWnuYBN/0R+ZRYM8ya6cZo+2kzMJVb47L/u9scNlgfOOcVk1y/1t1fTCR/S+zYbLpBI 93n0FErZ3wDFNeJkwNrOuEegzVLvqdJmmYgufkh/IYQ5HoqksYPza47k6ZvVtOrF9TtO MSUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=reNos8zT; 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 b24si647245jaq.29.2021.03.23.18.56.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 23 Mar 2021 18:56:00 -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=reNos8zT; 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]:43298 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lOskZ-0006vL-Ma for patch@linaro.org; Tue, 23 Mar 2021 21:55:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38604) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOsYp-0005z9-ND for qemu-devel@nongnu.org; Tue, 23 Mar 2021 21:43:51 -0400 Received: from mail-oi1-x22c.google.com ([2607:f8b0:4864:20::22c]:45046) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lOsYa-0005ia-5R for qemu-devel@nongnu.org; Tue, 23 Mar 2021 21:43:48 -0400 Received: by mail-oi1-x22c.google.com with SMTP id a8so19178506oic.11 for ; Tue, 23 Mar 2021 18:43:35 -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=TRTvaKGiSvx53wjPubAax9jKEnNNfX7W0YfiA8JJ1s4=; b=reNos8zTfIQ7Vp9FIn5NP3C46v/nl4ex9Wkm9oek5TMp8Xmt0174cF2NbcN3ORPIIU 7eyuA1bb+Dxsrh1zJhaiordqcu4O6AcVo7SAcqNC+oaURKxhtNwguszLxfwL8lv5MyJn EaQkFX9uPk4qiI9hYZf6OTfhR8ApINQLSvPjAAhGEZW5Q/QXdxmK3GBIh28Wpz30TZYA x5AU+V2F4VUqCEcaTAlNKY21BDTPoIYlT5mtzdrUVCU3T600iI8FlufaC9Sty9aplFUE AmhHd8g7sv9wJXTQDHL6TPFh8QRvmUnvlTe8dYbiD8T+DoL+ndt/AqqCDamBj4dybdW+ w95g== 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=TRTvaKGiSvx53wjPubAax9jKEnNNfX7W0YfiA8JJ1s4=; b=jyna/sWlYNq64NwxkgAfhDNfUCOJ33KLSuNQpU6oXx/CH4G1Sy+tGQH9AXrzljXgpa 67frrQueXl/9cD3pf3a/GmC9iWMSfgtmp+ahbr4sDcoDykowqJ9wF22eKHMR0YU9ELqX a/UDMW387cKUVn0lI60Ea7BPqheBAfygelS+Phxi5R6Iu60Ya+5HafTRJXbOzAktU8u3 /D1EuRlt702/z+MshvbKtWzDK8EWI9VYxbxRuzfupqkLonN3ZpV2e35vNAO1lkIRkpqF iQXZCU9nyaH5/8QkcLsQxtJca21O5Kw5C1F9d4D3pBoLh28aWEtFYuU81ZxF7Apcxw47 rdnQ== X-Gm-Message-State: AOAM530A05GtWFt0eODqLDZVEZl8fXUmXbOcft8F4iUg5IdFaVtNkqP2 71YrxeGT0PQxy97h2HJJc5I1+5CW2w4pHPfY X-Received: by 2002:aca:2103:: with SMTP id 3mr706767oiz.80.1616550214907; Tue, 23 Mar 2021 18:43:34 -0700 (PDT) Received: from localhost.localdomain (168.189-204-159.bestelclientes.com.mx. [189.204.159.168]) by smtp.gmail.com with ESMTPSA id c9sm203601ooq.31.2021.03.23.18.43.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Mar 2021 18:43:34 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 1/5] tcg: Do not set guard pages on the rx portion of code_gen_buffer Date: Tue, 23 Mar 2021 19:43:28 -0600 Message-Id: <20210324014332.6331-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210324014332.6331-1-richard.henderson@linaro.org> References: <20210324014332.6331-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::22c; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x22c.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=unavailable 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, Roman Bolshakov Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The rw portion of the buffer is the only one in which overruns can be generated. Allow the rx portion to be more completely covered by huge pages. Signed-off-by: Richard Henderson Tested-by: Roman Bolshakov Reviewed-by: Roman Bolshakov Message-Id: <20210320165720.1813545-2-richard.henderson@linaro.org> --- tcg/tcg.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) -- 2.25.1 diff --git a/tcg/tcg.c b/tcg/tcg.c index de91bb6e9e..88c9e6f8a4 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -828,7 +828,6 @@ void tcg_region_init(void) size_t region_size; size_t n_regions; size_t i; - uintptr_t splitwx_diff; n_regions = tcg_n_regions(); @@ -858,8 +857,11 @@ void tcg_region_init(void) /* account for that last guard page */ region.end -= page_size; - /* set guard pages */ - splitwx_diff = tcg_splitwx_diff; + /* + * Set guard pages in the rw buffer, as that's the one into which + * buffer overruns could occur. Do not set guard pages in the rx + * buffer -- let that one use hugepages throughout. + */ for (i = 0; i < region.n; i++) { void *start, *end; int rc; @@ -867,10 +869,6 @@ void tcg_region_init(void) tcg_region_bounds(i, &start, &end); rc = qemu_mprotect_none(end, page_size); g_assert(!rc); - if (splitwx_diff) { - rc = qemu_mprotect_none(end + splitwx_diff, page_size); - g_assert(!rc); - } } tcg_region_trees_init();