From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 077DBC433E2 for ; Wed, 9 Sep 2020 17:51:56 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A6B1D21D46 for ; Wed, 9 Sep 2020 17:51:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="3l09jbid"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="mxP9a4GO" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A6B1D21D46 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Type: Content-Transfer-Encoding:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Message-ID:References:In-Reply-To:Subject:To:From: Date:MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Oz88xmEqAoymQ1f1HqPkpwQgnlIhHwkfSPMkFO+GP74=; b=3l09jbidKy1ZKhAQ6R8eQfUni 4TXROoeQ5mfYUDCmv5bDXhEgrp4G2COU0IPE1LISicNAplJH2Lh9O80RzeyObrI0U1SNHM21wWFAf +AiWFg9S+bLnDHadwcQHcwXgkTS9HQ0fYsksbmGihyCD4CQxOvYYNRFbiwiqasWdZzoQ2uGA7YNFy OhmrhqPv9yZ7tRaZiOvsc3MFvgErXVeIzZUwcCmiliw9M+KnMvycQTxLJNWxyac8qqSgzMZWkWOPf 9R3FZzH22aJClyQCBEZ3a2qk+JgMcsNeFXPEPREWYto5gH4X9qZhY0vPIHeBQjnPIhLmA04mCa7YE XXUKmsFOw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kG4F7-0005M3-IN; Wed, 09 Sep 2020 17:50:49 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kG4F4-0005LI-Uu for linux-arm-kernel@lists.infradead.org; Wed, 09 Sep 2020 17:50:47 +0000 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 138DE218AC; Wed, 9 Sep 2020 17:50:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599673846; bh=pHkoGN/SrAl75I0SSLoE/8IUrQFIq3+oTpQRBnqBWCo=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=mxP9a4GO903rCGGzFFUdjWtiAtfijqoExzGe4sxhZjm/AOmgiSJ6bLkutsIOKoiNW Y1y+YYlyfA+eN2FNKxaPyN4huEE5yU+BdqKlRTLLADQNCu2oCtQNEHi7zrHbaOd2WX gzU8k0kCnREInSmgCUlqmx5TrXKiLMOGpIgHJ3uM= Received: from disco-boy.misterjones.org ([51.254.78.96] helo=www.loen.fr) by disco-boy.misterjones.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kG4F1-00ARBT-UW; Wed, 09 Sep 2020 18:50:44 +0100 MIME-Version: 1.0 Date: Wed, 09 Sep 2020 18:50:43 +0100 From: Marc Zyngier To: Auger Eric Subject: Re: [PATCH v3 4/5] KVM: arm64: Mask out filtered events in PCMEID{0,1}_EL1 In-Reply-To: <735f5464-3a45-8dc0-c330-ac5632bcb4b4@redhat.com> References: <20200908075830.1161921-1-maz@kernel.org> <20200908075830.1161921-5-maz@kernel.org> <735f5464-3a45-8dc0-c330-ac5632bcb4b4@redhat.com> User-Agent: Roundcube Webmail/1.4.8 Message-ID: X-Sender: maz@kernel.org X-SA-Exim-Connect-IP: 51.254.78.96 X-SA-Exim-Rcpt-To: eric.auger@redhat.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, james.morse@arm.com, julien.thierry.kdev@gmail.com, suzuki.poulose@arm.com, robin.murphy@arm.com, mark.rutland@arm.com, graf@amazon.com, kernel-team@android.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200909_135047_142219_0715C5F5 X-CRM114-Status: GOOD ( 21.36 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , kvm@vger.kernel.org, Suzuki K Poulose , kernel-team@android.com, James Morse , linux-arm-kernel@lists.infradead.org, graf@amazon.com, Robin Murphy , kvmarm@lists.cs.columbia.edu, Julien Thierry Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Eric, On 2020-09-09 18:43, Auger Eric wrote: > Hi Marc, > > On 9/8/20 9:58 AM, Marc Zyngier wrote: >> As we can now hide events from the guest, let's also adjust its view >> of >> PCMEID{0,1}_EL1 so that it can figure out why some common events are >> not >> counting as they should. > Referring to my previous comment should we filter the cycle counter > out? >> >> The astute user can still look into the TRM for their CPU and find out >> they've been cheated, though. Nobody's perfect. >> >> Signed-off-by: Marc Zyngier >> --- >> arch/arm64/kvm/pmu-emul.c | 29 +++++++++++++++++++++++++++++ >> arch/arm64/kvm/sys_regs.c | 5 +---- >> include/kvm/arm_pmu.h | 5 +++++ >> 3 files changed, 35 insertions(+), 4 deletions(-) >> >> diff --git a/arch/arm64/kvm/pmu-emul.c b/arch/arm64/kvm/pmu-emul.c >> index 67a731bafbc9..0458860bade2 100644 >> --- a/arch/arm64/kvm/pmu-emul.c >> +++ b/arch/arm64/kvm/pmu-emul.c >> @@ -765,6 +765,35 @@ static int kvm_pmu_probe_pmuver(void) >> return pmuver; >> } >> >> +u64 kvm_pmu_get_pmceid(struct kvm_vcpu *vcpu, bool pmceid1) >> +{ >> + unsigned long *bmap = vcpu->kvm->arch.pmu_filter; >> + u64 val, mask = 0; >> + int base, i; >> + >> + if (!pmceid1) { >> + val = read_sysreg(pmceid0_el0); >> + base = 0; >> + } else { >> + val = read_sysreg(pmceid1_el0); >> + base = 32; >> + } >> + >> + if (!bmap) >> + return val; >> + >> + for (i = 0; i < 32; i += 8) { > s/32/4? I don't think so, see below. > > Thanks > > Eric >> + u64 byte; >> + >> + byte = bitmap_get_value8(bmap, base + i); >> + mask |= byte << i; For each iteration of the loop, we read a byte from the bitmap (hence the += 8 above), and orr it into the mask. This makes 4 iteration of the loop. Or am I missing your point entirely? Thanks, M. -- Jazz is not dead. It just smells funny... _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel