[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [RFC PATCH] libacpi: Fix cross building x86 on arm


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Bertrand Marquis <Bertrand.Marquis@xxxxxxx>
  • Date: Tue, 23 Aug 2022 15:56:59 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com])
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
  • Arc-message-signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=lcZVFge0LIqYKORMto2zGpILYilLeRdPa+Ojl9VHZ7Y=; b=EHgbirSNFndimh423++p7TKh1eco6UepsrjmSFvY1TLQUC44duX7Tz2ptKduv39ufm5/sG2HL6X6YP78j+C8IU/sviyIqfW9uQ74Rv4PLKoCpZ6nAwjPGfZq7nfHSVaQ3VQb8nBPNbBc1g7vOVwYnHadFhBXlVHiteq5CyiaS9+588FG9IEEmrmV012TTs1GWL2KEgXoEyQZ9+f3Yw3TUQqteINcvvKplq2KGEs//x2lyCvhm/NCC1ilI86n3Jttu/EjJ8Q+Co2XEd2xwh5ZRiqvqFx5BX3CtJu50AATrBKO1YV6o8BCDdvFsHSzmvCj63jtHTXBFvodKo+4Khh37A==
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=lcZVFge0LIqYKORMto2zGpILYilLeRdPa+Ojl9VHZ7Y=; b=PFO2XO4SD6PmN1F+f8abv6FHZXqdKcioMcOL0wRSr7x6BuwUXoVBy5xb7UOkqeQO7V2hS455JelWVtAdTGeXqKlJd89JZybTqkblffbV5KikydGD6OEGXkHUDC3/hfCyu2HqechacMTO/k3wmcg1a+M2bgilXYpy6E79aEHTGiWwz0ro7SoYB1oFevX4k5Io3ACBQAPkCXAK0wsH0rrYJxvONCBNLv9Oin8u4Aa2vR+JitOaSc2HdYRoLfmSWJ/5BfVGcURJF5sHrHxzs2GAXWUnu0KzVEowPlqcRYdjL21YuN6DKSxOd0o/1IHihLg3ejSTSE0VdAt86SglAqqMPg==
  • Arc-seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=SgyZHESH59XX0bvdYwhFqGvhVN8dG9NQTr8yDemlZKw63rZTz/YpjEVbVNc2QwKxZ68YDi3+pasNQiwjnAMwnp46+SPcu87qxYP3gehgWwBnLaUc/5Rfm0VpfNTiZcoLZnSq3UeWVDRo268Xjpb/2jr7HSlwnUArDu7t4Cs2AG3TiIfmYbRKRLEFe3s7B/6XEvxY5s3Bgv2H2GsnIyBRi99FPgmlb5GbEqFmqE5qZOH138p4RaA8Jkdf7h9Wb649Ol/hO5VqTnw6X7Rs2H18jucDscKzIRbZ3UHFTBcAaIKgK1gHFyOwboloJInfZi+Dt96QLF3NunBBGpSjFXmtxA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XwC/NQHbmml/8Xw9axxaLN9fq22ppCnLhgghddzdwETevoqhFiqoU2KJfqnTAxQhg7cZerXT/kXnGMKw1Gy84yATNJOB7l276Lk2666TYbx3RW/QVQPnFBtS2+Go52UFNIZXYo+sJ6cT0Mvj17wZcOhTCKKPz+k1LXpv5jFKBwVWcoGQ0HX6pVX+Ziphxbme17K80qYelx+MfZ4q7OfGYQfvz2pQmh8UvrbS7bR9HjzKCh/ImOhmhFLKSeUv/5NXPYr+UESif/9UvbCNqYtnZo8fkfIpL1ufVMJ5CvQiguHLl2/LIa8NgfTQQqIOZMsMmgGJTM2xGr7cHnFZKGqSBQ==
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>, "julien@xxxxxxx" <julien@xxxxxxx>, Wei Liu <wl@xxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Tue, 23 Aug 2022 15:57:20 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Original-authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Thread-index: AQHYttqU3r7Sk/IKHkKroerrTRS8F628a1KAgAARJACAABAJgIAAAokAgAAIAACAAAnuAIAAA0iA
  • Thread-topic: [RFC PATCH] libacpi: Fix cross building x86 on arm


> On 23 Aug 2022, at 16:45, Jan Beulich <jbeulich@xxxxxxxx> wrote:
> 
> On 23.08.2022 17:09, Bertrand Marquis wrote:
>>> On 23 Aug 2022, at 15:41, Bertrand Marquis <Bertrand.Marquis@xxxxxxx> wrote:
>>>> On 23 Aug 2022, at 15:31, Jan Beulich <jbeulich@xxxxxxxx> wrote:
>>>> On 23.08.2022 15:34, Bertrand Marquis wrote:
>>>>>> On 23 Aug 2022, at 13:33, Jan Beulich <jbeulich@xxxxxxxx> wrote:
>>>>>> On 23.08.2022 12:24, Bertrand Marquis wrote:
>>>>>>> --- a/tools/libacpi/mk_dsdt.c
>>>>>>> +++ b/tools/libacpi/mk_dsdt.c
>>>>>>> @@ -18,6 +18,16 @@
>>>>>>> #include <stdlib.h>
>>>>>>> #include <stdbool.h>
>>>>>>> #if defined(CONFIG_X86)
>>>>>>> +/*
>>>>>>> + * When building on non x86 host, arch-x86/xen.h will include xen.h 
>>>>>>> which will
>>>>>>> + * try to include the arch xen.h (for example if built on arm, 
>>>>>>> x86/xen.h will
>>>>>>> + * include xen.h which will include arch-arm.h).
>>>>>>> + * To prevent this effect, define x86 to have the proper sub arch 
>>>>>>> included when
>>>>>>> + * the compiler does not define it.
>>>>>>> + */
>>>>>>> +#if !(defined(__i386__) || defined(__x86_64__))
>>>>>>> +#define __x86_64__
>>>>>>> +#endif
>>>>>> 
>>>>>> Besides being confusing this depends on the order of checks in xen.h.
>>>>>> 
>>>>>>> #include <xen/arch-x86/xen.h>
>>>>>>> #include <xen/hvm/hvm_info_table.h>
>>>>>>> #elif defined(CONFIG_ARM_64)
>>>>>> 
>>>>>> At the very least you will want to #undef the auxiliary define as soon
>>>>>> as practically possible.
>>>>> 
>>>>> Ack
>>>>> 
>>>>>> 
>>>>>> But I think a different solution will want finding. Did you check what
>>>>>> the #include is needed for, really? I've glanced through the file
>>>>>> without being able to spot anything ... After all this is a build tool,
>>>>>> which generally can't correctly use many of the things declared in the
>>>>>> header.
>>>>> 
>>>>> As stated in the comment after the commit message, this is not a good
>>>>> solution but an hack.
>>>>> 
>>>>> Now I do not completely agree here, the tool is not really the problem
>>>>> but the headers are.
>>>> 
>>>> Well - the issue is the tool depending on these headers.
>>> 
>>> Yes but the tool itself cannot solve the issue, we need to have the values
>>> in properly accessible headers.
>>> 
>>>> 
>>>>> There is not such an issue on arm.
>>>> 
>>>> Then why does the tool include xen/arch-arm.h for Arm64?
>>> 
>>> Because this header defines the values required and as no such thing as 
>>> include xen.h.
>>> The point is on arm, the arch-arm.h header does not depend on per cpu 
>>> defines.
>>> 
>>>> 
>>>>> The tool needs at least:
>>>>> HVM_MAX_VCPUS
>>>>> XEN_ACPI_CPU_MAP
>>>>> XEN_ACPI_CPU_MAP_LEN
>>>>> XEN_ACPI_GPE0_CPUHP_BIT
>>>>> 
>>>>> Which are defined in arch-x86/xen.h and hvm_info_table.h.
>>>>> 
>>>>> I am not quite sure how to get those without the current include
>>>> 
>>>> 1) Move those #define-s to a standalone header, which the ones
>>>> currently defining them would simply include. The tool would then
>>>> include _only_ this one header.
>>> 
>>> Shouldn’t we try to unify a little bit what is done on arm and x86 here ?
>>> Not only for this tool but in general in the public headers
> 
> Where possible I'm all for it.
> 
>>> I will try to reduce the problem a bit more to find what we would need to
>>> pull out in a standalone header.
>> 
>> Only the 3 XEN_ACPI_ are needed
> 
> Yet XEN_ACPI_CPU_MAP_LEN drives from HVM_MAX_VCPUS.
> 
>> and those are in fact only used by mk_dsdt.c.
> 
> Well - that's the only thing we talk about here. Building target code
> is fine to use the headers. Building code to run on the build system
> is where the headers should not be used.
> 
>> How about moving those to a xen-acpi.h header and include that one in xen.h ?
> 
> In principle okay, if there wasn't the need for HVM_MAX_VCPUS. With a
> suitable comment it may be okay to live there. I'd be curious what
> others think.

The problem with this already exists in the current status as this is defined in
hvm_info_table.h which is never included from arch-x86/xen.h

Including hvm_info_table.h from xen-acpi.h could create include path issues.

But as those are used nowhere apart from mk_dsdt, I would probably skip the
include of xen-acpi.h from xen.h.

Any chance that those XEN_ACPI_ are needed by some external tools that
could get broken by this modification ?

> 
>> Other solution as those are only used in mk_dsdt, I could just define them 
>> there …
> 
> Please let's try hard to avoid doing so.

Agree

> 
>>>> 2) Seddery on the headers, producing a local one to be used by the
>>>> tool.
>>> 
>>> You mean autogenerating something ? This would just move the problem.
> 
> Why?

You would have to handle the arch specific part there. I would rather prevent 
any
auto-generation here and stick with better defined headers.

> 
> Jan


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.