Received: by 10.223.176.5 with SMTP id f5csp707071wra; Wed, 7 Feb 2018 06:17:48 -0800 (PST) X-Google-Smtp-Source: AH8x2256BwFNr/h/tbr0Xc08ElSRfj22ZPtk9dVknkj4u+BlQ9LuSQp7fyx6mw2tf0Uzb1Guc5ru X-Received: by 2002:a17:902:2983:: with SMTP id h3-v6mr6008840plb.76.1518013068598; Wed, 07 Feb 2018 06:17:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518013068; cv=none; d=google.com; s=arc-20160816; b=02hzSe/VkD+XJdJdIDzwrwZcoNPNWqIPeHUJleDIq0MAAUGD3+PLsGi8ZIDoK/DYrO rsukJpjm1pdbg/MXDWm8E0y49zHGUlMBQLT6h2LlCHOmqPTDJjUEmnGhBGf/mGZSoabQ zv7k8Sb4wSFsOe2DxPyQwdaXBpOrreQ88Ss2GciI749Ng7lFsZtax5QhzBu+Pr3jzLB6 LleKZTpZy2C4nB6eF6Ml6whdAPVf3QowKCy0jnJzcI9vUWQIr4g2V3mR+0y5BDdmeROu NfTj/0QyWBtXouR8o6VR5mlIa1fb7YRWW03Rynx+FzNFcH5N2abKP05FSHmnVrdc40Hq 2uLQ== 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:arc-authentication-results; bh=wKRKiZ0RAE3JlnIpKCaNl/L85/ZjYdmvORaBWF0M2rc=; b=pHwWtA54/m/jbUwLeht2jAchsRONsqWtWTyZ3n1TflO4icc5uydUZLwNi5dXdKIL2u dO2KxPDGivC/FXlkGWuotBxaCQiantvaJAHixyLvz9951DrZX9nz38Vel/3oNvpctAYK BqiRarRfz+wx2bkKHhdfJrSrLHJ5enUfZ8fMA4Bbxhllr4Jsxq5oMW6hvvBXeWGcOYVH Rl5pVh9LUnSHe2U8W3fDihjPayT+8zwc5LvEX6ppmL256MPyazXsEHvK1wgJvFe9XZ1b dQZ3C/Vp2dIleSc3kmSlOD7Y5MQZ6Q6cBc7BAIblsrAWkDBRRWwqPkh4b4l2Bx6xbLhk FpJw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d75si1176604pfb.360.2018.02.07.06.17.34; Wed, 07 Feb 2018 06:17:48 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754215AbeBGOQy (ORCPT + 99 others); Wed, 7 Feb 2018 09:16:54 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:60278 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753796AbeBGOQw (ORCPT ); Wed, 7 Feb 2018 09:16:52 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 78A9740363AD; Wed, 7 Feb 2018 14:16:52 +0000 (UTC) Received: from [10.36.117.194] (ovpn-117-194.ams2.redhat.com [10.36.117.194]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8295D1251C65; Wed, 7 Feb 2018 14:16:51 +0000 (UTC) Subject: Re: [PATCH] KVM: X86: Fix SMRAM accessing even if VM is shutdown To: Wanpeng Li , linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , Dmitry Vyukov References: <1517984706-47244-1-git-send-email-wanpengli@tencent.com> From: Paolo Bonzini Message-ID: <233cfca3-971e-c3c2-f0fe-b50dd69d2546@redhat.com> Date: Wed, 7 Feb 2018 15:16:49 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: <1517984706-47244-1-git-send-email-wanpengli@tencent.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Wed, 07 Feb 2018 14:16:52 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Wed, 07 Feb 2018 14:16:52 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'pbonzini@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 07/02/2018 07:25, Wanpeng Li wrote: > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index 786cd00..445e702 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -7458,6 +7458,11 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) > goto out; > } > > + if (unlikely(vcpu->run->exit_reason == KVM_EXIT_SHUTDOWN)) { > + r = -EINVAL; > + goto out; > + } > + > if (vcpu->run->kvm_dirty_regs) { > r = sync_regs(vcpu); > if (r != 0) > This most likely breaks triple faults in the usual case where they should result in resetting the system; the KVM API doesn't say that you should clear vcpu->run->exit_reason before entering. What exactly causes the EPT misconfig to reach the WARN? That is, how does kvm_mmu_page_fault end up returning a negative errno value? If I read the code correctly only tdp_page_fault can do so, so my guess would be kvm_handle_bad_page: if (pfn == KVM_PFN_ERR_RO_FAULT) return RET_PF_EMULATE; if (pfn == KVM_PFN_ERR_HWPOISON) { kvm_send_hwpoison_signal(kvm_vcpu_gfn_to_hva(vcpu, gfn), current); return RET_PF_RETRY; } /* KVM_PFN_ERR_FAULT */ return -EFAULT; Maybe it should return RET_PF_EMULATE, which would cause an emulation failure and then an exit with KVM_EXIT_INTERNAL_ERROR. Thanks, Paolo