From mboxrd@z Thu Jan 1 00:00:00 1970 From: Don Slutz Subject: Re: [PATCH v9 12/13] test_x86_emulator.c: Add tests for #GP usage Date: Wed, 25 Feb 2015 08:27:56 -0500 Message-ID: <54EDCDDC.9000606@terremark.com> References: <1424127915-27004-1-git-send-email-dslutz@verizon.com> <1424127915-27004-13-git-send-email-dslutz@verizon.com> <54ECA90B02000078000632E7@mail.emea.novell.com> <54ECC311.3090903@terremark.com> <54ED961B020000780006367B@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <54ED961B020000780006367B@mail.emea.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Jan Beulich , Don Slutz Cc: Jun Nakajima , Tim Deegan , Kevin Tian , Keir Fraser , Ian Campbell , Stefano Stabellini , George Dunlap , Andrew Cooper , Ian Jackson , xen-devel@lists.xen.org, Eddie Dong , Aravind Gopalakrishnan , Suravee Suthikulpanit , Boris Ostrovsky List-Id: xen-devel@lists.xenproject.org On 02/25/15 03:30, Jan Beulich wrote: >>>> On 24.02.15 at 19:29, wrote: >> + /* >> + * Test out special #GP handling for the VMware port 0x5658. >> + * This is done in two "modes", j=0 and j=1. Testing 4 >> + * instructions (all the basic PIO) in both modes. >> + * >> + * The port used is based on j. >> + * >> + * For IN, eax should change. For OUT eax should not change. >> + * >> + * All 4 PIO instructions are 1 byte long, so eip should only >> + * change by 1. >> + */ > > Thanks, this looks reasonable. > >> + /* >> + * In j=0, there should not be an error returned. >> + * In j=1, there should be an error returned. >> + */ >> + if ( rc != X86EMUL_OKAY ) >> + { >> + if ( j == 0 ) >> + goto fail; >> + } >> + else if ( j == 1 ) >> + goto fail; > > I'd appreciate if this could be expressed in a little fewer lines. I'm not > sure > > if ( (rc == X86EMUL_OKAY) == j ) > goto fail; > > would be deemed readable, but surely > > if ( rc == X86EMUL_OKAY ? j : !j ) > goto fail; > > would suffice. Tried this and it works fine, so switching to: + if ( rc == X86EMUL_OKAY ? j : !j ) -Don Slutz >> So I have checked and read, write_gp, cmpxchg_gp, read_segment, >> and inject_hw_exception are not needed. So that leaves: >> >> static struct x86_emulate_ops emulops_gp = { >> .insn_fetch = fetch, >> .read_io = read_io, >> .write_io = write_io, >> .vmport_check = vmport_check, >> }; > > Quite a bit better, thanks. > > Jan >