Skip to contentSkip to conversation

HYBRID: PV in HVM container

DISCUSSION Mukesh Rathor 8 participants 30 messages Jun 27, 2011 – Nov 19, 2011

Subsystems (8)
lore
Share & tools
lore
#0 lore raw

Hi guys,

Cheers!! I got PV in HVM container prototype working with single VCPU (pinned to a cpu). Basically, I create a VMX container just like for HVM guest (with some differences that I'll share soon when I clean up the code). The PV guest starts in Protected mode with the usual entry point startup_xen().

0. Guest kernel runs in ring 0, CS:0x10.

1. I use xen for all pt management just like a PV guest. So at present all faults are going to xen, and when fixup_page_fault() fails, they are injected into the container for the guest to handle it.

2. The guest manages the GDT, LDT, TR, in the container.

3. The guest installs the trap table in the vmx container instead of do_set_trap_table().

4. Events/INTs are delivered via HVMIRQ_callback_vector.

5. MSR_GS_BASE is managed by the guest in the container itself.

6. Currently, I'm managing cr4 in the container, but going to xen for cr0. I need to revisit that.

7. Currently, VPID is disabled, I need to figure it out, and revisit.

8. Currently, VM_ENTRY_LOAD_GUEST_PAT is disabled, I need to look at that.

These are the salient points I can think of at the moment. Next, I am going to run LMBench and figure out the gains. After that, make sure SMP works, and things are stable, and look at any enhancements. I need to look at couple unrelated bugs at the moment, but hope to return back to this very soon.

thanks,
Mukesh

#1 lore raw
Quoted 11 lines · Mukesh Rathor

Hi guys,

Cheers!! I got PV in HVM container prototype working with single VCPU (pinned to a cpu). Basically, I create a VMX container just like for HVM guest (with some differences that I'll share soon when I clean up the code). The PV guest starts in Protected mode with the usual entry point startup_xen().

0. Guest kernel runs in ring 0, CS:0x10.

Quoted 8 lines

1. I use xen for all pt management just like a PV guest. So at present all faults are going to xen, and when fixup_page_fault() fails, they are injected into the container for the guest to handle it.

2. The guest manages the GDT, LDT, TR, in the container.

3. The guest installs the trap table in the vmx container instead of do_set_trap_table().

To be clear, you intend for this to work with unmodified PV guests, right? All of this translation can easily be done in Xen, avoiding multiple paths needed in the guest kernel (not really tenable for upstreaming).

-- Keir

Quoted 26 lines

4. Events/INTs are delivered via HVMIRQ_callback_vector.

5. MSR_GS_BASE is managed by the guest in the container itself.

6. Currently, I'm managing cr4 in the container, but going to xen for cr0. I need to revisit that.

7. Currently, VPID is disabled, I need to figure it out, and revisit.

8. Currently, VM_ENTRY_LOAD_GUEST_PAT is disabled, I need to look at that.

These are the salient points I can think of at the moment. Next, I am going to run LMBench and figure out the gains. After that, make sure SMP works, and things are stable, and look at any enhancements. I need to look at couple unrelated bugs at the moment, but hope to return back to this very soon.

thanks,
Mukesh

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

#2 lore raw
Quoted 23 lines · On Mon, 27 Jun 2011 20:36:18 +0100 Keir Fraser <[email protected]> wrote:
Quoted 16 lines · Mukesh Rathor

Hi guys,

Cheers!! I got PV in HVM container prototype working with single VCPU (pinned to a cpu). Basically, I create a VMX container just like for HVM guest (with some differences that I'll share soon when I clean up the code). The PV guest starts in Protected mode with the usual entry point startup_xen().

0. Guest kernel runs in ring 0, CS:0x10.

1. I use xen for all pt management just like a PV guest. So at present all faults are going to xen, and when fixup_page_fault() fails, they are injected into the container for the guest to handle it.

Quoted 4 lines

2. The guest manages the GDT, LDT, TR, in the container.

3. The guest installs the trap table in the vmx container instead of do_set_trap_table().

Quoted 6 lines

To be clear, you intend for this to work with unmodified PV guests, right? All of this translation can easily be done in Xen, avoiding multiple paths needed in the guest kernel (not really tenable for upstreaming).

-- Keir

Hi Keir,

Actually, I modified the PVops guest. The changes in the pvops are minimal and mostly confied to xen specific files. So I think it has a fair shot of being upstreamed, at least, worth a shot. I will run them by Jeremy/Konrad and get their opinions.

thanks
Mukesh

#3 lore raw
Quoted 5 lines · Mukesh Rathor
Quoted 5 lines

To be clear, you intend for this to work with unmodified PV guests, right? All of this translation can easily be done in Xen, avoiding multiple paths needed in the guest kernel (not really tenable for upstreaming).

Quoted 8 lines
Quoted 1 line

-- Keir

Hi Keir,

Actually, I modified the PVops guest. The changes in the pvops are minimal and mostly confied to xen specific files. So I think it has a fair shot of being upstreamed, at least, worth a shot. I will run them by Jeremy/Konrad and get their opinions.

Well, maybe. But we now have HVM guests, PV guests, and PV-HVM guests. I'm not sure that adding explicitly HVM-PV guests as well isn't just a bloody mess.

-- Keir

Quoted 3 lines

thanks
Mukesh

#4 lore raw
Quoted 11 lines · Keir Fraser
Quoted 9 lines · Mukesh Rathor
Quoted 6 lines

To be clear, you intend for this to work with unmodified PV guests, right? All of this translation can easily be done in Xen, avoiding multiple paths needed in the guest kernel (not really tenable for upstreaming).

-- Keir

Hi Keir,

Quoted 8 lines
Quoted 4 lines

Actually, I modified the PVops guest. The changes in the pvops are minimal and mostly confied to xen specific files. So I think it has a fair shot of being upstreamed, at least, worth a shot. I will run them by Jeremy/Konrad and get their opinions.

Well, maybe. But we now have HVM guests, PV guests, and PV-HVM guests. I'm not sure that adding explicitly HVM-PV guests as well isn't just a bloody mess.

Ideally this container could be used to accelerate existing 64 bit guests (e.g. older distros running classic-Xen) unmodified (or at least only with latent bugs fixed) too.

Getting something working with a modified guest seems like a useful first step (to get to a working baseline) but I'm not sure it should be the end goal.

Ian.

#11 lore raw
In reply to Mukesh Rathor
Quoted 7 lines · Mukesh Rathor

Hi guys,

Cheers!! I got PV in HVM container prototype working with single VCPU (pinned to a cpu). Basically, I create a VMX container just like for HVM guest (with some differences that I'll share soon when I clean up the code). The PV guest starts in Protected mode with the usual entry point startup_xen().

Great stuff! I've been eagerly awaiting this functionality ;-)

Do you have any timeline for when you think you might post the code?

I presume you managed to avoid bouncing through the hypervisor for syscalls?

Cheers,
Ian.

Quoted 38 lines

0. Guest kernel runs in ring 0, CS:0x10.

1. I use xen for all pt management just like a PV guest. So at present all faults are going to xen, and when fixup_page_fault() fails, they are injected into the container for the guest to handle it.

2. The guest manages the GDT, LDT, TR, in the container.

3. The guest installs the trap table in the vmx container instead of do_set_trap_table().

4. Events/INTs are delivered via HVMIRQ_callback_vector.

5. MSR_GS_BASE is managed by the guest in the container itself.

6. Currently, I'm managing cr4 in the container, but going to xen for cr0. I need to revisit that.

7. Currently, VPID is disabled, I need to figure it out, and revisit.

8. Currently, VM_ENTRY_LOAD_GUEST_PAT is disabled, I need to look at that.

These are the salient points I can think of at the moment. Next, I am going to run LMBench and figure out the gains. After that, make sure SMP works, and things are stable, and look at any enhancements. I need to look at couple unrelated bugs at the moment, but hope to return back to this very soon.

thanks,
Mukesh

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

#5 lore raw
In reply to Ian Campbell
Quoted 10 lines · Ian Campbell
Quoted 5 lines · Keir Fraser

On 28/06/2011 02:51, "Mukesh Rathor" <[email protected]> wrote:

Well, maybe. But we now have HVM guests, PV guests, and PV-HVM guests. I'm not sure that adding explicitly HVM-PV guests as well isn't just a bloody mess.

Ideally this container could be used to accelerate existing 64 bit guests (e.g. older distros running classic-Xen) unmodified (or at least only with latent bugs fixed) too.

There was a question mark over whether unmodified PV guests would tolerate running in ring 0, rather than entirely in ring 3. I believe we're confident it should work, and thus supporting classic-Xen guests should certainly be the aim.

Quoted 3 lines

Getting something working with a modified guest seems like a useful first step (to get to a working baseline) but I'm not sure it should be the end goal.

I certainly don't think we should commit such a thing without careful thought.

-- Keir

Quoted 2 lines

Ian.

#6 lore raw
Quoted 9 lines · Keir Fraser
Quoted 7 lines · Ian Campbell
Quoted 5 lines · Keir Fraser

On 28/06/2011 02:51, "Mukesh Rathor" <[email protected]> wrote:

Well, maybe. But we now have HVM guests, PV guests, and PV-HVM guests. I'm not sure that adding explicitly HVM-PV guests as well isn't just a bloody mess.

Quoted 8 lines
Quoted 3 lines

Ideally this container could be used to accelerate existing 64 bit guests (e.g. older distros running classic-Xen) unmodified (or at least only with latent bugs fixed) too.

There was a question mark over whether unmodified PV guests would tolerate running in ring 0, rather than entirely in ring 3. I believe we're confident it should work, and thus supporting classic-Xen guests should certainly be the aim.

A guest which does XENFEAT_supervisor_mode_kernel (and perhaps one or two other XENFEATs) should work, but that was the primary source of the latent bugs I was thinking of...

In particular the pvops kernel probably doesn't do all the right things for XENFEAT_supervisor_mode_kernel, since it has never been run that way, but it also doesn't advertise it via XEN_ELFNOTE_FEATURES so we can at least detect when it is safe to enable the container from the builder side.

Quoted 6 lines
Quoted 3 lines

Getting something working with a modified guest seems like a useful first step (to get to a working baseline) but I'm not sure it should be the end goal.

I certainly don't think we should commit such a thing without careful thought.

Absolutely.

Ian.

#7 lore raw
In reply to Keir Fraser
Quoted 11 lines · Keir Fraser
Quoted 9 lines · Mukesh Rathor
Quoted 6 lines

To be clear, you intend for this to work with unmodified PV guests, right? All of this translation can easily be done in Xen, avoiding multiple paths needed in the guest kernel (not really tenable for upstreaming).

-- Keir

Hi Keir,

Quoted 8 lines
Quoted 4 lines

Actually, I modified the PVops guest. The changes in the pvops are minimal and mostly confied to xen specific files. So I think it has a fair shot of being upstreamed, at least, worth a shot. I will run them by Jeremy/Konrad and get their opinions.

Well, maybe. But we now have HVM guests, PV guests, and PV-HVM guests. I'm not sure that adding explicitly HVM-PV guests as well isn't just a bloody mess.

I very much agree on this point.

However it could still be useful at the very least to run a 64-bit hvm dom0 (assuming there is a significant performance improvement in doing so, compared to a traditional 64-bit dom0).

#8 lore raw
Quoted 21 lines · Stefano Stabellini
Quoted 11 lines · Keir Fraser
Quoted 9 lines · Mukesh Rathor
Quoted 6 lines

To be clear, you intend for this to work with unmodified PV guests, right? All of this translation can easily be done in Xen, avoiding multiple paths needed in the guest kernel (not really tenable for upstreaming).

-- Keir

Hi Keir,

Quoted 8 lines
Quoted 4 lines

Actually, I modified the PVops guest. The changes in the pvops are minimal and mostly confied to xen specific files. So I think it has a fair shot of being upstreamed, at least, worth a shot. I will run them by Jeremy/Konrad and get their opinions.

Well, maybe. But we now have HVM guests, PV guests, and PV-HVM guests. I'm not sure that adding explicitly HVM-PV guests as well isn't just a bloody mess.

Quoted 5 lines

I very much agree on this point.

However it could still be useful at the very least to run a 64-bit hvm dom0 (assuming there is a significant performance improvement in doing so, compared to a traditional 64-bit dom0).

That case is no different to the guest case in this respect, so we should still be aiming for not needing to modify the kernel. We certainly don't want to a new special case HVM-PV for dom0 only!

Ian.

#12 lore raw
In reply to Ian Campbell
Quoted 9 lines · On Tue, 28 Jun 2011 09:31:57 +0100 Ian Campbell <[email protected]> wrote:
Quoted 7 lines · Mukesh Rathor

Hi guys,

Cheers!! I got PV in HVM container prototype working with single VCPU (pinned to a cpu). Basically, I create a VMX container just like for HVM guest (with some differences that I'll share soon when I clean up the code). The PV guest starts in Protected mode with the usual entry point startup_xen().

Quoted 6 lines

Great stuff! I've been eagerly awaiting this functionality ;-)

Do you have any timeline for when you think you might post the code?

I presume you managed to avoid bouncing through the hypervisor for syscalls?

Yup, that was the primary goal. DB benchmarks suffered quite a bit because of syscall overhead.

thanks,
Mukesh

#9 lore raw
In reply to Keir Fraser
Quoted 11 lines · On Tue, 28 Jun 2011 08:46:08 +0100 Keir Fraser <[email protected]> wrote:
Quoted 6 lines · Mukesh Rathor

Hi Keir,

Actually, I modified the PVops guest. The changes in the pvops are minimal and mostly confied to xen specific files. So I think it has a fair shot of being upstreamed, at least, worth a shot. I will run them by Jeremy/Konrad and get their opinions.

Well, maybe. But we now have HVM guests, PV guests, and PV-HVM guests. I'm not sure that adding explicitly HVM-PV guests as well isn't just a bloody mess.

Could we perhaps define a HYBRID type that will have characteristics like, this runs in HVM container, it doesn't use EPT, it uses HVM callback, etc.. We can they modify it without defining any new types in future, say we find it works better with EPT under certain circumstances etc.. What do you think?

thanks,
Mukesh

#10 lore raw
Quoted 9 lines · Mukesh Rathor
Quoted 3 lines

Well, maybe. But we now have HVM guests, PV guests, and PV-HVM guests. I'm not sure that adding explicitly HVM-PV guests as well isn't just a bloody mess.

Could we perhaps define a HYBRID type that will have characteristics like, this runs in HVM container, it doesn't use EPT, it uses HVM callback, etc.. We can they modify it without defining any new types in future, say we find it works better with EPT under certain circumstances etc.. What do you think?

Yes, I don't mind the idea of some HVM extensions for performance, and that will probably become increasingly important. I just think we should support unmodified PV as a baseline, with best performance possible (i.e., the basic HVM container approach should support it).

-- Keir

#13 lore raw
In reply to Mukesh Rathor
Quoted 10 lines · On Mon, 27 Jun 2011 12:24:04 -0700 Mukesh Rathor <[email protected]>…

Hi guys,

Cheers!! I got PV in HVM container prototype working with single VCPU (pinned to a cpu). Basically, I create a VMX container just like for HVM guest (with some differences that I'll share soon when I clean up the code). The PV guest starts in Protected mode with the usual entry point startup_xen().

0. Guest kernel runs in ring 0, CS:0x10.

JFYI.. as expected, running in ring 0 and not bouncing syscalls thru xen, syscalls do very well. fork/execs are slow prob beause VPIDs are turned off right now. I'm trying to figure VPIDs out, and hopefully that would help. BTW, dont' compare to anything else, both kernels below are unoptimized debug kernels.

LMbench:
Processor, Processes - times in microseconds - smaller is better
----------------------------------------------------------------
Host OS Mhz null null open selct sig sig fork exec sh
call I/O stat clos TCP inst hndl proc proc proc
--------- ------------- ---- ---- ---- ---- ---- ----- ---- ---- ---- ---- ----
STOCK Linux 2.6.39+ 2771 0.68 0.91 2.13 4.45 4.251 0.82 3.87 433. 1134 3145
HYBRID Linux 2.6.39m 2745 0.13 0.22 0.88 2.04 3.287 0.28 1.11 526. 1393 3923

thanks,
Mukesh

#14 lore raw
Quoted 6 lines

JFYI.. as expected, running in ring 0 and not bouncing syscalls thru xen, syscalls do very well. fork/execs are slow prob beause VPIDs are turned off right now. I'm trying to figure VPIDs out, and hopefully that would help. BTW, dont' compare to anything else, both kernels below are unoptimized debug kernels.

Quoted 10 lines

LMbench:
Processor, Processes - times in microseconds - smaller is better
----------------------------------------------------------------
Host OS Mhz null null open selct sig sig fork
exec sh call I/O stat clos TCP inst hndl proc proc proc
--------- ------------- ---- ---- ---- ---- ---- ----- ---- ---- ----
---- ---- STOCK Linux 2.6.39+ 2771 0.68 0.91 2.13 4.45 4.251 0.82
3.87 433. 1134 3145 HYBRID Linux 2.6.39m 2745 0.13 0.22 0.88 2.04
3.287 0.28 1.11 526. 1393 3923

JFYI again, I seem to have caught up with pure PV on almost all with some optimizations:

Processor, Processes - times in microseconds - smaller is better
----------------------------------------------------------------
Host OS Mhz null null open selct sig sig fork exec sh
call I/O stat clos TCP inst hndl proc proc proc
--------- ------------- ---- ---- ---- ---- ---- ----- ---- ---- ---- ---- ----

STOCK:    Linux 2.6.39+ 2771 0.68 0.91 2.13 4.45 4.251 0.82 3.87 433. 1134 3145
N4        Linux 2.6.39m 2745 0.13 0.21 0.86 2.03 3.279 0.28 1.18 479. 1275 3502
N5        Linux 2.6.39m 2752 0.13 0.21 0.91 2.07 3.284 0.28 1.14 439. 1168 3155

Context switching - times in microseconds - smaller is better
-------------------------------------------------------------
Host OS 2p/0K 2p/16K 2p/64K 8p/16K 8p/64K 16p/16K 16p/64K
ctxsw ctxsw ctxsw ctxsw ctxsw ctxsw ctxsw
--------- ------------- ----- ------ ------ ------ ------ ------- -------

STOCK:    Linux 2.6.39+ 5.800 6.2400 6.8700 6.6700 8.4600 7.13000 8.63000
N4        Linux 2.6.39m 6.420 6.9300 8.0100 7.2600 8.7600 7.97000 9.25000
N5        Linux 2.6.39m 6.650 7.0000 7.8400 7.3900 8.8000 7.90000 9.06000

*Local* Communication latencies in microseconds - smaller is better
-------------------------------------------------------------------
Host OS 2p/0K Pipe AF UDP RPC/ TCP RPC/ TCP
ctxsw UNIX UDP TCP conn
--------- ------------- ----- ----- ---- ----- ----- ----- ----- ----

STOCK:    Linux 2.6.39+ 5.800  18.9 22.3  28.7  32.8  34.9  44.6 89.8
N4        Linux 2.6.39m 6.420  17.1 18.1  26.9  28.7  34.2  40.1 76.3
N5        Linux 2.6.39m 6.650  18.1 17.7  24.4  33.4  33.9  40.7 76.7

File & VM system latencies in microseconds - smaller is better
--------------------------------------------------------------

Host                 OS   0K File      10K File      Mmap    Prot    Page
                        Create Delete Create Delete  Latency Fault   Fault
--------- ------------- ------ ------ ------ ------  ------- -----   -----
STOCK:    Linux 2.6.39+                               3264.0 0.828 3.00000
N4        Linux 2.6.39m                               3990.0 1.351 4.00000
N5        Linux 2.6.39m                               3362.0 0.235 4.00000

where the only difference between N4 and N5 is that in N5 I've enabled vmexits only for page faults on write protection, ie, err code 0x3.

I'm trying to figure out how vtlb implemention relates to SDM 28.3.5. It seems in xen, vtlb is mostly for shadows glancing at the code, which I am not worrying for now (I've totally ignored migration for now). Any thoughts any body?

Also, at present I am not using vtsc, is it worth looking into? some of the tsc stuff makes my head spin just like the shadow code does :)...

thanks,
Mukesh

#15 lore raw
Quoted 7 lines · Mukesh Rathor

where the only difference between N4 and N5 is that in N5 I've enabled vmexits only for page faults on write protection, ie, err code 0x3.

I'm trying to figure out how vtlb implemention relates to SDM 28.3.5. It seems in xen, vtlb is mostly for shadows glancing at the code, which I am not worrying for now (I've totally ignored migration for now). Any thoughts any body?

You don't have to understand it very much. Trapping on write faults from supervisor mode only is fine for normal operation, and you'll have to fault on everything during live migration (since shadow page tables are built up via read & write demand faults).

Quoted 2 lines

Also, at present I am not using vtsc, is it worth looking into? some of the tsc stuff makes my head spin just like the shadow code does :)...

You have to understand that even less. For pure PV CR4.TSD gets set appropriately for the VTSC mode. You can hook off that, or duplicate that, to enable/disable RDTSC exiting instead. You don't have to actually *do* any vtsc work, as no doubt you jump out of your wrapper code into the proper PV paths for actually getting any real hypervisor work done (like vtsc).

-- Keir

#16 lore raw
In reply to Mukesh Rathor

Hi folks,

Well, I did some benchmarking and found interesting results. Following runs are on a westmere with 2 sockets and 10GB RAM. Xen was booted with maxcpus=2 and entire RAM. All guests were started with 1vcpu and 2GB RAM. dom0 started with 1 vcpu and 704MB. Baremetal was booted with 2GB and 1 cpu. HVM guest has EPT enabled. HT is on.

So, unless the NUMA'ness interfered with results (using some memory on remote socket), it appears HVM does very well. To the point that it seems a hybrid is not going to be worth it. I am currently running tests on a single socket system just to be sure.

I am attaching my diff's in case any one wants to see what I did. I used xen 4.0.2 and linux 2.6.39.

thanks,
Mukesh

L M B E N C H 3 . 0 S U M M A R Y

Processor, Processes - times in microseconds - smaller is better
------------------------------------------------------------------------------
Host OS Mhz null null open slct sig sig fork exec sh
call I/O stat clos TCP inst hndl proc proc proc
--------- ------------- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----

PV        Linux 2.6.39f 2639 0.65 0.88 2.14 4.59 3.77 0.79 3.62 535. 1294 3308
Hybrid    Linux 2.6.39f 2639 0.13 0.21 0.89 1.96 3.08 0.24 1.10 529. 1294 3246
HVM       Linux 2.6.39f 2639 0.12 0.21 0.64 1.76 3.04 0.24 3.37 113. 354. 1324

Baremetal Linux 2.6.39+ 2649 0.13 0.23 0.74 1.93 3.46 0.28 1.58 127. 386. 1434

Basic integer operations - times in nanoseconds - smaller is better
-------------------------------------------------------------------
Host OS intgr intgr intgr intgr intgr
bit add mul div mod
--------- ------------- ------ ------ ------ ------ ------

PV        Linux 2.6.39f 0.3800 0.0100 0.1700 9.1000 9.0400
Hybrid    Linux 2.6.39f 0.3800 0.0100 0.1700 9.1100 9.0300
HVM       Linux 2.6.39f 0.3800 0.0100 0.1700 9.1100 9.0600

Baremetal Linux 2.6.39+ 0.3800 0.0100 0.1700 9.0600 8.9800

Basic float operations - times in nanoseconds - smaller is better
-----------------------------------------------------------------

Host                 OS  float  float  float  float
                         add    mul    div    bogo
--------- ------------- ------ ------ ------ ------
PV        Linux 2.6.39f 1.1300 1.5200 5.6200 5.2900
Hybrid    Linux 2.6.39f 1.1300 1.5200 5.6300 5.2900
HVM       Linux 2.6.39f 1.1400 1.5200 5.6300 5.3000

Baremetal Linux 2.6.39+ 1.1300 1.5100 5.6000 5.2700

Basic double operations - times in nanoseconds - smaller is better
------------------------------------------------------------------
Host OS double double double double
add mul div bogo
--------- ------------- ------ ------ ------ ------

PV        Linux 2.6.39f 1.1300 1.9000 8.6400 8.3200
Hybrid    Linux 2.6.39f 1.1400 1.9000 8.6600 8.3200
HVM       Linux 2.6.39f 1.1400 1.9000 8.6600 8.3300

Baremetal Linux 2.6.39+ 1.1300 1.8900 8.6100 8.2800

Context switching - times in microseconds - smaller is better
-------------------------------------------------------------------------
Host OS 2p/0K 2p/16K 2p/64K 8p/16K 8p/64K 16p/16K 16p/64K
ctxsw ctxsw ctxsw ctxsw ctxsw ctxsw ctxsw
--------- ------------- ------ ------ ------ ------ ------ ------- -------

PV        Linux 2.6.39f 5.2800 5.7600 6.3600 6.3200 7.3600 6.69000 7.46000
Hybrid    Linux 2.6.39f 4.9200 4.9300 5.2200 5.7600 6.9600 6.12000 7.31000
HVM       Linux 2.6.39f 1.3100 1.2200 1.6200 1.9200 3.2600 2.23000 3.48000

Baremetal Linux 2.6.39+ 1.5500 1.4100 2.0600 2.2500 3.3900 2.44000 3.38000

*Local* Communication latencies in microseconds - smaller is better
---------------------------------------------------------------------
Host OS 2p/0K Pipe AF UDP RPC/ TCP RPC/ TCP
ctxsw UNIX UDP TCP conn
--------- ------------- ----- ----- ---- ----- ----- ----- ----- ----

PV        Linux 2.6.39f 5.280  16.6 21.3  25.9  33.7  34.7  41.8  87.
Hybrid    Linux 2.6.39f 4.920  11.2 14.4  19.6  26.1  27.5  32.9  71.
HVM       Linux 2.6.39f 1.310 4.416 6.15 9.386  14.8  15.8  20.1  45.
Baremetal Linux 2.6.39+ 1.550 4.625 7.34  14.3  19.8  21.4  26.4  66.

File & VM system latencies in microseconds - smaller is better
-------------------------------------------------------------------------------

Host                 OS   0K File      10K File     Mmap    Prot   Page   100fd
                        Create Delete Create Delete Latency Fault  Fault  selct
--------- ------------- ------ ------ ------ ------ ------- ----- ------- -----
PV        Linux 2.6.39f                               24.0K 0.746 3.55870 2.184
Hybrid    Linux 2.6.39f                               24.6K 0.238 4.00100 1.480
HVM       Linux 2.6.39f                              4716.0 0.202 0.96600 1.468

Baremetal Linux 2.6.39+ 6898.0 0.325 0.93610 1.620

*Local* Communication bandwidths in MB/s - bigger is better
-----------------------------------------------------------------------------
Host OS Pipe AF TCP File Mmap Bcopy Bcopy Mem Mem
UNIX reread reread (libc) (hand) read write
--------- ------------- ---- ---- ---- ------ ------ ------ ------ ---- -----

PV        Linux 2.6.39f 1661 2081 1041 3293.3 5528.3 3106.6 2800.0 4472 5633.
Hybrid    Linux 2.6.39f 1974 2450 1183 3481.5 5529.6 3114.9 2786.6 4470 5672.
HVM       Linux 2.6.39f 3232 2929 1622 3541.3 5527.5 3077.1 2765.6 4453 5634.

Baremetal Linux 2.6.39+ 3320 2800 1666 3523.6 5578.9 3147.0 2841.6 4541 5752.

Memory latencies in nanoseconds - smaller is better
(WARNING - may not be correct, check graphs)
------------------------------------------------------------------------------

Host                 OS   Mhz   L1 $   L2 $    Main mem    Rand mem    Guesses
--------- -------------   ---   ----   ----    --------    --------    -------
PV        Linux 2.6.39f  2639 1.5160 5.9170   29.7        97.5
Hybrid    Linux 2.6.39f  2639 1.5170 7.5000   29.7        97.4
HVM       Linux 2.6.39f  2639 1.5190 4.0210   29.8       105.4
Baremetal Linux 2.6.39+  2649 1.5090 3.8370   29.2        78.0
xen/arch/x86/domain.c +111 -6
diff -r f2cf898c7ff8 xen/arch/x86/domain.c
@@ -354,7 +354,12 @@ int vcpu_initialise(struct vcpu *v)
 
     paging_vcpu_init(v);
 
-    if ( is_hvm_domain(d) )
+    if ( is_hybrid_domain(d) )
+    {
+        if ( (rc = hybrid_vcpu_initialise(v)) != 0 )
+            return rc;
+    }
+    else if ( is_hvm_domain(d) )
     {
         if ( (rc = hvm_vcpu_initialise(v)) != 0 )
             return rc;
@@ -515,9 +520,17 @@ int arch_domain_create(struct domain *d,
             iommu_domain_destroy(d);
             goto fail;
         }
-    }
-    else
-    {
+
+    } else if ( is_hybrid_domain(d) ) {
+
+        if ( (rc = hybrid_domain_initialise(d)) != 0 )
+        {
+            iommu_domain_destroy(d);
+            goto fail;
+        }
+
+    } else {
+
         /* 32-bit PV guest by default only if Xen is not 64-bit. */
         d->arch.is_32bit_pv = d->arch.has_32bit_shinfo =
             (CONFIG_PAGING_LEVELS != 4);
@@ -608,6 +621,95 @@ unsigned long pv_guest_cr4_fixup(unsigne
     return (hv_cr4 & hv_cr4_mask) | (guest_cr4 & ~hv_cr4_mask);
 }
 
+extern void hybrid_update_cr3(struct vcpu *);
+int hybrid_arch_set_info_guest( struct vcpu *v, vcpu_guest_context_u c)
+{
+    struct domain *d = v->domain;
+    unsigned long cr3_pfn = INVALID_MFN;
+    unsigned long flags;
+    int i;
+
+#define c(fld) (c.nat->fld)
+
+    flags = c(flags);
+    v->fpu_initialised = !!(flags & VGCF_I387_VALID);
+    v->arch.flags |= TF_kernel_mode;
+
+    memcpy(&v->arch.guest_context, c.nat, sizeof(*c.nat));
+
+    /* IOPL privileges are virtualised. */
+    v->arch.iopl = (v->arch.guest_context.user_regs.eflags >> 12) & 3;
+
+    v->arch.guest_context.user_regs.eflags |= 2;
+
+    memset(v->arch.guest_context.debugreg, 0,
+           sizeof(v->arch.guest_context.debugreg));
+    for ( i = 0; i < 8; i++ )
+        (void)set_debugreg(v, i, c(debugreg[i]));
+
+    if ( v->is_initialised )
+        goto out;
+
+    if ( v->vcpu_id == 0 )
+        d->vm_assist = c.nat->vm_assist;
+
+    cr3_pfn = gmfn_to_mfn(d, xen_cr3_to_pfn(c.nat->ctrlreg[3]));
+
+    if ( !mfn_valid(cr3_pfn) ||
+             (paging_mode_refcounts(d)
+              ? !get_page(mfn_to_page(cr3_pfn), d)
+              : !get_page_and_type(mfn_to_page(cr3_pfn), d,
+                                   PGT_base_page_table)) )
+    {
+        destroy_gdt(v);
+        return -EINVAL;
+    }
+
+    v->arch.guest_table = pagetable_from_pfn(cr3_pfn);
+
+    if ( c.nat->ctrlreg[1] )
+    {
+        cr3_pfn = gmfn_to_mfn(d, xen_cr3_to_pfn(c.nat->ctrlreg[1]));
+
+        if ( !mfn_valid(cr3_pfn) ||
+                 (paging_mode_refcounts(d)
+                  ? !get_page(mfn_to_page(cr3_pfn), d)
+                  : !get_page_and_type(mfn_to_page(cr3_pfn), d,
+                                       PGT_base_page_table)) )
+        {
+            cr3_pfn = pagetable_get_pfn(v->arch.guest_table);
+            v->arch.guest_table = pagetable_null();
+            if ( paging_mode_refcounts(d) )
+                put_page(mfn_to_page(cr3_pfn));
+            else
+                put_page_and_type(mfn_to_page(cr3_pfn));
+            destroy_gdt(v);
+            return -EINVAL;
+        }
+        v->arch.guest_table_user = pagetable_from_pfn(cr3_pfn);
+    }
+
+    if ( v->vcpu_id == 0 )
+        update_domain_wallclock_time(d);
+
+    /* Don't redo final setup */
+    v->is_initialised = 1;
+
+    if ( paging_mode_enabled(d) )
+        paging_update_paging_modes(v);
+    update_cr3(v);
+
+    hybrid_update_cr3(v);
+
+ out:
+    if ( flags & VGCF_online )
+        clear_bit(_VPF_down, &v->pause_flags);
+    else
+        set_bit(_VPF_down, &v->pause_flags);
+    return 0;
+#undef c
+}
+
 /* This is called by arch_final_setup_guest and do_boot_vcpu */
 int arch_set_info_guest(
     struct vcpu *v, vcpu_guest_context_u c)
@@ -628,6 +730,9 @@ int arch_set_info_guest(
 #endif
     flags = c(flags);
 
+    if (is_hybrid_vcpu(v))
+        return hybrid_arch_set_info_guest(v, c);
+
     if ( !is_hvm_vcpu(v) )
     {
         if ( !compat )
@@ -1347,7 +1452,7 @@ static void update_runstate_area(struct 
 
 static inline int need_full_gdt(struct vcpu *v)
 {
-    return (!is_hvm_vcpu(v) && !is_idle_vcpu(v));
+    return (!is_hvm_vcpu(v) && !is_idle_vcpu(v) && !is_hybrid_vcpu(v));
 }
 
 static void __context_switch(void)
@@ -2115,7 +2220,7 @@ void vcpu_mark_events_pending(struct vcp
     if ( already_pending )
         return;
 
-    if ( is_hvm_vcpu(v) )
+    if ( is_hvm_vcpu(v) || is_hybrid_vcpu(v))
         hvm_assert_evtchn_irq(v);
     else
         vcpu_kick(v);
xen/arch/x86/hvm/hvm.c +125 -3

184 lines not on this page · raw message

xen/arch/x86/hvm/irq.c +3 -0
diff -r f2cf898c7ff8 xen/arch/x86/hvm/irq.c
@@ -333,6 +333,9 @@ struct hvm_intack hvm_vcpu_has_pending_i
          && vcpu_info(v, evtchn_upcall_pending) )
         return hvm_intack_vector(plat->irq.callback_via.vector);
 
+    if (is_hybrid_vcpu(v))
+        return hvm_intack_none;
+
     if ( unlikely(v->nmi_pending) )
         return hvm_intack_nmi;
 
xen/arch/x86/hvm/vmx/Makefile +1 -0
diff -r f2cf898c7ff8 xen/arch/x86/hvm/vmx/Makefile
@@ -5,3 +5,4 @@ obj-y += vmcs.o
 obj-y += vmx.o
 obj-y += vpmu.o
 obj-y += vpmu_core2.o
+obj-y += hybrid.o
xen/arch/x86/hvm/vmx/intr.c +3 -2
diff -r f2cf898c7ff8 xen/arch/x86/hvm/vmx/intr.c
@@ -125,8 +125,9 @@ asmlinkage void vmx_intr_assist(void)
         return;
     }
 
-    /* Crank the handle on interrupt state. */
-    pt_update_irq(v);
+    if (!is_hybrid_vcpu(v))
+        /* Crank the handle on interrupt state. */
+        pt_update_irq(v);
 
     do {
         intack = hvm_vcpu_has_pending_irq(v);
xen/arch/x86/hvm/vmx/vmcs.c +287 -8

365 lines not on this page · raw message

xen/arch/x86/hvm/vmx/vmx.c +45 -4

106 lines not on this page · raw message

xen/arch/x86/hvm/vpt.c +5 -0
diff -r f2cf898c7ff8 xen/arch/x86/hvm/vpt.c
@@ -289,6 +289,11 @@ void pt_intr_post(struct vcpu *v, struct
     if ( intack.source == hvm_intsrc_vector )
         return;
 
+if (is_hybrid_vcpu(v)) {
+    kdbp("MUK: unexpected intack src:%d vec:%d\n", intack.source,intack.vector);
+    kdb_trap_immed(KDB_TRAP_NONFATAL);
+}
+
     spin_lock(&v->arch.hvm_vcpu.tm_lock);
 
     pt = is_pt_irq(v, intack);
xen/arch/x86/mm.c +27 -2
diff -r f2cf898c7ff8 xen/arch/x86/mm.c
@@ -490,9 +490,12 @@ void make_cr3(struct vcpu *v, unsigned l
 
 #endif /* !defined(__i386__) */
 
+/* calling hybrid_update_cr3 doesnt work because during context switch
+ * vmcs is not completely setup? */
 void write_ptbase(struct vcpu *v)
 {
-    write_cr3(v->arch.cr3);
+    if (!is_hybrid_vcpu(v))
+        write_cr3(v->arch.cr3);
 }
 
 /*
@@ -2482,6 +2485,7 @@ int get_page_type_preemptible(struct pag
 }
 
 
+extern void hybrid_update_cr3(struct vcpu *v);
 int new_guest_cr3(unsigned long mfn)
 {
     struct vcpu *curr = current;
@@ -2530,6 +2534,9 @@ int new_guest_cr3(unsigned long mfn)
 
     write_ptbase(curr);
 
+    if (is_hybrid_vcpu(curr))
+        hybrid_update_cr3(curr);
+
     if ( likely(old_base_mfn != 0) )
     {
         if ( paging_mode_refcounts(d) )
@@ -2863,10 +2870,23 @@ int do_mmuext_op(
 #endif
         
         case MMUEXT_TLB_FLUSH_LOCAL:
+            /* do this for both, flush_tlb_user and flush_tlb_kernel, for now.
+             * To debug: hvm_asid_flush_vcpu for flush_tlb_user, and
+             * vpid_sync_all for flush_tlb_kernel */
+            if (is_hybrid_vcpu(current)) {
+                extern void hybrid_flush_tlb(void);
+                hybrid_flush_tlb();
+                break;
+            }
             flush_tlb_local();
             break;
     
         case MMUEXT_INVLPG_LOCAL:
+            if (is_hybrid_vcpu(current)) {
+                extern void hybrid_do_invlpg(ulong);
+                hybrid_do_invlpg(op.arg1.linear_addr);
+                break;
+            }
             if ( !paging_mode_enabled(d) 
                  || paging_invlpg(curr, op.arg1.linear_addr) != 0 )
                 flush_tlb_one_local(op.arg1.linear_addr);
@@ -2877,6 +2897,11 @@ int do_mmuext_op(
         {
             cpumask_t pmask;
 
+            if (is_hybrid_vcpu(current)) {
+                kdbp("MUK:FIX: MMUEXT_TLB_FLUSH_MULTI/MMUEXT_INVLPG_MULTI\n");
+                kdb_trap_immed(KDB_TRAP_NONFATAL);
+                break;
+            }
             if ( unlikely(vcpumask_to_pcpumask(d, op.arg2.vcpumask, &pmask)) )
             {
                 okay = 0;
@@ -4181,7 +4206,7 @@ long do_update_descriptor(u64 pa, u64 de
     mfn = gmfn_to_mfn(dom, gmfn);
     if ( (((unsigned int)pa % sizeof(struct desc_struct)) != 0) ||
          !mfn_valid(mfn) ||
-         !check_descriptor(dom, &d) )
+         (!is_hybrid_domain(dom) && !check_descriptor(dom, &d)) )
         return -EINVAL;
 
     page = mfn_to_page(mfn);
xen/arch/x86/time.c +7 -5
diff -r f2cf898c7ff8 xen/arch/x86/time.c
@@ -879,7 +879,7 @@ static void __update_vcpu_system_time(st
         _u.tsc_to_system_mul = t->tsc_scale.mul_frac;
         _u.tsc_shift         = (s8)t->tsc_scale.shift;
     }
-    if ( is_hvm_domain(d) )
+    if ( is_hvm_domain(d) || is_hybrid_domain(d))
         _u.tsc_timestamp += v->arch.hvm_vcpu.cache_tsc_offset;
 
     /* Don't bother unless timestamp record has changed or we are forced. */
@@ -947,7 +947,7 @@ static void update_domain_rtc(void)
     rcu_read_lock(&domlist_read_lock);
 
     for_each_domain ( d )
-        if ( is_hvm_domain(d) )
+        if ( is_hvm_domain(d) ||  is_hybrid_domain(d))
             rtc_update_clock(d);
 
     rcu_read_unlock(&domlist_read_lock);
@@ -956,7 +956,7 @@ static void update_domain_rtc(void)
 void domain_set_time_offset(struct domain *d, int32_t time_offset_seconds)
 {
     d->time_offset_seconds = time_offset_seconds;
-    if ( is_hvm_domain(d) )
+    if ( is_hvm_domain(d) ||  is_hybrid_domain(d))
         rtc_update_clock(d);
 }
 
@@ -1708,7 +1708,7 @@ struct tm wallclock_time(void)
 
 u64 gtime_to_gtsc(struct domain *d, u64 tsc)
 {
-    if ( !is_hvm_domain(d) )
+    if ( !is_hvm_domain(d) ||  is_hybrid_domain(d))
         tsc = max_t(s64, tsc - d->arch.vtsc_offset, 0);
     return scale_delta(tsc, &d->arch.ns_to_vtsc);
 }
@@ -1856,6 +1856,8 @@ void tsc_set_info(struct domain *d,
         d->arch.vtsc = 0;
         return;
     }
+    if ( is_hybrid_domain(d) )
+        kdbp("INFO: setting vtsc for hybrid tsc_mode:%d \n", tsc_mode);
 
     switch ( d->arch.tsc_mode = tsc_mode )
     {
@@ -1901,7 +1903,7 @@ void tsc_set_info(struct domain *d,
         break;
     }
     d->arch.incarnation = incarnation + 1;
-    if ( is_hvm_domain(d) )
+    if ( is_hvm_domain(d) || is_hybrid_domain(d) )
         hvm_set_rdtsc_exiting(d, d->arch.vtsc);
 }
 
xen/arch/x86/traps.c +3 -2
diff -r f2cf898c7ff8 xen/arch/x86/traps.c
@@ -1217,13 +1217,14 @@ static int spurious_page_fault(
     return is_spurious;
 }
 
-static int fixup_page_fault(unsigned long addr, struct cpu_user_regs *regs)
+int fixup_page_fault(unsigned long addr, struct cpu_user_regs *regs)
 {
     struct vcpu   *v = current;
     struct domain *d = v->domain;
 
     /* No fixups in interrupt context or when interrupts are disabled. */
-    if ( in_irq() || !(regs->eflags & X86_EFLAGS_IF) )
+    if ( in_irq() ||
+         (!is_hybrid_vcpu(v) && !(regs->eflags & X86_EFLAGS_IF)) )
         return 0;
 
     /* Faults from external-mode guests are handled by shadow/hap */
xen/arch/x86/x86_64/traps.c +1 -1
diff -r f2cf898c7ff8 xen/arch/x86/x86_64/traps.c
@@ -617,7 +617,7 @@ static void hypercall_page_initialise_ri
 void hypercall_page_initialise(struct domain *d, void *hypercall_page)
 {
     memset(hypercall_page, 0xCC, PAGE_SIZE);
-    if ( is_hvm_domain(d) )
+    if ( is_hvm_domain(d) || is_hybrid_domain(d))
         hvm_hypercall_page_initialise(d, hypercall_page);
     else if ( !is_pv_32bit_domain(d) )
         hypercall_page_initialise_ring3_kernel(hypercall_page);
xen/common/domain.c +4 -1
diff -r f2cf898c7ff8 xen/common/domain.c
@@ -208,6 +208,7 @@ static void __init parse_extra_guest_irq
 }
 custom_param("extra_guest_irqs", parse_extra_guest_irqs);
 
+volatile int mukhybrid = 0;
 struct domain *domain_create(
     domid_t domid, unsigned int domcr_flags, ssidref_t ssidref)
 {
@@ -238,7 +239,9 @@ struct domain *domain_create(
     spin_lock_init(&d->shutdown_lock);
     d->shutdown_code = -1;
 
-    if ( domcr_flags & DOMCRF_hvm )
+    if (domid != 0 && mukhybrid)
+        d->is_hybrid = 1;
+    else if ( domcr_flags & DOMCRF_hvm )
         d->is_hvm = 1;
 
     if ( domid == 0 )
xen/common/kernel.c +2 -0
diff -r f2cf898c7ff8 xen/common/kernel.c
@@ -246,6 +246,8 @@ DO(xen_version)(int cmd, XEN_GUEST_HANDL
             else
                 fi.submap |= (1U << XENFEAT_hvm_safe_pvclock) |
                              (1U << XENFEAT_hvm_callback_vector);
+            if ( is_hybrid_vcpu(current) )
+                fi.submap |= (1U << XENFEAT_hvm_callback_vector);
 #endif
             break;
         default:
xen/common/timer.c +10 -3
diff -r f2cf898c7ff8 xen/common/timer.c
@@ -546,13 +546,20 @@ void kdb_dump_timer_queues(void)
     struct timers *ts;
     unsigned long sz, offs;
     char buf[KSYM_NAME_LEN+1];
-    int            cpu, j;
-    s_time_t       now = NOW();
+    int cpu, j;
+    u64 tsc;
 
     for_each_online_cpu( cpu )
     {
         ts = &per_cpu(timers, cpu);
-        kdbp("CPU[%02d]: NOW:0x%08x%08x\n", cpu, (u32)(now>>32), (u32)now);
+        kdbp("CPU[%02d]:", cpu);
+
+        if (cpu == smp_processor_id()) {
+            s_time_t now = NOW();
+            rdtscll(tsc);
+            kdbp("NOW:0x%08x%08x TSC:0x%016lx\n", (u32)(now>>32),(u32)now, tsc);
+        } else
+            kdbp("\n");
 
         /* timers in the heap */
         for ( j = 1; j <= GET_HEAP_SIZE(ts->heap); j++ ) {
xen/include/asm-x86/desc.h +6 -1
diff -r f2cf898c7ff8 xen/include/asm-x86/desc.h
@@ -58,7 +58,8 @@
 #ifndef __ASSEMBLY__
 
 #if defined(__x86_64__)
-#define GUEST_KERNEL_RPL(d) (is_pv_32bit_domain(d) ? 1 : 3)
+#define GUEST_KERNEL_RPL(d) (is_hybrid_domain(d) ? 0 : \
+              is_pv_32bit_domain(d) ? 1 : 3)
 #elif defined(__i386__)
 #define GUEST_KERNEL_RPL(d) ((void)(d), 1)
 #endif
@@ -67,6 +68,10 @@
 #define __fixup_guest_selector(d, sel)                             \
 ({                                                                 \
     uint16_t _rpl = GUEST_KERNEL_RPL(d);                           \
+    if (is_hybrid_domain(d)) {                                      \
+        printk("MUK: hybrid domain fixing up selector\n");          \
+        kdb_trap_immed(KDB_TRAP_NONFATAL);                         \
+    }                                                              \
     (sel) = (((sel) & 3) >= _rpl) ? (sel) : (((sel) & ~3) | _rpl); \
 })
 
xen/include/asm-x86/domain.h +1 -1
diff -r f2cf898c7ff8 xen/include/asm-x86/domain.h
@@ -18,7 +18,7 @@
 #endif
 #define is_pv_32on64_vcpu(v)   (is_pv_32on64_domain((v)->domain))
 
-#define is_hvm_pv_evtchn_domain(d) (is_hvm_domain(d) && \
+#define is_hvm_pv_evtchn_domain(d) ((is_hvm_domain(d) || is_hybrid_domain(d))&&\
         d->arch.hvm_domain.irq.callback_via_type == HVMIRQ_callback_vector)
 #define is_hvm_pv_evtchn_vcpu(v) (is_hvm_pv_evtchn_domain(v->domain))
 
xen/include/asm-x86/event.h +1 -1
diff -r f2cf898c7ff8 xen/include/asm-x86/event.h
@@ -18,7 +18,7 @@ int hvm_local_events_need_delivery(struc
 static inline int local_events_need_delivery(void)
 {
     struct vcpu *v = current;
-    return (is_hvm_vcpu(v) ? hvm_local_events_need_delivery(v) :
+    return ( (is_hvm_vcpu(v)||is_hybrid_vcpu(v)) ? hvm_local_events_need_delivery(v) :
             (vcpu_info(v, evtchn_upcall_pending) &&
              !vcpu_info(v, evtchn_upcall_mask)));
 }
xen/include/asm-x86/hvm/hvm.h +2 -0
diff -r f2cf898c7ff8 xen/include/asm-x86/hvm/hvm.h
@@ -144,10 +144,12 @@ struct hvm_function_table {
 extern struct hvm_function_table hvm_funcs;
 extern int hvm_enabled;
 
+int hybrid_domain_initialise(struct domain *d);
 int hvm_domain_initialise(struct domain *d);
 void hvm_domain_relinquish_resources(struct domain *d);
 void hvm_domain_destroy(struct domain *d);
 
+int hybrid_vcpu_initialise(struct vcpu *v);
 int hvm_vcpu_initialise(struct vcpu *v);
 void hvm_vcpu_destroy(struct vcpu *v);
 void hvm_vcpu_down(struct vcpu *v);
xen/include/asm-x86/hvm/vmx/vmx.h +1 -0
diff -r f2cf898c7ff8 xen/include/asm-x86/hvm/vmx/vmx.h
@@ -110,6 +110,7 @@ void vmx_update_debug_state(struct vcpu 
 #define EXIT_REASON_EPT_VIOLATION       48
 #define EXIT_REASON_EPT_MISCONFIG       49
 #define EXIT_REASON_RDTSCP              51
+#define EXIT_REASON_INVVPID             53
 #define EXIT_REASON_WBINVD              54
 #define EXIT_REASON_XSETBV              55
 
xen/include/xen/sched.h +3 -0
diff -r f2cf898c7ff8 xen/include/xen/sched.h
@@ -228,6 +228,7 @@ struct domain
 
     /* Is this an HVM guest? */
     bool_t           is_hvm;
+    bool_t           is_hybrid;
     /* Does this guest need iommu mappings? */
     bool_t           need_iommu;
     /* Is this guest fully privileged (aka dom0)? */
@@ -590,6 +591,8 @@ uint64_t get_cpu_idle_time(unsigned int 
 
 #define is_hvm_domain(d) ((d)->is_hvm)
 #define is_hvm_vcpu(v)   (is_hvm_domain(v->domain))
+#define is_hybrid_domain(d) ((d)->is_hybrid)
+#define is_hybrid_vcpu(v)   (is_hybrid_domain(v->domain))
 #define is_pinned_vcpu(v) ((v)->domain->is_pinned || \
                            cpus_weight((v)->cpu_affinity) == 1)
 #define need_iommu(d)    ((d)->need_iommu)
xen/kdb/kdb_cmds.c +3 -3
diff -r f2cf898c7ff8 xen/kdb/kdb_cmds.c
@@ -977,7 +977,7 @@ kdb_cmdf_ss(int argc, const char **argv,
         kdbp("kdb: Failed to read byte at: %lx\n", regs->KDBIP);
         return KDB_CPU_MAIN_KDB;
     }
-    if (guest_mode(regs) && is_hvm_vcpu(current))
+    if (guest_mode(regs) && (is_hybrid_vcpu(current) || is_hvm_vcpu(current)))
         current->arch.hvm_vcpu.single_step = 1;
     else
         regs->eflags |= X86_EFLAGS_TF;
@@ -2240,8 +2240,8 @@ kdb_display_dom(struct domain *dp)
         kdbp("    mapcnt:");
         kdb_print_spin_lock("mapcnt: lk:", &gp->lock, "\n");
     }
-    kdbp("  hvm:%d priv:%d dbg:%d dying:%d paused:%d\n",
-         dp->is_hvm, dp->is_privileged, dp->debugger_attached,
+    kdbp("  hvm:%d hybrid:%d priv:%d dbg:%d dying:%d paused:%d\n",
+         dp->is_hvm, dp->is_hybrid, dp->is_privileged, dp->debugger_attached,
          dp->is_dying, dp->is_paused_by_controller);
     kdb_print_spin_lock("  shutdown: lk:", &dp->shutdown_lock, "\n");
     kdbp("  shutn:%d shut:%d code:%d \n", dp->is_shutting_down,
arch/x86/Kconfig.debug +1 -1
index 615e188..7791d31 100644
@@ -1,7 +1,7 @@
 menu "Kernel hacking"
 
 config TRACE_IRQFLAGS_SUPPORT
-	def_bool y
+	def_bool n
 
 source "lib/Kconfig.debug"
 
arch/x86/include/asm/cpufeature.h +1 -1
index 91f3e08..b69a989 100644
@@ -271,7 +271,7 @@ extern const char * const x86_power_flags[32];
 #define cpu_has_pebs		boot_cpu_has(X86_FEATURE_PEBS)
 #define cpu_has_clflush		boot_cpu_has(X86_FEATURE_CLFLSH)
 #define cpu_has_bts		boot_cpu_has(X86_FEATURE_BTS)
-#define cpu_has_gbpages		boot_cpu_has(X86_FEATURE_GBPAGES)
+#define cpu_has_gbpages		0
 #define cpu_has_arch_perfmon	boot_cpu_has(X86_FEATURE_ARCH_PERFMON)
 #define cpu_has_pat		boot_cpu_has(X86_FEATURE_PAT)
 #define cpu_has_xmm4_1		boot_cpu_has(X86_FEATURE_XMM4_1)
arch/x86/include/asm/hypervisor.h +1 -0
index 7a15153..f0bbb51 100644
@@ -49,6 +49,7 @@ extern const struct hypervisor_x86 *x86_hyper;
 extern const struct hypervisor_x86 x86_hyper_vmware;
 extern const struct hypervisor_x86 x86_hyper_ms_hyperv;
 extern const struct hypervisor_x86 x86_hyper_xen_hvm;
+extern const struct hypervisor_x86 x86_hyper_xen_hybrid;
 
 static inline bool hypervisor_x2apic_available(void)
 {
arch/x86/kernel/cpu/hypervisor.c +1 -0
index 8095f86..5ec8dbb 100644
@@ -37,6 +37,7 @@ static const __initconst struct hypervisor_x86 * const hypervisors[] =
 #ifdef CONFIG_XEN_PVHVM
 	&x86_hyper_xen_hvm,
 #endif
+        &x86_hyper_xen_hybrid,
 };
 
 const struct hypervisor_x86 *x86_hyper;
arch/x86/mm/init_64.c +4 -1
index 7942335..414cbb8 100644
@@ -202,7 +202,10 @@ void set_pte_vaddr_pud(pud_t *pud_page, unsigned long vaddr, pte_t new_pte)
 	pmd = fill_pmd(pud, vaddr);
 	pte = fill_pte(pmd, vaddr);
 
-	set_pte(pte, new_pte);
+        if (xen_domain_type == XEN_PV_IN_HVM) {
+                set_pte_at(&init_mm, vaddr, pte, new_pte);
+        } else
+                set_pte(pte, new_pte);
 
 	/*
 	 * It's enough to flush this one mapping.
arch/x86/mm/ioremap.c +5 -1
index 0369843..5810ef4 100644
@@ -425,7 +425,11 @@ static void __init __early_set_fixmap(enum fixed_addresses idx,
 	pte = early_ioremap_pte(addr);
 
 	if (pgprot_val(flags))
-		set_pte(pte, pfn_pte(phys >> PAGE_SHIFT, flags));
+                set_pte(pte, pfn_pte(phys >> PAGE_SHIFT, flags));
+#if 0
+                set_pte_at(&init_mm, addr, pte, pfn_pte(phys >> PAGE_SHIFT, 
+                           flags));
+#endif
 	else
 		pte_clear(&init_mm, addr, pte);
 	__flush_tlb_one(addr);
arch/x86/pci/direct.c +3 -0
index bd33620..eb6d4d7 100644
@@ -282,6 +282,9 @@ int __init pci_direct_probe(void)
 {
 	struct resource *region, *region2;
 
+        if (xen_domain_type == XEN_PV_IN_HVM)
+                return 0;
+
 	if ((pci_probe & PCI_PROBE_CONF1) == 0)
 		goto type2;
 	region = request_region(0xCF8, 8, "PCI conf1");
arch/x86/xen/enlighten.c +64 -25

178 lines not on this page · raw message

arch/x86/xen/irq.c +10 -1
index 6a6fe89..fb4777c 100644
@@ -100,6 +100,9 @@ PV_CALLEE_SAVE_REGS_THUNK(xen_irq_enable);
 
 static void xen_safe_halt(void)
 {
+        if (xen_domain_type == XEN_PV_IN_HVM)
+                local_irq_enable();
+
 	/* Blocking includes an implicit local_irq_enable(). */
 	if (HYPERVISOR_sched_op(SCHEDOP_block, NULL) != 0)
 		BUG();
@@ -114,15 +117,21 @@ static void xen_halt(void)
 }
 
 static const struct pv_irq_ops xen_irq_ops __initdata = {
+#if 0
 	.save_fl = PV_CALLEE_SAVE(xen_save_fl),
 	.restore_fl = PV_CALLEE_SAVE(xen_restore_fl),
 	.irq_disable = PV_CALLEE_SAVE(xen_irq_disable),
 	.irq_enable = PV_CALLEE_SAVE(xen_irq_enable),
+#endif
+        .save_fl = __PV_IS_CALLEE_SAVE(native_save_fl),
+        .restore_fl = __PV_IS_CALLEE_SAVE(native_restore_fl),
+        .irq_disable = __PV_IS_CALLEE_SAVE(native_irq_disable),
+        .irq_enable = __PV_IS_CALLEE_SAVE(native_irq_enable),
 
 	.safe_halt = xen_safe_halt,
 	.halt = xen_halt,
 #ifdef CONFIG_X86_64
-	.adjust_exception_frame = xen_adjust_exception_frame,
+	.adjust_exception_frame = paravirt_nop,
 #endif
 };
 
arch/x86/xen/mmu.c +2 -2
index f298bd7..978d4be 100644
@@ -2047,8 +2047,8 @@ static void xen_leave_lazy_mmu(void)
 }
 
 static const struct pv_mmu_ops xen_mmu_ops __initdata = {
-	.read_cr2 = xen_read_cr2,
-	.write_cr2 = xen_write_cr2,
+	.read_cr2 = native_read_cr2,
+	.write_cr2 = native_write_cr2,
 
 	.read_cr3 = xen_read_cr3,
 #ifdef CONFIG_X86_32
arch/x86/xen/setup.c +3 -2
index adaf127..3a4d9c3 100644
@@ -394,9 +394,9 @@ void __cpuinit xen_enable_syscall(void)
 void __init xen_arch_setup(void)
 {
 	xen_panic_handler_init();
-
-	HYPERVISOR_vm_assist(VMASST_CMD_enable, VMASST_TYPE_4gb_segments);
 	HYPERVISOR_vm_assist(VMASST_CMD_enable, VMASST_TYPE_writable_pagetables);
+#if 0
+	HYPERVISOR_vm_assist(VMASST_CMD_enable, VMASST_TYPE_4gb_segments);
 
 	if (!xen_feature(XENFEAT_auto_translated_physmap))
 		HYPERVISOR_vm_assist(VMASST_CMD_enable,
@@ -415,6 +415,7 @@ void __init xen_arch_setup(void)
 		disable_acpi();
 	}
 #endif
+#endif
 
 	memcpy(boot_command_line, xen_start_info->cmd_line,
 	       MAX_GUEST_CMDLINE > COMMAND_LINE_SIZE ?
arch/x86/xen/xen-head.S +1 -0
index aaa7291..9d0e0e3 100644
@@ -16,6 +16,7 @@
 	__INIT
 ENTRY(startup_xen)
 	cld
+        sti
 #ifdef CONFIG_X86_32
 	mov %esi,xen_start_info
 	mov $init_thread_union+THREAD_SIZE,%esp
config.sav +6 -42

138 lines not on this page · raw message

drivers/tty/serial/8250.c +2 -0
index 6611535..1f52fd1 100644
@@ -3294,6 +3294,8 @@ static int __init serial8250_init(void)
 {
 	int ret;
 
+return -ENODEV;
+
 	if (nr_uarts > UART_NR)
 		nr_uarts = UART_NR;
 
drivers/xen/events.c +4 -1
index 33167b4..9133641 100644
@@ -1579,7 +1579,8 @@ int xen_set_callback_via(uint64_t via)
 }
 EXPORT_SYMBOL_GPL(xen_set_callback_via);
 
-#ifdef CONFIG_XEN_PVHVM
+#ifdef CONFIG_XEN_PVHVM 
+/* #if 1 */
 /* Vector callbacks are better than PCI interrupts to receive event
  * channel notifications because we can receive vector callbacks on any
  * vcpu and we don't need PCI support or APIC interactions. */
@@ -1632,5 +1633,7 @@ void __init xen_init_IRQ(void)
 		irq_ctx_init(smp_processor_id());
 		if (xen_initial_domain())
 			xen_setup_pirqs();
+                if (xen_domain_type == XEN_PV_IN_HVM)
+		        xen_callback_vector();
 	}
 }
include/xen/xen.h +3 -1
index a164024..96ad928 100644
@@ -4,6 +4,7 @@
 enum xen_domain_type {
 	XEN_NATIVE,		/* running on bare hardware    */
 	XEN_PV_DOMAIN,		/* running in a PV domain      */
+        XEN_PV_IN_HVM,          /* running PV in HVM container */
 	XEN_HVM_DOMAIN,		/* running in a Xen hvm domain */
 };
 
@@ -15,7 +16,8 @@ extern enum xen_domain_type xen_domain_type;
 
 #define xen_domain()		(xen_domain_type != XEN_NATIVE)
 #define xen_pv_domain()		(xen_domain() &&			\
-				 xen_domain_type == XEN_PV_DOMAIN)
+				 (xen_domain_type == XEN_PV_DOMAIN ||   \
+                                 xen_domain_type == XEN_PV_IN_HVM))
 #define xen_hvm_domain()	(xen_domain() &&			\
 				 xen_domain_type == XEN_HVM_DOMAIN)
 

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

#17 lore raw
Quoted 8 lines · Mukesh Rathor

Hi folks,

Well, I did some benchmarking and found interesting results. Following runs are on a westmere with 2 sockets and 10GB RAM. Xen was booted with maxcpus=2 and entire RAM. All guests were started with 1vcpu and 2GB RAM. dom0 started with 1 vcpu and 704MB. Baremetal was booted with 2GB and 1 cpu. HVM guest has EPT enabled. HT is on.

Quoted 5 lines

So, unless the NUMA'ness interfered with results (using some memory on remote socket), it appears HVM does very well. To the point that it seems a hybrid is not going to be worth it. I am currently running tests on a single socket system just to be sure.

The high level benchmarks I run to compare PV and PV on HVM guests show a very similar scenario.

It is still worth having HYBRID guests (running with EPT?) in order to support dom0 in an HVM container one day not too far from now.

#26 lore raw
In reply to Mukesh Rathor
Quoted 7 lines · Mukesh Rathor

Hi folks,

Well, I did some benchmarking and found interesting results. Following runs are on a westmere with 2 sockets and 10GB RAM. Xen was booted with maxcpus=2 and entire RAM. All guests were started with 1vcpu and 2GB RAM. dom0 started with 1 vcpu and 704MB. Baremetal was booted with 2GB and 1 cpu. HVM guest has EPT enabled. HT is on.

Is this PVonHVM? Or is it real HVM without _any_ PV enablement? Ah, the .config tells me it is PVonHVM - so IRQ callbacks, and timers are PV actually.

Quoted 5 lines

So, unless the NUMA'ness interfered with results (using some memory on remote socket), it appears HVM does very well. To the point that it seems a hybrid is not going to be worth it. I am currently running tests on a single socket system just to be sure.

The xm has some NUMA capability while xl does not. Did you use xm or xl to run this?

Quoted 3 lines

I am attaching my diff's in case any one wants to see what I did. I used xen 4.0.2 and linux 2.6.39.

Wow. That is surprisingly a compact set of changes to the Linux kernel. Good job.

Quoted 6 lines

thanks,
Mukesh

L M B E N C H 3 . 0 S U M M A R Y

Quoted 7 lines

Processor, Processes - times in microseconds - smaller is better
------------------------------------------------------------------------------
Host OS Mhz null null open slct sig sig fork exec sh
call I/O stat clos TCP inst hndl proc proc proc
--------- ------------- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
PV Linux 2.6.39f 2639 0.65 0.88 2.14 4.59 3.77 0.79 3.62 535. 1294 3308
Hybrid Linux 2.6.39f 2639 0.13 0.21 0.89 1.96 3.08 0.24 1.10 529. 1294 3246

Hm, so it follows baremetal until fork/exec/sh. At which it is as bad as PV.

Quoted 1 line

HVM Linux 2.6.39f 2639 0.12 0.21 0.64 1.76 3.04 0.24 3.37 113. 354. 1324

<blinks> So HVM is better than baremetal?

Quoted 32 lines

Baremetal Linux 2.6.39+ 2649 0.13 0.23 0.74 1.93 3.46 0.28 1.58 127. 386. 1434

Basic integer operations - times in nanoseconds - smaller is better
-------------------------------------------------------------------
Host OS intgr intgr intgr intgr intgr
bit add mul div mod
--------- ------------- ------ ------ ------ ------ ------

PV        Linux 2.6.39f 0.3800 0.0100 0.1700 9.1000 9.0400
Hybrid    Linux 2.6.39f 0.3800 0.0100 0.1700 9.1100 9.0300
HVM       Linux 2.6.39f 0.3800 0.0100 0.1700 9.1100 9.0600

Baremetal Linux 2.6.39+ 0.3800 0.0100 0.1700 9.0600 8.9800

Basic float operations - times in nanoseconds - smaller is better
-----------------------------------------------------------------

Host                 OS  float  float  float  float
                         add    mul    div    bogo
--------- ------------- ------ ------ ------ ------
PV        Linux 2.6.39f 1.1300 1.5200 5.6200 5.2900
Hybrid    Linux 2.6.39f 1.1300 1.5200 5.6300 5.2900
HVM       Linux 2.6.39f 1.1400 1.5200 5.6300 5.3000

Baremetal Linux 2.6.39+ 1.1300 1.5100 5.6000 5.2700

Basic double operations - times in nanoseconds - smaller is better
------------------------------------------------------------------
Host OS double double double double
add mul div bogo
--------- ------------- ------ ------ ------ ------

PV        Linux 2.6.39f 1.1300 1.9000 8.6400 8.3200
Hybrid    Linux 2.6.39f 1.1400 1.9000 8.6600 8.3200
HVM       Linux 2.6.39f 1.1400 1.9000 8.6600 8.3300

Baremetal Linux 2.6.39+ 1.1300 1.8900 8.6100 8.2800

Quoted 7 lines

Context switching - times in microseconds - smaller is better
-------------------------------------------------------------------------
Host OS 2p/0K 2p/16K 2p/64K 8p/16K 8p/64K 16p/16K 16p/64K
ctxsw ctxsw ctxsw ctxsw ctxsw ctxsw ctxsw
--------- ------------- ------ ------ ------ ------ ------ ------- -------
PV Linux 2.6.39f 5.2800 5.7600 6.3600 6.3200 7.3600 6.69000 7.46000
Hybrid Linux 2.6.39f 4.9200 4.9300 5.2200 5.7600 6.9600 6.12000 7.31000

So the diff between PV an Hybrid looks to be 8%..

And then ~50% difference between Hybrid and baremetal. So syscall is only causing 8% drop in performance - what is the other 42%?

Quoted 1 line

HVM Linux 2.6.39f 1.3100 1.2200 1.6200 1.9200 3.2600 2.23000 3.48000

This is really bizzare. HVM kicks baremetal butt?

Quoted 12 lines

Baremetal Linux 2.6.39+ 1.5500 1.4100 2.0600 2.2500 3.3900 2.44000 3.38000

*Local* Communication latencies in microseconds - smaller is better
---------------------------------------------------------------------
Host OS 2p/0K Pipe AF UDP RPC/ TCP RPC/ TCP
ctxsw UNIX UDP TCP conn
--------- ------------- ----- ----- ---- ----- ----- ----- ----- ----

PV        Linux 2.6.39f 5.280  16.6 21.3  25.9  33.7  34.7  41.8  87.
Hybrid    Linux 2.6.39f 4.920  11.2 14.4  19.6  26.1  27.5  32.9  71.
HVM       Linux 2.6.39f 1.310 4.416 6.15 9.386  14.8  15.8  20.1  45.
Baremetal Linux 2.6.39+ 1.550 4.625 7.34  14.3  19.8  21.4  26.4  66.
Quoted 7 lines

File & VM system latencies in microseconds - smaller is better
-------------------------------------------------------------------------------

Host                 OS   0K File      10K File     Mmap    Prot   Page   100fd
                        Create Delete Create Delete Latency Fault  Fault  selct
--------- ------------- ------ ------ ------ ------ ------- ----- ------- -----
PV        Linux 2.6.39f                               24.0K 0.746 3.55870 2.184
Hybrid    Linux 2.6.39f                               24.6K 0.238 4.00100 1.480

Could the mmap and the pagetable creations be the fault (ha! a pun!) of sucky performance? Perhaps running with autotranslate pagetables would eliminate this?

Is the mmap doing small little 4K runs or something much bigger?

Quoted 16 lines

HVM Linux 2.6.39f 4716.0 0.202 0.96600 1.468
Baremetal Linux 2.6.39+ 6898.0 0.325 0.93610 1.620

*Local* Communication bandwidths in MB/s - bigger is better
-----------------------------------------------------------------------------
Host OS Pipe AF TCP File Mmap Bcopy Bcopy Mem Mem
UNIX reread reread (libc) (hand) read write
--------- ------------- ---- ---- ---- ------ ------ ------ ------ ---- -----

PV        Linux 2.6.39f 1661 2081 1041 3293.3 5528.3 3106.6 2800.0 4472 5633.
Hybrid    Linux 2.6.39f 1974 2450 1183 3481.5 5529.6 3114.9 2786.6 4470 5672.
HVM       Linux 2.6.39f 3232 2929 1622 3541.3 5527.5 3077.1 2765.6 4453 5634.

Baremetal Linux 2.6.39+ 3320 2800 1666 3523.6 5578.9 3147.0 2841.6 4541 5752.

Memory latencies in nanoseconds - smaller is better
(WARNING - may not be correct, check graphs)
------------------------------------------------------------------------------

Quoted 6 lines
Host                 OS   Mhz   L1 $   L2 $    Main mem    Rand mem    Guesses
--------- -------------   ---   ----   ----    --------    --------    -------
PV        Linux 2.6.39f  2639 1.5160 5.9170   29.7        97.5
Hybrid    Linux 2.6.39f  2639 1.5170 7.5000   29.7        97.4
HVM       Linux 2.6.39f  2639 1.5190 4.0210   29.8       105.4
Baremetal Linux 2.6.39+  2649 1.5090 3.8370   29.2        78.0

OK, so once you have access to the memory, using it under PV is actually OK.

#18 lore raw
In reply to Stefano Stabellini
Quoted 15 lines · Stefano Stabellini
Quoted 8 lines · Mukesh Rathor

Hi folks,

Well, I did some benchmarking and found interesting results. Following runs are on a westmere with 2 sockets and 10GB RAM. Xen was booted with maxcpus=2 and entire RAM. All guests were started with 1vcpu and 2GB RAM. dom0 started with 1 vcpu and 704MB. Baremetal was booted with 2GB and 1 cpu. HVM guest has EPT enabled. HT is on.

Quoted 5 lines

So, unless the NUMA'ness interfered with results (using some memory on remote socket), it appears HVM does very well. To the point that it seems a hybrid is not going to be worth it. I am currently running tests on a single socket system just to be sure.

Quoted 5 lines

The high level benchmarks I run to compare PV and PV on HVM guests show a very similar scenario.

It is still worth having HYBRID guests (running with EPT?) in order to support dom0 in an HVM container one day not too far from now.

I am just wondering how much dom0 cares about this? I mean if you use blkback, netback - etc - they are all in the kernel. The device drivers are also in the kernel.

Based on Mukeshs's results the PVonHVM work you did really paid itself off for guests. The numbers are even better than baremetal .. which I am bit surprised - maybe the collecting of the data (gettimeofday) is not the best?

#19 lore raw
Quoted 19 lines · Konrad Rzeszutek Wilk
Quoted 18 lines · Stefano Stabellini
Quoted 8 lines · Mukesh Rathor

Hi folks,

Well, I did some benchmarking and found interesting results. Following runs are on a westmere with 2 sockets and 10GB RAM. Xen was booted with maxcpus=2 and entire RAM. All guests were started with 1vcpu and 2GB RAM. dom0 started with 1 vcpu and 704MB. Baremetal was booted with 2GB and 1 cpu. HVM guest has EPT enabled. HT is on.

Quoted 5 lines

So, unless the NUMA'ness interfered with results (using some memory on remote socket), it appears HVM does very well. To the point that it seems a hybrid is not going to be worth it. I am currently running tests on a single socket system just to be sure.

The high level benchmarks I run to compare PV and PV on HVM guests show a very similar scenario.

Quoted 6 lines
Quoted 2 lines

It is still worth having HYBRID guests (running with EPT?) in order to support dom0 in an HVM container one day not too far from now.

I am just wondering how much dom0 cares about this? I mean if you use blkback, netback - etc - they are all in the kernel. The device drivers are also in the kernel.

There are always going to be some userspace processes, even with stubdoms.
Besides if we have HVM dom0, we can enable XENFEAT_auto_translated_physmap and EPT and have the same level of performances of a PV on HVM guest. Moreover since we wouldn't be using the mmu pvops anymore we could drop them completely: that would greatly simplify the Xen maintenance in the Linux kernel as well as gain back some love from the x86 maintainers :)

The way I see it, normal Linux guests would be PV on HVM guests, but we still need to do something about dom0.
This work would make dom0 exactly like PV on HVM guests apart from the boot sequence: dom0 would still boot from xen_start_kernel, everything else would be pretty much the same.

I would ask you to run some benchmarks using XENFEAT_auto_translated_physmap but I am afraid it bitrotted over the years so it would need some work to get it working.

#20 lore raw
Quoted 6 lines
Quoted 3 lines

I am just wondering how much dom0 cares about this? I mean if you use blkback, netback - etc - they are all in the kernel. The device drivers are also in the kernel.

There are always going to be some userspace processes, even with stubdoms.

Stubdomains? Linux HVM's have now PVonHVM - and for Windows there are multitude of PV drivers available? But sure there are some processes - like snort or other packet filtering userland software.

Quoted 4 lines

Besides if we have HVM dom0, we can enable XENFEAT_auto_translated_physmap and EPT and have the same level of performances of a PV on HVM guest. Moreover since we wouldn't be using the mmu pvops anymore we could drop them completely: that would greatly

Sure. It also means you MUST have an IOMMU in the box.

Quoted 8 lines

simplify the Xen maintenance in the Linux kernel as well as gain back some love from the x86 maintainers :)

The way I see it, normal Linux guests would be PV on HVM guests, but we still need to do something about dom0.
This work would make dom0 exactly like PV on HVM guests apart from the boot sequence: dom0 would still boot from xen_start_kernel, everything else would be pretty much the same.

Ah, so not HVM exactly (you would only use the EPT/NPT/RV1/HAP for pagetables).. and PV for startup, spinlock, timers, debug, CPU, and backends. Thought sticking in the HVM container in PV that Mukesh made work would also benefit.

Or just come back to the idea of "real" HVM device driver domains and have the PV dom0 be a light one loading the rest. But the setup of it is just so complex.. And the PV dom0 needs to deal with the PCI backend xenstore, and able to comprehend ACPI _PRT... and then launch the "device driver" Dom0, which at its simplest form would have all of the devices passed in to it.

So four payloads: PV dom0, PV dom0 initrd, HVM dom0, HVM dom0 initrd :-) Ok, that is too cumbersome. Maybe ingest the PV dom0+initrd in the Xen hypervisor binary.. I should stop here.

#21 lore raw
Quoted 6 lines · Konrad Rzeszutek Wilk
Quoted 4 lines

Besides if we have HVM dom0, we can enable XENFEAT_auto_translated_physmap and EPT and have the same level of performances of a PV on HVM guest. Moreover since we wouldn't be using the mmu pvops anymore we could drop them completely: that would greatly

Sure. It also means you MUST have an IOMMU in the box.

Why?
We can still remap interrupts into event channels. Maybe you mean VMX?

Quoted 9 lines
Quoted 8 lines

simplify the Xen maintenance in the Linux kernel as well as gain back some love from the x86 maintainers :)

The way I see it, normal Linux guests would be PV on HVM guests, but we still need to do something about dom0.
This work would make dom0 exactly like PV on HVM guests apart from the boot sequence: dom0 would still boot from xen_start_kernel, everything else would be pretty much the same.

Quoted 4 lines

Ah, so not HVM exactly (you would only use the EPT/NPT/RV1/HAP for pagetables).. and PV for startup, spinlock, timers, debug, CPU, and backends. Thought sticking in the HVM container in PV that Mukesh made work would also benefit.

Yes for startup, spinlock, timers and backends. I would use HVM for cpu operations too (no need for pv_cpu_ops.write_gdt_entry anymore for example).

Quoted 10 lines

Or just come back to the idea of "real" HVM device driver domains and have the PV dom0 be a light one loading the rest. But the setup of it is just so complex.. And the PV dom0 needs to deal with the PCI backend xenstore, and able to comprehend ACPI _PRT... and then launch the "device driver" Dom0, which at its simplest form would have all of the devices passed in to it.

So four payloads: PV dom0, PV dom0 initrd, HVM dom0, HVM dom0 initrd :-) Ok, that is too cumbersome. Maybe ingest the PV dom0+initrd in the Xen hypervisor binary.. I should stop here.

The goal of splitting up dom0 into multiple management domain is surely a worthy goal, no matter is the domains are PV or HVM or PV on HVM, but yeah the setup is hard. I hope that the we'll be able to simplify it in the near future, maybe after the switchover to the new qemu and seabios is completed.

#22 lore raw
Quoted 9 lines · Stefano Stabellini
Quoted 6 lines · Konrad Rzeszutek Wilk
Quoted 4 lines

Besides if we have HVM dom0, we can enable XENFEAT_auto_translated_physmap and EPT and have the same level of performances of a PV on HVM guest. Moreover since we wouldn't be using the mmu pvops anymore we could drop them completely: that would greatly

Sure. It also means you MUST have an IOMMU in the box.

Why?

For HVM dom0s.. But I think when you say HVM here, you mean using
PV with the hypervisor's code that is used for managing page-tables - EPT/NPT/HAP.

So PV+HAP = Stefano's HVM :-)

Quoted 13 lines

We can still remap interrupts into event channels. Maybe you mean VMX?

Quoted 9 lines
Quoted 8 lines

simplify the Xen maintenance in the Linux kernel as well as gain back some love from the x86 maintainers :)

The way I see it, normal Linux guests would be PV on HVM guests, but we still need to do something about dom0.
This work would make dom0 exactly like PV on HVM guests apart from the boot sequence: dom0 would still boot from xen_start_kernel, everything else would be pretty much the same.

Quoted 8 lines
Quoted 4 lines

Ah, so not HVM exactly (you would only use the EPT/NPT/RV1/HAP for pagetables).. and PV for startup, spinlock, timers, debug, CPU, and backends. Thought sticking in the HVM container in PV that Mukesh made work would also benefit.

Yes for startup, spinlock, timers and backends. I would use HVM for cpu operations too (no need for pv_cpu_ops.write_gdt_entry anymore for example).

OK, so a SVM/VMX setup is required.

Quoted 18 lines
Quoted 9 lines

Or just come back to the idea of "real" HVM device driver domains and have the PV dom0 be a light one loading the rest. But the setup of it is just so complex.. And the PV dom0 needs to deal with the PCI backend xenstore, and able to comprehend ACPI _PRT... and then launch the "device driver" Dom0, which at its simplest form would have all of the devices passed in to it.

Quoted 3 lines

So four payloads: PV dom0, PV dom0 initrd, HVM dom0, HVM dom0 initrd :-) Ok, that is too cumbersome. Maybe ingest the PV dom0+initrd in the Xen hypervisor binary.. I should stop here.

The goal of splitting up dom0 into multiple management domain is surely a worthy goal, no matter is the domains are PV or HVM or PV on HVM, but yeah the setup is hard. I hope that the we'll be able to simplify it in the near future, maybe after the switchover to the new qemu and seabios is completed.

#23 lore raw
Quoted 7 lines · Konrad Rzeszutek Wilk
Quoted 6 lines · Stefano Stabellini
Quoted 5 lines · Konrad Rzeszutek Wilk
Quoted 4 lines

Besides if we have HVM dom0, we can enable XENFEAT_auto_translated_physmap and EPT and have the same level of performances of a PV on HVM guest. Moreover since we wouldn't be using the mmu pvops anymore we could drop them completely: that would greatly

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

Sure. It also means you MUST have an IOMMU in the box.

Why?

For HVM dom0s.. But I think when you say HVM here, you mean using
PV with the hypervisor's code that is used for managing page-tables - EPT/NPT/HAP.

So PV+HAP = Stefano's HVM :-)

:-)

Quoted 5 lines
Quoted 3 lines

Yes for startup, spinlock, timers and backends. I would use HVM for cpu operations too (no need for pv_cpu_ops.write_gdt_entry anymore for example).

OK, so a SVM/VMX setup is required.

Yes, I would actually require SVM/VMX for performances and to simplify the setup and maintenance of the code in general.

#24 lore raw
In reply to Stefano Stabellini
Quoted 15 lines · Stefano Stabellini
Quoted 8 lines · Mukesh Rathor

Hi folks,

Well, I did some benchmarking and found interesting results. Following runs are on a westmere with 2 sockets and 10GB RAM. Xen was booted with maxcpus=2 and entire RAM. All guests were started with 1vcpu and 2GB RAM. dom0 started with 1 vcpu and 704MB. Baremetal was booted with 2GB and 1 cpu. HVM guest has EPT enabled. HT is on.

Quoted 5 lines

So, unless the NUMA'ness interfered with results (using some memory on remote socket), it appears HVM does very well. To the point that it seems a hybrid is not going to be worth it. I am currently running tests on a single socket system just to be sure.

Quoted 5 lines

The high level benchmarks I run to compare PV and PV on HVM guests show a very similar scenario.

It is still worth having HYBRID guests (running with EPT?) in order to support dom0 in an HVM container one day not too far from now.

I think it is also worth bearing in mind that once we have basic support for HYBRID we can begin looking at/measuring which hardware features offer advantages to PV guests and enhancing the PV interfaces for use by HYBRID guests etc. (i.e. make things truly hybrid PV+Hardware and not just contained PV)

Also there are arguments to be made for HYBRID over PVHVM in terms of ease of manageability (i.e. a lot of folks like the dom0-supplied kernel idiom which PV enables), avoiding the need for a virtualised BIOS and emulated boot paths, HYBRID can potentially give a best of both in the trade off between standard-PV vs. HVM/PVHVM while also not needing a QEMU process for each guest (which helps scalability and so on) etc. I think HYBRID is worthwhile even if it is basically on-par with PVHVM for some workloads.

Ian.

#25 lore raw
Quoted 8 lines · Ian Campbell

Also there are arguments to be made for HYBRID over PVHVM in terms of ease of manageability (i.e. a lot of folks like the dom0-supplied kernel idiom which PV enables), avoiding the need for a virtualised BIOS and emulated boot paths, HYBRID can potentially give a best of both in the trade off between standard-PV vs. HVM/PVHVM while also not needing a QEMU process for each guest (which helps scalability and so on) etc. I think HYBRID is worthwhile even if it is basically on-par with PVHVM for some workloads.

And it's amazing how much stuff goes away when you can set CONFIG_PCI=n...

J

#27 lore raw
In reply to Mukesh Rathor

Alright, got hybrid with EPT numbers in now from my prototype, it needs some perf work..

Attaching the diffs from my prototype. Linux: 2.6.39. Xen 4.0.2.

Processor, Processes - times in microseconds - smaller is better
------------------------------------------------------------------------------
Host OS Mhz null null open slct sig sig fork exec sh
call I/O stat clos TCP inst hndl proc proc proc
--------- ------------- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----

PV        Linux 2.6.39f 2639 0.65 0.88 2.14 4.59 3.77 0.79 3.62 535. 1294 3308
Hybrid    Linux 2.6.39f 2639 0.13 0.21 0.89 1.96 3.08 0.24 1.10 529. 1294 3246
HVM       Linux 2.6.39f 2639 0.12 0.21 0.64 1.76 3.04 0.24 3.37 113. 354. 1324

Baremetal Linux 2.6.39+ 2649 0.13 0.23 0.74 1.93 3.46 0.28 1.58 127. 386. 1434
HYB-EPT Linux 2.6.39f 2639 0.13 0.21 0.68 1.95 3.04 0.25 3.09 145. 452. 1542

Basic integer operations - times in nanoseconds - smaller is better
-------------------------------------------------------------------
Host OS intgr intgr intgr intgr intgr
bit add mul div mod
--------- ------------- ------ ------ ------ ------ ------

PV        Linux 2.6.39f 0.3800 0.0100 0.1700 9.1000 9.0400
Hybrid    Linux 2.6.39f 0.3800 0.0100 0.1700 9.1100 9.0300
HVM       Linux 2.6.39f 0.3800 0.0100 0.1700 9.1100 9.0600

Baremetal Linux 2.6.39+ 0.3800 0.0100 0.1700 9.0600 8.9800
HYB-EPT Linux 2.6.39f 0.3800 0.0100 0.1700 9.1200 9.0500

Basic float operations - times in nanoseconds - smaller is better
-----------------------------------------------------------------

Host                 OS  float  float  float  float
                         add    mul    div    bogo
--------- ------------- ------ ------ ------ ------ 
PV        Linux 2.6.39f 1.1300 1.5200 5.6200 5.2900
Hybrid    Linux 2.6.39f 1.1300 1.5200 5.6300 5.2900
HVM       Linux 2.6.39f 1.1400 1.5200 5.6300 5.3000

Baremetal Linux 2.6.39+ 1.1300 1.5100 5.6000 5.2700
HYB-EPT Linux 2.6.39f 1.1400 1.5200 5.6300 5.3000

Basic double operations - times in nanoseconds - smaller is better
------------------------------------------------------------------
Host OS double double double double
add mul div bogo
--------- ------------- ------ ------ ------ ------

PV        Linux 2.6.39f 1.1300 1.9000 8.6400 8.3200
Hybrid    Linux 2.6.39f 1.1400 1.9000 8.6600 8.3200
HVM       Linux 2.6.39f 1.1400 1.9000 8.6600 8.3300

Baremetal Linux 2.6.39+ 1.1300 1.8900 8.6100 8.2800
HYB-EPT Linux 2.6.39f 1.1400 1.9000 8.6600 8.3300

Context switching - times in microseconds - smaller is better
-------------------------------------------------------------------------
Host OS 2p/0K 2p/16K 2p/64K 8p/16K 8p/64K 16p/16K 16p/64K
ctxsw ctxsw ctxsw ctxsw ctxsw ctxsw ctxsw
--------- ------------- ------ ------ ------ ------ ------ ------- -------

PV        Linux 2.6.39f 5.2800 5.7600 6.3600 6.3200 7.3600 6.69000 7.46000
Hybrid    Linux 2.6.39f 4.9200 4.9300 5.2200 5.7600 6.9600 6.12000 7.31000
HVM       Linux 2.6.39f 1.3100 1.2200 1.6200 1.9200 3.2600 2.23000 3.48000

Baremetal Linux 2.6.39+ 1.5500 1.4100 2.0600 2.2500 3.3900 2.44000 3.38000
HYB-EPT Linux 2.6.39f 3.2000 3.6100 4.1700 4.3600 6.1200 4.81000 6.20000

*Local* Communication latencies in microseconds - smaller is better
---------------------------------------------------------------------
Host OS 2p/0K Pipe AF UDP RPC/ TCP RPC/ TCP
ctxsw UNIX UDP TCP conn
--------- ------------- ----- ----- ---- ----- ----- ----- ----- ----

PV        Linux 2.6.39f 5.280  16.6 21.3  25.9  33.7  34.7  41.8  87.
Hybrid    Linux 2.6.39f 4.920  11.2 14.4  19.6  26.1  27.5  32.9  71.
HVM       Linux 2.6.39f 1.310 4.416 6.15 9.386  14.8  15.8  20.1  45.
Baremetal Linux 2.6.39+ 1.550 4.625 7.34  14.3  19.8  21.4  26.4  66.
HYB-EPT   Linux 2.6.39f 3.200 8.669 15.3  17.5  23.5  25.1  30.4  66.

File & VM system latencies in microseconds - smaller is better
-------------------------------------------------------------------------------

Host                 OS   0K File      10K File     Mmap    Prot   Page   100fd
                        Create Delete Create Delete Latency Fault  Fault  selct
--------- ------------- ------ ------ ------ ------ ------- ----- ------- -----
PV        Linux 2.6.39f                               24.0K 0.746 3.55870 2.184
Hybrid    Linux 2.6.39f                               24.6K 0.238 4.00100 1.480
HVM       Linux 2.6.39f                              4716.0 0.202 0.96600 1.468

Baremetal Linux 2.6.39+ 6898.0 0.325 0.93610 1.620
HYB-EPT Linux 2.6.39f 5321.0 0.347 1.19510 1.480

*Local* Communication bandwidths in MB/s - bigger is better
-----------------------------------------------------------------------------
Host OS Pipe AF TCP File Mmap Bcopy Bcopy Mem Mem
UNIX reread reread (libc) (hand) read write
--------- ------------- ---- ---- ---- ------ ------ ------ ------ ---- -----

PV        Linux 2.6.39f 1661 2081 1041 3293.3 5528.3 3106.6 2800.0 4472 5633.
Hybrid    Linux 2.6.39f 1974 2450 1183 3481.5 5529.6 3114.9 2786.6 4470 5672.
HVM       Linux 2.6.39f 3232 2929 1622 3541.3 5527.5 3077.1 2765.6 4453 5634.

Baremetal Linux 2.6.39+ 3320 2800 1666 3523.6 5578.9 3147.0 2841.6 4541 5752.
HYB-EPT Linux 2.6.39f 2104 2480 1231 3451.5 5503.4 3067.7 2751.0 4438 5636.

Memory latencies in nanoseconds - smaller is better
(WARNING - may not be correct, check graphs)
------------------------------------------------------------------------------

Host                 OS   Mhz   L1 $   L2 $    Main mem    Rand mem    Guesses
--------- -------------   ---   ----   ----    --------    --------    -------
PV        Linux 2.6.39f  2639 1.5160 5.9170   29.7        97.5
Hybrid    Linux 2.6.39f  2639 1.5170 7.5000   29.7        97.4
HVM       Linux 2.6.39f  2639 1.5190 4.0210   29.8       105.4
Baremetal Linux 2.6.39+  2649 1.5090 3.8370   29.2        78.0
HYB-EPT   Linux 2.6.39f  2639 1.5180 4.0060   29.9       109.9

thanks,
Mukesh

Quoted 16 lines · On Wed, 27 Jul 2011 18:58:28 -0700 Mukesh Rathor <[email protected]>…

Hi folks,

Well, I did some benchmarking and found interesting results. Following runs are on a westmere with 2 sockets and 10GB RAM. Xen was booted with maxcpus=2 and entire RAM. All guests were started with 1vcpu and 2GB RAM. dom0 started with 1 vcpu and 704MB. Baremetal was booted with 2GB and 1 cpu. HVM guest has EPT enabled. HT is on.

So, unless the NUMA'ness interfered with results (using some memory on remote socket), it appears HVM does very well. To the point that it seems a hybrid is not going to be worth it. I am currently running tests on a single socket system just to be sure.

I am attaching my diff's in case any one wants to see what I did. I used xen 4.0.2 and linux 2.6.39.

Quoted 7 lines

thanks,
Mukesh

L M B E N C H 3 . 0 S U M M A R Y

Processor, Processes - times in microseconds - smaller is better
------------------------------------------------------------------------------

arch/x86/Kconfig.debug +1 -1
index 615e188..7791d31 100644
@@ -1,7 +1,7 @@
 menu "Kernel hacking"
 
 config TRACE_IRQFLAGS_SUPPORT
-	def_bool y
+	def_bool n
 
 source "lib/Kconfig.debug"
 
arch/x86/include/asm/cpufeature.h +2 -1
index 91f3e08..bdd7022 100644
@@ -238,7 +238,8 @@ extern const char * const x86_power_flags[32];
 #define cpu_has_fpu		boot_cpu_has(X86_FEATURE_FPU)
 #define cpu_has_vme		boot_cpu_has(X86_FEATURE_VME)
 #define cpu_has_de		boot_cpu_has(X86_FEATURE_DE)
-#define cpu_has_pse		boot_cpu_has(X86_FEATURE_PSE)
+#define cpu_has_pse		0
+/* #define cpu_has_pse		boot_cpu_has(X86_FEATURE_PSE) */
 #define cpu_has_tsc		boot_cpu_has(X86_FEATURE_TSC)
 #define cpu_has_pae		boot_cpu_has(X86_FEATURE_PAE)
 #define cpu_has_pge		boot_cpu_has(X86_FEATURE_PGE)
arch/x86/include/asm/hypervisor.h +1 -0
index 7a15153..f0bbb51 100644
@@ -49,6 +49,7 @@ extern const struct hypervisor_x86 *x86_hyper;
 extern const struct hypervisor_x86 x86_hyper_vmware;
 extern const struct hypervisor_x86 x86_hyper_ms_hyperv;
 extern const struct hypervisor_x86 x86_hyper_xen_hvm;
+extern const struct hypervisor_x86 x86_hyper_xen_hybrid;
 
 static inline bool hypervisor_x2apic_available(void)
 {
arch/x86/kernel/cpu/hypervisor.c +1 -0
index 8095f86..5ec8dbb 100644
@@ -37,6 +37,7 @@ static const __initconst struct hypervisor_x86 * const hypervisors[] =
 #ifdef CONFIG_XEN_PVHVM
 	&x86_hyper_xen_hvm,
 #endif
+        &x86_hyper_xen_hybrid,
 };
 
 const struct hypervisor_x86 *x86_hyper;
arch/x86/pci/direct.c +3 -0
index bd33620..89bfe86 100644
@@ -282,6 +282,9 @@ int __init pci_direct_probe(void)
 {
 	struct resource *region, *region2;
 
+        if (xen_hybrid_domain())
+                return 0;
+
 	if ((pci_probe & PCI_PROBE_CONF1) == 0)
 		goto type2;
 	region = request_region(0xCF8, 8, "PCI conf1");
arch/x86/xen/enlighten.c +139 -10

239 lines not on this page · raw message

arch/x86/xen/irq.c +20 -1
index 6a6fe89..1a161db 100644
@@ -100,6 +100,9 @@ PV_CALLEE_SAVE_REGS_THUNK(xen_irq_enable);
 
 static void xen_safe_halt(void)
 {
+        if (xen_hybrid_domain())
+                local_irq_enable();
+
 	/* Blocking includes an implicit local_irq_enable(). */
 	if (HYPERVISOR_sched_op(SCHEDOP_block, NULL) != 0)
 		BUG();
@@ -113,6 +116,19 @@ static void xen_halt(void)
 		xen_safe_halt();
 }
 
+static const struct pv_irq_ops xen_hybrid_irq_ops __initdata = {
+        .save_fl = __PV_IS_CALLEE_SAVE(native_save_fl),
+        .restore_fl = __PV_IS_CALLEE_SAVE(native_restore_fl),
+        .irq_disable = __PV_IS_CALLEE_SAVE(native_irq_disable),
+        .irq_enable = __PV_IS_CALLEE_SAVE(native_irq_enable),
+
+	.safe_halt = xen_safe_halt,
+	.halt = xen_halt,
+#ifdef CONFIG_X86_64
+	.adjust_exception_frame = paravirt_nop,
+#endif
+};
+
 static const struct pv_irq_ops xen_irq_ops __initdata = {
 	.save_fl = PV_CALLEE_SAVE(xen_save_fl),
 	.restore_fl = PV_CALLEE_SAVE(xen_restore_fl),
@@ -128,6 +144,9 @@ static const struct pv_irq_ops xen_irq_ops __initdata = {
 
 void __init xen_init_irq_ops(void)
 {
-	pv_irq_ops = xen_irq_ops;
+        if (xen_hybrid_domain())
+	        pv_irq_ops = xen_hybrid_irq_ops;
+        else
+	        pv_irq_ops = xen_irq_ops;
 	x86_init.irqs.intr_init = xen_init_IRQ;
 }
arch/x86/xen/mmu.c +55 -27

148 lines not on this page · raw message

arch/x86/xen/setup.c +9 -4
index adaf127..9a2a576 100644
@@ -391,12 +391,9 @@ void __cpuinit xen_enable_syscall(void)
 #endif /* CONFIG_X86_64 */
 }
 
-void __init xen_arch_setup(void)
+static __init void xen_nonhybrid_arch_setup(void)
 {
-	xen_panic_handler_init();
-
 	HYPERVISOR_vm_assist(VMASST_CMD_enable, VMASST_TYPE_4gb_segments);
-	HYPERVISOR_vm_assist(VMASST_CMD_enable, VMASST_TYPE_writable_pagetables);
 
 	if (!xen_feature(XENFEAT_auto_translated_physmap))
 		HYPERVISOR_vm_assist(VMASST_CMD_enable,
@@ -415,6 +412,14 @@ void __init xen_arch_setup(void)
 		disable_acpi();
 	}
 #endif
+}
+
+void __init xen_arch_setup(void)
+{
+	xen_panic_handler_init();
+	HYPERVISOR_vm_assist(VMASST_CMD_enable, VMASST_TYPE_writable_pagetables);
+	if (!xen_hybrid_domain())
+                xen_nonhybrid_arch_setup();
 
 	memcpy(boot_command_line, xen_start_info->cmd_line,
 	       MAX_GUEST_CMDLINE > COMMAND_LINE_SIZE ?
arch/x86/xen/smp.c +5 -4
index 3061244..0b0464e 100644
@@ -195,10 +195,11 @@ static void __init xen_smp_prepare_boot_cpu(void)
 	BUG_ON(smp_processor_id() != 0);
 	native_smp_prepare_boot_cpu();
 
-	/* We've switched to the "real" per-cpu gdt, so make sure the
-	   old memory can be recycled */
-	make_lowmem_page_readwrite(xen_initial_gdt);
-
+	if (!xen_feature(XENFEAT_auto_translated_physmap)) {
+		/* We've switched to the "real" per-cpu gdt, so make sure the
+	   	   old memory can be recycled */
+		make_lowmem_page_readwrite(xen_initial_gdt);
+	}
 	xen_filter_cpu_maps();
 	xen_setup_vcpu_info_placement();
 }
drivers/tty/serial/8250.c +3 -0
index 6611535..1a3ebbc 100644
@@ -3294,6 +3294,9 @@ static int __init serial8250_init(void)
 {
 	int ret;
 
+	if (xen_hybrid_domain())
+		return -ENODEV;
+
 	if (nr_uarts > UART_NR)
 		nr_uarts = UART_NR;
 
drivers/xen/cpu_hotplug.c +1 -1
index 14e2d99..631a019 100644
@@ -99,7 +99,7 @@ static int __init setup_vcpu_hotplug_event(void)
 	static struct notifier_block xsn_cpu = {
 		.notifier_call = setup_cpu_watcher };
 
-	if (!xen_pv_domain())
+	if (!xen_pv_domain() || xen_hybrid_domain())
 		return -ENODEV;
 
 	register_xenstore_notifier(&xsn_cpu);
drivers/xen/events.c +2 -0
index 33167b4..69bad2e 100644
@@ -1632,5 +1632,7 @@ void __init xen_init_IRQ(void)
 		irq_ctx_init(smp_processor_id());
 		if (xen_initial_domain())
 			xen_setup_pirqs();
+                if (xen_hybrid_domain())
+		        xen_callback_vector();
 	}
 }
drivers/xen/grant-table.c +55 -0

73 lines not on this page · raw message

drivers/xen/xenbus/xenbus_probe.c +7 -1
index 7397695..2429d0e 100644
@@ -737,7 +737,13 @@ static int __init xenbus_init(void)
 
 		xen_store_interface = mfn_to_virt(xen_store_mfn);
 	} else {
-		if (xen_hvm_domain()) {
+		if (xen_hybrid_autoxlate_domain()) {
+                	xen_store_evtchn = xen_start_info->store_evtchn;
+			xen_store_mfn = xen_start_info->store_mfn;  /* pfn */
+			xen_store_interface = __va(xen_store_mfn<<PAGE_SHIFT);
+			xenstored_ready = 1;
+
+		} else if (xen_hvm_domain()) {
 			uint64_t v = 0;
 			err = hvm_get_parameter(HVM_PARAM_STORE_EVTCHN, &v);
 			if (err)
include/linux/printk.h +2 -0
index ee048e7..0758b26 100644
@@ -1,6 +1,8 @@
 #ifndef __KERNEL_PRINTK__
 #define __KERNEL_PRINTK__
 
+extern void mukchk(unsigned long);
+
 extern const char linux_banner[];
 extern const char linux_proc_banner[];
 
include/xen/interface/xen.h +1 -0
index b33257b..805eb60 100644
@@ -452,6 +452,7 @@ struct start_info {
 /* These flags are passed in the 'flags' field of start_info_t. */
 #define SIF_PRIVILEGED    (1<<0)  /* Is the domain privileged? */
 #define SIF_INITDOMAIN    (1<<1)  /* Is this the initial control domain? */
+#define SIF_IS_HYBRID     (1<<3)  /* Is it a PV running in HVM container? */
 
 typedef uint64_t cpumap_t;
 
include/xen/xen.h +5 -1
index a164024..0c3fca1 100644
@@ -18,7 +18,11 @@ extern enum xen_domain_type xen_domain_type;
 				 xen_domain_type == XEN_PV_DOMAIN)
 #define xen_hvm_domain()	(xen_domain() &&			\
 				 xen_domain_type == XEN_HVM_DOMAIN)
-
+/* xen_pv_domain check is necessary as start_info ptr is null in HVM */
+#define xen_hybrid_domain()     (xen_pv_domain () &&                    \
+                                 (xen_start_info->flags & SIF_IS_HYBRID))
+#define xen_hybrid_autoxlate_domain() (xen_hybrid_domain() &&  \
+                                 (xen_feature(XENFEAT_auto_translated_physmap)))
 #ifdef CONFIG_XEN_DOM0
 #include <xen/interface/xen.h>
 #include <asm/xen/hypervisor.h>
tools/debugger/gdbsx/xg/xg_main.c +4 -1
diff -r f2cf898c7ff8 tools/debugger/gdbsx/xg/xg_main.c
@@ -80,6 +80,7 @@ int xgtrc_on = 0;
 struct xen_domctl domctl;         /* just use a global domctl */
 
 static int     _hvm_guest;        /* hvm guest? 32bit HVMs have 64bit context */
+static int     _hybrid_guest;
 static domid_t _dom_id;           /* guest domid */
 static int     _max_vcpu_id;      /* thus max_vcpu_id+1 VCPUs */
 static int     _dom0_fd;          /* fd of /dev/privcmd */
@@ -308,6 +309,8 @@ xg_attach(int domid, int guest_bitness)
 
     _max_vcpu_id = domctl.u.getdomaininfo.max_vcpu_id;
     _hvm_guest = (domctl.u.getdomaininfo.flags & XEN_DOMINF_hvm_guest);
+    _hybrid_guest = (domctl.u.getdomaininfo.flags & XEN_DOMINF_hybrid_guest);
+
     return _max_vcpu_id;
 }
 
@@ -368,7 +371,7 @@ _change_TF(vcpuid_t which_vcpu, int gues
     int sz = sizeof(anyc);
 
     /* first try the MTF for hvm guest. otherwise do manually */
-    if (_hvm_guest) {
+    if (_hvm_guest || _hybrid_guest) {
         domctl.u.debug_op.vcpu = which_vcpu;
         domctl.u.debug_op.op = setit ? XEN_DOMCTL_DEBUG_OP_SINGLE_STEP_ON :
                                        XEN_DOMCTL_DEBUG_OP_SINGLE_STEP_OFF;
tools/libxc/Makefile +1 -1
diff -r f2cf898c7ff8 tools/libxc/Makefile
@@ -58,7 +58,7 @@ GUEST_SRCS-$(CONFIG_IA64)    += xc_dom_i
 -include $(XEN_TARGET_ARCH)/Makefile
 
 CFLAGS   += -Werror -Wmissing-prototypes
-CFLAGS   += $(INCLUDES) -I. -I../xenstore -I../include
+CFLAGS   += $(INCLUDES) -I. -I../xenstore -I../include -g -O0
 
 # Needed for posix_fadvise64() in xc_linux.c
 CFLAGS-$(CONFIG_Linux) += -D_GNU_SOURCE
tools/libxc/xc_dom.h +5 -1
diff -r f2cf898c7ff8 tools/libxc/xc_dom.h
@@ -110,6 +110,9 @@ struct xc_dom_image {
     struct xc_dom_arch *arch_hooks;
     /* allocate up to virt_alloc_end */
     int (*allocate) (struct xc_dom_image * dom, xen_vaddr_t up_to);
+
+    /* hybrid flags */
+    char hybrid_hap;
 };
 
 /* --- pluggable kernel loader ------------------------------------- */
@@ -241,7 +244,8 @@ static inline void *xc_dom_vaddr_to_ptr(
 
 static inline int xc_dom_feature_translated(struct xc_dom_image *dom)
 {
-    return elf_xen_feature_get(XENFEAT_auto_translated_physmap, dom->f_active);
+    return(dom->hybrid_hap || 
+           elf_xen_feature_get(XENFEAT_auto_translated_physmap, dom->f_active));
 }
 
 static inline xen_pfn_t xc_dom_p2m_host(struct xc_dom_image *dom, xen_pfn_t pfn)
tools/libxc/xc_dom_x86.c +3 -2
diff -r f2cf898c7ff8 tools/libxc/xc_dom_x86.c
@@ -372,7 +372,8 @@ static int setup_pgtables_x86_64(struct 
         pgpfn = (addr - dom->parms.virt_base) >> PAGE_SHIFT_X86;
         l1tab[l1off] =
             pfn_to_paddr(xc_dom_p2m_guest(dom, pgpfn)) | L1_PROT;
-        if ( (addr >= dom->pgtables_seg.vstart) && 
+        if ( !dom->hybrid_hap                   &&
+             (addr >= dom->pgtables_seg.vstart) && 
              (addr < dom->pgtables_seg.vend) )
             l1tab[l1off] &= ~_PAGE_RW; /* page tables are r/o */
         if ( l1off == (L1_PAGETABLE_ENTRIES_X86_64 - 1) )
@@ -819,7 +820,7 @@ int arch_setup_bootlate(struct xc_dom_im
         }
 
         /* Map grant table frames into guest physmap. */
-        for ( i = 0; ; i++ )
+        for ( i = 0; !dom->hybrid_hap ; i++ )
         {
             xatp.domid = dom->guest_domid;
             xatp.space = XENMAPSPACE_grant_table;
tools/libxl/Makefile +1 -1
diff -r f2cf898c7ff8 tools/libxl/Makefile
@@ -12,7 +12,7 @@ XLUMAJOR = 1.0
 XLUMINOR = 0
 
 CFLAGS += -Werror
-CFLAGS += -I. -fPIC
+CFLAGS += -I. -fPIC -g -O0
 CFLAGS += $(CFLAGS_libxenctrl) $(CFLAGS_libxenguest) $(CFLAGS_libxenstore)
 
 LIBS = $(LDFLAGS_libxenctrl) $(LDFLAGS_libxenguest) $(LDFLAGS_libxenstore)
tools/libxl/libxl.c +1 -0
diff -r f2cf898c7ff8 tools/libxl/libxl.c
@@ -99,6 +99,7 @@ int libxl_domain_make(struct libxl_ctx *
     if (!uuid_string) return ERROR_NOMEM;
 
     flags = info->hvm ? XEN_DOMCTL_CDF_hvm_guest : 0;
+    flags |= info->hybrid ? XEN_DOMCTL_CDF_hybrid_guest : 0;
     flags |= info->hap ? XEN_DOMCTL_CDF_hap : 0;
     flags |= info->oos ? 0 : XEN_DOMCTL_CDF_oos_off;
     *domid = -1;
tools/libxl/libxl.h +3 -0
diff -r f2cf898c7ff8 tools/libxl/libxl.h
@@ -78,6 +78,7 @@ const libxl_version_info* libxl_get_vers
 
 typedef struct {
     bool hvm;
+    bool hybrid;
     bool hap;
     bool oos;
     int ssidref;
@@ -97,6 +98,8 @@ typedef struct {
     uint32_t shadow_memkb;
     const char *kernel;
     int hvm;
+    int hybrid;
+    int hybrid_hap;
     union {
         struct {
             bool pae;
tools/libxl/libxl_dom.c +5 -2
diff -r f2cf898c7ff8 tools/libxl/libxl_dom.c
@@ -69,7 +69,7 @@ int build_pre(struct libxl_ctx *ctx, uin
             (info->max_memkb + info->u.pv.slack_memkb));
     xc_domain_set_tsc_info(ctx->xch, domid, info->tsc_mode, 0, 0, 0);
 
-    if (info->hvm) {
+    if (info->hvm || info->hybrid) {
         unsigned long shadow;
         shadow = (info->shadow_memkb + 1023) / 1024;
         xc_shadow_control(ctx->xch, domid, XEN_DOMCTL_SHADOW_OP_SET_ALLOCATION, NULL, 0, &shadow, 0, NULL);
@@ -139,13 +139,16 @@ int build_pv(struct libxl_ctx *ctx, uint
 {
     struct xc_dom_image *dom;
     int ret;
-    int flags = 0;
+    int flags;               /* start info flags: start_info_x86_64() */
+
+    flags = info->hybrid ? SIF_IS_HYBRID : 0;
 
     dom = xc_dom_allocate(info->u.pv.cmdline, info->u.pv.features);
     if (!dom) {
         XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "xc_dom_allocate failed");
         return -1;
     }
+    dom->hybrid_hap = info->hybrid_hap ? 1 : 0;
     ret = xc_dom_linux_build(ctx->xch, dom, domid, info->target_memkb / 1024,
                                   info->kernel, info->u.pv.ramdisk, flags,
                                   state->store_port, &state->store_mfn,
tools/libxl/xl_cmdimpl.c +10 -0
diff -r f2cf898c7ff8 tools/libxl/xl_cmdimpl.c
@@ -197,6 +197,11 @@ static void init_build_info(libxl_domain
     } else {
         b_info->u.pv.slack_memkb = 8 * 1024;
     }
+    if (c_info->hybrid) {
+        b_info->hybrid = 1;
+        if (c_info->hap)
+            b_info->hybrid_hap = 1;
+    }
 }
 
 static void init_dm_info(libxl_device_model_info *dm_info,
@@ -469,6 +474,11 @@ static void parse_config_data(const char
         !strncmp(buf, "hvm", strlen(buf)))
         c_info->hvm = 1;
 
+    c_info->hybrid = 0;
+    if (!xlu_cfg_get_long (config, "hybrid", &l))
+        c_info->hybrid = 1;
+
+    c_info->hap = 0;
     if (!xlu_cfg_get_long (config, "hap", &l))
         c_info->hap = l;
 
xen/arch/x86/debug.c +2 -3
diff -r f2cf898c7ff8 xen/arch/x86/debug.c
@@ -43,7 +43,6 @@ extern void kdbp(const char *fmt, ...);
 typedef unsigned long dbgva_t;
 typedef unsigned char dbgbyte_t;
 
-
 /* Returns: mfn for the given (hvm guest) vaddr */
 static unsigned long 
 dbg_hvm_va2mfn(dbgva_t vaddr, struct domain *dp, int toaddr)
@@ -55,6 +54,7 @@ dbg_hvm_va2mfn(dbgva_t vaddr, struct dom
     DBGP2("vaddr:%lx domid:%d\n", vaddr, dp->domain_id);
 
     gfn = paging_gva_to_gfn(dp->vcpu[0], vaddr, &pfec);
+
     if ( gfn == INVALID_GFN )
     {
         DBGP2("kdb:bad gfn from gva_to_gfn\n");
@@ -200,7 +200,7 @@ dbg_rw_guest_mem(dbgva_t addr, dbgbyte_t
 
         pagecnt = min_t(long, PAGE_SIZE - (addr & ~PAGE_MASK), len);
 
-        mfn = (dp->is_hvm
+        mfn = ( (is_hvm_domain(dp) || is_hyb_hap_domain(dp))
                ? dbg_hvm_va2mfn(addr, dp, toaddr)
                : dbg_pv_va2mfn(addr, dp, pgd3));
         if ( mfn == INVALID_MFN ) 
@@ -225,7 +225,6 @@ dbg_rw_guest_mem(dbgva_t addr, dbgbyte_t
         buf += pagecnt;
         len -= pagecnt;
     }
-
     return len;
 }
 
xen/arch/x86/domain.c +77 -40

252 lines not on this page · raw message

xen/arch/x86/domctl.c +9 -3
diff -r f2cf898c7ff8 xen/arch/x86/domctl.c
@@ -466,6 +466,7 @@ long arch_do_domctl(
             goto sethvmcontext_out;
 
         ret = -EINVAL;
+        KASSERT(!is_hybrid_domain(d));
         if ( !is_hvm_domain(d) ) 
             goto sethvmcontext_out;
 
@@ -503,6 +504,7 @@ long arch_do_domctl(
             goto gethvmcontext_out;
 
         ret = -EINVAL;
+        KASSERT(!is_hybrid_domain(d));
         if ( !is_hvm_domain(d) ) 
             goto gethvmcontext_out;
 
@@ -558,6 +560,7 @@ long arch_do_domctl(
             goto gethvmcontext_partial_out;
 
         ret = -EINVAL;
+        KASSERT(!is_hybrid_domain(d));
         if ( !is_hvm_domain(d) ) 
             goto gethvmcontext_partial_out;
 
@@ -719,6 +722,7 @@ long arch_do_domctl(
         case XEN_DOMCTL_SENDTRIGGER_POWER:
         {
             ret = -EINVAL;
+            KASSERT(!is_hybrid_domain(d));
             if ( is_hvm_domain(d) ) 
             {
                 ret = 0;
@@ -731,6 +735,7 @@ long arch_do_domctl(
         {
             extern void hvm_acpi_sleep_button(struct domain *d);
 
+            KASSERT(!is_hybrid_domain(d));
             ret = -EINVAL;
             if ( is_hvm_domain(d) ) 
             {
@@ -1285,7 +1290,7 @@ long arch_do_domctl(
             goto debug_op_out;
 
         ret = -EINVAL;
-        if ( !is_hvm_domain(d))
+        if ( !is_hvm_or_hyb_domain(d))
             goto debug_op_out;
 
         ret = hvm_debug_op(v, domctl->u.debug_op.op);
@@ -1465,8 +1470,9 @@ void arch_get_info_guest(struct vcpu *v,
         c(flags |= VGCF_i387_valid);
     if ( !test_bit(_VPF_down, &v->pause_flags) )
         c(flags |= VGCF_online);
-
-    if ( is_hvm_vcpu(v) )
+        
+    /* HYBRID TDB: debugregs? Verify this again */
+    if ( is_hvm_or_hyb_vcpu(v) )
     {
         struct segment_register sreg;
         memset(c.nat->ctrlreg, 0, sizeof(c.nat->ctrlreg));
xen/arch/x86/hvm/hvm.c +146 -37

299 lines not on this page · raw message

xen/arch/x86/hvm/irq.c +3 -0
diff -r f2cf898c7ff8 xen/arch/x86/hvm/irq.c
@@ -333,6 +333,9 @@ struct hvm_intack hvm_vcpu_has_pending_i
          && vcpu_info(v, evtchn_upcall_pending) )
         return hvm_intack_vector(plat->irq.callback_via.vector);
 
+    if (is_hybrid_vcpu(v))       /* Hybrid TBD: See NMI / MCE below */
+        return hvm_intack_none;
+
     if ( unlikely(v->nmi_pending) )
         return hvm_intack_nmi;
 
xen/arch/x86/hvm/mtrr.c +3 -0
diff -r f2cf898c7ff8 xen/arch/x86/hvm/mtrr.c
@@ -573,6 +573,7 @@ int32_t hvm_get_mem_pinned_cacheattr(
     uint32_t *type)
 {
     struct hvm_mem_pinned_cacheattr_range *range;
+    KASSERT(!is_hybrid_domain(d));
 
     *type = 0;
 
@@ -601,6 +602,8 @@ int32_t hvm_set_mem_pinned_cacheattr(
 {
     struct hvm_mem_pinned_cacheattr_range *range;
 
+    KASSERT(!is_hybrid_domain(d));
+
     if ( !((type == PAT_TYPE_UNCACHABLE) ||
            (type == PAT_TYPE_WRCOMB) ||
            (type == PAT_TYPE_WRTHROUGH) ||
xen/arch/x86/hvm/svm/vmcb.c +1 -1
diff -r f2cf898c7ff8 xen/arch/x86/hvm/svm/vmcb.c
@@ -419,7 +419,7 @@ void kdb_dump_vmcb(domid_t did, int vid)
 
     rcu_read_lock(&domlist_read_lock);
     for_each_domain (dp) {
-        if (!is_hvm_domain(dp) || dp->is_dying)
+        if (!is_hvm_or_hyb_domain(dp) || dp->is_dying)
             continue;
         if (did != 0 && did != dp->domain_id)
             continue;
xen/arch/x86/hvm/vmx/Makefile +1 -0
diff -r f2cf898c7ff8 xen/arch/x86/hvm/vmx/Makefile
@@ -5,3 +5,4 @@ obj-y += vmcs.o
 obj-y += vmx.o
 obj-y += vpmu.o
 obj-y += vpmu_core2.o
+obj-y += hybrid.o
xen/arch/x86/hvm/vmx/hybrid.c new file +576 -0

576 lines not on this page · raw message

xen/arch/x86/hvm/vmx/intr.c +3 -2
diff -r f2cf898c7ff8 xen/arch/x86/hvm/vmx/intr.c
@@ -125,8 +125,9 @@ asmlinkage void vmx_intr_assist(void)
         return;
     }
 
-    /* Crank the handle on interrupt state. */
-    pt_update_irq(v);
+    if (!is_hybrid_vcpu(v))
+        /* Crank the handle on interrupt state. */
+        pt_update_irq(v);
 
     do {
         intack = hvm_vcpu_has_pending_irq(v);
xen/arch/x86/hvm/vmx/vmcs.c +328 -16

414 lines not on this page · raw message

xen/arch/x86/hvm/vmx/vmx.c +46 -45

208 lines not on this page · raw message

xen/arch/x86/hvm/vpt.c +1 -0
diff -r f2cf898c7ff8 xen/arch/x86/hvm/vpt.c
@@ -289,6 +289,7 @@ void pt_intr_post(struct vcpu *v, struct
     if ( intack.source == hvm_intsrc_vector )
         return;
 
+    KASSERT(!is_hybrid_vcpu(current));
     spin_lock(&v->arch.hvm_vcpu.tm_lock);
 
     pt = is_pt_irq(v, intack);
xen/arch/x86/mm.c +26 -2
diff -r f2cf898c7ff8 xen/arch/x86/mm.c
@@ -490,9 +490,12 @@ void make_cr3(struct vcpu *v, unsigned l
 
 #endif /* !defined(__i386__) */
 
+/* calling hybrid_update_cr3 doesnt work because during context switch
+ * vmcs is not completely setup? */
 void write_ptbase(struct vcpu *v)
 {
-    write_cr3(v->arch.cr3);
+    if (!is_hybrid_vcpu(v))
+        write_cr3(v->arch.cr3);
 }
 
 /*
@@ -2482,6 +2485,7 @@ int get_page_type_preemptible(struct pag
 }
 
 
+extern void hybrid_update_cr3(struct vcpu *v);
 int new_guest_cr3(unsigned long mfn)
 {
     struct vcpu *curr = current;
@@ -2530,6 +2534,9 @@ int new_guest_cr3(unsigned long mfn)
 
     write_ptbase(curr);
 
+    if (is_hybrid_vcpu(curr))
+        hybrid_update_cr3(curr);
+
     if ( likely(old_base_mfn != 0) )
     {
         if ( paging_mode_refcounts(d) )
@@ -2863,10 +2870,23 @@ int do_mmuext_op(
 #endif
         
         case MMUEXT_TLB_FLUSH_LOCAL:
+            /* do this for both, flush_tlb_user and flush_tlb_kernel, for now.
+             * To debug: hvm_asid_flush_vcpu for flush_tlb_user, and
+             * vpid_sync_all for flush_tlb_kernel */
+            if (is_hybrid_domain(d)) {
+                extern void hybrid_flush_tlb(void);
+                hybrid_flush_tlb();
+                break;
+            }
             flush_tlb_local();
             break;
     
         case MMUEXT_INVLPG_LOCAL:
+            if (is_hybrid_domain(d)) {
+                extern void hybrid_do_invlpg(ulong);
+                hybrid_do_invlpg(op.arg1.linear_addr);
+                break;
+            }
             if ( !paging_mode_enabled(d) 
                  || paging_invlpg(curr, op.arg1.linear_addr) != 0 )
                 flush_tlb_one_local(op.arg1.linear_addr);
@@ -2877,6 +2897,10 @@ int do_mmuext_op(
         {
             cpumask_t pmask;
 
+            if (is_hybrid_domain(d)) {
+                printk("MUK:FIX: MMUEXT_TLB_FLUSH_MULTI/MMUEXT_INVLPG_MULTI\n");
+                break;
+            }
             if ( unlikely(vcpumask_to_pcpumask(d, op.arg2.vcpumask, &pmask)) )
             {
                 okay = 0;
@@ -4181,7 +4205,7 @@ long do_update_descriptor(u64 pa, u64 de
     mfn = gmfn_to_mfn(dom, gmfn);
     if ( (((unsigned int)pa % sizeof(struct desc_struct)) != 0) ||
          !mfn_valid(mfn) ||
-         !check_descriptor(dom, &d) )
+         (!is_hybrid_domain(dom) && !check_descriptor(dom, &d)) )
         return -EINVAL;
 
     page = mfn_to_page(mfn);
xen/arch/x86/mm/hap/hap.c +4 -2
diff -r f2cf898c7ff8 xen/arch/x86/mm/hap/hap.c
@@ -705,8 +705,10 @@ void hap_vcpu_init(struct vcpu *v)
 static int hap_page_fault(struct vcpu *v, unsigned long va,
                           struct cpu_user_regs *regs)
 {
-    HAP_ERROR("Intercepted a guest #PF (%u:%u) with HAP enabled.\n",
-              v->domain->domain_id, v->vcpu_id);
+    HAP_ERROR("Intercepted a guest #PF (%u:%u:VA %016lx IP:%016lx) with "
+              "HAP enabled.\n", v->domain->domain_id, v->vcpu_id,va, regs->rip);
+
+    kdb_trap_immed(KDB_TRAP_NONFATAL);
     domain_crash(v->domain);
     return 0;
 }
xen/arch/x86/mm/mem_event.c +1 -1
diff -r f2cf898c7ff8 xen/arch/x86/mm/mem_event.c
@@ -216,7 +216,7 @@ int mem_event_domctl(struct domain *d, x
 
             /* Currently only EPT is supported */
             rc = -ENODEV;
-            if ( !(is_hvm_domain(d) && d->arch.hvm_domain.hap_enabled &&
+            if ( !(is_hvm_or_hyb_domain(d) && d->arch.hvm_domain.hap_enabled &&
                   (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL)) )
                 break;
 
xen/arch/x86/mm/mem_sharing.c +0 -3
diff -r f2cf898c7ff8 xen/arch/x86/mm/mem_sharing.c
@@ -42,9 +42,6 @@ static void mem_sharing_audit(void);
 # define mem_sharing_audit() do {} while(0)
 #endif /* MEM_SHARING_AUDIT */
 
-
-#define hap_enabled(d) \
-    (is_hvm_domain(d) && (d)->arch.hvm_domain.hap_enabled)
 #define mem_sharing_enabled(d) \
     (is_hvm_domain(d) && (d)->arch.hvm_domain.mem_sharing_enabled)
  
xen/arch/x86/mm/p2m.c +2 -2
diff -r f2cf898c7ff8 xen/arch/x86/mm/p2m.c
@@ -1569,7 +1569,7 @@ int p2m_init(struct domain *d)
     p2m->get_entry_current = p2m_gfn_to_mfn_current;
     p2m->change_entry_type_global = p2m_change_type_global;
 
-    if ( is_hvm_domain(d) && d->arch.hvm_domain.hap_enabled &&
+    if ( is_hvm_or_hyb_domain(d) && d->arch.hvm_domain.hap_enabled &&
          (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL) )
         ept_p2m_init(d);
 
@@ -1596,7 +1596,7 @@ int set_p2m_entry(struct domain *d, unsi
 
     while ( todo )
     {
-        if ( is_hvm_domain(d) && d->arch.hvm_domain.hap_enabled )
+        if ( is_hvm_or_hyb_domain(d) && d->arch.hvm_domain.hap_enabled )
             order = ((((gfn | mfn_x(mfn) | todo) & (SUPERPAGE_PAGES - 1)) == 0)
                     && hvm_hap_has_2mb(d)) ? 9 : 0;
         else
xen/arch/x86/mm/paging.c +0 -2
diff -r f2cf898c7ff8 xen/arch/x86/mm/paging.c
@@ -29,8 +29,6 @@
 #include <xen/numa.h>
 #include <xsm/xsm.h>
 
-#define hap_enabled(d) (is_hvm_domain(d) && (d)->arch.hvm_domain.hap_enabled)
-
 /* Printouts */
 #define PAGING_PRINTK(_f, _a...)                                     \
     debugtrace_printk("pg: %s(): " _f, __func__, ##_a)
xen/arch/x86/time.c +4 -5
diff -r f2cf898c7ff8 xen/arch/x86/time.c
@@ -879,7 +879,7 @@ static void __update_vcpu_system_time(st
         _u.tsc_to_system_mul = t->tsc_scale.mul_frac;
         _u.tsc_shift         = (s8)t->tsc_scale.shift;
     }
-    if ( is_hvm_domain(d) )
+    if ( is_hvm_or_hyb_domain(d) )
         _u.tsc_timestamp += v->arch.hvm_vcpu.cache_tsc_offset;
 
     /* Don't bother unless timestamp record has changed or we are forced. */
@@ -947,7 +947,7 @@ static void update_domain_rtc(void)
     rcu_read_lock(&domlist_read_lock);
 
     for_each_domain ( d )
-        if ( is_hvm_domain(d) )
+        if ( is_hvm_or_hyb_domain(d) )
             rtc_update_clock(d);
 
     rcu_read_unlock(&domlist_read_lock);
@@ -956,7 +956,7 @@ static void update_domain_rtc(void)
 void domain_set_time_offset(struct domain *d, int32_t time_offset_seconds)
 {
     d->time_offset_seconds = time_offset_seconds;
-    if ( is_hvm_domain(d) )
+    if ( is_hvm_or_hyb_domain(d) )
         rtc_update_clock(d);
 }
 
@@ -1856,7 +1856,6 @@ void tsc_set_info(struct domain *d,
         d->arch.vtsc = 0;
         return;
     }
-
     switch ( d->arch.tsc_mode = tsc_mode )
     {
     case TSC_MODE_NEVER_EMULATE:
@@ -1901,7 +1900,7 @@ void tsc_set_info(struct domain *d,
         break;
     }
     d->arch.incarnation = incarnation + 1;
-    if ( is_hvm_domain(d) )
+    if ( is_hvm_or_hyb_domain(d) )
         hvm_set_rdtsc_exiting(d, d->arch.vtsc);
 }
 
xen/arch/x86/traps.c +1 -2
diff -r f2cf898c7ff8 xen/arch/x86/traps.c
@@ -1217,7 +1217,7 @@ static int spurious_page_fault(
     return is_spurious;
 }
 
-static int fixup_page_fault(unsigned long addr, struct cpu_user_regs *regs)
+int fixup_page_fault(unsigned long addr, struct cpu_user_regs *regs)
 {
     struct vcpu   *v = current;
     struct domain *d = v->domain;
@@ -3228,7 +3228,6 @@ void load_TR(void)
         .base = (long)(this_cpu(gdt_table) - FIRST_RESERVED_GDT_ENTRY),
         .limit = LAST_RESERVED_GDT_BYTE
     };
-
     _set_tssldt_desc(
         this_cpu(gdt_table) + TSS_ENTRY - FIRST_RESERVED_GDT_ENTRY,
         (unsigned long)tss,
xen/arch/x86/x86_64/traps.c +1 -1
diff -r f2cf898c7ff8 xen/arch/x86/x86_64/traps.c
@@ -617,7 +617,7 @@ static void hypercall_page_initialise_ri
 void hypercall_page_initialise(struct domain *d, void *hypercall_page)
 {
     memset(hypercall_page, 0xCC, PAGE_SIZE);
-    if ( is_hvm_domain(d) )
+    if ( is_hvm_or_hyb_domain(d) )
         hvm_hypercall_page_initialise(d, hypercall_page);
     else if ( !is_pv_32bit_domain(d) )
         hypercall_page_initialise_ring3_kernel(hypercall_page);
xen/common/domain.c +8 -2
diff -r f2cf898c7ff8 xen/common/domain.c
@@ -238,8 +238,13 @@ struct domain *domain_create(
     spin_lock_init(&d->shutdown_lock);
     d->shutdown_code = -1;
 
-    if ( domcr_flags & DOMCRF_hvm )
+    if ( domcr_flags & DOMCRF_hybrid ) {
+        d->is_hybrid = 1;
+        printk("Hybrid guest with%s ept. Domid:%d\n", 
+               (domcr_flags&DOMCRF_hap) ? "" : " no", domid);
+    } else if ( domcr_flags & DOMCRF_hvm ) {
         d->is_hvm = 1;
+    }
 
     if ( domid == 0 )
     {
@@ -588,7 +593,8 @@ void domain_pause_for_debugger(void)
     for_each_vcpu ( d, v )
         vcpu_sleep_nosync(v);
 
-    send_guest_global_virq(dom0, VIRQ_DEBUGGER);
+    if (current->arch.gdbsx_vcpu_event == 0)
+        send_guest_global_virq(dom0, VIRQ_DEBUGGER);
 }
 
 /* Complete domain destroy after RCU readers are not holding old references. */
xen/common/domctl.c +6 -1
diff -r f2cf898c7ff8 xen/common/domctl.c
@@ -132,6 +132,8 @@ void getdomaininfo(struct domain *d, str
 
     if ( is_hvm_domain(d) )
         info->flags |= XEN_DOMINF_hvm_guest;
+    else if ( is_hybrid_domain(d) )
+        info->flags |= XEN_DOMINF_hybrid_guest;
 
     xsm_security_domaininfo(d, info);
 
@@ -394,7 +396,8 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
         if ( supervisor_mode_kernel ||
              (op->u.createdomain.flags &
              ~(XEN_DOMCTL_CDF_hvm_guest | XEN_DOMCTL_CDF_hap |
-               XEN_DOMCTL_CDF_s3_integrity | XEN_DOMCTL_CDF_oos_off)) )
+               XEN_DOMCTL_CDF_s3_integrity | XEN_DOMCTL_CDF_oos_off |
+               XEN_DOMCTL_CDF_hybrid_guest)) )
             break;
 
         dom = op->domain;
@@ -430,6 +433,8 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
             domcr_flags |= DOMCRF_s3_integrity;
         if ( op->u.createdomain.flags & XEN_DOMCTL_CDF_oos_off )
             domcr_flags |= DOMCRF_oos_off;
+        if ( op->u.createdomain.flags & XEN_DOMCTL_CDF_hybrid_guest )
+            domcr_flags |= DOMCRF_hybrid;
 
         ret = -ENOMEM;
         d = domain_create(dom, domcr_flags, op->u.createdomain.ssidref);
xen/common/kernel.c +4 -1
diff -r f2cf898c7ff8 xen/common/kernel.c
@@ -239,13 +239,16 @@ DO(xen_version)(int cmd, XEN_GUEST_HANDL
             if ( supervisor_mode_kernel )
                 fi.submap |= 1U << XENFEAT_supervisor_mode_kernel;
 #ifdef CONFIG_X86
-            if ( !is_hvm_vcpu(current) )
+            if ( !is_hvm_vcpu(current) && 
+                 !paging_mode_translate(current->domain) )  /* hybrid */
                 fi.submap |= (1U << XENFEAT_mmu_pt_update_preserve_ad) |
                              (1U << XENFEAT_highmem_assist) |
                              (1U << XENFEAT_gnttab_map_avail_bits);
             else
                 fi.submap |= (1U << XENFEAT_hvm_safe_pvclock) |
                              (1U << XENFEAT_hvm_callback_vector);
+            if ( is_hybrid_vcpu(current) )
+                fi.submap |= (1U << XENFEAT_hvm_callback_vector);
 #endif
             break;
         default:
xen/common/memory.c +2 -1
diff -r f2cf898c7ff8 xen/common/memory.c
@@ -89,7 +89,7 @@ static void increase_reservation(struct 
     a->nr_done = i;
 }
 
-static void populate_physmap(struct memop_args *a)
+static noinline void populate_physmap(struct memop_args *a)
 {
     struct page_info *page;
     unsigned long i, j;
@@ -134,6 +134,7 @@ static void populate_physmap(struct memo
             }
 
             mfn = page_to_mfn(page);
+
             guest_physmap_add_page(d, gpfn, mfn, a->extent_order);
 
             if ( !paging_mode_translate(d) )
xen/common/timer.c +10 -3
diff -r f2cf898c7ff8 xen/common/timer.c
@@ -546,13 +546,20 @@ void kdb_dump_timer_queues(void)
     struct timers *ts;
     unsigned long sz, offs;
     char buf[KSYM_NAME_LEN+1];
-    int            cpu, j;
-    s_time_t       now = NOW();
+    int cpu, j;
+    u64 tsc;
 
     for_each_online_cpu( cpu )
     {
         ts = &per_cpu(timers, cpu);
-        kdbp("CPU[%02d]: NOW:0x%08x%08x\n", cpu, (u32)(now>>32), (u32)now);
+        kdbp("CPU[%02d]:", cpu);
+
+        if (cpu == smp_processor_id()) {
+            s_time_t now = NOW();
+            rdtscll(tsc);
+            kdbp("NOW:0x%08x%08x TSC:0x%016lx\n", (u32)(now>>32),(u32)now, tsc);
+        } else
+            kdbp("\n");
 
         /* timers in the heap */
         for ( j = 1; j <= GET_HEAP_SIZE(ts->heap); j++ ) {
xen/include/asm-x86/desc.h +5 -1
diff -r f2cf898c7ff8 xen/include/asm-x86/desc.h
@@ -58,7 +58,8 @@
 #ifndef __ASSEMBLY__
 
 #if defined(__x86_64__)
-#define GUEST_KERNEL_RPL(d) (is_pv_32bit_domain(d) ? 1 : 3)
+#define GUEST_KERNEL_RPL(d) (is_hybrid_domain(d) ? 0 : \
+                      is_pv_32bit_domain(d) ? 1 : 3)
 #elif defined(__i386__)
 #define GUEST_KERNEL_RPL(d) ((void)(d), 1)
 #endif
@@ -67,6 +68,9 @@
 #define __fixup_guest_selector(d, sel)                             \
 ({                                                                 \
     uint16_t _rpl = GUEST_KERNEL_RPL(d);                           \
+    if (d->is_hybrid) {                                      \
+        printk("MUK: hybrid domain fixing up selector\n");          \
+    }                                                              \
     (sel) = (((sel) & 3) >= _rpl) ? (sel) : (((sel) & ~3) | _rpl); \
 })
 
xen/include/asm-x86/domain.h +1 -1
diff -r f2cf898c7ff8 xen/include/asm-x86/domain.h
@@ -18,7 +18,7 @@
 #endif
 #define is_pv_32on64_vcpu(v)   (is_pv_32on64_domain((v)->domain))
 
-#define is_hvm_pv_evtchn_domain(d) (is_hvm_domain(d) && \
+#define is_hvm_pv_evtchn_domain(d) (is_hvm_or_hyb_domain(d) && \
         d->arch.hvm_domain.irq.callback_via_type == HVMIRQ_callback_vector)
 #define is_hvm_pv_evtchn_vcpu(v) (is_hvm_pv_evtchn_domain(v->domain))
 
xen/include/asm-x86/event.h +1 -1
diff -r f2cf898c7ff8 xen/include/asm-x86/event.h
@@ -18,7 +18,7 @@ int hvm_local_events_need_delivery(struc
 static inline int local_events_need_delivery(void)
 {
     struct vcpu *v = current;
-    return (is_hvm_vcpu(v) ? hvm_local_events_need_delivery(v) :
+    return ( is_hvm_or_hyb_vcpu(v) ? hvm_local_events_need_delivery(v) :
             (vcpu_info(v, evtchn_upcall_pending) &&
              !vcpu_info(v, evtchn_upcall_mask)));
 }
xen/include/asm-x86/guest_access.h +4 -4
diff -r f2cf898c7ff8 xen/include/asm-x86/guest_access.h
@@ -14,19 +14,19 @@
 
 /* Raw access functions: no type checking. */
 #define raw_copy_to_guest(dst, src, len)        \
-    (is_hvm_vcpu(current) ?                     \
[… more lines in the raw message]

Lines of this file are not shown. View the raw message.

xen/include/asm-x86/hvm/domain.h +3 -0
diff -r f2cf898c7ff8 xen/include/asm-x86/hvm/domain.h

Lines of this file are not shown. View the raw message.

xen/include/asm-x86/hvm/hvm.h +2 -0
diff -r f2cf898c7ff8 xen/include/asm-x86/hvm/hvm.h

Lines of this file are not shown. View the raw message.

xen/include/asm-x86/hvm/vmx/vmx.h +46 -0

46 lines not on this page · raw message

xen/include/public/domctl.h +6 -0
diff -r f2cf898c7ff8 xen/include/public/domctl.h

Lines of this file are not shown. View the raw message.

xen/include/public/xen.h +1 -0
diff -r f2cf898c7ff8 xen/include/public/xen.h

Lines of this file are not shown. View the raw message.

xen/include/xen/lib.h +13 -0
diff -r f2cf898c7ff8 xen/include/xen/lib.h

Lines of this file are not shown. View the raw message.

xen/include/xen/sched.h +11 -0
diff -r f2cf898c7ff8 xen/include/xen/sched.h

Lines of this file are not shown. View the raw message.

xen/include/xen/xencomm.h +1 -1
diff -r f2cf898c7ff8 xen/include/xen/xencomm.h

Lines of this file are not shown. View the raw message.

xen/kdb/kdb_cmds.c +118 -79

197 lines not on this page · raw message

xen/kdb/kdb_io.c +1 -1
diff -r f2cf898c7ff8 xen/kdb/kdb_io.c

Lines of this file are not shown. View the raw message.

xen/kdb/kdbmain.c +15 -8
diff -r f2cf898c7ff8 xen/kdb/kdbmain.c

Lines of this file are not shown. View the raw message.

xen/kdb/x86/udis86-1.7/kdb_dis.c +2 -0
diff -r f2cf898c7ff8 xen/kdb/x86/udis86-1.7/kdb_dis.c

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

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

Part of the diff is not shown here. View the raw message.

#28 lore raw
Quoted 2 lines · Mukesh Rathor

Alright, got hybrid with EPT numbers in now from my prototype, it needs some perf work..

Is HVM a PV on HVM guest or a pure HVM guest (no CONFIG_XEN)?

Quoted 10 lines

Processor, Processes - times in microseconds - smaller is better
------------------------------------------------------------------------------
Host OS Mhz null null open slct sig sig fork exec sh
call I/O stat clos TCP inst hndl proc proc proc
--------- ------------- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----

PV        Linux 2.6.39f 2639 0.65 0.88 2.14 4.59 3.77 0.79 3.62 535. 1294 3308
Hybrid    Linux 2.6.39f 2639 0.13 0.21 0.89 1.96 3.08 0.24 1.10 529. 1294 3246
HVM       Linux 2.6.39f 2639 0.12 0.21 0.64 1.76 3.04 0.24 3.37 113. 354. 1324

Baremetal Linux 2.6.39+ 2649 0.13 0.23 0.74 1.93 3.46 0.28 1.58 127. 386. 1434
HYB-EPT Linux 2.6.39f 2639 0.13 0.21 0.68 1.95 3.04 0.25 3.09 145. 452. 1542

good, hybrid == HVM in this test

[...]

Quoted 10 lines

Context switching - times in microseconds - smaller is better
-------------------------------------------------------------------------
Host OS 2p/0K 2p/16K 2p/64K 8p/16K 8p/64K 16p/16K 16p/64K
ctxsw ctxsw ctxsw ctxsw ctxsw ctxsw ctxsw
--------- ------------- ------ ------ ------ ------ ------ ------- -------

PV        Linux 2.6.39f 5.2800 5.7600 6.3600 6.3200 7.3600 6.69000 7.46000
Hybrid    Linux 2.6.39f 4.9200 4.9300 5.2200 5.7600 6.9600 6.12000 7.31000
HVM       Linux 2.6.39f 1.3100 1.2200 1.6200 1.9200 3.2600 2.23000 3.48000

Baremetal Linux 2.6.39+ 1.5500 1.4100 2.0600 2.2500 3.3900 2.44000 3.38000
HYB-EPT Linux 2.6.39f 3.2000 3.6100 4.1700 4.3600 6.1200 4.81000 6.20000

How is it possible that the HYB-EPT numbers here are so much worse than HVM? Shouldn't they be the same as in the other tests?

Quoted 16 lines

*Local* Communication latencies in microseconds - smaller is better
---------------------------------------------------------------------
Host OS 2p/0K Pipe AF UDP RPC/ TCP RPC/ TCP
ctxsw UNIX UDP TCP conn
--------- ------------- ----- ----- ---- ----- ----- ----- ----- ----

PV        Linux 2.6.39f 5.280  16.6 21.3  25.9  33.7  34.7  41.8  87.
Hybrid    Linux 2.6.39f 4.920  11.2 14.4  19.6  26.1  27.5  32.9  71.
HVM       Linux 2.6.39f 1.310 4.416 6.15 9.386  14.8  15.8  20.1  45.
Baremetal Linux 2.6.39+ 1.550 4.625 7.34  14.3  19.8  21.4  26.4  66.
HYB-EPT   Linux 2.6.39f 3.200 8.669 15.3  17.5  23.5  25.1  30.4  66.

*Local* Communication bandwidths in MB/s - bigger is better
-----------------------------------------------------------------------------
Host OS Pipe AF TCP File Mmap Bcopy Bcopy Mem Mem
UNIX reread reread (libc) (hand) read write
--------- ------------- ---- ---- ---- ------ ------ ------ ------ ---- -----

Quoted 5 lines
PV        Linux 2.6.39f 1661 2081 1041 3293.3 5528.3 3106.6 2800.0 4472 5633.
Hybrid    Linux 2.6.39f 1974 2450 1183 3481.5 5529.6 3114.9 2786.6 4470 5672.
HVM       Linux 2.6.39f 3232 2929 1622 3541.3 5527.5 3077.1 2765.6 4453 5634.

Baremetal Linux 2.6.39+ 3320 2800 1666 3523.6 5578.9 3147.0 2841.6 4541 5752.
HYB-EPT Linux 2.6.39f 2104 2480 1231 3451.5 5503.4 3067.7 2751.0 4438 5636.

same on these two tests

Quoted 1 line

Attaching the diffs from my prototype. Linux: 2.6.39. Xen 4.0.2.

lin.diff:

Quoted 139 lines
arch/x86/xen/enlighten.c +76 -4
index e3c6a06..53ceae0 100644
@@ -110,7 +110,7 @@ struct shared_info *HYPERVISOR_shared_info = (void *)&xen_dummy_shared_info;
  *
  * 0: not available, 1: available
  */
-static int have_vcpu_info_placement = 1;
+static int have_vcpu_info_placement = 0;
 
 static void clamp_max_cpus(void)
 {
@@ -195,6 +195,13 @@ static void __init xen_banner(void)
 	printk(KERN_INFO "Xen version: %d.%d%s%s\n",
 	       version >> 16, version & 0xffff, extra.extraversion,
 	       xen_feature(XENFEAT_mmu_pt_update_preserve_ad) ? " (preserve-AD)" : "");
+
+        if (xen_hybrid_domain()) {
+	        printk(KERN_INFO "MUK: is MUK HYBRID domain....");
+		if (xen_feature(XENFEAT_auto_translated_physmap))
+                	printk(KERN_INFO "with EPT...");
+        	printk(KERN_INFO "\n");
+        }
 }
 
 static __read_mostly unsigned int cpuid_leaf1_edx_mask = ~0;
@@ -222,8 +229,10 @@ static void xen_cpuid(unsigned int *ax, unsigned int *bx,
 		maskebx = 0;
 		break;
 	}
-
-	asm(XEN_EMULATE_PREFIX "cpuid"
+        if (xen_hybrid_domain()) {
+                native_cpuid(ax, bx, cx, dx);
+        } else
+	        asm(XEN_EMULATE_PREFIX "cpuid"
 		: "=a" (*ax),
 		  "=b" (*bx),
 		  "=c" (*cx),
@@ -244,6 +253,7 @@ static __init void xen_init_cpuid_mask(void)
 		~((1 << X86_FEATURE_MCE)  |  /* disable MCE */
 		  (1 << X86_FEATURE_MCA)  |  /* disable MCA */
 		  (1 << X86_FEATURE_MTRR) |  /* disable MTRR */
+                  (1 << X86_FEATURE_PSE)  |  /* disable 2M pages */
 		  (1 << X86_FEATURE_ACC));   /* thermal monitoring */
 
 	if (!xen_initial_domain())
@@ -393,6 +403,10 @@ static void xen_load_gdt(const struct desc_ptr *dtr)
 		make_lowmem_page_readonly(virt);
 	}
 
+        if (xen_hybrid_domain()) {
+                native_load_gdt(dtr);
+                return;
+        }
 	if (HYPERVISOR_set_gdt(frames, size / sizeof(struct desc_struct)))
 		BUG();
 }
@@ -431,6 +445,10 @@ static __init void xen_load_gdt_boot(const struct desc_ptr *dtr)
 		frames[f] = mfn;
 	}
 
+        if (xen_hybrid_domain()) {
+                native_load_gdt(dtr);
+                return;
+        }
 	if (HYPERVISOR_set_gdt(frames, size / sizeof(struct desc_struct)))
 		BUG();
 }
@@ -849,9 +867,11 @@ void xen_setup_shared_info(void)
 
 		HYPERVISOR_shared_info =
 			(struct shared_info *)fix_to_virt(FIX_PARAVIRT_BOOTMAP);
-	} else
+	} else {
 		HYPERVISOR_shared_info =
 			(struct shared_info *)__va(xen_start_info->shared_info);
+        	return;
+	}
 
 #ifndef CONFIG_SMP
 	/* In UP this is as good a place as any to set up shared info */
@@ -944,6 +964,71 @@ static const struct pv_init_ops xen_init_ops __initdata = {
 	.patch = xen_patch,
 };
 
+extern void native_iret(void);
+extern void native_irq_enable_sysexit(void);
+extern void native_usergs_sysret32(void);
+extern void native_usergs_sysret64(void);
+
+static const struct pv_cpu_ops xen_hybrid_cpu_ops __initdata = {
+	.cpuid = xen_cpuid,
+	.set_debugreg = xen_set_debugreg,
+	.get_debugreg = xen_get_debugreg,
+
+	.clts = xen_clts,
+
+	.read_cr0 = xen_read_cr0,
+	.write_cr0 = xen_write_cr0,
+
+	.read_cr4 = native_read_cr4,
+	.read_cr4_safe = native_read_cr4_safe,
+	.write_cr4 = native_write_cr4,
+
+	.wbinvd = native_wbinvd,
+
+	.read_msr = native_read_msr_safe,
+	.write_msr = native_write_msr_safe,
+	.read_tsc = native_read_tsc,
+	.read_pmc = native_read_pmc,
+
+	.iret = native_iret,
+	.irq_enable_sysexit = native_irq_enable_sysexit,
+#ifdef CONFIG_X86_64
+	.usergs_sysret32 = native_usergs_sysret32,
+	.usergs_sysret64 = native_usergs_sysret64,
+#endif
+
+	.load_tr_desc = native_load_tr_desc,
+	.set_ldt = native_set_ldt,
+	.load_gdt = native_load_gdt,
+	.load_idt = native_load_idt,
+	.load_tls = native_load_tls,
+#ifdef CONFIG_X86_64
+	.load_gs_index = native_load_gs_index,
+#endif
+
+	.alloc_ldt = paravirt_nop,
+	.free_ldt = paravirt_nop,
+
+	.store_gdt = native_store_gdt,
+	.store_idt = native_store_idt,
+	.store_tr = native_store_tr,
+
+	.write_ldt_entry = native_write_ldt_entry,
+	.write_gdt_entry = native_write_gdt_entry,
+	.write_idt_entry = native_write_idt_entry,

arch/x86/xen/enlighten.c static const struct pv_init_ops xen_init_ops __initdata = { · line 1028

Quoted 10 lines
arch/x86/xen/enlighten.c +10 -0
+	.load_sp0 = native_load_sp0,
+
+	.set_iopl_mask = native_set_iopl_mask,
+	.io_delay = xen_io_delay,
+
+	/* Xen takes care of %gs when switching to usermode for us */
+	.swapgs = native_swapgs,
+
+	.start_context_switch = paravirt_start_context_switch,
+	.end_context_switch = xen_end_context_switch,

why are you using the paravirt version of start_context_switch and end_context_switch? Is this for the non-autotranslate version?

Quoted 48 lines
arch/x86/xen/enlighten.c +19 -1
+};
+
 static const struct pv_cpu_ops xen_cpu_ops __initdata = {
 	.cpuid = xen_cpuid,
 
@@ -1010,6 +1095,11 @@ static const struct pv_apic_ops xen_apic_ops __initdata = {
 #endif
 };
 
+static void __init xen_hybrid_override_autox_cpu_ops(void)
+{
+        pv_cpu_ops.cpuid = xen_cpuid;
+}
+
 static void xen_reboot(int reason)
 {
 	struct sched_shutdown r = { .reason = reason };
@@ -1071,6 +1161,10 @@ static const struct machine_ops __initdata xen_machine_ops = {
  */
 static void __init xen_setup_stackprotector(void)
 {
+        if (xen_hybrid_domain()) {
+                switch_to_new_gdt(0);
+                return;
+        }
 	pv_cpu_ops.write_gdt_entry = xen_write_gdt_entry_boot;
 	pv_cpu_ops.load_gdt = xen_load_gdt_boot;
 
@@ -1093,14 +1187,22 @@ asmlinkage void __init xen_start_kernel(void)
 
 	xen_domain_type = XEN_PV_DOMAIN;
 
+	xen_setup_features();
 	xen_setup_machphys_mapping();
 
 	/* Install Xen paravirt ops */
 	pv_info = xen_info;
 	pv_init_ops = xen_init_ops;
-	pv_cpu_ops = xen_cpu_ops;
 	pv_apic_ops = xen_apic_ops;
 
+        if (xen_hybrid_domain()) {
+	        if (xen_feature(XENFEAT_auto_translated_physmap))
+                        xen_hybrid_override_autox_cpu_ops();
+                else
+	        	pv_cpu_ops = xen_hybrid_cpu_ops;
+        } else
+	        pv_cpu_ops = xen_cpu_ops;

[...]

Quoted 10 lines

void __init xen_init_mmu_ops(void)
{

arch/x86/xen/enlighten.c +6 -0
+	memset(dummy_mapping, 0xff, PAGE_SIZE);
+	x86_init.paging.pagetable_setup_done = xen_pagetable_setup_done;
+
+	if (xen_feature(XENFEAT_auto_translated_physmap))
+        	return;
+
 	x86_init.mapping.pagetable_reserve = xen_mapping_pagetable_reserve;
 	x86_init.paging.pagetable_setup_start = xen_pagetable_setup_start;

arch/x86/xen/enlighten.c

Quoted 10 lines
arch/x86/xen/enlighten.c +3 -3
-	x86_init.paging.pagetable_setup_done = xen_pagetable_setup_done;
-	pv_mmu_ops = xen_mmu_ops;
+        pv_mmu_ops = xen_mmu_ops;
 
-	memset(dummy_mapping, 0xff, PAGE_SIZE);
+        if (xen_hybrid_domain())      /* hybrid without EPT, ie, pv paging. */
+		xen_hyb_override_mmu_ops();
 }
 
 /* Protected by xen_reservation_lock. */

So in theory HYB-EPT is running with native_cpu_ops and native_mmu_ops; in this case I don't understand why the performances are lower than HVM.

#29 lore raw
Quoted 5 lines · On Fri, 18 Nov 2011 12:21:19 +0000 Stefano Stabellini…
Quoted 2 lines · Mukesh Rathor

Alright, got hybrid with EPT numbers in now from my prototype, it needs some perf work..

Is HVM a PV on HVM guest or a pure HVM guest (no CONFIG_XEN)?

PV on HVM.

Quoted 2 lines

How is it possible that the HYB-EPT numbers here are so much worse than HVM? Shouldn't they be the same as in the other tests?

Yeah I know. I wondered that myself. I need to investigate.

Quoted 2 lines

why are you using the paravirt version of start_context_switch and end_context_switch? Is this for the non-autotranslate version?

this is for non-autotranslate version.

Quoted 4 lines

So in theory HYB-EPT is running with native_cpu_ops and native_mmu_ops; in this case I don't understand why the performances are lower than HVM.

Yup, same here. I'll have to investigate to see whats going on. Keep you posted. I am working on SMP now, then I'll take a look.

thanks,
Mukesh