From patchwork Thu Sep 24 22:31:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 7261341 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7BC3E9F30C for ; Thu, 24 Sep 2015 22:33:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9FE2420B29 for ; Thu, 24 Sep 2015 22:33:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4077B20B27 for ; Thu, 24 Sep 2015 22:33:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932184AbbIXWdT (ORCPT ); Thu, 24 Sep 2015 18:33:19 -0400 Received: from mail-pa0-f51.google.com ([209.85.220.51]:34651 "EHLO mail-pa0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932081AbbIXWdR (ORCPT ); Thu, 24 Sep 2015 18:33:17 -0400 Received: by padhy16 with SMTP id hy16so85184387pad.1 for ; Thu, 24 Sep 2015 15:33:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=EWxNfc27CIR+fJ+ZECFBr43TZMI5h5/xP3xi+rkwTIE=; b=H12bX2lZNHKIcu/lqLoLFDWKnh0AiE5plgh9vw/XqJnmaOMouJrK3GqbtLQbnjtGvU 3R6FF4yZF76oTgEltCkBIVPVTsJH8a2d62LhVXfcTp3S9Lh888I2c3STmdbUXA3LB/PV Cv3h0K8z5Jz6/JtfQSExawK8Nlc2ZYg2+2nn+mW+zisiPfULh6UUq8pt0DlfNXN1p2DV zmJu0gO7X16GXc592AEVZK/w4QUIr1188HY4uTKaqpJKjVG2kqghb3x1z3zDzGa8N/7u Ae7tVii0OGpWQ1G7lvMH5rtL3oXRfqD+aW/VGzVLMcwe4SAS8xoI2OrMkCkEUzHczUIu lWLw== X-Gm-Message-State: ALoCoQkcaQ4U6FGtZ2nXBnMu2jf3T4Dp+QnFwGFYhYoGtMQSQ7MYCYk0KjGY9VOyKOyqMtx2TDSB X-Received: by 10.68.231.5 with SMTP id tc5mr2696410pbc.54.1443133997481; Thu, 24 Sep 2015 15:33:17 -0700 (PDT) Received: from localhost.localdomain ([40.139.248.3]) by smtp.gmail.com with ESMTPSA id ll9sm325723pbc.42.2015.09.24.15.33.12 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 24 Sep 2015 15:33:16 -0700 (PDT) From: Shannon Zhao To: kvmarm@lists.cs.columbia.edu Cc: linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, marc.zyngier@arm.com, christoffer.dall@linaro.org, will.deacon@arm.com, wei@redhat.com, alex.bennee@linaro.org, peter.huangpeng@huawei.com, shannon.zhao@linaro.org Subject: [PATCH v3 18/20] KVM: ARM64: Reset PMU state when resetting vcpu Date: Thu, 24 Sep 2015 15:31:23 -0700 Message-Id: <1443133885-3366-19-git-send-email-shannon.zhao@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1443133885-3366-1-git-send-email-shannon.zhao@linaro.org> References: <1443133885-3366-1-git-send-email-shannon.zhao@linaro.org> 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=ham 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 Signed-off-by: Shannon Zhao --- arch/arm64/kvm/reset.c | 3 +++ include/kvm/arm_pmu.h | 2 ++ virt/kvm/arm/pmu.c | 18 ++++++++++++++++++ 3 files changed, 23 insertions(+) diff --git a/arch/arm64/kvm/reset.c b/arch/arm64/kvm/reset.c index 91cf535..4da7f6c 100644 --- a/arch/arm64/kvm/reset.c +++ b/arch/arm64/kvm/reset.c @@ -120,6 +120,9 @@ int kvm_reset_vcpu(struct kvm_vcpu *vcpu) /* Reset system registers */ kvm_reset_sys_regs(vcpu); + /* Reset PMU */ + kvm_pmu_vcpu_reset(vcpu); + /* Reset timer */ return kvm_timer_vcpu_reset(vcpu, cpu_vtimer_irq); } diff --git a/include/kvm/arm_pmu.h b/include/kvm/arm_pmu.h index 953c400..8dacfd3 100644 --- a/include/kvm/arm_pmu.h +++ b/include/kvm/arm_pmu.h @@ -38,6 +38,7 @@ struct kvm_pmu { }; #ifdef CONFIG_KVM_ARM_PMU +void kvm_pmu_vcpu_reset(struct kvm_vcpu *vcpu); void kvm_pmu_sync_hwstate(struct kvm_vcpu *vcpu); unsigned long kvm_pmu_get_counter_value(struct kvm_vcpu *vcpu, u32 select_idx); void kvm_pmu_disable_counter(struct kvm_vcpu *vcpu, u32 val); @@ -46,6 +47,7 @@ void kvm_pmu_software_increment(struct kvm_vcpu *vcpu, u32 val); void kvm_pmu_set_counter_event_type(struct kvm_vcpu *vcpu, u32 data, u32 select_idx); #else +void kvm_pmu_vcpu_reset(struct kvm_vcpu *vcpu) {} void kvm_pmu_sync_hwstate(struct kvm_vcpu *vcpu) {} unsigned long kvm_pmu_get_counter_value(struct kvm_vcpu *vcpu, u32 select_idx) { diff --git a/virt/kvm/arm/pmu.c b/virt/kvm/arm/pmu.c index ca7e849..faa2b76 100644 --- a/virt/kvm/arm/pmu.c +++ b/virt/kvm/arm/pmu.c @@ -63,6 +63,24 @@ static void kvm_pmu_stop_counter(struct kvm_vcpu *vcpu, u32 select_idx) } /** + * kvm_pmu_vcpu_reset - reset pmu state for cpu + * @vcpu: The vcpu pointer + * + */ +void kvm_pmu_vcpu_reset(struct kvm_vcpu *vcpu) +{ + int i; + struct kvm_pmu *pmu = &vcpu->arch.pmu; + + for (i = 0; i < ARMV8_MAX_COUNTERS; i++) { + kvm_pmu_stop_counter(vcpu, i); + pmu->pmc[i].idx = i; + pmu->pmc[i].vcpu = vcpu; + } + pmu->irq_pending = false; +} + +/** * kvm_pmu_sync_hwstate - sync pmu state for cpu * @vcpu: The vcpu pointer *