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=-4.0 required=3.0 tests=MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=no 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 7D1FFC35280 for ; Tue, 8 Oct 2019 16:02:01 +0000 (UTC) Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by mail.kernel.org (Postfix) with ESMTP id 3442020815 for ; Tue, 8 Oct 2019 16:02:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3442020815 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvmarm-bounces@lists.cs.columbia.edu Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id E1BCA4A8C9; Tue, 8 Oct 2019 12:02:00 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id aEphK4Vw+Rnp; Tue, 8 Oct 2019 12:01:59 -0400 (EDT) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id B1F804A8EE; Tue, 8 Oct 2019 12:01:57 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 5051C4A8CB for ; Tue, 8 Oct 2019 12:01:56 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 9DIpqWF1Wp3q for ; Tue, 8 Oct 2019 12:01:55 -0400 (EDT) Received: from inca-roads.misterjones.org (inca-roads.misterjones.org [213.251.177.50]) by mm01.cs.columbia.edu (Postfix) with ESMTPS id 3DFC14A81C for ; Tue, 8 Oct 2019 12:01:55 -0400 (EDT) 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 1iHrvs-0001rs-DQ; Tue, 08 Oct 2019 18:01:52 +0200 From: Marc Zyngier To: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org Subject: [PATCH v2 0/5] KVM: arm64: Assorted PMU emulation fixes Date: Tue, 8 Oct 2019 17:01:23 +0100 Message-Id: <20191008160128.8872-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 Cc: Will Deacon X-BeenThere: kvmarm@lists.cs.columbia.edu X-Mailman-Version: 2.1.14 Precedence: list List-Id: Where KVM/ARM decisions are made List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu 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 fourth patch is also new as of v2, and is an arm64 PMU change for which I clearly don't know what I'm doing. I'd appreciate some guidance from Will or Mark. 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 patch #4 to fix the issue. I'l planning to send patches 1 through to 3 as fixes shortly, but I expect the last two patches to require more discussions. Marc Zyngier (5): 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 arm64: perf: Add reload-on-overflow capability KVM: arm64: pmu: Reset sample period on overflow handling arch/arm64/include/asm/perf_event.h | 4 +++ arch/arm64/kernel/perf_event.c | 8 ++++- arch/arm64/kvm/sys_regs.c | 4 +++ virt/kvm/arm/pmu.c | 45 +++++++++++++++++++---------- 4 files changed, 45 insertions(+), 16 deletions(-) -- 2.20.1 _______________________________________________ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm 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=-4.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=no 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 E35DAC4360C for ; Tue, 8 Oct 2019 16:02:23 +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 AA45D2070B for ; Tue, 8 Oct 2019 16:02:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="hRUvnagk" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AA45D2070B 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+infradead-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=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=7Fu87kkcEloV7fHBYioTyR6ksCADs4NJZoJxROsm7Ho=; b=hRUvnagkb4HcI7 /sZPVOx1yxEjsCQQv62Tf9yFtiotYuIyCkf2TkNUUHuv0UbMiyr8PeG2sCis75pyAQQBfSLyLGVXc 0ULnFx33cIC7M4imEy+JaffLDTk+DkPBM9SBXzoPDbmyqZvnKAGrd/ZvTjMHSSmW+Md8Ea9AdgVxH /VNp8Sy2+e6X3jEXBVfrdMYVVJGPGtsTASWFry9x4MHWCrNRNs7LhL+LJdOGm1rv/7p/qPphw3j3D gCzI+pRdFm9GBfzNZgD97v+y52ZxrKSbIuGuIoIfl2ZRsSvJsbb8p/i5gvFgodEbD6jq8APijfzfh SMVYVkXohEBYzEpvbN7Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.2 #3 (Red Hat Linux)) id 1iHrwF-0002LL-6w; Tue, 08 Oct 2019 16:02:15 +0000 Received: from inca-roads.misterjones.org ([213.251.177.50]) by bombadil.infradead.org with esmtps (Exim 4.92.2 #3 (Red Hat Linux)) id 1iHrvw-00027a-VH for linux-arm-kernel@lists.infradead.org; Tue, 08 Oct 2019 16:01:59 +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 1iHrvs-0001rs-DQ; Tue, 08 Oct 2019 18:01:52 +0200 From: Marc Zyngier To: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org Subject: [PATCH v2 0/5] KVM: arm64: Assorted PMU emulation fixes Date: Tue, 8 Oct 2019 17:01:23 +0100 Message-Id: <20191008160128.8872-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-20191008_090157_160352_C147DC91 X-CRM114-Status: GOOD ( 10.34 ) 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.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 fourth patch is also new as of v2, and is an arm64 PMU change for which I clearly don't know what I'm doing. I'd appreciate some guidance from Will or Mark. 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 patch #4 to fix the issue. I'l planning to send patches 1 through to 3 as fixes shortly, but I expect the last two patches to require more discussions. Marc Zyngier (5): 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 arm64: perf: Add reload-on-overflow capability KVM: arm64: pmu: Reset sample period on overflow handling arch/arm64/include/asm/perf_event.h | 4 +++ arch/arm64/kernel/perf_event.c | 8 ++++- arch/arm64/kvm/sys_regs.c | 4 +++ virt/kvm/arm/pmu.c | 45 +++++++++++++++++++---------- 4 files changed, 45 insertions(+), 16 deletions(-) -- 2.20.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel 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=-4.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=no 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 655E7ECE596 for ; Tue, 8 Oct 2019 16:01:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 33CDF2070B for ; Tue, 8 Oct 2019 16:01:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570550518; bh=hKiwaJhVxCSiCRF1bXZhTDlIgr8qrLaf2A0Ts8wmUUo=; h=From:To:Cc:Subject:Date:List-ID:From; b=SQ0QZGB4XXNzxB6pxb8EpA0gzsJnJuD4YtR7b5JyeySOVm0eyE5mL+aWMOBhRD9ow vChPcI6ntFobjoKsIWLuhlOs1VNCo8XJn681FjAWIhwPqFt0DgObpTZHztuaOdtnBC vFhFjrjKxHzwfDvClzPuytddcuB1jxPiVUD9qePI= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728459AbfJHQB5 (ORCPT ); Tue, 8 Oct 2019 12:01:57 -0400 Received: from inca-roads.misterjones.org ([213.251.177.50]:54549 "EHLO inca-roads.misterjones.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727970AbfJHQB5 (ORCPT ); Tue, 8 Oct 2019 12:01:57 -0400 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 1iHrvs-0001rs-DQ; Tue, 08 Oct 2019 18:01:52 +0200 From: Marc Zyngier To: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org Cc: Will Deacon , Mark Rutland , James Morse , Julien Thierry , Suzuki K Poulose , Andrew Murray Subject: [PATCH v2 0/5] KVM: arm64: Assorted PMU emulation fixes Date: Tue, 8 Oct 2019 17:01:23 +0100 Message-Id: <20191008160128.8872-1-maz@kernel.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.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 fourth patch is also new as of v2, and is an arm64 PMU change for which I clearly don't know what I'm doing. I'd appreciate some guidance from Will or Mark. 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 patch #4 to fix the issue. I'l planning to send patches 1 through to 3 as fixes shortly, but I expect the last two patches to require more discussions. Marc Zyngier (5): 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 arm64: perf: Add reload-on-overflow capability KVM: arm64: pmu: Reset sample period on overflow handling arch/arm64/include/asm/perf_event.h | 4 +++ arch/arm64/kernel/perf_event.c | 8 ++++- arch/arm64/kvm/sys_regs.c | 4 +++ virt/kvm/arm/pmu.c | 45 +++++++++++++++++++---------- 4 files changed, 45 insertions(+), 16 deletions(-) -- 2.20.1