[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH v2 10/16] x86/PV: split out dealing with CRn from privileged instruction handling
On 28/09/16 09:14, Jan Beulich wrote: > This is in preparation for using the generic emulator here. > > Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx> > > --- a/xen/arch/x86/traps.c > +++ b/xen/arch/x86/traps.c > @@ -2255,6 +2255,107 @@ unsigned long guest_to_host_gpr_switch(u > > void (*pv_post_outb_hook)(unsigned int port, u8 value); > > +static int priv_op_read_cr(unsigned int reg, unsigned long *val, > + struct x86_emulate_ctxt *ctxt) > +{ > + const struct vcpu *curr = current; > + > + switch ( reg ) > + { > + case 0: /* Read CR0 */ > + *val = (read_cr0() & ~X86_CR0_TS) | curr->arch.pv_vcpu.ctrlreg[0]; > + return X86EMUL_OKAY; > + > + case 2: /* Read CR2 */ > + case 4: /* Read CR4 */ > + *val = curr->arch.pv_vcpu.ctrlreg[reg]; > + return X86EMUL_OKAY; > + > + case 3: /* Read CR3 */ > + { > + const struct domain *currd = curr->domain; > + unsigned long mfn; Any chance of switching this to mfn_t while you are moving it? > + > + if ( !is_pv_32bit_domain(currd) ) > + { > + mfn = pagetable_get_pfn(curr->arch.guest_table); > + *val = xen_pfn_to_cr3(mfn_to_gmfn(currd, mfn)); > + } > + else > + { > + l4_pgentry_t *pl4e = > + > map_domain_page(_mfn(pagetable_get_pfn(curr->arch.guest_table))); > + > + mfn = l4e_get_pfn(*pl4e); > + unmap_domain_page(pl4e); > + *val = compat_pfn_to_cr3(mfn_to_gmfn(currd, mfn)); > + } > + /* PTs should not be shared */ > + BUG_ON(page_get_owner(mfn_to_page(mfn)) == dom_cow); > + return X86EMUL_OKAY; > + } > + } > + > + return X86EMUL_UNHANDLEABLE; > +} > + > +static int priv_op_write_cr(unsigned int reg, unsigned long val, > + struct x86_emulate_ctxt *ctxt) > +{ > + struct vcpu *curr = current; > + > + switch ( reg ) > + { > + case 0: /* Write CR0 */ > + if ( (val ^ read_cr0()) & ~X86_CR0_TS ) > + { > + gdprintk(XENLOG_WARNING, > + "Attempt to change unmodifiable CR0 flags\n"); > + break; > + } > + do_fpu_taskswitch(!!(val & X86_CR0_TS)); > + return X86EMUL_OKAY; > + > + case 2: /* Write CR2 */ > + curr->arch.pv_vcpu.ctrlreg[2] = val; > + arch_set_cr2(curr, val); > + return X86EMUL_OKAY; > + > + case 3: /* Write CR3 */ > + { > + struct domain *currd = curr->domain; > + unsigned long gfn; Similarly, gfn_t ? Reviewed-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |