From patchwork Thu Sep 24 22:31:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 54141 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f70.google.com (mail-la0-f70.google.com [209.85.215.70]) by patches.linaro.org (Postfix) with ESMTPS id D3D2922B1E for ; Thu, 24 Sep 2015 22:37:02 +0000 (UTC) Received: by laka1 with SMTP id a1sf10019324lak.0 for ; Thu, 24 Sep 2015 15:37:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:subject:date:message-id :in-reply-to:references:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:cc:mime-version :content-type:content-transfer-encoding:sender:errors-to :x-original-sender:x-original-authentication-results:mailing-list; bh=GEP5oqfVNLsaj6GjB7q+wF1j+qIGkUzD9zyR6kQ9Aos=; b=dDE0jtqNCiYgrVXhSqZu14PZaI+la4cKyp+DWNchiA8HYe60jk34XDFyLa52JLkcie j6JO12k6oOOlgFs3uQySzt6ny9w73CM9BcklwilpYNv4a1yp6lFuPfjb1lP4rZqeJghc zcaFuOrNDpk4YdR9rcfUBXiWuK/MgAgmeICAsQ247T7lxuypERWe1XG0bCxsJYISr7gm LUxt1hYSnjeo35DS7xhIEVf5mBxJHe6nYGH3opoUHETmAVMyzXXg/tLNxjMv3JjX7EVW qtjtXGdrvKChSY4+Y64Y5RQJ5M35IaXJp2lAz2B7DL8helnPSn3qvU/8upQLPR23DkWk WzCw== X-Gm-Message-State: ALoCoQl/gbJER9xT94WPjIi+vBE1YIVW4covFKK0nwM2sTv5RNKVcrq0Pd73i4iJ9zYdlwrx4cGB X-Received: by 10.112.173.230 with SMTP id bn6mr319458lbc.15.1443134221822; Thu, 24 Sep 2015 15:37:01 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.21.166 with SMTP id w6ls143262lae.10.gmail; Thu, 24 Sep 2015 15:37:01 -0700 (PDT) X-Received: by 10.152.43.138 with SMTP id w10mr629560lal.104.1443134221486; Thu, 24 Sep 2015 15:37:01 -0700 (PDT) Received: from mail-la0-f48.google.com (mail-la0-f48.google.com. [209.85.215.48]) by mx.google.com with ESMTPS id r8si244986lfg.142.2015.09.24.15.37.01 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Sep 2015 15:37:01 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.48 as permitted sender) client-ip=209.85.215.48; Received: by lacao8 with SMTP id ao8so79748328lac.3 for ; Thu, 24 Sep 2015 15:37:01 -0700 (PDT) X-Received: by 10.112.129.225 with SMTP id nz1mr43551lbb.36.1443134221013; Thu, 24 Sep 2015 15:37:01 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp586589lbq; Thu, 24 Sep 2015 15:37:00 -0700 (PDT) X-Received: by 10.68.179.133 with SMTP id dg5mr2750821pbc.0.1443134219893; Thu, 24 Sep 2015 15:36:59 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id rb8si677562pbb.243.2015.09.24.15.36.59 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Sep 2015 15:36:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZfF73-0003lt-LF; Thu, 24 Sep 2015 22:35:37 +0000 Received: from mail-pa0-f44.google.com ([209.85.220.44]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZfF4T-0007GG-Da for linux-arm-kernel@lists.infradead.org; Thu, 24 Sep 2015 22:32:58 +0000 Received: by padhy16 with SMTP id hy16so85170460pad.1 for ; Thu, 24 Sep 2015 15:32:37 -0700 (PDT) X-Received: by 10.69.2.69 with SMTP id bm5mr2576769pbd.41.1443133956950; Thu, 24 Sep 2015 15:32:36 -0700 (PDT) Received: from localhost.localdomain ([40.139.248.3]) by smtp.gmail.com with ESMTPSA id ll9sm325723pbc.42.2015.09.24.15.32.32 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 24 Sep 2015 15:32:36 -0700 (PDT) From: Shannon Zhao To: kvmarm@lists.cs.columbia.edu Subject: [PATCH v3 10/20] KVM: ARM64: Add reset and access handlers for PMCCNTR register Date: Thu, 24 Sep 2015 15:31:15 -0700 Message-Id: <1443133885-3366-11-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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150924_153257_523914_B08AC09D X-CRM114-Status: GOOD ( 13.50 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.220.44 listed in wl.mailspike.net] -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.220.44 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Cc: wei@redhat.com, kvm@vger.kernel.org, marc.zyngier@arm.com, will.deacon@arm.com, peter.huangpeng@huawei.com, linux-arm-kernel@lists.infradead.org, alex.bennee@linaro.org, christoffer.dall@linaro.org, shannon.zhao@linaro.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: shannon.zhao@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.48 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Since the reset value of PMCCNTR is UNKNOWN, use reset_unknown for its reset handler. Add a new case to emulate reading to PMCCNTR register. Signed-off-by: Shannon Zhao --- arch/arm64/kvm/sys_regs.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c index e7f6058..c38c2de 100644 --- a/arch/arm64/kvm/sys_regs.c +++ b/arch/arm64/kvm/sys_regs.c @@ -518,6 +518,12 @@ static bool access_pmu_regs(struct kvm_vcpu *vcpu, } } else { switch (r->reg) { + case PMCCNTR_EL0: { + val = kvm_pmu_get_counter_value(vcpu, + ARMV8_MAX_COUNTERS - 1); + *vcpu_reg(vcpu, p->Rt) = val; + break; + } case PMXEVCNTR_EL0: { val = kvm_pmu_get_counter_value(vcpu, vcpu_sys_reg(vcpu, PMSELR_EL0)); @@ -748,7 +754,7 @@ static const struct sys_reg_desc sys_reg_descs[] = { access_pmu_regs, reset_pmceid, PMCEID1_EL0 }, /* PMCCNTR_EL0 */ { Op0(0b11), Op1(0b011), CRn(0b1001), CRm(0b1101), Op2(0b000), - trap_raz_wi }, + access_pmu_regs, reset_unknown, PMCCNTR_EL0 }, /* PMXEVTYPER_EL0 */ { Op0(0b11), Op1(0b011), CRn(0b1001), CRm(0b1101), Op2(0b001), access_pmu_regs, reset_unknown, PMXEVTYPER_EL0 }, @@ -997,6 +1003,12 @@ static bool access_pmu_cp15_regs(struct kvm_vcpu *vcpu, } } else { switch (r->reg) { + case c9_PMCCNTR: { + val = kvm_pmu_get_counter_value(vcpu, + ARMV8_MAX_COUNTERS - 1); + *vcpu_reg(vcpu, p->Rt) = val; + break; + } case c9_PMXEVCNTR: { val = kvm_pmu_get_counter_value(vcpu, vcpu_cp15(vcpu, c9_PMSELR)); @@ -1051,7 +1063,8 @@ static const struct sys_reg_desc cp15_regs[] = { reset_pmceid, c9_PMCEID0 }, { Op1( 0), CRn( 9), CRm(12), Op2( 7), access_pmu_cp15_regs, reset_pmceid, c9_PMCEID1 }, - { Op1( 0), CRn( 9), CRm(13), Op2( 0), trap_raz_wi }, + { Op1( 0), CRn( 9), CRm(13), Op2( 0), access_pmu_cp15_regs, + reset_unknown_cp15, c9_PMCCNTR }, { Op1( 0), CRn( 9), CRm(13), Op2( 1), access_pmu_cp15_regs, reset_unknown_cp15, c9_PMXEVTYPER }, { Op1( 0), CRn( 9), CRm(13), Op2( 2), access_pmu_cp15_regs,