Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp3266641rdb; Sat, 9 Dec 2023 20:54:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IHFOj/eDdaqS2lBq97FoTHSNIqeMv1xEfH9XbkycbJINAwVepG3eABB1+WmH7+Ran58QiXu X-Received: by 2002:a05:6a20:4f97:b0:18c:328b:61db with SMTP id gh23-20020a056a204f9700b0018c328b61dbmr1006640pzb.1.1702184078623; Sat, 09 Dec 2023 20:54:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702184078; cv=none; d=google.com; s=arc-20160816; b=p6DA3mHSBQrNA5pvVf/d+/NA6zxoiViBiA6MPT2hw9tGHyNU0wfDIoQ6YuES5ZmJxj Iw++4TswcCKBrjLwCsBdG0H6XC2BT8EzVkU6HV73aRsQroXmaqSLcfT99wZEZT+EKx6l pNDJv7Q9ZpToMNd9cFQJPt+eXfnlu/9ba+GlmndhIAhYn3hDuTQ/9oZTIUZjipeEGcgR XwOvpInS/Dk8PbxjJQVs5fEhZVeLORgbmCSTikcf3Vtdnkiiaz/1TZqWb96AKrcUZDgl Atw8CdeTCGfBNwr/d1IWoHibtzwcrfFAz6N9VjP1d/CS+QGLTkQM5y1zLVKtLiON38zN X81A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:content-transfer-encoding:mime-version :user-agent:message-id:in-reply-to:date:references:cc:to:from; bh=WJakYnHJlzuyxgRVI2Zybo/wQI27Kk/QqOI61hCtFJc=; fh=2nHnxd+RTvjYMl4IcsDEldRSd4eJsKeEdrJreQcHsZA=; b=dX1JLiUx4Y4yB0ja8LGaqmaMGGjqlJ0VtEZGHCB81N8YEm1VPxdsUWQ2IsWaYM7e87 23RTOZDBLCUTGyq0u6nmnlNWjsGmx/9pV6L+s42kl0bLnru7JQwEQHkj1Jisey6GRI2q qDEPdvsh/N/c7/d8QnjPj6bsK1gwKDEcoUqTGw7h+4+QoFz7RbylV8JQpNlBWNWhKobT HuozMm6RWUVJEQ7wjN6d1w4XegyAjF9lSTouayOA0icCE7Sur5uUzga+xg4CFK4UkuD3 DW0ddO4rOmjW0WYtwpaLZ+P0Rt48xJKb2ogHQhSbxBm4Ab48qEOtxR9duyqcZSOH+ReA HDFQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=xmission.com Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id i1-20020a17090a974100b00286ce76ff01si1308698pjw.146.2023.12.09.20.54.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Dec 2023 20:54:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=xmission.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 22055805FD43; Sat, 9 Dec 2023 20:54:36 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231449AbjLJEyH convert rfc822-to-8bit (ORCPT + 99 others); Sat, 9 Dec 2023 23:54:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229488AbjLJEyG (ORCPT ); Sat, 9 Dec 2023 23:54:06 -0500 Received: from out03.mta.xmission.com (out03.mta.xmission.com [166.70.13.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C47D7CC for ; Sat, 9 Dec 2023 20:54:12 -0800 (PST) Received: from in02.mta.xmission.com ([166.70.13.52]:33540) by out03.mta.xmission.com with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1rCBpP-00B9T9-5N; Sat, 09 Dec 2023 21:54:07 -0700 Received: from ip68-227-168-167.om.om.cox.net ([68.227.168.167]:35840 helo=email.froward.int.ebiederm.org.xmission.com) by in02.mta.xmission.com with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1rCBpN-00BEzy-T4; Sat, 09 Dec 2023 21:54:06 -0700 From: "Eric W. Biederman" To: "Gowans, James" Cc: "pbonzini@redhat.com" , "Graf (AWS), Alexander" , "seanjc@google.com" , =?utf-8?Q?Sc?= =?utf-8?Q?h=C3=B6nherr=2C_Jan_H=2E?= , "yuzenghui@huawei.com" , "atishp@atishpatra.org" , "kvm-riscv@lists.infradead.org" , "james.morse@arm.com" , "suzuki.poulose@arm.com" , "oliver.upton@linux.dev" , "chenhuacai@kernel.org" , "linux-kernel@vger.kernel.org" , "kvmarm@lists.linux.dev" , "maz@kernel.org" , "kvm@vger.kernel.org" , "aleksandar.qemu.devel@gmail.com" , "anup@brainfault.org" , "kexec@lists.infradead.org" References: <20230512233127.804012-1-seanjc@google.com> <20230512233127.804012-2-seanjc@google.com> Date: Sat, 09 Dec 2023 22:53:30 -0600 In-Reply-To: (James Gowans's message of "Sat, 9 Dec 2023 07:26:36 +0000") Message-ID: <871qbud5f9.fsf@email.froward.int.ebiederm.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT X-XM-SPF: eid=1rCBpN-00BEzy-T4;;;mid=<871qbud5f9.fsf@email.froward.int.ebiederm.org>;;;hst=in02.mta.xmission.com;;;ip=68.227.168.167;;;frm=ebiederm@xmission.com;;;spf=pass X-XM-AID: U2FsdGVkX1+JmH+hfPfL+HY3DU2+KTDcxM737ZP9cTs= X-SA-Exim-Connect-IP: 68.227.168.167 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-DCC: XMission; sa06 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: *;"Gowans, James" X-Spam-Relay-Country: X-Spam-Timing: total 676 ms - load_scoreonly_sql: 0.04 (0.0%), signal_user_changed: 12 (1.8%), b_tie_ro: 11 (1.6%), parse: 1.39 (0.2%), extract_message_metadata: 4.0 (0.6%), get_uri_detail_list: 1.64 (0.2%), tests_pri_-2000: 3.1 (0.5%), tests_pri_-1000: 3.5 (0.5%), tests_pri_-950: 1.20 (0.2%), tests_pri_-900: 1.03 (0.2%), tests_pri_-90: 332 (49.0%), check_bayes: 330 (48.8%), b_tokenize: 8 (1.2%), b_tok_get_all: 9 (1.4%), b_comp_prob: 2.4 (0.4%), b_tok_touch_all: 306 (45.3%), b_finish: 0.89 (0.1%), tests_pri_0: 295 (43.7%), check_dkim_signature: 0.54 (0.1%), check_dkim_adsp: 3.4 (0.5%), poll_dns_idle: 1.54 (0.2%), tests_pri_10: 3.2 (0.5%), tests_pri_500: 10 (1.5%), rewrite_mail: 0.00 (0.0%) Subject: Re: [PATCH v2 1/2] KVM: Use syscore_ops instead of reboot_notifier to hook restart/shutdown X-SA-Exim-Version: 4.2.1 (built Sat, 08 Feb 2020 21:53:50 +0000) X-SA-Exim-Scanned: Yes (on in02.mta.xmission.com) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Sat, 09 Dec 2023 20:54:36 -0800 (PST) "Gowans, James" writes: > Hi Sean, > > Blast from the past but I've just been bitten by this patch when > rebasing across v6.4. > > On Fri, 2023-05-12 at 16:31 -0700, 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(). > > The issue is that, AFAICT, the syscore_ops.shutdown are not called when > doing a kexec. Reboot notifiers are called across kexec via: > > kernel_kexec > kernel_restart_prepare > blocking_notifier_call_chain > kvm_reboot > > So after this patch, KVM is not shutdown during kexec; if hardware virt > mode is enabled then the kexec hangs in exactly the same manner as you > describe with the reboot. kernel_restart_prepare calls device_shutdown. Which should call all of the shutdown operations. This has been the way the code has been structured since December 2005. > Some specific shutdown callbacks, for example IOMMU, HPET, IRQ, etc are > called in native_machine_shutdown, but KVM is not one of these. > > Thoughts on possible ways to fix this: > a) go back to reboot notifiers > b) get kexec to call syscore_shutdown() to invoke all of these callbacks > c) Add a KVM-specific callback to native_machine_shutdown(); we only > need this for Intel x86, right? > > My slight preference is towards adding syscore_shutdown() to kexec, but > I'm not sure that's feasible. Adding kexec maintainers for input. Why isn't device_suthdown calling syscore_shutdown? What problem are you running into with your rebase that worked with reboot notifiers that is not working with syscore_shutdown? Eric