svn commit: r368513 - head/sys/dev/hyperv/vmbus
Bradley T. Hughes
bhughes at FreeBSD.org
Thu Dec 10 13:11:52 UTC 2020
Author: bhughes (ports committer)
Date: Thu Dec 10 13:11:52 2020
New Revision: 368513
URL: https://svnweb.freebsd.org/changeset/base/368513
Log:
hyperv/vmbus: avoid crash, panic if vbe fb info is missing
Do not assume that VBE framebuffer metadata can be used. Like with the
EFI fb metadata, it may be null, so we should take care not to
dereference the null vbefb pointer. This avoids a panic when booting
-CURRENT on a gen1 VM in Azure.
Approved by: tsoome
Sponsored by: Miles AS
Differential Revision: https://reviews.freebsd.org/D27533
Modified:
head/sys/dev/hyperv/vmbus/vmbus.c
Modified: head/sys/dev/hyperv/vmbus/vmbus.c
==============================================================================
--- head/sys/dev/hyperv/vmbus/vmbus.c Thu Dec 10 13:08:06 2020 (r368512)
+++ head/sys/dev/hyperv/vmbus/vmbus.c Thu Dec 10 13:11:52 2020 (r368513)
@@ -1361,35 +1361,33 @@ vmbus_fb_mmio_res(device_t dev)
kmdp = preload_search_by_type("elf64 kernel");
efifb = (struct efi_fb *)preload_search_info(kmdp,
MODINFO_METADATA | MODINFOMD_EFI_FB);
- if (efifb == NULL) {
- vbefb = (struct vbe_fb *)preload_search_info(kmdp,
- MODINFO_METADATA | MODINFOMD_VBE_FB);
+ vbefb = (struct vbe_fb *)preload_search_info(kmdp,
+ MODINFO_METADATA | MODINFOMD_VBE_FB);
+ if (efifb != NULL) {
+ fb_start = efifb->fb_addr;
+ fb_end = efifb->fb_addr + efifb->fb_size;
+ fb_count = efifb->fb_size;
+ fb_height = efifb->fb_height;
+ fb_width = efifb->fb_width;
+ } else if (vbefb != NULL) {
fb_start = vbefb->fb_addr;
fb_end = vbefb->fb_addr + vbefb->fb_size;
fb_count = vbefb->fb_size;
fb_height = vbefb->fb_height;
fb_width = vbefb->fb_width;
} else {
- fb_start = efifb->fb_addr;
- fb_end = efifb->fb_addr + efifb->fb_size;
- fb_count = efifb->fb_size;
- fb_height = efifb->fb_height;
- fb_width = efifb->fb_width;
- }
-
- if (fb_start == 0) {
if (bootverbose)
device_printf(dev,
"no preloaded kernel fb information\n");
/* We are on Gen1 VM, just return. */
return;
- } else {
- if (bootverbose)
- device_printf(dev,
- "fb: fb_addr: %#jx, size: %#jx, "
- "actual size needed: 0x%x\n",
- fb_start, fb_count, fb_height * fb_width);
}
+
+ if (bootverbose)
+ device_printf(dev,
+ "fb: fb_addr: %#jx, size: %#jx, "
+ "actual size needed: 0x%x\n",
+ fb_start, fb_count, fb_height * fb_width);
hv_fb_res = pcib_host_res_alloc(&sc->vmbus_mmio_res, dev,
SYS_RES_MEMORY, &rid, fb_start, fb_end, fb_count,
More information about the svn-src-head
mailing list