From patchwork Sat Aug 24 03:49:54 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 269609 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 6FDE02C0092 for ; Sat, 24 Aug 2013 13:51:06 +1000 (EST) Received: from localhost ([::1]:39757 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VD4sS-0007Er-Me for incoming@patchwork.ozlabs.org; Fri, 23 Aug 2013 23:51:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52313) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VD4rm-0007Bi-NM for qemu-devel@nongnu.org; Fri, 23 Aug 2013 23:50:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VD4re-0002TF-5n for qemu-devel@nongnu.org; Fri, 23 Aug 2013 23:50:22 -0400 Received: from mail-ee0-x231.google.com ([2a00:1450:4013:c00::231]:40476) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VD4rd-0002T6-Rl for qemu-devel@nongnu.org; Fri, 23 Aug 2013 23:50:14 -0400 Received: by mail-ee0-f49.google.com with SMTP id d41so592684eek.22 for ; Fri, 23 Aug 2013 20:50:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=4iOm4vEqVkkclIYgHK0ZzDBpEo/pyViXxu8niVFUrHU=; b=irWHZiwUL89Iu6+QHCNQ4bR8YeEKmsAUfPVtQQhnBBoTCCFW7VrxnM9Z3bSEt85UZ1 Ha9AB5DeyHEM9k3RbWXqbJbrWsn9NRprXYxdDI9Li8D6wXuIt8QYavPMkHAvHqAtu/JS z910r5MlNc6UvKQumYHFBK5c5cteq9x34EsKXMlGMALMZ/juY7jBoZbQ/XzJwlqvLV9/ UmBiTHmmqHNByD/XCAEg1TXlrVp7VgfAx2WgXOO0nyx/BdR6rHLckvjMWNjRZSzVvKKw VavrLxZVcf8+UVsB2cDShJ33hLv48X/PsbMxaFWvKEyjzmxXjFYbDWjfoCF9X8/BAoCt esRw== X-Received: by 10.15.35.196 with SMTP id g44mr4184975eev.18.1377316213054; Fri, 23 Aug 2013 20:50:13 -0700 (PDT) Received: from yakj.lan (net-37-116-203-123.cust.dsl.vodafone.it. [37.116.203.123]) by mx.google.com with ESMTPSA id b45sm3950848eef.4.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 23 Aug 2013 20:50:11 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Sat, 24 Aug 2013 05:49:54 +0200 Message-Id: <1377316202-2849-2-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1377316202-2849-1-git-send-email-pbonzini@redhat.com> References: <1377316202-2849-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4013:c00::231 Cc: Arthur Chunqi Li , anthony@codemonkey.ws, gleb@redhat.com Subject: [Qemu-devel] [PULL 1/9] Initialize IA32_FEATURE_CONTROL MSR in reset and migration X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Arthur Chunqi Li The recent KVM patch adds IA32_FEATURE_CONTROL support. QEMU needs to clear this MSR when reset vCPU and keep the value of it when migration. This patch add this feature. Signed-off-by: Arthur Chunqi Li Signed-off-by: Gleb Natapov --- target-i386/cpu.h | 2 ++ target-i386/kvm.c | 4 ++++ target-i386/machine.c | 22 ++++++++++++++++++++++ 3 files changed, 28 insertions(+) diff --git a/target-i386/cpu.h b/target-i386/cpu.h index cedefdc..3a52f94 100644 --- a/target-i386/cpu.h +++ b/target-i386/cpu.h @@ -301,6 +301,7 @@ #define MSR_IA32_APICBASE_BSP (1<<8) #define MSR_IA32_APICBASE_ENABLE (1<<11) #define MSR_IA32_APICBASE_BASE (0xfffff<<12) +#define MSR_IA32_FEATURE_CONTROL 0x0000003a #define MSR_TSC_ADJUST 0x0000003b #define MSR_IA32_TSCDEADLINE 0x6e0 @@ -813,6 +814,7 @@ typedef struct CPUX86State { uint64_t mcg_status; uint64_t msr_ia32_misc_enable; + uint64_t msr_ia32_feature_control; /* exception/interrupt handling */ int error_code; diff --git a/target-i386/kvm.c b/target-i386/kvm.c index 3c9d10a..84ac00a 100644 --- a/target-i386/kvm.c +++ b/target-i386/kvm.c @@ -1121,6 +1121,7 @@ static int kvm_put_msrs(X86CPU *cpu, int level) if (hyperv_vapic_recommended()) { kvm_msr_entry_set(&msrs[n++], HV_X64_MSR_APIC_ASSIST_PAGE, 0); } + kvm_msr_entry_set(&msrs[n++], MSR_IA32_FEATURE_CONTROL, env->msr_ia32_feature_control); } if (env->mcg_cap) { int i; @@ -1345,6 +1346,7 @@ static int kvm_get_msrs(X86CPU *cpu) if (has_msr_misc_enable) { msrs[n++].index = MSR_IA32_MISC_ENABLE; } + msrs[n++].index = MSR_IA32_FEATURE_CONTROL; if (!env->tsc_valid) { msrs[n++].index = MSR_IA32_TSC; @@ -1443,6 +1445,8 @@ static int kvm_get_msrs(X86CPU *cpu) case MSR_IA32_MISC_ENABLE: env->msr_ia32_misc_enable = msrs[i].data; break; + case MSR_IA32_FEATURE_CONTROL: + env->msr_ia32_feature_control = msrs[i].data; default: if (msrs[i].index >= MSR_MC0_CTL && msrs[i].index < MSR_MC0_CTL + (env->mcg_cap & 0xff) * 4) { diff --git a/target-i386/machine.c b/target-i386/machine.c index f9ec581..0d2088e 100644 --- a/target-i386/machine.c +++ b/target-i386/machine.c @@ -435,6 +435,14 @@ static bool misc_enable_needed(void *opaque) return env->msr_ia32_misc_enable != MSR_IA32_MISC_ENABLE_DEFAULT; } +static bool feature_control_needed(void *opaque) +{ + X86CPU *cpu = opaque; + CPUX86State *env = &cpu->env; + + return env->msr_ia32_feature_control != 0; +} + static const VMStateDescription vmstate_msr_ia32_misc_enable = { .name = "cpu/msr_ia32_misc_enable", .version_id = 1, @@ -446,6 +454,17 @@ static const VMStateDescription vmstate_msr_ia32_misc_enable = { } }; +static const VMStateDescription vmstate_msr_ia32_feature_control = { + .name = "cpu/msr_ia32_feature_control", + .version_id = 1, + .minimum_version_id = 1, + .minimum_version_id_old = 1, + .fields = (VMStateField []) { + VMSTATE_UINT64(env.msr_ia32_feature_control, X86CPU), + VMSTATE_END_OF_LIST() + } +}; + const VMStateDescription vmstate_x86_cpu = { .name = "cpu", .version_id = 12, @@ -571,6 +590,9 @@ const VMStateDescription vmstate_x86_cpu = { }, { .vmsd = &vmstate_msr_ia32_misc_enable, .needed = misc_enable_needed, + }, { + .vmsd = &vmstate_msr_ia32_feature_control, + .needed = feature_control_needed, } , { /* empty */ }