Su, Disheng
2008-Feb-01 06:24 UTC
[Xen-devel] [PATCH 3/4] Enable VirtualPC 2007 run on top of XEN: REPS prefix emulation
REPS prefix emulation for INS and OUTS is already in xen. Can we enable REPS for "stos" and "movs" in paging mode? Although it doesn''t benefit a lot for normal hvm guest, in virtualpc case, I have to do that. VirtualPC will call "reps stos"(ecx=0x400, eax=0) a lot, about 1000 times per second. It seems to clear a L1 page table page, it can''t be fast unshadowed in check_for_early_unshadow and it''s even ReadOnly in guest page table(CR0.wp = 0). So we get 0x400 * 1000 times page faults per second, so CPU cycle is almost wasted on it. Reviewed-by: Kevin Tian <kevin.tian@intel.com> Signed-off-by: Disheng Su <disheng.su.com> _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Tim Deegan
2008-Feb-01 09:36 UTC
Re: [Xen-devel] [PATCH 3/4] Enable VirtualPC 2007 run on top of XEN: REPS prefix emulation
Hi, At 14:24 +0800 on 01 Feb (1201875864), Su, Disheng wrote:> REPS prefix emulation for INS and OUTS is already in xen. Can we enable > REPS for "stos" and "movs" in paging mode? Although it doesn''t benefit a > lot for normal hvm guest, in virtualpc case, I have to do that. > VirtualPC will call "reps stos"(ecx=0x400, eax=0) a lot, about 1000 > times per second. It seems to clear a L1 page table page, it can''t be > fast unshadowed in check_for_early_unshadow and it''s even ReadOnly in > guest page table(CR0.wp = 0). So we get 0x400 * 1000 times page faults > per second, so CPU cycle is almost wasted on it.This patch looks fine to me; I''ll let Keir decide whether the extra 200 lines or so of shadow/emulate code is worthwhile for running VPC under Xen. Keir, even if we don''t take this, please do take this hunk: diff -r 05b3bdb3b7fa xen/arch/x86/mm/shadow/multi.c --- a/xen/arch/x86/mm/shadow/multi.c Wed Jan 30 00:09:03 2008 +0800 +++ b/xen/arch/x86/mm/shadow/multi.c Wed Jan 30 00:09:04 2008 +0800 @@ -4076,8 +4091,8 @@ static void *emulate_map_dest(struct vcp sh_ctxt->mfn2 = emulate_gva_to_mfn(v, (vaddr + bytes - 1) & PAGE_MASK, sh_ctxt); if ( !mfn_valid(sh_ctxt->mfn2) ) - return ((mfn_x(sh_ctxt->mfn1) == BAD_GVA_TO_GFN) ? + return ((mfn_x(sh_ctxt->mfn2) == BAD_GVA_TO_GFN) ? MAPPING_EXCEPTION : MAPPING_UNHANDLEABLE); /* Cross-page writes mean probably not a pagetable */ sh_remove_shadows(v, sh_ctxt->mfn2, 0, 0 /* Slow, can fail */ ); Cheers, Tim. -- Tim Deegan <Tim.Deegan@citrix.com> Principal Software Engineer, Citrix Systems (R&D) Ltd. [Company #02300071, SL9 0DZ, UK.] _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Bruce Rogers
2008-Feb-01 16:12 UTC
Re: [Xen-devel] [PATCH 3/4] Enable VirtualPC 2007 run on top of XEN: REPS prefix emulation
>>> On 2/1/2008 at 2:36 AM, Tim Deegan <Tim.Deegan@citrix.com> wrote: > Hi, > > At 14:24 +0800 on 01 Feb (1201875864), Su, Disheng wrote: >> REPS prefix emulation for INS and OUTS is already in xen. Can we enable >> REPS for "stos" and "movs" in paging mode? Although it doesn''t benefit a >> lot for normal hvm guest, in virtualpc case, I have to do that. >> VirtualPC will call "reps stos"(ecx=0x400, eax=0) a lot, about 1000 >> times per second. It seems to clear a L1 page table page, it can''t be >> fast unshadowed in check_for_early_unshadow and it''s even ReadOnly in >> guest page table(CR0.wp = 0). So we get 0x400 * 1000 times page faults >> per second, so CPU cycle is almost wasted on it. > > This patch looks fine to me; I''ll let Keir decide whether the extra 200 > lines or so of shadow/emulate code is worthwhile for running VPC under Xen. > > Keir, even if we don''t take this, please do take this hunk: > > diff -r 05b3bdb3b7fa xen/arch/x86/mm/shadow/multi.c > --- a/xen/arch/x86/mm/shadow/multi.c Wed Jan 30 00:09:03 2008 +0800 > +++ b/xen/arch/x86/mm/shadow/multi.c Wed Jan 30 00:09:04 2008 +0800 > @@ -4076,8 +4091,8 @@ static void *emulate_map_dest(struct vcp > sh_ctxt->mfn2 = emulate_gva_to_mfn(v, (vaddr + bytes - 1) & PAGE_MASK, > sh_ctxt); > if ( !mfn_valid(sh_ctxt->mfn2) ) > - return ((mfn_x(sh_ctxt->mfn1) == BAD_GVA_TO_GFN) ? > + return ((mfn_x(sh_ctxt->mfn2) == BAD_GVA_TO_GFN) ? > MAPPING_EXCEPTION : MAPPING_UNHANDLEABLE); > > /* Cross-page writes mean probably not a pagetable */ > sh_remove_shadows(v, sh_ctxt->mfn2, 0, 0 /* Slow, can fail */ ); > > Cheers, > > Tim.If I could chime in here, I''m all for better support of CR0.WP = 0 guests. NetWare has traditionally run in this mode, and although we''ve recently made it capable of running with WP bit set as part of the paravirtualization effort, there would be benefit to running older versions as HVM guests. I haven''t had the cycles myself to work on that, but with all the other changes to real mode support, it looks like we''re really close to having NetWare run fully virtualized. (Another gottcha is that we write the debug registers in real mode, but that should be a fairly simple hypervisor fix.) Thanks to everyone who has worked on getting HVM support more robust. - Bruce _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel