From nobody Wed May 1 17:59:00 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1616551017; cv=none; d=zohomail.com; s=zohoarc; b=Opv2F1bKS7Gd6xyk+V0nowcut7aPOeoqH0m69bPYwda59mbvFBgX0FN0HMXyXxfzHGCUSIWUqVjiY/5ToilzX7OtkfdcYXrt/nn/jrq+7YBt17W0bUKsKzjT2OhkrNBgOFKI62TxwgXsh08Jjq3RtAu/QsH4yUh80mBM8ff2edg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616551017; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=TRTvaKGiSvx53wjPubAax9jKEnNNfX7W0YfiA8JJ1s4=; b=SLenEI29U4VweMEuIbzIpLawXvLJppWKn9b3jkHw4bQ4q9u03MUOTkeAktMZtosza5bOhRkMfMssWZSH1RetnNHQkhiYjF0vsFeU95W7eZr7ykntQbXMRA7sbt6ysiAmLumBG4Bc5nvCj+z3I7XlScL1XEe+D8s54rFKdZcwhII= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616551017457851.7574698632276; Tue, 23 Mar 2021 18:56:57 -0700 (PDT) Received: from localhost ([::1]:45494 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lOslT-0007sF-B3 for importer@patchew.org; Tue, 23 Mar 2021 21:56:55 -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) 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) 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-Google-Smtp-Source: ABdhPJxrJfHZRLitvQc5Wkywmo+KIzExJeRnLl2yaPh/ny9MrRbccIGqopIThcvawpWqc/Al+VPbZw== X-Received: by 2002:aca:2103:: with SMTP id 3mr706767oiz.80.1616550214907; 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" 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(-) 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; =20 n_regions =3D tcg_n_regions(); =20 @@ -858,8 +857,11 @@ void tcg_region_init(void) /* account for that last guard page */ region.end -=3D page_size; =20 - /* set guard pages */ - splitwx_diff =3D 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 =3D 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 =3D qemu_mprotect_none(end, page_size); g_assert(!rc); - if (splitwx_diff) { - rc =3D qemu_mprotect_none(end + splitwx_diff, page_size); - g_assert(!rc); - } } =20 tcg_region_trees_init(); --=20 2.25.1 From nobody Wed May 1 17:59:00 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1616550881; cv=none; d=zohomail.com; s=zohoarc; b=cAuuyMJ2JMVqfdFhlD3TJeIok6+mZKJHsVzwX7yB6dQdn5GUvmg2EummkM3yxgeMeB4ZkSMzo28vLqUR49JlDdHIqRgGpyUv4VjDADctm5m9ZYlo67hFyEu2Z3w2pELJb3WVo6WAFrBvjaQ5JPEfamhjtDQlfRSEkU/0/5uTLZM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616550881; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=DsSc9dreF6wvzxcw7uDCKMSE3jEvXRT6fQS54ICyVMQ=; b=hTKOt69u47dMaH2LImzgb9vIUQfMxrHUjktA+DnmO2Hy8IekDDkCCsS1DrYK7Iei4B+LgTp5yJC+EYWClVy1ccCeOmxm4uo9Bvwd4Mc/jSjYfqx+zS6RgcOCEJeuEjBegz1hmlMvUAeiBl5fSPGuZNUUQjks0yyG3VWkcwvSzTw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616550881548607.280079133355; Tue, 23 Mar 2021 18:54:41 -0700 (PDT) Received: from localhost ([::1]:40724 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lOsjH-0005r0-75 for importer@patchew.org; Tue, 23 Mar 2021 21:54:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38582) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOsYl-0005xL-RW for qemu-devel@nongnu.org; Tue, 23 Mar 2021 21:43:49 -0400 Received: from mail-oo1-xc35.google.com ([2607:f8b0:4864:20::c35]:42558) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lOsYb-0005if-SX for qemu-devel@nongnu.org; Tue, 23 Mar 2021 21:43:45 -0400 Received: by mail-oo1-xc35.google.com with SMTP id h3-20020a4ae8c30000b02901b68b39e2d3so5430782ooe.9 for ; Tue, 23 Mar 2021 18:43:36 -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.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); 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=DsSc9dreF6wvzxcw7uDCKMSE3jEvXRT6fQS54ICyVMQ=; b=T5qC0n9bxBGVWypiYHvESuCH1PHIqjSyxIF5fx4XGmlLmF5Jd8/iA+P+PF3zSyn5TA V9IId+sDI3JxGbrw/QyaN9XjINMc3c+uStWVndiZHx7BvA1Kq0svS8qawxS5DUoAOZiw ukhdp1jbCjQV9aQ2qLf1bibWF0r5gvyD7YqMucRDhIk7dFUQzbg90Og777y6L7P3iWKr M0yYWJqUvgXW5MjvpsJM+NPIApBuL6ADn5aXLvMLJk+5iLInJTlTd5geJAcfaA7Vvyrk y7XoHXPTvniw0nVDSRZBuSJ465WfhrHfyK5/yQCVHRyrub+gzS4panKUisI7kfsx1S1d jHPA== 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=DsSc9dreF6wvzxcw7uDCKMSE3jEvXRT6fQS54ICyVMQ=; b=Lia7KV9YyugDdC2W8B1LVXYLITbSsZSFKkbq6PzBDB2F1MGGlFmyztLUTie01/SRIW fRvJgc8FGgqX4Cj0T1JeC4YS2xX1qnE2yZYLydlSJOhkzlMB4GsFZEZBPOfH4/RExuWZ 8CmRi5GLj5yuJErye2k5+qalilNcbnOCNw86iy+8ogRnG00s+zqYzPJt0ZH2dkpwg528 SYNSTEjUguWgifAkRn1iz5CRtp6IerE02XYA+YDOJB7nULX5BxP0D5VfXv/kLDgVD8au wcqj0RkSAmrR3ZaJ/90VwVGZXlveXz7OQ1CoYh/CDrCzhRAz9lomeVkikv3jj0Co3ZP0 RPGQ== X-Gm-Message-State: AOAM531WZewlepSl3DRFn+MxaCq58GAiZYPcR6SZFsLvYa0ls0cIWjFO ni1EVfF8bhl/I+Eviz7zH98ctzpcxPKuueHp X-Google-Smtp-Source: ABdhPJyq0wsdCDBmMpVtFeSx/KnHOwC0dBstCQRMQrUXJ8on5GMUmptd1a/1ciXbojyVZafveaUsjw== X-Received: by 2002:a4a:6b44:: with SMTP id h4mr701736oof.38.1616550215886; Tue, 23 Mar 2021 18:43:35 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 2/5] tcg: Workaround macOS 11.2 mprotect bug Date: Tue, 23 Mar 2021 19:43:29 -0600 Message-Id: <20210324014332.6331-3-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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::c35; envelope-from=richard.henderson@linaro.org; helo=mail-oo1-xc35.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, Roman Bolshakov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" There's a change in mprotect() behaviour [1] in the latest macOS on M1 and it's not yet clear if it's going to be fixed by Apple. As a short-term fix, ignore failures setting up the guard pages. [1] https://gist.github.com/hikalium/75ae822466ee4da13cbbe486498a191f Signed-off-by: Richard Henderson Tested-by: Roman Bolshakov Reviewed-by: Roman Bolshakov Buglink: https://bugs.launchpad.net/qemu/+bug/1914849 Message-Id: <20210320165720.1813545-3-richard.henderson@linaro.org> --- tcg/tcg.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tcg/tcg.c b/tcg/tcg.c index 88c9e6f8a4..1fbe0b686d 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -864,11 +864,15 @@ void tcg_region_init(void) */ for (i =3D 0; i < region.n; i++) { void *start, *end; - int rc; =20 tcg_region_bounds(i, &start, &end); - rc =3D qemu_mprotect_none(end, page_size); - g_assert(!rc); + + /* + * macOS 11.2 has a bug (Apple Feedback FB8994773) in which mprote= ct + * rejects a permission change from RWX -> NONE. Guard pages are + * nice for bug detection but are not essential; ignore any failur= e. + */ + (void)qemu_mprotect_none(end, page_size); } =20 tcg_region_trees_init(); --=20 2.25.1 From nobody Wed May 1 17:59:00 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1616550425; cv=none; d=zohomail.com; s=zohoarc; b=L91FzlCmD+qAa4O/hqzzxH2zf/BUXfIQbCKf8G0Q0eWsTvI4V8idIA3Il+QZ1QXinxKciFemWr7ScpA7F179VjnBSQz/WLg2qZBwOCi39prv9SlyGhEq7bXwuZ2UBA3W9BZITS/5jiq0ntAJXYKk38nkC2Q0WOQ9soXmBmKbLcE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616550425; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=0e93t7AcpX0MjpVEUPJ+qK951VVe9n5DKhcqYQAAQ+4=; b=dzRpHQ+wpoBFmu5oRKgGBOdefM2yTaxOOwbGStnFTq1+a1yShCG5cfQusQqTrx42plobphQL8HZlPVexQuXtIoA5xodh3zrba4bbLQtvLaigEsqbur7dfNc+41/fXk0q9LBZNw6atPc2/w/mU3Zmmw2S0bndBZuKgc0AXZmnaCM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616550425489222.13066209439728; Tue, 23 Mar 2021 18:47:05 -0700 (PDT) Received: from localhost ([::1]:53512 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lOsbw-0007iv-9k for importer@patchew.org; Tue, 23 Mar 2021 21:47:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38564) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOsYi-0005vd-0D for qemu-devel@nongnu.org; Tue, 23 Mar 2021 21:43:44 -0400 Received: from mail-oi1-x230.google.com ([2607:f8b0:4864:20::230]:36681) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lOsYd-0005jM-OF for qemu-devel@nongnu.org; Tue, 23 Mar 2021 21:43:43 -0400 Received: by mail-oi1-x230.google.com with SMTP id c16so10304113oib.3 for ; Tue, 23 Mar 2021 18:43:37 -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.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Mar 2021 18:43:36 -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=0e93t7AcpX0MjpVEUPJ+qK951VVe9n5DKhcqYQAAQ+4=; b=ckMQQ3HFhr+elAIS1qIUVUMpiwJLmburz5CjITSwDDix6ocT7D0ZoI+vt3FSE0Flyr okcEAEgHBz8NgdqNe+TmPA5O//9YbcXyeMrUobDUvHRhUpAcFsute9mzqUSU/NuZezCa 0b3vygxVQyRRGQrHBa0IEDQG28DzOcnk+voI+D8J6ZvDs0HPPtmLdeEQo0ihUQmMshc+ xPwL70EcXNgeMBn7h+DRKb4vC/MzorVsJWqLvj914MuDJUvlP/glHamooosqhC9fHvaU 1e59XdR6iQCX9gY4Q0i6u0Zwcj4vOdW8XFj31h/Rz5s5aPANfxaa8Sln72ThNjkaU2m3 ypMw== 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=0e93t7AcpX0MjpVEUPJ+qK951VVe9n5DKhcqYQAAQ+4=; b=VkPAygWB5Cbtk/ydFrGUCX3WdFCceAlao0NV4ADeq8WX3U/HOwTVwn9GyupHuYYGwv uilOYvf0VXB+mBeagPEBBza7GTLniy2fJUbeve16EK3CW6WR+jSyHQ7RloVRS8qvAtZE YOVEPVtxrb4WpN87pSMyEAf3o9CJdqSkkNoqqKXzRrsEKF+ZpgzxMZmwbUsZkpQ6joGb tdBVN/ICP0qw+HkfehVjlefY3Gu6prkVicIeKQkf4Sz3VjGYdJkM21vBLQef5KfZdoaP mZwgZZgjJbQj32f02D1pbjhlM4s0xsxVpuBECcJWDrcqqZ4eYtFyKQKuRFBbXLE5Jpdk BoFg== X-Gm-Message-State: AOAM531GnfCF9NEh++S30vaGJUWcI7ny3Tj9+xQBECpwx2if/dex3moU X0AKLHkKEIfWDBclf/D/hPi1gjJaK1caKgVP X-Google-Smtp-Source: ABdhPJzGBNqVS9RR2Z38R6X3oxfEzVd5xiRyHiWRvJQQmKNkODfQGzYBt/6rrPPmGfI02AekVNFnOQ== X-Received: by 2002:aca:2104:: with SMTP id 4mr713558oiz.124.1616550216942; Tue, 23 Mar 2021 18:43:36 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 3/5] exec: Rename exec-vary.c as page-vary.c Date: Tue, 23 Mar 2021 19:43:30 -0600 Message-Id: <20210324014332.6331-4-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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::230; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x230.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=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) exec-vary.c is about variable page size handling, rename it page-vary.c. Currently this file is target specific (built once for each target), comment this. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20210322112427.4045204-2-f4bug@amsat.org> [rth: Update MAINTAINERS] Signed-off-by: Richard Henderson --- meson.build | 3 ++- exec-vary.c =3D> page-vary.c | 2 +- MAINTAINERS | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) rename exec-vary.c =3D> page-vary.c (98%) diff --git a/meson.build b/meson.build index 5c85a15364..f0dd8aa089 100644 --- a/meson.build +++ b/meson.build @@ -1933,7 +1933,6 @@ subdir('softmmu') =20 common_ss.add(capstone) specific_ss.add(files('cpu.c', 'disas.c', 'gdbstub.c'), capstone) -specific_ss.add(files('exec-vary.c')) specific_ss.add(when: 'CONFIG_TCG', if_true: files( 'fpu/softfloat.c', 'tcg/optimize.c', @@ -1945,6 +1944,8 @@ specific_ss.add(when: 'CONFIG_TCG', if_true: files( )) specific_ss.add(when: 'CONFIG_TCG_INTERPRETER', if_true: files('tcg/tci.c'= )) =20 +specific_ss.add(files('page-vary.c')) + subdir('backends') subdir('disas') subdir('migration') diff --git a/exec-vary.c b/page-vary.c similarity index 98% rename from exec-vary.c rename to page-vary.c index a603b1b433..344f9fcf76 100644 --- a/exec-vary.c +++ b/page-vary.c @@ -1,5 +1,5 @@ /* - * Variable page size handling + * Variable page size handling -- target specific part. * * Copyright (c) 2003 Fabrice Bellard * diff --git a/MAINTAINERS b/MAINTAINERS index 9147e9a429..ed68de3cec 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -117,6 +117,7 @@ R: Paolo Bonzini S: Maintained F: softmmu/cpus.c F: cpus-common.c +F: page-vary.c F: accel/tcg/ F: accel/stubs/tcg-stub.c F: util/cacheinfo.c --=20 2.25.1 From nobody Wed May 1 17:59:00 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1616550597; cv=none; d=zohomail.com; s=zohoarc; b=GsvTcw+KpMiuYfoRnU7Btd6T4FDx/+/8OjtT22SGWihUgguSw0g3J+LIBceodM38Z2/HRjwRORd/enSwRbeyO00lxR3CyPFGCZbXDhyF6LRfQKt4bKGh3VlBkqtLRJLKqg4X2GMtMCKLEkUmBPrhvUfPGrEN2f03F11YHK1TqpQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616550597; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=NbPfp2/HarteDkEoK6vgLYJvIbLA4R8fYVtBiQeWrMA=; b=MVMJkqYdy+tEfG5ER+TfUFgJoTjUO/XOUM6qUj/Hh08hkqP09ZEm/Ayzn33kkjGVXHlMXtvel5gtY6LifBQ6+yIdwTr2+WnlS447UPdpo5XrVeUYiyL+Zgd28mvzRcknkdqsJecuIIfyr8IBIWyii/EewZcsCRYeIj6MG+rxbH8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616550597000524.4260700125748; Tue, 23 Mar 2021 18:49:57 -0700 (PDT) Received: from localhost ([::1]:59868 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lOseg-0001zp-Uj for importer@patchew.org; Tue, 23 Mar 2021 21:49:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38586) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOsYl-0005xe-TK for qemu-devel@nongnu.org; Tue, 23 Mar 2021 21:43:49 -0400 Received: from mail-oi1-x22f.google.com ([2607:f8b0:4864:20::22f]:38577) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lOsYd-0005je-PV for qemu-devel@nongnu.org; Tue, 23 Mar 2021 21:43:47 -0400 Received: by mail-oi1-x22f.google.com with SMTP id f9so19194392oiw.5 for ; Tue, 23 Mar 2021 18:43:38 -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.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Mar 2021 18:43:37 -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=NbPfp2/HarteDkEoK6vgLYJvIbLA4R8fYVtBiQeWrMA=; b=CBsldl65VrNqA3HV3AryVPc8Knfy9N/Ul6+L8PpjECXw14NTsAQn7uJZgvgdbgY0o8 zPBkXo232jm7DwZLah+RubrvqRWx+5jEfuM6JwTICZrXXJo3k0s68YYBwC7h/XVsiQdJ pYYybCDXJLgAxYaHR6VLtcMwnw2AFMw/UT56oRrK4JtMgySgzGokkjEjSR982vF0DMH6 jKV/voifyqc/eXihp1rk3rhXNmdMW9/ZKjV1XBQ9Jp0W2XE8XPyPhsk59dV0sbrWhLJ0 VRwe6HMq+R60U3vh0xZGTP00wqZ7v7KpHxz/8ib04H/2irp83HTsKK2TrZvme6qePirA UKig== 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=NbPfp2/HarteDkEoK6vgLYJvIbLA4R8fYVtBiQeWrMA=; b=qzlIToUXQY8K9zkfWFRLYV3WB1vFMILr7eDU9qThAdAr26Z/nXJkBEUeMvRmvvc/2a VN6kofU6wAFlwLxABXj8T1VVV2Mfsu9EjDT3kGPCwHDgvdoDnyRntvID3xI2xqvDmt/f 9Xi7cOYGc3lZS6CqwOK1zA3cWFjj7aSqOBsT9rIegRmOqZpQoLriV/CZqZaxbRxAaFCn Yd9v/YgllfoyBAH4/H3DNQtieMiyuYPHQc7GskkezkREpp/iJYg3wfWo/hJtC5u5JhmS BocbtRaMAQLM15keoY9HXxl+MScy82HUnlUhEetfylffhXaPRrIsj2I/9RNJFs/iEITk 44Ew== X-Gm-Message-State: AOAM531G18MxT9Wz1kw+SALOWXTXaBlYZ3AJQZXF/C4qn7aLAcIxUrMf Cwhp8wo14X+OewiN0u8ag2arU+XCPXFyxAlk X-Google-Smtp-Source: ABdhPJx/EHdmD8sMrMibRoibr20yoKKWnh38j/zzq/MTAVpET9BSQaGcKjebvW2L9ws3XClPd82o9Q== X-Received: by 2002:aca:4b03:: with SMTP id y3mr755120oia.78.1616550217935; Tue, 23 Mar 2021 18:43:37 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 4/5] exec: Extract 'page-vary.h' header Date: Tue, 23 Mar 2021 19:43:31 -0600 Message-Id: <20210324014332.6331-5-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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::22f; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x22f.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=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) In the next commit we will extract the generic code out of page-vary.c, only keeping the target specific code. Both files will use the same TargetPageBits structure, so make its declaration in a shared header. As the common header can not use target specific types, use a uint64_t to hold the page mask value, and add a cast back to target_long in the TARGET_PAGE_MASK definitions. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20210322112427.4045204-3-f4bug@amsat.org> Signed-off-by: Richard Henderson --- include/exec/cpu-all.h | 11 ++++------- include/exec/page-vary.h | 29 +++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 7 deletions(-) create mode 100644 include/exec/page-vary.h diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index 76443eb11d..b0a422c7b6 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -215,11 +215,7 @@ static inline void stl_phys_notdirty(AddressSpace *as,= hwaddr addr, uint32_t val /* page related stuff */ =20 #ifdef TARGET_PAGE_BITS_VARY -typedef struct { - bool decided; - int bits; - target_long mask; -} TargetPageBits; +# include "exec/page-vary.h" #if defined(CONFIG_ATTRIBUTE_ALIAS) || !defined(IN_EXEC_VARY) extern const TargetPageBits target_page; #else @@ -227,10 +223,11 @@ extern TargetPageBits target_page; #endif #ifdef CONFIG_DEBUG_TCG #define TARGET_PAGE_BITS ({ assert(target_page.decided); target_page.bit= s; }) -#define TARGET_PAGE_MASK ({ assert(target_page.decided); target_page.mas= k; }) +#define TARGET_PAGE_MASK ({ assert(target_page.decided); \ + (target_long)target_page.mask; }) #else #define TARGET_PAGE_BITS target_page.bits -#define TARGET_PAGE_MASK target_page.mask +#define TARGET_PAGE_MASK ((target_long)target_page.mask) #endif #define TARGET_PAGE_SIZE (-(int)TARGET_PAGE_MASK) #else diff --git a/include/exec/page-vary.h b/include/exec/page-vary.h new file mode 100644 index 0000000000..799d6310d6 --- /dev/null +++ b/include/exec/page-vary.h @@ -0,0 +1,29 @@ +/* + * Definitions for cpus with variable page sizes. + * + * Copyright (c) 2003 Fabrice Bellard + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +#ifndef EXEC_PAGE_VARY_H +#define EXEC_PAGE_VARY_H + +typedef struct { + bool decided; + int bits; + uint64_t mask; +} TargetPageBits; + +#endif /* EXEC_PAGE_VARY_H */ --=20 2.25.1 From nobody Wed May 1 17:59:00 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1616550649; cv=none; d=zohomail.com; s=zohoarc; b=F2YfzpLsC/Q8acnOpojRZzrWNnX5iJulTlv8liyaOSSVTmsSPOAVNUQN8txmgUQmGNNbRb2EO9A3EM7L00Kr0zza4j66d/ue+85Aykxr/foMsx8hXOkqJeEUlHFTRpVcjmKk2XHTBhOt++ctwhjEXcYN/9W0pHcoOkmGE/zZpEs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616550649; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=fWgqA9QIHHI+TQJjaLupeuAekMYMAEES1TIcXaDxulI=; b=Jd6rCQ29CwFSUzowmq8z/EhaUNeF9qP0zuSz2QIqYdOTiupxNcCJfHkLjhM8PfQ42FAd8aXDbvKtAt+gQCgL6hWUsLVXSCTUsTOQHj4J5ueBawqjDin2kprgLDXrmCsKa9iLLhYjMAU0RnUlXV4FOqHwH3UFh70fMOBm04SCFOI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616550649287813.4231159233698; Tue, 23 Mar 2021 18:50:49 -0700 (PDT) Received: from localhost ([::1]:33048 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lOsfW-0002cl-RC for importer@patchew.org; Tue, 23 Mar 2021 21:50:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38602) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOsYp-0005z8-N3 for qemu-devel@nongnu.org; Tue, 23 Mar 2021 21:43:51 -0400 Received: from mail-oi1-x235.google.com ([2607:f8b0:4864:20::235]:33409) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lOsYf-0005kQ-PH for qemu-devel@nongnu.org; Tue, 23 Mar 2021 21:43:51 -0400 Received: by mail-oi1-x235.google.com with SMTP id w70so19186863oie.0 for ; Tue, 23 Mar 2021 18:43:39 -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.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Mar 2021 18:43:38 -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=fWgqA9QIHHI+TQJjaLupeuAekMYMAEES1TIcXaDxulI=; b=U0jyxp0HdCFGy53Ex1+VMHt0OZTkP7ps2lXbKLUr+CukYmDa/wiThSPJ6L88xMlSSd 68EDLYzopg2l/uuYFrUv/ef0wqf1hpqNISddCWg/Tpuh5/rrtULb/D4ckJWcJf753IoX eP68ZzOdOD3UWGfCgyM8Q0JEijZT6J+xHaOFjBJWJVuqLCOm2VaZhmiiRDgxilDvYUOn 25imMZR0XwliJkUyrMlI7HocPfCNRj9SkAnl1EgAQ1bRq3Dbnh9j3BvdZGTUTT3WR30B TOhgwmAzMe3JXEdKV02q6TrdOzat34xoeutFetCF74zFrfiW+LrgI/gZJAI5/U7D1hql qMww== 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=fWgqA9QIHHI+TQJjaLupeuAekMYMAEES1TIcXaDxulI=; b=U8t9phlADRWPf/hLVy3VhD1pcjOoSUHW4K8sjlpUuJ0SquvHYOtx0ysdaaCt5hcAGV yGTEIb5iw9Zsd0WH7jBSOdjUD7cxs4JwRA0kIoNs2H+V5Yaf3ki/l3hStgJAtC//mUnl qPDvXFzacHYtwX+R09Da0DwrMDH6ufk/V+Cs2T/X1viYk3JsDX/Z80pJwyYUqSs3mUgT 4JcNZtfRr8j25C39OUYcSvllXQthmjBRoaKtTXndO1Sh/0Z2B71bB/yartgcj78toLfc +9QCQzsUO8Ycwtys3rQ9+a3GDfpkKqNhaRrCkcMnPbC087HE3G5YA6HYjNl1dKd8ye9V PF0A== X-Gm-Message-State: AOAM5310jUUfQBUJmytQD61f7nPkbX2fdWXu1sRBWwuHcTuK2gcni5c7 SNHMoOEFbUzelBoqD/Iw1lQaAPTAKDZjh0Im X-Google-Smtp-Source: ABdhPJwlJm3/FhgYzM4lq6BPwT4BJVnTO+cQdbIhJ8Al+b2smikfuuw+Q+oUvVQq8iNRb9eP/Qk3hA== X-Received: by 2002:aca:b446:: with SMTP id d67mr736255oif.6.1616550218985; Tue, 23 Mar 2021 18:43:38 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 5/5] exec: Build page-vary-common.c with -fno-lto Date: Tue, 23 Mar 2021 19:43:32 -0600 Message-Id: <20210324014332.6331-6-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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::235; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x235.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, Gavin Shan , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) In bbc17caf81f, we used an alias attribute to allow target_page to be declared const, and yet be initialized late. This fails when using LTO with several versions of gcc. The compiler looks through the alias and decides that the const variable is statically initialized to zero, then propagates that zero to many uses of the variable. This can be avoided by compiling one object file with -fno-lto. In this way, any initializer cannot be seen, and the constant propagation does not occur. Since we are certain to have this separate compilation unit, we can drop the alias attribute as well. We simply have differing declarations for target_page in different compilation units. Drop the use of init_target_page, and drop the configure detection for CONFIG_ATTRIBUTE_ALIAS. In order to change the compilation flags for a file with meson, we must use a static_library. This runs into specific_ss, where we would need to create many static_library instances. Fix this by splitting page-vary.c: the page-vary-common.c part is compiled once as a static_library, while the page-vary.c part is left in specific_ss in order to handle the target-specific value of TARGET_PAGE_BITS_MIN. Reported-by: Gavin Shan Signed-off-by: Richard Henderson Message-Id: <20210321211534.2101231-1-richard.henderson@linaro.org> [PMD: Fix typo in subject, split original patch in 3] Signed-off-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Gavin Shan Message-Id: <20210322112427.4045204-4-f4bug@amsat.org> [rth: Update MAINTAINERS] Signed-off-by: Richard Henderson --- configure | 19 ---------- meson.build | 18 +++++++++ include/exec/cpu-all.h | 4 -- include/exec/page-vary.h | 5 +++ page-vary-common.c | 54 +++++++++++++++++++++++++++ page-vary.c | 79 +++------------------------------------- MAINTAINERS | 1 + 7 files changed, 84 insertions(+), 96 deletions(-) create mode 100644 page-vary-common.c diff --git a/configure b/configure index 61872096a8..edf9dc8985 100755 --- a/configure +++ b/configure @@ -4889,21 +4889,6 @@ if test "$plugins" =3D "yes" && "for this purpose. You can't build with --static." fi =20 -######################################## -# See if __attribute__((alias)) is supported. -# This false for Xcode 9, but has been remedied for Xcode 10. -# Unfortunately, travis uses Xcode 9 by default. - -attralias=3Dno -cat > $TMPC << EOF -int x =3D 1; -extern const int y __attribute__((alias("x"))); -int main(void) { return 0; } -EOF -if compile_prog "" "" ; then - attralias=3Dyes -fi - ######################################## # check if getauxval is available. =20 @@ -5935,10 +5920,6 @@ if test "$atomic64" =3D "yes" ; then echo "CONFIG_ATOMIC64=3Dy" >> $config_host_mak fi =20 -if test "$attralias" =3D "yes" ; then - echo "CONFIG_ATTRIBUTE_ALIAS=3Dy" >> $config_host_mak -fi - if test "$getauxval" =3D "yes" ; then echo "CONFIG_GETAUXVAL=3Dy" >> $config_host_mak fi diff --git a/meson.build b/meson.build index f0dd8aa089..c6f4b0cf5e 100644 --- a/meson.build +++ b/meson.build @@ -1944,6 +1944,24 @@ specific_ss.add(when: 'CONFIG_TCG', if_true: files( )) specific_ss.add(when: 'CONFIG_TCG_INTERPRETER', if_true: files('tcg/tci.c'= )) =20 +# Work around a gcc bug/misfeature wherein constant propagation looks +# through an alias: +# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99696 +# to guess that a const variable is always zero. Without lto, this is +# impossible, as the alias is restricted to page-vary-common.c. Indeed, +# without lto, not even the alias is required -- we simply use different +# declarations in different compilation units. +pagevary =3D files('page-vary-common.c') +if get_option('b_lto') + pagevary_flags =3D ['-fno-lto'] + if get_option('cfi') + pagevary_flags +=3D '-fno-sanitize=3Dcfi-icall' + endif + pagevary =3D static_library('page-vary-common', sources: pagevary, + c_args: pagevary_flags) + pagevary =3D declare_dependency(link_with: pagevary) +endif +common_ss.add(pagevary) specific_ss.add(files('page-vary.c')) =20 subdir('backends') diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index b0a422c7b6..d76b0b9e02 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -216,11 +216,7 @@ static inline void stl_phys_notdirty(AddressSpace *as,= hwaddr addr, uint32_t val =20 #ifdef TARGET_PAGE_BITS_VARY # include "exec/page-vary.h" -#if defined(CONFIG_ATTRIBUTE_ALIAS) || !defined(IN_EXEC_VARY) extern const TargetPageBits target_page; -#else -extern TargetPageBits target_page; -#endif #ifdef CONFIG_DEBUG_TCG #define TARGET_PAGE_BITS ({ assert(target_page.decided); target_page.bit= s; }) #define TARGET_PAGE_MASK ({ assert(target_page.decided); \ diff --git a/include/exec/page-vary.h b/include/exec/page-vary.h index 799d6310d6..c22a7a742e 100644 --- a/include/exec/page-vary.h +++ b/include/exec/page-vary.h @@ -26,4 +26,9 @@ typedef struct { uint64_t mask; } TargetPageBits; =20 +#ifdef IN_PAGE_VARY +extern bool set_preferred_target_page_bits_common(int bits); +extern void finalize_target_page_bits_common(int min); +#endif + #endif /* EXEC_PAGE_VARY_H */ diff --git a/page-vary-common.c b/page-vary-common.c new file mode 100644 index 0000000000..9175556498 --- /dev/null +++ b/page-vary-common.c @@ -0,0 +1,54 @@ +/* + * Variable page size handling -- target independent part. + * + * Copyright (c) 2003 Fabrice Bellard + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +#define IN_PAGE_VARY 1 + +#include "qemu/osdep.h" +#include "qemu-common.h" +#include "exec/page-vary.h" + +/* WARNING: This file must *not* be complied with -flto. */ + +TargetPageBits target_page; + +bool set_preferred_target_page_bits_common(int bits) +{ + /* + * The target page size is the lowest common denominator for all + * the CPUs in the system, so we can only make it smaller, never + * larger. And we can't make it smaller once we've committed to + * a particular size. + */ + if (target_page.bits =3D=3D 0 || target_page.bits > bits) { + if (target_page.decided) { + return false; + } + target_page.bits =3D bits; + } + return true; +} + +void finalize_target_page_bits_common(int min) +{ + if (target_page.bits =3D=3D 0) { + target_page.bits =3D min; + } + target_page.mask =3D -1ull << target_page.bits; + target_page.decided =3D true; +} diff --git a/page-vary.c b/page-vary.c index 344f9fcf76..057c7f1815 100644 --- a/page-vary.c +++ b/page-vary.c @@ -17,92 +17,25 @@ * License along with this library; if not, see . */ =20 +#define IN_PAGE_VARY 1 + #include "qemu/osdep.h" #include "qemu-common.h" - -#define IN_EXEC_VARY 1 - #include "exec/exec-all.h" =20 -#ifdef TARGET_PAGE_BITS_VARY -# ifdef CONFIG_ATTRIBUTE_ALIAS -/* - * We want to declare the "target_page" variable as const, which tells - * the compiler that it can cache any value that it reads across calls. - * This avoids multiple assertions and multiple reads within any one user. - * - * This works because we finish initializing the data before we ever read - * from the "target_page" symbol. - * - * This also requires that we have a non-constant symbol by which we can - * perform the actual initialization, and which forces the data to be - * allocated within writable memory. Thus "init_target_page", and we use - * that symbol exclusively in the two functions that initialize this value. - * - * The "target_page" symbol is created as an alias of "init_target_page". - */ -static TargetPageBits init_target_page; - -/* - * Note that this is *not* a redundant decl, this is the definition of - * the "target_page" symbol. The syntax for this definition requires - * the use of the extern keyword. This seems to be a GCC bug in - * either the syntax for the alias attribute or in -Wredundant-decls. - * - * See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D91765 - */ -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wredundant-decls" - -extern const TargetPageBits target_page - __attribute__((alias("init_target_page"))); - -# pragma GCC diagnostic pop -# else -/* - * When aliases are not supported then we force two different declarations, - * by way of suppressing the header declaration with IN_EXEC_VARY. - * We assume that on such an old compiler, LTO cannot be used, and so the - * compiler cannot not detect the mismatched declarations, and all is well. - */ -TargetPageBits target_page; -# define init_target_page target_page -# endif -#endif - bool set_preferred_target_page_bits(int bits) { - /* - * The target page size is the lowest common denominator for all - * the CPUs in the system, so we can only make it smaller, never - * larger. And we can't make it smaller once we've committed to - * a particular size. - */ #ifdef TARGET_PAGE_BITS_VARY assert(bits >=3D TARGET_PAGE_BITS_MIN); - if (init_target_page.bits =3D=3D 0 || init_target_page.bits > bits) { - if (init_target_page.decided) { - return false; - } - init_target_page.bits =3D bits; - } -#endif + return set_preferred_target_page_bits_common(bits); +#else return true; +#endif } =20 void finalize_target_page_bits(void) { #ifdef TARGET_PAGE_BITS_VARY - if (init_target_page.bits =3D=3D 0) { - init_target_page.bits =3D TARGET_PAGE_BITS_MIN; - } - init_target_page.mask =3D (target_long)-1 << init_target_page.bits; - init_target_page.decided =3D true; - - /* - * For the benefit of an -flto build, prevent the compiler from - * hoisting a read from target_page before we finish initializing. - */ - barrier(); + finalize_target_page_bits_common(TARGET_PAGE_BITS_MIN); #endif } diff --git a/MAINTAINERS b/MAINTAINERS index ed68de3cec..10ed6d7624 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -118,6 +118,7 @@ S: Maintained F: softmmu/cpus.c F: cpus-common.c F: page-vary.c +F: page-vary-common.c F: accel/tcg/ F: accel/stubs/tcg-stub.c F: util/cacheinfo.c --=20 2.25.1