All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] x86emul/test: generate non-pie executable for 64bit builds
@ 2017-09-25 13:40 Wei Liu
  2017-09-25 13:58 ` Jan Beulich
  0 siblings, 1 reply; 5+ messages in thread
From: Wei Liu @ 2017-09-25 13:40 UTC (permalink / raw)
  To: Xen-devel; +Cc: Andrew Cooper, Wei Liu, Jan Beulich

PIE may (and commonly will) result in the binary being loaded above
the 4Gb boundary, which can't work with at least the VZEROUPPER compat
mode test.

Add -no-pie when appropriate so that linker won't generate a PIE
executable.

Reported-by: Wei Liu <wei.liu2@citrix.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>

With this patch, vzeroupper passes, but one other test fails.
Testing SSE packed single 64-bit code sequence...[line 368] failed!
---
 tools/tests/x86_emulator/Makefile | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tools/tests/x86_emulator/Makefile b/tools/tests/x86_emulator/Makefile
index fd13ab53b1..87064494d1 100644
--- a/tools/tests/x86_emulator/Makefile
+++ b/tools/tests/x86_emulator/Makefile
@@ -76,7 +76,7 @@ $(addsuffix .c,$(SIMD)) $(addsuffix -avx.c,$(filter sse%,$(SIMD))):
 	ln -sf simd.c $@
 
 $(TARGET): x86_emulate.o test_x86_emulator.o
-	$(HOSTCC) -o $@ $^
+	$(HOSTCC) $(HOSTCFLAGS) -o $@ $^
 
 .PHONY: clean
 clean:
@@ -98,7 +98,9 @@ asm:
 
 asm/%: asm ;
 
-HOSTCFLAGS += $(CFLAGS_xeninclude) -I.
+HOSTCFLAGS-x86_64 :=
+$(call cc-option-add,HOSTCFLAGS-x86_64,HOSTCC,-no-pie)
+HOSTCFLAGS += $(CFLAGS_xeninclude) -I. $(HOSTCFLAGS-$(XEN_COMPILE_ARCH))
 
 x86.h := asm/x86-vendors.h asm/x86-defns.h asm/msr-index.h
 x86_emulate.h := x86_emulate.h x86_emulate/x86_emulate.h $(x86.h)
-- 
2.11.0


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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] x86emul/test: generate non-pie executable for 64bit builds
  2017-09-25 13:40 [PATCH v2] x86emul/test: generate non-pie executable for 64bit builds Wei Liu
@ 2017-09-25 13:58 ` Jan Beulich
  2017-09-25 14:11   ` Wei Liu
  0 siblings, 1 reply; 5+ messages in thread
From: Jan Beulich @ 2017-09-25 13:58 UTC (permalink / raw)
  To: Wei Liu; +Cc: AndrewCooper, Xen-devel

>>> On 25.09.17 at 15:40, <wei.liu2@citrix.com> wrote:
> --- a/tools/tests/x86_emulator/Makefile
> +++ b/tools/tests/x86_emulator/Makefile
> @@ -76,7 +76,7 @@ $(addsuffix .c,$(SIMD)) $(addsuffix -avx.c,$(filter sse%,$(SIMD))):
>  	ln -sf simd.c $@
>  
>  $(TARGET): x86_emulate.o test_x86_emulator.o
> -	$(HOSTCC) -o $@ $^
> +	$(HOSTCC) $(HOSTCFLAGS) -o $@ $^
>  
>  .PHONY: clean
>  clean:
> @@ -98,7 +98,9 @@ asm:
>  
>  asm/%: asm ;
>  
> -HOSTCFLAGS += $(CFLAGS_xeninclude) -I.
> +HOSTCFLAGS-x86_64 :=
> +$(call cc-option-add,HOSTCFLAGS-x86_64,HOSTCC,-no-pie)
> +HOSTCFLAGS += $(CFLAGS_xeninclude) -I. $(HOSTCFLAGS-$(XEN_COMPILE_ARCH))

Hmm, so other than one could imply from gcc doc we get away
without using -fno-PIE at all, i.e. it's only an issue with how
linking is being done? Wouldn't it be better then to pass both (as
long as supported, if we really care about older compilers here)?

Jan


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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] x86emul/test: generate non-pie executable for 64bit builds
  2017-09-25 13:58 ` Jan Beulich
@ 2017-09-25 14:11   ` Wei Liu
  2017-09-25 14:25     ` Jan Beulich
  0 siblings, 1 reply; 5+ messages in thread
From: Wei Liu @ 2017-09-25 14:11 UTC (permalink / raw)
  To: Jan Beulich; +Cc: AndrewCooper, Wei Liu, Xen-devel

On Mon, Sep 25, 2017 at 07:58:15AM -0600, Jan Beulich wrote:
> >>> On 25.09.17 at 15:40, <wei.liu2@citrix.com> wrote:
> > --- a/tools/tests/x86_emulator/Makefile
> > +++ b/tools/tests/x86_emulator/Makefile
> > @@ -76,7 +76,7 @@ $(addsuffix .c,$(SIMD)) $(addsuffix -avx.c,$(filter sse%,$(SIMD))):
> >  	ln -sf simd.c $@
> >  
> >  $(TARGET): x86_emulate.o test_x86_emulator.o
> > -	$(HOSTCC) -o $@ $^
> > +	$(HOSTCC) $(HOSTCFLAGS) -o $@ $^
> >  
> >  .PHONY: clean
> >  clean:
> > @@ -98,7 +98,9 @@ asm:
> >  
> >  asm/%: asm ;
> >  
> > -HOSTCFLAGS += $(CFLAGS_xeninclude) -I.
> > +HOSTCFLAGS-x86_64 :=
> > +$(call cc-option-add,HOSTCFLAGS-x86_64,HOSTCC,-no-pie)
> > +HOSTCFLAGS += $(CFLAGS_xeninclude) -I. $(HOSTCFLAGS-$(XEN_COMPILE_ARCH))
> 
> Hmm, so other than one could imply from gcc doc we get away
> without using -fno-PIE at all, i.e. it's only an issue with how
> linking is being done?

Yeah, it was ld that complained.

> Wouldn't it be better then to pass both (as
> long as supported, if we really care about older compilers here)?

I'm fine with that. -fno-PIE is supported a long time ago. I can fold in
the following diff to this patch.

diff --git a/tools/tests/x86_emulator/Makefile
b/tools/tests/x86_emulator/Makefile
index 87064494d1..fbe02cd2f9 100644
--- a/tools/tests/x86_emulator/Makefile
+++ b/tools/tests/x86_emulator/Makefile
@@ -98,7 +98,7 @@ asm:

 asm/%: asm ;

-HOSTCFLAGS-x86_64 :=
+HOSTCFLAGS-x86_64 := -fno-PIE
 $(call cc-option-add,HOSTCFLAGS-x86_64,HOSTCC,-no-pie)
 HOSTCFLAGS += $(CFLAGS_xeninclude) -I.  $(HOSTCFLAGS-$(XEN_COMPILE_ARCH))

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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] x86emul/test: generate non-pie executable for 64bit builds
  2017-09-25 14:11   ` Wei Liu
@ 2017-09-25 14:25     ` Jan Beulich
  2017-09-25 14:27       ` Wei Liu
  0 siblings, 1 reply; 5+ messages in thread
From: Jan Beulich @ 2017-09-25 14:25 UTC (permalink / raw)
  To: Wei Liu; +Cc: AndrewCooper, Xen-devel

>>> On 25.09.17 at 16:11, <wei.liu2@citrix.com> wrote:
> On Mon, Sep 25, 2017 at 07:58:15AM -0600, Jan Beulich wrote:
>> Wouldn't it be better then to pass both (as
>> long as supported, if we really care about older compilers here)?
> 
> I'm fine with that. -fno-PIE is supported a long time ago. I can fold in
> the following diff to this patch.
> 
> diff --git a/tools/tests/x86_emulator/Makefile
> b/tools/tests/x86_emulator/Makefile
> index 87064494d1..fbe02cd2f9 100644
> --- a/tools/tests/x86_emulator/Makefile
> +++ b/tools/tests/x86_emulator/Makefile
> @@ -98,7 +98,7 @@ asm:
> 
>  asm/%: asm ;
> 
> -HOSTCFLAGS-x86_64 :=
> +HOSTCFLAGS-x86_64 := -fno-PIE
>  $(call cc-option-add,HOSTCFLAGS-x86_64,HOSTCC,-no-pie)
>  HOSTCFLAGS += $(CFLAGS_xeninclude) -I.  $(HOSTCFLAGS-$(XEN_COMPILE_ARCH))

Feel free to commit with that addition (or tell me that I should),
or maybe Andrew could give his ack.

Thanks for your help here, Jan


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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] x86emul/test: generate non-pie executable for 64bit builds
  2017-09-25 14:25     ` Jan Beulich
@ 2017-09-25 14:27       ` Wei Liu
  0 siblings, 0 replies; 5+ messages in thread
From: Wei Liu @ 2017-09-25 14:27 UTC (permalink / raw)
  To: Jan Beulich; +Cc: AndrewCooper, Wei Liu, Xen-devel

On Mon, Sep 25, 2017 at 08:25:43AM -0600, Jan Beulich wrote:
> >>> On 25.09.17 at 16:11, <wei.liu2@citrix.com> wrote:
> > On Mon, Sep 25, 2017 at 07:58:15AM -0600, Jan Beulich wrote:
> >> Wouldn't it be better then to pass both (as
> >> long as supported, if we really care about older compilers here)?
> > 
> > I'm fine with that. -fno-PIE is supported a long time ago. I can fold in
> > the following diff to this patch.
> > 
> > diff --git a/tools/tests/x86_emulator/Makefile
> > b/tools/tests/x86_emulator/Makefile
> > index 87064494d1..fbe02cd2f9 100644
> > --- a/tools/tests/x86_emulator/Makefile
> > +++ b/tools/tests/x86_emulator/Makefile
> > @@ -98,7 +98,7 @@ asm:
> > 
> >  asm/%: asm ;
> > 
> > -HOSTCFLAGS-x86_64 :=
> > +HOSTCFLAGS-x86_64 := -fno-PIE
> >  $(call cc-option-add,HOSTCFLAGS-x86_64,HOSTCC,-no-pie)
> >  HOSTCFLAGS += $(CFLAGS_xeninclude) -I.  $(HOSTCFLAGS-$(XEN_COMPILE_ARCH))
> 
> Feel free to commit with that addition (or tell me that I should),
> or maybe Andrew could give his ack.
> 

I will commit it soon. I will add your ack too.

> Thanks for your help here, Jan
> 

You're welcome.

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-09-25 14:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-25 13:40 [PATCH v2] x86emul/test: generate non-pie executable for 64bit builds Wei Liu
2017-09-25 13:58 ` Jan Beulich
2017-09-25 14:11   ` Wei Liu
2017-09-25 14:25     ` Jan Beulich
2017-09-25 14:27       ` Wei Liu

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.