Hi Ady, Would it work if we removed "ifdef EFI_BUILD" condition and just add -mno-red-zone for all x86_64 builds? If not, do you have any ideas how to pass this flag? This could work, because the patch is adding the -mno-red-zone flag only for x86_64 builds, which are only used in the form of the efi64 target. The efi32 and bios targets are both 32-bit. BTW. I also tried 6.04-pre1 and top of tree on the systems where the problem occurs and syslinux would crash, unless it was rebuilt with the -mno-red-zone flag. Best Regards, - Chris On Tue, Oct 18, 2016 at 9:14 PM, Ady Ady via Syslinux <syslinux at zytor.com> wrote:> >> Thank you very much for this, I have been running into this issue a number >> of times but could never get a firm grip on it. >> >> Especially HP Gen9 proliants seem to suffer from it by sometimes throwing a >> stack dump very early in the boot. In the past we worked around it by >> forcing bios boot. >> >> >> >> After rebuilding it with -mno-red-zone the problem appears to be fixed, at >> least after a couple of hours of testing I have not seen it anymore. >> > > Have you tried 6.04-pre1 or later? With pre-built binaries? > > Would you please clarify? Are you saying that 6.04-pre1 is failing too, > but building 6.03 with this proposed patch is working correctly? > > Regards, > Ady. > > PS: In my previous email I wrote "2016Nov"; of course I meant 2015Nov. > > _______________________________________________ > Syslinux mailing list > Submissions to Syslinux at zytor.com > Unsubscribe or set options at: > http://www.zytor.com/mailman/listinfo/syslinux
> Hi Ady, > > Would it work if we removed "ifdef EFI_BUILD" condition and just add > -mno-red-zone for all x86_64 builds? If not, do you have any ideas how > to pass this flag? > > This could work, because the patch is adding the -mno-red-zone flag > only for x86_64 builds, which are only used in the form of the efi64 > target. The efi32 and bios targets are both 32-bit. > > BTW. I also tried 6.04-pre1 and top of tree on the systems where the > problem occurs and syslinux would crash, unless it was rebuilt with > the -mno-red-zone flag. > > Best Regards, > - Chris >The last time the red zone flag was modified in the code was in commit: repo.or.cz/syslinux.git/commit/7d70885d22e4474407637026c1af12a253281407 during 2015Nov. At that time, "EFI_BUILD" was not only in use but was also expanded / passed down to additional makefiles (by the commit just before that one). Then there is this email from Gene: http://www.syslinux.org/archives/2015-December/024641.html but I do not know to which exact commit he was referring when he wrote "pushed". Then "EFI_BUILD" was completely removed by commit: repo.or.cz/syslinux.git/commit/7284652bbd41a0a37ac7146c5e7ae807abdf5748 during 2016Feb. According to some reports, the current use of the -mno-red-zone flag seems to not be enough / correct. It is there, and it is not using "EFI_BUILD" at this time, but the resulting binaries seem to be failing, at least in certain cases. It would be interesting to have a valid patch for the current git master head, or at least for 6.04-pre1. Regards, Ady. PS: Please avoid top-posting.
On 10/19/16 01:37, Chris Dragan via Syslinux wrote:> Hi Ady, > > Would it work if we removed "ifdef EFI_BUILD" condition and just add > -mno-red-zone for all x86_64 builds? If not, do you have any ideas how > to pass this flag? > > This could work, because the patch is adding the -mno-red-zone flag > only for x86_64 builds, which are only used in the form of the efi64 > target. The efi32 and bios targets are both 32-bit. > > BTW. I also tried 6.04-pre1 and top of tree on the systems where the > problem occurs and syslinux would crash, unless it was rebuilt with > the -mno-red-zone flag. >I think this makes sense. Even if we end up with non-EFI x86-64 targets, they almost certainly need the redzone disabled, too; any ring 0 code on x86-64 has to be compiled without red zone due to the way the kernel stack is used by the hardware. -hpa
Thank you all. It looks like -mno-red-zone flag is already in master branch since commit 7d70885d, but it seems it is applied to all EFI builds. IIUC, the problem only affects efi64 builds. So here's the modification of my patch to only apply -mno-red-zone flag to efi64 target. The patch is against master. I verified that it builds correctly in master. Please feel free to accept or reject this solution. Best Regards, - Chris The patch: Makefile: add -mno-red-zone only to efi64 objects x86_64 EFI requires that all sources are compiled without red zone, which is not supported by the Windows ABI. Without this, syslinux crashes on some UEFI implementations. --- syslinux.orig/mk/com32.mk +++ syslinux/mk/com32.mk @@ -29,6 +29,9 @@ ifeq ($(strip $(ARCH)),x86_64) GCCOPT += $(call gcc_ok,-m64,) GCCOPT += $(call gcc_ok,-march=x86-64) +ifeq ($(FWCLASS),EFI) + GCCOPT += $(call gcc_ok,-mno-red-zone) +endif #let the stack-boundary default to whatever it is on 64bit #GCCOPT += $(call gcc_ok,-mpreferred-stack-boundary=8,) #GCCOPT += $(call gcc_ok,-incoming-stack-boundary=8,) @@ -48,9 +51,7 @@ GCCOPT += $(call gcc_ok,-falign-labels=0,-malign-labels=0) GCCOPT += $(call gcc_ok,-falign-loops=0,-malign-loops=0) -ifeq ($(FWCLASS),EFI) -GCCOPT += -mno-red-zone -else +ifneq ($(FWCLASS),EFI) GCCOPT += -mregparm=3 -DREGPARM=3 endif --- syslinux.orig/mk/efi.mk +++ syslinux/mk/efi.mk @@ -17,6 +17,7 @@ endif ifeq ($(ARCH),x86_64) ARCHOPT = -m64 -march=x86-64 + ARCHOPT += -mno-red-zone EFI_SUBARCH = $(ARCH) endif @@ -29,7 +32,7 @@ -I$(core)/include -I$(core)/ $(ARCHOPT) \ -I$(com32)/lib/ -I$(com32)/libutil/include -std=gnu99 \ -DELF_DEBUG -DSYSLINUX_EFI -I$(objdir) \ - $(GCCWARN) -D__COM32__ -D__FIRMWARE_$(FIRMWARE)__ -mno-red-zone \ + $(GCCWARN) -D__COM32__ -D__FIRMWARE_$(FIRMWARE)__ \ -DLDLINUX=\"$(LDLINUX)\" -fvisibility=hidden \ -Wno-unused-parameter $(GCCOPT) --- syslinux.orig/mk/elf.mk +++ syslinux/mk/elf.mk @@ -27,6 +27,9 @@ ifeq ($(ARCH),x86_64) GCCOPT += $(call gcc_ok,-m64,) GCCOPT += $(call gcc_ok,-march=x86-64) +ifeq ($(FWCLASS),EFI) + GCCOPT += $(call gcc_ok,-mno-red-zone) +endif #let preferred-stack-boundary be default (=4) endif GCCOPT += -Os -fomit-frame-pointer @@ -60,9 +63,7 @@ -I$(com32)/libutil/include -I$(com32)/include \ -I$(com32)/include/sys $(GPLINCLUDE) -I$(core)/include \ -I$(objdir) -DLDLINUX=\"$(LDLINUX)\" -ifeq ($(FWCLASS),EFI) -GCCOPT += -mno-red-zone -else +ifneq ($(FWCLASS),EFI) GCCOPT += -mregparm=3 -DREGPARM=3 endif --- syslinux.orig/mk/embedded.mk +++ syslinux/mk/embedded.mk @@ -30,6 +30,9 @@ ifeq ($(ARCH),x86_64) GCCOPT := $(call gcc_ok,-m64) GCCOPT += $(call gcc_ok,-march=x86-64) +ifeq ($(FWCLASS),EFI) + GCCOPT += $(call gcc_ok,-mno-red-zone) +endif #let preferred-stack-boundary and incoming-stack-boundary be default(=4) # Somewhere down the line ld barfs requiring -fPIC GCCOPT += $(call gcc_ok,-fPIC) @@ -39,7 +42,7 @@ GCCOPT += $(call gcc_ok,-fwrapv,) GCCOPT += $(call gcc_ok,-freg-struct-return,) ifeq ($(FWCLASS),EFI) -GCCOPT += -Os -fomit-frame-pointer -msoft-float -mno-red-zone +GCCOPT += -Os -fomit-frame-pointer -msoft-float else GCCOPT += -Os -fomit-frame-pointer -mregparm=3 -DREGPARM=3 -msoft-float endif --- syslinux.orig/mk/lib.mk +++ syslinux/mk/lib.mk @@ -12,6 +12,9 @@ endif ifeq ($(ARCH),x86_64) GCCOPT += $(call gcc_ok,-m64,) +ifeq ($(FWCLASS),EFI) + GCCOPT += $(call gcc_ok,-mno-red-zone) +endif #let preferred-stack-boundary be default(=4) MARCH = x86-64 endif @@ -54,9 +57,7 @@ CFLAGS = $(OPTFLAGS) $(REQFLAGS) $(WARNFLAGS) $(LIBFLAGS) -ifeq ($(FWCLASS),EFI) -CFLAGS += -mno-red-zone -else +ifneq ($(FWCLASS),EFI) CFLAGS += -mregparm=3 -DREGPARM=3 endif
> Thank you all. > > It looks like -mno-red-zone flag is already in master branch since > commit 7d70885d, but it seems it is applied to all EFI builds.Finally we are on the same page.> > IIUC, the problem only affects efi64 builds.Have you actually tested efi32 (ia32) builds?> > So here's the modification of my patch to only apply -mno-red-zone > flag to efi64 target. The patch is against master. I verified that it > builds correctly in master. Please feel free to accept or reject this > solution. > > Best Regards, > - ChrisI still have some problem understanding this situation (FWIW). If the -mno-red-zone flag was already applied for all EFI builds (in the current git master head and in 6.04-pre1), then what exactly makes the current 6.04-pre1 *pre-built* binaries fail for you? As Jur van der Burg reported, 6.04-pre1 works just as well as your previously-proposed patch; so, what exactly are we changing now that is not already achieved in the current code? I am failing to grasp what exactly was making it fail for you. I apologize if these questions are trivial to others; to me they are not. Anyway, I appreciate contributions and I hope to see more active and effective Syslinux development. Regards, Ady.