Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3339151ybt; Sat, 4 Jul 2020 13:49:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwVJOJCamGswzScf3zAt+D7ubbVnsAUeYnJHjBnIK0V3pRcXEyISeIWALXMJSsuF9qf7Aip X-Received: by 2002:a17:906:ae56:: with SMTP id lf22mr37001937ejb.59.1593895768159; Sat, 04 Jul 2020 13:49:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593895768; cv=none; d=google.com; s=arc-20160816; b=yZl5sa8zfgrV6/i7WetqYThkLF3ukg8FwfbhgCVOg9+cJNkip+8pvYdfXSFu43L0cE lLDxG6FdovQ5uwDD3CxC0Ec9lF0OmLBqkFxCgtDb0t9HtBXI0EoAUxeV62dcXJ10XZ5v K9ZCUek+dBgd/P0oJzyymjPGayFkkhA7mqOGNvGQ0AZdSPObZQ6GwhQDANf3ICwyh7XB 96u2icV9KAe0aV+Go4iPvX+l1FQ988fgyCOPoPufcxY+6mmkRlh1wfUR0Bt5PXyYp1kP msak8L8xDr76nCBK9KlEQ2+hBdTQViPQO454DZjtXt/I6ER5PUCrzZcdPDBH/4NicwsG EHcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=TVC7qYCc7hiGM6HbuYh6jdqGItDBkzldUGSy+MD/zsM=; b=NKuq3qFajIOPXH1ZCY0gLeV3sQit2cFe4WpCHyN4XES/3M92hbVg8FOznPpbFKxWqY C6pp4eqeMfwAQxUrhJvHw/OPt9EiBR99jLRpxSRJsltCu9G78kG9WUXP8cfnbKBkP2Ie QrLsqqKcoKJBd3tjzYvXCkdm5TiMliTGe10rfbYsfs/htbnxhhiVRt7SITEG5uv1qOII 9Ua9uZAkeNoMFH9I6l3j+dLJNSbPOxpLZGeZ1wqT7xSlGYvvWtmt2MNoEdaOXfGoxLEB 1Gcd6ZqKu+P2vqZ6Ip0B0j4jXGfOjtuAc2W755ay/rNCxYwR1YwH91yD1j3M/a0nmXFk 227A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@g001.emailsrvr.com header.s=20190322-9u7zjiwi header.b=UppMAbcj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id mb24si10004203ejb.233.2020.07.04.13.49.05; Sat, 04 Jul 2020 13:49:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@g001.emailsrvr.com header.s=20190322-9u7zjiwi header.b=UppMAbcj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727929AbgGDUqr (ORCPT + 99 others); Sat, 4 Jul 2020 16:46:47 -0400 Received: from smtp90.iad3b.emailsrvr.com ([146.20.161.90]:55281 "EHLO smtp90.iad3b.emailsrvr.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727835AbgGDUqq (ORCPT ); Sat, 4 Jul 2020 16:46:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=g001.emailsrvr.com; s=20190322-9u7zjiwi; t=1593895108; bh=O6glA4IE1cHXwt+X4FOTNeQIZuKguXoehyGtlHjClgw=; h=From:To:Subject:Date:From; b=UppMAbcjv3sCHvOkbSb8mLrTOGjD+LIlfOFUkNyz2F2orOrRKRPf/ajE2yBOf6HcI hkHUWgw24svzYvNXC3ouDTj7nHRHAsZbspE8taBlRZs/Zhlw0E3+l3eiVV34wp9b34 gu8GAA+oz+AQoRZrDBw9ONVJzp859SsBfMqw2m9c= X-Auth-ID: dpreed@deepplum.com Received: by smtp20.relay.iad3b.emailsrvr.com (Authenticated sender: dpreed-AT-deepplum.com) with ESMTPSA id 55609A00F6; Sat, 4 Jul 2020 16:38:27 -0400 (EDT) From: "David P. Reed" To: Sean Christopherson Cc: "David P. Reed" , Andy Lutomirski , Thomas Gleixner , Ingo Molnar , Borislav Petkov , X86 ML , "H. Peter Anvin" , Allison Randal , Enrico Weigelt , Greg Kroah-Hartman , Kate Stewart , "Peter Zijlstra (Intel)" , Randy Dunlap , Martin Molnar , Andy Lutomirski , Alexandre Chartre , Jann Horn , Dave Hansen , LKML Subject: [PATCH v3 3/3] Force all cpus to exit VMX root operation on crash/panic reliably Date: Sat, 4 Jul 2020 16:38:09 -0400 Message-Id: <20200704203809.76391-4-dpreed@deepplum.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200704203809.76391-1-dpreed@deepplum.com> References: <20200629214956.GA12962@linux.intel.com> <20200704203809.76391-1-dpreed@deepplum.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Classification-ID: 64370b40-6b65-46c7-a817-521193c95a46-4-1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Fix the logic during crash/panic reboot on Intel processors that can support VMX operation to ensure that all processors are not in VMX root operation. Prior code made optimistic assumptions about other cpus that would leave other cpus in VMX root operation depending on timing of crash/panic reboot. Builds on cpu_ermergency_vmxoff() and __cpu_emergency_vmxoff() created in a prior patch. Suggested-by: Sean Christopherson Signed-off-by: David P. Reed --- arch/x86/kernel/reboot.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c index 0ec7ced727fe..c8e96ba78efc 100644 --- a/arch/x86/kernel/reboot.c +++ b/arch/x86/kernel/reboot.c @@ -543,24 +543,18 @@ static void emergency_vmx_disable_all(void) * signals when VMX is enabled. * * We can't take any locks and we may be on an inconsistent - * state, so we use NMIs as IPIs to tell the other CPUs to disable - * VMX and halt. + * state, so we use NMIs as IPIs to tell the other CPUs to exit + * VMX root operation and halt. * * For safety, we will avoid running the nmi_shootdown_cpus() * stuff unnecessarily, but we don't have a way to check - * if other CPUs have VMX enabled. So we will call it only if the - * CPU we are running on has VMX enabled. - * - * We will miss cases where VMX is not enabled on all CPUs. This - * shouldn't do much harm because KVM always enable VMX on all - * CPUs anyway. But we can miss it on the small window where KVM - * is still enabling VMX. + * if other CPUs might be in VMX root operation. */ - if (cpu_has_vmx() && cpu_vmx_enabled()) { - /* Disable VMX on this CPU. */ - cpu_vmxoff(); + if (cpu_has_vmx()) { + /* Safely force out of VMX root operation on this CPU. */ + __cpu_emergency_vmxoff(); - /* Halt and disable VMX on the other CPUs */ + /* Halt and exit VMX root operation on the other CPUs */ nmi_shootdown_cpus(vmxoff_nmi); } -- 2.26.2