Patchwork : Fix memset calling error

login
register
about
Submitter Bao, Zheng
Date 2010-03-19 07:32:51
Message ID <DD1CC71B621B004FA76856E5129D6B17038E3E47@sbjgexmb1.amd.com>
Download mbox | patch
Permalink /patch/1092/
State Accepted
Headers show

Comments

Bao, Zheng - 2010-03-19 07:32:51
The parameters of memset() should be
memset(addr, value, size), right?
It is an obvious bug created at r5201. I am wondering
why it doesnt trouble you. I took a quike look at other
files and didnt find other calling error.

Signed-off-by: Zheng Bao <zheng.bao@amd.com>

 	print_debug("Done\r\n");
Stefan Reinauer - 2010-03-19 08:10:55
On 3/19/10 8:32 AM, Bao, Zheng wrote:
> The parameters of memset() should be
> memset(addr, value, size), right?
> It is an obvious bug created at r5201. I am wondering
> why it doesnt trouble you. I took a quike look at other
> files and didnt find other calling error.
>
> Signed-off-by: Zheng Bao <zheng.bao@amd.com>
>   
Acked-by: Stefan Reinauer <stepan@coresystems.de>
Myles Watson - 2010-03-19 12:29:21
On Fri, Mar 19, 2010 at 1:32 AM, Bao, Zheng <Zheng.Bao@amd.com> wrote:

> The parameters of memset() should be
> memset(addr, value, size), right?
> It is an obvious bug created at r5201.

Yes.  Sorry about that.


> I am wondering
> why it doesnt trouble you.

Good question.  I didn't see any effect on SimNow or my Tyan board.

Thanks,
Myles
Carl-Daniel Hailfinger - 2010-03-19 14:04:10
On 19.03.2010 08:32, Bao, Zheng wrote:
> The parameters of memset() should be
> memset(addr, value, size), right?
> It is an obvious bug created at r5201. I am wondering
> why it doesnt trouble you. I took a quike look at other
> files and didnt find other calling error.
>
> Signed-off-by: Zheng Bao <zheng.bao@amd.com>
>   

Impressive bug discovery!
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>

Regards,
Carl-Daniel

Patch

Index: src/cpu/amd/model_fxx/model_fxx_init.c
===================================================================
--- src/cpu/amd/model_fxx/model_fxx_init.c	(revision 5260)
+++ src/cpu/amd/model_fxx/model_fxx_init.c	(working copy)
@@ -238,7 +238,7 @@ 
 
                 /* clear memory 2M (limitk - basek) */
                 addr = (void *)(((uint32_t)addr) | ((basek & 0x7ff) <<
10));
-                memset(addr, size, 0);
+                memset(addr, 0, size);
 }
 
 static void init_ecc_memory(unsigned node_id)
Index: src/cpu/amd/car/post_cache_as_ram.c
===================================================================
--- src/cpu/amd/car/post_cache_as_ram.c	(revision 5260)
+++ src/cpu/amd/car/post_cache_as_ram.c	(working copy)
@@ -95,9 +95,9 @@ 
 	print_debug("Clearing initial memory region: ");
 #if CONFIG_HAVE_ACPI_RESUME == 1
 	/* clear only coreboot used region of memory. Note: this may
break ECC enabled boards */
-	memset((void*) CONFIG_RAMBASE, (CONFIG_RAMTOP) - CONFIG_RAMBASE
- CONFIG_DCACHE_RAM_SIZE, 0);
+	memset((void*) CONFIG_RAMBASE, 0, (CONFIG_RAMTOP) -
CONFIG_RAMBASE - CONFIG_DCACHE_RAM_SIZE);
 #else
-	memset((void*)0, ((CONFIG_RAMTOP) - CONFIG_DCACHE_RAM_SIZE), 0);
+	memset((void*)0, 0, ((CONFIG_RAMTOP) - CONFIG_DCACHE_RAM_SIZE));
 #endif