From 786a195f8e81d4f7c0af2a82b9d458361d424a71 Mon Sep 17 00:00:00 2001 From: johannst Date: Wed, 26 May 2021 00:21:06 +0200 Subject: minimal KVM abstraction + real mode guest example --- guest/guest16.S | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 guest/guest16.S (limited to 'guest/guest16.S') diff --git a/guest/guest16.S b/guest/guest16.S new file mode 100644 index 0000000..7f0be0e --- /dev/null +++ b/guest/guest16.S @@ -0,0 +1,21 @@ +.code16 +.intel_syntax noprefix + +.section .boot, "ax", @progbits + // Trigger `KVM_EXIT_IO:KVM_EXIT_IO_OUT` by writing string to output port. + mov dx, 0x1000 // Output port. + lea si, [msg] // Address of string. + mov cx, [msg_len] // Len of string. + rep outsb dx, ds:[si] // Write out string bytes. + + // Trigger `KVM_EXIT_MMIO` by writing to non mapped physical address. + mov byte ptr ds:[0x2000], 0xaa + + // Trigger `KVM_EXIT_HLT`. + hlt + +.section .rodata, "a", @progbits +msg: + .asciz "Hello from Real Mode!\n" +msg_len: + .byte .-msg -- cgit v1.2.3