magicvar breaks tftp (or ramfs)

Sascha Hauer s.hauer at pengutronix.de
Tue May 29 12:23:50 EDT 2012


On Tue, May 29, 2012 at 10:48:44AM +0200, Eric Bénard wrote:
> Hi Sascha,
> 
> > 
> > I really want to believe this, but I wouldn't be so sure. I think
> > it's more likely that you found a bug in barebox that your new
> > toolchain happens to trigger. Could you provide the objdump of
> > show_progress along with a complete stack trace including register
> > contents?
> > 
> here is the full trace.
> There is something strange as it seems a wrong value gets loaded into R3
> leading to the error.

I recently found a bug that could match this description. The following
patch fixes this, but currently I don't now what other places might be
affected. It's a matter of reviewing all places where dma_inv_range is
used. Does the problem persist when you turn off the MMU?

Sascha



>From f11b34785ba3d33854c752e81c43de0271d19d35 Mon Sep 17 00:00:00 2001
From: Sascha Hauer <s.hauer at pengutronix.de>
Date: Thu, 24 May 2012 16:02:37 +0200
Subject: [PATCH] USB gadget fsl: request cacheline aligned buffer

The fsl udc driver allocates a buffer for small requests. The
driver then calls dma_inv_range later on it. This buffer happens
to be not cacheline aligned which means that a dma_inv_range can
corrupt other memory around the buffer.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 drivers/usb/gadget/fsl_udc.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/fsl_udc.c b/drivers/usb/gadget/fsl_udc.c
index 5b64ec2..96cdb30 100644
--- a/drivers/usb/gadget/fsl_udc.c
+++ b/drivers/usb/gadget/fsl_udc.c
@@ -2109,7 +2109,8 @@ static int struct_udc_setup(struct fsl_udc *udc,
 	udc->status_req = container_of(fsl_alloc_request(NULL),
 			struct fsl_req, req);
 	/* allocate a small amount of memory to get valid address */
-	udc->status_req->req.buf = xmalloc(8);
+	udc->status_req->req.buf = xmemalign(4096, 4096);
+	udc->status_req->req.length = 8;
 	udc->resume_state = USB_STATE_NOTATTACHED;
 	udc->usb_state = USB_STATE_POWERED;
 	udc->ep0_dir = 0;
-- 
1.7.10


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



More information about the barebox mailing list