From 1cc96be1c7445ce141c661293572ab4350bf1b07 Mon Sep 17 00:00:00 2001 From: Pekka Enberg Date: Sun, 11 Apr 2010 15:15:02 +0300 Subject: [PATCH] kvm: Ignore MMIO accesses Lets cheat some more and ignore MMIO accesses altogether. Signed-off-by: Pekka Enberg --- tools/kvm/Makefile | 3 ++- tools/kvm/include/kvm/kvm.h | 1 + tools/kvm/main.c | 14 ++++++++++++++ tools/kvm/mmio.c | 19 +++++++++++++++++++ 4 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 tools/kvm/mmio.c diff --git a/tools/kvm/Makefile b/tools/kvm/Makefile index bc1290d1336c..1846f3c4f7e7 100644 --- a/tools/kvm/Makefile +++ b/tools/kvm/Makefile @@ -14,9 +14,10 @@ OBJS += interrupt.o OBJS += ioport.o OBJS += kvm.o OBJS += main.o +OBJS += mmio.o OBJS += util.o -OBJS += bios/c-intfake.o OBJS += bios/c-int10.o +OBJS += bios/c-intfake.o CFLAGS += $(CPPFLAGS) -Iinclude -g diff --git a/tools/kvm/include/kvm/kvm.h b/tools/kvm/include/kvm/kvm.h index 61100151de37..2d39b6211c0b 100644 --- a/tools/kvm/include/kvm/kvm.h +++ b/tools/kvm/include/kvm/kvm.h @@ -39,6 +39,7 @@ bool kvm__load_kernel(struct kvm *kvm, const char *kernel_filename, const char * void kvm__reset_vcpu(struct kvm *self); void kvm__run(struct kvm *self); bool kvm__emulate_io(struct kvm *self, uint16_t port, void *data, int direction, int size, uint32_t count); +bool kvm__emulate_mmio(struct kvm *self, uint64_t phys_addr, uint8_t *data, uint32_t len, uint8_t is_write); /* * Debugging diff --git a/tools/kvm/main.c b/tools/kvm/main.c index 5e72cf5f7816..b6414e77f474 100644 --- a/tools/kvm/main.c +++ b/tools/kvm/main.c @@ -80,6 +80,20 @@ int main(int argc, char *argv[]) goto exit_kvm; break; } + case KVM_EXIT_MMIO: { + bool ret; + + ret = kvm__emulate_mmio(kvm, + kvm->kvm_run->mmio.phys_addr, + kvm->kvm_run->mmio.data, + kvm->kvm_run->mmio.len, + kvm->kvm_run->mmio.is_write); + + if (!ret) + goto exit_kvm; + break; + + } default: goto exit_kvm; } diff --git a/tools/kvm/mmio.c b/tools/kvm/mmio.c new file mode 100644 index 000000000000..095d2c9d919a --- /dev/null +++ b/tools/kvm/mmio.c @@ -0,0 +1,19 @@ +#include "kvm/kvm.h" + +#include + +static const char *to_direction(uint8_t is_write) +{ + if (is_write) + return "write"; + + return "read"; +} + +bool kvm__emulate_mmio(struct kvm *self, uint64_t phys_addr, uint8_t *data, uint32_t len, uint8_t is_write) +{ + fprintf(stderr, "Warning: Ignoring MMIO %s at %016" PRIx64 " (length %" PRIu32 ")\n", + to_direction(is_write), phys_addr, len); + + return true; +} -- 2.39.5