Re: [Xen-devel] [PATCH] x86emul: keep compiler from using {x, y, z}mm registers itself

2017-10-16 Thread Jan Beulich
>>> On 16.10.17 at 17:05,  wrote:
> On 10/16/2017 01:32 PM, Jan Beulich wrote:
>> Since the emulator acts on the live hardware registers, we need to
>> prevent the compiler from using them e.g. for inlined memcpy() /
>> memset() (as gcc7 does). 
> 
> Why doesn't this affect the rest of the hypervisor too, since we don't
> save and restore the *mm registers?

Because we build the hypervisor with -mno-sse.

>> We can't, however, set this from the command
>> line, as otherwise the 64-bit build would face issues with functions
>> returning floating point values and being declared in standard headers.
> 
> Sorry, just to clarify: You mean that there are standard headers which
> contain prototypes for functions which return floating point values; we
> include those headers but do not call the functions; and adding the
> #pragma to the command-line would cause the compiler to choke on the
> prototypes (even though the functions are never actually called)?

Yes (adding the command line option equivalent of the pragma,
that is).

Jan


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


Re: [Xen-devel] [PATCH] x86emul: keep compiler from using {x, y, z}mm registers itself

2017-10-16 Thread George Dunlap
On 10/16/2017 01:32 PM, Jan Beulich wrote:
> Since the emulator acts on the live hardware registers, we need to
> prevent the compiler from using them e.g. for inlined memcpy() /
> memset() (as gcc7 does). 

Why doesn't this affect the rest of the hypervisor too, since we don't
save and restore the *mm registers?

> We can't, however, set this from the command
> line, as otherwise the 64-bit build would face issues with functions
> returning floating point values and being declared in standard headers.

Sorry, just to clarify: You mean that there are standard headers which
contain prototypes for functions which return floating point values; we
include those headers but do not call the functions; and adding the
#pragma to the command-line would cause the compiler to choke on the
prototypes (even though the functions are never actually called)?

 -George


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


Re: [Xen-devel] [PATCH] x86emul: keep compiler from using {x, y, z}mm registers itself

2017-10-16 Thread Jan Beulich
>>> On 16.10.17 at 14:37,  wrote:
> On 16/10/17 13:32, Jan Beulich wrote:
>> Since the emulator acts on the live hardware registers, we need to
>> prevent the compiler from using them e.g. for inlined memcpy() /
>> memset() (as gcc7 does). We can't, however, set this from the command
>> line, as otherwise the 64-bit build would face issues with functions
>> returning floating point values and being declared in standard headers.
>>
>> As the pragma isn't available prior to gcc6, we need to invoke it
>> conditionally. Luckily up to gcc6 we haven't seen generated code access
>> SIMD registers beyond what our asm()s do.
>>
>> Reported-by: George Dunlap 
>> Signed-off-by: Jan Beulich 
>> ---
>> While this doesn't affect core functionality, I think it would still be
>> nice for it to be allowed in for 4.10.
> 
> Agreed.
> 
> Has this been tested with Clang?

Sorry, no - still haven't got around to set up a suitable Clang
locally.

>  It stands a good chance of being
> compatible, but we may need an && !defined(__clang__) included.

Should non-gcc silently ignore "#pragma GCC ..." it doesn't
recognize, or not define __GNUC__ in the first place if it isn't
sufficiently compatible? I.e. if anything I'd expect we need
"#elif defined(__clang__)" to achieve the same for Clang by
some different pragma (if such exists).

Jan


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


Re: [Xen-devel] [PATCH] x86emul: keep compiler from using {x, y, z}mm registers itself

2017-10-16 Thread Andrew Cooper
On 16/10/17 13:32, Jan Beulich wrote:
> Since the emulator acts on the live hardware registers, we need to
> prevent the compiler from using them e.g. for inlined memcpy() /
> memset() (as gcc7 does). We can't, however, set this from the command
> line, as otherwise the 64-bit build would face issues with functions
> returning floating point values and being declared in standard headers.
>
> As the pragma isn't available prior to gcc6, we need to invoke it
> conditionally. Luckily up to gcc6 we haven't seen generated code access
> SIMD registers beyond what our asm()s do.
>
> Reported-by: George Dunlap 
> Signed-off-by: Jan Beulich 
> ---
> While this doesn't affect core functionality, I think it would still be
> nice for it to be allowed in for 4.10.

Agreed.

Has this been tested with Clang?  It stands a good chance of being
compatible, but we may need an && !defined(__clang__) included.

~Andrew

>
> --- a/tools/tests/x86_emulator/x86-emulate.h
> +++ b/tools/tests/x86_emulator/x86-emulate.h
> @@ -4,6 +4,11 @@
>  #include 
>  #include 
>  #include 
> +
> +#if __GNUC__ >= 6
> +#pragma GCC target("no-sse")
> +#endif
> +
>  #include 
>  
>  #include 
>
>
>


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


[Xen-devel] [PATCH] x86emul: keep compiler from using {x, y, z}mm registers itself

2017-10-16 Thread Jan Beulich
Since the emulator acts on the live hardware registers, we need to
prevent the compiler from using them e.g. for inlined memcpy() /
memset() (as gcc7 does). We can't, however, set this from the command
line, as otherwise the 64-bit build would face issues with functions
returning floating point values and being declared in standard headers.

As the pragma isn't available prior to gcc6, we need to invoke it
conditionally. Luckily up to gcc6 we haven't seen generated code access
SIMD registers beyond what our asm()s do.

Reported-by: George Dunlap 
Signed-off-by: Jan Beulich 
---
While this doesn't affect core functionality, I think it would still be
nice for it to be allowed in for 4.10.

--- a/tools/tests/x86_emulator/x86-emulate.h
+++ b/tools/tests/x86_emulator/x86-emulate.h
@@ -4,6 +4,11 @@
 #include 
 #include 
 #include 
+
+#if __GNUC__ >= 6
+#pragma GCC target("no-sse")
+#endif
+
 #include 
 
 #include 




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