From patchwork Wed Feb 20 02:27:20 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 2165911 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id F2B45DF24C for ; Wed, 20 Feb 2013 02:29:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935418Ab3BTC3K (ORCPT ); Tue, 19 Feb 2013 21:29:10 -0500 Received: from mx1.redhat.com ([209.132.183.28]:38508 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934841Ab3BTC13 (ORCPT ); Tue, 19 Feb 2013 21:27:29 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r1K2RSkg014582 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 19 Feb 2013 21:27:29 -0500 Received: from amt.cnet (vpn1-4-183.gru2.redhat.com [10.97.4.183]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r1K2RSD0014945; Tue, 19 Feb 2013 21:27:28 -0500 Received: from amt.cnet (localhost [127.0.0.1]) by amt.cnet (Postfix) with ESMTP id A7FED102BBD; Tue, 19 Feb 2013 23:27:21 -0300 (BRT) Received: (from marcelo@localhost) by amt.cnet (8.14.6/8.14.6/Submit) id r1K2RKiR018695; Tue, 19 Feb 2013 23:27:20 -0300 Date: Tue, 19 Feb 2013 23:27:20 -0300 From: Marcelo Tosatti To: kvm Cc: Gleb Natapov Subject: [uq/master PATCH] target-i386: kvm: save/restore steal time MSR Message-ID: <20130220022720.GA18505@amt.cnet> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Read and write steal time MSR, so that reporting is functional across migration. Signed-off-by: Marcelo Tosatti Reviewed-by: Gleb Natapov --- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/target-i386/cpu.h b/target-i386/cpu.h index 7577e4f..17c7293 100644 --- a/target-i386/cpu.h +++ b/target-i386/cpu.h @@ -792,6 +792,7 @@ typedef struct CPUX86State { #endif uint64_t system_time_msr; uint64_t wall_clock_msr; + uint64_t steal_time_msr; uint64_t async_pf_en_msr; uint64_t pv_eoi_en_msr; diff --git a/target-i386/kvm.c b/target-i386/kvm.c index 0cf413d..9ae9d74 100644 --- a/target-i386/kvm.c +++ b/target-i386/kvm.c @@ -68,6 +68,7 @@ static bool has_msr_tsc_deadline; static bool has_msr_async_pf_en; static bool has_msr_pv_eoi_en; static bool has_msr_misc_enable; +static bool has_msr_kvm_steal_time; static int lm_capable_kernel; bool kvm_allows_irq0_override(void) @@ -507,6 +508,8 @@ int kvm_arch_init_vcpu(CPUState *cs) has_msr_pv_eoi_en = c->eax & (1 << KVM_FEATURE_PV_EOI); + has_msr_kvm_steal_time = c->eax & (1 << KVM_FEATURE_STEAL_TIME); + cpu_x86_cpuid(env, 0, 0, &limit, &unused, &unused, &unused); for (i = 0; i <= limit; i++) { @@ -1107,6 +1110,10 @@ static int kvm_put_msrs(X86CPU *cpu, int level) kvm_msr_entry_set(&msrs[n++], MSR_KVM_PV_EOI_EN, env->pv_eoi_en_msr); } + if (has_msr_kvm_steal_time) { + kvm_msr_entry_set(&msrs[n++], MSR_KVM_STEAL_TIME, + env->steal_time_msr); + } if (hyperv_hypercall_available()) { kvm_msr_entry_set(&msrs[n++], HV_X64_MSR_GUEST_OS_ID, 0); kvm_msr_entry_set(&msrs[n++], HV_X64_MSR_HYPERCALL, 0); @@ -1360,6 +1367,9 @@ static int kvm_get_msrs(X86CPU *cpu) if (has_msr_pv_eoi_en) { msrs[n++].index = MSR_KVM_PV_EOI_EN; } + if (has_msr_kvm_steal_time) { + msrs[n++].index = MSR_KVM_STEAL_TIME; + } if (env->mcg_cap) { msrs[n++].index = MSR_MCG_STATUS; @@ -1445,6 +1455,9 @@ static int kvm_get_msrs(X86CPU *cpu) case MSR_KVM_PV_EOI_EN: env->pv_eoi_en_msr = msrs[i].data; break; + case MSR_KVM_STEAL_TIME: + env->steal_time_msr = msrs[i].data; + break; } } diff --git a/target-i386/machine.c b/target-i386/machine.c index 8df6a6b..1feb9ca 100644 --- a/target-i386/machine.c +++ b/target-i386/machine.c @@ -287,6 +287,24 @@ static bool pv_eoi_msr_needed(void *opaque) return cpu->pv_eoi_en_msr != 0; } +static bool steal_time_msr_needed(void *opaque) +{ + CPUX86State *cpu = opaque; + + return cpu->steal_time_msr != 0; +} + +static const VMStateDescription vmstate_steal_time_msr = { + .name = "cpu/steal_time_msr", + .version_id = 1, + .minimum_version_id = 1, + .minimum_version_id_old = 1, + .fields = (VMStateField []) { + VMSTATE_UINT64(steal_time_msr, CPUX86State), + VMSTATE_END_OF_LIST() + } +}; + static const VMStateDescription vmstate_async_pf_msr = { .name = "cpu/async_pf_msr", .version_id = 1, @@ -494,6 +512,9 @@ static const VMStateDescription vmstate_cpu = { .vmsd = &vmstate_pv_eoi_msr, .needed = pv_eoi_msr_needed, } , { + .vmsd = &vmstate_steal_time_msr, + .needed = steal_time_msr_needed, + } , { .vmsd = &vmstate_fpop_ip_dp, .needed = fpop_ip_dp_needed, }, {