qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v5 9/9] tests: add a m25p80 test


From: Cédric Le Goater
Subject: Re: [Qemu-devel] [PATCH v5 9/9] tests: add a m25p80 test
Date: Mon, 4 Jul 2016 11:50:38 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.1.0

>>> +static void test_erase_sector(void)
>>> +{
>>> +    uint32_t some_page_addr = 0x600 * PAGE_SIZE;
>>> +    uint32_t page[PAGE_SIZE / 4];
>>> +    int i;
>>> +
>>> +    spi_conf(CONF_ENABLE_W0);
>>> +
>>> +    spi_ctrl_start_user();
>>> +    writeb(AST2400_FLASH_BASE, WREN);
>>> +    writeb(AST2400_FLASH_BASE, EN_4BYTE_ADDR);
>>> +    writeb(AST2400_FLASH_BASE, ERASE_SECTOR);
>>> +    writel(AST2400_FLASH_BASE, cpu_to_be32(some_page_addr));
>> Hi,
>>
>> I think you should not make any byte swapping because
>> qtest for all write* instructions (see qtest.c:377).
> 
> yes. on a BE, we should not byte swap.
> 
> When on a LE host, the cpu_to_be32() call in the test byte-swaps
> the address, tswap32() in qtest.c does nothing as the host endian 
> and guest endian are in sync and so the address reaches the 
> controller region in the expected order.  
> 
> When on a BE host, the cpu_to_be32() does nothing but tswap32() in 
> qtest.c reverses the order and so the address reaches the controller 
> region in the wrong order (LE).  
> 
> I see two possible fixes : 
> 
> 1 - replace the read* routines by out* (no tswap there)
> 2 - add an extra byteswap on BE hosts using qtest_big_endian() as 
>     in virtio-blk-test.c. see virtio_blk_fix_request() 

or :

        3 - use memwrite/read

which is I think the appropriate fix.

Thanks,

C. 




reply via email to

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