From: Francesco Lavra <francescolavra.fl@gmail.com>
To: grub-devel@gnu.org
Subject: Re: [PATCH 2/7] Initial support for ARMv7 architecture
Date: Mon, 01 Apr 2013 11:36:11 +0200 [thread overview]
Message-ID: <5159550B.1020706@gmail.com> (raw)
In-Reply-To: <5158E2B1.4040505@gmail.com>
On 04/01/2013 03:28 AM, Vladimir 'φ-coder/phcoder' Serbinenko wrote:
>> +grub_err_t
>> +reloc_thm_call (grub_uint16_t *target, Elf32_Addr sym_addr)
>> +{
>> + grub_int32_t offset, offset_low, offset_high;
>> + grub_uint32_t sign, j1, j2, is_blx;
>> + grub_uint32_t insword, insmask;
>> +
>> + /* Extract instruction word in alignment-safe manner */
>> + insword = (*target << 16) | (*(target + 1));
>
> Why not use grub_get_unaligned32
It's not a simple unaligned access, it's actually about accessing two
naturally aligned 16-bit halfwords, and concatenating them by putting
the first value in the most significant bytes. Each halfword is encoded
in little endian, but the set of two halfwords is encoded "most
significant halfword first".
The problem here is in the GRUB_UTIL case, where accessing each of the
two halfwords could cause endianness issues. In this case two calls to
grub_target_to_host16() should be used to retrieve the instruction word.
>> +#ifdef GRUB_UTIL
>> +#pragma GCC diagnostic ignored "-Wcast-align"
>> + grub_util_info (" *target = 0x%08x", *((unsigned int *)target));
>> +#endif
>
> grub_get_unaligned.
Ditto, it's not a simple unaligned access.
>
>> + *addr = insword >> 16;
>> + *(addr + 1) = insword & 0xffff;
>
> Use grub_set_unaligned+
The same applies here, in the util case a couple of
grub_host_to_target16() calls must be used to store back the instruction
word.
--
Francesco
next prev parent reply other threads:[~2013-04-01 9:36 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-24 17:01 [PATCH 2/7] Initial support for ARMv7 architecture Leif Lindholm
2013-03-30 15:15 ` Francesco Lavra
2013-04-03 15:36 ` Leif Lindholm
2013-04-01 1:28 ` Vladimir 'φ-coder/phcoder' Serbinenko
2013-04-01 9:36 ` Francesco Lavra [this message]
2013-04-03 15:20 ` Leif Lindholm
2013-04-08 23:27 ` Vladimir 'φ-coder/phcoder' Serbinenko
2013-04-09 10:34 ` Leif Lindholm
2013-04-09 11:37 ` Vladimir 'φ-coder/phcoder' Serbinenko
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=5159550B.1020706@gmail.com \
--to=francescolavra.fl@gmail.com \
--cc=grub-devel@gnu.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.