Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp9849602rwp; Thu, 20 Jul 2023 10:32:38 -0700 (PDT) X-Google-Smtp-Source: APBJJlGg6opOw17lLkJb+rm/l60YRhh9cApVH7Isfm/xfRkF4vzPn7eIEx+jD230K0skNPpnDCju X-Received: by 2002:a05:6a00:24c8:b0:678:5d3c:33e8 with SMTP id d8-20020a056a0024c800b006785d3c33e8mr31701723pfv.18.1689874358149; Thu, 20 Jul 2023 10:32:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689874358; cv=none; d=google.com; s=arc-20160816; b=vOgHPlsjh6tYPFbuVgKAinMzby/+6N+ld+6mZ0qbMTVfvzVCGVBW0ymdZWW0eD0/FM bMBH1c8V2b4HXLpZs5B+OpX2msVADo94KzS76HkoF+AI8jBILc6csE4WERNJMgZJiaan ebFNk1Yhd43Hi58s2/LfWzJ191HZOSpfdYMpwlbcXQ0UsqKMwprIcLHI8vxMZ80RTnGy ZUMaomyVLBv5eCjbOzLjde0QbQAqyaNBNgNX5BnSt5huhc/3vtOQHvGkY8h2d1EeIh4f 7G58CbAQ9CuE0qhXo0gXNrjBN6zfjASh2d7lpnizwa8/9yIyu3nPk4FkPwW7Sy/ISEeK LbHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date:dkim-signature; bh=lUeD3WZ6Emqt4aPOsrOl+hgs2TTa7Y2pNCfyxw6BrYY=; fh=prB+KtrYXddCKe0XFbBsYS44yZ3OEJH/tb89BeeQEhM=; b=gKhlJ3mxBcuD0iinDcuFZ+7a4k1Sw1KlrAF6aGludL19bRs4QB+/dofzCPbzG2kZqX VyzhXNh/AHR1xmZ1ATwnWy7fH5+poLp5yTOzqNGYMAl46qk+Tvx+AL8kpMTVecIC+ty/ 8LDiEL+g2sIYypX+R1kf2hquz4fuVoR4QTqzkC5EEQzpEsOt910BYmPj8BnWsIBjed/c ISmFEFO309K7qa/uwdOPQskz+leCjKyPQf5c8A3ag5/jLj9glZPQA96GVLzLYd5SWdnL RB3vZIpmk1YG9o/2xR2R71Mq+LN7gVihjdJ4AlPcwhjpgyb/qUyNamn1y4ZnjY8z3pZ+ 0MPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SsMVVFOH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k17-20020a056a00169100b00659af029c39si1458359pfc.90.2023.07.20.10.32.25; Thu, 20 Jul 2023 10:32:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SsMVVFOH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231274AbjGTRJc (ORCPT + 99 others); Thu, 20 Jul 2023 13:09:32 -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 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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.