From patchwork Tue Nov 20 14:15:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Murray X-Patchwork-Id: 10690571 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DE39B15A7 for ; Tue, 20 Nov 2018 15:56:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CD1A92A9BA for ; Tue, 20 Nov 2018 15:56:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C12C12AA19; Tue, 20 Nov 2018 15:56:16 +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=-3.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5FB952A9BA for ; Tue, 20 Nov 2018 15:56:16 +0000 (UTC) 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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To: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:List-Owner; bh=uVWjXaDOLi77Gbuurljy1LGxOISi36+kAVCaRpHaKsU=; b=WS/FfebS0CppWs7hL+YuqSsRP6 4AblaCZHYifqgPIFlvc7KEN1m0/fZfKeHBGBGZ8Y5tqt0+jUwgnHAM8rIAWYc5QsF32j16IawXc8g QS51jVKtxBYa5LKlKoECsEUiKB0X2zOOlpQooPu5hAFLp+4f/glKiMSVB/MtXTJ8F48au90fXNPGu +0Xe0Uvk/OWXcvPzFTjMOowgCDz3VLNs+hqWnvDrW/0R+veq4V9asutdlD8qiZhadsnJ2/tuDXN8p RPAUUTEYEVtWtZjmm++nKiOLpDi8+Ty+5zUlrcgElabhVxPpArAenq4mdgA7/rVhR6mRlOYJ3EGrU GE6rOhfQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gP8Nk-0006Jx-SR; Tue, 20 Nov 2018 15:56:08 +0000 Received: from merlin.infradead.org ([205.233.59.134]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gP8Ft-0003nl-EK for linux-arm-kernel@bombadil.infradead.org; Tue, 20 Nov 2018 15:48:01 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=IRyXunswoOYaYP3IrB5q+rF7byQK1gSuf925sz5PfAg=; b=CiM10JMrVq0FNcpNmN/7jOEgM 7lnTZ4DY1d9NgXjlRklV/O90o/BKT8LH9uzmYwvnsWj57SmDBxutjqzNm9Hh7hoF+qlA37cnjIGMD CHAghC1SLOKA4/juyRcugmGN7DfkB62frq+SYV770rcbhZopWletjwVwMdEY2Yz8udjMgTUkYrFDs W4LNDSCQ92n8wrM7/eIQODSm0GyqONjmn8y+FsTi7Oe5Ch9CrWva0REyg3GV30RsGdIU+mSKXYIu3 e+0T5Fo0Rhxj/HUxgixsfROaOlFZMvv/SsYh+UzUjrKN5nCjXHZR8u2f/e777yV30wMe7md9T7aD5 9UG9dc3eA==; Received: from foss.arm.com ([217.140.101.70]) by merlin.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gP6og-0008T6-7N for linux-arm-kernel@lists.infradead.org; Tue, 20 Nov 2018 14:15:51 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8077015BE; Tue, 20 Nov 2018 06:15:42 -0800 (PST) Received: from e119886-lin.cambridge.arm.com (unknown [10.37.6.11]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 89D2C3F5A0; Tue, 20 Nov 2018 06:15:40 -0800 (PST) From: Andrew Murray To: Christoffer Dall , Marc Zyngier , Catalin Marinas , Will Deacon , Mark Rutland Subject: [PATCH v2 2/4] arm64: KVM: add accessors to track guest/host only counters Date: Tue, 20 Nov 2018 14:15:20 +0000 Message-Id: <1542723322-42536-3-git-send-email-andrew.murray@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1542723322-42536-1-git-send-email-andrew.murray@arm.com> References: <1542723322-42536-1-git-send-email-andrew.murray@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181120_091550_342414_9F2EAE60 X-CRM114-Status: GOOD ( 12.64 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Julien Thierry , kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, Suzuki K Poulose MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP In order to effeciently enable/disable guest/host only perf counters at guest entry/exit we add bitfields to kvm_cpu_context for guest and host only events as well as accessors for updating them. Signed-off-by: Andrew Murray --- arch/arm64/include/asm/kvm_host.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h index 1550192..b6f998b 100644 --- a/arch/arm64/include/asm/kvm_host.h +++ b/arch/arm64/include/asm/kvm_host.h @@ -203,6 +203,8 @@ struct kvm_cpu_context { }; struct kvm_vcpu *__hyp_running_vcpu; + u32 events_host_only; + u32 events_guest_only; }; typedef struct kvm_cpu_context kvm_cpu_context_t; @@ -472,6 +474,24 @@ static inline int kvm_arch_vcpu_run_pid_change(struct kvm_vcpu *vcpu) { return kvm_arch_vcpu_run_map_fp(vcpu); } +static inline void kvm_set_clr_host_pmu_events(u32 clr, u32 set) +{ + kvm_cpu_context_t *ctx = this_cpu_ptr(&kvm_host_cpu_state); + + ctx->events_host_only &= ~clr; + ctx->events_host_only |= set; +} + +static inline void kvm_set_clr_guest_pmu_events(u32 clr, u32 set) +{ + kvm_cpu_context_t *ctx = this_cpu_ptr(&kvm_host_cpu_state); + + ctx->events_guest_only &= ~clr; + ctx->events_guest_only |= set; +} +#else +static inline void kvm_set_clr_host_pmu_events(u32 clr, u32 set) {} +static inline void kvm_set_clr_guest_pmu_events(u32 clr, u32 set) {} #endif static inline void kvm_arm_vhe_guest_enter(void)