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 04093EB64DD for ; Thu, 20 Jul 2023 17:09:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231443AbjGTRJd (ORCPT ); Thu, 20 Jul 2023 13:09:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231138AbjGTRJb (ORCPT ); Thu, 20 Jul 2023 13:09:31 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 754A6AA; Thu, 20 Jul 2023 10:09:30 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 04F0B61B54; Thu, 20 Jul 2023 17:09:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 665B4C433C7; Thu, 20 Jul 2023 17:09:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689872969; bh=Hrcx6Pm4TTDsV1NJBZCewGpqN+gICfUVfLzVWI7VTvk=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=SsMVVFOHjT7S4PNsHRk02MBLl1FrgL/inwUsXdgK/+k42JIe7LyWK6EpPZ75hOdNq lT/iNuMXIUiZuOPt7NOmnfVtRwKn51g3rq9rEtmpovDnzgeUGiXdOASCgTTPmt1A2P G3le7neoP+qLYwtU9Vl9zFD4O6S1sQW580wRhcNcQfkvVU30g6pgQcO6zEfETdNLXd ks5T1yQkUnBHotQFb6xns4kWw22LEVhWA50EonGd9RiHIUl7IrQpIHDDObO9x3Cgja yrNyadHpHiwufGDEHKp07EtYGeEeeH3Eowxx5NMpSnRVJ44Mx3cbJC9YjGhl5+z/85 dSjZaghB7wE6A== 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 1qMX9b-00Emp0-2b; Thu, 20 Jul 2023 18:09:27 +0100 Date: Thu, 20 Jul 2023 18:09:26 +0100 Message-ID: <86tttytsqh.wl-maz@kernel.org> From: Marc Zyngier To: Raghavendra Rao Ananta Cc: Oliver Upton , James Morse , Suzuki K Poulose , Will Deacon , Fuad Tabba , Jing Zhang , Colton Lewis , Reiji Watanabe , kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org, kvm@vger.kernel.org Subject: Re: [PATCH v2] KVM: arm64: Fix hardware enable/disable flows for pKVM In-Reply-To: <20230719215725.799162-1-rananta@google.com> References: <20230719215725.799162-1-rananta@google.com> 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") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: rananta@google.com, oliver.upton@linux.dev, james.morse@arm.com, suzuki.poulose@arm.com, will@kernel.org, tabba@google.com, jingzhangos@google.com, coltonlewis@google.com, reijiw@google.com, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org, kvm@vger.kernel.org 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: linux-kernel@vger.kernel.org On Wed, 19 Jul 2023 22:57:25 +0100, Raghavendra Rao Ananta wrote: > > When running in protected mode, the hyp stub is disabled after pKVM is > initialized, meaning the host cannot enable/disable the hyp at > runtime. As such, kvm_arm_hardware_enabled is always 1 after > initialization, and kvm_arch_hardware_enable() never enables the vgic > maintenance irq or timer irqs. > > Unconditionally enable/disable the vgic + timer irqs in the respective > calls, instead relying on the percpu bookkeeping in the generic code > to keep track of which cpus have the interrupts unmasked. > > Fixes: 466d27e48d7c ("KVM: arm64: Simplify the CPUHP logic") > Reported-by: Oliver Upton > Suggested-by: Oliver Upton > Signed-off-by: Raghavendra Rao Ananta > --- > arch/arm64/kvm/arm.c | 14 ++++---------- > 1 file changed, 4 insertions(+), 10 deletions(-) > > diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c > index c2c14059f6a8..010ebfa69650 100644 > --- a/arch/arm64/kvm/arm.c > +++ b/arch/arm64/kvm/arm.c > @@ -1867,14 +1867,10 @@ static void _kvm_arch_hardware_enable(void *discard) > > int kvm_arch_hardware_enable(void) > { > - int was_enabled = __this_cpu_read(kvm_arm_hardware_enabled); > - > _kvm_arch_hardware_enable(NULL); > > - if (!was_enabled) { > - kvm_vgic_cpu_up(); > - kvm_timer_cpu_up(); > - } > + kvm_vgic_cpu_up(); > + kvm_timer_cpu_up(); > > return 0; > } > @@ -1889,10 +1885,8 @@ static void _kvm_arch_hardware_disable(void *discard) > > void kvm_arch_hardware_disable(void) > { > - if (__this_cpu_read(kvm_arm_hardware_enabled)) { > - kvm_timer_cpu_down(); > - kvm_vgic_cpu_down(); > - } > + kvm_timer_cpu_down(); > + kvm_vgic_cpu_down(); > > if (!is_protected_kvm_enabled()) > _kvm_arch_hardware_disable(NULL); Note that this will likely conflict with the preemption disabling patch that is on its way to upstream. Otherwise: Acked-by: Marc Zyngier M. -- Without deviation from the norm, progress is not possible.