xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Wei Liu <wei.liu2@citrix.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
	Wei Liu <wei.liu2@citrix.com>,
	xen-devel <xen-devel@lists.xenproject.org>
Subject: Re: Ping: [PATCH v2] x86/EFI: meet further spec requirements for runtime calls
Date: Tue, 22 Nov 2016 10:35:48 +0000	[thread overview]
Message-ID: <20161122103548.GL23528@citrix.com> (raw)
In-Reply-To: <583427710200007800120914@prv-mh.provo.novell.com>

On Tue, Nov 22, 2016 at 03:09:37AM -0700, Jan Beulich wrote:
> >>> On 15.11.16 at 17:06, <JBeulich@suse.com> wrote:
> >>>> On 15.11.16 at 16:47, <andrew.cooper3@citrix.com> wrote:
> >> On 14/11/16 10:32, Jan Beulich wrote:
> >>> So far we didn't guarantee 16-byte alignment of the stack: While (so
> >>> far) we don't tell the compiler to use smaller alignment, we also don't
> >>> guarantee 16-byte alignment when establishing stack pointers for new
> >>> vCPU-s. Runtime service functions using SSE instructions may end with
> >>> #GP(0) without that.
> >>>
> >>> Note that making use of -mpreferred-stack-boundary=3, as mentioned in
> >>> the comment, wouldn't help to reduce the needed alignment: The compiler
> >>> would then be free to align the stack of the function with the aligned
> >>> object, but would be permitted to place an odd number of 8-byte objects
> >>> there, resulting in the callee to still run on an unaligned stack.
> >>>
> >>> (The only working alternative to the approach chosen here would be to
> >>> use -mincoming-stack-boundary=3, but that would affect all functions in
> >>> runtime.c, not just the ones actually making runtime services calls.
> >>> And it would still require the manual alignment logic here to be used
> >>> with gcc 5.2 and earlier - not permitting that command line option -,
> >>> just that then the alignment amount would become conditional.)
> >>>
> >>> Hence enforce the needed alignment by making efi_rs_enter() return a
> >>> suitably aligned structure, which the caller then necessarily has to
> >>> store in a suitably aligned local variable, the address of which then
> >>> gets passed to efi_rs_leave(). Also (to limit exposure) move the
> >>> function declarations to where they belong: They're local to runtime.c,
> >>> and shared only with compat.c (by the latter including the former).
> >> 
> >> Why does this guarantee alignment?  What prevents the compiler from
> >> reordering the items in its stack layout?
> > 
> > The compiler will always allocate stack variables such that called
> > functions will see an ABI-compliant stack. Without variables of
> > bigger alignment, it does this by implying that the current function
> > also has an aligned stack. Since we start out with a stack frame on
> > an 8 mod 16 boundary, said compiler behavior propagates
> > this through all call hierarchies. With variables of bigger alignment
> > the compiler arranges for the current frame to be suitably
> > expanded, and it will of course continue to guarantee that all
> > callees get to see a 16-byte aligned stack. IOW all we need to do
> > is break this 8 mod 16 thing once.
> 
> Ping? We have a problem to solve here, so I think I can expect that
> either the proposed solution (even if not covering all theoretical
> cases of possibly compiler behavior) is accepted, or an alternative
> proposal is put up. I'd really like to avoid seeing 4.8 go out with the
> problem un-addressed. (From a strictly formal perspective, me being
> the only maintainer of EFI code, I could put the patch in without any
> ack [other than Wei's release one], but I'd like to avoid that if at all
> possible.)
> 

I can't judge the technical correctness of this patch. I think it would
be good to fix this, so:

Release-acked-by: Wei Liu <wei.liu2@citrix.com>

> Jan
> 

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  reply	other threads:[~2016-11-22 10:35 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-14 10:32 [PATCH v2] x86/EFI: meet further spec requirements for runtime calls Jan Beulich
2016-11-15 15:47 ` Andrew Cooper
2016-11-15 16:06   ` Jan Beulich
2016-11-22 10:09     ` Ping: " Jan Beulich
2016-11-22 10:35       ` Wei Liu [this message]
2016-11-22 10:41       ` Andrew Cooper
2016-11-22 11:08         ` Jan Beulich

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=20161122103548.GL23528@citrix.com \
    --to=wei.liu2@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=andrew.cooper3@citrix.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 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).