public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Nikita Kiryanov <nikita@compulab.co.il>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH V2 3/7] lcd: prevent unaligned memory access when displaying splash screen
Date: Sun, 10 Feb 2013 13:14:02 +0200	[thread overview]
Message-ID: <511780FA.9070904@compulab.co.il> (raw)
In-Reply-To: <1359618000-19069-4-git-send-email-nikita@compulab.co.il>

Following the discussion in the "Create an API for safely accessing BMP
header fields" patch series, this patch should be dropped.

On 01/31/2013 09:39 AM, Nikita Kiryanov wrote:
> When the bmp file is loaded to an address specified by the environment
> variable "splashimage", its header members might be unaligned.
> This happens because the bmp header starts with two byte size fields followd by
> mostly 32 bit fields. When the address in splashimage is not equal to aligned
> address plus/minus 2, the 32 bit members will be placed in unaligned addresses
> and the result would be a data abort on targets that cannot handle unaligned
> memory accesses.
>
> Check that the address is safe to use, and fix it if it's not.
>
> Cc: Anatolij Gustschin <agust@denx.de>
> Cc: Albert ARIBAUD <albert.u.boot@aribaud.net>
> Cc: Jeroen Hofstee <jeroen@myspectrum.nl>
> Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il>
> Signed-off-by: Igor Grinberg <grinberg@compulab.co.il>
> ---
> Changes in V2: None. Patch introduced in V2.
>
>   common/lcd.c |    8 ++++++++
>   1 file changed, 8 insertions(+)
>
> diff --git a/common/lcd.c b/common/lcd.c
> index 66d4f94..104125d 100644
> --- a/common/lcd.c
> +++ b/common/lcd.c
> @@ -1046,6 +1046,14 @@ static void *lcd_logo(void)
>   		do_splash = 0;
>
>   		addr = simple_strtoul (s, NULL, 16);
> +		/*
> +		 * In order for the fields of bmp header to be properly aligned
> +		 * in memory, splash image addr must be aligned to "aligned
> +		 * address plus 2". Fix addr if necessary.
> +		 */
> +		if (addr % 4 != 2)
> +			addr += (addr % 4) ?: 2;
> +
>   #ifdef CONFIG_SPLASH_SCREEN_ALIGN
>   		s = getenv("splashpos");
>   		if (s != NULL) {
>


-- 
Regards,
Nikita.

  reply	other threads:[~2013-02-10 11:14 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-31  7:39 [U-Boot] [PATCH V3 0/7] Add splash screen for CM-T35 Nikita Kiryanov
2013-01-31  7:39 ` [U-Boot] [PATCH V3 1/7] omap3: add useful dss defines Nikita Kiryanov
2013-01-31  7:39 ` [U-Boot] [PATCH V3 2/7] omap3: allow dynamic selection of gfx_format Nikita Kiryanov
2013-01-31  7:39 ` [U-Boot] [PATCH V2 3/7] lcd: prevent unaligned memory access when displaying splash screen Nikita Kiryanov
2013-02-10 11:14   ` Nikita Kiryanov [this message]
2013-01-31  7:39 ` [U-Boot] [PATCH V1 4/7] lcd: add option for board specific splash screen preparation Nikita Kiryanov
2013-01-31  7:39 ` [U-Boot] [PATCH V3 5/7] cm-t35: add support for dvi displays Nikita Kiryanov
2013-01-31  7:39 ` [U-Boot] [PATCH V2 6/7] cm-t35: add support for user defined lcd parameters Nikita Kiryanov
2013-01-31  7:40 ` [U-Boot] [PATCH V2 7/7] cm-t35: add support for loading splash image from NAND Nikita Kiryanov
2013-02-10 11:17   ` Nikita Kiryanov
2013-03-10 11:21 ` [U-Boot] [PATCH V3 0/7] Add splash screen for CM-T35 Nikita Kiryanov
  -- strict thread matches above, loose matches on Subject: below --
2013-01-29 12:42 [U-Boot] [PATCH V2 " Nikita Kiryanov
2013-01-29 12:42 ` [U-Boot] [PATCH V2 3/7] lcd: prevent unaligned memory access when displaying splash screen Nikita Kiryanov
2013-01-29 13:46   ` Wolfgang Denk
2013-01-29 14:34     ` Nikita Kiryanov

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=511780FA.9070904@compulab.co.il \
    --to=nikita@compulab.co.il \
    --cc=u-boot@lists.denx.de \
    /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