From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751943AbdKVQ4b (ORCPT ); Wed, 22 Nov 2017 11:56:31 -0500 Received: from mail-wm0-f49.google.com ([74.125.82.49]:42239 "EHLO mail-wm0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751259AbdKVQ4a (ORCPT ); Wed, 22 Nov 2017 11:56:30 -0500 X-Google-Smtp-Source: AGs4zMbSrL/jfAQQONqsbWope9pwGONLiHuXgqgf/eCRs97BBiPxTLp6ZBWUnwxHEMzBEGxJ0RxXuQ== Subject: Re: [PATCH] KVM: VMX: Fix vmx->nested freeing when no SMI handler To: Liran Alon , Wanpeng Li Cc: "linux-kernel@vger.kernel.org" , kvm , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , Wanpeng Li , Dmitry Vyukov References: <1511337410-8100-1-git-send-email-wanpeng.li@hotmail.com> <5A153926.7030004@ORACLE.COM> <5A153E5B.2060104@ORACLE.COM> <5A1546A7.4080506@ORACLE.COM> From: Paolo Bonzini Message-ID: Date: Wed, 22 Nov 2017 17:56:26 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <5A1546A7.4080506@ORACLE.COM> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 22/11/2017 10:43, Liran Alon wrote: >>> >>> I think we should also set "vmx->nested.smm.vmxon = false;" >>> after "vmx->nested.vmxon = false;" to correctlyhandle the case >>> VMXOFF is executed from SMI handler. Otherwise, when SMI handler >>> executes RSM, we will reach vmx_pre_leave_smm() which will set >>> again "vmx->nested.vmxon = true;" which I think shouldn't >>> happen. >> >> I didn't see a real scenario for this. > > Actually I later saw that handle_vmoff() calls > nested_vmx_check_permission() which indeed won't allow to continue > executing if running from SMI because vmx->nested.vmxon=false; and > therefore this will raise a #UD. So you are right. :) Still, not clearing the flag is wrong. free_nested is also called by vmx_leave_nested when the host writes 0 to MSR_IA32_FEATURE_CONTROL with KVM_SET_MSRS. Paolo