On 10/24/2012 11:19 AM, Stefan Fritsch wrote: >> >> With the decode table fix I think it should work. > > It needs some more changes. The patch below did the trick for me. It is > against 3.5, because I didn't want to build a whole new kernel (my test > machine is a dead slow AMD E-350). > > The patch is definitely incomplete. It now allows the lock prefix for > all mov operations on the cr1-7, which should not be the case. Apart > from that, do the changes look reasonable? I have not checked that this > is the minimal patch that works. But the LockReg bit was definitely > necessary, that was the final piece to make it work. > > Cheers, > Stefan > > diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c > index 4837375..c7f0ec7 100644 > --- a/arch/x86/kvm/emulate.c > +++ b/arch/x86/kvm/emulate.c > @@ -128,6 +128,7 @@ > #define Priv (1<<27) /* instruction generates #GP if current CPL > != 0 */ > #define No64 (1<<28) > #define PageTable (1 << 29) /* instruction used to write page table */ > +#define LockReg (1<<30) /* lock prefix is allowed for the > instruction even for reg destination */ > /* Source 2 operand type */ > #define Src2Shift (30) LockReg conflicts with Src2Shift. > #define Src2None (OpNone << Src2Shift) > @@ -420,6 +421,7 @@ static int emulator_check_intercept(struct > x86_emulate_ctxt *ctxt, > struct x86_instruction_info info = { > .intercept = intercept, > .rep_prefix = ctxt->rep_prefix, > + .lock_prefix = ctxt->lock_prefix, > .modrm_mod = ctxt->modrm_mod, > .modrm_reg = ctxt->modrm_reg, > .modrm_rm = ctxt->modrm_rm, > @@ -2874,7 +2876,10 @@ static int em_mov(struct x86_emulate_ctxt *ctxt) > > static int em_cr_write(struct x86_emulate_ctxt *ctxt) > { > - if (ctxt->ops->set_cr(ctxt, ctxt->modrm_reg, ctxt->src.val)) > + int cr = ctxt->modrm_reg; Blank line here. > + if (ctxt->lock_prefix && cr == 0) > + cr = 8; But maybe this is better dealt with during general decode, and ctxt->modrm_reg adjusted instead. This removes the code triplicstion. Please also #UD if modrm_reg != 0, and if the feature is not exposed to the guest via cpuid. Please regenerate against kvm.git next, there have been changes to emulate.c. -- error compiling committee.c: too many arguments to function -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html