From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50066) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z4UpR-0007gz-9m for qemu-devel@nongnu.org; Mon, 15 Jun 2015 09:53:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z4UpO-0006jK-2O for qemu-devel@nongnu.org; Mon, 15 Jun 2015 09:53:33 -0400 Received: from omzsmtpe04.verizonbusiness.com ([199.249.25.207]:16795) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z4UpN-0006j8-UI for qemu-devel@nongnu.org; Mon, 15 Jun 2015 09:53:30 -0400 From: Don Slutz Message-ID: <557ED8D3.8010900@one.verizon.com> Date: Mon, 15 Jun 2015 09:53:23 -0400 MIME-Version: 1.0 References: <1434117956-4929-1-git-send-email-dslutz@verizon.com> <1434117956-4929-2-git-send-email-dslutz@verizon.com> <557B5F49.5050109@redhat.com> In-Reply-To: <557B5F49.5050109@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [BUGFIX][PATCH v7 1/9] vmport: The io memory region needs to be at least a size of 4 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake , "qemu-devel@nongnu.org" Cc: "Michael S. Tsirkin" , Markus Armbruster , Luiz Capitulino , Don Slutz , Anthony Liguori , Paolo Bonzini , =?UTF-8?B?QW5kcmVhcyBGw6RyYmVy?= , Richard Henderson On 06/12/15 18:38, Eric Blake wrote: > On 06/12/2015 08:05 AM, Don Slutz wrote: >> Before: >> >> commit c3c1bb99d1c11978d9ce94d1bdcf0705378c1459 >> Author: Peter Crosthwaite >> Date: Mon Mar 16 22:35:54 2015 -0700 >> >> exec: Respect as_tranlsate_internal length clamp >> >> it did not matter. Only accept I/O that starts on 1st >> port. >> >> Signed-off-by: Don Slutz >> CC: Don Slutz >> --- >> hw/misc/vmport.c | 6 +++++- >> 1 file changed, 5 insertions(+), 1 deletion(-) >> >> diff --git a/hw/misc/vmport.c b/hw/misc/vmport.c >> index 7fcc00d..51b64bc 100644 >> --- a/hw/misc/vmport.c >> +++ b/hw/misc/vmport.c >> @@ -69,6 +69,10 @@ static uint64_t vmport_ioport_read(void *opaque, hwaddr addr, >> unsigned char command; >> uint32_t eax; >> >> + /* Only support 1 address */ >> + if (addr) { >> + return ~0U; >> + } > > Different answer on 32-bit platforms (there, ~0U is 0xffffffff, which > then 0-extends to uint64_t rather than your desired result of > 0xffffffffffffffffULL). > This is not true: Using: build1:~/tmp>cat zr64.c #include #include uint64_t vmport_ioport_read(void) { return ~0U; } int main(void) { uint64_t res = vmport_ioport_read(); printf("res=0x%llx\n", res); } On 32-bits: build1:~/tmp>file zr64 zr64: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, not stripped build1:~/tmp>./zr64 res=0xffffffff on 64-bits: build2:~/tmp>file zr64 zr64: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, not stripped build2:~/tmp>./zr64 res=0xffffffff > Why can't you just 'return -1;'? > I/O instructions on x86 are limited to 32bits max. Also when EAX is changed via inl, the high 32bits are 0. So the correct result is ~0U not -1. -Don Slutz