Initial support for HVM compat guests
A message that is not in the archive (sent off-list or not yet received): [email protected]
Curious about "HVM compat" here? :-) I can't get exact meaning simply by following change. Is it an exact new model, since 32bit HVM guests are already supported on 64bit xen? Or it means a compat-dom0 coupled with 32bit HVM? Or something like to reuse new compat layer for HVM side if translation required?
Thanks,
Kevin
Quoted 120 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Xen patchbot-unstable
Sent: 2007年1月6日 4:56
To: [email protected]
Subject: [Xen-changelog] [xen-unstable] Initial support for HVM compat guests# HG changeset patch
# User Emmanuel Ackaouy <[email protected]> # Date 1168019467 0
# Node ID23dcc167b97efba1c81c51bd0d6adb094c80d013# Parent1b7ebd25fa40cf603910f1ffc7d59eba03050da1Initial support for HVM compat guestsSigned-off-by Emmanuel Ackaouy <[email protected]>---
xen/arch/x86/domain.c | 6 +++++- xen/arch/x86/hvm/intercept.c | 2 +- xen/arch/x86/mm/shadow/multi.c | 1 - xen/arch/x86/x86_64/compat/entry.S | 4 ++-- xen/include/public/hvm/ioreq.h | 5 +++-- 5 files changed, 11 insertions(+), 7 deletions(-)diff -r
1b7ebd25fa40-r23dcc167b97exen/arch/x86/domain.cxen/arch/x86/domain.c +5
-1@@ -1395,7 +1395,11 @@ void domain_relinquish_resources(struct#ifdef CONFIG_COMPAT if (IS_COMPAT (d) ) { - pfn =l4e_get_pfn (*(l4_pgentry_t *)__va(pagetable_get_paddr(v->arch.guest_table))); +if (is_hvm_vcpu (v) ) + pfn =pagetable_get_pfn (v->arch.guest_table); +else + pfn =l4e_get_pfn (*(l4_pgentry_t *)__va (pagetable_get_paddr (v->arch.guest_table))); +if ( pfn !=0 ){
if (shadow_mode_refcounts(d))
diff -r1b7ebd25fa40-r23dcc167b97exen/arch/x86/hvm/intercept.cxen/arch/x86/hvm/intercept.c +0
-0@@ -182,7 +182,7 @@ int hvm_buffered_io_intercept(ioreq_t *pspin_lock (buffered_io_lock); if ( buffered_iopage->write_pointer -
buffered_iopage->read_pointer==xen/arch/x86/hvm/intercept.c +1
-1- (unsigned long)IOREQ_BUFFER_SLOT_NUM ) { + (unsigned int)IOREQ_BUFFER_SLOT_NUM ) {/* the queue is full. * send the iopacket through the normal path. * NOTE: The arithimetic operation could handle the situation for
diff -r1b7ebd25fa40-r23dcc167b97exen/arch/x86/mm/shadow/multi.cxen/arch/x86/mm/shadow/multi.c +1
-1+0000 @@ -2106,7 +2106,6 @@ void sh_destroy_monitor_table(struct vcpshadow_free (d,_mfn (l3e_get_pfn (l3e[3 ]))); sh_unmap_domain_page(l3e); } -shadow_free (d, mmfn);sh_unmap_domain_page (l4e); }#elif CONFIG_PAGING_LEVELS == 3diff -r
1b7ebd25fa40-r23dcc167b97exen/arch/x86/x86_64/compat/entry.S
---a/xen/arch/x86/x86_64/compat/entry.SFri Jan 05 17:46:14 2007
+0000
+++b/xen/arch/x86/x86_64/compat/entry.SFri Jan 05 17:51:07
2007 +0000xen/arch/x86/mm/shadow/multi.c +2
-2@@ -313,7 +313,7 @@ ENTRY(compat_hypercall_table) .quad compat_xenoprof_op .quad do_event_channel_op .quad compat_physdev_op - .quad compat_ni_hypercall + .quad do_hvm_op .quad compat_sysctl /* 35 */ .quad compat_domctl .quad compat_kexec_op@@ -356,7 +356,7 @@ ENTRY(compat_hypercall_args_table) .byte 2 /* compat_xenoprof_op */ .byte 2 /* compat_event_channel_op */ .byte 2 /* compat_physdev_op */ - .byte 0 /* compat_ni_hypercall */ + .byte 2 /* do_hvm_op */ .byte 1 /* compat_sysctl */ /* 35 */ .byte 1 /* compat_domctl */ .byte 2 /* compat_kexec_op */diff -r
1b7ebd25fa40-r23dcc167b97exen/include/public/hvm/ioreq.hxen/include/public/hvm/ioreq.h +3
-2@@ -56,6 +56,7 @@ struct ioreq { uint8_t dir:1; /* 1=read, 0=write */ uint8_t df:1;uint8_t type;/* I/O type */ +uint8_t _pad0[6 ];uint64_t io_count;/* How many IO done on a vcpu */ };typedef struct ioreq ioreq_t ;@@ -74,8 +75,8 @@ typedef struct shared_iopage shared_iopa#define IOREQ_BUFFER_SLOT_NUM 80struct buffered_iopage { -unsigned long read_pointer; -unsigned long write_pointer; +unsigned int read_pointer; +unsigned int write_pointer;ioreq_t ioreq[IOREQ_BUFFER_SLOT_NUM ]; };/* sizeof this structure must be in one page */ typedef struct buffered_iopage buffered_iopage_t ;_______________________________________________
Xen-changelog mailing list
[email protected]
http://lists.xensource.com/xen-changelog
Quoted 3 lines · Kevin
Or it means a
compat-dom0 coupled with 32bit HVM? Or something like to reuse new compat layer for HVM side if translation required?
Both of the above.
-- Keir
Quoted 5 lines
From: Keir Fraser [mailto:[email protected]]
Sent: 2007年1月15日 15:43On 15/1/07 6:31 am, "Tian, Kevin" <[email protected]> wrote:
Quoted 7 lines
Quoted 3 lines
Or it means a
compat-dom0 coupled with 32bit HVM? Or something like to reuse new compat layer for HVM side if translation required?Both of the above.
-- Keir
So is this still on development for HVM? I didn't find where _DOMF_COMPAT is set for 32bit HVM guest, and then compat logic under is_hvm_vcpu may not make effect yet. (Correct me if I'm wrong)
Other incompleteness is like, XLAT_cpu_user_regs is invoked after hvm_store_cpu_guest_regs in arch_get_info_guest, while arch_set_info_guest invokes hvm_load_cpu_guest_regs directly, etc.
Also, one question is whether COMPAT mode requires all guests to be in compatible, or can be mixed like 64bit dom0 + 32bit domU. Still take arch_get_info_guest for example:
Vcpu_guest_context is translated if target domain is compat
mode, while there's no check for current domain's mode. Then compat context is copied back to dom0 even when dom0 is a 64bit guest.
Are things like above deliberately made to depend on dom0 aware of target guest context layout, or something still immature? I just want to get a clear picture what impact this new compatible mode may bring to the whole environment. :-)
Thanks,
Kevin
Quoted 4 lines · Kevin
So is this still on development for HVM? I didn't find where
_DOMF_COMPATis set for 32bit HVM guest, and then compat logic underis_hvm_vcpumay not make effect yet. (Correct me if I'm wrong)
An HVM guest does not use DOMF_COMPAT. You can deduce its execution mode from CS attribute bytes. And of course it can switch execution mode back and forth as it runs, and on different VCPUs, etc.
Quoted 4 lines
Other incompleteness is like,
XLAT_cpu_user_regsis invoked afterhvm_store_cpu_guest_regsinarch_get_info_guest, whilearch_set_info_guestinvokeshvm_load_cpu_guest_regsdirectly, etc.
Yes, that's an incompleteness. Stuff is getting implemented on demand. Noone uses arch_set_info_guest() on an HVM guest, but xc_ptrace() does use arch_get_info_guest() so I guess Jan fixed that one up.
Quoted 7 lines
Also, one question is whether COMPAT mode requires all guests to be in compatible, or can be mixed like 64bit dom0 + 32bit domU. Still take
arch_get_info_guestfor example:
Vcpu_guest_contextis translated if target domain is compat
mode, while there's no check for current domain's mode. Then compat context is copied back to dom0 even when dom0 is a 64bit guest.
Currently we require all guests to be in the same mode. However, there are tools changes in progress to allow mixed-mode guests. Checking COMPAT of caller vs. target is indeed a bit confusing. We'll audit the domctl interfaces and make up our mind how that should work when we apply the tools changes for mixed-mode guests.
Quoted 4 lines
Are things like above deliberately made to depend on dom0 aware of target guest context layout, or something still immature? I just want to get a clear picture what impact this new compatible mode may bring to the whole environment. :-)
dom0 must be aware of target guest context. It builds the page tables for example. :-) So it is acceptable for him to have to use different domctl() commands to initialise 32- vs 64-bit pv guests (although we obviously want to avoid bloating the interface with compat crap as far as possible).
-- Keir
Quoted 11 lines
-----Original Message-----
From: Keir Fraser [mailto:[email protected]]
Sent: 2007年1月15日 16:17Quoted 4 lines · Kevin
So is this still on development for HVM? I didn't find where
_DOMF_COMPATis set for 32bit HVM guest, and then compat logic underis_hvm_vcpumay not make effect yet. (Correct me if I'm wrong)
Quoted 5 lines
An HVM guest does not use
DOMF_COMPAT. You can deduce its execution mode
from CS attribute bytes. And of course it can switch execution mode back and
forth as it runs, and on different VCPUs, etc.
So what's the proposed way to reuse compat code for HVM guest? Extend IS_COMPAT() to cover HVM domain even when DOMF_COMPAT is not set, or invoke compatible layer directly when required. In any case, I just didn't see why IS_COMPAT() branch is placed under is_hvm_vcpu for now. :-)
Thanks for you kind answer on other questions.
- Kevin
Quoted 11 lines · Kevin
Quoted 5 lines
An HVM guest does not use
DOMF_COMPAT. You can deduce its execution mode
from CS attribute bytes. And of course it can switch execution mode back and
forth as it runs, and on different VCPUs, etc.So what's the proposed way to reuse compat code for HVM guest? Extend
IS_COMPAT()to cover HVM domain even whenDOMF_COMPATis not set, or invoke compatible layer directly when required. In any case, I just didn't see whyIS_COMPAT()branch is placed underis_hvm_vcpufor now. :-)
Hmmm there is underlying code shared by both compat and native hypercall layer that will check IS_COMPAT. So jumping at the compat layer is insufficient (even though that is precisely what the hvm hypercall wrapper does).
Basically this work isn't complete yet. Probably what will happen is that the IS_COMPAT() test will be made per-vcpu rather than per-domain and we will set the per-vcpu flag correctly for an hvm guest at least whenever it vmexits for a hypercall. Or we will make IS_COMPAT() look at shadow-mode guest_levels if it is invoked on an HVM vcpu.
-- Keir
Quoted 18 lines
From: Keir Fraser [mailto:[email protected]]
Sent: 2007年1月15日 16:39Hmmm there is underlying code shared by both compat and native hypercall
layer that will checkIS_COMPAT. So jumping at the compat layer is insufficient (even though that is precisely what the hvm hypercall wrapper
does).Basically this work isn't complete yet. Probably what will happen is that the
IS_COMPAT()test will be made per-vcpu rather than per-domain and we
will set the per-vcpu flag correctly for an hvm guest at least whenever it vmexits for a hypercall. Or we will makeIS_COMPAT()look at shadow-modeguest_levelsif it is invoked on an HVM vcpu.
Quoted 1 line
-- Keir
OK, the status is clearer to me now. Thanks a lot,
- Kevin