Skip to contentSkip to conversation

HVM hypercalls

DISCUSSION Ruslan Nikolaev 9 participants 20 messages Jul 28, 2010 – May 25, 2011

lore
Share & tools
lore
#0 lore raw

Hi

I need to use hypercalls from HVM domain (e.g. HYPERVISOR_add_to_physmap). However, it does not work when I am trying to invoke it from HVM Linux guest. Basically, I don't see that anything happens on hypervisor's side. I also grep'ed the guest code for 'vmmcall'/'vmcall' and did not find anything. Is it possible to do it at all? Is it possible to make hypercalls from HVM domains or are they simply used for tools responsible to load HVM domain? Also, are they allowed (if allowed at all) from stubdom, ioemu, or both configurations?

I am using latest Xen version (xen-4.0.1-rc). I also tried both official Linux distribution as an HVM domain and the version from Xen repositary. The computer has Nehalem processor with VMX.

Thanks,
Ruslan.

#1 lore raw

Xen only allows certain hypercalls from an HVM guest and the list is kept in tables in arch/x86/hvm/hvm.c. See http://xenbits.xensource.com/xen-unstable.hg?rev/72c6228b5f0f
for an example of adding an existing hypercall so that it will be sent through to Xen. Note that there is
no guarantee that any particular hypercall will work properly from an HVM guest... this is just the mechanism for getting a hypercall to be allowed by Xen.

Quoted 33 lines

-----Original Message-----
From: Ruslan Nikolaev [mailto:[email protected]]
Sent: Wednesday, July 28, 2010 1:23 PM
To: [email protected]
Subject: [Xen-devel] HVM hypercalls

Hi

I need to use hypercalls from HVM domain (e.g. HYPERVISOR_add_to_physmap). However, it does not work when I am trying to invoke it from HVM Linux guest. Basically, I don't see that anything happens on hypervisor's side. I also grep'ed the guest code for 'vmmcall'/'vmcall' and did not find anything. Is it possible to do it at all? Is it possible to make hypercalls from HVM domains or are they simply used for tools responsible to load HVM domain? Also, are they allowed (if allowed at all) from stubdom, ioemu, or both configurations?

I am using latest Xen version (xen-4.0.1-rc). I also tried both official Linux distribution as an HVM domain and the version from Xen repositary. The computer has Nehalem processor with VMX.

Thanks,
Ruslan.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#2 lore raw
In reply to Ruslan Nikolaev
Quoted 5 lines · Ruslan Nikolaev

Hi

I need to use hypercalls from HVM domain (e.g. HYPERVISOR_add_to_physmap). However, it does not work when I am trying to invoke it from HVM Linux guest. Basically, I don't see that anything happens on hypervisor's side. I also grep'ed the guest code for 'vmmcall'/'vmcall' and did not find anything. Is it possible to do it at all? Is it possible to make hypercalls from HVM domains or are they simply used for tools responsible to load HVM domain? Also, are they allowed (if allowed at all) from stubdom, ioemu, or both configurations?

I am using latest Xen version (xen-4.0.1-rc). I also tried both official Linux distribution as an HVM domain and the version from Xen repositary. The computer has Nehalem processor with VMX.

This should work.
We are using hypercalls from HVM domains without any problem on xen 3.3 and 4.0, one of them being HYPERVISOR_add_to_physmap. There must be something you are doing wrong.

The following steps are required:

- use the cpuid instruction to search for Xen signature. You should begin with index 0x40000000 and look for the text "XenVMMXenVMM" in the returned registers ebx, ecx and edx. Increment the index by 0x100 up to 0x40001000 if necessary.
- get the xen msr register number via cpuid with index 0x40000x002 (x from step 1). The msr register number will be in register ebx.
- write the physical address of a 4k page to the obtained msr register via wrmsr. This page will be used by the hypervisor to write the appropriate code for the hypercalls to.
- each entry in that page occupies 32 bytes. You can do a specific hypercall by calling the function at the specific entry with the hypercall number as index

Juergen

Signature · 5 lines
Juergen Gross                 Principal Developer Operating Systems
TSP ES&S SWE OS6                       Telephone: +49 (0) 89 3222 2967
Fujitsu Technology Solutions              e-mail: [email protected]
Domagkstr. 28                           Internet: ts.fujitsu.com
D-80807 Muenchen                 Company details: ts.fujitsu.com/imprint.html
#3 lore raw

Thank you very much! I'll try this. BTW is it required to do this for every module with HVM hypercalls or there is some shared initialization code in HVM guest (Linux) similar to one used in paravirtualized guests?

If it's supposed to be in a module, is there any good example I can look at?

AFAIK hypercall_page is being initialized on Xen side with appropriate vmcall/vmmcall code. Is this CPUID mechanism a standard way to obtain hypercall_page reference on HVM domain?

Thank you!
Ruslan.

Quoted 79 lines · Juergen Gross

From: Juergen Gross <[email protected]>
Subject: Re: [Xen-devel] HVM hypercalls
To: "Ruslan Nikolaev" <[email protected]>
Cc: [email protected]
Date: Thursday, July 29, 2010, 11:30 AM

Quoted 3 lines · Ruslan Nikolaev

Hi

I need to use hypercalls from HVM domain (e.g.

HYPERVISOR_add_to_physmap). However, it does not work when I am trying to invoke it from HVM Linux guest. Basically, I don't see that anything happens on hypervisor's side. I also grep'ed the guest code for 'vmmcall'/'vmcall' and did not find anything. Is it possible to do it at all? Is it possible to make hypercalls from HVM domains or are they simply used for tools responsible to load HVM domain? Also, are they allowed (if allowed at all) from stubdom, ioemu, or both configurations?

Quoted 2 lines

I am using latest Xen version (xen-4.0.1-rc). I also

tried both official Linux distribution as an HVM domain and the version from Xen repositary. The computer has Nehalem processor with VMX.

This should work.
We are using hypercalls from HVM domains without any problem on xen 3.3 and
4.0, one of them being HYPERVISOR_add_to_physmap. There must be something
you are doing wrong.

The following steps are required:

- use the cpuid instruction to search for Xen signature. You should begin with
  index 0x40000000 and look for the text "XenVMMXenVMM" in the returned
  registers ebx, ecx and edx. Increment the index by 0x100 up to 0x40001000 if
  necessary.
- get the xen msr register number via cpuid with index 0x40000x002 (x from
  step 1). The msr register number will be in register ebx.
- write the physical address of a 4k page to the obtained msr register via
  wrmsr. This page will be used by the hypervisor to write the appropriate
  code for the hypercalls to.
- each entry in that page occupies 32 bytes. You can do a specific hypercall
  by calling the function at the specific entry with the hypercall number as
  index

Juergen

-- Juergen Gross
     Principal Developer Operating
Systems
TSP ES&S SWE OS6

   Telephone: +49 (0) 89 3222 2967
Fujitsu Technology Solutions
      e-mail: [email protected]
Domagkstr. 28

   Internet: ts.fujitsu.com
D-80807 Muenchen
     Company details:
ts.fujitsu.com/imprint.html

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#4 lore raw
Quoted 5 lines · Ruslan Nikolaev

Thank you very much! I'll try this. BTW is it required to do this for every module with HVM hypercalls or there is some shared initialization code in HVM guest (Linux) similar to one used in paravirtualized guests?

If it's supposed to be in a module, is there any good example I can look at?

AFAIK hypercall_page is being initialized on Xen side with appropriate vmcall/vmmcall code. Is this CPUID mechanism a standard way to obtain hypercall_page reference on HVM domain?

What kernel are you working with? There's already code to implement pv-on-hvm support for various recent pvops kernels, so you can just base your work on those.

J

#5 lore raw

I have 2 kernels:

1. From Xen repositary pvops-git (2.6.31.13).
2. From kernel.org: 2.6.32.16

Thank you!
Ruslan.

Quoted 27 lines · Jeremy Fitzhardinge

From: Jeremy Fitzhardinge <[email protected]>
Subject: Re: [Xen-devel] HVM hypercalls
To: "Ruslan Nikolaev" <[email protected]>
Cc: [email protected]
Date: Thursday, July 29, 2010, 11:47 PM

Quoted 1 line · Ruslan Nikolaev

Thank you very much! I'll try this. BTW is it required

to do this for every module with HVM hypercalls or there is some shared initialization code in HVM guest (Linux) similar to one used in paravirtualized guests?

Quoted 2 lines

If it's supposed to be in a module, is there any good

example I can look at?

Quoted 2 lines

AFAIK hypercall_page is being initialized on Xen side

with appropriate vmcall/vmmcall code. Is this CPUID mechanism a standard way to obtain hypercall_page reference on HVM domain?

What kernel are you working with?  There's already code to implement pv-on-hvm support for various recent pvops kernels, so you can just base your work on those.

    J

#6 lore raw
Quoted 3 lines · Ruslan Nikolaev

I have 2 kernels:

1. From Xen repositary pvops-git (2.6.31.13).

You want 2.6.32.16 from xen.git - the branch is xen/stable-2.6.32.x

J

Quoted 41 lines

2. From kernel.org: 2.6.32.16

Thank you!
Ruslan.

Quoted 18 lines · Jeremy Fitzhardinge

From: Jeremy Fitzhardinge<[email protected]>
Subject: Re: [Xen-devel] HVM hypercalls
To: "Ruslan Nikolaev"<[email protected]>
Cc: [email protected]
Date: Thursday, July 29, 2010, 11:47 PM

Quoted 1 line · Ruslan Nikolaev

Thank you very much! I'll try this. BTW is it required

to do this for every module with HVM hypercalls or there is some shared initialization code in HVM guest (Linux) similar to one used in paravirtualized guests?

Quoted 1 line

If it's supposed to be in a module, is there any good

example I can look at?

Quoted 1 line

AFAIK hypercall_page is being initialized on Xen side

with appropriate vmcall/vmmcall code. Is this CPUID mechanism a standard way to obtain hypercall_page reference on HVM domain?

Quoted 7 lines

What kernel are you working with? There's already code to implement pv-on-hvm support for various recent pvops kernels, so you can just base your work on those.

J

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#7 lore raw

I've just tried to configure newever version (2.6.32.16) from repositary. However, boot fails because no root device is found. I am using disk image (the line in HVM config is disk = [ 'file:/home/ruslan/fs1.img,hda,w' ]) I also tried to compile kernel with 'blktap' driver which is disabled in default kernel config, but it does not help.

The previous version (2.6.31.13) worked fine with the same disk image and default configuration.

Thanks,
Ruslan.

Quoted 74 lines · Jeremy Fitzhardinge

From: Jeremy Fitzhardinge <[email protected]>
Subject: Re: [Xen-devel] HVM hypercalls
To: "Ruslan Nikolaev" <[email protected]>
Cc: [email protected]
Date: Saturday, July 31, 2010, 4:07 AM

Quoted 3 lines · Ruslan Nikolaev

I have 2 kernels:

1. From Xen repositary pvops-git (2.6.31.13).

You want 2.6.32.16 from xen.git - the branch is
xen/stable-2.6.32.x

     J

Quoted 7 lines

2. From kernel.org: 2.6.32.16

Thank you!
Ruslan.

--- On Thu, 7/29/10, Jeremy Fitzhardinge<[email protected]>

Quoted 9 lines · wrote:
Quoted 9 lines

From: Jeremy Fitzhardinge<[email protected]>
Subject: Re: [Xen-devel] HVM hypercalls
To: "Ruslan Nikolaev"<[email protected]>
Cc: [email protected]
Date: Thursday, July 29, 2010, 11:47 PM

Quoted 1 line · Ruslan Nikolaev

Thank you very much! I'll try this. BTW is it

required

Quoted 1 line
Quoted 1 line

to do this for every module with HVM hypercalls or

there is

Quoted 1 line
Quoted 1 line

some shared initialization code in HVM guest

(Linux) similar

Quoted 2 lines
Quoted 2 lines

to one used in paravirtualized guests?

Quoted 1 line

If it's supposed to be in a module, is there

any good

Quoted 2 lines
Quoted 2 lines

example I can look at?

Quoted 1 line

AFAIK hypercall_page is being initialized on

Xen side

Quoted 1 line
Quoted 1 line

with appropriate vmcall/vmmcall code. Is this

CPUID

Quoted 1 line
Quoted 1 line

mechanism a standard way to obtain hypercall_page

reference

Quoted 3 lines
Quoted 3 lines

on HVM domain?

What kernel are you working with?  There's

already

Quoted 1 line
Quoted 1 line

code to implement pv-on-hvm support for various

recent pvops

Quoted 8 lines
Quoted 5 lines

kernels, so you can just base your work on those.

      J

Quoted 5 lines

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#8 lore raw
Quoted 2 lines · Ruslan Nikolaev

I've just tried to configure newever version (2.6.32.16) from repositary. However, boot fails because no root device is found. I am using disk image (the line in HVM config is disk = [ 'file:/home/ruslan/fs1.img,hda,w' ]) I also tried to compile kernel with 'blktap' driver which is disabled in default kernel config, but it does not help.

What is your root= parameter? If you're using pv-on-hvm drivers, then the device will be named /dev/xvd[a-d] (for the moment). It's very strongly recommended that you don't use a device-based root name (ie, use LABEL= UUID= or LVM for your root device) so that your config is failsafe against root device name changes.

J

Quoted 80 lines

The previous version (2.6.31.13) worked fine with the same disk image and default configuration.

Thanks,
Ruslan.

Quoted 70 lines · Jeremy Fitzhardinge

From: Jeremy Fitzhardinge<[email protected]>
Subject: Re: [Xen-devel] HVM hypercalls
To: "Ruslan Nikolaev"<[email protected]>
Cc: [email protected]
Date: Saturday, July 31, 2010, 4:07 AM

Quoted 3 lines · Ruslan Nikolaev

I have 2 kernels:

1. From Xen repositary pvops-git (2.6.31.13).

You want 2.6.32.16 from xen.git - the branch is
xen/stable-2.6.32.x

J

Quoted 7 lines

2. From kernel.org: 2.6.32.16

Thank you!
Ruslan.

--- On Thu, 7/29/10, Jeremy Fitzhardinge<[email protected]>

Quoted 8 lines · wrote:
Quoted 8 lines

From: Jeremy Fitzhardinge<[email protected]>
Subject: Re: [Xen-devel] HVM hypercalls
To: "Ruslan Nikolaev"<[email protected]>
Cc: [email protected]
Date: Thursday, July 29, 2010, 11:47 PM

    On 07/29/2010 11:55 AM, Ruslan
Quoted 1 line · Nikolaev

Thank you very much! I'll try this. BTW is it

required

Quoted 1 line
Quoted 1 line

to do this for every module with HVM hypercalls or

there is

Quoted 1 line
Quoted 1 line

some shared initialization code in HVM guest

(Linux) similar

Quoted 2 lines
Quoted 2 lines

to one used in paravirtualized guests?

Quoted 1 line

If it's supposed to be in a module, is there

any good

Quoted 2 lines
Quoted 2 lines

example I can look at?

Quoted 1 line

AFAIK hypercall_page is being initialized on

Xen side

Quoted 1 line
Quoted 1 line

with appropriate vmcall/vmmcall code. Is this

CPUID

Quoted 1 line
Quoted 1 line

mechanism a standard way to obtain hypercall_page

reference

Quoted 3 lines
Quoted 3 lines

on HVM domain?

What kernel are you working with? There's

already

Quoted 1 line
Quoted 1 line

code to implement pv-on-hvm support for various

recent pvops

Quoted 7 lines
Quoted 5 lines

kernels, so you can just base your work on those.

J

Quoted 5 lines

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#9 lore raw

Yes, I tried this but it does not seem to work. BTW in paravirtualized mode it works fine, the problem is only with HVM.

I tried to specify root=/dev/xvda (my disk image has no partitions, entire disk image is a single file system).

My config is (I also tried to comment out device model but it does not help):

import os, re
arch = os.uname()[4]
if re.search('64', arch):

    arch_libdir = 'lib64'

else:
arch_libdir = 'lib'

kernel = "/usr/lib/xen/boot/hvmloader"

builder='hvm'

vcpus=1

memory = 1024
shadow_memory = 8
name = "xenhvm1"
disk = [ 'file:/home/ruslan/fs1.img,xvda,w' ] device_model = '/usr/' + arch_libdir + '/xen/bin/qemu-dm'

# boot on floppy (a), hard disk (c) or CD-ROM (d)
# default: hard disk, cd-rom, floppy
boot="c"

sdl=1
vnc=0
vncviewer=0
vncpasswd=''
stdvga=1
serial='pty'
usbdevice='tablet'

Thanks,
Ruslan

Quoted 128 lines · Jeremy Fitzhardinge

From: Jeremy Fitzhardinge <[email protected]>
Subject: Re: [Xen-devel] HVM hypercalls
To: "Ruslan Nikolaev" <[email protected]>
Cc: [email protected]
Date: Wednesday, August 4, 2010, 1:40 AM

Quoted 1 line · Ruslan Nikolaev

I've just tried to configure newever version

(2.6.32.16) from repositary. However, boot fails because no root device is found. I am using disk image (the line in HVM config is disk = [ 'file:/home/ruslan/fs1.img,hda,w' ])

Quoted 1 line

I also tried to compile kernel with 'blktap' driver

which is disabled in default kernel config, but it does not help.

What is your root= parameter?  If you're using pv-on-hvm drivers, then
the device will be named /dev/xvd[a-d] (for the moment).  It's very
strongly recommended that you don't use a device-based root name (ie,
use LABEL= UUID= or LVM for your root device) so that your config is
failsafe against root device name changes.

     J

Quoted 1 line

The previous version (2.6.31.13) worked fine with the

same disk image and default configuration.

Quoted 5 lines

Thanks,
Ruslan.

--- On Sat, 7/31/10, Jeremy Fitzhardinge<[email protected]>

Quoted 22 lines · wrote:
Quoted 22 lines

From: Jeremy Fitzhardinge<[email protected]>
Subject: Re: [Xen-devel] HVM hypercalls
To: "Ruslan Nikolaev"<[email protected]>
Cc: [email protected]
Date: Saturday, July 31, 2010, 4:07 AM

Quoted 3 lines · Ruslan Nikolaev

I have 2 kernels:

1. From Xen repositary pvops-git (2.6.31.13).

You want 2.6.32.16 from xen.git - the branch is
xen/stable-2.6.32.x

       J

Quoted 6 lines

2. From kernel.org: 2.6.32.16

Thank you!
Ruslan.

Quoted 8 lines
Quoted 8 lines
Quoted 1 line

--- On Thu, 7/29/10, Jeremy Fitzhardinge<[email protected]>

Quoted 6 lines · wrote:
Quoted 6 lines

From: Jeremy Fitzhardinge<[email protected]>
Subject: Re: [Xen-devel] HVM hypercalls
To: "Ruslan Nikolaev"<[email protected]>
Cc: [email protected]
Date: Thursday, July 29, 2010, 11:47 PM
     On 07/29/2010

11:55 AM, Ruslan

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 1 line · Nikolaev

Thank you very much! I'll try this.

BTW is it

Quoted 2 lines
Quoted 2 lines

required

Quoted 1 line
Quoted 1 line

to do this for every module with HVM

hypercalls or

Quoted 2 lines
Quoted 2 lines

there is

Quoted 1 line
Quoted 1 line

some shared initialization code in HVM

guest

Quoted 3 lines
Quoted 3 lines

(Linux) similar

Quoted 2 lines
Quoted 2 lines

to one used in paravirtualized guests?

Quoted 1 line

If it's supposed to be in a module, is

there

Quoted 3 lines
Quoted 3 lines

any good

Quoted 2 lines
Quoted 2 lines

example I can look at?

Quoted 1 line

AFAIK hypercall_page is being

initialized on

Quoted 2 lines
Quoted 2 lines

Xen side

Quoted 1 line
Quoted 1 line

with appropriate vmcall/vmmcall code. Is

this

Quoted 2 lines
Quoted 2 lines

CPUID

Quoted 1 line
Quoted 1 line

mechanism a standard way to obtain

hypercall_page

Quoted 4 lines
Quoted 4 lines

reference

Quoted 3 lines
Quoted 3 lines

on HVM domain?

What kernel are you working with?

There's

Quoted 2 lines
Quoted 2 lines

already

Quoted 1 line
Quoted 1 line

code to implement pv-on-hvm support for

various

Quoted 2 lines
Quoted 2 lines

recent pvops

Quoted 1 line
Quoted 1 line

kernels, so you can just base your work on

those.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines

        J

_______________________________________________

Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

Quoted 8 lines
Quoted 5 lines

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#10 lore raw
Quoted 8 lines · On Wednesday 04 August 2010 19:41:20 Ruslan Nikolaev wrote:

Yes, I tried this but it does not seem to work. BTW in paravirtualized mode it works fine, the problem is only with HVM.

I tried to specify root=/dev/xvda (my disk image has no partitions, entire disk image is a single file system).

My config is (I also tried to comment out device model but it does not help):

You can simplify your guest config file:

Quoted 6 lines

import os, re
arch = os.uname()[4]
if re.search('64', arch):

    arch_libdir = 'lib64'

else:
arch_libdir = 'lib'

Remove this part.

Quoted 1 line

kernel = "/usr/lib/xen/boot/hvmloader"

kernel = "hvmloader"

Quoted 9 lines

builder='hvm'

vcpus=1

memory = 1024
shadow_memory = 8
name = "xenhvm1"
disk = [ 'file:/home/ruslan/fs1.img,xvda,w' ] device_model = '/usr/' + arch_libdir + '/xen/bin/qemu-dm'

device_model = "qemu-dm"

Quoted 11 lines
# boot on floppy (a), hard disk (c) or CD-ROM (d)
# default: hard disk, cd-rom, floppy
boot="c"

sdl=1
vnc=0
vncviewer=0
vncpasswd=''
stdvga=1
serial='pty'
usbdevice='tablet'

Christoph

Signature · 6 lines
---to satisfy European Law for business letters:
Advanced Micro Devices GmbH
Einsteinring 24, 85609 Dornach b. Muenchen
Geschaeftsfuehrer: Alberto Bozzo, Andrew Bowd
Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen
Registergericht Muenchen, HRB Nr. 43632
#11 lore raw
In reply to Ruslan Nikolaev
Quoted 4 lines · Ruslan Nikolaev

Yes, I tried this but it does not seem to work. BTW in paravirtualized mode it works fine, the problem is only with HVM.

I tried to specify root=/dev/xvda (my disk image has no partitions, entire disk image is a single file system).

If your disk file represents a single partition and in your pv config file you have a disk entry like this one:

disk = [ 'file:/home/ruslan/fs1.img,xvda1,w' ]

then your disk is not going to work in HVM mode.
Qemu must be able to handle your disk otherwise the bootloader won't be able to boot your kernel.

Quoted 9 lines

My config is (I also tried to comment out device model but it does not help):

import os, re
arch = os.uname()[4]
if re.search('64', arch):

    arch_libdir = 'lib64'

else:
arch_libdir = 'lib'

remove this part if you are using xl

Quoted 10 lines

kernel = "/usr/lib/xen/boot/hvmloader"

builder='hvm'

vcpus=1

memory = 1024
shadow_memory = 8
name = "xenhvm1"
disk = [ 'file:/home/ruslan/fs1.img,xvda,w' ]

Even though xvda is currently supported it would be better to specify hda here if you only have one disk, because you need at least an IDE interface to boot.

Quoted 1 line

device_model = '/usr/' + arch_libdir + '/xen/bin/qemu-dm'

device_model='qemu-dm' especially if you are using xl

#12 lore raw
In reply to Juergen Gross

Hi,

I recently started working on XEN, and I am looking for ways to invoke hypercalls from HVM.
I followed your instructions and succeeded in reading MSR register. But when i attempt to write the physical address of a 4K page from my HVM guest (2.6.30 kernel), i observed the XEN hypervisor reporting it as bad GMFN as follows.

[root@f13 ~]# xm dmesg -c
(XEN) traps.c:664:d17 Bad GMFN ffff88001e925 (MFN ffffffffffffffff) to MSR 40000000

Could you please help me in understanding what went wrong in my implementation.

I am running XEN 4.0.1 on AMD 64bit machine with svm support and the dom0 kernel running 2.6.32.39.

The
Thanks & Regards,
VSR.

--
View this message in context: http://xen.1045712.n5.nabble.com/HVM-hypercalls-tp2541346p4418332.html
Sent from the Xen - Dev mailing list archive at Nabble.com.

#13 lore raw
Quoted 9 lines · veeruyours

Hi,

I recently started working on XEN, and I am looking for ways to invoke hypercalls from HVM.
I followed your instructions and succeeded in reading MSR register. But when i attempt to write the physical address of a 4K page from my HVM guest (2.6.30 kernel), i observed the XEN hypervisor reporting it as bad GMFN as follows.

Quoted 3 lines

[root@f13 ~]# xm dmesg -c
(XEN) traps.c:664:d17 Bad GMFN ffff88001e925 (MFN ffffffffffffffff) to MSR 40000000

That supposed GMFN (fff88001e925) looks an awful lot like a virtual address and not a physical one to me, unless your guest really has >4TB of RAM assigned...

Quoted 20 lines

Could you please help me in understanding what went wrong in my implementation.

I am running XEN 4.0.1 on AMD 64bit machine with svm support and the dom0 kernel running 2.6.32.39.

The
Thanks & Regards,
VSR.

--
View this message in context: http://xen.1045712.n5.nabble.com/HVM-hypercalls-tp2541346p4418332.html
Sent from the Xen - Dev mailing list archive at Nabble.com.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#14 lore raw

Hi,

Thanks a lot for quick reply.

I modified my code to get physical page address and now i do not see error message on XEN hypervisor.
Could you please correct if am writing proper physical address or not?

We can write the page address to hypervisor using wrmsr() but who should set hypercall_page which is declared as extern in hypercall.h on HVM? Because when i try to invoke HYPERCALL_xxxx(), it reported hypercall_page not declared. Do we need to enable CONFIG_XEN in HVM kernel in order to invoke hypercalls to hypervisor?

Could you please share any sample code if you have to get a clear understanding of HVM hypercalls.

{
        char id[13];
        unsigned int msr1;
        unsigned long  my_hpage_phys;
        int my_hpage_lo, my_hpage_hi;

        __asm__ __volatile__(
                "cpuid"
                : "=b" (*(int *)(&id[0])),
                  "=d" (*(int *)(&id[8])),
                  "=c" (*(int *)(&id[4]))
                : "a" (0x40000000)
        );
        id[12]='\0';
        printk("CPU ID read- %s\n", id);

        /* Read MSR register */
        __asm__ __volatile__(
                "cpuid"
                : "=b" (*(int *)(&msr1))
                : "a" (0x40000002)
        );

        my_hpage_phys = __get_free_page(GFP_ATOMIC);
        hypercall_page = virt_to_phys(my_hpage_phys);
        printk("my_hpage_phys get_free = %lx\n", my_hpage_phys);
        printk("hypercal_page = %p\n", hypercall_page);

        my_hpage_lo = (unsigned long)hypercall_page & 0xffffffff;
        my_hpage_hi = (unsigned long)hypercall_page >> 32;
        printk("my_hpage lo = %x hi = %x\n", my_hpage_lo, my_hpage_hi);
        /* Write hypercall page address to MSR */
        wrmsr(msr1, my_hpage_lo, my_hpage_hi);

        return 0;
}

================= output on HVM ==========
[root@localhost src]# dmesg
my_hypercall_page @ ffffffffa0388000
CPU ID read- XenVMMXenVMM
my_hpage_phys get_free = ffff880005c0b000
hypercal_page = 0000000005c0b000
my_hpage lo = 5c0b000 hi = 0
============================

Thanks & Regards,
VSR.

Quoted 26 lines · Ian Campbell
Quoted 11 lines · veeruyours

Hi,

I recently started working on XEN, and I am looking for ways to invoke hypercalls from HVM.
I followed your instructions and succeeded in reading MSR register. But when i attempt to write the physical address of a 4K page from my HVM guest (2.6.30 kernel), i observed the XEN hypervisor reporting it as bad GMFN as follows.

[root@f13 ~]# xm dmesg -c
(XEN) traps.c:664:d17 Bad GMFN ffff88001e925 (MFN ffffffffffffffff) to

MSR

Quoted 1 line

40000000

That supposed GMFN (fff88001e925) looks an awful lot like a virtual address and not a physical one to me, unless your guest really has >4TB of RAM assigned...

Quoted 7 lines

Could you please help me in understanding what went wrong in my implementation.

I am running XEN 4.0.1 on AMD 64bit machine with svm support and the dom0 kernel running 2.6.32.39.

Quoted 17 lines
Quoted 7 lines

The
Thanks & Regards,
VSR.

--
View this message in context:

http://xen.1045712.n5.nabble.com/HVM-hypercalls-tp2541346p4418332.html

Quoted 6 lines

Sent from the Xen - Dev mailing list archive at Nabble.com.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#15 lore raw
Quoted 8 lines · veerasena reddy

Hi,

Thanks a lot for quick reply.

I modified my code to get physical page address and now i do not see error message on XEN hypervisor.
Could you please correct if am writing proper physical address or not?

Quoted 5 lines

We can write the page address to hypervisor using wrmsr() but who should set hypercall_page which is declared as extern in hypercall.h on HVM? Because when i try to invoke HYPERCALL_xxxx(), it reported hypercall_page not declared. Do we need to enable CONFIG_XEN in HVM kernel in order to invoke hypercalls to hypervisor?

Which kernel are you running with?

This should all be taken care of for you in a kernel with PVHVM support enabled.

Quoted 109 lines

Could you please share any sample code if you have to get a clear understanding of HVM hypercalls.

{
        char id[13];
        unsigned int msr1;
        unsigned long  my_hpage_phys;
        int my_hpage_lo, my_hpage_hi;

        __asm__ __volatile__(
                "cpuid"
                : "=b" (*(int *)(&id[0])),
                  "=d" (*(int *)(&id[8])),
                  "=c" (*(int *)(&id[4]))
                : "a" (0x40000000)
        );
        id[12]='\0';
        printk("CPU ID read- %s\n", id);

        /* Read MSR register */
        __asm__ __volatile__(
                "cpuid"
                : "=b" (*(int *)(&msr1))
                : "a" (0x40000002)
        );

        my_hpage_phys = __get_free_page(GFP_ATOMIC);
        hypercall_page = virt_to_phys(my_hpage_phys);
        printk("my_hpage_phys get_free = %lx\n", my_hpage_phys);
        printk("hypercal_page = %p\n", hypercall_page);

        my_hpage_lo = (unsigned long)hypercall_page & 0xffffffff;
        my_hpage_hi = (unsigned long)hypercall_page >> 32;
        printk("my_hpage lo = %x hi = %x\n", my_hpage_lo,
my_hpage_hi);
        /* Write hypercall page address to MSR */
        wrmsr(msr1, my_hpage_lo, my_hpage_hi);

        return 0;
}

================= output on HVM ==========
[root@localhost src]# dmesg
my_hypercall_page @ ffffffffa0388000
CPU ID read- XenVMMXenVMM
my_hpage_phys get_free = ffff880005c0b000
hypercal_page = 0000000005c0b000
my_hpage lo = 5c0b000 hi = 0
============================

Thanks & Regards,
VSR.

On Mon, May 23, 2011 at 1:52 PM, Ian Campbell <[email protected]> wrote:
On Mon, 2011-05-23 at 08:48 +0100, veeruyours wrote:
> Hi,
>
> I recently started working on XEN, and I am looking for ways to invoke
> hypercalls from HVM.
> I followed your instructions and succeeded in reading MSR register.
> But when i attempt to write the physical address of a 4K page from my HVM
> guest (2.6.30 kernel), i observed the XEN hypervisor reporting it as bad
> GMFN as follows.
>
> [root@f13 ~]# xm dmesg -c
> (XEN) traps.c:664:d17 Bad GMFN ffff88001e925 (MFN ffffffffffffffff) to MSR
> 40000000

That supposed GMFN (fff88001e925) looks an awful lot like a virtual
address and not a physical one to me, unless your guest really has >4TB
of RAM assigned...

>
> Could you please help me in understanding what went wrong in my
> implementation.
>
> I am running XEN 4.0.1 on AMD 64bit machine with svm support and the dom0
> kernel running 2.6.32.39.
>
> The
> Thanks & Regards,
> VSR.
>
>
> --
> View this message in context:
http://xen.1045712.n5.nabble.com/HVM-hypercalls-tp2541346p4418332.html
> Sent from the Xen - Dev mailing list archive at Nabble.com. >
> _______________________________________________
> Xen-devel mailing list
> [email protected]
> http://lists.xensource.com/xen-devel

#16 lore raw

I am running 2.6.30 (downloaded from kernel.org) on top of CENTOS 5.4. Do u mean i should enable following option

--> Processor type and features

      [*] Paravirtualized guest support  --->
             --> [ ]   Xen guest support (NEW)

But enabling this also selects PARAVIRT and does it make my guest PV guest or PVHVM guest?

--- Paravirtualized guest support
[*] Xen guest support
(32) Maximum allowed size of a domain in gigabytes (NEW)
[ ] Enable Xen debug and tuning parameters in debugfs

[ ]   KVM paravirtualized clock (NEW)
[ ]   KVM Guest support (NEW)
-*-   Enable paravirtualization code

[ ] Paravirtualization layer for spinlocks

Could you please suggest how to enable only PVHVM support? I am fine for moving to recent kernels if required.

Thanks & Regards,
VSR.

Quoted 141 lines · On Tue, May 24, 2011 at 5:38 PM, Ian Campbell-12 [via Xen] <…
Quoted 8 lines · veerasena reddy

Hi,

Thanks a lot for quick reply.

I modified my code to get physical page address and now i do not see error message on XEN hypervisor.
Could you please correct if am writing proper physical address or not?

Quoted 5 lines

We can write the page address to hypervisor using wrmsr() but who should set hypercall_page which is declared as extern in hypercall.h on HVM? Because when i try to invoke HYPERCALL_xxxx(), it reported hypercall_page not declared. Do we need to enable CONFIG_XEN in HVM kernel in order to invoke hypercalls to hypervisor?

Which kernel are you running with?

This should all be taken care of for you in a kernel with PVHVM support enabled.

Quoted 55 lines

Could you please share any sample code if you have to get a clear understanding of HVM hypercalls.

{
        char id[13];
        unsigned int msr1;
        unsigned long  my_hpage_phys;
        int my_hpage_lo, my_hpage_hi;

        __asm__ __volatile__(
                "cpuid"
                : "=b" (*(int *)(&id[0])),
                  "=d" (*(int *)(&id[8])),
                  "=c" (*(int *)(&id[4]))
                : "a" (0x40000000)
        );
        id[12]='\0';
        printk("CPU ID read- %s\n", id);

        /* Read MSR register */
        __asm__ __volatile__(
                "cpuid"
                : "=b" (*(int *)(&msr1))
                : "a" (0x40000002)
        );

        my_hpage_phys = __get_free_page(GFP_ATOMIC);
        hypercall_page = virt_to_phys(my_hpage_phys);
        printk("my_hpage_phys get_free = %lx\n", my_hpage_phys);
        printk("hypercal_page = %p\n", hypercall_page);

        my_hpage_lo = (unsigned long)hypercall_page & 0xffffffff;
        my_hpage_hi = (unsigned long)hypercall_page >> 32;
        printk("my_hpage lo = %x hi = %x\n", my_hpage_lo,
my_hpage_hi);
        /* Write hypercall page address to MSR */
        wrmsr(msr1, my_hpage_lo, my_hpage_hi);

        return 0;
}

================= output on HVM ==========
[root@localhost src]# dmesg
my_hypercall_page @ ffffffffa0388000
CPU ID read- XenVMMXenVMM
my_hpage_phys get_free = ffff880005c0b000
hypercal_page = 0000000005c0b000
my_hpage lo = 5c0b000 hi = 0
============================

Thanks & Regards,
VSR.

On Mon, May 23, 2011 at 1:52 PM, Ian Campbell
<[hidden email] <http://user/SendEmail.jtp?type=node&node=4421864&i=0>>

Quoted 27 lines · wrote:

On Mon, 2011-05-23 at 08:48 +0100, veeruyours wrote:
> Hi,
>
> I recently started working on XEN, and I am looking for ways to invoke
> hypercalls from HVM.
> I followed your instructions and succeeded in reading MSR register.
> But when i attempt to write the physical address of a 4K page from my HVM
> guest (2.6.30 kernel), i observed the XEN hypervisor reporting it as bad
> GMFN as follows.
>
> [root@f13 ~]# xm dmesg -c
> (XEN) traps.c:664:d17 Bad GMFN ffff88001e925 (MFN ffffffffffffffff) to MSR
> 40000000

That supposed GMFN (fff88001e925) looks an awful lot like a virtual
address and not a physical one to me, unless your guest really has >4TB
of RAM assigned...

Quoted 17 lines

>
> Could you please help me in understanding what went wrong in my
> implementation.
>
> I am running XEN 4.0.1 on AMD 64bit machine with svm support and the dom0
> kernel running 2.6.32.39.
>
> The
> Thanks & Regards,
> VSR.
>
>
> --
> View this message in context:

http://xen.1045712.n5.nabble.com/HVM-hypercalls-tp2541346p4418332.html

Quoted 10 lines
        > Sent from the Xen - Dev mailing list archive at Nabble.com.
        >
        > _______________________________________________
        > Xen-devel mailing list
        > [hidden email]<http://user/SendEmail.jtp?type=node&node=4421864&i=1>
        > http://lists.xensource.com/xen-devel

_______________________________________________
Xen-devel mailing list
[hidden email] <http://user/SendEmail.jtp?type=node&node=4421864&i=2>
http://lists.xensource.com/xen-devel

Quoted 7 lines

------------------------------
If you reply to this email, your message will be added to the discussion
below:
http://xen.1045712.n5.nabble.com/HVM-hypercalls-tp2541346p4421864.html
To unsubscribe from HVM hypercalls, click here<http://xen.1045712.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=2541346&code=dmVlcnV5b3Vyc0BnbWFpbC5jb218MjU0MTM0NnwyMDQ5MTI4OTk2>.

--
View this message in context: http://xen.1045712.n5.nabble.com/HVM-hypercalls-tp2541346p4422128.html
Sent from the Xen - Dev mailing list archive at Nabble.com.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#17 lore raw
Quoted 1 line · veeruyours

I am running 2.6.30 (downloaded from kernel.org) on top of CENTOS 5.4.

That is a very old kernel (June 2009 IIRC).

Quoted 8 lines

Do u mean i should enable following option

--> Processor type and features

      [*] Paravirtualized guest support  --->
             --> [ ]   Xen guest support (NEW)

But enabling this also selects PARAVIRT and does it make my guest PV guest or PVHVM guest?

This kernel only support PV and not PVHVM. You need something newer for PVHVM, I forget exactly when it was but 2.6.38/39 is certainly new enough.

Ian.

#18 lore raw

Hi,

I downloaded 2.6.38.7 and seen the CONFIG_XEN_PVHVM available. This feature is automatically selected if XEN and X86_LOCAL_APIC are seletected.

config XEN_PVHVM
def_bool y
depends on XEN
depends on X86_LOCAL_APIC

But, when i select XEN (CONFIG_XEN), it automatically selects "PARAVIRT". Does that make my HVM guest into PV guest?

CONFIG_PARAVIRT:

This changes the kernel so it can modify itself when it is run under a hypervisor, potentially improving performance significantly over full virtualization. However, when run without a hypervisor the kernel is theoretically slower and slightly larger.

i do not want to convert HVM guest into PV, i just want to make hypercalls from HVM guest to hypervisor.

Could you please suggest.

Thanks & Regards,
VSR.

Quoted 27 lines · On Tue, May 24, 2011 at 7:39 PM, Ian Campbell-10 [via Xen] <…
Quoted 1 line · veeruyours

I am running 2.6.30 (downloaded from kernel.org) on top of CENTOS 5.4.

That is a very old kernel (June 2009 IIRC).

Quoted 8 lines

Do u mean i should enable following option

--> Processor type and features

      [*] Paravirtualized guest support  --->
             --> [ ]   Xen guest support (NEW)

But enabling this also selects PARAVIRT and does it make my guest PV guest or PVHVM guest?

This kernel only support PV and not PVHVM. You need something newer for PVHVM, I forget exactly when it was but 2.6.38/39 is certainly new enough.

Ian.

_______________________________________________
Xen-devel mailing list
[hidden email] <http://user/SendEmail.jtp?type=node&node=4422155&i=0>
http://lists.xensource.com/xen-devel

Quoted 7 lines

------------------------------
If you reply to this email, your message will be added to the discussion
below:
http://xen.1045712.n5.nabble.com/HVM-hypercalls-tp2541346p4422155.html
To unsubscribe from HVM hypercalls, click here<http://xen.1045712.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=2541346&code=dmVlcnV5b3Vyc0BnbWFpbC5jb218MjU0MTM0NnwyMDQ5MTI4OTk2>.

--
View this message in context: http://xen.1045712.n5.nabble.com/HVM-hypercalls-tp2541346p4424489.html
Sent from the Xen - Dev mailing list archive at Nabble.com.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#19 lore raw
Quoted 6 lines · veeruyours

Hi,

I downloaded 2.6.38.7 and seen the CONFIG_XEN_PVHVM available. This feature is automatically selected if XEN and X86_LOCAL_APIC are seletected.

Quoted 7 lines

config XEN_PVHVM
def_bool y
depends on XEN
depends on X86_LOCAL_APIC

But, when i select XEN (CONFIG_XEN), it automatically selects "PARAVIRT". Does that make my HVM guest into PV guest?

No. It makes your kernel capable of being used as either PV, PVHVM or just HVM kernel. The guest type is purely derived from the guest cfg file you use.

PV vs PVHVM/HVM is controlled by specifying hvm=0|1. PVHVM vs HVM is controlled via the xen_platform_device=0|1 option, disabling the platform device (it is enabled by default) puts you back to just HVM mode.

BTW, this sort of question really belongs on xen-users.

Ian.

Quoted 67 lines

CONFIG_PARAVIRT:

This changes the kernel so it can modify itself when it is run under a hypervisor, potentially improving performance significantly over full virtualization. However, when run without a hypervisor the kernel is theoretically slower and slightly larger.

i do not want to convert HVM guest into PV, i just want to make hypercalls from HVM guest to hypervisor.

Could you please suggest.

Thanks & Regards,
VSR.

On Tue, May 24, 2011 at 7:39 PM, Ian Campbell-10 [via Xen] <[hidden email]> wrote:
On Tue, 2011-05-24 at 14:58 +0100, veeruyours wrote:

> I am running 2.6.30 (downloaded from kernel.org) on top of CENTOS 5.4.

That is a very old kernel (June 2009 IIRC).

> Do u mean i should enable following option
>
> --> Processor type and features
> [*] Paravirtualized guest support --->
> --> [ ] Xen guest support (NEW)
>
> But enabling this also selects PARAVIRT and does it make my guest PV
> guest or PVHVM guest?

This kernel only support PV and not PVHVM. You need something newer for
PVHVM, I forget exactly when it was but 2.6.38/39 is certainly new
enough.

Ian.

_______________________________________________
Xen-devel mailing list
[hidden email]
http://lists.xensource.com/xen-devel

______________________________________________________________
If you reply to this email, your message will be added to the discussion below:
http://xen.1045712.n5.nabble.com/HVM-hypercalls-tp2541346p4422155.html

To unsubscribe from HVM hypercalls, click here.

______________________________________________________________________
View this message in context: Re: HVM hypercalls Sent from the Xen - Dev mailing list archive at Nabble.com.