aboutsummaryrefslogtreecommitdiffhomepage
path: root/guest
diff options
context:
space:
mode:
Diffstat (limited to 'guest')
-rw-r--r--guest/Makefile13
-rw-r--r--guest/guest64.S17
2 files changed, 28 insertions, 2 deletions
diff --git a/guest/Makefile b/guest/Makefile
index e3f1e1b..a2eea1b 100644
--- a/guest/Makefile
+++ b/guest/Makefile
@@ -1,8 +1,17 @@
+guest: guest16 guest64
+disasm: disasm16 disasm64
+
guest16: guest.ld guest16.S
$(CC) $(CFLAGS) -m16 -o $@ -nostdlib -ffreestanding -Wpedantic -Wall -Wextra -Werror -T guest.ld guest16.S
-disasm: guest16
+guest64: guest.ld guest64.S
+ $(CC) $(CFLAGS) -m64 -o $@ -nostdlib -fPIC -ffreestanding -Wpedantic -Wall -Wextra -Werror -T guest.ld guest64.S
+
+disasm16: guest16
objdump -D -b binary -m i8086 -M intel $^
+disasm64: guest64
+ objdump -D -b binary -m i386:x86-64 -M intel $^
+
clean:
- $(RM) guest16
+ $(RM) guest16 guest64
diff --git a/guest/guest64.S b/guest/guest64.S
new file mode 100644
index 0000000..1862749
--- /dev/null
+++ b/guest/guest64.S
@@ -0,0 +1,17 @@
+.intel_syntax noprefix
+
+.section .boot, "ax", @progbits
+ // Trigger `KVM_EXIT_IO:KVM_EXIT_IO_OUT` by writing string to output port.
+ mov rdx, 0x1000 // Output port.
+ lea rsi, [rip + msg] // Address of string.
+ mov rcx, [rip + msg_len] // Len of string.
+ rep outsb // Write ds:rsi to output port rdx.
+
+ // Trigger `KVM_EXIT_HLT`.
+ hlt
+
+.section .rodata, "a", @progbits
+msg:
+ .asciz "Hello from Long Mode!\n"
+msg_len:
+ .byte .-msg