From a6ea073ad7e76a3d556b4fda3b386c232ae6f0e2 Mon Sep 17 00:00:00 2001 From: Pekka Enberg Date: Sun, 4 Jul 2010 13:41:45 +0300 Subject: [PATCH] kvm: Add proper 00E0 ioport handling We use 00E0 ioport for trapping to the hypervisor. This patch cleans up handling of the ioport to call exit() in ioport emulation handler. Signed-off-by: Pekka Enberg --- tools/kvm/Makefile | 2 +- tools/kvm/ioport.c | 14 ++++++++++++++ tools/kvm/main.c | 14 +------------- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/tools/kvm/Makefile b/tools/kvm/Makefile index 5dee20b1d8a4..6096ac713a6b 100644 --- a/tools/kvm/Makefile +++ b/tools/kvm/Makefile @@ -79,7 +79,7 @@ bios/int10.o: bios/int10.S bios/int10-real.S check: $(PROGRAM) $(MAKE) -C tests - ./$(PROGRAM) --dbgtest tests/pit/tick.bin + ./$(PROGRAM) tests/pit/tick.bin .PHONY: check clean: diff --git a/tools/kvm/ioport.c b/tools/kvm/ioport.c index 42454d2d30e3..4bcc2b7dbf96 100644 --- a/tools/kvm/ioport.c +++ b/tools/kvm/ioport.c @@ -4,6 +4,7 @@ #include #include +#include #include static uint8_t ioport_to_uint8(void *data) @@ -28,6 +29,15 @@ static struct ioport_operations cmos_ram_rtc_ops = { .io_out = cmos_ram_rtc_io_out, }; +static bool debug_io_out(struct kvm *self, uint16_t port, void *data, int size, uint32_t count) +{ + exit(EXIT_SUCCESS); +} + +static struct ioport_operations debug_ops = { + .io_out = debug_io_out, +}; + static bool dummy_io_in(struct kvm *self, uint16_t port, void *data, int size, uint32_t count) { return true; @@ -70,6 +80,10 @@ static struct ioport_operations *ioport_ops[USHRT_MAX] = { [0x00A0] = &dummy_read_write_ioport_ops, [0x00A1] = &dummy_read_write_ioport_ops, + /* PORT 00E0-00EF are 'motherboard specific' so we use them for our + internal debugging purposes. */ + [0x00E0] = &debug_ops, + /* PORT 00ED - DUMMY PORT FOR DELAY??? */ [0x00ED] = &dummy_write_only_ioport_ops, diff --git a/tools/kvm/main.c b/tools/kvm/main.c index 9002c0ff6d2b..91be73585c9d 100644 --- a/tools/kvm/main.c +++ b/tools/kvm/main.c @@ -10,11 +10,9 @@ #include #include -unsigned int dbgtest_mode; - static void usage(char *argv[]) { - fprintf(stderr, " usage: %s [--dbgtest] [--single-step] [--kernel=]\n", + fprintf(stderr, " usage: %s [--single-step] [--kernel=]\n", argv[0]); exit(1); } @@ -55,9 +53,6 @@ int main(int argc, char *argv[]) } else if (option_matches(argv[i], "--params=")) { kernel_cmdline = &argv[i][9]; continue; - } else if (option_matches(argv[i], "--dbgtest")) { - dbgtest_mode = 1; - continue; } else if (option_matches(argv[i], "--single-step")) { single_step = true; continue; @@ -137,13 +132,6 @@ int main(int argc, char *argv[]) exit_kvm: - if (dbgtest_mode) { - if (kvm->kvm_run->exit_reason == KVM_EXIT_IO && - kvm->kvm_run->io.port == 0xe0) - fprintf(stderr, "KVM: this is an expected IO error\n"); - goto out; - } - fprintf(stderr, "KVM exit reason: %" PRIu32 " (\"%s\")\n", kvm->kvm_run->exit_reason, kvm_exit_reasons[kvm->kvm_run->exit_reason]); if (kvm->kvm_run->exit_reason == KVM_EXIT_UNKNOWN) -- 2.39.5