Received: by 10.223.164.202 with SMTP id h10csp4264351wrb; Wed, 29 Nov 2017 03:45:01 -0800 (PST) X-Google-Smtp-Source: AGs4zMZ+my3+Gk9OGGcWtOA8wwmMt4OjPZdXiwOriOb5bKpbdFVi3um9a0I9V2WnzCsdx+OYgMW3 X-Received: by 10.84.131.40 with SMTP id 37mr2642462pld.302.1511955901229; Wed, 29 Nov 2017 03:45:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511955901; cv=none; d=google.com; s=arc-20160816; b=O+2CIt/6SE+Pddy9e8iyh1L2Ww7RKGvcNT6Ui0y25Z6OTxsV5qadVT0WIsYHDYZJ6L VcmjiZNgzG6dSbhLyNr+ZotjcMHacsrf4rx7SlCsWkOgliSZo1RlhAj78B65ffSMAS0J AlOgXoWRN3ykEK0hnWHt0Eavb4pS+qHvwOqUqb6jp1c06b//cnL9YlzxwF/Tua0ExzjR EWOnxtlg33t+gWg7BO7Y3tZZT7eNp7Wujg0Z+jeWNeJRZWyscxhG+fRz4wnWUcx2goWJ R3rTGxpcXKQ79oPVTuQVv5CUcqukPRHp9hY3zfWnzS1AleraaLiCAAkJFW6knXlkSaXb IETg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=TqEacxFqN3QO3VayBfhVtyWQHJTj6Ba5y8MZ49sHGHE=; b=EtP/lAXhwO6eKdFyyRAKGDa2ju02S9TFgZM+lW6n6cKdsYQKUHRne3h5Oux2Ne2Ovi aGIph5ib+UucD8PJ648QRKTMxYUGAwM+M2IotLzNg2am80luAr4IkM7lUGCLBa7CVtVH vzsYkfEci7zd2gxvQoZ0df89LuccxneaM5xydvhlCTPWg2U/cwhhhveo2vCpuSyNoLcg W36k51dEI9uNRw+bWrMfCH+9a809LAwuMw4WzJPHJmI3mU9j06zAVvNbmMDeRV2Hwy0u x2HaR8jDIkx/DrcZnSb6Kw4Q1wLue7ofoslpOl8P+4zTIwiCjy/v7UfQEdPuW9Dkijaz /Biw== 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 f7si1220371pff.45.2017.11.29.03.44.50; Wed, 29 Nov 2017 03:45:01 -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 S1754577AbdK2LoO (ORCPT + 70 others); Wed, 29 Nov 2017 06:44:14 -0500 Received: from mx1.redhat.com ([209.132.183.28]:42456 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751496AbdK2LoN (ORCPT ); Wed, 29 Nov 2017 06:44:13 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 265785D68C; Wed, 29 Nov 2017 11:44:13 +0000 (UTC) Received: from localhost (ovpn-116-15.gru2.redhat.com [10.97.116.15]) by smtp.corp.redhat.com (Postfix) with ESMTP id AFB9E60BE1; Wed, 29 Nov 2017 11:44:12 +0000 (UTC) Date: Wed, 29 Nov 2017 09:44:11 -0200 From: Eduardo Habkost To: Paolo Bonzini Cc: Wanpeng Li , "linux-kernel@vger.kernel.org" , kvm , yfu@redhat.com Subject: Re: [PATCH] KVM: x86: inject exceptions produced by x86_decode_insn Message-ID: <20171129114411.GA16634@localhost.localdomain> 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-Fnord: you can see the fnord User-Agent: Mutt/1.9.1 (2017-09-22) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 29 Nov 2017 11:44:13 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 13, 2017 at 09:32:09AM +0100, Paolo Bonzini wrote: > 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! :( > > Yanan, can you double check that you can reproduce the issue with an > unpatched kernel? I will work on a kvm-unit-tests testcsae We don't have a kvm-unit-tests reproducer for this yet, right? I'm considering trying to write one, but I don't want to duplicate work. -- Eduardo From 1584245708007316787@xxx Thu Nov 16 17:47:22 +0000 2017 X-GM-THRID: 1583672192246103487 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread