From nobody Thu Sep 19 00:17:03 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1719596002; cv=none; d=zohomail.com; s=zohoarc; b=HdH7d+8Q42m0gaZ26nDETL4yBE81GfUprIe7U2C7/ZoOIWan5WYGH0u+hc7MsTk/3E99eDT/zhiUjWBRXpYDtOI6Gu5AGhLTdxt5IX9hx60DqSv05u0aOsbKCd0sFvR8p3ECnz97aKPC4BOKSWgzCgX4/6P9vG3mVnSHpKjDlFI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719596002; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=EZr6EpxPTnCtfkI/16JpVzSMCa8vz0QSxvxLLnS2Bk8=; b=BcONeMq23H7O8+rGr8bYojKVh/lRjDH/KtaCDIpAtjbkrDYTnVK/xrwQdOI6K922qfxPQdUd+Sm3ipFM6UvggiAD33s4vgJ0eczU2z6sGxKyZEMY6xEwEqQkjaWLUciJaTsJxZoWN0J1SFXGlHr1PbOfaMNU30o8c7KvwBfOLwY= 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+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1719596002338532.2544063583686; Fri, 28 Jun 2024 10:33:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sNFPY-0005aA-NS; Fri, 28 Jun 2024 13:29:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sNFPO-0005YW-90 for qemu-devel@nongnu.org; Fri, 28 Jun 2024 13:29:14 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sNFPM-0002AR-Aq for qemu-devel@nongnu.org; Fri, 28 Jun 2024 13:29:13 -0400 Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-526-YxdTIJMnPICnGVWpjTaBkA-1; Fri, 28 Jun 2024 13:29:09 -0400 Received: by mail-ed1-f72.google.com with SMTP id 4fb4d7f45d1cf-57d22ea3e71so606501a12.2 for ; Fri, 28 Jun 2024 10:29:09 -0700 (PDT) Received: from avogadro.local ([151.62.196.71]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-58612c8720dsm1288640a12.7.2024.06.28.10.29.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jun 2024 10:29:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1719595751; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EZr6EpxPTnCtfkI/16JpVzSMCa8vz0QSxvxLLnS2Bk8=; b=F4Ki1lG8YYs2cHnGN5VVIgy+JhQQK1CQassz+MDDvAMxx/+C1epYNOPk3ZjttOq2GH8g4a W1avYlxd1DRZ7vl37f+D560dmclZ926I5S6gJS6yUPv2K9IVh1Y7sh6h4sptQbCWyDpbxv edq5FkbtB/ev1dpSLyScFTjzVyXU+2E= X-MC-Unique: YxdTIJMnPICnGVWpjTaBkA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719595748; x=1720200548; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EZr6EpxPTnCtfkI/16JpVzSMCa8vz0QSxvxLLnS2Bk8=; b=UzYELiGEnkkiekr+e8+TlaUWzV14APNzsUYFN+cifuYBng4+HCSHzGuBJU/x28xwEb 4Vu5usmramx70p5qaUnksHQUowrqOG3RaEo/5Kfoza9RyTgvUovl4rVYlzO7tM/agNyE kKL8x+boOPbFCtB3oCv5QFZWki/MZToSzk2BBjztSGMfxEV6PdQjB4AR8IDVywCDe3IR sckevlOgxA9Y3j0WERrFWxsboMOIM5BekhyWXhZTVjdVbDLBVcFxagViZbKEIwFwL5AI FpUZldRY+hzEVH6blyFssRiQJvAAr7pg4TZSnqSNDM2JiIAWz8JKuwnoXIqBTBLtOwI4 Psmg== X-Gm-Message-State: AOJu0YwhcezQ1CZKw+VniwgVh8ef+KDmfXGFkW3ufxvoTvaBD9ykRC67 vvvz3t8K9iv3I2pqQcLGpIAiNk2JcJFE5bELy/lXdEQ5kRvqESEHzcQD/EcfivJnBiTAU18UG3y zWKdptOJs0iOFO69ositoBDx3kyiWgISDuYLeSE0pRmVNINyKD8QLm2Lz2soPvTdhK+tXI2f3oK tYz7HUFLKj6CStqPea/A8VOptYD5s4HoL7ZX4k X-Received: by 2002:a50:c058:0:b0:572:4fc3:3a28 with SMTP id 4fb4d7f45d1cf-57d4a28e8bcmr13800176a12.23.1719595747827; Fri, 28 Jun 2024 10:29:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFrLT2EykPq3z0vUTeobzU3w7rycYdNp4vNjPiZoymiOPwpisEhtIXVa2fHQ+6FULtTF+aDyw== X-Received: by 2002:a50:c058:0:b0:572:4fc3:3a28 with SMTP id 4fb4d7f45d1cf-57d4a28e8bcmr13800160a12.23.1719595747302; Fri, 28 Jun 2024 10:29:07 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson Subject: [PULL 05/23] meson: allow configuring the x86-64 baseline Date: Fri, 28 Jun 2024 19:28:37 +0200 Message-ID: <20240628172855.1147598-6-pbonzini@redhat.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240628172855.1147598-1-pbonzini@redhat.com> References: <20240628172855.1147598-1-pbonzini@redhat.com> 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.206, 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_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1719596002679100002 Content-Type: text/plain; charset="utf-8" Add a Meson option to configure which x86-64 instruction set to use. QEMU will now default to x86-64-v1 + cmpxchg16b for 64-bit builds (that corresponds to a Pentium 4 for 32-bit builds). The baseline can be tuned down to Pentium Pro for 32-bit builds (with -Dx86_version=3D0), or up as desired. Acked-by: Richard Henderson Signed-off-by: Paolo Bonzini --- meson.build | 41 ++++++++++++++++++++++++++++------- meson_options.txt | 3 +++ scripts/meson-buildoptions.sh | 3 +++ 3 files changed, 39 insertions(+), 8 deletions(-) diff --git a/meson.build b/meson.build index 97e00d6f59b..6e694ecd9fe 100644 --- a/meson.build +++ b/meson.build @@ -336,15 +336,40 @@ if host_arch =3D=3D 'i386' and not cc.links(''' qemu_common_flags =3D ['-march=3Di486'] + qemu_common_flags endif =20 -# Assume x86-64-v2 (minus CMPXCHG16B for 32-bit code) -if host_arch =3D=3D 'i386' - qemu_common_flags =3D ['-mfpmath=3Dsse'] + qemu_common_flags -endif +# Pick x86-64 baseline version if host_arch in ['i386', 'x86_64'] - qemu_common_flags =3D ['-mpopcnt', '-msse4.2'] + qemu_common_flags -endif -if host_arch =3D=3D 'x86_64' - qemu_common_flags =3D ['-mcx16'] + qemu_common_flags + if get_option('x86_version') =3D=3D '0' and host_arch =3D=3D 'x86_64' + error('x86_64-v1 required for x86-64 hosts') + endif + + # add flags for individual instruction set extensions + if get_option('x86_version') >=3D '1' + if host_arch =3D=3D 'i386' + qemu_common_flags =3D ['-mfpmath=3Dsse'] + qemu_common_flags + else + # present on basically all processors but technically not part of + # x86-64-v1, so only include -mneeded for x86-64 version 2 and above + qemu_common_flags =3D ['-mcx16'] + qemu_common_flags + endif + endif + if get_option('x86_version') >=3D '2' + qemu_common_flags =3D ['-mpopcnt'] + qemu_common_flags + qemu_common_flags =3D cc.get_supported_arguments('-mneeded') + qemu_co= mmon_flags + endif + if get_option('x86_version') >=3D '3' + qemu_common_flags =3D ['-mmovbe', '-mabm', '-mbmi1', '-mbmi2', '-mfma'= , '-mf16c'] + qemu_common_flags + endif + + # add required vector instruction set (each level implies those below) + if get_option('x86_version') =3D=3D '1' + qemu_common_flags =3D ['-msse2'] + qemu_common_flags + elif get_option('x86_version') =3D=3D '2' + qemu_common_flags =3D ['-msse4.2'] + qemu_common_flags + elif get_option('x86_version') =3D=3D '3' + qemu_common_flags =3D ['-mavx2'] + qemu_common_flags + elif get_option('x86_version') =3D=3D '4' + qemu_common_flags =3D ['-mavx512f', '-mavx512bw', '-mavx512cd', '-mavx= 512dq', '-mavx512vl'] + qemu_common_flags + endif endif =20 if get_option('prefer_static') diff --git a/meson_options.txt b/meson_options.txt index 7a79dd89706..6065ed2d352 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -370,3 +370,6 @@ option('qemu_ga_version', type: 'string', value: '', =20 option('hexagon_idef_parser', type : 'boolean', value : true, description: 'use idef-parser to automatically generate TCG code fo= r the Hexagon frontend') + +option('x86_version', type : 'combo', choices : ['0', '1', '2', '3', '4'],= value: '1', + description: 'tweak required x86_64 architecture version beyond com= piler default') diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh index 58d49a447d5..62842d47e88 100644 --- a/scripts/meson-buildoptions.sh +++ b/scripts/meson-buildoptions.sh @@ -82,6 +82,8 @@ meson_options_help() { printf "%s\n" ' --with-suffix=3DVALUE Suffix for QEMU data/modules= /config directories' printf "%s\n" ' (can be empty) [qemu]' printf "%s\n" ' --with-trace-file=3DVALUE Trace file prefix for simple= backend [trace]' + printf "%s\n" ' --x86-version=3DCHOICE tweak required x86_64 archit= ecture version beyond' + printf "%s\n" ' compiler default [1] (choices:= 0/1/2/3)' printf "%s\n" '' printf "%s\n" 'Optional features, enabled with --enable-FEATURE and' printf "%s\n" 'disabled with --disable-FEATURE, default is enabled if av= ailable' @@ -552,6 +554,7 @@ _meson_option_parse() { --disable-werror) printf "%s" -Dwerror=3Dfalse ;; --enable-whpx) printf "%s" -Dwhpx=3Denabled ;; --disable-whpx) printf "%s" -Dwhpx=3Ddisabled ;; + --x86-version=3D*) quote_sh "-Dx86_version=3D$2" ;; --enable-xen) printf "%s" -Dxen=3Denabled ;; --disable-xen) printf "%s" -Dxen=3Ddisabled ;; --enable-xen-pci-passthrough) printf "%s" -Dxen_pci_passthrough=3Denab= led ;; --=20 2.45.2