From nobody Mon Apr 13 17:13:22 2026 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 0A2AEC4332F for ; Mon, 14 Nov 2022 23:35:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237302AbiKNXfB (ORCPT ); Mon, 14 Nov 2022 18:35:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236646AbiKNXeu (ORCPT ); Mon, 14 Nov 2022 18:34:50 -0500 Received: from mail-pl1-x64a.google.com (mail-pl1-x64a.google.com [IPv6:2607:f8b0:4864:20::64a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 168719FD8 for ; Mon, 14 Nov 2022 15:34:49 -0800 (PST) Received: by mail-pl1-x64a.google.com with SMTP id q6-20020a170902dac600b001873ef77938so10010167plx.18 for ; Mon, 14 Nov 2022 15:34:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=CuKvIMG0gJXVjX3tbXmKavICyGNlOF16asBACO4qrT8=; b=aX7xVD9dcMcvK8lTJzwcwroZfbH8mtqoObt1cLCfIfNBrnQLxxBOraVlNmlV1JCA8v T3RIatPfsiUm6v2ocVOy7mhJafHTgtZ/VxsTTQp4gkDjXNVCByn+Gft5BNWQjK8VvPoa OV1L+vFy/ScifZSCgMAqJ3BHKVSXSWzbhwvw/n+gx8DJryuZ7UOckJDB4I8E43ujvfn2 HYWG8yhQlTGAQawT97Wi62I9/RKDpDdFA/hILuQIw19xUYAKRZazPOG1geJPc9C6vbR7 GpW4Us68LKM+T8+3KHHykvt/rS1LtQ1C9k/XLH7wC6gTVyGcq7RVthPp7zc7a4+0mzOS u8HQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=CuKvIMG0gJXVjX3tbXmKavICyGNlOF16asBACO4qrT8=; b=HwYPt2Geu3jzjPxsNrQBVxlwvFsSKFIt6IcdflvrfqbPlSRP15AsviCrWrHNbpuX9j 0Fx+8ih/jxKjyRbP/+ZKcdzuh4IHcciPVsOZ2ucZbqHWS5VCBw3AbJzam+bP1UnNdL4H hsWs59aks2+eejaJV6yW00PcEDe7XshZ4kLJ3Hyc2EIGTXJKXhyWa/cbZHUIRmS5Mf+C MEDiWYjxn1+EbN/cpNcH/K770NeZ4an9gybbV+xqhj4eyCiIUU3wtV9PXyeuL27p326e KWEujnxE2HVj6fGkFy6pAYUWMSH46XWhAqe8ifmjj0VuSgBKq0OWek1ITnwXSd0Ez5mF vCew== X-Gm-Message-State: ANoB5pldMwLSqE3R0IISVO4mKr2avxyDSJAIo7sRMcZYs7mfmaMzPVcW ma5OZoU9AdJW5go9pd8cuRyNiCNozsw= X-Google-Smtp-Source: AA0mqf4x09lIuwZh4im23IautEl9b4C/xw4JSHaYddbQuuWR0iYnjW3xSI82tH+OAp0etW4Q+a/2ZGOE4IM= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a62:1dd8:0:b0:572:24c7:34da with SMTP id d207-20020a621dd8000000b0057224c734damr6261309pfd.73.1668468889489; Mon, 14 Nov 2022 15:34:49 -0800 (PST) Reply-To: Sean Christopherson Date: Mon, 14 Nov 2022 23:34:41 +0000 In-Reply-To: <20221114233441.3895891-1-seanjc@google.com> Mime-Version: 1.0 References: <20221114233441.3895891-1-seanjc@google.com> X-Mailer: git-send-email 2.38.1.431.g37b22c650d-goog Message-ID: <20221114233441.3895891-4-seanjc@google.com> Subject: [PATCH v3 3/3] x86/virt: Fold __cpu_emergency_vmxoff() into its sole caller From: Sean Christopherson To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org Cc: "H. Peter Anvin" , linux-kernel@vger.kernel.org, "Guilherme G . Piccoli" , Vitaly Kuznetsov , Paolo Bonzini , Tom Lendacky , Sean Christopherson Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Fold __cpu_emergency_vmxoff() into cpu_emergency_vmxoff(), its sole remaining caller, to discourage crash/emergency code from handling VMX but not SVM. The behavior of VMX and SVM is so similar that it's highly unlikely that there will be a scenario where VMX needs to be disabled, but SVM can be left enabled. In other words, during a crash and/or emergency reboot, funnel all virtualization teardown sequences through cpu_crash_disable_virtualization(). No functional change intended. Signed-off-by: Sean Christopherson --- arch/x86/include/asm/virtext.h | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/arch/x86/include/asm/virtext.h b/arch/x86/include/asm/virtext.h index 8757078d4442..a9414ef5269e 100644 --- a/arch/x86/include/asm/virtext.h +++ b/arch/x86/include/asm/virtext.h @@ -60,22 +60,12 @@ static inline int cpu_vmx_enabled(void) return __read_cr4() & X86_CR4_VMXE; } =20 -/** Disable VMX if it is enabled on the current CPU - * - * You shouldn't call this if cpu_has_vmx() returns 0. - */ -static inline void __cpu_emergency_vmxoff(void) -{ - if (cpu_vmx_enabled()) - cpu_vmxoff(); -} - /** Disable VMX if it is supported and enabled on the current CPU */ static inline void cpu_emergency_vmxoff(void) { - if (cpu_has_vmx()) - __cpu_emergency_vmxoff(); + if (cpu_has_vmx() && cpu_vmx_enabled()) + cpu_vmxoff(); } =20 =20 --=20 2.38.1.431.g37b22c650d-goog