On Mon, Apr 15, 2024 at 2:32 PM HAGIO KAZUHITO(萩尾 一仁) <k-hagio...@nec.com>
wrote:

> On 2024/04/09 18:30, Yulong Tang wrote:
> > Hi, Lianbo
> >
> > Thank you for your review.
> >
> > Your concerns are valid, there are some bit operations performed here
> after get_unaligned_le16(), perhaps we can add a check.
> >
> > But the crash-utility should match the endianess of the vmcore file and
> the local machine, and whether the compression algorithm always compresses
> data in the same format, so may need to be tested on a big-endian machine.
>
> Good catch, Lianbo.
>
> It seems that in the kenrnel, le16_to_cpu in get_unaligned_le16 does
> bswap_16 on a big-endian machine, probably we need to add something like
>
>    #if __BYTE_ORDER == __BIG_ENDIAN
>        return bswap_16(value);
>    #else
>        return value;
>    #endif
>
> Is it possible to test on a big-endian machine?
>

Sure. The macro '#if __BYTE_ORDER == __BIG_ENDIAN' takes effect on a
big-endian machine. But it requires to include the header file 'byteswap.h'
as below:
#include <byteswap.h>

In addition, there is a similar implementation, but I haven't tested it
with Yulong's case. Can you help to check if this can work well for you?
Yulong.

static inline uint16_t
get_unaligned_le16 (const uint8_t *p)
{
  return p[0] | p[1] << 8;
}


Thank
Lianbo


> Thanks,
> Kazu
--
Crash-utility mailing list -- devel@lists.crash-utility.osci.io
To unsubscribe send an email to devel-le...@lists.crash-utility.osci.io
https://${domain_name}/admin/lists/devel.lists.crash-utility.osci.io/
Contribution Guidelines: https://github.com/crash-utility/crash/wiki

Reply via email to