From patchwork Wed Sep 23 06:27:33 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Shah X-Patchwork-Id: 7247781 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 499CBBEEC1 for ; Wed, 23 Sep 2015 06:27:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6D11C207A9 for ; Wed, 23 Sep 2015 06:27:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4BA8B207A8 for ; Wed, 23 Sep 2015 06:27:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752105AbbIWG1v (ORCPT ); Wed, 23 Sep 2015 02:27:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59756 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751421AbbIWG1u (ORCPT ); Wed, 23 Sep 2015 02:27:50 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id EE4952F90DC; Wed, 23 Sep 2015 06:27:49 +0000 (UTC) Received: from localhost ([10.3.113.10]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8N6RlUn018179; Wed, 23 Sep 2015 02:27:49 -0400 From: Amit Shah To: qemu list , kvm list Cc: Amit Shah , Paolo Bonzini , Juan Quintela , "Dr. David Alan Gilbert" , Marcelo Tosatti , Richard Henderson , Eduardo Habkost Subject: [PATCH 1/1] target-i386: get/put MSR_TSC_AUX across reset and migration Date: Wed, 23 Sep 2015 11:57:33 +0530 Message-Id: <7e1d1d52d0599c8c3d3e043b5d96ff8732c91250.1442989653.git.amit.shah@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP There's one report of migration breaking due to missing MSR_TSC_AUX save/restore. Fix this by adding a new subsection that saves the state of this MSR. https://bugzilla.redhat.com/show_bug.cgi?id=1261797 Reported-by: Xiaoqing Wei Signed-off-by: Amit Shah CC: Paolo Bonzini CC: Juan Quintela CC: "Dr. David Alan Gilbert" CC: Marcelo Tosatti CC: Richard Henderson CC: Eduardo Habkost Reviewed-by: Eduardo Habkost --- target-i386/kvm.c | 14 ++++++++++++++ target-i386/machine.c | 20 ++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/target-i386/kvm.c b/target-i386/kvm.c index 7b0ba17..80d1a7e 100644 --- a/target-i386/kvm.c +++ b/target-i386/kvm.c @@ -67,6 +67,7 @@ const KVMCapabilityInfo kvm_arch_required_capabilities[] = { static bool has_msr_star; static bool has_msr_hsave_pa; +static bool has_msr_tsc_aux; static bool has_msr_tsc_adjust; static bool has_msr_tsc_deadline; static bool has_msr_feature_control; @@ -825,6 +826,10 @@ static int kvm_get_supported_msrs(KVMState *s) has_msr_hsave_pa = true; continue; } + if (kvm_msr_list->indices[i] == MSR_TSC_AUX) { + has_msr_tsc_aux = true; + continue; + } if (kvm_msr_list->indices[i] == MSR_TSC_ADJUST) { has_msr_tsc_adjust = true; continue; @@ -1299,6 +1304,9 @@ static int kvm_put_msrs(X86CPU *cpu, int level) if (has_msr_hsave_pa) { kvm_msr_entry_set(&msrs[n++], MSR_VM_HSAVE_PA, env->vm_hsave); } + if (has_msr_tsc_aux) { + kvm_msr_entry_set(&msrs[n++], MSR_TSC_AUX, env->tsc_aux); + } if (has_msr_tsc_adjust) { kvm_msr_entry_set(&msrs[n++], MSR_TSC_ADJUST, env->tsc_adjust); } @@ -1671,6 +1679,9 @@ static int kvm_get_msrs(X86CPU *cpu) if (has_msr_hsave_pa) { msrs[n++].index = MSR_VM_HSAVE_PA; } + if (has_msr_tsc_aux) { + msrs[n++].index = MSR_TSC_AUX; + } if (has_msr_tsc_adjust) { msrs[n++].index = MSR_TSC_ADJUST; } @@ -1820,6 +1831,9 @@ static int kvm_get_msrs(X86CPU *cpu) case MSR_IA32_TSC: env->tsc = msrs[i].data; break; + case MSR_TSC_AUX: + env->tsc_aux = msrs[i].data; + break; case MSR_TSC_ADJUST: env->tsc_adjust = msrs[i].data; break; diff --git a/target-i386/machine.c b/target-i386/machine.c index 9fa0563..116693d 100644 --- a/target-i386/machine.c +++ b/target-i386/machine.c @@ -453,6 +453,25 @@ static const VMStateDescription vmstate_fpop_ip_dp = { } }; +static bool tsc_aux_needed(void *opaque) +{ + X86CPU *cpu = opaque; + CPUX86State *env = &cpu->env; + + return env->tsc_aux != 0; +} + +static const VMStateDescription vmstate_msr_tsc_aux = { + .name = "cpu/msr_tsc_aux", + .version_id = 1, + .minimum_version_id = 1, + .needed = tsc_aux_needed, + .fields = (VMStateField[]) { + VMSTATE_UINT64(env.tsc_aux, X86CPU), + VMSTATE_END_OF_LIST() + } +}; + static bool tsc_adjust_needed(void *opaque) { X86CPU *cpu = opaque; @@ -871,6 +890,7 @@ VMStateDescription vmstate_x86_cpu = { &vmstate_msr_hyperv_crash, &vmstate_avx512, &vmstate_xss, + &vmstate_msr_tsc_aux, NULL } };