From patchwork Mon Jul 6 02:17:36 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 50678 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 19326229E5 for ; Mon, 6 Jul 2015 02:20:13 +0000 (UTC) Received: by wipp2 with SMTP id p2sf26874168wip.2 for ; Sun, 05 Jul 2015 19:20:12 -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=5iKy69wdIYk8gdiL6vskl3Oc/LOPkHVqHvkAHlBqTV8=; b=Sd0xA0EK/sa3uDxuPL4pGzYm8bRZ1fda9H+yC6XsMczPrlbFE1xaXDIWXNMQO+ONuT bjO2HbfCfpywQBe4lk0w1QHrx4QuNuLRj4FX7LBcij4CRZhmXhqKOwLib2l95+aZ1Tr6 gDKOi1eMSD3LTCN4tDIbj56o3iT4PqS1tkVEHb6vC3yEEttJnFx3sbFw0h/ncdQrRfSD Lrnt+rr+QGmEdU3aY4fdRDVkJ8tRl8MxHFjhsRuhuj2unMDvnrRwJwrxjyz5zhDQhKCx fMGbvPMhlEX/PDIX3eVUX6+Qga+TbMJrSzJskpOfE+ihFMlbN/YKxpC6FHt0KzfGyM09 BlzA== X-Gm-Message-State: ALoCoQmYOW79l8GRsZFS5RPHE+pUTtqk0rlK/ULY5+LyNvmAOCOvk3nTXFmcVeQtix7XisZPUt77 X-Received: by 10.112.9.100 with SMTP id y4mr29480676lba.20.1436149212441; Sun, 05 Jul 2015 19:20:12 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.43.228 with SMTP id z4ls664013lal.90.gmail; Sun, 05 Jul 2015 19:20:12 -0700 (PDT) X-Received: by 10.112.162.70 with SMTP id xy6mr47531925lbb.122.1436149212042; Sun, 05 Jul 2015 19:20:12 -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 yk6si13954401lbb.90.2015.07.05.19.20.12 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 05 Jul 2015 19:20:12 -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 lagx9 with SMTP id x9so137437504lag.1 for ; Sun, 05 Jul 2015 19:20:12 -0700 (PDT) X-Received: by 10.152.42.177 with SMTP id p17mr46443458lal.29.1436149211623; Sun, 05 Jul 2015 19:20:11 -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 hn6csp1426047lbb; Sun, 5 Jul 2015 19:20:10 -0700 (PDT) X-Received: by 10.66.121.230 with SMTP id ln6mr43245176pab.17.1436149208287; Sun, 05 Jul 2015 19:20:08 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id sa6si26332913pbb.125.2015.07.05.19.20.07 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 05 Jul 2015 19:20:08 -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 1ZBvzm-00069f-Ei; Mon, 06 Jul 2015 02:18:58 +0000 Received: from mail-pd0-f169.google.com ([209.85.192.169]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZBvzX-0005pe-32 for linux-arm-kernel@lists.infradead.org; Mon, 06 Jul 2015 02:18:43 +0000 Received: by pdbdz6 with SMTP id dz6so1056589pdb.0 for ; Sun, 05 Jul 2015 19:18:22 -0700 (PDT) X-Received: by 10.70.101.168 with SMTP id fh8mr99255175pdb.15.1436149102234; Sun, 05 Jul 2015 19:18:22 -0700 (PDT) Received: from localhost ([120.136.34.248]) by mx.google.com with ESMTPSA id os7sm16216303pdb.51.2015.07.05.19.18.21 (version=TLSv1 cipher=RC4-SHA bits=128/128); Sun, 05 Jul 2015 19:18:21 -0700 (PDT) From: shannon.zhao@linaro.org To: kvmarm@lists.cs.columbia.edu Subject: [PATCH 06/18] KVM: ARM64: Add reset and access handlers for PMCEID0_EL0 and PMCEID1_EL0 register Date: Mon, 6 Jul 2015 10:17:36 +0800 Message-Id: <1436149068-3784-7-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_191843_161522_1525253E X-CRM114-Status: GOOD ( 13.32 ) 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.192.169 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.192.169 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.48 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 Add reset handler which gets host value of PMCEID0_EL0 or PMCEID1_EL0. Add access handler which emulates writing and reading PMCEID0_EL0 or PMCEID1_EL0 register. Signed-off-by: Shannon Zhao --- arch/arm64/kvm/sys_regs.c | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c index 69c8c48..1df9ef3 100644 --- a/arch/arm64/kvm/sys_regs.c +++ b/arch/arm64/kvm/sys_regs.c @@ -246,6 +246,19 @@ static void reset_pmcr_el0(struct kvm_vcpu *vcpu, const struct sys_reg_desc *r) | (ARMV8_PMCR_MASK & 0xdecafbad); } +static void reset_pmceid(struct kvm_vcpu *vcpu, const struct sys_reg_desc *r) +{ + u32 pmceid; + + if (r->reg == PMCEID0_EL0) { + asm volatile("mrs %0, pmceid0_el0\n" : "=r" (pmceid)); + vcpu_sys_reg(vcpu, r->reg) = pmceid; + } else { + asm volatile("mrs %0, pmceid1_el0\n" : "=r" (pmceid)); + vcpu_sys_reg(vcpu, r->reg) = pmceid; + } +} + /* PMCR_EL0 accessor. Only called as long as MDCR_EL2.TPMCR is set. */ static bool access_pmcr(struct kvm_vcpu *vcpu, const struct sys_reg_params *p, @@ -299,6 +312,25 @@ static bool access_pmselr(struct kvm_vcpu *vcpu, return true; } +/* PMCEID0_EL0 and PMCEID1_EL0 accessor. */ +static bool access_pmceid(struct kvm_vcpu *vcpu, + const struct sys_reg_params *p, + const struct sys_reg_desc *r) +{ + unsigned long val; + + if (p->is_write) { + return ignore_write(vcpu, p); + } else { + if (!p->is_aarch32) + val = vcpu_sys_reg(vcpu, r->reg); + else + val = vcpu_cp15(vcpu, r->reg); + *vcpu_reg(vcpu, p->Rt) = val; + 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 */ \ @@ -508,10 +540,10 @@ static const struct sys_reg_desc sys_reg_descs[] = { access_pmselr, reset_unknown, PMSELR_EL0 }, /* PMCEID0_EL0 */ { Op0(0b11), Op1(0b011), CRn(0b1001), CRm(0b1100), Op2(0b110), - trap_raz_wi }, + access_pmceid, reset_pmceid, PMCEID0_EL0, }, /* PMCEID1_EL0 */ { Op0(0b11), Op1(0b011), CRn(0b1001), CRm(0b1100), Op2(0b111), - trap_raz_wi }, + access_pmceid, reset_pmceid, PMCEID1_EL0, }, /* PMCCNTR_EL0 */ { Op0(0b11), Op1(0b011), CRn(0b1001), CRm(0b1101), Op2(0b000), trap_raz_wi },