From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758126AbbIDHKw (ORCPT ); Fri, 4 Sep 2015 03:10:52 -0400 Received: from mail.kapsi.fi ([217.30.184.167]:43777 "EHLO mail.kapsi.fi" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751669AbbIDHKv (ORCPT ); Fri, 4 Sep 2015 03:10:51 -0400 Date: Fri, 4 Sep 2015 10:10:31 +0300 From: Mikko Rapeli To: Ingo Molnar Cc: Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, linux-kernel@vger.kernel.org, Linus Torvalds , Borislav Petkov , Andy Lutomirski Subject: Re: [PATCH] x86/headers: Fix (old) header file dependency bug in uapi/asm/sigcontext32.h Message-ID: <20150904071031.GA9187@lakka.kapsi.fi> References: <1433000370-19509-1-git-send-email-mikko.rapeli@iki.fi> <1433000370-19509-95-git-send-email-mikko.rapeli@iki.fi> <20150902193453.GZ9187@lakka.kapsi.fi> <20150903074231.GA23098@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20150903074231.GA23098@gmail.com> X-SA-Exim-Connect-IP: 2001:1bc8:1004::1 X-SA-Exim-Mail-From: mikko.rapeli@iki.fi X-SA-Exim-Scanned: No (on mail.kapsi.fi); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 03, 2015 at 09:42:32AM +0200, Ingo Molnar wrote: > > * Mikko Rapeli wrote: > > > Hi Ingo, Thomas and Peter, > > > > Do you have any pointers for me how arch/x86/include/uapi/asm/sigcontext32.h > > could be fixed to also compile in userspace? Is definition of _fpx_sw_bytes > > or _fpstate_ia32 even needed there? > > > > Instructions to reproduce the userspace build failure are here: > > https://lkml.org/lkml/2015/5/30/98 > > Yeah, so this is a real bug in the headers, good find. > > Also note that somewhat luckily your testcase is artificial, no real user-space > code can contain that code at the moment because the header never built standalone > in the past either AFAICS. > > So it's an old header file dependency bug, to make it build in user-space you need > to do this workaround: > > #include > #include > > If you only include sigcontext32.h: > > #include > > it will fail to build. > > To fix the bug: > > > > --- a/arch/x86/include/uapi/asm/sigcontext32.h > > > +++ b/arch/x86/include/uapi/asm/sigcontext32.h > > > @@ -45,7 +45,6 @@ struct _fpstate_ia32 { > > > __u32 padding[44]; > > > union { > > > __u32 padding2[12]; > > > - struct _fpx_sw_bytes sw_reserved; > > > }; > > > }; > > No, those fields are real and compat sigframe handling user-space might be relying > on them. > > Does the fix below work for you? Unfortunately no: cc -Wall -c -nostdinc -I /usr/lib/gcc/i586-linux-gnu/5/include -I /usr/lib/gcc/i 586-linux-gnu/5/include-fixed -I . -I ../headers_compile_test_include -I ../head ers_compile_test_include/i586-linux-gnu ./asm/sigcontext32.c In file included from ./asm/sigcontext32.c:1:0: ./asm/sigcontext32.h:12:8: error: redefinition of ‘struct _fpreg’ struct _fpreg { ^ In file included from ./asm/sigcontext32.h:6:0, from ./asm/sigcontext32.c:1: ./asm/sigcontext.h:56:8: note: originally defined here struct _fpreg { ^ In file included from ./asm/sigcontext32.c:1:0: ./asm/sigcontext32.h:17:8: error: redefinition of ‘struct _fpxreg’ struct _fpxreg { ^ In file included from ./asm/sigcontext32.h:6:0, from ./asm/sigcontext32.c:1: ./asm/sigcontext.h:61:8: note: originally defined here struct _fpxreg { ^ In file included from ./asm/sigcontext32.c:1:0: ./asm/sigcontext32.h:23:8: error: redefinition of ‘struct _xmmreg’ struct _xmmreg { ^ In file included from ./asm/sigcontext32.h:6:0, from ./asm/sigcontext32.c:1: ./asm/sigcontext.h:67:8: note: originally defined here struct _xmmreg { ^ FAILED: ./asm/sigcontext32.h I guess this was the reason why I ended with the hack. -Mikko > Thanks, > > Ingo > > =========================> > >From 0bcdebb70e1ae246139df71acfa744ab1629d877 Mon Sep 17 00:00:00 2001 > From: Ingo Molnar > Date: Thu, 3 Sep 2015 09:35:19 +0200 > Subject: [PATCH] x86/headers: Fix (old) header file dependency bug in uapi/asm/sigcontext32.h > > Mikko Rapeli reported that the following standalone user-space header does not compile: > > #include > > Due to undefined 'struct __fpx_sw_bytes' which is defined in asm/sigcontext.h. > > The following header order works: > > #include > #include > > and that's probably how everyone's been using these headers for the past decade or > so, but it's a legit header file dependency bug, so include asm/sigcontext.h in > sigcontext32.h to allow it to be built standlone. > > Reported-by: Mikko Rapeli > Cc: Andy Lutomirski > Cc: Borislav Petkov > Cc: Brian Gerst > Cc: Denys Vlasenko > Cc: H. Peter Anvin > Cc: Linus Torvalds > Cc: Peter Zijlstra > Cc: Thomas Gleixner > Cc: linux-kernel@vger.kernel.org > Signed-off-by: Ingo Molnar > --- > arch/x86/include/uapi/asm/sigcontext32.h | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/arch/x86/include/uapi/asm/sigcontext32.h b/arch/x86/include/uapi/asm/sigcontext32.h > index ad1478c4ae12..ff7826c41a1c 100644 > --- a/arch/x86/include/uapi/asm/sigcontext32.h > +++ b/arch/x86/include/uapi/asm/sigcontext32.h > @@ -3,6 +3,8 @@ > > #include > > +#include > + > /* signal context for 32bit programs. */ > > #define X86_FXSR_MAGIC 0x0000 >