From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id E78081FF146 for ; Tue, 12 May 2026 11:00:47 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 011D49D99; Tue, 12 May 2026 11:00:46 +0200 (CEST) Date: Tue, 12 May 2026 11:00:40 +0200 From: Arthur Bied-Charreton To: Fiona Ebner Subject: Re: [PATCH docs/manager/qemu-server v4 00/17] Add API and UI for custom CPU models Message-ID: References: <20260430160109.565536-1-a.bied-charreton@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1778576329915 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.762 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: SQG5N43AHGL2VTVMAQYODL7XDI7YBANP X-Message-ID-Hash: SQG5N43AHGL2VTVMAQYODL7XDI7YBANP X-MailFrom: a.bied-charreton@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: pve-devel@lists.proxmox.com X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Tue, May 12, 2026 at 10:50:48AM +0200, Fiona Ebner wrote: > Am 12.05.26 um 10:09 AM schrieb Arthur Bied-Charreton: > > On Mon, May 11, 2026 at 12:42:02PM +0200, Fiona Ebner wrote: > >> I found a pre-existing bug in query_supported_cpu_flags() that we should > >> fix. Namely the following replacement is wrong in general: > >> > >>> foreach my $prop (keys %$props) { > >>> next if $props->{$prop} ne '1'; > > Oh, and we should compare against JSON::true here, since the CPU model > expansion also contains numeric, non-flag properties. While none of them > are 1 on my machine, not sure if that's the case everywhere and it's > rather for future-proofing. > yes, will change that as well, thanks for catching that > >>> # QEMU returns some flags multiple times, with '_', '.' or '-' > >>> # (e.g. lahf_lm and lahf-lm; sse4.2, sse4-2 and sse4_2; ...). > >>> # We only keep those with underscores, to match /proc/cpuinfo > >>> $prop =~ s/\.|-/_/g; > >>> $flags->{$prop} = 1; > >>> } > >> > >> In particular, flags like 'virt-ssbd' or 'amd-ssbd' or 'amd-no-ssb' are > >> not present multiple times, but only in their exact form. Because of the > >> replacement, we only consider e.g. 'virt_ssbd' and then mistakenly > >> detect the flags as not supported on any node. > >> > >> Let's just make an explicit map of what is actually duplicate and not do > >> such general replacement here. > > > > After looking a little more into it I think we should also apply the > > same logic to the recognized CPU flags, or normalize the flags in > > query_supported_cpu_flags() to match the `qemu-system-$arch -cpu help` > > output rather than /proc/cpuinfo, since that is the source we use? > > > > For example, /proc/cpuinfo writes the sse4.2 flag as sse4_2, while > > `qemu-system-$arch -cpu help` writes it as sse4.2, so normalizing it to > > sse4_2 in query_supported_cpu_flags() means it does not match anything > > in the output of query_understood_cpu_flags(). QEMU accepts both > > versions. > > > > Is there a reason why we need to match /proc/cpuinfo specifically that > > I am overlooking, or is it just about having a consistent output for CPU > > flags in general? > > Yes, I too suppose it was done with the expectation to somehow > incorporate information from /proc/cpuinfo, but we don't need that. > Let's align the flags with their proper, unaliased names in QEMU. See > the x86_cpu_initfn() in target/i386/cpu.c for the list of aliases. We thanks, that's very helpful! > can just skip the aliases when iterating the result from the queried CPU > model expansion here. Of course, a code comment that QEMU uses a > different form from /proc/cpuinfo for some flags would be good. ack, will do - thanks!