From patchwork Sun Apr 23 17:08:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 9694959 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 699F160245 for ; Sun, 23 Apr 2017 17:11:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 517A626538 for ; Sun, 23 Apr 2017 17:11:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 45899265B9; Sun, 23 Apr 2017 17:11:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D494E269A3 for ; Sun, 23 Apr 2017 17:11:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1163100AbdDWRLX (ORCPT ); Sun, 23 Apr 2017 13:11:23 -0400 Received: from mail-wm0-f52.google.com ([74.125.82.52]:36684 "EHLO mail-wm0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1162603AbdDWRKF (ORCPT ); Sun, 23 Apr 2017 13:10:05 -0400 Received: by mail-wm0-f52.google.com with SMTP id u65so7503545wmu.1 for ; Sun, 23 Apr 2017 10:10:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=bInz8LSpgKdyiSAE0r27/4K2OvbRH/FonBeX/RtI+Wg=; b=da4/FAo23xYEfxAZ8wZqvGgF0SMdC4MoNFEMZccB6DgEJ24liiPFZPsOdpdtS56fN1 8h2LPOXoda7X+dXBL+zTnoiHC3HSw+5RTpjOjy6bvBBGVuLw5zjOCPVX0Q5DUfCtPlu2 YIksXCVcwGl1yWhzhTKBFq5Jje48kBYlpj1lQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=bInz8LSpgKdyiSAE0r27/4K2OvbRH/FonBeX/RtI+Wg=; b=hlR0qsWxNbVRrcf9uLgwSunFepHWEpH3eNSaQYeUVa6nsk17NUFe+FXBkLTWrZbZ6B t1r8tZO77nsaw0PI3J3gtgjClgYTxAJErwaCxJuUI4qe435eWxQEbfFCvNsy2lYl3KEc 4Km1LiSxfo2DtrYE+J8paJ4gpF05JXb4KPV7BmWQb0K1e8tAUWehUBkMYAJIhBJCnsme 42R64feNZigVsssLEUg70ADVMdknURVM4lhKGe8e0YP7jZqrEeKX0L/iWZyu1lScK2kN uQggAlqYeEZWQ0o8uyz02RC0vXOt24EsYaLK0K+2SWor+bzvY8Qtny8l689ZwDpokIEu /d7g== X-Gm-Message-State: AN3rC/7Qdcp8hahEfGq6dVPg/zW6F6X8rsbrmntwMLlssJLOYycq30ka GrkBizB6S1+ju0809MLZhA== X-Received: by 10.80.147.89 with SMTP id n25mr121168eda.69.1492967403753; Sun, 23 Apr 2017 10:10:03 -0700 (PDT) Received: from localhost.localdomain (xd93ddc2d.cust.hiper.dk. [217.61.220.45]) by smtp.gmail.com with ESMTPSA id 58sm2803521edz.2.2017.04.23.10.10.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 23 Apr 2017 10:10:03 -0700 (PDT) From: Christoffer Dall To: Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= Cc: Marc Zyngier , kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PULL 31/79] arm64: KVM: PMU: Inject UNDEF on read access to PMSWINC_EL0 Date: Sun, 23 Apr 2017 19:08:41 +0200 Message-Id: <20170423170929.27334-32-cdall@linaro.org> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170423170929.27334-1-cdall@linaro.org> References: <20170423170929.27334-1-cdall@linaro.org> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Marc Zyngier PMSWINC_EL0 is a WO register, so let's UNDEF when reading from it (in the highly hypothetical case where this doesn't UNDEF at EL1). Reviewed-by: Christoffer Dall Signed-off-by: Marc Zyngier --- arch/arm64/kvm/sys_regs.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c index 20f90c0..3fef01d 100644 --- a/arch/arm64/kvm/sys_regs.c +++ b/arch/arm64/kvm/sys_regs.c @@ -772,16 +772,15 @@ static bool access_pmswinc(struct kvm_vcpu *vcpu, struct sys_reg_params *p, if (!kvm_arm_pmu_v3_ready(vcpu)) return trap_raz_wi(vcpu, p, r); + if (!p->is_write) + return read_from_write_only(vcpu, p); + if (pmu_write_swinc_el0_disabled(vcpu)) return false; - if (p->is_write) { - mask = kvm_pmu_valid_counter_mask(vcpu); - kvm_pmu_software_increment(vcpu, p->regval & mask); - return true; - } - - return false; + mask = kvm_pmu_valid_counter_mask(vcpu); + kvm_pmu_software_increment(vcpu, p->regval & mask); + return true; } static bool access_pmuserenr(struct kvm_vcpu *vcpu, struct sys_reg_params *p,