Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp628721ybl; Fri, 24 Jan 2020 06:43:19 -0800 (PST) X-Google-Smtp-Source: APXvYqxA2zvRRma6T420jzVX4wLwk31jjtfYrJKkNxsHbm9u1qquKpJ/p3k+HQFGymUQjwdSmSKs X-Received: by 2002:a05:6830:16d8:: with SMTP id l24mr2831414otr.268.1579876999322; Fri, 24 Jan 2020 06:43:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579876999; cv=none; d=google.com; s=arc-20160816; b=ofAMv8FGuiGwXd+IizY1IxH2ORJ/1cvtA8IGKqXG6ejZbJYeDQq0NYj2VhtgDnnV9x xFv6t/rZASqVygvCafOgPCTaLHA91S7B2m/wiwmAeCx6wnEnFseRelvPmqzZ2xMQq5QR aBZ6/E5J1dz/Bry6O+Acnm3ltI1rrV9NTpXyiygMr7mRik26HFVViwNSNnAR9VxZCgYr iey08kj17q59aCEOozJZxggdi+fJ2zYPm051FQjDxncPZpftgjiZ1ksTjaofbMsNykly 7A495GKTSxEJ3fDrXIrsqOEiPRuprtAf0f56xIWju5/Pt46WjyD4tyHC97BiAeQp0zdH 74gQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ZfbqCEGb1Hozb97Wquprp+GaP9A0aUtFnhQN/uvV2os=; b=HU/05YfFH7IlO5F1ZncSp8dtd9+jF6uL64am8Um4GzSXD1DErsk638S8nAKn+9TJQL BI4MKavx6psDDy7rVYE63GIYbzuCiPFFpQsXDlHejHLhHcbZm4f7sM0X0xS3C+8hZvs/ wgL68BVF0inOXmLDV+glc4mC1ST875oPYqs7e8tu6rmd4SNNKZ6JuQPOk0kCCrm5zvSO likLQ+ayiv9Z+aqn53Nrq+AfPuMGCT3ysu0iSGyTsed0hSLTyknmg+ZM4za33Qh2fcVZ 0U0IM3X+gyzPKfJPlrVEBVSD30GanEP9kTnu9j6SYKGH6iJNZGiY3tSzFFD0Szt1ZEPW Irow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=LFrV84A7; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e15si1259437ote.211.2020.01.24.06.43.06; Fri, 24 Jan 2020 06:43:19 -0800 (PST) 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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=LFrV84A7; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388696AbgAXOZ7 (ORCPT + 99 others); Fri, 24 Jan 2020 09:25:59 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:37879 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2389790AbgAXOZx (ORCPT ); Fri, 24 Jan 2020 09:25:53 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579875952; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZfbqCEGb1Hozb97Wquprp+GaP9A0aUtFnhQN/uvV2os=; b=LFrV84A7VQ/eUyMGP6182CfhMjGOBbGUWGJonp+uJFqnLhTKqVnPAPcOho/2ZIwjswyGpR S8ADWdrbn7cMLPhY6zJnbSeNMaXRakw1KF3P9kFpLVoKJ1d+UKTOVFphJQtnoXIcfHphFm 8LfaxGvv75Dc5KtO03S08P5thQOyGno= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-283-3FfZJy17PoKvPLfhp7L94A-1; Fri, 24 Jan 2020 09:25:50 -0500 X-MC-Unique: 3FfZJy17PoKvPLfhp7L94A-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CC690800D41; Fri, 24 Jan 2020 14:25:48 +0000 (UTC) Received: from laptop.redhat.com (ovpn-116-37.ams2.redhat.com [10.36.116.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id 46DF119C69; Fri, 24 Jan 2020 14:25:44 +0000 (UTC) From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, maz@kernel.org, linux-kernel@vger.kernel.org, kvmarm@lists.cs.columbia.edu Cc: andrew.murray@arm.com Subject: [PATCH 1/4] KVM: arm64: pmu: Don't increment SW_INCR if PMCR.E is unset Date: Fri, 24 Jan 2020 15:25:32 +0100 Message-Id: <20200124142535.29386-2-eric.auger@redhat.com> In-Reply-To: <20200124142535.29386-1-eric.auger@redhat.com> References: <20200124142535.29386-1-eric.auger@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The specification says PMSWINC increments PMEVCNTR_EL1 by 1 if PMEVCNTR_EL0 is enabled and configured to count SW_INCR. For PMEVCNTR_EL0 to be enabled, we need both PMCNTENSET to be set for the corresponding event counter but we also need the PMCR.E bit to be set. Fixes: 7a0adc7064b8 ("arm64: KVM: Add access handler for PMSWINC register= ") Signed-off-by: Eric Auger Reviewed-by: Andrew Murray Acked-by: Marc Zyngier --- virt/kvm/arm/pmu.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/virt/kvm/arm/pmu.c b/virt/kvm/arm/pmu.c index 8731dfeced8b..c3f8b059881e 100644 --- a/virt/kvm/arm/pmu.c +++ b/virt/kvm/arm/pmu.c @@ -486,6 +486,9 @@ void kvm_pmu_software_increment(struct kvm_vcpu *vcpu= , u64 val) if (val =3D=3D 0) return; =20 + if (!(__vcpu_sys_reg(vcpu, PMCR_EL0) & ARMV8_PMU_PMCR_E)) + return; + enable =3D __vcpu_sys_reg(vcpu, PMCNTENSET_EL0); for (i =3D 0; i < ARMV8_PMU_CYCLE_IDX; i++) { if (!(val & BIT(i))) --=20 2.20.1