Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp773010ybg; Wed, 10 Jun 2020 13:20:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzuFRCljzp2Hnz0KbZEKNTtc/9G8rzXw0uFsE0HGsUpIzhVbvCIpiXtxlLJbeu0iHsKr/vf X-Received: by 2002:aa7:d5c7:: with SMTP id d7mr4074225eds.11.1591820434265; Wed, 10 Jun 2020 13:20:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591820434; cv=none; d=google.com; s=arc-20160816; b=LBJKLrb7agvMBvmnLFpK9ne8mHSvQabG7MXb7s7d4XegJVSe1sLWDBexJKZu551voi eXbpJex7G0XIYNPA5Q/0u6H5VnUV3WnxRqYuKtMHmNLFj02Xs03ZDQPm2r00Db5ouaWo eVSQKPdqY+NhWW/Nmiz2xZbWEt11om8m3SsArtmRGHwKxp0ou+O2fl4JCoppwxIcCOWM X46kFHBse6Vb7VXxMboR9GrOCFO6uXIzLrXjpOs4ouxWiNkEWTAWnSNwZK9934cL3Tpc UQeGwvyoiljqRPqDxpyN6RWDCNsNKY2H+OMkL7qNdxOF1BIYdnkn8S0e2c8/rbzpAN6Q 2zZw== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=8ghC+vmTGIqK1CHqeWZt7cWGPC/FCSZFgrrDuvIqh2k=; b=jAI49uYUHYpgupc/37mo/Xq8MOqCQS5rj2SASOD/T6G5Qh2r3NbEzf5+BeHpxnpu/T MVewiH1mUMwDKLuvxrv0/XIWH/YYsmUQMLdGtJdOhW1fLdU7+rWkKMMvnzgzBc4xISrZ /W856wHd+vIAN3Ee9p1ryRJ+u5L58UfWRxyvKEtusoldytZlqyvVUQoYr5aXaRyn0bNo sqV2q/0GIaqsCWFTS6NQN+fCzdXyoew/X9toXThpLCfot/vPJ5MSGBWgRRo/FrTSgFRr zzFdeSkFmnr2DZeG2U3TwX8rXwCFFhY998GL80XqWgBLZhyyh3WAVDeDoKz+YyD8W17P b6Mw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=j4F6gt+H; 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 z18si647588ejb.75.2020.06.10.13.20.11; Wed, 10 Jun 2020 13:20:34 -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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=j4F6gt+H; 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 S1730246AbgFJTgR (ORCPT + 99 others); Wed, 10 Jun 2020 15:36:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727011AbgFJTgQ (ORCPT ); Wed, 10 Jun 2020 15:36:16 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E92C1C03E96B for ; Wed, 10 Jun 2020 12:36:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: Content-Type:In-Reply-To:MIME-Version:Date:Message-ID:From:References:Cc:To: Subject:Sender:Reply-To:Content-ID:Content-Description; bh=8ghC+vmTGIqK1CHqeWZt7cWGPC/FCSZFgrrDuvIqh2k=; b=j4F6gt+HuszBoawySExHD+f1aj o5YiNMgIcHL3B5tQ00XOFZaToObxmyGxfq9xk2xeUBcML9M1cyy1+OaYmDVJkIRGUTJwgx9oe9q+J 83n89sPPTbRTtNk952N04YcjuhLSyr/WfPbhCEdulXyUyYjJxwA9oBKKvL8Ld/Fsm/XEjrpMtGp6q +sqi+UOTmz4e5knIOrVMeFVXNdHZJfUq9U0DUP6WuVYrrT7hVMrES+jm2jMC9nnNF51rCtgVzQ8Wu 95SxKv6Z1q+hxsfry005YhQYK5U+2UdoJIb/H1ocTylpu6cVPEJUJhtFqIKGx910DaZKlGe7tWMdn UJRRGIRQ==; Received: from [2601:1c0:6280:3f0::19c2] by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jj6WG-0007BW-4F; Wed, 10 Jun 2020 19:36:16 +0000 Subject: Re: [PATCH] Fix undefined operation VMXOFF during reboot and crash To: "David P. Reed" Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" , Allison Randal , Enrico Weigelt , Greg Kroah-Hartman , Kate Stewart , "Peter Zijlstra (Intel)" , Martin Molnar , Andy Lutomirski , Alexandre Chartre , Jann Horn , Dave Hansen , linux-kernel@vger.kernel.org References: <20200610181254.2142-1-dpreed@deepplum.com> From: Randy Dunlap Message-ID: Date: Wed, 10 Jun 2020 12:36:13 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: <20200610181254.2142-1-dpreed@deepplum.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi David, If you happen to make a v2 of this patch, there are a few comments that begin with "/**" but they are not kernel-doc comments, so they should instead begin with just "/*". Please see below. (and you did not introduce this comment style here.) On 6/10/20 11:12 AM, David P. Reed wrote: > > Signed-off-by: David P. Reed > --- > arch/x86/include/asm/virtext.h | 24 ++++++++++++---- > arch/x86/kernel/reboot.c | 13 ++------- > arch/x86/kernel/traps.c | 52 ++++++++++++++++++++++++++++++++-- > 3 files changed, 71 insertions(+), 18 deletions(-) > > diff --git a/arch/x86/include/asm/virtext.h b/arch/x86/include/asm/virtext.h > index 9aad0e0876fb..ea2d67191684 100644 > --- a/arch/x86/include/asm/virtext.h > +++ b/arch/x86/include/asm/virtext.h > @@ -13,12 +13,16 @@ > #ifndef _ASM_X86_VIRTEX_H > #define _ASM_X86_VIRTEX_H > > +#include > + > #include > > #include > #include > #include > > +DECLARE_PER_CPU_READ_MOSTLY(int, doing_emergency_vmxoff); > + > /* > * VMX functions: > */ > @@ -33,8 +37,8 @@ static inline int cpu_has_vmx(void) > /** Disable VMX on the current CPU just /* Disable VMX on the current CPU > * > * vmxoff causes a undefined-opcode exception if vmxon was not run > - * on the CPU previously. Only call this function if you know VMX > - * is enabled. > + * on the CPU previously. Only call this function directly if you know VMX > + * is enabled *and* CPU is in VMX root operation. > */ > static inline void cpu_vmxoff(void) > { > @@ -47,17 +51,25 @@ static inline int cpu_vmx_enabled(void) > return __read_cr4() & X86_CR4_VMXE; > } > > -/** Disable VMX if it is enabled on the current CPU > +/** Force disable VMX if it is enabled on the current CPU. just /* Force disable VMX if it is enabled on the current CPU. > + * Note that if CPU is not in VMX root operation this > + * VMXOFF will fault an undefined operation fault. > + * So the 'doing_emergency_vmxoff' percpu flag is set, > + * the trap handler for just restarts execution after > + * the VMXOFF instruction. > * > - * You shouldn't call this if cpu_has_vmx() returns 0. > + * You shouldn't call this directly if cpu_has_vmx() returns 0. > */ > static inline void __cpu_emergency_vmxoff(void) > { > - if (cpu_vmx_enabled()) > + if (cpu_vmx_enabled()) { > + this_cpu_write(doing_emergency_vmxoff, 1); > cpu_vmxoff(); > + this_cpu_write(doing_emergency_vmxoff, 0); > + } > } > > -/** Disable VMX if it is supported and enabled on the current CPU > +/** Force disable VMX if it is supported and enabled on the current CPU ditto. > */ > static inline void cpu_emergency_vmxoff(void) > { thanks. -- ~Randy