From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marcelo Tosatti Subject: Re: KVM: x86: use proper port value when checking io instruction permission (v3) Date: Mon, 30 May 2011 15:23:29 -0300 Message-ID: <20110530182329.GB2719@amt.cnet> References: <20110524171120.GA19906@amt.cnet> <20110524172706.GC22042@redhat.com> <20110525181820.GA14921@amt.cnet> <4DDDF3D6.3000505@redhat.com> <20110526115605.GA29882@amt.cnet> <4DE20523.7080707@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Gleb Natapov , kvm , Joerg Roedel To: Avi Kivity Return-path: Received: from mx1.redhat.com ([209.132.183.28]:30007 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757648Ab1E3SZX (ORCPT ); Mon, 30 May 2011 14:25:23 -0400 Content-Disposition: inline In-Reply-To: <4DE20523.7080707@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On Sun, May 29, 2011 at 11:34:43AM +0300, Avi Kivity wrote: > On 05/26/2011 02:56 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. > > > >diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c > >index 3bc6b7a..fc3d2d9 100644 > >--- a/arch/x86/kvm/emulate.c > >+++ b/arch/x86/kvm/emulate.c > >@@ -47,7 +47,7 @@ > > #define DstDI (5<<1) /* Destination is in ES:(E)DI */ > > #define DstMem64 (6<<1) /* 64bit memory operand */ > > #define DstImmUByte (7<<1) /* 8-bit unsigned immediate operand */ > >-#define DstMask (7<<1) > >+#define DstMask ((7<<1) | (1<<18)) > > Ouch, why?? > > My comment about bits 19-20 was only about the shifting of of Prot > etc. from 21+ to 22+. Oh, OK, please check v4.