* mmx sse emulation @ 2008-11-05 0:34 Ashish Bijlani 2008-11-05 7:34 ` Keir Fraser 2008-11-05 9:59 ` Andre Przywara 0 siblings, 2 replies; 8+ messages in thread From: Ashish Bijlani @ 2008-11-05 0:34 UTC (permalink / raw) To: xen-devel Hi, I want to emulate mmx/sse for hvm guests when applications inside hvm guests are compiled for mmx/sse but the underlying hardware doesn't support mmx/sse. What is the best place to do this? i'm looking at x86_emulate but i dunno if that is the best place to put the emulation layer. any suggestions?? also, currently movq emulation is present in x86_emulate for handling mmio. however, i realized that get_fpu fails if the hardware doesn't have mmx capability. is it true or am i missing something here? Thanks, Ashish ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: mmx sse emulation 2008-11-05 0:34 mmx sse emulation Ashish Bijlani @ 2008-11-05 7:34 ` Keir Fraser 2008-11-05 7:52 ` Ashish Bijlani 2008-11-05 9:59 ` Andre Przywara 1 sibling, 1 reply; 8+ messages in thread From: Keir Fraser @ 2008-11-05 7:34 UTC (permalink / raw) To: Ashish Bijlani, xen-devel On 5/11/08 00:34, "Ashish Bijlani" <ashish.bijlani@gmail.com> wrote: > > I want to emulate mmx/sse for hvm guests when applications inside hvm > guests are compiled for mmx/sse but the underlying hardware doesn't > support mmx/sse. What is the best place to do this? i'm looking at > x86_emulate but i dunno if that is the best place to put the emulation > layer. any suggestions?? also, currently movq emulation is present in > x86_emulate for handling mmio. however, i realized that get_fpu fails > if the hardware doesn't have mmx capability. is it true or am i > missing something here? x86_emulate() does its work by using the actual underlying processor instructions (really it is a system emulator rather than an instruction emulator). This wouldn't necessarily stop you adding full emulation for certain instructions like SSE/MMX though, and it's probably the right place to put that sort of thing. -- Keir ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: mmx sse emulation 2008-11-05 7:34 ` Keir Fraser @ 2008-11-05 7:52 ` Ashish Bijlani 2008-11-05 9:04 ` Keir Fraser 0 siblings, 1 reply; 8+ messages in thread From: Ashish Bijlani @ 2008-11-05 7:52 UTC (permalink / raw) To: Keir Fraser; +Cc: xen-devel Hi Keir, Thanks for the help. I've one more doubt though. Calling x86_emulate from do_device_not_available after validating the EM flag would work? Of course provided MMX/SS emulation code reside in x86_emulate. Please lemme know. Thanks, Ashish On Wed, Nov 5, 2008 at 2:34 AM, Keir Fraser <keir.fraser@eu.citrix.com> wrote: > On 5/11/08 00:34, "Ashish Bijlani" <ashish.bijlani@gmail.com> wrote: > >> >> I want to emulate mmx/sse for hvm guests when applications inside hvm >> guests are compiled for mmx/sse but the underlying hardware doesn't >> support mmx/sse. What is the best place to do this? i'm looking at >> x86_emulate but i dunno if that is the best place to put the emulation >> layer. any suggestions?? also, currently movq emulation is present in >> x86_emulate for handling mmio. however, i realized that get_fpu fails >> if the hardware doesn't have mmx capability. is it true or am i >> missing something here? > > x86_emulate() does its work by using the actual underlying processor > instructions (really it is a system emulator rather than an instruction > emulator). This wouldn't necessarily stop you adding full emulation for > certain instructions like SSE/MMX though, and it's probably the right place > to put that sort of thing. > > -- Keir > > > ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: mmx sse emulation 2008-11-05 7:52 ` Ashish Bijlani @ 2008-11-05 9:04 ` Keir Fraser 0 siblings, 0 replies; 8+ messages in thread From: Keir Fraser @ 2008-11-05 9:04 UTC (permalink / raw) To: Ashish Bijlani; +Cc: xen-devel On 5/11/08 07:52, "Ashish Bijlani" <ashish.bijlani@gmail.com> wrote: > Hi Keir, > > Thanks for the help. I've one more doubt though. > > Calling x86_emulate from do_device_not_available after validating the > EM flag would work? Of course provided MMX/SS emulation code reside in > x86_emulate. Please lemme know. Sounds about right to me. -- Keir ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: mmx sse emulation 2008-11-05 0:34 mmx sse emulation Ashish Bijlani 2008-11-05 7:34 ` Keir Fraser @ 2008-11-05 9:59 ` Andre Przywara 2008-11-05 10:34 ` Ashish Bijlani 1 sibling, 1 reply; 8+ messages in thread From: Andre Przywara @ 2008-11-05 9:59 UTC (permalink / raw) To: Ashish Bijlani; +Cc: xen-devel Ashish Bijlani wrote: > Hi, > > I want to emulate mmx/sse for hvm guests when applications inside hvm > guests are compiled for mmx/sse but the underlying hardware doesn't > support mmx/sse. First: HVM guests require a virtualization capable processor. AFAIK all these processors support at least SSE2 (if not SSE3). So why do you want to emulate these instructions? Second: Applications should check the CPUID bit before using instruction set extension. So, if the host processor does not support MMX/SSE, the guest shouldn't see this bit, too. And I doubt that you are faster with emulating SSE compared to legacy x87-FPU executed natively. So, what is the use-case of your proposal? Or am I missing something here? Regards, Andre. > What is the best place to do this? i'm looking at > x86_emulate but i dunno if that is the best place to put the emulation > layer. any suggestions?? also, currently movq emulation is present in > x86_emulate for handling mmio. however, i realized that get_fpu fails > if the hardware doesn't have mmx capability. is it true or am i > missing something here? > > Thanks, > Ashish -- Andre Przywara AMD-OSRC (Dresden) Tel: x84917 ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: mmx sse emulation 2008-11-05 9:59 ` Andre Przywara @ 2008-11-05 10:34 ` Ashish Bijlani 2008-11-05 12:25 ` Ashish Bijlani 0 siblings, 1 reply; 8+ messages in thread From: Ashish Bijlani @ 2008-11-05 10:34 UTC (permalink / raw) To: Andre Przywara; +Cc: xen-devel Hi Andre, You are absolutely right. All hardware virtualization capable machines have recent simd technology built-in. However, I'm just trying to evaluate a case when HVM guests rely on the virtual hardware platform and not on the actual hardware platform. Precisely, what would be the performance gain/loss if hypervisor has to emulate the functionality. -Ashish On Wed, Nov 5, 2008 at 4:59 AM, Andre Przywara <andre.przywara@amd.com> wrote: > Ashish Bijlani wrote: >> >> Hi, >> >> I want to emulate mmx/sse for hvm guests when applications inside hvm >> guests are compiled for mmx/sse but the underlying hardware doesn't >> support mmx/sse. > > First: HVM guests require a virtualization capable processor. AFAIK all > these processors support at least SSE2 (if not SSE3). So why do you want to > emulate these instructions? > Second: Applications should check the CPUID bit before using instruction set > extension. So, if the host processor does not support MMX/SSE, the guest > shouldn't see this bit, too. And I doubt that you are faster with emulating > SSE compared to legacy x87-FPU executed natively. > > So, what is the use-case of your proposal? Or am I missing something here? > > Regards, > Andre. > >> What is the best place to do this? i'm looking at >> >> x86_emulate but i dunno if that is the best place to put the emulation >> layer. any suggestions?? also, currently movq emulation is present in >> x86_emulate for handling mmio. however, i realized that get_fpu fails >> if the hardware doesn't have mmx capability. is it true or am i >> missing something here? >> >> Thanks, >> Ashish > > -- > Andre Przywara > AMD-OSRC (Dresden) > Tel: x84917 > > ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: mmx sse emulation 2008-11-05 10:34 ` Ashish Bijlani @ 2008-11-05 12:25 ` Ashish Bijlani [not found] ` <a7065af20811050710w3bf20245s95f31d0edb6e5879@mail.gmail.com> 0 siblings, 1 reply; 8+ messages in thread From: Ashish Bijlani @ 2008-11-05 12:25 UTC (permalink / raw) To: xen-devel If I'm not wrong, Bochs emulates SSE/MMX instructions and qemu uses dynamic translation. Does this mean that I use SSE/MMX emulation code from Bochs to put under x86_emulate? or am I missing something? Thanks. On Wed, Nov 5, 2008 at 5:34 AM, Ashish Bijlani <ashish.bijlani@gmail.com> wrote: > Hi Andre, > > You are absolutely right. All hardware virtualization capable machines > have recent simd technology built-in. However, I'm just trying to > evaluate a case when HVM guests rely on the virtual hardware platform > and not on the actual hardware platform. Precisely, what would be the > performance gain/loss if hypervisor has to emulate the functionality. > > -Ashish > > On Wed, Nov 5, 2008 at 4:59 AM, Andre Przywara <andre.przywara@amd.com> wrote: >> Ashish Bijlani wrote: >>> >>> Hi, >>> >>> I want to emulate mmx/sse for hvm guests when applications inside hvm >>> guests are compiled for mmx/sse but the underlying hardware doesn't >>> support mmx/sse. >> >> First: HVM guests require a virtualization capable processor. AFAIK all >> these processors support at least SSE2 (if not SSE3). So why do you want to >> emulate these instructions? >> Second: Applications should check the CPUID bit before using instruction set >> extension. So, if the host processor does not support MMX/SSE, the guest >> shouldn't see this bit, too. And I doubt that you are faster with emulating >> SSE compared to legacy x87-FPU executed natively. >> >> So, what is the use-case of your proposal? Or am I missing something here? >> >> Regards, >> Andre. >> >>> What is the best place to do this? i'm looking at >>> >>> x86_emulate but i dunno if that is the best place to put the emulation >>> layer. any suggestions?? also, currently movq emulation is present in >>> x86_emulate for handling mmio. however, i realized that get_fpu fails >>> if the hardware doesn't have mmx capability. is it true or am i >>> missing something here? >>> >>> Thanks, >>> Ashish >> >> -- >> Andre Przywara >> AMD-OSRC (Dresden) >> Tel: x84917 >> >> > ^ permalink raw reply [flat|nested] 8+ messages in thread
[parent not found: <a7065af20811050710w3bf20245s95f31d0edb6e5879@mail.gmail.com>]
* Re: mmx sse emulation [not found] ` <a7065af20811050710w3bf20245s95f31d0edb6e5879@mail.gmail.com> @ 2008-11-06 10:16 ` Ashish Bijlani 0 siblings, 0 replies; 8+ messages in thread From: Ashish Bijlani @ 2008-11-06 10:16 UTC (permalink / raw) To: xen-devel in an attempt to emulate mmx/sse instructions from within xen, i tried setting EM and NE bit in CR0 to have mmx/sse instructions fault into xen. however, the hvm guest doesn't boot after that. also, i don't get any "device_not_available_fault" any ideas what could be wrong? am i missing something? this is what i've done :- int hvm_set_cr0(unsigned long value) { ... value &= ~HVM_CR0_GUEST_RESERVED_BITS; value |= (X86_CR0_EM | X86_CR0_NE); // EMULATE FPU /* ET is reserved and should be always be 1. */ value |= X86_CR0_ET; ... } I run system with dom0 4 vcpus on 0-2 cpu cores and hvm 1 vcpu on the 3rd cpu core -Ashish On Wed, Nov 5, 2008 at 10:10 AM, mats petersson <mats@planetcatfish.com> wrote: > 2008/11/5 Ashish Bijlani <ashish.bijlani@gmail.com> >> >> If I'm not wrong, Bochs emulates SSE/MMX instructions and qemu uses >> dynamic translation. Does this mean that I use SSE/MMX emulation code >> from Bochs to put under x86_emulate? or am I missing something? >> Thanks. >> >> On Wed, Nov 5, 2008 at 5:34 AM, Ashish Bijlani <ashish.bijlani@gmail.com> >> wrote: >> > Hi Andre, >> > >> > You are absolutely right. All hardware virtualization capable machines >> > have recent simd technology built-in. However, I'm just trying to >> > evaluate a case when HVM guests rely on the virtual hardware platform >> > and not on the actual hardware platform. Precisely, what would be the >> > performance gain/loss if hypervisor has to emulate the functionality. > > The performance loss would be HUGE. First of all, you'd fall into the > hypervisor and get back out again, which takes a fair few cycles (like more > than 100x or more that of a single instruction). Then you have to emulate > the actual instruction itself, which will be the small part of the ovehead. > > Many SSE/MMX/3DNow! instructions execute in 1-2 clockcycles. My guess would > be that it would reduce any SSE optimized code to a crawl (like in the order > of 100-1000x slower). Such an application would be much better off running > in x87 mode. > > I was looking at doing SSE/MMX emulation in x86_emulate a long time ago, but > the purpose of that wasn't to emulate SSE/MMX as such, but rather allow > SSE/MMX to access emulated hardware (such as video memory). > > -- > Mats >> >> -Ashish >> >> On Wed, Nov 5, 2008 at 4:59 AM, Andre Przywara <andre.przywara@amd.com> >> wrote: >>> Ashish Bijlani wrote: >>>> >>>> Hi, >>>> >>>> I want to emulate mmx/sse for hvm guests when applications inside hvm >>>> guests are compiled for mmx/sse but the underlying hardware doesn't >>>> support mmx/sse. >>> >>> First: HVM guests require a virtualization capable processor. AFAIK all >>> these processors support at least SSE2 (if not SSE3). So why do you want >>> to >>> emulate these instructions? >>> Second: Applications should check the CPUID bit before using instruction >>> set >>> extension. So, if the host processor does not support MMX/SSE, the guest >>> shouldn't see this bit, too. And I doubt that you are faster with >>> emulating >>> SSE compared to legacy x87-FPU executed natively. >>> >>> So, what is the use-case of your proposal? Or am I missing something >>> here? >>> >>> Regards, >>> Andre. >>> >>>> What is the best place to do this? i'm looking at >>>> >>>> x86_emulate but i dunno if that is the best place to put the emulation >>>> layer. any suggestions?? also, currently movq emulation is present in >>>> x86_emulate for handling mmio. however, i realized that get_fpu fails >>>> if the hardware doesn't have mmx capability. is it true or am i >>>> missing something here? >>>> >>>> Thanks, >>>> Ashish >>> >>> -- >>> Andre Przywara >>> AMD-OSRC (Dresden) >>> Tel: x84917 >>> >>> >> > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xensource.com > http://lists.xensource.com/xen-devel > > ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2008-11-06 10:16 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-05 0:34 mmx sse emulation Ashish Bijlani
2008-11-05 7:34 ` Keir Fraser
2008-11-05 7:52 ` Ashish Bijlani
2008-11-05 9:04 ` Keir Fraser
2008-11-05 9:59 ` Andre Przywara
2008-11-05 10:34 ` Ashish Bijlani
2008-11-05 12:25 ` Ashish Bijlani
[not found] ` <a7065af20811050710w3bf20245s95f31d0edb6e5879@mail.gmail.com>
2008-11-06 10:16 ` Ashish Bijlani
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.