From 21c2e3c672676b598c4f84bcf83fe826e7ac0664 Mon Sep 17 00:00:00 2001 From: Cyrill Gorcunov Date: Thu, 10 Jun 2010 20:55:40 +0400 Subject: [PATCH] kvm: Add force exit from tests To make so we write any value to port 0 and start kvm in --dbgtest mode so we are expecting for this exit. Signed-off-by: Cyrill Gorcunov --- tools/kvm/Makefile | 2 +- tools/kvm/main.c | 17 +++++++++++++++-- tools/kvm/tests/pit/tick.S | 6 +++++- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/tools/kvm/Makefile b/tools/kvm/Makefile index 6096ac713a6..5dee20b1d8a 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) tests/pit/tick.bin + ./$(PROGRAM) --dbgtest tests/pit/tick.bin .PHONY: check clean: diff --git a/tools/kvm/main.c b/tools/kvm/main.c index 5135de15eff..ded9dda2e5f 100644 --- a/tools/kvm/main.c +++ b/tools/kvm/main.c @@ -10,9 +10,11 @@ #include #include +unsigned int dbgtest_mode; + static void usage(char *argv[]) { - fprintf(stderr, " usage: %s [--single-step] [--kernel=]\n", + fprintf(stderr, " usage: %s [--dbgtest] [--single-step] [--kernel=]\n", argv[0]); exit(1); } @@ -48,6 +50,9 @@ int main(int argc, char *argv[]) } else if (!strncmp("--params=", argv[i], 9)) { kernel_cmdline = &argv[i][9]; continue; + } else if (!strncmp("--dbgtest", argv[i], 9)) { + dbgtest_mode = 1; + continue; } else if (!strncmp("--single-step", argv[i], 13)) { single_step = true; continue; @@ -126,6 +131,14 @@ 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 == 0) + 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) @@ -135,7 +148,7 @@ exit_kvm: kvm__show_registers(kvm); kvm__show_code(kvm); kvm__show_page_tables(kvm); - +out: kvm__delete(kvm); return 0; diff --git a/tools/kvm/tests/pit/tick.S b/tools/kvm/tests/pit/tick.S index 847793f5c9e..8c98e31d7bb 100644 --- a/tools/kvm/tests/pit/tick.S +++ b/tools/kvm/tests/pit/tick.S @@ -4,6 +4,8 @@ #define TIMER_FREQ 1193182 #define TIMER_DIV(x) ((TIMER_FREQ+(x)/2)/(x)) +#define DBG_PORT 0 + #define TEST_COUNT 0x0200 .code16gcc @@ -72,7 +74,9 @@ test_ok: cs lea msg2, %si mov $(msg2_end-msg2), %cx cs rep/outsb - hlt + + /* not a valid port to force exit */ + outb %al, $DBG_PORT timer_isr: cli -- 2.11.4.GIT