From: "BillXiang" <xiangwencheng@lanxincomputing.com>
To: "Richard Henderson" <richard.henderson@linaro.org>, <mst@redhat.com>
Cc: <pbonzini@redhat.com>, <peterx@redhat.com>, <philmd@mailo.com>,
<qemu-devel@nongnu.org>
Subject: Re: [PATCH] virtio: Add aligned ld/st accessors for vring
Date: Fri, 21 Aug 2026 10:20:20 +0800 [thread overview]
Message-ID: <6e417ca3-ec49-498c-8bfa-e29be60c6551@lanxincomputing.com> (raw)
In-Reply-To: <0ab52741-c059-4b3b-b1cd-fcf289bf820f@linaro.org>
On 8/20/2026 10:59 PM, Richard Henderson wrote:
> On 8/20/26 02:46, BillXiang wrote:
>> diff --git a/include/qemu/bswap.h b/include/qemu/bswap.h
>> index 387d65c..c23f5a2 100644
>> --- a/include/qemu/bswap.h
>> +++ b/include/qemu/bswap.h
>> @@ -255,6 +255,20 @@ static inline int lduw_he_p(const void *ptr)
>> return r;
>> }
>> +static inline int lduw_he_p_aligned(const void *ptr)
>> +{
>> + uint16_t r;
>> + __builtin_memcpy(&r, __builtin_assume_aligned(ptr, sizeof(r)),
>> sizeof(r));
>> + return r;
>> +}
>
> If you know it's aligned, then you don't need anything special: just a
> normal C memory access. E.g.
>
> *(uint16_t *)ptr
>
> and then of course no need for a wrapper function.
Noted, thanks! I’ll resend it with the changes.
>
>> +static inline int lduw_le_p_aligned(const void *ptr)
>> +{
>> + return (uint16_t)le_bswap(lduw_he_p_aligned(ptr), 16);
>> +}
>
> And this: le16_to_cpu(*(uint16_t *)ptr)
>
>
> r~
prev parent reply other threads:[~2026-08-21 2:21 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-20 9:46 [PATCH] virtio: Add aligned ld/st accessors for vring BillXiang
2026-08-20 14:59 ` Richard Henderson
2026-08-21 2:20 ` BillXiang [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6e417ca3-ec49-498c-8bfa-e29be60c6551@lanxincomputing.com \
--to=xiangwencheng@lanxincomputing.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peterx@redhat.com \
--cc=philmd@mailo.com \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox