qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 0/9] Remove legacy unaligned bswap functions


From: Peter Maydell
Subject: Re: [Qemu-devel] [PATCH 0/9] Remove legacy unaligned bswap functions
Date: Mon, 9 Sep 2013 13:17:30 +0100

On 9 September 2013 12:54, Michael S. Tsirkin <address@hidden> wrote:
> On Sun, Aug 25, 2013 at 03:59:28PM +0100, Peter Maydell wrote:
>> The bswap.h header includes a set of "legacy unaligned functions"
>> that (since commit c732a52d3 at the beginning of this year) are
>> just wrappers for underlying {ld,st}<type> functions. The legacy
>> functions aren't used in many places, so just replace all their
>> uses with uses of the new-style {ld,st} functions; this lets us
>> remove the legacy wrappers altogether.
>
> I have a question on this: what happens if an unaligned
> address is supplied?
> In particular, if the address is supplied by the guest?
>
> Esp the pci wrappers have many callers - were they all
> audited?
> I tried checking but there are many callers, will take
> a while.

This patchset has zero behavioural changes, because
literally all it is doing is taking trivial wrapper
functions like

static inline void cpu_to_le16wu(uint16_t *p, uint16_t v)
{
    stw_le_p(p, v);
}

and replacing the calls to the wrapper with direct
calls to the underlying function. There's no need
to audit calls to the callsites because there is
no semantic change and not even any implementation
change here.

There are no problems with unaligned accesses, because
the stw_le_p &c functions are designed to work for
unaligned accesses: they boil down to calls to
ldl_p/stw_p and friends, which use memcpy() to
ensure they work OK with unaligned accesses.

You can check all this by looking at bswap.h.

-- PMM



reply via email to

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