Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp507776ybi; Fri, 24 May 2019 07:15:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqx58w2MU7gzm332dpJQb0I6Hk7q7M86x+3XiGNhjGY8wK9MowOcNacdnmNUyruqBahnibhX X-Received: by 2002:a17:90a:36d0:: with SMTP id t74mr9628644pjb.4.1558707321540; Fri, 24 May 2019 07:15:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558707321; cv=none; d=google.com; s=arc-20160816; b=v7hLG42lhxXOJ8HOVFkJGdq9pJc5+04spZPbbmiaUj6791fDccx7dbC8FxsUsmnSFA 2WbAtc4CZ4SgAOyHm4bQy9KPv74pml4PRav5xXW7GvHoB1HoN/DpoY7Tp3HI2/8o3i7I wHjLMIIK8V20Ulx5R+ZEr/N77XiRLzHJf2BjjPfi9X1JaiCgqWQ7yUtiGoXr3L99Qbt5 wfyV4Xwx5yjZGd9LDJG5NT/YkkTdJDWz8P35HRHoFKcgDC+3I09dImq4sd/ACwRpXTSq CWOWeNcPeq0nGUlv5cWZPK2JS5HKR6RI5eHyv8Cw+x+QSF4QMmjYvDhsJkggm/j6dPsh Rvmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=o8YIt/wOnTL1jWSni4Lv7enoP4ApWL25DOnGkUVmLn8=; b=nKOvC9K8Tpx8PHjj03UFx061wdSXnf2OACh3BOxalIMZaFgjgQIzIByLjSmTCPcum/ FQkISQ3OaF5oiuqlwhzIBzdf9WfDEld1AqsESMBAhBdcPidQYX/irTVXb3L7EzSUZv6E iJAwM59tvQM0lFXeZW85xU1t6yYQzEEalPZRtHfWTRAkbBw9Ky3B3yPrRCS12vA6T44L P0cH3a3zzKmJltf/0Z4QFTMu68AzuWcESjSgUTpV1XiUHLFSqUVvNA76YtYr/qiLBMLd tknq33nw7PLL+VwAcIsLQzjmcT8AQIEdNsUBWylmNsXkC/TvxIl0UNzPVIM1CWuim9Pi bj5Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q138si4120998pfq.149.2019.05.24.07.15.03; Fri, 24 May 2019 07:15:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2403997AbfEXOM1 (ORCPT + 99 others); Fri, 24 May 2019 10:12:27 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:43846 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403864AbfEXOM0 (ORCPT ); Fri, 24 May 2019 10:12:26 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E549BA78; Fri, 24 May 2019 07:12:25 -0700 (PDT) Received: from e107155-lin (e107155-lin.cambridge.arm.com [10.1.196.42]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id CFD8C3F575; Fri, 24 May 2019 07:12:23 -0700 (PDT) Date: Fri, 24 May 2019 15:12:18 +0100 From: Sudeep Holla To: Julien Thierry Cc: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Christoffer Dall , Marc Zyngier , James Morse , Suzuki K Pouloze , Catalin Marinas , Sudeep Holla , Will Deacon Subject: Re: [PATCH v2 05/15] arm64: KVM: add access handler for SPE system registers Message-ID: <20190524141218.GA29406@e107155-lin> References: <20190523103502.25925-1-sudeep.holla@arm.com> <20190523103502.25925-6-sudeep.holla@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 24, 2019 at 12:36:24PM +0100, Julien Thierry wrote: > Hi Sudeep, > > On 23/05/2019 11:34, Sudeep Holla wrote: > > SPE Profiling Buffer owning EL is configurable and when MDCR_EL2.E2PB > > is configured to provide buffer ownership to EL1, the control registers > > are trapped. > > > > Add access handlers for the Statistical Profiling Extension(SPE) > > Profiling Buffer controls registers. This is need to support profiling > > using SPE in the guests. > > > > Signed-off-by: Sudeep Holla > > --- > > arch/arm64/include/asm/kvm_host.h | 13 ++++++++++++ > > arch/arm64/kvm/sys_regs.c | 35 +++++++++++++++++++++++++++++++ > > include/kvm/arm_spe.h | 15 +++++++++++++ > > 3 files changed, 63 insertions(+) > > > > diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h > > index 611a4884fb6c..559aa6931291 100644 > > --- a/arch/arm64/include/asm/kvm_host.h > > +++ b/arch/arm64/include/asm/kvm_host.h > > @@ -147,6 +147,19 @@ enum vcpu_sysreg { > > MDCCINT_EL1, /* Monitor Debug Comms Channel Interrupt Enable Reg */ > > DISR_EL1, /* Deferred Interrupt Status Register */ > > > > + /* Statistical Profiling Extension Registers */ > > + > > + PMSCR_EL1, > > + PMSICR_EL1, > > + PMSIRR_EL1, > > + PMSFCR_EL1, > > + PMSEVFR_EL1, > > + PMSLATFR_EL1, > > + PMSIDR_EL1, > > + PMBLIMITR_EL1, > > + PMBPTR_EL1, > > + PMBSR_EL1, > > + > > /* Performance Monitors Registers */ > > PMCR_EL0, /* Control Register */ > > PMSELR_EL0, /* Event Counter Selection Register */ > > diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c > > index 857b226bcdde..dbf5056828d3 100644 > > --- a/arch/arm64/kvm/sys_regs.c > > +++ b/arch/arm64/kvm/sys_regs.c > > @@ -646,6 +646,30 @@ static void reset_pmcr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *r) > > __vcpu_sys_reg(vcpu, PMCR_EL0) = val; > > } > > > > +static bool access_pmsb_val(struct kvm_vcpu *vcpu, struct sys_reg_params *p, > > + const struct sys_reg_desc *r) > > +{ > > + if (p->is_write) > > + vcpu_write_sys_reg(vcpu, p->regval, r->reg); > > + else > > + p->regval = vcpu_read_sys_reg(vcpu, r->reg); > > + > > + return true; > > +} > > + > > +static void reset_pmsb_val(struct kvm_vcpu *vcpu, const struct sys_reg_desc *r) > > +{ > > + if (!kvm_arm_support_spe_v1()) { > > + __vcpu_sys_reg(vcpu, r->reg) = 0; > > + return; > > + } > > + > > + if (r->reg == PMSIDR_EL1) > > If only PMSIDR_EL1 has a non-zero reset value, it feels a bit weird to > share the reset function for all these registers. > Ah, right. Initially I did have couple of other registers which were not needed. So I removed them without observing that I could have just used reset_val(0) for all except PMSIDR_EL1. > I would suggest only having a reset_pmsidr() function, and just use > reset_val() with sys_reg_desc->val set to 0 for all the others. > Thanks for pointing this out. -- Regards, Sudeep