From nobody Mon Apr 29 03:27:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1616519972; cv=none; d=zohomail.com; s=zohoarc; b=WupjzmSgzYSBIVPx4LKh+Tzvy/kynVXoN+WSoKX6tXsm/4GZ0gxYIYberj+RywJwl5hhlTCb5iwuCbykmMH0qzSWcNOrzE3x63JRBfDDt+0BSyp/VSCFmytoPZ8qsrxFaeMJQkLfLcs02/ei18ConkkwhYEL85qfvfD+TDpJWbQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616519972; 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=G3btJ15hldWGgIcqqIHhuaFfFgCQiyhx40yZuCG66XQaiuBi9i3ZYuoZ14QTIuaMg2FM1LtI3GbbF+kZzn+xqZmyZurYloPlKoow9dIRbDDVOaNmzeKWG33In96ahQvd9mqQ5TQr8+uIYVZYmJwQ/sMc529x9D+dDa2XF+x8YxM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail 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 1616519972262671.1078741049214; Tue, 23 Mar 2021 10:19:32 -0700 (PDT) Received: from localhost ([::1]:60158 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lOkgf-0000bp-TV for importer@patchew.org; Tue, 23 Mar 2021 13:19:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45786) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOjhS-00070m-LT for qemu-devel@nongnu.org; Tue, 23 Mar 2021 12:16:10 -0400 Received: from mail-oi1-x232.google.com ([2607:f8b0:4864:20::232]:45716) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lOjhP-0008QK-9R for qemu-devel@nongnu.org; Tue, 23 Mar 2021 12:16:10 -0400 Received: by mail-oi1-x232.google.com with SMTP id d12so17581144oiw.12 for ; Tue, 23 Mar 2021 09:16:06 -0700 (PDT) Received: from localhost.localdomain (168.189-204-159.bestelclientes.com.mx. [189.204.159.168]) by smtp.gmail.com with ESMTPSA id 8sm4317822otx.1.2021.03.23.09.16.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Mar 2021 09:16:04 -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=n6KcxKMbLfem1Pn7BLCmxKQVCteAHjjVJMLlqK/0smSSDp7vnDy7sbjcZMQxBDXhgr HVATv1xA62bLJvuPiEmpo8smcjdmv8SD9fitgsg1NJvlOZJVZw6n/Ovc18kyqyQPiML1 PUujMvGTZsbh57aqLZdEWnOis2L7lCKKm3t/xKA1+A2Ad/X2jboH3q8Kt9D1H8OhHoZj KM1FFbWuMvB2qQcO24Pp5coMTl4BQ8W/aVfXBgOH8cZw1mfpQzsiuXkWUmolRqatM6Qh srWHA8w2Cbx9L+UwophwgFcfS7ZZ6qKkJv4mVRVqmyKj5kmfAaawvwi114EHt2kNp5cq nR1w== 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=d00r7Ooq+qf6MeEM7Ew4W1cbHTr6fi49xWfqvE2KoffhDMmtpCqEQi9LO1MZm7WX34 bVCn12dbc+omz1zy1UzvAncei8Qx6OqzKFJMLkP/yy11AaqzajREXupnjDl/HwRs/rnH 5Swq1GPHvKegjNsVWBwoa2vl9tWKyftHoTzvn91Waspdob3S19UMXBc/AMAEnr/VZq29 XEMkMFKOdv8U4Y3pk/+/l6bjLJSbhpbA9qJKfzdKr/vIBGpTrbpY/WhwPWEb9DIDKGzp DKMPjMfcBlOy4J5MB/KRHNzslfktV9uXarH0JXo5loW/+TJzyiNVFl8mNVOaK29pX0IL PC6w== X-Gm-Message-State: AOAM531kgr6RlMncu4t3gwI4XZ/rLR4Eae7Hc7Rr8lq8SclIddrA0/m0 a9IJfaWMyD+N3hY0WcJH0LrU6BHwVY9MGTiO X-Google-Smtp-Source: ABdhPJz8Azu1HbNxjFXxMW4zMbNXEutbEAp/LmqmiF3fiUx5Sqwz0jFHOaRwoXl3ODg6p46jpnKMBQ== X-Received: by 2002:aca:47c4:: with SMTP id u187mr3862953oia.136.1616516165273; Tue, 23 Mar 2021 09:16:05 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 1/3] exec: Rename exec-vary.c as page-vary.c Date: Tue, 23 Mar 2021 10:15:59 -0600 Message-Id: <20210323161601.454996-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210323161601.454996-1-richard.henderson@linaro.org> References: <20210323161601.454996-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::232; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x232.google.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 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, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: pbonzini@redhat.com, gshan@redhat.com, f4bug@amsat.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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 Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- 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 Mon Apr 29 03:27:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1616520193; cv=none; d=zohomail.com; s=zohoarc; b=LwyL+uuKsYLh3QH4/2zkyTWQuxxhzvfheguoBCgijzseq0kDk1SkN066Dn3bskRAwMUnU6THp0g+OdAzlxL7EtaRRXaoVtBMjABs7abWls/7x9OMHiPISDzxWwl074cZx2WBKMi65YAdxCaicdoOtc05ngARTWIcixmoWDVzqN0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616520193; 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=ZN/UkFKum4CSlfZV6OTSutF+ZGW+H6MMaZpUWkb7i2fHoDn6EKfPP+ZUICxmZ4IfcYaNZGTT0xEFpQtrNX0xgl2Gkn2ElnqxJWKscts1w4YOxQtsuYFhKOabzJwPHLjMjztjhIYMImnybEjxF/DcgxlzaMOeLip09Lwnf3Z0ziM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail 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 1616520193717549.5319796877665; Tue, 23 Mar 2021 10:23:13 -0700 (PDT) Received: from localhost ([::1]:40472 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lOkkJ-0005IB-Qi for importer@patchew.org; Tue, 23 Mar 2021 13:23:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45794) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOjhS-00071J-Rx for qemu-devel@nongnu.org; Tue, 23 Mar 2021 12:16:10 -0400 Received: from mail-oi1-x229.google.com ([2607:f8b0:4864:20::229]:46720) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lOjhP-0008RS-ET for qemu-devel@nongnu.org; Tue, 23 Mar 2021 12:16:10 -0400 Received: by mail-oi1-x229.google.com with SMTP id m13so17564216oiw.13 for ; Tue, 23 Mar 2021 09:16:07 -0700 (PDT) Received: from localhost.localdomain (168.189-204-159.bestelclientes.com.mx. [189.204.159.168]) by smtp.gmail.com with ESMTPSA id 8sm4317822otx.1.2021.03.23.09.16.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Mar 2021 09:16:05 -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=J6YZsZvPADbB4Xg5jpNc62U9q/JlPrbXIMjOT85oQTuSbwiTDwcBmMMrc5z1GrqUYu t1vSt6vNt2GJwEPzHdo2hUTd14mbl7EjNGPB1ELEaGK585u6v7du8YEB2hKq8eQ1adQt UzHJ1HpQL1H9kmLPXq58x1Yc5V2oOWJo2aumw+D3bwk/X37Ud0oiuvVDkV446XD6R4VS Z3/v28EW7usr+uZ9kOFrxuSpOpqp2Abd8nZYrpMZiyMHZg8EsPbGaQNrW4aeln3MCEbf /0RyDnIlR22DI9f3x2ZWL5Ymfqvmdy5GB/YMtYaYXIuHZ0Kc9CZVz3aZ5c5A/cBPDamt hVwA== 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=fNKO1YcmL30z9Uosw//vkP9Y/dBGmlQDLwKEhXihS/6ALFZPMNlSM9bjr9WGtDGsfA VMWloUOJAEz52BviPGBBm5RCWqwBL94euuGCa7HgDg7LLHTlsi/fkH7t4v22VDHpJl0l HfKB5O6HVtrqxV6p3W9q70tNZaOC3Tam04b2aX2UvFpjpZe1A3W3wQgh7sw9oEBv7DpY OGKWMQwuyxIF2yoOnjv4AyRkVJTdQwvFMwKvAcGoQNqTeZWptP52dHhNs0jwPqZa1AVS 01ZzKFT8O1ImRvomYhtNVMglp/4zPn62rcyXNhggYfRmnMCK1bbmNDszrt/9zXJIVyyi XiTg== X-Gm-Message-State: AOAM533IjkizVOAxJlEkqEMsGbp7vEL7oxFznaOuSfFP8KsMeolKIbSK jrq/G+6Tv9rItJCJXYzX/SU3oux6MXjuxdlf X-Google-Smtp-Source: ABdhPJwLCC/7pjlJXqXiMfMz2zjhXg8TEmyj4xY9n11lgKSM0NLrmEZEow66k7tBa2jMb66HBZy8nA== X-Received: by 2002:aca:61c1:: with SMTP id v184mr3887727oib.125.1616516166399; Tue, 23 Mar 2021 09:16:06 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 2/3] exec: Extract 'page-vary.h' header Date: Tue, 23 Mar 2021 10:16:00 -0600 Message-Id: <20210323161601.454996-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210323161601.454996-1-richard.henderson@linaro.org> References: <20210323161601.454996-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::229; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x229.google.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 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, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: pbonzini@redhat.com, gshan@redhat.com, f4bug@amsat.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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 Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- 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 Mon Apr 29 03:27:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1616520409; cv=none; d=zohomail.com; s=zohoarc; b=HV2iHcdU5iOrI+VmiWLj8IXJBEV2J7pMmWrO3fvH00EwS4iFkRBeOrmulZfuS0Un1ozDUycQecQkMpQc0RT4y6FbZcDvvAFHgjuj2uQtQldwn0nzd3OIU1y2daT21wdk5+dGcNvmo/lnf9mNLw24MPYWrMTWTTrrdVFt2Nm+YHc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616520409; 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=mSPjl/4/EKHW0h64VZT+YVO0G10BLyrXeHIIt+er56Y=; b=DNK8PsqtggB8KTlpFZifncVt83DtK2R8m1ZlSR0nRxVtC+73JWU7eoFFwUBVn/l42MkIiXVGaXS2gBz+id8P1Qav5ugBKmItZY72OWN5VkyVmE8CJ+JcDLsmCPKm0ZkoefADsVf5ikcyYo723bQEkrGUSvgjWtb8R8M1/QOi0Iw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail 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 1616520409955912.6212215751418; Tue, 23 Mar 2021 10:26:49 -0700 (PDT) Received: from localhost ([::1]:49078 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lOkno-0002oY-PP for importer@patchew.org; Tue, 23 Mar 2021 13:26:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45812) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOjhT-00073D-RA for qemu-devel@nongnu.org; Tue, 23 Mar 2021 12:16:11 -0400 Received: from mail-oi1-x233.google.com ([2607:f8b0:4864:20::233]:42568) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lOjhQ-0008RZ-LD for qemu-devel@nongnu.org; Tue, 23 Mar 2021 12:16:11 -0400 Received: by mail-oi1-x233.google.com with SMTP id n140so17570137oig.9 for ; Tue, 23 Mar 2021 09:16:08 -0700 (PDT) Received: from localhost.localdomain (168.189-204-159.bestelclientes.com.mx. [189.204.159.168]) by smtp.gmail.com with ESMTPSA id 8sm4317822otx.1.2021.03.23.09.16.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Mar 2021 09:16:07 -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=mSPjl/4/EKHW0h64VZT+YVO0G10BLyrXeHIIt+er56Y=; b=Y8c5jC3z0hcP3rlW2K8QqL+T2GUhWvqCkmbnKUAh6bHvNBooK8WevPV4iyuMo9lL0h uevp1TnU10RCtiBtdy0x8Pdv+cK/zioATBGzFUvMHmgnd23Jis+tZNFKInTJKal9gKQi xhSAl1Bf5B6OmxzTA0gXJuUrS1S6DrMX+CuHPqfzCaZi+TmJJIwjblVk/8ZTd4tG7fji W892OYfx7/qqHbalwLDfGRK5Vc6gwbmRae2qLUd6XGWqiU6rhSi0z5ecWr2Lzs67NHkW CLMEZiG3iBX/n0k1FpxIvR+Y53CIrKbaOWaanbsOAavmVt0dFMxKLpqBljbHW9WglZf6 ohrg== 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=mSPjl/4/EKHW0h64VZT+YVO0G10BLyrXeHIIt+er56Y=; b=GRTCCrCXbw+4vvjXEf6SVg4z4Yyx5dYGJMBhpbod1b9DDqpQmu50IqsUz2P9j9os+5 /fS4qz89D2IsoppJPiDSnrvDAOfGRWJa5dee6c/TSlZruUmbPJoV9E77fU3IIrHTAlKF h/YkwDqel6cV306hnA56b9MnXA4W93ZMO5+xgaKh3TtoTV35z5VTtOTk5q7ggz4+6mbW Gg+STrRUrP/6bOIh6afAozB5LtYMb0abts9eB3xliubs+Ta/AYvUID9xhr91CRDKKYAs 5tGM/3faBzmbvRSuaxNdIY5avEZM0x7g+0TAUm7tTCcsoOcY1Xz6Gmw3PBd2Yk0By5sb 2XQw== X-Gm-Message-State: AOAM530i52VaCrebmz55dehV1WGnLyZe13VPBcNsgTGt7V+tkohzvhXh B2TS89aSn8B2r7nNeJW1xhIUUg/Lrf94oPZJ X-Google-Smtp-Source: ABdhPJzD0X5gb4N3V+VJSEeh2UrHUVwkQeLNA1kNRKjOR4k5kNeOxLXvVb9PN+6G7+FxjUZ8EgADqQ== X-Received: by 2002:aca:1b01:: with SMTP id b1mr3738626oib.177.1616516167455; Tue, 23 Mar 2021 09:16:07 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 3/3] exec: Build page-vary-common.c with -fno-lto Date: Tue, 23 Mar 2021 10:16:01 -0600 Message-Id: <20210323161601.454996-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210323161601.454996-1-richard.henderson@linaro.org> References: <20210323161601.454996-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::233; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x233.google.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 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, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: pbonzini@redhat.com, gshan@redhat.com, f4bug@amsat.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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 | 15 ++++++++ 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, 81 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..24e8897ba2 100644 --- a/meson.build +++ b/meson.build @@ -1944,6 +1944,21 @@ 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 =3D static_library('page-vary-common', + sources: pagevary, + c_args: ['-fno-lto']) + 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