mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Ahmad Fatoum <a.fatoum@pengutronix.de>
Cc: barebox@lists.infradead.org, Michael Tretter <m.tretter@pengutronix.de>
Subject: Re: [PATCH 1/2] ARM: mmu64: allow to disable null pointer trap on zero page
Date: Thu, 15 Oct 2020 10:44:26 +0200	[thread overview]
Message-ID: <20201015084426.GJ13710@pengutronix.de> (raw)
In-Reply-To: <424d6679-3acd-f6fe-adb3-860ba75ab820@pengutronix.de>

On Wed, Oct 14, 2020 at 06:29:47PM +0200, Ahmad Fatoum wrote:
> 
> 
> On 10/14/20 5:08 PM, Michael Tretter wrote:
> > Barebox uses the zero page to trap NULL pointer dereferences. However,
> > if the SDRAM starts at address 0x0, this makes the first page of the
> > SDRAM inaccessible and makes it impossible to load images to offset 0x0
> > in the SDRAM.
> > 
> > Trapping NULL pointer dereferences on such systems is still desirable.
> > Therefore, add a function to disable the traps if accessing the zero
> > page is necessary and to re-enable the traps after the access is done.
> 
> Can't we map the (phy_addr_t)0 at some higher virtual address and
> change uimage to use phys_to_virt() ?
> 
> Something like 
> 
> static inline void *phys_to_virt(unsigned long phys)
> {
> 	if (!IS_ENABLED(CONFIG_ARM_MACH_CUSTOM_MAPPING) || !arm_mach_phys_to_virt)
> 		return (void *)phys;
> 	return arm_mach_phys_to_virt(phys);
> }

Please don't. A user of that function would have to implicitly know that
phys_to_virt() would have to be called exactly for the zero page. Also
how big is the area returned from phys_to_virt()? If it's up to the next
page boundary a user would have to align all of it's memcpys to page
boundaries for no gain.

I rather suggest to introduce an explicit

void *memcpy_to_zero(void *dst, void *src, size_t len)

The implementation could then be architecture specific and could choose
if it likes to just map the zero page to NULL or somewhere else.

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

      parent reply	other threads:[~2020-10-15  8:44 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-14 15:08 Michael Tretter
2020-10-14 15:08 ` [PATCH 2/2] uimage: disable zero page when loading to SDRAM at address 0x0 Michael Tretter
2020-10-14 16:33   ` Ahmad Fatoum
2020-10-15  7:40     ` Michael Tretter
2020-10-15  8:35       ` Sascha Hauer
2020-10-15  9:12       ` Ahmad Fatoum
2020-10-14 16:29 ` [PATCH 1/2] ARM: mmu64: allow to disable null pointer trap on zero page Ahmad Fatoum
     [not found]   ` <20201015073331.GA29491@pengutronix.de>
2020-10-15  8:14     ` Ahmad Fatoum
2020-10-15  8:40       ` Michael Tretter
2020-10-15  8:44   ` Sascha Hauer [this message]

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=20201015084426.GJ13710@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=m.tretter@pengutronix.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