From patchwork Mon Jul 6 02:17:44 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 50685 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 44DC4229E5 for ; Mon, 6 Jul 2015 02:21:42 +0000 (UTC) Received: by widjy10 with SMTP id jy10sf46982290wid.3 for ; Sun, 05 Jul 2015 19:21:41 -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=8hiS3KN/q3pm6bUbOCyNQVfPQoRnO3QbTP8io2y7LUs=; b=f3YaRUza2qpTtZPbPxb03kwSA6CbKJzBxyg+5Y0T+TUv6Ja+nIxv5iUAlWVGo5PM2Z ZlMIIpcOW1HinDHJitv2Yr7SpDzGO6BJ3qx9fuhMTidnSKEYLoH09NP8UxC17m0lUcbB 553lWg1vQNdJmBgjPz24A/vyvid14SFbYO+A9b0/VXRgkpADJ5fJGXsH2syHqYIy4btJ QsK6UpIktITZYhiKABzkfLs3xBmGh17hOOySI2ZRFlsiAUuU2BaDQo1PW2CqpnHlCK+W FPlnEH75X4tyvLHys0nwhvuiJotqkGA1bgzJkNe2eJbowoT6/HPHS8qvH+3A947/Y0OT HstA== X-Gm-Message-State: ALoCoQlSP3HbpC28wSFyIHrpYZa5kDAa0Q9Q5oCKbI2wwd6ugtNp9Kp0dZ+Ym/bU7lffMJ2b8QFo X-Received: by 10.180.77.225 with SMTP id v1mr2790022wiw.5.1436149301629; Sun, 05 Jul 2015 19:21:41 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.4.227 with SMTP id n3ls695218lan.0.gmail; Sun, 05 Jul 2015 19:21:41 -0700 (PDT) X-Received: by 10.112.218.67 with SMTP id pe3mr41471569lbc.53.1436149301086; Sun, 05 Jul 2015 19:21:41 -0700 (PDT) Received: from mail-la0-f45.google.com (mail-la0-f45.google.com. [209.85.215.45]) by mx.google.com with ESMTPS id ku9si10042616lac.141.2015.07.05.19.21.40 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 05 Jul 2015 19:21:40 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.45 as permitted sender) client-ip=209.85.215.45; Received: by lagx9 with SMTP id x9so137460890lag.1 for ; Sun, 05 Jul 2015 19:21:40 -0700 (PDT) X-Received: by 10.112.55.207 with SMTP id u15mr46629920lbp.88.1436149300824; Sun, 05 Jul 2015 19:21:40 -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.108.230 with SMTP id hn6csp1426509lbb; Sun, 5 Jul 2015 19:21:39 -0700 (PDT) X-Received: by 10.66.66.172 with SMTP id g12mr99490066pat.77.1436149299120; Sun, 05 Jul 2015 19:21:39 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id pu1si26279978pbb.242.2015.07.05.19.21.38 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 05 Jul 2015 19:21:39 -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 1ZBw1F-0000o4-Fl; Mon, 06 Jul 2015 02:20:29 +0000 Received: from mail-pa0-f53.google.com ([209.85.220.53]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZBw0B-0006Ey-EU for linux-arm-kernel@lists.infradead.org; Mon, 06 Jul 2015 02:19:23 +0000 Received: by pactm7 with SMTP id tm7so86960435pac.2 for ; Sun, 05 Jul 2015 19:19:02 -0700 (PDT) X-Received: by 10.66.102.65 with SMTP id fm1mr98689468pab.25.1436149142469; Sun, 05 Jul 2015 19:19:02 -0700 (PDT) Received: from localhost ([120.136.34.248]) by mx.google.com with ESMTPSA id k5sm16217402pdb.53.2015.07.05.19.19.00 (version=TLSv1 cipher=RC4-SHA bits=128/128); Sun, 05 Jul 2015 19:19:01 -0700 (PDT) From: shannon.zhao@linaro.org To: kvmarm@lists.cs.columbia.edu Subject: [PATCH 14/18] KVM: ARM64: Add reset and access handlers for PMUSERENR_EL0 register Date: Mon, 6 Jul 2015 10:17:44 +0800 Message-Id: <1436149068-3784-15-git-send-email-shannon.zhao@linaro.org> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1436149068-3784-1-git-send-email-shannon.zhao@linaro.org> References: <1436149068-3784-1-git-send-email-shannon.zhao@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150705_191923_532526_98D161FB X-CRM114-Status: GOOD ( 13.05 ) 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.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.220.53 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.220.53 listed in wl.mailspike.net] -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: kvm@vger.kernel.org, marc.zyngier@arm.com, will.deacon@arm.com, linux-arm-kernel@lists.infradead.org, zhaoshenglong@huawei.com, 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.45 as permitted sender) smtp.mail=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 From: Shannon Zhao Since the reset value of PMUSERENR_EL0 is UNKNOWN, use reset_unknown for its reset handler. Add access handler which emulates writing and reading PMUSERENR_EL0 register. Signed-off-by: Shannon Zhao --- arch/arm64/kvm/sys_regs.c | 15 ++++++++++++++- include/kvm/arm_pmu.h | 1 + 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c index ec80937..d5984d0 100644 --- a/arch/arm64/kvm/sys_regs.c +++ b/arch/arm64/kvm/sys_regs.c @@ -522,6 +522,19 @@ static bool access_pmovsclr(struct kvm_vcpu *vcpu, return true; } +/* PMUSERENR_EL0 accessor. */ +static bool access_pmuserenr(struct kvm_vcpu *vcpu, + const struct sys_reg_params *p, + const struct sys_reg_desc *r) +{ + if (p->is_write) + vcpu->arch.pmu.user_enable |= *vcpu_reg(vcpu, p->Rt); + else + *vcpu_reg(vcpu, p->Rt) = vcpu->arch.pmu.user_enable; + + return true; +} + /* Silly macro to expand the DBG{BCR,BVR,WVR,WCR}n_EL1 registers in one go */ #define DBG_BCR_BVR_WCR_WVR_EL1(n) \ /* DBGBVRn_EL1 */ \ @@ -746,7 +759,7 @@ static const struct sys_reg_desc sys_reg_descs[] = { access_pmxevcntr, reset_unknown, PMXEVCNTR_EL0 }, /* PMUSERENR_EL0 */ { Op0(0b11), Op1(0b011), CRn(0b1001), CRm(0b1110), Op2(0b000), - trap_raz_wi }, + access_pmuserenr, reset_unknown, PMUSERENR_EL0 }, /* PMOVSSET_EL0 */ { Op0(0b11), Op1(0b011), CRn(0b1001), CRm(0b1110), Op2(0b011), access_pmovsset, reset_unknown, PMOVSSET_EL0 }, diff --git a/include/kvm/arm_pmu.h b/include/kvm/arm_pmu.h index dee8356..4f3d8a6 100644 --- a/include/kvm/arm_pmu.h +++ b/include/kvm/arm_pmu.h @@ -39,6 +39,7 @@ struct kvm_pmu { /* IRQ pending flag */ bool irq_pending; struct irq_work irq_work; + u32 user_enable; struct kvm_pmc pmc[ARMV8_MAX_COUNTERS]; #endif };