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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 42B66C77B61 for ; Thu, 13 Apr 2023 08:57:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Subject:Cc:To:From:Message-ID:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=xnhaORSXwXwVB8LLzt4gezk5WZfIel7m70oZx5MlRlg=; b=xXp7tqGmLAFUjQ tP10le//+GRW27bkN6etYxJMRt9SIdZK74luJeDMUe7ClpWbO+84xKnrdhtEoIhxOrIgSQbgNuqZi /FvbMk+FfCo1yQyzTU6dub1+3It0/NWqpRamp1MU/Qt8XlPtZ3+quMsEDHx0tNf2wYWB57EQ9cy/9 IyUgl939F25Qgh8uAQ03TWuyW3UI8gRmX8E1CE/zYun+7Fic6PZp7rEqDuTwEleqNHhRB3lvT885V oYxpm35reiBtjEgu9Pg9T3Bq4NnsVyrA8sfkIryWjCGjLekW+L9COF2UqpuKLSPgyO3AW83qYGYVQ oHpB0MibHlcWUGpPIlAA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pmslJ-005U2R-3A; Thu, 13 Apr 2023 08:57:02 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pmslH-005U1Z-2f for linux-arm-kernel@lists.infradead.org; Thu, 13 Apr 2023 08:57:01 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 3550560F51; Thu, 13 Apr 2023 08:56:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 93771C433EF; Thu, 13 Apr 2023 08:56:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1681376218; bh=zEf3rhAJHBPYfiQYH2oVuSK4sAgQN8WGP8TwFvgADmo=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=SPw5L1Jn7S/Frm7xZT8KZvOePxJRqV6nBhmUTP/OupGiG8Coy/3IHcxsZl+MbNw4S ZQBntnOFQOSy3g9B81P2n3en1enRc/PRVcz9Ittag4yDNEfGJ6ncx7xnd7dPwUQdJc ZuFdLk2EBe4C4CoPhCprWi/Ga/SYR8CPXd2Lc5zQPnq0iaCMHauyoKrWWPzTyz21QI iQPAaf3nsstl6kZrdS7VYmIYi9m3JAwQP4W9kWdPBtDGeTJSOJHObODffYeZpDycH6 nSM3rzKzA6Dw+ho2CtkuDUGpgGmDEHNR0Auaz5Mh1a8njBstirXuhJM/6DJjZM64Qi FGdmsUlV0Ai4g== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.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 1pmslE-0083Tf-Ab; Thu, 13 Apr 2023 09:56:56 +0100 Date: Thu, 13 Apr 2023 09:56:55 +0100 Message-ID: <86jzygkvmw.wl-maz@kernel.org> From: Marc Zyngier To: Reiji Watanabe Cc: Mark Rutland , Oliver Upton , Will Deacon , Catalin Marinas , kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, James Morse , Alexandru Elisei , Zenghui Yu , Suzuki K Poulose , Paolo Bonzini , Ricardo Koller , Jing Zhang , Raghavendra Rao Anata , Shaoqin Huang , Rob Herring Subject: Re: [PATCH v2 2/2] KVM: arm64: PMU: Don't overwrite PMUSERENR with vcpu loaded In-Reply-To: References: <20230408034759.2369068-1-reijiw@google.com> <20230408034759.2369068-3-reijiw@google.com> <20230412051410.emaip77vyak624pu@google.com> <86v8i1l7ru.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 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: reijiw@google.com, mark.rutland@arm.com, oliver.upton@linux.dev, will@kernel.org, catalin.marinas@arm.com, kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, james.morse@arm.com, alexandru.elisei@arm.com, yuzenghui@huawei.com, suzuki.poulose@arm.com, pbonzini@redhat.com, ricarkol@google.com, jingzhangos@google.com, rananta@google.com, shahuang@redhat.com, robh@kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230413_015659_937847_0B45133D X-CRM114-Status: GOOD ( 30.26 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, 13 Apr 2023 01:07:38 +0100, Reiji Watanabe wrote: > > On Wed, Apr 12, 2023 at 11:22:29AM +0100, Marc Zyngier wrote: > > On Wed, 12 Apr 2023 10:20:05 +0100, > > Mark Rutland wrote: > > > > > > On Tue, Apr 11, 2023 at 10:14:10PM -0700, Reiji Watanabe wrote: > > > > Uh, right, interrupts are not masked during those windows... > > > > > > > > What I am currently considering on this would be disabling > > > > IRQs while manipulating the register, and introducing a new flag > > > > to indicate whether the PMUSERENR for the guest EL0 is loaded, > > > > and having kvm_set_pmuserenr() check the new flag. > > > > > > > > The code would be something like below (local_irq_save/local_irq_restore > > > > needs to be excluded for NVHE though). > > > > It shouldn't need to be excluded. It should be fairly harmless, unless > > I'm missing something really obvious? > > The reason why I think local_irq_{save,restore} should be excluded > are because they use trace_hardirqs_{on,off} (Since IRQs are > masked here for NVHE, practically, they shouldn't be called with > the current KVM implementation though). Gah. Indeed, we end-up with a lot of unwanted crap, and absolutely no way to locally override it. > I'm looking at using "ifndef __KVM_NVHE_HYPERVISOR__" or other > ways to organize the code for this. I'd vote for something like the code below: diff --git a/arch/arm64/kvm/hyp/nvhe/Makefile b/arch/arm64/kvm/hyp/nvhe/Makefile index 530347cdebe3..1796fadb26cc 100644 --- a/arch/arm64/kvm/hyp/nvhe/Makefile +++ b/arch/arm64/kvm/hyp/nvhe/Makefile @@ -10,7 +10,7 @@ asflags-y := -D__KVM_NVHE_HYPERVISOR__ -D__DISABLE_EXPORTS # will explode instantly (Words of Marc Zyngier). So introduce a generic flag # __DISABLE_TRACE_MMIO__ to disable MMIO tracing for nVHE KVM. ccflags-y := -D__KVM_NVHE_HYPERVISOR__ -D__DISABLE_EXPORTS -D__DISABLE_TRACE_MMIO__ -ccflags-y += -fno-stack-protector \ +ccflags-y += -fno-stack-protector -DNO_TRACE_IRQFLAGS \ -DDISABLE_BRANCH_PROFILING \ $(DISABLE_STACKLEAK_PLUGIN) diff --git a/include/linux/irqflags.h b/include/linux/irqflags.h index 5ec0fa71399e..ab0ae58dd797 100644 --- a/include/linux/irqflags.h +++ b/include/linux/irqflags.h @@ -198,9 +198,10 @@ extern void warn_bogus_irq_restore(void); /* * The local_irq_*() APIs are equal to the raw_local_irq*() - * if !TRACE_IRQFLAGS. + * if !TRACE_IRQFLAGS or if NO_TRACE_IRQFLAGS is localy + * set. */ -#ifdef CONFIG_TRACE_IRQFLAGS +#if defined(CONFIG_TRACE_IRQFLAGS) && !defined(NO_TRACE_IRQFLAGS) #define local_irq_enable() \ do { \ > Since {__activate,__deactivate}_traps_common() are pretty lightweight > functions, I'm also considering disabling IRQs in their call sites > (i.e. activate_traps_vhe_load/deactivate_traps_vhe_put), instead of in > __{de}activate_traps_common() (Thanks for this suggestion, Oliver). That would work too. Thanks, M. -- Without deviation from the norm, progress is not possible. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel