From mboxrd@z Thu Jan 1 00:00:00 1970 From: Shriram Rajagopalan Subject: Re: xl/xm save -c fails - set_vcpucontext EOPNOTSUPP (was Re: xl save -c issues with Windows 7 Ultimate) Date: Mon, 16 May 2011 21:48:23 -0400 Message-ID: References: <1305016915.26692.261.camel@zakaz.uk.xensource.com> <4DC96FA50200007800040C69@vpn.id2.novell.com> <4DC97E000200007800040CFF@vpn.id2.novell.com> <4DCA5B3A0200007800040EC4@vpn.id2.novell.com> <4DCD1D4702000078000413D0@vpn.id2.novell.com> <4DD12E8202000078000417CD@vpn.id2.novell.com> Reply-To: rshriram@cs.ubc.ca Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1308963613==" Return-path: In-Reply-To: <4DD12E8202000078000417CD@vpn.id2.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Jan Beulich Cc: "xen-devel@lists.xensource.com" , Keir Fraser , Ian Campbell List-Id: xen-devel@lists.xenproject.org --===============1308963613== Content-Type: multipart/alternative; boundary=bcaec52d51d704300504a36efa23 --bcaec52d51d704300504a36efa23 Content-Type: text/plain; charset=ISO-8859-1 On Mon, May 16, 2011 at 8:02 AM, Jan Beulich wrote: > >>> On 15.05.11 at 00:15, Shriram Rajagopalan wrote: > > This one works only for 64-bit domUs. 32bit domU (on 64bit dom0) fails > with > > usual EOPNOTSUPP. > > Next (hopefully final) try below. > > Jan > > --- a/xen/arch/x86/domain.c > +++ b/xen/arch/x86/domain.c > @@ -856,6 +856,15 @@ int arch_set_info_guest( > goto out; > } > > + init_int80_direct_trap(v); > + > + /* IOPL privileges are virtualised. */ > + v->arch.pv_vcpu.iopl = (v->arch.user_regs.eflags >> 12) & 3; > + v->arch.user_regs.eflags &= ~X86_EFLAGS_IOPL; > + > + /* Ensure real hardware interrupts are enabled. */ > + v->arch.user_regs.eflags |= X86_EFLAGS_IF; > + > if ( !v->is_initialised ) > { > v->arch.pv_vcpu.ldt_base = c(ldt_base); > @@ -863,11 +872,27 @@ int arch_set_info_guest( > } > else > { > - bool_t fail = v->arch.pv_vcpu.ctrlreg[3] != c(ctrlreg[3]); > + unsigned long pfn = pagetable_get_pfn(v->arch.guest_table); > + bool_t fail; > > + if ( !compat ) > + { > + fail = xen_pfn_to_cr3(pfn) != c.nat->ctrlreg[3]; > #ifdef CONFIG_X86_64 > - fail |= v->arch.pv_vcpu.ctrlreg[1] != c(ctrlreg[1]); > + if ( pagetable_is_null(v->arch.guest_table_user) ) > + fail |= c.nat->ctrlreg[1] || !(flags & VGCF_in_kernel); > + else > + { > + pfn = pagetable_get_pfn(v->arch.guest_table_user); > + fail |= xen_pfn_to_cr3(pfn) != c.nat->ctrlreg[1]; > + } > + } else { > + l4_pgentry_t *l4tab = __va(pfn_to_paddr(pfn)); > + > + pfn = l4e_get_pfn(*l4tab); > + fail = compat_pfn_to_cr3(pfn) != c.cmp->ctrlreg[3]; > #endif > + } > > for ( i = 0; i < ARRAY_SIZE(v->arch.pv_vcpu.gdt_frames); ++i ) > fail |= v->arch.pv_vcpu.gdt_frames[i] != c(gdt_frames[i]); > @@ -907,15 +932,6 @@ int arch_set_info_guest( > v->arch.pv_vcpu.ctrlreg[0] &= X86_CR0_TS; > v->arch.pv_vcpu.ctrlreg[0] |= read_cr0() & ~X86_CR0_TS; > > - init_int80_direct_trap(v); > - > - /* IOPL privileges are virtualised. */ > - v->arch.pv_vcpu.iopl = (v->arch.user_regs.eflags >> 12) & 3; > - v->arch.user_regs.eflags &= ~X86_EFLAGS_IOPL; > - > - /* Ensure real hardware interrupts are enabled. */ > - v->arch.user_regs.eflags |= X86_EFLAGS_IF; > - > cr4 = v->arch.pv_vcpu.ctrlreg[4]; > v->arch.pv_vcpu.ctrlreg[4] = cr4 ? pv_guest_cr4_fixup(v, cr4) : > real_cr4_to_pv_guest_cr4(mmu_cr4_features); > > > ok. this one works :). I ve tested with remus too :P. Can you please please spin out a patch to be pushed into the repo ? thanks for the help. shriram --bcaec52d51d704300504a36efa23 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
On Mon, May 16, 2011 at 8:02 AM, Jan Beulich <JBeulich@novell.c= om> wrote:
>>> On 15.05.11 at 00:15, Shriram Rajagopalan &l= t;rshriram@cs.ubc.ca> wrote: > This one works only for 64-bit domUs. 32bit domU (on 64bit dom0) fails= with
> usual EOPNOTSUPP.

Next (hopefully final) try below.

Jan

--- a/xen/arch/x86/domain.c
+++ b/xen/arch/x86/domain.c
@@ -856,6 +856,15 @@ int arch_set_info_guest(
=A0 =A0 =A0 =A0 goto out;
=A0 =A0 }

+ =A0 =A0init_int80_direct_trap(v);
+
+ =A0 =A0/* IOPL privileges are virtualised. */
+ =A0 =A0v->arch.pv_vcpu.iopl =3D (v->arch.user_regs.eflags >> = 12) & 3;
+ =A0 =A0v->arch.user_regs.eflags &=3D ~X86_EFLAGS_IOPL;
+
+ =A0 =A0/* Ensure real hardware interrupts are enabled. */
+ =A0 =A0v->arch.user_regs.eflags |=3D X86_EFLAGS_IF;
+
=A0 =A0 if ( !v->is_initialised )
=A0 =A0 {
=A0 =A0 =A0 =A0 v->arch.pv_vcpu.ldt_base =3D c(ldt_base);
@@ -863,11 +872,27 @@ int arch_set_info_guest(
=A0 =A0 }
=A0 =A0 else
=A0 =A0 {
- =A0 =A0 =A0 =A0bool_t fail =3D v->arch.pv_vcpu.ctrlreg[3] !=3D c(ctrlr= eg[3]);
+ =A0 =A0 =A0 =A0unsigned long pfn =3D pagetable_get_pfn(v->arch.guest_t= able);
+ =A0 =A0 =A0 =A0bool_t fail;

+ =A0 =A0 =A0 =A0if ( !compat )
+ =A0 =A0 =A0 =A0{
+ =A0 =A0 =A0 =A0 =A0 =A0fail =3D xen_pfn_to_cr3(pfn) !=3D c.nat->ctrlre= g[3];
=A0#ifdef CONFIG_X86_64
- =A0 =A0 =A0 =A0fail |=3D v->arch.pv_vcpu.ctrlreg[1] !=3D c(ctrlreg[1])= ;
+ =A0 =A0 =A0 =A0 =A0 =A0if ( pagetable_is_null(v->arch.guest_table_user= ) )
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0fail |=3D c.nat->ctrlreg[1] || !(flags = & VGCF_in_kernel);
+ =A0 =A0 =A0 =A0 =A0 =A0else
+ =A0 =A0 =A0 =A0 =A0 =A0{
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0pfn =3D pagetable_get_pfn(v->arch.guest= _table_user);
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0fail |=3D xen_pfn_to_cr3(pfn) !=3D c.nat-&= gt;ctrlreg[1];
+ =A0 =A0 =A0 =A0 =A0 =A0}
+ =A0 =A0 =A0 =A0} else {
+ =A0 =A0 =A0 =A0 =A0 =A0l4_pgentry_t *l4tab =3D __va(pfn_to_paddr(pfn)); +
+ =A0 =A0 =A0 =A0 =A0 =A0pfn =3D l4e_get_pfn(*l4tab);
+ =A0 =A0 =A0 =A0 =A0 =A0fail =3D compat_pfn_to_cr3(pfn) = !=3D c.cmp->ctrlreg[3];
=A0#endif
+ =A0 =A0 =A0 =A0}

=A0 =A0 =A0 =A0 for ( i =3D 0; i < ARRAY_SIZE(v->arch.pv_vcpu.gdt_fr= ames); ++i )
=A0 =A0 =A0 =A0 =A0 =A0 fail |=3D v->arch.pv_vcpu.gdt_frames[i] != =3D c(gdt_frames[i]);
@@ -907,15 +932,6 @@ int arch_set_info_guest(
=A0 =A0 v->arch.pv_vcpu.ctrlreg[0] &a= mp;=3D X86_CR0_TS;
=A0 =A0 v->arch.pv_vcpu.ctrlreg[0] |=3D read_cr0() & ~X86_CR0_TS;
- =A0 =A0init_int80_direct_trap(v);
-
- =A0 =A0/* IOPL privileges are virtualised. */
- =A0 =A0v->arch.pv_vcpu.iopl =3D (v->arch.user_regs.eflags >> = 12) & 3;
- =A0 =A0v->arch.user_regs.eflags &=3D ~X86_EFLAGS_IOPL;
-
- =A0 =A0/* Ensure real hardware interrupts are enabled. */
- =A0 =A0v->arch.user_regs.eflags |=3D X86_EFLAGS_IF;
-
=A0 =A0 cr4 =3D v->arch.pv_vcpu.ctrlreg[4];
=A0 =A0 v->arch.pv_vcpu.ctrlreg[4] =3D cr4 ? pv_guest_cr4_fixup(v, cr4)= :
=A0 =A0 =A0 =A0 real_cr4_to_pv_guest_cr4(mmu_cr4_features);


ok. this one works :). I ve tested with remu= s too :P. Can you please please
spin out a patch to be pushed into the r= epo ? thanks for the help.

shriram
--bcaec52d51d704300504a36efa23-- --===============1308963613== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --===============1308963613==--