]> xenbits.xensource.com Git - unikraft/unikraft.git/commitdiff
plat/kvm/x86: Pre-initialize VGA framebuffer `terminal_buffer`
authorSergiu Moga <sergiu@unikraft.io>
Sat, 14 Oct 2023 09:17:55 +0000 (12:17 +0300)
committerRazvan Deaconescu <razvand@unikraft.io>
Fri, 20 Oct 2023 16:35:55 +0000 (19:35 +0300)
After commit f57ca0bbc402 ("plat/kvm/x86: Make zero page inaccessible"),
early accesses to uninitialized VGA framebuffer would issue an unhandled
page fault and thus crashing the application. Solve this by
preinitializing the `terminal_buffer` variable.

Signed-off-by: Sergiu Moga <sergiu@unikraft.io>
Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1136

plat/kvm/x86/vga_console.c

index 1e6e4be5e70ded46c6e3255bb95aeb4cc80af2a6..c393250b860188cd4c601587f0f5786f8fe39573 100644 (file)
@@ -66,11 +66,12 @@ static inline uint16_t vga_entry(unsigned char uc, uint8_t color)
 #define TAB_ALIGNMENT 8
 #define VGA_WIDTH     80
 #define VGA_HEIGHT    25
+#define VGA_FB_BASE   0xb8000
 
 static size_t terminal_row;
 static size_t terminal_column;
 static uint8_t terminal_color;
-static uint16_t *terminal_buffer;
+static uint16_t *const terminal_buffer = (uint16_t *)VGA_FB_BASE;
 static uint16_t areg;   /* VGA address register */
 static uint16_t dreg;   /* VGA data register */
 
@@ -117,7 +118,6 @@ void _libkvmplat_init_vga_console(void)
        outb(dreg, 0x0f);
        local_irq_restore(irq_flags);
 
-       terminal_buffer = (uint16_t *) 0xb8000;
        clear_terminal();
 }