[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] tci: Fix some unaligned memory accesses
From: |
Stefan Weil |
Subject: |
Re: [Qemu-devel] [PATCH] tci: Fix some unaligned memory accesses |
Date: |
Tue, 9 Apr 2019 18:53:15 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 |
On 09.04.19 08:58, Richard Henderson wrote:
> On 4/8/19 8:04 PM, Stefan Weil wrote:
>> static tcg_target_ulong tci_read_i(uint8_t **tb_ptr)
>> {
>> - tcg_target_ulong value = *(tcg_target_ulong *)(*tb_ptr);
>> + tcg_target_ulong value;
>
> Ideally these would use the helpers from "qemu/bswap.h", ldl_he_p(), etc.
>
> r~
That would require adding a helper for tcg_target_ulong to qemu/bswap.h.
Or tci.c would need conditional code for reading a tcg_target_ulong.
Those helpers in qemu/bswap.h are also a little bit strange:
- Why does lduw_he_p return an int instead of an uint16_t?
- Why does ldsw_he_p return an int instead of an int16_t?
- Why does ldl_he_p return an int instead of an int32_t?
- Should ldl_he_p be renamed into ldsl_he_p?
And why is ldul_he_p missing?
- Should ldq_he_p be renamed into lduq_he_p?
And why is ldsq_he_p missing?
Using the helpers might require nasty type casts to avoid compiler
warnings because of signed / unsigned and size mismatches.
Aren't the few memcpy statements in the TCI helpers much more direct and
understandable?
Regards
Stefan