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 389A6C6FA99 for ; Sun, 12 Mar 2023 10:12:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229823AbjCLKMq (ORCPT ); Sun, 12 Mar 2023 06:12:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229514AbjCLKMo (ORCPT ); Sun, 12 Mar 2023 06:12:44 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8F912B9FD; Sun, 12 Mar 2023 03:12:35 -0700 (PDT) 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 ams.source.kernel.org (Postfix) with ESMTPS id 55809B80B8E; Sun, 12 Mar 2023 10:12:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DEE6FC433EF; Sun, 12 Mar 2023 10:12:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1678615953; bh=E7bPVAJB0P+NNUv6wlLhylVPpS+IMeu0U2Tgnih222A=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=hs+B2RdhF8yCtX3AI/64vDPUdob4V//XDNTjqKcYtyv4Fen+yoFEZj3ihh5CcleYc z2XFSLdjys8Ew7++uTpr2WHJgqEuHGir4JBYaEcX83uHiWHkE5FloUTmLC+KAt8mLR XQD/k8UAKWzUkrriU6fnUp8aPltYttnT2a4ulAnT+tO8QQls7+uJ9IeS/UtZSK4gTd ecpFB3RL/AXGLUQLpyx+C6QFc5bSoDXp9IIsfPHBUYiHMTCRwbc1akUZq90QiBhHin xB+6zfedEqXpnd3fJn9an91NO41PV4ElZsu1qFgXIwN3gVFRVonWT2BI91mqD7Bf08 x1Kri4o4D+wIA== Received: from sofa.misterjones.org ([185.219.108.64] 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 1pbIgo-00GyIX-8j; Sun, 12 Mar 2023 10:12:30 +0000 Date: Sun, 12 Mar 2023 10:12:29 +0000 Message-ID: <87h6uq5lde.wl-maz@kernel.org> From: Marc Zyngier To: Sean Christopherson Cc: Paolo Bonzini , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Oliver Upton , James Morse , Suzuki K Poulose , Zenghui Yu , kvmarm@lists.linux.dev, Huacai Chen , Aleksandar Markovic , Anup Patel , Atish Patra , kvm-riscv@lists.infradead.org Subject: Re: [PATCH 1/2] KVM: Use syscore_ops instead of reboot_notifier to hook restart/shutdown In-Reply-To: <20230310221414.811690-2-seanjc@google.com> References: <20230310221414.811690-1-seanjc@google.com> <20230310221414.811690-2-seanjc@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/27.1 (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.219.108.64 X-SA-Exim-Rcpt-To: seanjc@google.com, pbonzini@redhat.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, oliver.upton@linux.dev, james.morse@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, kvmarm@lists.linux.dev, chenhuacai@kernel.org, aleksandar.qemu.devel@gmail.com, anup@brainfault.org, atishp@atishpatra.org, kvm-riscv@lists.infradead.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 Fri, 10 Mar 2023 22:14:13 +0000, Sean Christopherson wrote: > > Use syscore_ops.shutdown to disable hardware virtualization during a > reboot instead of using the dedicated reboot_notifier so that KVM disables > virtualization _after_ system_state has been updated. This will allow > fixing a race in KVM's handling of a forced reboot where KVM can end up > enabling hardware virtualization between kernel_restart_prepare() and > machine_restart(). > > Cc: Marc Zyngier > Cc: Oliver Upton > Cc: James Morse > Cc: Suzuki K Poulose > Cc: Zenghui Yu > Cc: kvmarm@lists.linux.dev > Cc: Huacai Chen > Cc: Aleksandar Markovic > Cc: Anup Patel > Cc: Atish Patra > Cc: kvm-riscv@lists.infradead.org > Signed-off-by: Sean Christopherson > --- > virt/kvm/kvm_main.c | 14 +++----------- > 1 file changed, 3 insertions(+), 11 deletions(-) > > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c > index d255964ec331..6cdfbb2c641b 100644 > --- a/virt/kvm/kvm_main.c > +++ b/virt/kvm/kvm_main.c > @@ -5211,8 +5211,7 @@ static int hardware_enable_all(void) > return r; > } > > -static int kvm_reboot(struct notifier_block *notifier, unsigned long val, > - void *v) > +static void kvm_reboot(void) > { > /* > * Some (well, at least mine) BIOSes hang on reboot if > @@ -5223,14 +5222,8 @@ static int kvm_reboot(struct notifier_block *notifier, unsigned long val, > pr_info("kvm: exiting hardware virtualization\n"); > kvm_rebooting = true; > on_each_cpu(hardware_disable_nolock, NULL, 1); > - return NOTIFY_OK; > } > > -static struct notifier_block kvm_reboot_notifier = { > - .notifier_call = kvm_reboot, > - .priority = 0, > -}; > - > static int kvm_suspend(void) > { > /* > @@ -5261,6 +5254,8 @@ static void kvm_resume(void) > static struct syscore_ops kvm_syscore_ops = { > .suspend = kvm_suspend, > .resume = kvm_resume, > + .shutdown = kvm_reboot, > + nit: consider renaming the kvm_reboot to kvm_shutdown to match the syscore structure, and drop the spurious blank line. M. -- Without deviation from the norm, progress is not possible.