public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Matthias Fuchs <matthias.fuchs@esd-electronics.com>
To: u-boot@lists.denx.de
Subject: [U-Boot-Users] flash hardware protection with CFI driver does not autoprotect monitor completely
Date: Sun, 18 Nov 2007 19:59:54 +0100	[thread overview]
Message-ID: <200711181959.55060.matthias.fuchs@esd-electronics.com> (raw)

Hi,

I noticed that the monitor flash autoprotection from drivers/cfi_flash.c is not completely safe.
It does not protect all bootloader sectors in some situations:

	/* Monitor protection ON by default */
#if (CFG_MONITOR_BASE >= CFG_FLASH_BASE)
	flash_protect (FLAG_PROTECT_SET,
		       CFG_MONITOR_BASE,
		       CFG_MONITOR_BASE + monitor_flash_len  - 1,
		       flash_get_info(CFG_MONITOR_BASE));
#endif

I noticed this on the APC405 board after modifying it to use the common CFI flash driver.
Here are some lines from its config file:

#define CFG_MONITOR_BASE	0xFFF80000
#define CFG_MONITOR_LEN		(512 * 1024)	/* Reserve 512 kB for Monitor	*/

#define CFG_FLASH_CFI         1       /* Flash is CFI conformant */
#define CFG_FLASH_CFI_DRIVER  1       /* Use the common driver */
#define CFG_MAX_FLASH_SECT    128     /* max num of sects on one chip */
#define CFG_MAX_FLASH_BANKS   2       /* max num of flash banks */
#define CFG_FLASH_PROTECTION  1       /* use hardware protection        */
#define CFG_FLASH_USE_BUFFER_WRITE 1  /* use buffered writes (20x faster)     */
#define CFG_FLASH_BANKS_LIST  {CFG_FLASH_BASE, CFG_FLASH_BASE + CFG_FLASH_INCREMENT}

With this setup 'CFG_MONITOR_BASE + monitor_flash_len  - 1' evalutaes to fffc00ff
and therefore the last sector will not be protected. But on 4xx CPUs you have the reset
vector in the last sector so you definetely want it to be protected.

=> flinfo
...
  FFDC0000        FFDE0000        FFE00000        FFE20000        FFE40000
  FFE60000        FFE80000        FFEA0000        FFEC0000        FFEE0000 E
  FFF00000 E      FFF20000 E      FFF40000 E      FFF60000 E      FFF80000   RO
  FFFA0000   RO   FFFC0000   RO   FFFE0000


Question: what's the best way to fix this? We could modify the call to flash_protect()
like this:

	flash_protect (FLAG_PROTECT_SET,
		       CFG_MONITOR_BASE,
		       CFG_MONITOR_BASE + CFG_MONITOR_LEN  - 1,
		       flash_get_info(CFG_MONITOR_BASE));

But I am not sure if this is fine for all architectures. Any ideas?

Matthias

             reply	other threads:[~2007-11-18 18:59 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-18 18:59 Matthias Fuchs [this message]
2007-11-18 19:31 ` [U-Boot-Users] flash hardware protection with CFI driver does not autoprotect monitor completely Wolfgang Denk
2007-11-18 21:14   ` Matthias Fuchs
2007-11-18 21:52     ` Wolfgang Denk
2007-11-19  6:14       ` Stefan Roese
2007-11-19 10:04         ` Matthias Fuchs
2007-11-19 10:10           ` Stefan Roese

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=200711181959.55060.matthias.fuchs@esd-electronics.com \
    --to=matthias.fuchs@esd-electronics.com \
    --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