From: ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org (Eric W. Biederman) Subject: Re: [PATCH v9 1/2] x86/kexec: VMCLEAR VMCSs loaded on all cpus if necessary Date: Tue, 04 Dec 2012 12:14:15 -0800 Message-ID: <87zk1t4lt4.fsf@xmission.com> References: <50B43299.9030409@cn.fujitsu.com> <50B432CA.70804@cn.fujitsu.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: Marcelo Tosatti , Gleb Natapov , "kvm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org" , "x86-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org" , "kexec-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org" , "linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org" To: Zhang Yanfei Return-path: In-Reply-To: <50B432CA.70804-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org> (Zhang Yanfei's message of "Tue, 27 Nov 2012 11:26:02 +0800") List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: kexec-bounces-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org Errors-To: kexec-bounces+glkk-kexec=m.gmane.org-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org List-Id: kvm.vger.kernel.org Zhang Yanfei writes: > This patch provides a way to VMCLEAR VMCSs related to guests > on all cpus before executing the VMXOFF when doing kdump. This > is used to ensure the VMCSs in the vmcore updated and > non-corrupted. Apologies for the delay I have been travelling, and I wanted to at least read through the code. Overall I think this is good but I have one nit, and I see one real problem with this code. > +/* > + * This is used to VMCLEAR all VMCSs loaded on the > + * processor. And when loading kvm_intel module, the > + * callback function pointer will be assigned. > + */ > +void (*crash_vmclear_loaded_vmcss)(void) = NULL; > +EXPORT_SYMBOL_GPL(crash_vmclear_loaded_vmcss); > + > +static inline void cpu_emergency_vmclear_loaded_vmcss(void) > +{ > + if (crash_vmclear_loaded_vmcss) > + crash_vmclear_loaded_vmcss(); > +} The nit is the use of emergency instead of crash in the name. The problem is that this is potentially a NULL pointer dereference if kvm-intel is removed. The easist fix would be in your second patch to just make it impossible to unload the kvm-intel module. Otherwise there the deference of crash_vmclear_loaded_vmcss needs to be rcu protected, with a syncrhonize_rcu after the pointer is set to NULL in the unload path. Otherwise I have no objections to this code. Eric