Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1038011iob; Fri, 13 May 2022 20:36:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwap8Ev3X9j5Wu80D3WYaVr19hZYLPQHzDFcPHTw2Hqz1hilBsRhdF1Fm5M7qkZ17jtjFlA X-Received: by 2002:a05:600c:3d0c:b0:396:edb5:bba4 with SMTP id bh12-20020a05600c3d0c00b00396edb5bba4mr2964451wmb.176.1652499403989; Fri, 13 May 2022 20:36:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652499403; cv=none; d=google.com; s=arc-20160816; b=jTtqyKRxALt8ehEeHbrkWEf+gQEO4hepvdLYtSkuXyNbaETdSmAAI77lEjP5LjrtMM EzbIHczwodC35YiElnUTxrYlFHJqmBYnGJCxxPCiyPPV/ySl8wP0mjbtmydi9WvqnhHy /J3Qyfjw/FKYYNQvlPdlniqD+/Go+udIPSeXp3vcEnhiSEWTX7XyTtGaZUHYFpaK5Onw 7ivmiJCNyjN8fdKiAlOqmJjm1HK9AYXED//USdVNNWJesT/3cFMcS7YGJNr834XDyMeX 7QEF+wPaqqEMeBD6WI745S1wIPYDlw7GHypPs9SGmzr+egonEMjse8fs7wvd5KsJdSL/ fcdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=E1mAoedHqKCxbwiJhcTWVMyW7rs80mjXjW2wzN8EpSY=; b=ZuzbKvJgLqkzs2nuXH5XTGzWy/7WNjFhbEdEh4ySD/RUFFrPxDNJdpcwIWcAy325Rq oUAYS0rNZCjMqCwOochJDUdpCD23ZHT9CvWUPEyPBeDwZ+odMLb+68QxsKP8hRkUVY9k ZYl6xGEqfC34f0z0v7g8JPMwe7ubQA38AA5kVSFbdrkz5CHWZtd9nC7GFimexlojEqX2 PS7/c4Tw56WEBgJg4k4tc1JwniavMwcBdS/Vuf2MAQVDkjCEg0CLyDh1s58ka0L/H3+u HwQcqiRHAupv2TB2rff0eag9f8YcHjFFelnaB3RMWtWp3xMvJb+sfmt9s1ZJGrQoc0t+ 1yzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=hzs3wRnT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id d5-20020a056000186500b0020cc13864edsi4864261wri.1051.2022.05.13.20.36.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 20:36:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=hzs3wRnT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C146943F7F9; Fri, 13 May 2022 17:12:30 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355463AbiELOjQ (ORCPT + 99 others); Thu, 12 May 2022 10:39:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355453AbiELOjL (ORCPT ); Thu, 12 May 2022 10:39:11 -0400 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19B1A2618C8 for ; Thu, 12 May 2022 07:39:11 -0700 (PDT) Received: by mail-pl1-x62c.google.com with SMTP id x18so5063236plg.6 for ; Thu, 12 May 2022 07:39:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=E1mAoedHqKCxbwiJhcTWVMyW7rs80mjXjW2wzN8EpSY=; b=hzs3wRnTcQy01CmqLlxG9g6xOizB2yWFw8y++j1vmsFHdynWNX5ubGCdvmz+gwaqE3 dDz2aAUKb+oPO72jrcbsIIbxLB23+WildV3hJXC5DXrW1amv/REI49ycKi40b211THXa Mg79bqL6EzTg9xF0LU9V79cMXITgxHfrC0RqESuYKYYh2G9eCC5ggM4y0k5bfz+zmjo4 wJAyqoa8yQKhG0s6M991iNRgPLs+CNykf31CIWFmy4FMUnliEuNw6TQmnqDYl8qLN+3E Fn8y9MytcYVwuFKQoceMFjysHF2aKrrCBmDOkja7SFGW9+1ISKPwGdtA2w0jSZz6mMcQ BJZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=E1mAoedHqKCxbwiJhcTWVMyW7rs80mjXjW2wzN8EpSY=; b=JJtGe426bvPRtX701GCScWjvTbD4u7DjChnjKItxe04hYt6EWMDChkhob9MufRe/z2 hlihwQVL1mHYBc8f9ScGViQXWIYrOJ2UEXUPvO6eGXYyjOUCrLJVM3uhw0Mw0I6g5vse jpOY6QX3U/31+MK8bL8MipfSsbnLc7NyeR0tKvwTcSaFcM4YFPrJjTblvRDwIWxKI6Co TBkJD+a+mgg4RIt7usidD51iwMGHoSX5cLZlaW8QCz5KzUBprJL1v4lzJa3V3ok0YBGV Tf8q/ZQ/wPPxA69OuQmLE4dlQeTY493Ms0QHS9QaA9DaOa1gJHRSW7hIllahhRnZUTZu zkzA== X-Gm-Message-State: AOAM531eL7DxnLvpBRL4qtZTeIEIEUcEYnVeBcfFHymnqUtpbDf2rZDn 43veEtUuSt317FhkiijrQ0Pjzw== X-Received: by 2002:a17:902:d482:b0:15e:a06a:db0a with SMTP id c2-20020a170902d48200b0015ea06adb0amr291573plg.38.1652366350327; Thu, 12 May 2022 07:39:10 -0700 (PDT) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id 204-20020a6302d5000000b003c619f3d086sm2070886pgc.2.2022.05.12.07.39.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 May 2022 07:39:09 -0700 (PDT) Date: Thu, 12 May 2022 14:39:06 +0000 From: Sean Christopherson To: Thomas Gleixner Cc: Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , linux-kernel@vger.kernel.org, "Guilherme G . Piccoli" , Vitaly Kuznetsov , Paolo Bonzini Subject: Re: [PATCH 2/2] x86/reboot: Disable virtualization in an emergency if SVM is supported Message-ID: References: <20220511234332.3654455-1-seanjc@google.com> <20220511234332.3654455-3-seanjc@google.com> <87tu9vvx19.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87tu9vvx19.ffs@tglx> X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=no 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 Thu, May 12, 2022, Thomas Gleixner wrote: > On Wed, May 11 2022 at 23:43, Sean Christopherson wrote: > > Disable SVM on all CPUs via NMI shootdown during an emergency reboot. > > Like VMX, SVM can block INIT and thus prevent bringing up other CPUs via > > INIT-SIPI-SIPI. > > With the delta patch applied, I'd make that: > > --- a/arch/x86/kernel/reboot.c > +++ b/arch/x86/kernel/reboot.c > @@ -530,29 +530,25 @@ static inline void kb_wait(void) > > static inline void nmi_shootdown_cpus_on_restart(void); > > -/* Use NMIs as IPIs to tell all CPUs to disable virtualization */ > -static void emergency_vmx_disable_all(void) > +static void emergency_reboot_disable_virtualization(void) > { > /* Just make sure we won't change CPUs while doing this */ > local_irq_disable(); > > /* > - * Disable VMX on all CPUs before rebooting, otherwise we risk hanging > - * the machine, because the CPU blocks INIT when it's in VMX root. > + * Disable virtualization on all CPUs before rebooting to avoid hanging > + * the system, as VMX and SVM block INIT when running in the host > * > * We can't take any locks and we may be on an inconsistent state, so > - * use NMIs as IPIs to tell the other CPUs to exit VMX root and halt. > + * use NMIs as IPIs to tell the other CPUs to disable VMX/SVM and halt. > * > - * Do the NMI shootdown even if VMX if off on _this_ CPU, as that > - * doesn't prevent a different CPU from being in VMX root operation. > + * Do the NMI shootdown even if virtualization is off on _this_ CPU, as > + * other CPUs may have virtualization enabled. > */ > - if (cpu_has_vmx()) { > - /* Safely force _this_ CPU out of VMX root operation. */ > - __cpu_emergency_vmxoff(); > + cpu_crash_disable_virtualization(); > > - /* Halt and exit VMX root operation on the other CPUs. */ > + if (cpu_has_vmx() || cpu_has_svm(NULL)) > nmi_shootdown_cpus_on_restart(); > - } What about leaving cpu_crash_disable_virtualization() inside the if-statement? It feels wierd to "disable" virtualization on the current CPU but ignore others, e.g. if there's some newfangled type of virtualization in the future, I would be quite surprised if only the CPU doing the transfer needed to disable virtualization. if (cpu_has_vmx() || cpu_has_svm(NULL)) { /* Safely force _this_ CPU out of VMX/SVM operation. */ cpu_crash_disable_virtualization(); /* Disable VMX/SVM and halt on other CPUs. */ nmi_shootdown_cpus_on_restart() } > } > > > @@ -587,7 +583,7 @@ static void native_machine_emergency_res > unsigned short mode; > > if (reboot_emergency) > - emergency_vmx_disable_all(); > + emergency_reboot_disable_virtualization(); > > tboot_shutdown(TB_SHUTDOWN_REBOOT); >