From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0A0B0C83F1A for ; Fri, 18 Jul 2025 13:28:44 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.1048759.1418936 (Exim 4.92) (envelope-from ) id 1ucl8Y-0007Iq-AU; Fri, 18 Jul 2025 13:28:30 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 1048759.1418936; Fri, 18 Jul 2025 13:28:30 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ucl8Y-0007Ij-6N; Fri, 18 Jul 2025 13:28:30 +0000 Received: by outflank-mailman (input) for mailman id 1048759; Fri, 18 Jul 2025 13:28:29 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ucl8W-0007Id-W8 for xen-devel@lists.xenproject.org; Fri, 18 Jul 2025 13:28:29 +0000 Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [2a00:1450:4864:20::531]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 14281c89-63db-11f0-b894-0df219b8e170; Fri, 18 Jul 2025 15:28:23 +0200 (CEST) Received: by mail-ed1-x531.google.com with SMTP id 4fb4d7f45d1cf-60c51860bf5so3718236a12.1 for ; Fri, 18 Jul 2025 06:28:23 -0700 (PDT) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aec6ca31defsm121273966b.95.2025.07.18.06.28.22 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 18 Jul 2025 06:28:22 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 14281c89-63db-11f0-b894-0df219b8e170 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1752845303; x=1753450103; darn=lists.xenproject.org; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to; bh=bYC7HA2wDATmo85CNtx+jcKbD9kuYuu66hl5k9zYAdY=; b=gdIFso238ZEc/0Mv5aIIK6WgaL/aiLiQmFQ8sGPGS9UBipQLe3KoNIPMnCdEUbkctD Cp5AzZWnbjLwNvwUYyVDgGLQykxWRVpvqwutY+zKD3G7hxzriU13FgrZJBdozuf8koXQ 6z88aTYPs2W2DOb4yQB9Y3DPrQjEDS1uhMDrc4hCeXWLsIVHMd6869QGSktF7m9tYWdv XSBRngpEPCMQMytGKNvTLvwOMgIeDEdYc8JvbnrobDre7aNXtKTmimDB3pPwe5Wj59ja i7Vi1yf9ThRVaGPBIlY3SupQ6/R0+L+EJlay9JpURGy6XtnR/MDHvrA/rITL5L42DMCK e1CA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752845303; x=1753450103; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=bYC7HA2wDATmo85CNtx+jcKbD9kuYuu66hl5k9zYAdY=; b=faXv4lyAX6n2DOWysK6eGsqzWuYnESymlv23YYrjrF2pfFyWBAy/KdrWfp20FMdtRd z13x4jrPNXQ7yIFLjhffl+OBY9VF1TFQsV8D6REIJIaidqmycqmlJq66ZzPWMz0fmOd+ ImSZy2ZKci+MFVVjHO54lvdF1eKh0F8aZ7R4sXuUackkABw60IVT9G0Z4pQ6Of2z5UtK V28F/OKXw3ZkFhhX556YT4aCDXWgUQ8kDDegi27B6kyvJXqbwp0b4obfcMo3ETY+b95V e1foCWX7cFc2d8EP3tKP2mMknCHRRuRWRdC1q5uBSacs7ouPL6JT2AZ/9g05npbXE61B nfBw== X-Forwarded-Encrypted: i=1; AJvYcCVcSwE2Xez2iM4VCaMl2CmOGzkJex1BFkS5OzaVcizMnYpSCIas0nkZcWandVzeH9pa2uUktec1v0o=@lists.xenproject.org X-Gm-Message-State: AOJu0Yw71g7Hxk3Tk7IL2FlGSO2Y33TpRvcUnYUI03YSUOIQlOUJ1dgX ZtU2YYcGmoQadMjpzQTf3ggDBodtJ+fgiwEnHdHZwO5RQEITTCMThl/cCjzfkKs3gg== X-Gm-Gg: ASbGncuqFq2BD59/RsE982lyuRiqSD92KuxEGLB3jFG6qDwmEhvHuB7roBeDAoIF1Ug UOCZVT40uxV1JnpZsfi4nO49zFvkuRrRH4v36WNcGewJJ2D2AGCph0qxA381VrWblEtGQ2F9lxp BR7ciBE+XjYQcRMimkpgEPEsqXhhOqy4Ar5+O5tKYhj+JeVDch8669n6CQhmTxKrISmN2akTsU0 i2fCkYRSvTOkxy992llykEMmvbaOHcIBqJKl++pD2Vy6DrDinYLRrRCAx92rwjWHLdb59XWoe3C pFzWFfimUYtmBCny1qshoTJ4AsVMNazjwTNXjqsAP7y83jVgjZN8gDs1P6cv5WRB0eQxkdqpwQv kN55uGfX+r6D6XDFjpPN6LzVEP0fKdejIwkkNmpy2xCS4QXOdFe+6rkFfbIbgYrfd3bVx/2Ypgi CaWstHF1A= X-Google-Smtp-Source: AGHT+IFc+nPMAINYmj2FNm1MI7Ghp4kdfZ10UAkb6RqDo9J7O/en5n2klfUAnHiyjrwiiBET2hez9Q== X-Received: by 2002:a17:906:68d2:b0:ae0:da2f:dcf3 with SMTP id a640c23a62f3a-ae9c9be2d5dmr928860366b.59.1752845303019; Fri, 18 Jul 2025 06:28:23 -0700 (PDT) Message-ID: <48e1c298-0afb-40a3-80a0-a5b97465ce4e@suse.com> Date: Fri, 18 Jul 2025 15:28:21 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 5/6] x86/match-cpu: Support matching on steppings To: Andrew Cooper Cc: =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= , Xen-devel References: <20250716173132.2213891-1-andrew.cooper3@citrix.com> <20250716173132.2213891-6-andrew.cooper3@citrix.com> <03ecaa72-2370-47f7-b84b-83831d188f4e@citrix.com> <29cb9771-ee2a-4c7d-b661-74b37728bc2f@suse.com> <3cefd149-505f-4e29-8018-492886050c6f@citrix.com> Content-Language: en-US From: Jan Beulich Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jOlBhxPqRWv6ND4c9PH1xjQ3NP nxJuMBS8rnNg22uyfAgmBKNLpLgAGVRMZGaGoJObGf72s6TeIqKJo/LtggAS9qAUiuKVnygo 3wjfkS9A3DRO+SpU7JqWdsveeIQyeyEJ/8PTowmSQLakF+3fote9ybzd880fSmFuIEJldWxp Y2ggPGpiZXVsaWNoQHN1c2UuY29tPsJgBBMRAgAgBQJZN5xEAhsDBgsJCAcDAgQVAggDBBYC AwECHgECF4AACgkQoDSui/t3IH4J+wCfQ5jHdEjCRHj23O/5ttg9r9OIruwAn3103WUITZee e7Sbg12UgcQ5lv7SzsFNBFk3nEQQCACCuTjCjFOUdi5Nm244F+78kLghRcin/awv+IrTcIWF hUpSs1Y91iQQ7KItirz5uwCPlwejSJDQJLIS+QtJHaXDXeV6NI0Uef1hP20+y8qydDiVkv6l IreXjTb7DvksRgJNvCkWtYnlS3mYvQ9NzS9PhyALWbXnH6sIJd2O9lKS1Mrfq+y0IXCP10eS FFGg+Av3IQeFatkJAyju0PPthyTqxSI4lZYuJVPknzgaeuJv/2NccrPvmeDg6Coe7ZIeQ8Yj t0ARxu2xytAkkLCel1Lz1WLmwLstV30g80nkgZf/wr+/BXJW/oIvRlonUkxv+IbBM3dX2OV8 AmRv1ySWPTP7AAMFB/9PQK/VtlNUJvg8GXj9ootzrteGfVZVVT4XBJkfwBcpC/XcPzldjv+3 HYudvpdNK3lLujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: <3cefd149-505f-4e29-8018-492886050c6f@citrix.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 18.07.2025 12:29, Andrew Cooper wrote: > On 18/07/2025 6:53 am, Jan Beulich wrote: >> On 17.07.2025 21:39, Andrew Cooper wrote: >>> On 17/07/2025 9:11 am, Jan Beulich wrote: >>>> On 16.07.2025 19:31, Andrew Cooper wrote: >>>>> --- a/xen/arch/x86/cpu/common.c >>>>> +++ b/xen/arch/x86/cpu/common.c >>>>> @@ -1003,13 +1003,15 @@ const struct x86_cpu_id *x86_match_cpu(const struct x86_cpu_id table[]) >>>>> const struct x86_cpu_id *m; >>>>> const struct cpuinfo_x86 *c = &boot_cpu_data; >>>>> >>>>> - for (m = table; m->vendor | m->family | m->model | m->feature; m++) { >>>>> + for (m = table; m->vendor | m->family | m->model | m->steppings | m->feature; m++) { >>>> Nit: Line length. But - do we need the change at all? It looks entirely >>>> implausible to me to use ->steppings with all of vendor, family, and >>>> model being *_ANY (if, as per below, they would be 0 in the first place). >>> I do keep on saying that | like this is pure obfuscation.  This is an >>> excellent example. >>> >>> It's looking for the {} entry, by looking for 0's in all of the metadata >>> fields.  A better check would be *(uint64_t *)m, or perhaps a unioned >>> metadata field, but.. >>> >>> This is also a good demonstration of binary | is a bad thing to use, not >>> only for legibility.  Swapping | for || lets the compiler do: >>> >>> add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-76 (-76) >>> Function                                     old     new   delta >>> x86_match_cpu                                243     167     -76 >>> >>> and the code generation looks much better too: >> Feel free to switch to ||. (The use of | producing worse code is clearly >> a weakness of the compiler. Especially when used on non-adjacent fields >> I expect | to be quite a bit better, first and foremost by ending up >> with just a single conditional branch. Sadly I haven't seen compilers >> do such a transformation for us.) >> >> All of your reply doesn't address my remark regarding whether to check >> ->steppings here, though. (And no, whether to check it shouldn't be >> [solely] justified by the compiler generating better code that way.) > > Well, as stated: "It's looking for the {} entry, by looking for 0's in > all of the metadata fields." > > The intended usage of ->steppings, or ->feature for that matter, is not > relevant to the loop termination condition, which is simply "is all the > metadata 0". > >>>>> uint16_t model; >>>> Whereas the model is strictly limited to 8 bits. >>> There is space in here, if we need it, but you can't shrink it without >>> breaking the check for the NULL entry (going back to the first obfuscation). >> Breaking? Or merely affecting code generation in a negative way? > > Shrinking model without adding (and checking) a new field would mean the > loop condition no longer covers all metadata. And it doesn't strictly need to. It needs to check enough to not mistake a valid entry for a sentinel one. Jan