From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: KVM: x86: use proper port value when checking io instruction permission (v2) Date: Thu, 26 May 2011 09:31:50 +0300 Message-ID: <4DDDF3D6.3000505@redhat.com> References: <20110524171120.GA19906@amt.cnet> <20110524172706.GC22042@redhat.com> <20110525181820.GA14921@amt.cnet> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Gleb Natapov , kvm , Joerg Roedel To: Marcelo Tosatti Return-path: Received: from mx1.redhat.com ([209.132.183.28]:31512 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752276Ab1EZGb4 (ORCPT ); Thu, 26 May 2011 02:31:56 -0400 In-Reply-To: <20110525181820.GA14921@amt.cnet> Sender: kvm-owner@vger.kernel.org List-ID: On 05/25/2011 09:18 PM, Marcelo Tosatti wrote: > Commit fa4491a6b667304 moved the permission check for io instructions > to the ->check_perm callback. It failed to copy the port value from RDX > register for string and "in,out ax,dx" instructions. > > Fix it by reading RDX register at decode stage when appropriate. > > Fixes FC8.32 installation. > > +#define Sse (1<<18) /* SSE Vector instruction */ 19/20 are still available, no need to go 64-bit just yet. > /* Misc flags */ > -#define Prot (1<<21) /* instruction generates #UD if not in prot-mode */ > > + case SrcDX: > + c->src.type = OP_REG; > + c->src.bytes = c->op_bytes; Needs to be 2. Otherwise we'll see extra bits from edx, or lose bits from dx if it's a 1-byte instruction. > + c->src.addr.reg =&c->regs[VCPU_REGS_RDX]; > + fetch_register_operand(&c->src); > + break; > } > > if (rc != X86EMUL_CONTINUE) > @@ -3649,6 +3657,12 @@ done_prefixes: > c->dst.addr.mem.seg = VCPU_SREG_ES; > c->dst.val = 0; > break; > + case DstDX: > + c->dst.type = OP_REG; > + c->dst.bytes = c->op_bytes; 2 again. > + c->dst.addr.reg =&c->regs[VCPU_REGS_RDX]; > + fetch_register_operand(&c->dst); > + break; > case ImplicitOps: > /* Special instructions do their own operand decoding. */ > default: We also need to unify Src/Dst decode eventually. -- I have a truly marvellous patch that fixes the bug which this signature is too narrow to contain.