Received: by 10.223.176.5 with SMTP id f5csp1730881wra; Thu, 8 Feb 2018 02:30:59 -0800 (PST) X-Google-Smtp-Source: AH8x226UT57F7tmvKaeG95f8ignxV1UKiNsF2aO8iBDAOjrKbDX71QuvovCGnSm2JqSWxE9+ixza X-Received: by 10.98.206.65 with SMTP id y62mr183363pfg.79.1518085859155; Thu, 08 Feb 2018 02:30:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518085859; cv=none; d=google.com; s=arc-20160816; b=nz9ip96LgyKlxAcfCl/ejmE4/i5exYEABZyL7jrt5SGqPqMv/bW3Id0S+NJeQrnkDc MSYRCm1BxgFecPHgvg1XQ7B5MTWlq+xlVutYFUWLEGojDQ+1ex8Ytxc+GAb0S6aiwM9c LvPO18JasarPELDK39adX87nR6JuYqTbVKgC/JcPvELgNGyilE8BeAUJYTlEwR1XR9Fq RkEuodevDi5DFlHjmc50TEJt4dupSSoBnLSfzBnhtuM0CdpUsClA3KIBGITgdcBRLlmn mEDfR0yy1xQJXSLgGN97yqwSlUWH8XZghnQS8Jw4nmruaVQy2R1RbiuYsIIgBbRiYBp4 J1Rw== 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=ubeDqLsEude7Jw4o9ZvkaRlAHUQa0QXNq8w34IjG3z8=; b=iuqYVgeFGurXvPLXDULMreWUmeESaM/RWbpNTjziEMj2QTeIlTao8NlY1mqYjGMSlf FjY3wa5KUpkAWFiExfgcTIK2njvMlzHo6w6Rja6Fv2vrQHE0BVcAjswLqXl0ilfQteO4 jt9DS0sMZRokrLlh/uUx5fCEAyvAAIc8OebgOqeP507zvVd9TCG+ZMzZh8s4f+OFyd3t JqrE8TladHxqsp9xYDlZjZ8+QMUJueszkwLKJx6Vm9DXJ25UuSTxzBRZNztj98U6o208 5VqH9xJo+ezqQA/ExJbhREmNUIpQMubdx653eFRBX7uW4Gtg/aJSeRkPau3urxBpNGqQ z/vA== 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 b24si2585371pfd.321.2018.02.08.02.30.44; Thu, 08 Feb 2018 02:30:59 -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 S1751796AbeBHKaE (ORCPT + 99 others); Thu, 8 Feb 2018 05:30:04 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:57272 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751014AbeBHKaD (ORCPT ); Thu, 8 Feb 2018 05:30:03 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D60C84040073; Thu, 8 Feb 2018 10:30:02 +0000 (UTC) Received: from [10.36.116.177] (ovpn-116-177.ams2.redhat.com [10.36.116.177]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5C9982166BAE; Thu, 8 Feb 2018 10:29:59 +0000 (UTC) Subject: Re: [PATCH] x86/kvm/vmx: Don't halt vcpu when L1 is injecting events to L2 To: Chao Gao , kvm@vger.kernel.org Cc: linux-kernel@vger.kernel.org, x86@kernel.org, "H. Peter Anvin" , Ingo Molnar , Thomas Gleixner , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , Liran Alon References: <1518066816-7197-1-git-send-email-chao.gao@intel.com> From: Paolo Bonzini Message-ID: <7de4e758-08cc-2c45-b0aa-dfe28dfef398@redhat.com> Date: Thu, 8 Feb 2018 11:29: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: <1518066816-7197-1-git-send-email-chao.gao@intel.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Thu, 08 Feb 2018 10:30:02 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Thu, 08 Feb 2018 10:30:02 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.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 08/02/2018 06:13, Chao Gao wrote: > Although L2 is in halt state, it will be in the active state after > VM entry if the VM entry is vectoring. Halting the vcpu here means > the event won't be injected to L2 and this decision isn't reported > to L1. Thus L0 drops an event that should be injected to L2. > > Because virtual interrupt delivery may wake L2 vcpu, if VID is enabled, > do the same thing -- don't halt L2. This second part seems wrong to me, or at least overly general. Perhaps you mean if RVI>0? Thanks, Paolo > Signed-off-by: Chao Gao > --- > arch/x86/kvm/vmx.c | 10 ++++++++-- > 1 file changed, 8 insertions(+), 2 deletions(-) > > diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c > index bb5b488..e1fe4e4 100644 > --- a/arch/x86/kvm/vmx.c > +++ b/arch/x86/kvm/vmx.c > @@ -10985,8 +10985,14 @@ static int nested_vmx_run(struct kvm_vcpu *vcpu, bool launch) > if (ret) > return ret; > > - if (vmcs12->guest_activity_state == GUEST_ACTIVITY_HLT) > - return kvm_vcpu_halt(vcpu); > + if (vmcs12->guest_activity_state == GUEST_ACTIVITY_HLT) { > + u32 intr_info = vmcs_read32(VM_ENTRY_INTR_INFO_FIELD); > + u32 exec_control = vmcs_read32(SECONDARY_VM_EXEC_CONTROL); > + > + if (!(intr_info & VECTORING_INFO_VALID_MASK) && > + !(exec_control & SECONDARY_EXEC_VIRTUAL_INTR_DELIVERY)) > + return kvm_vcpu_halt(vcpu); > + } > vmx->nested.nested_run_pending = 1; > >