diff options
Diffstat (limited to 'guest')
-rw-r--r-- | guest/Makefile | 17 | ||||
-rw-r--r-- | guest/guest64.S | 8 |
2 files changed, 14 insertions, 11 deletions
diff --git a/guest/Makefile b/guest/Makefile index 5dca740..635759a 100644 --- a/guest/Makefile +++ b/guest/Makefile @@ -1,17 +1,14 @@ +ARCH16 := i8086 +ARCH64 := i386:x86-64 + 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 - -guest64: guest.ld guest64.S - $(CC) $(CFLAGS) -m64 -o $@ -nostdlib -ffreestanding -Wpedantic -Wall -Wextra -Werror -T guest.ld guest64.S - -disasm16: guest16 - objdump -D -b binary -m i8086 -M intel $^ +guest%: guest.ld guest%.S + $(CC) $(CFLAGS) -m$* -o $@ -nostdlib -ffreestanding -Wpedantic -Wall -Wextra -Werror -T guest.ld guest$*.S -disasm64: guest64 - objdump -D -b binary -m i386:x86-64 -M intel $^ +disasm%: guest% + objdump -D -b binary -m $(ARCH$*) -M intel $^ clean: $(RM) guest16 guest64 diff --git a/guest/guest64.S b/guest/guest64.S index 6629273..533d186 100644 --- a/guest/guest64.S +++ b/guest/guest64.S @@ -9,9 +9,15 @@ // Trigger `KVM_EXIT_IO:KVM_EXIT_IO_IN` by reading byte to memory from input port. mov dx, 0x1000 // Input port. - lea di, [in_dest] // Destination address. + lea di, [rip + in_dest] // Destination address. insb // Read byte from input port dx to ds:di. + // Write to allocated virtual addresses. + mov byte ptr ds:[0x2000], 0xaa + mov byte ptr ds:[0x2001], 0xbb + mov byte ptr ds:[0x2002], 0xcc + mov byte ptr ds:[0x2003], 0xdd + // Trigger `KVM_EXIT_HLT`. hlt |