From: "Jan Beulich" Subject: Re: [PATCH v2] nested VMX: fix I/O port exit emulation Date: Wed, 04 Dec 2013 07:52:50 +0000 Message-ID: <529EED620200007800109CAE@nat28.tlf.novell.com> References: <529DEE4E0200007800109691@nat28.tlf.novell.com> <529DE2D0.8090305@citrix.com> <529DF27E02000078001096DC@nat28.tlf.novell.com> <529DF37E02000078001096F9@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Vo7GU-0000tI-Fg for xen-devel@lists.xenproject.org; Wed, 04 Dec 2013 07:52:59 +0000 In-Reply-To: Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Yang Z Zhang Cc: Andrew Cooper , Matthew Daley , Eddie Dong , Jun Nakajima , xen-devel List-Id: xen-devel@lists.xenproject.org >>> On 04.12.13 at 02:51, "Zhang, Yang Z" wrote: > Jan Beulich wrote on 2013-12-03: >> @@ -2220,15 +2219,23 @@ int nvmx_n2_vmexit_handler(struct cpu_us >> if ( ctrl & CPU_BASED_ACTIVATE_IO_BITMAP ) >> { >> unsigned long qual; >> - u16 port; >> + u16 port, size; >> >> __vmread(EXIT_QUALIFICATION, &qual); >> port = qual >> 16; >> - bitmap = nvmx->iobitmap[port >> 15]; >> - if ( bitmap[(port & 0x7fff) >> 3] & (1 << (port & 0x7)) ) >> - nvcpu->nv_vmexit_pending = 1; >> + size = (qual & 7) + 1; >> + do { >> + const u8 *bitmap = nvmx->iobitmap[port >> 15]; >> + >> + if ( bitmap[(port & 0x7fff) >> 3] & (1 << (port & 7)) ) >> + nvcpu->nv_vmexit_pending = 1; >> + if ( !--size ) >> + break; >> + if ( !++port ) >> + nvcpu->nv_vmexit_pending = 1; > > If port overflow, will it cause vmexit or maybe other fault like GP or just > be ignored? The documentation is explicit here: It causes a VM exit. And hence the emulation is doing so too. > Also, you need to check the DF bit to know the string direction > before updating the port. I think Andrew already sufficiently clarified that part. Jan