Fix an integer overflow while setting the kernel address (MODINFO_ADDR).

This eliminates build warning and makes kldstat happy.

Approved by:	re (marius)
This commit is contained in:
Ruslan Bukin 2018-08-31 16:15:46 +00:00
parent 74aa2d49d6
commit 0f669630ac

View File

@ -734,12 +734,14 @@ 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;
@ -751,12 +753,13 @@ fake_preload_metadata(struct riscv_bootparams *rvbp __unused)
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