Mailing List Archive

[PATCH mini-os enhancements for vtpm 7/8] add floating point and sse to mini-os
This patch adds floating point and sse support to mini-os by
initializing the floating point unit and the see unit during domain boot up.


Signed of by: Matthew Fioravante matthew.fioravante@jhuapl.edu

diff --git a/extras/mini-os/arch/x86/setup.c
b/extras/mini-os/arch/x86/setup.c
--- a/extras/mini-os/arch/x86/setup.c
+++ b/extras/mini-os/arch/x86/setup.c
@@ -74,9 +74,28 @@ shared_info_t *map_shared_info(unsigned long pa)
return (shared_info_t *)shared_info;
}

+static inline void fpu_init(void) {
+ asm volatile("fninit");
+}
+
+#ifdef __SSE__
+static inline void sse_init(void) {
+ unsigned long status = 0x1f80;
+ asm volatile("ldmxcsr %0" : : "m" (status));
+}
+#else
+#define sse_init()
+#endif
+
void
arch_init(start_info_t *si)
{
+ /*Initialize floating point unit */
+ fpu_init();
+
+ /* Initialize SSE */
+ sse_init();
+
/* Copy the start_info struct to a globally-accessible area. */
/* WARN: don't do printk before here, it uses information from
shared_info. Use xprintk instead. */
@@ -99,6 +118,7 @@ arch_init(start_info_t *si)
(unsigned long)failsafe_callback, 0);
#endif

+
}

void
Re: [PATCH mini-os enhancements for vtpm 7/8] add floating point and sse to mini-os [ In reply to ]
Matthew Fioravante, le Mon 17 Sep 2012 18:04:47 -0400, a écrit :
> This patch adds floating point and sse support to mini-os by
> initializing the floating point unit and the see unit during domain boot up.
>
>
> Signed of by: Matthew Fioravante matthew.fioravante@jhuapl.edu

I don't remember: does xen support optimizing out FPU context switch
when a domain does not use the FPU? It might be useful to make FPU
initialization optional in that case, to keep context switch faster.
Apart from that,

Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
Re: [PATCH mini-os enhancements for vtpm 7/8] add floating point and sse to mini-os [ In reply to ]
At 00:20 +0200 on 18 Sep (1347927637), Samuel Thibault wrote:
> Matthew Fioravante, le Mon 17 Sep 2012 18:04:47 -0400, a écrit :
> > This patch adds floating point and sse support to mini-os by
> > initializing the floating point unit and the see unit during domain boot up.
> >
> >
> > Signed of by: Matthew Fioravante matthew.fioravante@jhuapl.edu
>
> I don't remember: does xen support optimizing out FPU context switch
> when a domain does not use the FPU?

Yes, but using the FPU once at boot shouldn't interfere with that.

Tim.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
Re: [PATCH mini-os enhancements for vtpm 7/8] add floating point and sse to mini-os [ In reply to ]
Tim Deegan, le Tue 18 Sep 2012 01:03:22 +0100, a écrit :
> At 00:20 +0200 on 18 Sep (1347927637), Samuel Thibault wrote:
> > Matthew Fioravante, le Mon 17 Sep 2012 18:04:47 -0400, a écrit :
> > > This patch adds floating point and sse support to mini-os by
> > > initializing the floating point unit and the see unit during domain boot up.
> > >
> > >
> > > Signed of by: Matthew Fioravante matthew.fioravante@jhuapl.edu
> >
> > I don't remember: does xen support optimizing out FPU context switch
> > when a domain does not use the FPU?
>
> Yes, but using the FPU once at boot shouldn't interfere with that.

Ah, right, the initialize context isn't restored until FPU is really
used. Then it's all OK.

Samuel

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
Re: [PATCH mini-os enhancements for vtpm 7/8] add floating point and sse to mini-os [ In reply to ]
On Mon, 2012-09-17 at 23:04 +0100, Matthew Fioravante wrote:
> This patch adds floating point and sse support to mini-os by
> initializing the floating point unit and the see unit during domain boot up.
>
>
> Signed of by: Matthew Fioravante matthew.fioravante@jhuapl.edu
>
> diff --git a/extras/mini-os/arch/x86/setup.c
> b/extras/mini-os/arch/x86/setup.c
> --- a/extras/mini-os/arch/x86/setup.c
> +++ b/extras/mini-os/arch/x86/setup.c
> @@ -74,9 +74,28 @@ shared_info_t *map_shared_info(unsigned long pa)
> return (shared_info_t *)shared_info;
> }
>
> +static inline void fpu_init(void) {
> + asm volatile("fninit");
> +}
> +
> +#ifdef __SSE__

How and when is this symbol defined?

> +static inline void sse_init(void) {
> + unsigned long status = 0x1f80;
> + asm volatile("ldmxcsr %0" : : "m" (status));
> +}
> +#else
> +#define sse_init()
> +#endif
> +
> void
> arch_init(start_info_t *si)
> {
> + /*Initialize floating point unit */
> + fpu_init();
> +
> + /* Initialize SSE */
> + sse_init();

The indentation here is a bit suspect.

> +
> /* Copy the start_info struct to a globally-accessible area. */
> /* WARN: don't do printk before here, it uses information from
> shared_info. Use xprintk instead. */
> @@ -99,6 +118,7 @@ arch_init(start_info_t *si)
> (unsigned long)failsafe_callback, 0);
> #endif
>
> +
> }
>
> void
>
>



_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
Re: [PATCH mini-os enhancements for vtpm 7/8] add floating point and sse to mini-os [ In reply to ]
Ian Campbell, le Tue 18 Sep 2012 08:21:18 +0100, a écrit :
> On Mon, 2012-09-17 at 23:04 +0100, Matthew Fioravante wrote:
> > This patch adds floating point and sse support to mini-os by
> > initializing the floating point unit and the see unit during domain boot up.
> >
> >
> > Signed of by: Matthew Fioravante matthew.fioravante@jhuapl.edu
> >
> > diff --git a/extras/mini-os/arch/x86/setup.c
> > b/extras/mini-os/arch/x86/setup.c
> > --- a/extras/mini-os/arch/x86/setup.c
> > +++ b/extras/mini-os/arch/x86/setup.c
> > @@ -74,9 +74,28 @@ shared_info_t *map_shared_info(unsigned long pa)
> > return (shared_info_t *)shared_info;
> > }
> >
> > +static inline void fpu_init(void) {
> > + asm volatile("fninit");
> > +}
> > +
> > +#ifdef __SSE__
>
> How and when is this symbol defined?

This is defined by the compiler if some -msse is enabled. This is the
default on i686/x86_64 at least.

Samuel

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
Re: [PATCH mini-os enhancements for vtpm 7/8] add floating point and sse to mini-os [ In reply to ]
On Tue, 2012-09-18 at 08:31 +0100, Samuel Thibault wrote:
> Ian Campbell, le Tue 18 Sep 2012 08:21:18 +0100, a écrit :
> > On Mon, 2012-09-17 at 23:04 +0100, Matthew Fioravante wrote:
> > > This patch adds floating point and sse support to mini-os by
> > > initializing the floating point unit and the see unit during domain boot up.
> > >
> > >
> > > Signed of by: Matthew Fioravante matthew.fioravante@jhuapl.edu
> > >
> > > diff --git a/extras/mini-os/arch/x86/setup.c
> > > b/extras/mini-os/arch/x86/setup.c
> > > --- a/extras/mini-os/arch/x86/setup.c
> > > +++ b/extras/mini-os/arch/x86/setup.c
> > > @@ -74,9 +74,28 @@ shared_info_t *map_shared_info(unsigned long pa)
> > > return (shared_info_t *)shared_info;
> > > }
> > >
> > > +static inline void fpu_init(void) {
> > > + asm volatile("fninit");
> > > +}
> > > +
> > > +#ifdef __SSE__
> >
> > How and when is this symbol defined?
>
> This is defined by the compiler if some -msse is enabled. This is the
> default on i686/x86_64 at least.

Do we support processors/compilers without SSE or conversely do we
require SSE support?

It sounds like either we need a runtime test or the compile time test is
unnecessary.

Ian.


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
Re: [PATCH mini-os enhancements for vtpm 7/8] add floating point and sse to mini-os [ In reply to ]
Ian Campbell, le Tue 18 Sep 2012 08:38:23 +0100, a écrit :
> On Tue, 2012-09-18 at 08:31 +0100, Samuel Thibault wrote:
> > Ian Campbell, le Tue 18 Sep 2012 08:21:18 +0100, a écrit :
> > > On Mon, 2012-09-17 at 23:04 +0100, Matthew Fioravante wrote:
> > > > This patch adds floating point and sse support to mini-os by
> > > > initializing the floating point unit and the see unit during domain boot up.
> > > >
> > > >
> > > > Signed of by: Matthew Fioravante matthew.fioravante@jhuapl.edu
> > > >
> > > > diff --git a/extras/mini-os/arch/x86/setup.c
> > > > b/extras/mini-os/arch/x86/setup.c
> > > > --- a/extras/mini-os/arch/x86/setup.c
> > > > +++ b/extras/mini-os/arch/x86/setup.c
> > > > @@ -74,9 +74,28 @@ shared_info_t *map_shared_info(unsigned long pa)
> > > > return (shared_info_t *)shared_info;
> > > > }
> > > >
> > > > +static inline void fpu_init(void) {
> > > > + asm volatile("fninit");
> > > > +}
> > > > +
> > > > +#ifdef __SSE__
> > >
> > > How and when is this symbol defined?
> >
> > This is defined by the compiler if some -msse is enabled. This is the
> > default on i686/x86_64 at least.
>
> Do we support processors/compilers without SSE or conversely do we
> require SSE support?
>
> It sounds like either we need a runtime test or the compile time test is
> unnecessary.

If the code is compiled with -msse (and thus __SSE__ defined), the
compiler itself can emit sse code, so a runtime test will not be enough
to avoid a crash on a non-sse machine.

The compile test is however not strictly needed since the code is
provided in assembly. And it might be useful to enable sse anyway in
case some -msse code gets pulled. IIRC we only support SSE machines, but
I'm not 100% sure.

Samuel

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