From: "Roger Pau Monné" <roger.pau@citrix.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: Alejandro Vallejo <alejandro.vallejo@cloud.com>,
xen-devel@lists.xenproject.org,
Andrew Cooper <andrew.cooper3@citrix.com>,
Oleksii Kurochko <oleksii.kurochko@gmail.com>
Subject: Re: [PATCH for-4.19] x86/altcall: fix clang code-gen when using altcall in loop constructs
Date: Wed, 24 Jul 2024 11:13:08 +0200 [thread overview]
Message-ID: <ZqDFpLbGe_HmTrTF@macbook> (raw)
In-Reply-To: <4a1bae1e-16d2-4536-b69a-1fff8179ee86@suse.com>
On Wed, Jul 24, 2024 at 10:41:43AM +0200, Jan Beulich wrote:
> On 24.07.2024 10:28, Roger Pau Monné wrote:
> > The only way I've found to cope with this is to use something like:
> >
> > #define ALT_CALL_ARG(arg, n) \
> > union { \
> > typeof(arg) e[(sizeof(long) + sizeof(arg) - 1) / sizeof(arg)]; \
> > unsigned long r; \
> > } a ## n ## __ = { \
> > .e[0] = ({ BUILD_BUG_ON(sizeof(arg) > sizeof(void *)); (arg); })\
> > }; \
> > register unsigned long a ## n ## _ asm ( ALT_CALL_arg ## n ) = \
> > a ## n ## __.r
> >
> > An oversized array that ensures all the space of the long is covered
> > by the array, but then we need an extra variable, as we would
> > otherwise require modifying ALT_CALL{0..6}_OUT to use aX_.r instead of
> > aX_.
>
> I don't think we need to over-size the array. It just gets yet a little
> more complex then:
>
> #define ALT_CALL_ARG(arg, n) \
> register union { \
> struct { \
> typeof(arg) e; \
> char pad[sizeof(long) - sizeof(arg)]; \
> } s; \
> unsigned long r; \
> } a ## n ## _ asm ( ALT_CALL_arg ## n ) = { \
> .s.e = ({ BUILD_BUG_ON(sizeof(arg) > sizeof(void *)); (arg); }) \
> }
We could even simplify this, there's no need for the union anymore,
since struct size == sizeof(long) already:
#define ALT_CALL_ARG(arg, n) \
register struct { \
typeof(arg) e; \
char pad[sizeof(long) - sizeof(arg)]; \
} a ## n ## _ asm ( ALT_CALL_arg ## n ) = { \
.e = ({ BUILD_BUG_ON(sizeof(arg) > sizeof(void *)); (arg); }) \
}
The above seems to work for both the original issue and the new one.
Thanks, Roger.
next prev parent reply other threads:[~2024-07-24 9:13 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-23 9:31 [PATCH for-4.19] x86/altcall: fix clang code-gen when using altcall in loop constructs Roger Pau Monne
2024-07-23 9:56 ` oleksii.kurochko
2024-07-23 10:07 ` Jan Beulich
2024-07-23 15:37 ` Alejandro Vallejo
2024-07-23 16:09 ` Roger Pau Monné
2024-07-23 16:24 ` Alejandro Vallejo
2024-07-24 6:39 ` Jan Beulich
2024-07-24 8:28 ` Roger Pau Monné
2024-07-24 8:41 ` Jan Beulich
2024-07-24 9:13 ` Roger Pau Monné [this message]
2024-07-24 9:16 ` Jan Beulich
2024-07-24 9:23 ` Roger Pau Monné
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=ZqDFpLbGe_HmTrTF@macbook \
--to=roger.pau@citrix.com \
--cc=alejandro.vallejo@cloud.com \
--cc=andrew.cooper3@citrix.com \
--cc=jbeulich@suse.com \
--cc=oleksii.kurochko@gmail.com \
--cc=xen-devel@lists.xenproject.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.