From patchwork Fri Oct 11 12:39:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Zyngier X-Patchwork-Id: 11185359 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 93A6414ED for ; Fri, 11 Oct 2019 12:40:32 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 72308214E0 for ; Fri, 11 Oct 2019 12:40:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="BCn3N/hg" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 72308214E0 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=VeLx83W68OL/aAU+w7xfHdo+yj7Y0m0+vJL63Bvi04I=; b=BCn3N/hg75QKOW pw1FCfDaaN3jc3LJYEYmvkYatmkxw39oFDWlANaKwpmdB8AzsovLlU2sxbn0wXu73AnHsaywZ1nrv wb4zbvrBviWPy2tjGHMUfW6Kyx/Fq/rAksgNXuzb7rXnL8erFEu00XhrNXC4vf8CUHT9T6zV2oMtc HGW9NsAw+hNNBO8Z8jxqWRCfCjU1dDuR0iN1IGvD+P/w+8r//4tQRZFpFhYgQMUEfrCW6PSxIbpvJ Nuj9C4FJ8GK7kiX0pHX6CAmXgogCBSWAX/OQBv3g/7uufYFWpKEDt9jEID/FimA0pltG3U2hInPSF 9HTBekp8JeDi28IVTRrQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iIuDf-0006qx-VI; Fri, 11 Oct 2019 12:40:32 +0000 Received: from inca-roads.misterjones.org ([213.251.177.50]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1iIuDV-0006fp-G2 for linux-arm-kernel@lists.infradead.org; Fri, 11 Oct 2019 12:40:23 +0000 Received: from 78.163-31-62.static.virginmediabusiness.co.uk ([62.31.163.78] helo=why.lan) by cheepnis.misterjones.org with esmtpsa (TLSv1.2:DHE-RSA-AES128-GCM-SHA256:128) (Exim 4.80) (envelope-from ) id 1iIuDO-00062U-Br; Fri, 11 Oct 2019 14:40:14 +0200 From: Marc Zyngier To: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org Subject: [PATCH v3 0/4] KVM: arm64: Assorted PMU emulation fixes Date: Fri, 11 Oct 2019 13:39:50 +0100 Message-Id: <20191011123954.31378-1-maz@kernel.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-SA-Exim-Connect-IP: 62.31.163.78 X-SA-Exim-Rcpt-To: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, will@kernel.org, mark.rutland@arm.com, james.morse@arm.com, julien.thierry.kdev@gmail.com, suzuki.poulose@arm.com, andrew.murray@arm.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on cheepnis.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191011_054021_694682_D1312ECA X-CRM114-Status: UNSURE ( 9.24 ) X-CRM114-Notice: Please train this message. X-Spam-Score: 1.0 (+) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (1.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 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 , Suzuki K Poulose , James Morse , Andrew Murray , Will Deacon , Julien Thierry Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org I recently came across a number of PMU emulation bugs, all which can result in unexpected behaviours in an unsuspecting guest. The first two patches already have been discussed on the list, but I'm including them here as part of a slightly longer series. The third patch is new as of v2, and fixes a bug preventing chained events from ever being used. The last patch fixes an issue that has been here from day one, where we confuse architectural overflow of a counter and perf sampling period, and uses a terrible hack^W^W creative way to interact with the underlying PMU driver so that we can reload the period when handling the overflow. * From v2 [1] - Dropped PMUv3 patch and moved the logic into the KVM code - Properly use UPDATE/RELOAD - Collected Andrew's RB [1] https://lore.kernel.org/kvmarm/20191008160128.8872-1-maz@kernel.org/ Marc Zyngier (4): KVM: arm64: pmu: Fix cycle counter truncation arm64: KVM: Handle PMCR_EL0.LC as RES1 on pure AArch64 systems KVM: arm64: pmu: Set the CHAINED attribute before creating the in-kernel event KVM: arm64: pmu: Reset sample period on overflow handling arch/arm64/kvm/sys_regs.c | 4 ++++ virt/kvm/arm/pmu.c | 48 ++++++++++++++++++++++++++++----------- 2 files changed, 39 insertions(+), 13 deletions(-)