Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp2076901ybf; Mon, 2 Mar 2020 01:21:11 -0800 (PST) X-Google-Smtp-Source: APXvYqyIpO5BOwenZGnKomuoGEDI5FWyI8xaNVSPSQnaien9RK7o5hvRlvq6buVOjmOLv7t37uBX X-Received: by 2002:a9d:6255:: with SMTP id i21mr12371726otk.183.1583140870893; Mon, 02 Mar 2020 01:21:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583140870; cv=none; d=google.com; s=arc-20160816; b=CpazoZLuczQF8wrJzT2xsZcRRO8KAkLtzfD1/QK1dhXmHyUjU9YCGIx569PRhlNDQK 6ty0199VXEcbrDF9saHht9BYkY0VhWNXDeiJYA8e/KXaif4K2cxq5v224frzsCmtoEHH JeUNVIkibMJjJQ5CrH+bk6fOWPRXshyyK8pxXiWKHoU6GfR81HF7IVieO2faIbp6uyUb f1jhgFwPHoJsbQwn3LkChWA7qJjqG+tIXTTuIp9a3zGxtvw1aqoBSAZTpcOf/6m2As9c VfuQbxjofLV+2CBivj2Fq0dMFpdj+oX21kB2z/qdTUIy+H/P8DbKehl+G/r72ndf2uL+ G+Ew== 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 :message-id:date:subject:to:from:dkim-signature; bh=ZJFxdajhUjFzdrLxSpnS9/s8iz/FeaFiOGrLtEOmsgI=; b=BMuLo4rWIAQ1A2QHcdbWvtqnTtvaQ6pe+yLuNUFzU0WrtVFbmVbuii6ZUu6dS9Ncvs P7jQX5DG2+7o7abQ2/77xlGktdDdDv9cPZWDwq3f/akRq9kQTFmygtasPEpI2AVKYfBz xUqvUXs6ih40hl36PVNFzEvwUMnun4wpP/xXUifHXzQR03yy7D3pirJoQTviDFPl1oNV NCUYi6TedPxdUqEUF/34G2HGqLfzcDoaaCs8bdaIuEr5CLsGVqD/LisvDjxaQMNULRNt 3W/bemxfU0RVUx4trvdY8i/yz+Van+NVOwTFscXYIb4jumGFbr/EF/rJdXBQ0yrWZntu xT8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=WZMs7cT0; 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 2si6006633ois.221.2020.03.02.01.20.58; Mon, 02 Mar 2020 01:21:10 -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=WZMs7cT0; 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 S1726946AbgCBJUn (ORCPT + 99 others); Mon, 2 Mar 2020 04:20:43 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:56963 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726390AbgCBJUn (ORCPT ); Mon, 2 Mar 2020 04:20:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583140842; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=ZJFxdajhUjFzdrLxSpnS9/s8iz/FeaFiOGrLtEOmsgI=; b=WZMs7cT0hQ3TsEBbGbPrNV9x80PKC5LoZK+sHYMtsx9luTZOa/aSfJxeT3jYoeWTNtFHAn n+kdGCfHQtV79f5TDX3vSzhCLE1OwHZEcoKzlciy9TW3a9vsyrxIeLgi9S0KbwtAUQgcjj yWLV9fRgIB8+8M/m66S3wwsnEp2OiLk= 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-295-mnSEhPCwNjSTOH0xBNql0Q-1; Mon, 02 Mar 2020 04:20:40 -0500 X-MC-Unique: mnSEhPCwNjSTOH0xBNql0Q-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 59FED189F760; Mon, 2 Mar 2020 09:20:39 +0000 (UTC) Received: from laptop.redhat.com (ovpn-116-59.ams2.redhat.com [10.36.116.59]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2EAE860BF3; Mon, 2 Mar 2020 09:20:34 +0000 (UTC) From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, stable@vger.kernel.org, maz@kernel.org, linux-kernel@vger.kernel.org, kvmarm@lists.cs.columbia.edu Subject: [PATCH] KVM: arm64: pmu: Don't increment SW_INCR if PMCR.E is unset Date: Mon, 2 Mar 2020 10:20:25 +0100 Message-Id: <20200302092025.22321-1-eric.auger@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org commit 3837407c1aa1 upstream. 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 Cc: # 4.14 only --- This is a backport of 3837407c1aa1 ("KVM: arm64: pmu: Don't increment SW_INCR if PMCR.E is unset") which did not apply on 4.14-stable. Compared to the original patch __vcpu_sys_reg() is replaced by vcpu_sys_reg(). --- 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 8a9c42366db7..3998add436da 100644 --- a/virt/kvm/arm/pmu.c +++ b/virt/kvm/arm/pmu.c @@ -316,6 +316,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