From patchwork Thu Oct 21 15:08:45 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gleb Natapov X-Patchwork-Id: 68624 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 C0809B7100 for ; Fri, 22 Oct 2010 02:13:42 +1100 (EST) Received: from localhost ([127.0.0.1]:59773 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P8wpn-0007K5-Lc for incoming@patchwork.ozlabs.org; Thu, 21 Oct 2010 11:13:39 -0400 Received: from [140.186.70.92] (port=42655 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P8wl8-00057I-Pi for qemu-devel@nongnu.org; Thu, 21 Oct 2010 11:08:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1P8wl7-0000Up-88 for qemu-devel@nongnu.org; Thu, 21 Oct 2010 11:08:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50428) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1P8wl7-0000UP-1h for qemu-devel@nongnu.org; Thu, 21 Oct 2010 11:08:49 -0400 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o9LF8kPP004368 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 21 Oct 2010 11:08:47 -0400 Received: from dhcp-1-237.tlv.redhat.com (dhcp-1-237.tlv.redhat.com [10.35.1.237]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o9LF8jaN009918; Thu, 21 Oct 2010 11:08:46 -0400 Received: by dhcp-1-237.tlv.redhat.com (Postfix, from userid 13519) id 9FCFB18D46D; Thu, 21 Oct 2010 17:08:45 +0200 (IST) Date: Thu, 21 Oct 2010 17:08:45 +0200 From: Gleb Natapov To: kvm@vger.kernel.org Message-ID: <20101021150845.GD2343@redhat.com> References: <20101018132538.GC10207@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20101018132538.GC10207@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.16 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCHv2] 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 Add save/restore of MSR for migration and cpuid bit. Signed-off-by: Gleb Natapov --- v1->v2 - use vmstate subsection to migrate new msr. -- Gleb. diff --git a/qemu-kvm-x86.c b/qemu-kvm-x86.c index 59aacd0..145c863 100644 --- a/qemu-kvm-x86.c +++ b/qemu-kvm-x86.c @@ -678,6 +678,9 @@ static int get_msr_entry(struct kvm_msr_entry *entry, CPUState *env) env->mcg_ctl = entry->data; break; #endif + case MSR_KVM_ASYNC_PF_EN: + env->async_pf_en_msr = entry->data; + break; default: #ifdef KVM_CAP_MCE if (entry->index >= MSR_MC0_CTL && @@ -967,6 +970,7 @@ void kvm_arch_load_regs(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); + kvm_msr_entry_set(&msrs[n++], MSR_KVM_ASYNC_PF_EN, env->async_pf_en_msr); } #ifdef KVM_CAP_MCE if (env->mcg_cap) { @@ -1186,6 +1190,7 @@ void kvm_arch_save_regs(CPUState *env) #endif msrs[n++].index = MSR_KVM_SYSTEM_TIME; msrs[n++].index = MSR_KVM_WALL_CLOCK; + msrs[n++].index = MSR_KVM_ASYNC_PF_EN; #ifdef KVM_CAP_MCE if (env->mcg_cap) { diff --git a/target-i386/cpu.h b/target-i386/cpu.h index 8b6efed..6d1d6a0 100644 --- a/target-i386/cpu.h +++ b/target-i386/cpu.h @@ -669,6 +669,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 d63fdcb..0ee1f88 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 f4fc063..0eb1e90 100644 --- a/target-i386/kvm.c +++ b/target-i386/kvm.c @@ -151,6 +151,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 } }; @@ -672,6 +675,7 @@ 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); + kvm_msr_entry_set(&msrs[n++], MSR_KVM_ASYNC_PF_EN, env->async_pf_en_msr); } msr_data.info.nmsrs = n; @@ -880,6 +884,7 @@ static int kvm_get_msrs(CPUState *env) #endif msrs[n++].index = MSR_KVM_SYSTEM_TIME; msrs[n++].index = MSR_KVM_WALL_CLOCK; + msrs[n++].index = MSR_KVM_ASYNC_PF_EN; msr_data.info.nmsrs = n; ret = kvm_vcpu_ioctl(env, KVM_GET_MSRS, &msr_data); @@ -926,6 +931,9 @@ static int kvm_get_msrs(CPUState *env) case MSR_VM_HSAVE_PA: env->vm_hsave = msrs[i].data; break; + case MSR_KVM_ASYNC_PF_EN: + env->async_pf_en_msr = msrs[i].data; + break; } } diff --git a/target-i386/machine.c b/target-i386/machine.c index 4398801..bf14067 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, @@ -476,6 +494,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 */ + } } };