public inbox for linux-um@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH] um: Fix check for _xstate for older hosts
@ 2017-07-18 23:43 Florian Fainelli
  2017-07-24 12:46 ` Richard Weinberger
  0 siblings, 1 reply; 4+ messages in thread
From: Florian Fainelli @ 2017-07-18 23:43 UTC (permalink / raw)
  To: linux-kernel
  Cc: Florian Fainelli, Jeff Dike, Richard Weinberger, Thomas Gleixner,
	Ingo Molnar, H. Peter Anvin,
	maintainer:X86 ARCHITECTURE 32-BIT AND 64-BIT,
	open list:USER-MODE LINUX, , open list:USER-MODE LINUX

Commit 0a987645672e ("um: Allow building and running on older
hosts") attempted to check for PTRACE_{GET,SET}REGSET under the premise
that these ptrace(2) parameters were directly linked with the presence
of the _xstate structure.

After Richard's commit 61e8d462457f ("um: Correctly check for
PTRACE_GETRESET/SETREGSET") which properly included linux/ptrace.h
instead of asm/ptrace.h, we could get into the original build failure
that I reported:

arch/x86/um/user-offsets.c: In function 'foo':
arch/x86/um/user-offsets.c:54: error: invalid application of 'sizeof' to
incomplete type 'struct _xstate'

On this particular host, we do have PTRACE_GETREGSET and
PTRACE_SETREGSET defined in linux/ptrace.h, but not the structure
_xstate that should be pulled from the following include chain: signal.h
-> bits/sigcontext.h.

Correctly fix this by checking for FP_XSTATE_MAGIC1 which is the correct
way to see if struct _xstate is available or not on the host.

Fixes: 61e8d462457f ("um: Correctly check for PTRACE_GETRESET/SETREGSET")
Fixes: 0a987645672e ("um: Allow building and running on older hosts")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 arch/x86/um/user-offsets.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/um/user-offsets.c b/arch/x86/um/user-offsets.c
index ae4cd58c0c7a..02250b2633b8 100644
--- a/arch/x86/um/user-offsets.c
+++ b/arch/x86/um/user-offsets.c
@@ -50,7 +50,7 @@ void foo(void)
 	DEFINE(HOST_GS, GS);
 	DEFINE(HOST_ORIG_AX, ORIG_EAX);
 #else
-#if defined(PTRACE_GETREGSET) && defined(PTRACE_SETREGSET)
+#ifdef FP_XSTATE_MAGIC1
 	DEFINE(HOST_FP_SIZE, sizeof(struct _xstate) / sizeof(unsigned long));
 #else
 	DEFINE(HOST_FP_SIZE, sizeof(struct _fpstate) / sizeof(unsigned long));
-- 
2.9.3



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

* Re: [PATCH] um: Fix check for _xstate for older hosts
  2017-07-18 23:43 [PATCH] um: Fix check for _xstate for older hosts Florian Fainelli
@ 2017-07-24 12:46 ` Richard Weinberger
  2017-08-18 21:40   ` Florian Fainelli
  0 siblings, 1 reply; 4+ messages in thread
From: Richard Weinberger @ 2017-07-24 12:46 UTC (permalink / raw)
  To: Florian Fainelli
  Cc: LKML, Jeff Dike, Richard Weinberger, Thomas Gleixner, Ingo Molnar,
	H. Peter Anvin, maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT),
	open list:USER-MODE LINUX (UML), open list:USER-MODE LINUX (UML)

On Wed, Jul 19, 2017 at 1:43 AM, Florian Fainelli <f.fainelli@gmail.com> wrote:
> Commit 0a987645672e ("um: Allow building and running on older
> hosts") attempted to check for PTRACE_{GET,SET}REGSET under the premise
> that these ptrace(2) parameters were directly linked with the presence
> of the _xstate structure.
>
> After Richard's commit 61e8d462457f ("um: Correctly check for
> PTRACE_GETRESET/SETREGSET") which properly included linux/ptrace.h
> instead of asm/ptrace.h, we could get into the original build failure
> that I reported:
>
> arch/x86/um/user-offsets.c: In function 'foo':
> arch/x86/um/user-offsets.c:54: error: invalid application of 'sizeof' to
> incomplete type 'struct _xstate'
>
> On this particular host, we do have PTRACE_GETREGSET and
> PTRACE_SETREGSET defined in linux/ptrace.h, but not the structure
> _xstate that should be pulled from the following include chain: signal.h
> -> bits/sigcontext.h.
>
> Correctly fix this by checking for FP_XSTATE_MAGIC1 which is the correct
> way to see if struct _xstate is available or not on the host.
>
> Fixes: 61e8d462457f ("um: Correctly check for PTRACE_GETRESET/SETREGSET")
> Fixes: 0a987645672e ("um: Allow building and running on older hosts")
> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
> ---
>  arch/x86/um/user-offsets.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/x86/um/user-offsets.c b/arch/x86/um/user-offsets.c
> index ae4cd58c0c7a..02250b2633b8 100644
> --- a/arch/x86/um/user-offsets.c
> +++ b/arch/x86/um/user-offsets.c
> @@ -50,7 +50,7 @@ void foo(void)
>         DEFINE(HOST_GS, GS);
>         DEFINE(HOST_ORIG_AX, ORIG_EAX);
>  #else
> -#if defined(PTRACE_GETREGSET) && defined(PTRACE_SETREGSET)
> +#ifdef FP_XSTATE_MAGIC1
>         DEFINE(HOST_FP_SIZE, sizeof(struct _xstate) / sizeof(unsigned long));
>  #else
>         DEFINE(HOST_FP_SIZE, sizeof(struct _fpstate) / sizeof(unsigned long));
> --
> 2.9.3
>

Applied, thanks for fixing!

-- 
Thanks,
//richard


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

* Re: [PATCH] um: Fix check for _xstate for older hosts
  2017-07-24 12:46 ` Richard Weinberger
@ 2017-08-18 21:40   ` Florian Fainelli
  2017-08-18 21:42     ` Richard Weinberger
  0 siblings, 1 reply; 4+ messages in thread
From: Florian Fainelli @ 2017-08-18 21:40 UTC (permalink / raw)
  To: Richard Weinberger
  Cc: LKML, Jeff Dike, Richard Weinberger, Thomas Gleixner, Ingo Molnar,
	H. Peter Anvin, maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT),
	open list:USER-MODE LINUX (UML), open list:USER-MODE LINUX (UML)

On 07/24/2017 05:46 AM, Richard Weinberger wrote:
> On Wed, Jul 19, 2017 at 1:43 AM, Florian Fainelli <f.fainelli@gmail.com> wrote:
>> Commit 0a987645672e ("um: Allow building and running on older
>> hosts") attempted to check for PTRACE_{GET,SET}REGSET under the premise
>> that these ptrace(2) parameters were directly linked with the presence
>> of the _xstate structure.
>>
>> After Richard's commit 61e8d462457f ("um: Correctly check for
>> PTRACE_GETRESET/SETREGSET") which properly included linux/ptrace.h
>> instead of asm/ptrace.h, we could get into the original build failure
>> that I reported:
>>
>> arch/x86/um/user-offsets.c: In function 'foo':
>> arch/x86/um/user-offsets.c:54: error: invalid application of 'sizeof' to
>> incomplete type 'struct _xstate'
>>
>> On this particular host, we do have PTRACE_GETREGSET and
>> PTRACE_SETREGSET defined in linux/ptrace.h, but not the structure
>> _xstate that should be pulled from the following include chain: signal.h
>> -> bits/sigcontext.h.
>>
>> Correctly fix this by checking for FP_XSTATE_MAGIC1 which is the correct
>> way to see if struct _xstate is available or not on the host.
>>
>> Fixes: 61e8d462457f ("um: Correctly check for PTRACE_GETRESET/SETREGSET")
>> Fixes: 0a987645672e ("um: Allow building and running on older hosts")
>> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
>> ---
>>  arch/x86/um/user-offsets.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/x86/um/user-offsets.c b/arch/x86/um/user-offsets.c
>> index ae4cd58c0c7a..02250b2633b8 100644
>> --- a/arch/x86/um/user-offsets.c
>> +++ b/arch/x86/um/user-offsets.c
>> @@ -50,7 +50,7 @@ void foo(void)
>>         DEFINE(HOST_GS, GS);
>>         DEFINE(HOST_ORIG_AX, ORIG_EAX);
>>  #else
>> -#if defined(PTRACE_GETREGSET) && defined(PTRACE_SETREGSET)
>> +#ifdef FP_XSTATE_MAGIC1
>>         DEFINE(HOST_FP_SIZE, sizeof(struct _xstate) / sizeof(unsigned long));
>>  #else
>>         DEFINE(HOST_FP_SIZE, sizeof(struct _fpstate) / sizeof(unsigned long));
>> --
>> 2.9.3
>>
> 
> Applied, thanks for fixing!

Can you submit this to Linus before v4.13 is released? Thank you!
-- 
Florian


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

* Re: [PATCH] um: Fix check for _xstate for older hosts
  2017-08-18 21:40   ` Florian Fainelli
@ 2017-08-18 21:42     ` Richard Weinberger
  0 siblings, 0 replies; 4+ messages in thread
From: Richard Weinberger @ 2017-08-18 21:42 UTC (permalink / raw)
  To: Florian Fainelli
  Cc: Richard Weinberger, LKML, Jeff Dike, Richard Weinberger,
	Thomas Gleixner, Ingo Molnar, H. Peter Anvin,
	maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT),
	open list:USER-MODE LINUX (UML), open list:USER-MODE LINUX (UML)

Am Freitag, 18. August 2017, 23:40:36 CEST schrieb Florian Fainelli:
> On 07/24/2017 05:46 AM, Richard Weinberger wrote:
> > On Wed, Jul 19, 2017 at 1:43 AM, Florian Fainelli <f.fainelli@gmail.com> 
wrote:
> >> Commit 0a987645672e ("um: Allow building and running on older
> >> hosts") attempted to check for PTRACE_{GET,SET}REGSET under the premise
> >> that these ptrace(2) parameters were directly linked with the presence
> >> of the _xstate structure.
> >> 
> >> After Richard's commit 61e8d462457f ("um: Correctly check for
> >> PTRACE_GETRESET/SETREGSET") which properly included linux/ptrace.h
> >> instead of asm/ptrace.h, we could get into the original build failure
> >> that I reported:
> >> 
> >> arch/x86/um/user-offsets.c: In function 'foo':
> >> arch/x86/um/user-offsets.c:54: error: invalid application of 'sizeof' to
> >> incomplete type 'struct _xstate'
> >> 
> >> On this particular host, we do have PTRACE_GETREGSET and
> >> PTRACE_SETREGSET defined in linux/ptrace.h, but not the structure
> >> _xstate that should be pulled from the following include chain: signal.h
> >> -> bits/sigcontext.h.
> >> 
> >> Correctly fix this by checking for FP_XSTATE_MAGIC1 which is the correct
> >> way to see if struct _xstate is available or not on the host.
> >> 
> >> Fixes: 61e8d462457f ("um: Correctly check for PTRACE_GETRESET/SETREGSET")
> >> Fixes: 0a987645672e ("um: Allow building and running on older hosts")
> >> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
> >> ---
> >> 
> >>  arch/x86/um/user-offsets.c | 2 +-
> >>  1 file changed, 1 insertion(+), 1 deletion(-)
> >> 
> >> diff --git a/arch/x86/um/user-offsets.c b/arch/x86/um/user-offsets.c
> >> index ae4cd58c0c7a..02250b2633b8 100644
> >> --- a/arch/x86/um/user-offsets.c
> >> +++ b/arch/x86/um/user-offsets.c
> >> @@ -50,7 +50,7 @@ void foo(void)
> >> 
> >>         DEFINE(HOST_GS, GS);
> >>         DEFINE(HOST_ORIG_AX, ORIG_EAX);
> >>  
> >>  #else
> >> 
> >> -#if defined(PTRACE_GETREGSET) && defined(PTRACE_SETREGSET)
> >> +#ifdef FP_XSTATE_MAGIC1
> >> 
> >>         DEFINE(HOST_FP_SIZE, sizeof(struct _xstate) / sizeof(unsigned
> >>         long));
> >>  
> >>  #else
> >>  
> >>         DEFINE(HOST_FP_SIZE, sizeof(struct _fpstate) / sizeof(unsigned
> >>         long));
> >> 
> >> --
> >> 2.9.3
> > 
> > Applied, thanks for fixing!
> 
> Can you submit this to Linus before v4.13 is released? Thank you!

Sure. The UML queue is just a bit slow, sorry for that.

Thanks,
//richard

-- 
sigma star gmbh - Eduard-Bodem-Gasse 6 - 6020 Innsbruck - Austria
ATU66964118 - FN 374287y


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

end of thread, other threads:[~2017-08-18 21:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-18 23:43 [PATCH] um: Fix check for _xstate for older hosts Florian Fainelli
2017-07-24 12:46 ` Richard Weinberger
2017-08-18 21:40   ` Florian Fainelli
2017-08-18 21:42     ` Richard Weinberger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox