From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:39051) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rmq3R-00036x-SJ for qemu-devel@nongnu.org; Mon, 16 Jan 2012 12:09:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rmq3N-0007mi-UC for qemu-devel@nongnu.org; Mon, 16 Jan 2012 12:09:09 -0500 Received: from mail-iy0-f173.google.com ([209.85.210.173]:42098) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rmq3N-0007mW-R8 for qemu-devel@nongnu.org; Mon, 16 Jan 2012 12:09:05 -0500 Received: by iaeo4 with SMTP id o4so8957621iae.4 for ; Mon, 16 Jan 2012 09:09:04 -0800 (PST) Message-ID: <4F1459AA.5070402@codemonkey.ws> Date: Mon, 16 Jan 2012 11:08:58 -0600 From: Anthony Liguori MIME-Version: 1.0 References: <1326479558-3016-1-git-send-email-aliguori@us.ibm.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 1/6] qtest: add test framework List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: Kevin Wolf , Anthony Liguori , Stefan Hajnoczi , qemu-devel@nongnu.org, Avi Kivity , Paolo Bonzini On 01/16/2012 10:59 AM, Stefan Hajnoczi wrote: > On Fri, Jan 13, 2012 at 6:32 PM, Anthony Liguori wrote: >> + if (strcmp(words[0], "outb") == 0 || >> + strcmp(words[0], "outw") == 0 || >> + strcmp(words[0], "outl") == 0) { >> + uint16_t addr; >> + uint32_t value; >> + >> + g_assert(words[1]&& words[2]); >> + addr = strtol(words[1], NULL, 0); >> + value = strtol(words[2], NULL, 0); >> + >> + if (words[0][3] == 'b') { >> + cpu_outb(addr, value); >> + } else if (words[0][3] == 'w') { >> + cpu_outw(addr, value); >> + } else if (words[0][3] == 'l') { >> + cpu_outl(addr, value); >> + } >> + qtest_send_prefix(chr); >> + qtest_send(chr, "OK\n"); >> + } else if (strcmp(words[0], "inb") == 0 || >> + strcmp(words[0], "inw") == 0 || >> + strcmp(words[0], "inl") == 0) { >> + uint16_t addr; >> + uint32_t value = -1U; >> + >> + g_assert(words[1]); >> + addr = strtol(words[1], NULL, 0); >> + >> + if (words[0][2] == 'b') { >> + value = cpu_inb(addr); >> + } else if (words[0][2] == 'w') { >> + value = cpu_inw(addr); >> + } else if (words[0][2] == 'l') { >> + value = cpu_inl(addr); >> + } >> + qtest_send_prefix(chr); >> + qtest_send(chr, "OK 0x%04x\n", value); > > Endianness is a little weird here. memory.c will byteswap if target > and device endianness differ. > > Imagine the case where we're on an x86 host, running a ppc guest, > reading from PCI configuration space (little-endian). These functions expect to get host native endian. The qtest wire protocol is a string (which has no endianness) and converts it to host native endian. > Since ppc > (target endian) is big-endian and the device is little-endian the > value read/written will be byteswapped. However, our qtest runs on > the host and therefore we don't want that automatic swap (or we need > to neutralize it by performing another byteswap on top). ppc wouldn't use outb/inb. It would do mmio to the PIO region which would send it through the host controller (which would do byte swapping as necessary). So a qtest test case would have to do little endian MMIO to interact with the PCI bus. Regards, Anthony Liguori > > Stefan >