Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/bhyvectl/bhyvectl.c
Show First 20 Lines • Show All 455 Lines • ▼ Show 20 Lines | for (msr = 0; msr < 0x2000; msr++) { | ||||
print_msr_pm(msr + MSR_AMD6TH_START, vcpu, readable, | print_msr_pm(msr + MSR_AMD6TH_START, vcpu, readable, | ||||
writeable); | writeable); | ||||
} | } | ||||
} | } | ||||
static int | static int | ||||
dump_msr_bitmap(int vcpu, uint64_t addr, bool cpu_intel) | dump_msr_bitmap(int vcpu, uint64_t addr, bool cpu_intel) | ||||
{ | { | ||||
int error, fd, map_size; | int error, fd, map_size; | ||||
neel: clang is confused but if you want to fix this then is to move the initialization of 'map_size'… | |||||
const char *bitmap; | const char *bitmap; | ||||
error = -1; | error = -1; | ||||
bitmap = MAP_FAILED; | bitmap = MAP_FAILED; | ||||
fd = open("/dev/mem", O_RDONLY, 0); | fd = open("/dev/mem", O_RDONLY, 0); | ||||
if (fd < 0) { | if (fd < 0) { | ||||
perror("Couldn't open /dev/mem"); | perror("Couldn't open /dev/mem"); | ||||
Show All 12 Lines | dump_msr_bitmap(int vcpu, uint64_t addr, bool cpu_intel) | ||||
} | } | ||||
if (cpu_intel) | if (cpu_intel) | ||||
dump_intel_msr_pm(bitmap, vcpu); | dump_intel_msr_pm(bitmap, vcpu); | ||||
else | else | ||||
dump_amd_msr_pm(bitmap, vcpu); | dump_amd_msr_pm(bitmap, vcpu); | ||||
error = 0; | error = 0; | ||||
map_size = 0; | |||||
neelUnsubmitted Not Done Inline ActionsThis is introducing a bug in the common case where 'map_size' is getting reset to 0. Yes, this is not worth committing :-) What I meant was to do this instead: error = -1; bitmap = MAP_FAILED; if (cpu_intel) map_size = PAGE_SIZE; else map_size = 2 * PAGE_SIZE; fd = open("/dev/mem", O_RDONLY, 0); if (fd < 0) { perror("Couldn't open /dev/mem"); goto done; } neel: This is introducing a bug in the common case where 'map_size' is getting reset to 0. Yes, this… | |||||
done: | done: | ||||
if (bitmap != MAP_FAILED) | if (bitmap != MAP_FAILED) | ||||
munmap((void *)bitmap, map_size); | munmap((void *)bitmap, map_size); | ||||
if (fd >= 0) | if (fd >= 0) | ||||
close(fd); | close(fd); | ||||
return (error); | return (error); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1,051 Lines • ▼ Show 20 Lines | while (1) { | ||||
printf("%-12s", numbuf); | printf("%-12s", numbuf); | ||||
printf("%-12s", name[0] ? name : "sysmem"); | printf("%-12s", name[0] ? name : "sysmem"); | ||||
printf("%-12lX", segoff); | printf("%-12lX", segoff); | ||||
printf("%c%c%c ", prot & PROT_READ ? 'R' : '-', | printf("%c%c%c ", prot & PROT_READ ? 'R' : '-', | ||||
prot & PROT_WRITE ? 'W' : '-', | prot & PROT_WRITE ? 'W' : '-', | ||||
prot & PROT_EXEC ? 'X' : '-'); | prot & PROT_EXEC ? 'X' : '-'); | ||||
delim = '\0'; | delim = '\0'; | ||||
Not Done Inline ActionsThis is wrong. 'delim' should be '\0' until the first field is pretty-printed. After that is should be set to the real delimited '/'. neel: This is wrong.
'delim' should be '\0' until the first field is pretty-printed. After that is… | |||||
if (flags & VM_MEMMAP_F_WIRED) { | if (flags & VM_MEMMAP_F_WIRED) { | ||||
printf("%cwired", delim); | printf("%cwired", delim); | ||||
delim = '/'; | delim = '/'; | ||||
} | } | ||||
if (flags & VM_MEMMAP_F_IOMMU) { | if (flags & VM_MEMMAP_F_IOMMU) { | ||||
printf("%ciommu", delim); | printf("%ciommu", delim); | ||||
delim = '/'; | delim = '/'; | ||||
} | } | ||||
printf("\n"); | printf("\n"); | ||||
gpa += maplen; | gpa += maplen; | ||||
Not Done Inline ActionsHuh? There *should* be a space before and after the '+=' operator. neel: Huh? There *should* be a space before and after the '+=' operator. | |||||
} | } | ||||
} | } | ||||
static int | static int | ||||
show_memseg(struct vmctx *ctx) | show_memseg(struct vmctx *ctx) | ||||
{ | { | ||||
char name[SPECNAMELEN + 1], numbuf[8]; | char name[SPECNAMELEN + 1], numbuf[8]; | ||||
size_t seglen; | size_t seglen; | ||||
▲ Show 20 Lines • Show All 641 Lines • Show Last 20 Lines |
clang is confused but if you want to fix this then is to move the initialization of 'map_size' before the first 'goto done'.