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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2BE2DCDB465 for ; Thu, 19 Oct 2023 07:21:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232858AbjJSHVG (ORCPT ); Thu, 19 Oct 2023 03:21:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232990AbjJSHVC (ORCPT ); Thu, 19 Oct 2023 03:21:02 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1DB69130 for ; Thu, 19 Oct 2023 00:21:01 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 88366C433C7; Thu, 19 Oct 2023 07:21:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1697700060; bh=SnrFhaZSmD0ROC/5wAvVn37d5U+f00s0nr48yYL0B7Y=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Bc9aJd28kZcrmmhY3ZE+yvl4piKSjOreHFgx0llEh9qlEBaB9bn/DV581gLKIycHP 2g6JEAsLvlC+D2mq/p3GBZw+EZ4EP/m24Jni2fw4ZkU7aJ9e7UHUaAYDzdKNDBhWPZ okfp2bNeqOJ9/tAnhfVpROr2V6/atcojntTaaZGRJkD1sL4cMtyN2+a18fEEA01NKF xGRtLMnF5Qk/n5gN8BEbwof/BZSeQJvfmzDTNuuG743kLUyQn21Z37A8gEdhj9olHy RwFnte0Kj1vl5OEwbKoTN80yVcOkYlqsTmz7WKgmUVIEkq1wfgZk5+vqmk+DYqGZG8 94HTQB1UHeR4g== Received: from ip-185-104-136-29.ptr.icomera.net ([185.104.136.29] helo=wait-a-minute.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1qtNKz-005eIo-SA; Thu, 19 Oct 2023 08:20:58 +0100 Date: Thu, 19 Oct 2023 08:20:56 +0100 Message-ID: <871qdr6pt3.wl-maz@kernel.org> From: Marc Zyngier To: Oliver Upton Cc: kvmarm@lists.linux.dev, kvm@vger.kernel.org, James Morse , Suzuki K Poulose , Zenghui Yu Subject: Re: [PATCH v2 2/2] KVM: arm64: Virtualise PMEVTYPER_EL1.{NSU,NSK} In-Reply-To: References: <20231013052901.170138-1-oliver.upton@linux.dev> <20231013052901.170138-3-oliver.upton@linux.dev> <86o7gwm50g.wl-maz@kernel.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/28.2 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.104.136.29 X-SA-Exim-Rcpt-To: oliver.upton@linux.dev, kvmarm@lists.linux.dev, kvm@vger.kernel.org, james.morse@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org On Wed, 18 Oct 2023 19:24:11 +0100, Oliver Upton wrote: > > On Wed, Oct 18, 2023 at 02:31:11PM +0100, Marc Zyngier wrote: > > On Fri, 13 Oct 2023 06:29:01 +0100, > > Oliver Upton wrote: > > > > > > Suzuki noticed that KVM's PMU emulation is oblivious to the NSU and NSK > > > event filter bits. On systems that have EL3 these bits modify the > > > filter behavior in non-secure EL0 and EL1, respectively. Even though the > > > kernel doesn't use these bits, it is entirely possible some other guest > > > OS does. > > > > But what does it mean for KVM itself? We have no EL3 to speak of as > > far as a guest is concerned. And the moment we allow things like > > NSU/NSK to be set, why don't we allow M as well? > > Yeah, we need to have a think about all these extra bits TBH. > > KVM doesn't filter the advertised ELs in PFR0, so from the guest POV > both EL2 and EL3 could potentially be implemented by the vCPU. Based > on that I think the bits at least need to be stateful, even though KVM's > emulation will never let the guest count events in a higher EL. > > My patches aren't even consistent with the above statement, as NSH gets > RES0 treatment and the NS{U,K} bits do not. So how about this: > > - If EL3 is advertised in the guest's ID registers NS{U,K}, and M can > be set. NS{U,K} work as proposed, M is ignored in KVM emulation. > > - If EL2 is advertised in the guest's ID registers NSH can be set but > is ignored in KVM emulation. > > Thoughts? This would be consistent with the pseudocode (and what KVM can reasonably achieve at this stage). Care to respin it? Thanks, M. -- Without deviation from the norm, progress is not possible.