From 675ed93badd83cea76c07ebf0febad4204937651 Mon Sep 17 00:00:00 2001 From: Glauber Costa Date: Wed, 10 Sep 2008 16:20:55 -0300 Subject: [PATCH] kvm: libkvm: start removing kernel memory functions kvm_arch_create_default_phys_mem and kvm_alloc_kernel_memory are legacy. Remove them, and their callers. The whole removal will be split for bisectability. These ones goes first because they are only called at initialization Signed-off-by: Glauber Costa Signed-off-by: Avi Kivity --- kvm/libkvm/kvm-common.h | 3 -- kvm/libkvm/libkvm-ia64.c | 25 ------------- kvm/libkvm/libkvm-powerpc.c | 14 ------- kvm/libkvm/libkvm-s390.c | 14 ------- kvm/libkvm/libkvm-x86.c | 91 --------------------------------------------- kvm/libkvm/libkvm.c | 19 +++------- 6 files changed, 5 insertions(+), 161 deletions(-) diff --git a/kvm/libkvm/kvm-common.h b/kvm/libkvm/kvm-common.h index 7092085a1a..93cea1b7b8 100644 --- a/kvm/libkvm/kvm-common.h +++ b/kvm/libkvm/kvm-common.h @@ -78,9 +78,6 @@ void *kvm_create_kernel_phys_mem(kvm_context_t kvm, unsigned long phys_start, int kvm_arch_create(kvm_context_t kvm, unsigned long phys_mem_bytes, void **vm_mem); -int kvm_arch_create_default_phys_mem(kvm_context_t kvm, - unsigned long phys_mem_bytes, - void **vm_mem); int kvm_arch_run(struct kvm_run *run, kvm_context_t kvm, int vcpu); diff --git a/kvm/libkvm/libkvm-ia64.c b/kvm/libkvm/libkvm-ia64.c index f35a16c59a..152d8fd4c3 100644 --- a/kvm/libkvm/libkvm-ia64.c +++ b/kvm/libkvm/libkvm-ia64.c @@ -33,31 +33,6 @@ #include #include -int kvm_arch_create_default_phys_mem(kvm_context_t kvm, - unsigned long phys_mem_bytes, - void **vm_mem) -{ - int zfd; - - zfd = open("/dev/zero", O_RDONLY); - if (zfd == -1) { - perror("open /dev/zero"); - return -1; - } - mmap(*vm_mem + 0xa8000, 0x8000, PROT_READ|PROT_WRITE, - MAP_PRIVATE|MAP_FIXED, zfd, 0); - close(zfd); - - return 0; -} - - -int kvm_alloc_kernel_memory(kvm_context_t kvm, unsigned long memory, - void **vm_mem) -{ - return 0; -} - void *kvm_create_kernel_phys_mem(kvm_context_t kvm, unsigned long phys_start, unsigned long len, int log, int writable) { diff --git a/kvm/libkvm/libkvm-powerpc.c b/kvm/libkvm/libkvm-powerpc.c index 376aca4707..c523f26ac0 100644 --- a/kvm/libkvm/libkvm-powerpc.c +++ b/kvm/libkvm/libkvm-powerpc.c @@ -43,13 +43,6 @@ int handle_dcr(struct kvm_run *run, kvm_context_t kvm, int vcpu) return ret; } -int kvm_alloc_kernel_memory(kvm_context_t kvm, unsigned long memory, - void **vm_mem) -{ - fprintf(stderr, "%s: Operation not supported\n", __FUNCTION__); - return -1; -} - void *kvm_create_kernel_phys_mem(kvm_context_t kvm, unsigned long phys_start, unsigned long len, int log, int writable) { @@ -102,13 +95,6 @@ int kvm_arch_create(kvm_context_t kvm, unsigned long phys_mem_bytes, return 0; } -int kvm_arch_create_default_phys_mem(kvm_context_t kvm, - unsigned long phys_mem_bytes, - void **vm_mem) -{ - return 0; -} - int kvm_arch_run(struct kvm_run *run, kvm_context_t kvm, int vcpu) { int ret = 0; diff --git a/kvm/libkvm/libkvm-s390.c b/kvm/libkvm/libkvm-s390.c index b3e4e92f00..59c534fc27 100644 --- a/kvm/libkvm/libkvm-s390.c +++ b/kvm/libkvm/libkvm-s390.c @@ -22,13 +22,6 @@ #include #include -int kvm_alloc_kernel_memory(kvm_context_t kvm, unsigned long memory, - void **vm_mem) -{ - fprintf(stderr, "%s: Operation not supported\n", __FUNCTION__); - return -1; -} - void *kvm_create_kernel_phys_mem(kvm_context_t kvm, unsigned long phys_start, unsigned long len, int log, int writable) { @@ -87,13 +80,6 @@ int kvm_arch_create(kvm_context_t kvm, unsigned long phys_mem_bytes, return 0; } -int kvm_arch_create_default_phys_mem(kvm_context_t kvm, - unsigned long phys_mem_bytes, - void **vm_mem) -{ - return 0; -} - int kvm_arch_run(struct kvm_run *run, kvm_context_t kvm, int vcpu) { int ret = 0; diff --git a/kvm/libkvm/libkvm-x86.c b/kvm/libkvm/libkvm-x86.c index ea97bdd23c..4ca3d7ba3c 100644 --- a/kvm/libkvm/libkvm-x86.c +++ b/kvm/libkvm/libkvm-x86.c @@ -13,79 +13,6 @@ #include #include -int kvm_alloc_kernel_memory(kvm_context_t kvm, unsigned long memory, - void **vm_mem) -{ - unsigned long dosmem = 0xa0000; - unsigned long exmem = 0xc0000; - unsigned long pcimem = 0xe0000000; - int r; - int tss_ext; - struct kvm_memory_region low_memory = { - .memory_size = memory < dosmem ? memory : dosmem, - .guest_phys_addr = 0, - }; - struct kvm_memory_region extended_memory = { - .memory_size = memory < exmem ? 0 : memory - exmem, - .guest_phys_addr = exmem, - }; - struct kvm_memory_region above_4g_memory = { - .memory_size = memory < pcimem ? 0 : memory - pcimem, - .guest_phys_addr = 0x100000000ULL, - }; - -#ifdef KVM_CAP_SET_TSS_ADDR - tss_ext = ioctl(kvm->fd, KVM_CHECK_EXTENSION, KVM_CAP_SET_TSS_ADDR); -#else - tss_ext = 0; -#endif - - if (memory >= pcimem) - extended_memory.memory_size = pcimem - exmem; - - /* 640K should be enough. */ - low_memory.slot = get_free_slot(kvm); - r = ioctl(kvm->vm_fd, KVM_SET_MEMORY_REGION, &low_memory); - if (r == -1) { - fprintf(stderr, "kvm_create_memory_region: %m\n"); - return -1; - } - register_slot(low_memory.slot, low_memory.guest_phys_addr, - low_memory.memory_size, 0, 0, 0); - - - if (extended_memory.memory_size) { - if (tss_ext > 0) - extended_memory.slot = get_free_slot(kvm); - else - extended_memory.slot = 0; - r = ioctl(kvm->vm_fd, KVM_SET_MEMORY_REGION, &extended_memory); - if (r == -1) { - fprintf(stderr, "kvm_create_memory_region: %m\n"); - return -1; - } - register_slot(extended_memory.slot, - extended_memory.guest_phys_addr, - extended_memory.memory_size, 0, 0, 0); - } - - if (above_4g_memory.memory_size) { - above_4g_memory.slot = get_free_slot(kvm); - r = ioctl(kvm->vm_fd, KVM_SET_MEMORY_REGION, &above_4g_memory); - if (r == -1) { - fprintf(stderr, "kvm_create_memory_region: %m\n"); - return -1; - } - register_slot(above_4g_memory.slot, - above_4g_memory.guest_phys_addr, - above_4g_memory.memory_size, 0, 0, 0); - } - - *vm_mem = mmap(NULL, memory, PROT_READ|PROT_WRITE, MAP_SHARED, kvm->vm_fd, 0); - - return 0; -} - int kvm_set_tss_addr(kvm_context_t kvm, unsigned long addr) { #ifdef KVM_CAP_SET_TSS_ADDR @@ -126,24 +53,6 @@ static int kvm_init_tss(kvm_context_t kvm) return 0; } -int kvm_arch_create_default_phys_mem(kvm_context_t kvm, - unsigned long phys_mem_bytes, - void **vm_mem) -{ - int zfd; - - zfd = open("/dev/zero", O_RDONLY); - if (zfd == -1) { - perror("open /dev/zero"); - return -1; - } - mmap(*vm_mem + 0xa8000, 0x8000, PROT_READ|PROT_WRITE, - MAP_PRIVATE|MAP_FIXED, zfd, 0); - close(zfd); - - return 0; -} - int kvm_create_pit(kvm_context_t kvm) { #ifdef KVM_CAP_PIT diff --git a/kvm/libkvm/libkvm.c b/kvm/libkvm/libkvm.c index 250a821d72..d0c65cbebd 100644 --- a/kvm/libkvm/libkvm.c +++ b/kvm/libkvm/libkvm.c @@ -328,24 +328,15 @@ static int kvm_create_default_phys_mem(kvm_context_t kvm, unsigned long phys_mem_bytes, void **vm_mem) { - unsigned long memory = (phys_mem_bytes + PAGE_SIZE - 1) & PAGE_MASK; - int r; - #ifdef KVM_CAP_USER_MEMORY - r = ioctl(kvm->fd, KVM_CHECK_EXTENSION, KVM_CAP_USER_MEMORY); + int r = ioctl(kvm->fd, KVM_CHECK_EXTENSION, KVM_CAP_USER_MEMORY); if (r > 0) return 0; - else + fprintf(stderr, "Hypervisor too old: KVM_CAP_USER_MEMORY extension not supported\n"); +#else +#error Hypervisor too old: KVM_CAP_USER_MEMORY extension not supported #endif - r = kvm_alloc_kernel_memory(kvm, memory, vm_mem); - if (r < 0) - return r; - - r = kvm_arch_create_default_phys_mem(kvm, phys_mem_bytes, vm_mem); - if (r < 0) - return r; - - return 0; + return -1; } int kvm_check_extension(kvm_context_t kvm, int ext) -- 2.11.4.GIT