From patchwork Sat Nov 6 00:43:29 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 70315 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id B60401007D1 for ; Sat, 6 Nov 2010 12:05:34 +1100 (EST) Received: from localhost ([127.0.0.1]:50856 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PEWva-00073e-I6 for incoming@patchwork.ozlabs.org; Fri, 05 Nov 2010 20:46:42 -0400 Received: from [140.186.70.92] (port=38837 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PEWuF-0005tv-OT for qemu-devel@nongnu.org; Fri, 05 Nov 2010 20:45:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PEWuA-0004V7-A0 for qemu-devel@nongnu.org; Fri, 05 Nov 2010 20:45:15 -0400 Received: from mx1.redhat.com ([209.132.183.28]:11223) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PEWuA-0004Ur-2K for qemu-devel@nongnu.org; Fri, 05 Nov 2010 20:45:14 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oA60jBJt032677 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 5 Nov 2010 20:45:12 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id oA60jBXR020549; Fri, 5 Nov 2010 20:45:11 -0400 Received: from amt.cnet (vpn-8-217.rdu.redhat.com [10.11.8.217]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id oA60j9fu026269; Fri, 5 Nov 2010 20:45:10 -0400 Received: from amt.cnet (localhost.localdomain [127.0.0.1]) by amt.cnet (Postfix) with ESMTP id 2F1ED6520A6; Fri, 5 Nov 2010 22:43:34 -0200 (BRST) Received: (from marcelo@localhost) by amt.cnet (8.14.4/8.14.4/Submit) id oA60hW1q004171; Fri, 5 Nov 2010 22:43:32 -0200 From: Marcelo Tosatti To: Anthony Liguori Date: Fri, 5 Nov 2010 22:43:29 -0200 Message-Id: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: Gleb Natapov , Marcelo Tosatti , qemu-devel@nongnu.org, kvm@vger.kernel.org Subject: [Qemu-devel] [PATCH 1/1] Add support for async page fault to qemu X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Gleb Natapov Add save/restore of MSR for migration and cpuid bit. Signed-off-by: Gleb Natapov Signed-off-by: Marcelo Tosatti --- target-i386/cpu.h | 1 + target-i386/cpuid.c | 2 +- target-i386/kvm.c | 14 ++++++++++++++ target-i386/machine.c | 26 ++++++++++++++++++++++++++ 4 files changed, 42 insertions(+), 1 deletions(-) diff --git a/target-i386/cpu.h b/target-i386/cpu.h index 2440d65..06e40f3 100644 --- a/target-i386/cpu.h +++ b/target-i386/cpu.h @@ -681,6 +681,7 @@ typedef struct CPUX86State { #endif uint64_t system_time_msr; uint64_t wall_clock_msr; + uint64_t async_pf_en_msr; uint64_t tsc; diff --git a/target-i386/cpuid.c b/target-i386/cpuid.c index 650a719..165045e 100644 --- a/target-i386/cpuid.c +++ b/target-i386/cpuid.c @@ -73,7 +73,7 @@ static const char *ext3_feature_name[] = { }; static const char *kvm_feature_name[] = { - "kvmclock", "kvm_nopiodelay", "kvm_mmu", NULL, NULL, NULL, NULL, NULL, + "kvmclock", "kvm_nopiodelay", "kvm_mmu", NULL, "kvm_asyncpf", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, diff --git a/target-i386/kvm.c b/target-i386/kvm.c index ae0a034..7dfc357 100644 --- a/target-i386/kvm.c +++ b/target-i386/kvm.c @@ -162,6 +162,9 @@ struct kvm_para_features { #ifdef KVM_CAP_PV_MMU { KVM_CAP_PV_MMU, KVM_FEATURE_MMU_OP }, #endif +#ifdef KVM_CAP_ASYNC_PF + { KVM_CAP_ASYNC_PF, KVM_FEATURE_ASYNC_PF }, +#endif { -1, -1 } }; @@ -838,6 +841,9 @@ static int kvm_put_msrs(CPUState *env, int level) kvm_msr_entry_set(&msrs[n++], MSR_KVM_SYSTEM_TIME, env->system_time_msr); kvm_msr_entry_set(&msrs[n++], MSR_KVM_WALL_CLOCK, env->wall_clock_msr); +#ifdef KVM_CAP_ASYNC_PF + kvm_msr_entry_set(&msrs[n++], MSR_KVM_ASYNC_PF_EN, env->async_pf_en_msr); +#endif } #ifdef KVM_CAP_MCE if (env->mcg_cap) { @@ -1064,6 +1070,9 @@ static int kvm_get_msrs(CPUState *env) #endif msrs[n++].index = MSR_KVM_SYSTEM_TIME; msrs[n++].index = MSR_KVM_WALL_CLOCK; +#ifdef KVM_CAP_ASYNC_PF + msrs[n++].index = MSR_KVM_ASYNC_PF_EN; +#endif #ifdef KVM_CAP_MCE if (env->mcg_cap) { @@ -1135,6 +1144,11 @@ static int kvm_get_msrs(CPUState *env) } #endif break; +#ifdef KVM_CAP_ASYNC_PF + case MSR_KVM_ASYNC_PF_EN: + env->async_pf_en_msr = msrs[i].data; + break; +#endif } } diff --git a/target-i386/machine.c b/target-i386/machine.c index 5f8376c..d78eceb 100644 --- a/target-i386/machine.c +++ b/target-i386/machine.c @@ -373,6 +373,24 @@ static int cpu_post_load(void *opaque, int version_id) return 0; } +static bool async_pf_msr_needed(void *opaque) +{ + CPUState *cpu = opaque; + + return cpu->async_pf_en_msr != 0; +} + +static const VMStateDescription vmstate_async_pf_msr = { + .name = "cpu/async_pf_msr", + .version_id = 1, + .minimum_version_id = 1, + .minimum_version_id_old = 1, + .fields = (VMStateField []) { + VMSTATE_UINT64(async_pf_en_msr, CPUState), + VMSTATE_END_OF_LIST() + } +}; + static const VMStateDescription vmstate_cpu = { .name = "cpu", .version_id = CPU_SAVE_VERSION, @@ -475,6 +493,14 @@ static const VMStateDescription vmstate_cpu = { VMSTATE_YMMH_REGS_VARS(ymmh_regs, CPUState, CPU_NB_REGS, 12), VMSTATE_END_OF_LIST() /* The above list is not sorted /wrt version numbers, watch out! */ + }, + .subsections = (VMStateSubsection []) { + { + .vmsd = &vmstate_async_pf_msr, + .needed = async_pf_msr_needed, + } , { + /* empty */ + } } };