[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH v4 4/6] x86emul: support VME and PVI
On 10/01/17 09:04, Jan Beulich wrote: > ... affecting POPF, CLI, and STI. There seems to be a a discrepancy in Intel documentation. Vol3 20.3.2 "Class 2—Maskable Hardware Interrupt Handling in Virtual-8086 Mode Using the Virtual Interrupt Mechanism" says "Also, if under these circumstances an 8086 program tries to read or change the IF flag using the PUSHF or POPF instructions, the processor will change the VIF flag instead, leaving IF unchanged." which clearly means that pushf/popf fold VIF into IF. This makes sense, as the entire point is to let older vm86 tasks play with the interrupt flag like they used to. The pseudocode for pushf doesn't indicate this behaviour. Looking at the AMD documentation, the pseduocode for pushf does specifically call out folding VIF into IF, and also showing IOPL as 3. > > Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx> > > --- a/xen/arch/x86/x86_emulate/x86_emulate.c > +++ b/xen/arch/x86/x86_emulate/x86_emulate.c > @@ -433,6 +433,8 @@ typedef union { > #define CR0_EM (1<<2) > #define CR0_TS (1<<3) > > +#define CR4_VME (1<<0) > +#define CR4_PVI (1<<1) > #define CR4_TSD (1<<2) > #define CR4_OSFXSR (1<<9) > #define CR4_OSXMMEXCPT (1<<10) > @@ -1178,6 +1180,15 @@ _mode_iopl( > fail_if(_iopl < 0); \ > _iopl; \ > }) > +#define mode_pvi() ({ \ > + unsigned long cr4 = 0; \ > + if ( ops->read_cr && get_cpl(ctxt, ops) == 3 ) \ > + { \ > + rc = ops->read_cr(4, &cr4, ctxt); \ > + if ( rc != X86EMUL_OKAY ) goto done; \ > + } \ > + !!(cr4 & (_regs._eflags & EFLG_VM ? CR4_VME : CR4_PVI)); \ > +}) The name mode_pvi() is misleading, because VME and PVI behave differently for everything other than cli/sti. mode_vif() would be better IMO, as it describes a condition under which VIF should be used instead of IF. ~Andrew _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |