From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Subject: Re: [PATCH] x86 emulator: Add IRET instruction Date: Wed, 28 Jul 2010 15:49:00 +0200 Message-ID: <4C50354C.3020407@redhat.com> References: <1280309920-13539-1-git-send-email-m.gamal005@gmail.com> <4C5030E2.8050202@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Mohammed Gamal , avi@redhat.com, mtosatti@redhat.com, kvm@vger.kernel.org To: unlisted-recipients:; (no To-header on input) Return-path: Received: from mail-qw0-f46.google.com ([209.85.216.46]:60483 "EHLO mail-qw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754112Ab0G1NtP (ORCPT ); Wed, 28 Jul 2010 09:49:15 -0400 Received: by qwh6 with SMTP id 6so876355qwh.19 for ; Wed, 28 Jul 2010 06:49:13 -0700 (PDT) In-Reply-To: <4C5030E2.8050202@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On 07/28/2010 03:30 PM, Paolo Bonzini wrote: > On 07/28/2010 11:38 AM, Mohammed Gamal wrote: >> + unsigned long mask = EFLG_CF | EFLG_PF | EFLG_AF | EFLG_ZF | EFLG_SF >> | EFLG_TF | >> + EFLG_IF | EFLG_DF | EFLG_OF | EFLG_IOPL | EFLG_NT | EFLG_RF | >> + EFLG_AC | EFLG_ID | (1 << 1); /* Last one is the reserved bit */ >> + unsigned long vm86_mask = EFLG_VM | EFLG_VIF | EFLG_VIP; >> ... >> + if (c->op_bytes == 4) >> + ctxt->eflags = ((temp_eflags & mask) | (ctxt->eflags & vm86_mask)); >> + else if (c->op_bytes == 2) { >> + ctxt->eflags &= ~0xffff; >> + ctxt->eflags |= temp_eflags; >> + } > > I think that's still not it. You can set reserved bits for c->op_bytes > == 2, and you can clear bit 1 for both 16- and 32-bit IRET. > > IOW you need something like this: > > mask = ...; /* without (1 << 1); */ > ctxt_mask = (1 << 1) | EFLG_VM | EFLG_VIF | EFLG_VIP; > > if (c->op_bytes == 2) { > mask &= 0xffff; > ctxt_mask |= ~0xffff; > } > > ctxt->eflags = (temp_eflags & mask) | (ctxt->eflags & ctxt_mask); Sorry, I replied to v3 of the patch while reviewing v2. Looks good indeed. Thanks! Paolo