From patchwork Tue Mar 23 16:37:12 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 87694 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o2NGgOte008347 for ; Tue, 23 Mar 2010 16:42:25 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755313Ab0CWQmU (ORCPT ); Tue, 23 Mar 2010 12:42:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:18750 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752263Ab0CWQmR (ORCPT ); Tue, 23 Mar 2010 12:42:17 -0400 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o2NGgHtr020173 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 23 Mar 2010 12:42:17 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o2NGgGEE012754; Tue, 23 Mar 2010 12:42:16 -0400 Received: from amt.cnet (vpn-10-84.rdu.redhat.com [10.11.10.84]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id o2NGgDe0031033; Tue, 23 Mar 2010 12:42:15 -0400 Received: from amt.cnet (amt.cnet [127.0.0.1]) by amt.cnet (Postfix) with ESMTP id E737C652089; Tue, 23 Mar 2010 13:40:04 -0300 (BRT) Received: (from marcelo@localhost) by amt.cnet (8.14.3/8.14.3/Submit) id o2NGe3Cg019163; Tue, 23 Mar 2010 13:40:03 -0300 Message-Id: <20100323163812.546016358@redhat.com> User-Agent: quilt/0.47-1 Date: Tue, 23 Mar 2010 13:37:12 -0300 From: Marcelo Tosatti To: kvm@vger.kernel.org Cc: Marcelo Tosatti Subject: [patch 3/6] kvm: allow qemu to set EPT identity mapping address References: <20100323163709.033115262@redhat.com> Content-Disposition: inline; filename=identity-map X-Scanned-By: MIMEDefang 2.67 on 10.5.11.17 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Tue, 23 Mar 2010 16:42:25 +0000 (UTC) Index: qemu-uq/target-i386/kvm.c =================================================================== --- qemu-uq.orig/target-i386/kvm.c +++ qemu-uq/target-i386/kvm.c @@ -326,6 +326,25 @@ static int kvm_has_msr_star(CPUState *en return 0; } +static int kvm_init_identity_map_page(KVMState *s) +{ +#ifdef KVM_CAP_SET_IDENTITY_MAP_ADDR + int ret; + uint64_t addr = 0xfffbc000; + + if (!kvm_check_extension(s, KVM_CAP_SET_IDENTITY_MAP_ADDR)) { + return 0; + } + + ret = kvm_vm_ioctl(s, KVM_SET_IDENTITY_MAP_ADDR, &addr); + if (ret < 0) { + fprintf(stderr, "kvm_set_identity_map_addr: %s\n", strerror(ret)); + return ret; + } +#endif + return 0; +} + int kvm_arch_init(KVMState *s, int smp_cpus) { int ret; @@ -353,7 +372,12 @@ int kvm_arch_init(KVMState *s, int smp_c perror("e820_add_entry() table is full"); exit(1); } - return kvm_vm_ioctl(s, KVM_SET_TSS_ADDR, 0xfffbd000); + ret = kvm_vm_ioctl(s, KVM_SET_TSS_ADDR, 0xfffbd000); + if (ret < 0) { + return ret; + } + + return kvm_init_identity_map_page(s); } static void set_v8086_seg(struct kvm_segment *lhs, const SegmentCache *rhs)