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 ED8AEC71136 for ; Fri, 13 Jun 2025 21:29:22 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.1014942.1392946 (Exim 4.92) (envelope-from ) id 1uQBxG-0000en-8V; Fri, 13 Jun 2025 21:28:54 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 1014942.1392946; Fri, 13 Jun 2025 21:28:54 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uQBxG-0000eg-4P; Fri, 13 Jun 2025 21:28:54 +0000 Received: by outflank-mailman (input) for mailman id 1014942; Fri, 13 Jun 2025 21:28:53 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uQBxF-0000ea-C7 for xen-devel@lists.xenproject.org; Fri, 13 Jun 2025 21:28:53 +0000 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [2a00:1450:4864:20::329]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 66b57bb3-489d-11f0-a309-13f23c93f187; Fri, 13 Jun 2025 23:28:52 +0200 (CEST) Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-45310223677so21721515e9.0 for ; Fri, 13 Jun 2025 14:28:51 -0700 (PDT) Received: from [192.168.86.29] ([90.250.112.104]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4532e268de2sm63353035e9.40.2025.06.13.14.28.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 13 Jun 2025 14:28:50 -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: 66b57bb3-489d-11f0-a309-13f23c93f187 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1749850131; x=1750454931; 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=cQOKjkQulsizKiLm5UcaiTbCzLcGc8rQoJUelijvatQ=; b=C8mQpD6B6kt+I5SBk8ZbRE2kQehed7hwIlzCfaPhEfIrtDx36T0cbMKXeZoNwMT/Pw YbjG5RC9hVHX9d33AV1CupM5qvdY1GlRXAnoMq7XFnV9EQCvUe1xd7qAZtJ4chQKZ6mo f92fBLmI32wGXBYVPjNaIHz1iNYm/VEYijiBc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749850131; x=1750454931; 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=cQOKjkQulsizKiLm5UcaiTbCzLcGc8rQoJUelijvatQ=; b=emlp0bTQXRz8VkSoKlygCF+1MvAVnHa31YCH4NEAJySvgaqISclgOAMmJNqqvG5cWp B+kJd2oJr7BlblWHDlEeM6immZaMeAs+kMnxZ/g2TnIjXZmFiIvdOsPCWkOfteWT1eTS MTP+SpjANXzWxZReU8sJ6/bP6uskl5TgKhqQMk+zSmHhoGMcPlFyEoIpr4SHECrv1/lV bTfRQgOYg3IRxixhLZdjk9f9Zf3zQRC1uvoGU4J+wti+4YuaTc8Z2RMQ02qiuZ4zyW13 2dhjHqA0cBJNes8CJJD7dfyODVW5Nx9CUdgZZSXNidT0fyjR6nv05GL9RY1UHcfAzZnx oNJg== X-Forwarded-Encrypted: i=1; AJvYcCVXIJFLlO053uFv75DMe8cNYX3bdtxiAV4a6XxW8SExgYf9OsyOgNwrcapRHWulX4K8vW0mUUUPpaM=@lists.xenproject.org X-Gm-Message-State: AOJu0Yyu94u8x5THo1r2VfL2v347UfBBpRE7WgxCxqPY0vljkUsG7Thf Jv8Wh25XUotMy/GOgt0cq4s97HW3q08g6ItvihaeKwbyxxNbofyKsMIOHvPFwsplicw= X-Gm-Gg: ASbGnctG2ikDZCLRjK4+NiIJzpWGsje/sOgkZcQtjn5V1dnClmbKyuXlmuE4eLfWEjO fYqIuZiul7gcLu5Paws/SpGK2pAvDlrKJMxr/WX7oJ2ez8sKkkhJ6CAxqB078xwV8+juZ1KFxzq DytYzaS+0HEpZ41RhaozPFeH0pSoQ9+/q9I0evqgDPwQ8DRXxDKVVzqgl5Rz+tmJCaTKV1dCevw Cv2i2iPisvrlK5rbNENam4hninEOcw23Zh0faMl6U3K4RbWz5fyYuNEr3PE1gYWCiJmLOFv1puC XZrOqR1/KhT5V9j4Cl4n7jXH674KIcBZGlp41KKCRbuGQImbEpA29KJ3VtcPJNMI6EGFRf8Z6Bk = X-Google-Smtp-Source: AGHT+IEGEgciZZYICSnuUD/+VQ46lh9Xp0U/h7JzgyzUX6oywN5jQPRXYnrk1qPrKLI/2bTns0nbOw== X-Received: by 2002:a05:600c:1c90:b0:443:48:66d2 with SMTP id 5b1f17b1804b1-4533caf5cc0mr11920355e9.16.1749850131263; Fri, 13 Jun 2025 14:28:51 -0700 (PDT) Message-ID: Date: Fri, 13 Jun 2025 22:28:50 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/3] x86/EFI: Fix detection of buildid To: Jan Beulich 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-GB From: Andrew Cooper Autocrypt: addr=andrew.cooper3@citrix.com; keydata= xsFNBFLhNn8BEADVhE+Hb8i0GV6mihnnr/uiQQdPF8kUoFzCOPXkf7jQ5sLYeJa0cQi6Penp VtiFYznTairnVsN5J+ujSTIb+OlMSJUWV4opS7WVNnxHbFTPYZVQ3erv7NKc2iVizCRZ2Kxn srM1oPXWRic8BIAdYOKOloF2300SL/bIpeD+x7h3w9B/qez7nOin5NzkxgFoaUeIal12pXSR Q354FKFoy6Vh96gc4VRqte3jw8mPuJQpfws+Pb+swvSf/i1q1+1I4jsRQQh2m6OTADHIqg2E ofTYAEh7R5HfPx0EXoEDMdRjOeKn8+vvkAwhviWXTHlG3R1QkbE5M/oywnZ83udJmi+lxjJ5 YhQ5IzomvJ16H0Bq+TLyVLO/VRksp1VR9HxCzItLNCS8PdpYYz5TC204ViycobYU65WMpzWe LFAGn8jSS25XIpqv0Y9k87dLbctKKA14Ifw2kq5OIVu2FuX+3i446JOa2vpCI9GcjCzi3oHV e00bzYiHMIl0FICrNJU0Kjho8pdo0m2uxkn6SYEpogAy9pnatUlO+erL4LqFUO7GXSdBRbw5 gNt25XTLdSFuZtMxkY3tq8MFss5QnjhehCVPEpE6y9ZjI4XB8ad1G4oBHVGK5LMsvg22PfMJ ISWFSHoF/B5+lHkCKWkFxZ0gZn33ju5n6/FOdEx4B8cMJt+cWwARAQABzSlBbmRyZXcgQ29v cGVyIDxhbmRyZXcuY29vcGVyM0BjaXRyaXguY29tPsLBegQTAQgAJAIbAwULCQgH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K14JdDDHUX2Rs 6+ahAA== In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 10/06/2025 9:01 am, Jan Beulich wrote: > 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? I think my feelings on how xen.efi was done are quite well known, but so what? I've spent longer than I can afford trying to untangle this, and its an impenetrable mess. >>>> 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. Compiling without a CodeView record doesn't magically cause the prior logic to guarantee to succeed. The compiler is forced to emit real conditional logic, and there's almost 2^96 bit-pattens the toolchain could put into memory which will very literally reach the CodeView check. "The toolchain shouldn't cause this path to be executed" is not the same as genuinely unreachable. What safety certification is liable to complain about is the inability to construct a test that demonstrates coverage, but I'm not changing that property with this patch. >>> 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? Because its currently impossible for ARM to have a codeview record. Remember that ARM writes a MZ/PE header by hand in a flat binary.  It does not use a PEP linker. ~Andrew