qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 1/6] qtest: add test framework


From: Stefan Hajnoczi
Subject: Re: [Qemu-devel] [PATCH 1/6] qtest: add test framework
Date: Wed, 18 Jan 2012 09:05:41 +0000

On Tue, Jan 17, 2012 at 11:13 AM, Stefan Hajnoczi <address@hidden> wrote:
> On Mon, Jan 16, 2012 at 5:08 PM, Anthony Liguori <address@hidden> wrote:
>> On 01/16/2012 10:59 AM, Stefan Hajnoczi wrote:
>>>
>>> On Fri, Jan 13, 2012 at 6:32 PM, Anthony Liguori<address@hidden>
>>>  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.
>
> The cpu_inl() return value is not host native endian.  We perform a
> byteswap if the memory region endianness is different from the target
> endianness.

After our chat yesterday I inspected cpu_inl() under gdb.  You are
right that cpu_inl() returns a value in host endian.  The memory
region endianness is ignored and no byteswapping is performed.

This means qtests do not need to byteswap - it's already in the
correct endianness, no matter which device, target, or host.

Stefan



reply via email to

[Prev in Thread] Current Thread [Next in Thread]