Received: by 10.223.164.202 with SMTP id h10csp2127683wrb; Thu, 16 Nov 2017 09:47:23 -0800 (PST) X-Google-Smtp-Source: AGs4zMZzQtBKrjSr6gEZEWy7UQBBeR+EFjVT+zejYX/11WkVRx831dBf9Em39Fkb7zbPu1Bpmg4v X-Received: by 10.84.151.69 with SMTP id i63mr2392272pli.61.1510854442891; Thu, 16 Nov 2017 09:47:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510854442; cv=none; d=google.com; s=arc-20160816; b=mdPwfXqHdfy0W1qTv48lLQrv3dYNf2Pn3qrRjchP8rZ0R+smEjOiLcqAOa8/lgCAcU a8jQZ9omkVMgpKzBPTB1QDtmDD3kanXkcx1XY65v9n7+3epcBe/O0l1Xpr1Ar13+OjWp 0zXxMV3qw9two1/cnpFumqJPLQGAuK9j26kKAc9OKz6e0Apobdis6NhA/OnOyzVonZij la1voGzjZWr4L8QY4UgqSIVe9vlSgN+ljzzgM9mR+DDhQBEFXInIXTcxrcDZq49VvOpr fI7qfGMEAG9o6U1fqvn3IzpemIM2Z4BVkWIbpd8PpDxOr3shv83fREPEhswIIb0gHmYl 0www== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :arc-authentication-results; bh=+YAweiV8cnYQco0t/nvc+w8CKeXzPkb1tQyQ5E31nj4=; b=HSezoAMRG2j/DrhiIxs8oACyd/0Y7AefCU++IVViUgGAu1RlxBve1dltDziZrIa2QH ZAblwhuIv5mIvAJn6tyCnIjJudGzaCOqhe15NmCR9OJPDV2Cb/TVvk7ItFjz7Ejqdx1N oWVtA2KlgzBo3o2aQGEhBYUQXuCBaOz6B7fHpC2q0/e5qRmT9rVYJIQa8Xl0SdEAwGBL eULLVRYigjisY/9F7vRbhWX0cqly1gCggguttBZ11ER7i9frJLTraMkcMx/hwpFSbM8j TapKgZeZLhK7/glNDxqoYjvx4ZG+Wv2bcHoIL3Ycj/NUyCYwJYMtS3r6n8Mgxl3sb3Gd GWoA== 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 o6si1230291pgn.138.2017.11.16.09.47.09; Thu, 16 Nov 2017 09:47:22 -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 S965537AbdKPRMZ (ORCPT + 92 others); Thu, 16 Nov 2017 12:12:25 -0500 Received: from mx1.redhat.com ([209.132.183.28]:43206 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965505AbdKPRMR (ORCPT ); Thu, 16 Nov 2017 12:12:17 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id ABB2CC05244A; Thu, 16 Nov 2017 17:12:17 +0000 (UTC) Received: from flask (unknown [10.43.2.80]) by smtp.corp.redhat.com (Postfix) with SMTP id 9F77146E71; Thu, 16 Nov 2017 17:12:14 +0000 (UTC) Received: by flask (sSMTP sendmail emulation); Thu, 16 Nov 2017 18:12:13 +0100 Date: Thu, 16 Nov 2017 18:12:13 +0100 From: Radim =?utf-8?B?S3LEjW3DocWZ?= To: Paolo Bonzini Cc: Wanpeng Li , "linux-kernel@vger.kernel.org" , kvm , yfu@redhat.com, Eduardo Habkost Subject: Re: [PATCH] KVM: x86: inject exceptions produced by x86_decode_insn Message-ID: <20171116171212.GA20438@flask> References: <1510307378-97452-1-git-send-email-pbonzini@redhat.com> <4ff4d2f3-439b-2a8f-ef89-b2a1984e809d@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4ff4d2f3-439b-2a8f-ef89-b2a1984e809d@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 16 Nov 2017 17:12:17 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 2017-11-13 09:32+0100, Paolo Bonzini: > On 13/11/2017 08:15, Wanpeng Li wrote: > > 2017-11-10 17:49 GMT+08:00 Paolo Bonzini : > >> Sometimes, a processor might execute an instruction while another > >> processor is updating the page tables for that instruction's code page, > >> but before the TLB shootdown completes. The interesting case happens > >> if the page is in the TLB. > >> > >> In general, the processor will succeed in executing the instruction and > >> nothing bad happens. However, what if the instruction is an MMIO access? > >> If *that* happens, KVM invokes the emulator, and the emulator gets the > >> updated page tables. If the update side had marked the code page as non > >> present, the page table walk then will fail and so will x86_decode_insn. > >> > >> Unfortunately, even though kvm_fetch_guest_virt is correctly returning > >> X86EMUL_PROPAGATE_FAULT, x86_decode_insn's caller treats the failure as > >> a fatal error if the instruction cannot simply be reexecuted (as is the > >> case for MMIO). And this in fact happened sometimes when rebooting > >> Windows 2012r2 guests. Just checking ctxt->have_exception and injecting > >> the exception if true is enough to fix the case. > > > > I found the only place which can set ctxt->have_exception is in the > > function x86_emulate_insn(), and x86_decode_insn() will not set > > ctxt->have_exception even if kvm_fetch_guest_virt() returns > > X86_EMUL_PROPAGATE_FAULT. > > Hmm, you're right. Looks like Yanan has been (un)lucky when trying out > this patch! :( I have dropped this patch in the meantime. From 1583945142600984085@xxx Mon Nov 13 10:10:01 +0000 2017 X-GM-THRID: 1583672192246103487 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread