All of lore.kernel.org
 help / color / mirror / Atom feed
* Early test for 32- vs 64-bit hvm domain?
@ 2008-01-30  0:01 Dan Magenheimer
  2008-01-30  0:11 ` Samuel Thibault
  0 siblings, 1 reply; 6+ messages in thread
From: Dan Magenheimer @ 2008-01-30  0:01 UTC (permalink / raw)
  To: xen-devel@lists.xensource.com

[-- Attachment #1: Type: text/plain, Size: 665 bytes --]

What is the proper way to test to see if an hvm domain is destined
to be x86 vs x86_64 whilst still early in its initialization in the
hypervisor, e.g. in hvm_vcpu_initialise(v) or hvm_domain_initialise(d)?
Is this information pased down from hvmloader or does it get
discovered somehow?  Or maybe it is not possible to determine
until a vcpu actually starts executing?

I see vmx_guest_x86_mode(v) ASSERTs if v!=current so hvm_guest_x86_mode(v)
can't be used. And hvm_long_mode_enabled(v) doesn't seem to work that
early.  Also, the arch_domain struct has a "is_32bit_pv" field but I can't
find any equivalent for hvm.

Thanks for any suggestions!
Dan

[-- Attachment #2: Type: text/plain, Size: 138 bytes --]

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

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

* Re: Early test for 32- vs 64-bit hvm domain?
  2008-01-30  0:01 Early test for 32- vs 64-bit hvm domain? Dan Magenheimer
@ 2008-01-30  0:11 ` Samuel Thibault
  2008-01-30  0:34   ` Dan Magenheimer
  0 siblings, 1 reply; 6+ messages in thread
From: Samuel Thibault @ 2008-01-30  0:11 UTC (permalink / raw)
  To: Dan Magenheimer; +Cc: xen-devel@lists.xensource.com

Dan Magenheimer, le Tue 29 Jan 2008 17:01:22 -0700, a écrit :
> What is the proper way to test to see if an hvm domain is destined
> to be x86 vs x86_64 whilst still early in its initialization in the
> hypervisor, e.g. in hvm_vcpu_initialise(v) or hvm_domain_initialise(d)?
> Is this information pased down from hvmloader or does it get
> discovered somehow?  Or maybe it is not possible to determine
> until a vcpu actually starts executing?

As long as e.g. Linux has not started (i.e. during bios and grub for
instance), you can't know whether that will be a 64bit Linux or a 32bit
Linux.

Samuel

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

* RE: Early test for 32- vs 64-bit hvm domain?
  2008-01-30  0:11 ` Samuel Thibault
@ 2008-01-30  0:34   ` Dan Magenheimer
  2008-01-30  8:21     ` Keir Fraser
  0 siblings, 1 reply; 6+ messages in thread
From: Dan Magenheimer @ 2008-01-30  0:34 UTC (permalink / raw)
  To: Samuel Thibault; +Cc: xen-devel@lists.xensource.com

> Dan Magenheimer, le Tue 29 Jan 2008 17:01:22 -0700, a écrit :
> > What is the proper way to test to see if an hvm domain is destined
> > to be x86 vs x86_64 whilst still early in its initialization in the
> > hypervisor, e.g. in hvm_vcpu_initialise(v) or 
> hvm_domain_initialise(d)?
> > Is this information pased down from hvmloader or does it get
> > discovered somehow?  Or maybe it is not possible to determine
> > until a vcpu actually starts executing?
> 
> As long as e.g. Linux has not started (i.e. during bios and grub for
> instance), you can't know whether that will be a 64bit Linux 
> or a 32bit
> Linux.

That's what I was afraid of...

Then what is the earliest point in the execution of an x86_64
domain/vcpu in *xen* where hvm_long_mode_enabled(v) will work
properly? E.g. in Linux/x86_64 is long mode set early in __start?
And is this done via a hypercall or an emulated instruction?

Thanks,
Dan

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

* Re: Early test for 32- vs 64-bit hvm domain?
  2008-01-30  0:34   ` Dan Magenheimer
@ 2008-01-30  8:21     ` Keir Fraser
  2008-01-30 18:44       ` Andi Kleen
  0 siblings, 1 reply; 6+ messages in thread
From: Keir Fraser @ 2008-01-30  8:21 UTC (permalink / raw)
  To: dan.magenheimer@oracle.com, Samuel Thibault; +Cc: xen-devel@lists.xensource.com

On 30/1/08 00:34, "Dan Magenheimer" <dan.magenheimer@oracle.com> wrote:

>> As long as e.g. Linux has not started (i.e. during bios and grub for
>> instance), you can't know whether that will be a 64bit Linux
>> or a 32bit
>> Linux.
> 
> That's what I was afraid of...
> 
> Then what is the earliest point in the execution of an x86_64
> domain/vcpu in *xen* where hvm_long_mode_enabled(v) will work
> properly? E.g. in Linux/x86_64 is long mode set early in __start?
> And is this done via a hypercall or an emulated instruction?

As sson as you see LME bit get set in the EFER MSR then you know you have a
64-bit guest. Writes to EFER are emulated in long_mode_do_msr_write() in
vmx.c and svm.c. Those are the places to patch in Xen 3.1 branch.

 -- Keir

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

* Re: Early test for 32- vs 64-bit hvm domain?
  2008-01-30  8:21     ` Keir Fraser
@ 2008-01-30 18:44       ` Andi Kleen
  2008-01-30 19:28         ` Keir Fraser
  0 siblings, 1 reply; 6+ messages in thread
From: Andi Kleen @ 2008-01-30 18:44 UTC (permalink / raw)
  To: Keir Fraser
  Cc: dan.magenheimer@oracle.com, xen-devel@lists.xensource.com,
	Samuel Thibault

Keir Fraser <Keir.Fraser@cl.cam.ac.uk> writes:

> On 30/1/08 00:34, "Dan Magenheimer" <dan.magenheimer@oracle.com> wrote:
>
>>> As long as e.g. Linux has not started (i.e. during bios and grub for
>>> instance), you can't know whether that will be a 64bit Linux
>>> or a 32bit
>>> Linux.
>> 
>> That's what I was afraid of...
>> 
>> Then what is the earliest point in the execution of an x86_64
>> domain/vcpu in *xen* where hvm_long_mode_enabled(v) will work
>> properly? E.g. in Linux/x86_64 is long mode set early in __start?
>> And is this done via a hypercall or an emulated instruction?
>
> As sson as you see LME bit get set in the EFER MSR then you know you have a
> 64-bit guest. Writes to EFER are emulated in long_mode_do_msr_write() in
> vmx.c and svm.c. Those are the places to patch in Xen 3.1 branch.

You could do it slightly earlier by intercepting bios int 0x15 eax=0xec00 ebx=2 
The kernel issues that to tell the BIOS it is 64bit.

That will only work if the boot loader does not skip the real mode code
(a few do) 

-Andi

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

* Re: Early test for 32- vs 64-bit hvm domain?
  2008-01-30 18:44       ` Andi Kleen
@ 2008-01-30 19:28         ` Keir Fraser
  0 siblings, 0 replies; 6+ messages in thread
From: Keir Fraser @ 2008-01-30 19:28 UTC (permalink / raw)
  To: Andi Kleen
  Cc: dan.magenheimer@oracle.com, xen-devel@lists.xensource.com,
	Samuel Thibault

On 30/1/08 18:44, "Andi Kleen" <andi@firstfloor.org> wrote:

>> As sson as you see LME bit get set in the EFER MSR then you know you have a
>> 64-bit guest. Writes to EFER are emulated in long_mode_do_msr_write() in
>> vmx.c and svm.c. Those are the places to patch in Xen 3.1 branch.
> 
> You could do it slightly earlier by intercepting bios int 0x15 eax=0xec00
> ebx=2 The kernel issues that to tell the BIOS it is 64bit.
> 
> That will only work if the boot loader does not skip the real mode code
> (a few do) 

Oh, I hadn't read about that. We should probably make that call during Xen
boot then. For this particular issue I expect that trapping EFER.LME is
equally good, and it depends on whether the trap is more conveniently
triggered in the hypervisor itself or in the virtual bios.

 -- Keir

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

end of thread, other threads:[~2008-01-30 19:28 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-30  0:01 Early test for 32- vs 64-bit hvm domain? Dan Magenheimer
2008-01-30  0:11 ` Samuel Thibault
2008-01-30  0:34   ` Dan Magenheimer
2008-01-30  8:21     ` Keir Fraser
2008-01-30 18:44       ` Andi Kleen
2008-01-30 19:28         ` Keir Fraser

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.