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 C7A74C5B543 for ; Tue, 10 Jun 2025 08:01:41 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.1010564.1388684 (Exim 4.92) (envelope-from ) id 1uOtvE-0004Bx-Dc; Tue, 10 Jun 2025 08:01:28 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 1010564.1388684; Tue, 10 Jun 2025 08:01:28 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uOtvE-0004Bq-Aq; Tue, 10 Jun 2025 08:01:28 +0000 Received: by outflank-mailman (input) for mailman id 1010564; Tue, 10 Jun 2025 08:01:27 +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 1uOtvD-0004Bk-1p for xen-devel@lists.xenproject.org; Tue, 10 Jun 2025 08:01:27 +0000 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [2a00:1450:4864:20::32f]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 16b7fc16-45d1-11f0-b894-0df219b8e170; Tue, 10 Jun 2025 10:01:18 +0200 (CEST) Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-442f4a3a4d6so27504445e9.0 for ; Tue, 10 Jun 2025 01:01:24 -0700 (PDT) Received: from ?IPV6:2003:ca:b734:b49b:5992:e13c:c106:5fe0? (p200300cab734b49b5992e13cc1065fe0.dip0.t-ipconnect.de. [2003:ca:b734:b49b:5992:e13c:c106:5fe0]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-452ec06d9aesm127741865e9.15.2025.06.10.01.01.23 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 10 Jun 2025 01:01:23 -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: 16b7fc16-45d1-11f0-b894-0df219b8e170 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1749542484; x=1750147284; 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=sZk9paXdDCd27tnOfR27Ep0WF1h8iUcDD+Ad36raOo0=; b=MRe4d4rZ08xmqVVZgq9HY3iVXjxZAOMgd4OCIkcT4JYLI6CIjXGRjY+Kpx7WcB6276 iUgG8WrW6PH5q5ynhj2wezitzQs1oFo/YJTfWS0DBrVU0g6fmytEJ79lUYTCeeUnoav0 8D2L0AtywL/fwGGhIjktVSvhVKcRoNQHVU5SN6inqEENtd2UnDOakopTeHSAlECbzIvs BI+o8Ouy/CDh9p0qmJJCFqP8qOJog9sZbvybpF8hoeMQNMcjzLi1i7HOeI4Nh2140ULa apc3NIOptggJys1hD0lHTp27+6WCS4uT4B0syh5KCSEdRtjXm+8A/CHcpn+hyYCAPMF9 YxgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749542484; x=1750147284; 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=sZk9paXdDCd27tnOfR27Ep0WF1h8iUcDD+Ad36raOo0=; b=R27OfdD6D7307PkwD7qFO0D0Y0w84quD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UiPq6ExPTO416qqDhd9Oiplj/HZc2qKyaTC85mtuRoNX7Op9k5fUBwiyQ== X-Received: by 2002:a05:600c:1d0c:b0:439:8878:5029 with SMTP id 5b1f17b1804b1-4531ceb6109mr19686285e9.2.1749542484166; Tue, 10 Jun 2025 01:01:24 -0700 (PDT) Message-ID: Date: Tue, 10 Jun 2025 10:01:23 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/3] x86/EFI: Fix detection of buildid To: Andrew Cooper Cc: Ross Lagerwall , =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= , =?UTF-8?Q?Marek_Marczykowski-G=C3=B3recki?= , "Daniel P . Smith" , Xen-devel References: <20250605111638.2869914-1-andrew.cooper3@citrix.com> <20250605111638.2869914-2-andrew.cooper3@citrix.com> <0a314400-126a-4c2a-b36c-dda61bb0b751@suse.com> <4d1f1b70-e309-453b-bae6-e066d49a417a@suse.com> <9200277c-aa8e-4fd9-ab6a-f9e106114f54@citrix.com> <6eaf2b27-969a-4326-9726-8b6e0994e006@suse.com> <3f9c5a18-2ea1-4e2d-80a0-773abc3598ae@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+AOVBJBACrZcnHAUSuCXBPy0jOlB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cJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: <3f9c5a18-2ea1-4e2d-80a0-773abc3598ae@citrix.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 06.06.2025 17:01, Andrew Cooper wrote: > On 06/06/2025 8:22 am, Jan Beulich wrote: >> On 05.06.2025 19:01, Andrew Cooper wrote: >>> On 05/06/2025 2:24 pm, Jan Beulich wrote: >>>> On 05.06.2025 14:14, Andrew Cooper wrote: >>>>> On 05/06/2025 1:02 pm, Jan Beulich wrote: >>>>>> On 05.06.2025 13:16, Andrew Cooper wrote: >>>>> This really is a property of being a PE32+ binary, and nothing to do >>>>> with EFI. >>>> Which still can be checked for without having this code path being taken >>>> for xen.gz, too: You could e.g. check for &efi > &_end. That's firmly an >>>> image property (yet I expect you're going to sigh about yet another hack). >>> It's all hacks, but no. >>> >>> I'm amazed MISRA hasn't spotted that we've got a global `struct efi >>> efi;` and a label named efi, creating an alias for the object with it >>> out of bounds in the compiled image.  But even then, it's based on >>> XEN_BUILD_EFI not XEN_BUILD_PE and does not distinguish the property >>> that matters. >> The use of XEN_BUILD_EFI in the linker script should have been switched >> to XEN_BUILD_PE when the split was introduced. > > That doesn't build.  As I already explained, the stubs aren't split in a > way that allows that. Which then is a pretty clear indication that the split was wrong to do in the first place, don't you agree? >>> But the argument I'm going to make this this:  Why do you want a check, >>> even if you can find a correct one (and as said before, I cannot)? >>> >>> This function is run exactly once.  We've excluded "nothing given by the >>> toolchain", and excluded "what the toolchain gave us was not the >>> expected ELF note".  The only thing left (modulo toolchain bugs) is the >>> CodeView region, and if it's not a valid CodeView region then we've >>> wasted a handful of cycles. >> Two reasons: Having code which cannot possibly do anything useful isn't >> good. Misra calls the latest the body of the inner if() "unreachable code" >> and objects to the presence of such in a build. > > It's not unreachable code, not even theoretically. How is it not? If we build without this CodeView record, it very much is unreachable. > *If* there was a suitable check, I'd be using it, but everything you've > proposed has been buggy or doesn't even compile. Okay, but we draw different conclusions: You want to do it in a way that, as per above, imo introduces unreachable code. Whereas I keep wanting to find a suitable check (or if necessary introduce whatever is needed to have one). >> And then, based on your reasoning above, why don't you also drop the >> #ifdef CONFIG_X86? > > Because that's the one non-buggy way of excluding an impossible case. > > x86 is the only architecture possibly linking with pep emulation, and > therefore the only architecture to possibly have a CodeView record. And how's the, say, Arm case different from the x86 case with no such record built in? Either it's unreachable code in both cases, or it's not. Jan