From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: David Woodhouse <dwmw2@infradead.org>,
Michael Tokarev <mjt@tls.msk.ru>,
Joao Martins <joao.m.martins@oracle.com>,
QEMU Developers <qemu-devel@nongnu.org>
Cc: Paul Durrant <paul@xen.org>
Subject: Re: xen bits broke x32 build
Date: Mon, 3 Apr 2023 08:46:14 +0200 [thread overview]
Message-ID: <be73a63b-76fb-c223-b93a-a964bae7ed99@linaro.org> (raw)
In-Reply-To: <D03542A7-2475-4BF3-8B32-CBA9447AD393@infradead.org>
On 1/4/23 14:10, David Woodhouse wrote:
> On 1 April 2023 12:57:33 BST, Michael Tokarev <mjt@tls.msk.ru> wrote:
>> 01.04.2023 14:45, Joao Martins пишет:
>>> On 01/04/2023 09:40, Michael Tokarev wrote:
>>>> After bringing in xen guest support, qemu fails to build on x32:
>>>> Adding the folks who added the feature too
>>>
>>>> target/i386/kvm/xen-emu.c:876:5: note: in expansion of macro ‘qemu_build_assert’
>>>> 876 | qemu_build_assert(sizeof(struct vcpu_info) == 64);
>>>> | ^~~~~~~~~~~~~~~~~
>>>>
>>>> This one should be easy to fix, but I wonder if there are other issues
>>>> with x32 exists..
>>>>
>>> Not sure.
>>>
>>> struct vcpu_info is supposed to be 64bytes on both 32-bit and 64-bit builds.
>>>
>>> If anything maybe arch_vcpu_info struct is different on 32-bit and 64-bit...
>>> David, Paul, any ideas?
>>
>> Yes, it is arch_vcpu_info. I assumed it is a trivial thing, but let me explain
>> if it's not the case.
>>
>> include/hw/xen/interface/arch-x86/xen.h :
>>
>> #if defined(__i386__)
>> #include "xen-x86_32.h"
>> #elif defined(__x86_64__)
>> #include "xen-x86_64.h"
>> #endif
>>
>> (I wonder if it ever possible to have none of the two defined).
>>
>> Now, xen-x86_32.h has:
>>
>> struct arch_vcpu_info {
>> unsigned long cr2;
>> unsigned long pad[5]; /* sizeof(vcpu_info_t) == 64 */
>> };
>>
>> Assuming sizeof(long)==32bits. But actually it is 64bits on x32.
>>
>> While xen-x86_64.h has:
>>
>> struct arch_vcpu_info {
>> unsigned long cr2;
>> unsigned long pad; /* sizeof(vcpu_info_t) == 64 */
>> };
>>
>>
>> It looks like for x32, the test in arch-x86/xen.h should be:
>>
>> #if defined(__x86_64__)
>> #include "xen-x86_64.h"
>> #else
>> #include "xen-x86_32.h"
>> #endif
>>
>> since x32 is almost like x86_64. The only difference from x86_64
>> is sizeof(pointer), which is 32bits.
>
> Hm, doesn't x32 also align uint64_t to 64 bits (unlike i386 which only aligns it to 32 bits)?
>
>> Well. Maybe xen support should be disabled entirely on x32.
>> Or maybe x32 should be declared as unsupported entirely.
>> I dunno.
>
> We rely heavily on the struct layouts being precisely the same, since these are ABI for the Xen guests. Wherever there was some 32/64 compatibility issue — and often where there wasn't — that's why I littered it with those build assertions.
>
> But while there are enough in there to sanity check the i386 vs. x86_64 ABI differences, I wouldn't swear that I've put in enough checks for x32. So "it builds without hitting an assertion" does not necessarily mean it'll be *correct*. Let's disable it on x32.
Does "(unsigned) long" type mix well with "ABI"?
next prev parent reply other threads:[~2023-04-03 6:47 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-01 8:40 xen bits broke x32 build Michael Tokarev
2023-04-01 11:45 ` Joao Martins
2023-04-01 11:57 ` Michael Tokarev
2023-04-01 12:10 ` David Woodhouse
2023-04-03 6:46 ` Philippe Mathieu-Daudé [this message]
2023-04-03 8:46 ` David Woodhouse
2023-04-01 12:07 ` Michael Tokarev
2023-04-11 11:56 ` Michael Tokarev
2023-04-11 12:09 ` Peter Maydell
2023-04-11 17:30 ` Michael Tokarev
2023-04-12 10:19 ` Philippe Mathieu-Daudé
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=be73a63b-76fb-c223-b93a-a964bae7ed99@linaro.org \
--to=philmd@linaro.org \
--cc=dwmw2@infradead.org \
--cc=joao.m.martins@oracle.com \
--cc=mjt@tls.msk.ru \
--cc=paul@xen.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).