Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 31 Aug 2018 16:15:46 +0000 (UTC)
From:      Ruslan Bukin <br@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r338409 - head/sys/riscv/riscv
Message-ID:  <201808311615.w7VGFkbH086702@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: br
Date: Fri Aug 31 16:15:46 2018
New Revision: 338409
URL: https://svnweb.freebsd.org/changeset/base/338409

Log:
  Fix an integer overflow while setting the kernel address (MODINFO_ADDR).
  
  This eliminates build warning and makes kldstat happy.
  
  Approved by:	re (marius)

Modified:
  head/sys/riscv/riscv/machdep.c

Modified: head/sys/riscv/riscv/machdep.c
==============================================================================
--- head/sys/riscv/riscv/machdep.c	Fri Aug 31 16:10:01 2018	(r338408)
+++ head/sys/riscv/riscv/machdep.c	Fri Aug 31 16:15:46 2018	(r338409)
@@ -734,13 +734,15 @@ cache_setup(void)
 vm_offset_t
 fake_preload_metadata(struct riscv_bootparams *rvbp __unused)
 {
+	static uint32_t fake_preload[35];
 #ifdef DDB
 	vm_offset_t zstart = 0, zend = 0;
 #endif
 	vm_offset_t lastaddr;
-	int i = 0;
-	static uint32_t fake_preload[35];
+	int i;
 
+	i = 0;
+
 	fake_preload[i++] = MODINFO_NAME;
 	fake_preload[i++] = strlen("kernel") + 1;
 	strcpy((char*)&fake_preload[i++], "kernel");
@@ -751,12 +753,13 @@ fake_preload_metadata(struct riscv_bootparams *rvbp __
 	i += 3;
 	fake_preload[i++] = MODINFO_ADDR;
 	fake_preload[i++] = sizeof(vm_offset_t);
-	fake_preload[i++] = (uint64_t)(KERNBASE + KERNENTRY);
+	*(vm_offset_t *)&fake_preload[i++] =
+	    (vm_offset_t)(KERNBASE + KERNENTRY);
 	i += 1;
 	fake_preload[i++] = MODINFO_SIZE;
-	fake_preload[i++] = sizeof(uint64_t);
-	printf("end is 0x%016lx\n", (uint64_t)&end);
-	fake_preload[i++] = (uint64_t)&end - (uint64_t)(KERNBASE + KERNENTRY);
+	fake_preload[i++] = sizeof(vm_offset_t);
+	fake_preload[i++] = (vm_offset_t)&end -
+	    (vm_offset_t)(KERNBASE + KERNENTRY);
 	i += 1;
 #ifdef DDB
 #if 0



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201808311615.w7VGFkbH086702>