From nobody Mon May 6 12:31:40 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.221.48 as permitted sender) client-ip=209.85.221.48; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-f48.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.48 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1616412275; cv=none; d=zohomail.com; s=zohoarc; b=FShfGA8DNbZ0+HSTerAfa2n3h9IEhKhBIQpewR3hNyXQy6zioPwrGGjz8xCUIzWQKqEZ8rAsET6P/E42VLBx74JBZnNe3LOhRJ+WO9+hOcf3k0Fe/uJZYUSl5zWO0WD/M+xQYH8eMrPxQdxR45MHLI8Qv8KyGTRGQTi6ZUuT6+8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616412275; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=pphh/M4i+V5QXSFWtxyeo/WK7bpisFUp1Fv9ddkKt44=; b=iC84Vp7wjhgs/zZnpzFfilN3QJClH6lfpaj3VCKO6+iDJnlEvrIR0n369WHxoqguPtd0pnOD6A6TpvOb/HCl0gSVv8gqTlzAaMIgAV4iu9Upfy6ic4+jIfyI3v/fH5QW0YBx3BEOEh+kYvzJfYvw+DspedRSwXWbvGA+6k9wDoE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.48 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) by mx.zohomail.com with SMTPS id 1616412275576960.7759199677301; Mon, 22 Mar 2021 04:24:35 -0700 (PDT) Received: by mail-wr1-f48.google.com with SMTP id o16so16289130wrn.0 for ; Mon, 22 Mar 2021 04:24:34 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (17.red-88-21-201.staticip.rima-tde.net. [88.21.201.17]) by smtp.gmail.com with ESMTPSA id l15sm19277270wru.38.2021.03.22.04.24.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Mar 2021 04:24:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pphh/M4i+V5QXSFWtxyeo/WK7bpisFUp1Fv9ddkKt44=; b=RS9raCY4cxrkhDo22yKNtsyZDUZFBY3FWekOpPhHzjTI7lBfW3jpXTVoyRrEi9EbJy DAdKKoUdF1owkh+RzcSfyASAodfJ50AIqHcDByNaGmiCeNQ6wCcdb/en1SaP8gf8OnvI ENbH+mo0/TwqWvPYk6LZ48lvn/Dmfj8pwSR59NE1OtNFQbtXs/oVBDJEa9K/YqlkIJPb 2HB2c83lyu47lgjqJXjZV4+9DbMWzqerehjX20PByydQUH7snNHW5y1bNI1mYg38s4aj 8Ja/kDEssfxo0mqlfG8cM7150psYOjuO7ApwS3CKoHODON7tOnCxjrgDkpwQKw9zGM4E aTxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=pphh/M4i+V5QXSFWtxyeo/WK7bpisFUp1Fv9ddkKt44=; b=g1r9bP7BRXqAPk9XkULOdq6V0qUYLYmA0W7HZK091x1bmVz8QPgnVzxxa6sNvfBk50 UjO7Yx4oDYvDh0Tjz+ywdRidYJzAuoP91Om4iCG+h3a1RkYZOrlDdJrQ3Lju+BGUe67s pvqQIAr/kpY5L3VOYp0mkeIEumfsY8enjVAVPJ++nrWRUiIIeC7FRXlEY5Yl33V/dKMm JghM/ZMOUskpdXdvjhBmxzyDiZNK1eqcs0Mu4nBBb0PyaUJXugpAilhao2rsxdYUuulk mDuD/0oFeCyDGm6DXBfJp6tn3ZvnS5UkYRXMnu+VifKn0v8ma/7jsvkbRVS6/o40zp20 OsWg== X-Gm-Message-State: AOAM530inhKiIDwKppwY6MTS2vTi61DufhFqKQym6rf62iwk7qN7k/kq qpR0+DD7mT/FnUmKzhwHneU= X-Google-Smtp-Source: ABdhPJxYCyNE7EBjis2u6HTnHhla93JP23TrQ7BVfgM2D07lN114fLSi50ykv12ng9rWFaI/AUeYfQ== X-Received: by 2002:adf:fe8d:: with SMTP id l13mr17271009wrr.81.1616412273872; Mon, 22 Mar 2021 04:24:33 -0700 (PDT) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Richard Henderson , Gavin Shan , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v2 1/3] exec: Rename exec-vary.c as page-vary.c Date: Mon, 22 Mar 2021 12:24:24 +0100 Message-Id: <20210322112427.4045204-2-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210322112427.4045204-1-f4bug@amsat.org> References: <20210322112427.4045204-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) From: Richard Henderson 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 --- meson.build | 3 ++- exec-vary.c =3D> page-vary.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) rename exec-vary.c =3D> page-vary.c (98%) diff --git a/meson.build b/meson.build index 5c85a15364d..f0dd8aa0898 100644 --- a/meson.build +++ b/meson.build @@ -1933,7 +1933,6 @@ =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_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 a603b1b4336..344f9fcf76a 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 * --=20 2.26.2 From nobody Mon May 6 12:31:40 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.221.41 as permitted sender) client-ip=209.85.221.41; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-f41.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.41 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com; dmarc=fail(p=none dis=none) header.from=amsat.org ARC-Seal: i=1; a=rsa-sha256; t=1616412280; cv=none; d=zohomail.com; s=zohoarc; b=Y32wXij7Swsy6vvMT4ir0jQeTPFhvyhHl59rBUkja0/h1Ualx8cedfWfOmnMsOYLg7EymRR00gaUFhEEIWOGZ1kf2+52QCj8I1ALfVGCndJEv5c6OQL2RKUU9XA7zd+puS0B73meh/6geNx/8UeLx2P1kHOX90xw16FqtdB4mtA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616412280; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=cDSXceljWqcXDx04k32YsIurC/KdJcDt8gGgRtwSfiY=; b=ThdhFNih5Ym8I14IfQD9Li1va4yPrv9lmSSwv3FAiJiH7sm31dWxeeOKXu5WxaFuNbhynYY1EMc6/mSas8bYXFe6NEP5hyfysThO67E4BwpUfa4Z7VBVJfTI6oNscUnsytjABcRvoO8EJ6AZ/USOGIuk/RdxGdKypcYpDVBSFto= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.41 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) by mx.zohomail.com with SMTPS id 1616412280241393.2703159728135; Mon, 22 Mar 2021 04:24:40 -0700 (PDT) Received: by mail-wr1-f41.google.com with SMTP id v11so16251398wro.7 for ; Mon, 22 Mar 2021 04:24:39 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (17.red-88-21-201.staticip.rima-tde.net. [88.21.201.17]) by smtp.gmail.com with ESMTPSA id q15sm19239794wrx.56.2021.03.22.04.24.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Mar 2021 04:24:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cDSXceljWqcXDx04k32YsIurC/KdJcDt8gGgRtwSfiY=; b=Gornl2f/h+Pp18smoGCzIQJsGW+mnBR7NalkLcGdIa3V9pZZ9fIATwCtkFJrLL01ZW D8/C5Zp2Dnk7qfbinotedDKe5QQBoKUldtKlqYqqBJkZFo1NvrG19riHKz9/Kv/AM48W ydXZPBGh7DlSbe/C2D/tFnpriwEzvBLgy72Om+VJjnSp+hjLtZXRvi4DSVHAxWZ2w9hX m4tofyMiprES0Z+mQhN3+gk/z8o47xKGRGNNmSyPHkhfuFSp5tKMMloPpJyXXwLy/DXP ZZWh3AIbum4lJeUZv6RW95oUKnQPCqteinNu0ZHa0iTp1QfV3TADU8fTgFbrRyNx9VwL LuZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=cDSXceljWqcXDx04k32YsIurC/KdJcDt8gGgRtwSfiY=; b=eUPgpOWieWk2py5940mEf9dR93ozzDJvHd0ticvYS3/FCD4ijAmHViaU/h28YS1Fm5 Aw+KGsRwwBRoZcqlcUwDo4nq9evalNTpTq0injyieUmiKdwzWPpcBUK/nXPIlStYJPft MRBli7Cn9rinf7Z2FPxYumxCyqyBPxzmzPkYNNzl1bMKaYN0CbrU9shstaQ57TOb6jO6 YBWy5I4JIJ8ytrMM9kaFuhQ3nQooKSpCdlWSiDbh2ZuTLypVsxyC3axVaFz4NnDv9hle EDB2U8gxib6w6yhDIcclcy1qYT7kbgPSoQTspupRaOwxroAC493dQoYqIEEOihpxer/f gvDg== X-Gm-Message-State: AOAM533kEXqAKVdjQZWzRar/UwztbOz/J1obeOg/g2xnqaLNQlH+kBsq mD+NsWuYZRg6SnL1RVCR/D4= X-Google-Smtp-Source: ABdhPJwngemH6Nwvr6xCTfsxQGu+ca66n2V7IBBBxnzu+QB00V79T5K1BNw4+dTI3l6hHsP6wTscEw== X-Received: by 2002:adf:ab52:: with SMTP id r18mr17611488wrc.65.1616412278516; Mon, 22 Mar 2021 04:24:38 -0700 (PDT) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Richard Henderson , Gavin Shan , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v2 2/3] exec: Extract 'page-vary.h' header Date: Mon, 22 Mar 2021 12:24:25 +0100 Message-Id: <20210322112427.4045204-3-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210322112427.4045204-1-f4bug@amsat.org> References: <20210322112427.4045204-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) From: Richard Henderson 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 --- 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 76443eb11d5..b0a422c7b62 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 00000000000..799d6310d6c --- /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.26.2 From nobody Mon May 6 12:31:40 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.128.51 as permitted sender) client-ip=209.85.128.51; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-f51.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.128.51 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1616412285; cv=none; d=zohomail.com; s=zohoarc; b=PjXuDGRSgTsvzJ/xPyTBIpnFYVuFOeAyrHH+QobN3OkxbeJh0o93B7Zgt2/XInMw/skvgRe0/FayABjDH6SzkF2gkbW4CCOA+MLxKD4UfYUyN1/PPVAmHqfSVQnlvspQSusEsESm5K0PyexCHj7s3sJ6h8DGA4kVus2fjsxOpKY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616412285; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=RYln04rPdXP16oTRf4bLDfPYDelgruJglulvhLpq8Eg=; b=P8m0D3SYwBalfK1/v36SdISKqjbip6aPylGumzjw8l4xVbqe+8YSCYgkN55BqNKUR5Kmr04/aAS7s0dd4eCEp3wbGw+h4H8NunwperkFbZHg4NeoxlLRbAkDYGQjHUObt2pyKUp5Fn91tNuQ5aQx9Vu3FGRZ9ejGxpopqHVB7Gw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.128.51 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) by mx.zohomail.com with SMTPS id 161641228571439.2451803454685; Mon, 22 Mar 2021 04:24:45 -0700 (PDT) Received: by mail-wm1-f51.google.com with SMTP id r10-20020a05600c35cab029010c946c95easo9024428wmq.4 for ; Mon, 22 Mar 2021 04:24:44 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (17.red-88-21-201.staticip.rima-tde.net. [88.21.201.17]) by smtp.gmail.com with ESMTPSA id u3sm19515610wrt.82.2021.03.22.04.24.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Mar 2021 04:24:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RYln04rPdXP16oTRf4bLDfPYDelgruJglulvhLpq8Eg=; b=bbDcH2f46kqE7WSNJezMhVvj7Ur3xXCY+3u3SIzO1ihY7RZGSufFyBNUgmlDn9sLIS +X5U6PZ/yezmFuF519g21NEGrNXbuEu2wMdZpFfMsp+f/tSXGjRkwB4dDOhh8NtrRcbG caF+i5C2vPGDCIH3FzfWAys08xsLsw5VNdoQsEEqd0hKfrFcP76SrfcOlnIsX2f8RUxz vGMUnPQwUcKTIC5770uuPRjbvalpFu4tjJ6B87WrSbyOw2xZmRBEW3m3IBQTgEI7jxCy argmtXBxNp09JLDdxMbbk4jOsySlMG2ebOh4/+Cfi8IooYj6rc57YR5mH5sfHrAUedtD DBKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=RYln04rPdXP16oTRf4bLDfPYDelgruJglulvhLpq8Eg=; b=InQw/6OahygWR6E7+4I2UY5KBG2CgljBTF3bCUW5lAMc0XDlguDyw6BTyE7SBFB2k/ CzmeDc7tirZg5/oZ+GrdObWUnjNt/iqbiW6d5vXlzrOnkPh4nj0jsvddKPHzA6/4YCjY dFUuOL6AEJ8YGdxdEUL3PAKs29Y/8QBhnaCbsBzf8v1+hvj14EeUqyZJWVHdo/gYA/fa YtK86o8vExXIYlAjO0b5prDL7Pq8yhkfD3Q0UIUSsdBuLYr35Z3z5lrxk+9ymKh8YRMX EE3PoYKxE17RLkhtaNPrK79ujAVZPIzlIjIx7LEcHanpkHLLPS11G1TFHEbxTh9l0LW7 MJag== X-Gm-Message-State: AOAM533jDoxx9/Vd29svqjLy4GKQ3e9+QYQhM0QaGJJc8hr0X6T/uGOb D9u1Zhq0pAyjftttWGD1/6o= X-Google-Smtp-Source: ABdhPJwx6cIl43GRxETVCbDAdoaE9cQGm7qhdfZsL7MkQ14rwFgAEOtD9ndsIgLBgISerYpEqoy6vA== X-Received: by 2002:a1c:3d8b:: with SMTP id k133mr15645394wma.6.1616412283397; Mon, 22 Mar 2021 04:24:43 -0700 (PDT) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Richard Henderson , Gavin Shan , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v2 3/3] exec: Build page-vary-common.c with -fno-lto Date: Mon, 22 Mar 2021 12:24:26 +0100 Message-Id: <20210322112427.4045204-4-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210322112427.4045204-1-f4bug@amsat.org> References: <20210322112427.4045204-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) From: Richard Henderson 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 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 exec-page.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 Tested-by: Gavin Shan 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 --- 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 +++------------------------------------- 6 files changed, 80 insertions(+), 96 deletions(-) create mode 100644 page-vary-common.c diff --git a/configure b/configure index 847bc4d0957..dbb873e09cb 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 f0dd8aa0898..24e8897ba2c 100644 --- a/meson.build +++ b/meson.build @@ -1944,6 +1944,21 @@ )) 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 b0a422c7b62..d76b0b9e02d 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 799d6310d6c..c22a7a742e7 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 00000000000..91755564985 --- /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 344f9fcf76a..057c7f18152 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 } --=20 2.26.2