Received: by 2002:a25:5b86:0:0:0:0:0 with SMTP id p128csp1632423ybb; Fri, 29 Mar 2019 08:15:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqyclT6FptQR+J5Zpesc8CdSVVvZ+eqdrLGiYiZca0onN1Q7LEzJOP5ZXfR6BtLEftGpleWz X-Received: by 2002:a62:f24e:: with SMTP id y14mr47818039pfl.209.1553872543091; Fri, 29 Mar 2019 08:15:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553872543; cv=none; d=google.com; s=arc-20160816; b=Uug0wlLwge2u7xJe+Kkr+t3bZFFlVQm8P1MH+XGaVZ2qO6I1IwNvzQ48o++QxN7QmX DEmdngl1lEPmeXCCly/ID8bdsygzF1ZBvPUigPawt5XK1uh01FwS4CIyL09Gwt+OvRH1 ue6u/dKzJDtfRpsgKJtLBRHoNm/I7Y/bpBm07EDGL7WLbzpcgsAf9f9u3DRE0A4sQJHa hiyeyVzceWVcXIPF+32Je5PUfO4Y2/OHp5Djy8gRkB8Gak9GRzKIXKAKjhEs3wfAOUdn ctDmtcgpfx8WbLPwE+390HaGXWWnMmExRQgK9rhc9syU53Pq0MbZGmuosfK66dlF1zng M1ng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from; bh=ad3FU1K6R0fG6gBLiNPRbbseS3w6abTKqPSmwInCleY=; b=sbfcbgKKTI1d5pPprbzHmrg8pcY2wu8qLyBqytEcvAED3Y6mQx54ePZhrdlwWP3n3z kebHmGhq/7KNyluGI7wQ9kq/VZKfybCRxSQRou/OSteDkb78kiLjLuP3GjxrtH28U9XF TX0CNL/RuKYmHUgT/colDbIoXu15LyVrj7E/pEqsO64FAzEQeebE6mM6w17ez9OiM1hF p5/cWGLx2c1oBxHbIBmE9ZtyW4+j/reOJnWuxANybgBuvhnVEvISkR4kfTYOeMOLrnIg Cw+eBW8kgFDMqRjhARc5tMQcazT+VkusiOmFWD5AnkO2tw+9qh70hWNcmKk1iy5tNgl6 AcCg== 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 a11si2035728pgw.243.2019.03.29.08.15.26; Fri, 29 Mar 2019 08:15:43 -0700 (PDT) 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 S1728961AbfC2POi (ORCPT + 99 others); Fri, 29 Mar 2019 11:14:38 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:43145 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728839AbfC2POh (ORCPT ); Fri, 29 Mar 2019 11:14:37 -0400 Received: by mail-wr1-f68.google.com with SMTP id k17so3014702wrx.10 for ; Fri, 29 Mar 2019 08:14:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=ad3FU1K6R0fG6gBLiNPRbbseS3w6abTKqPSmwInCleY=; b=PYT8p5KZGhFwEzDf1P5V6uzzNd+4MKaDVXl02Mo7SzbWZptnQnfszhLMUIc/haMEov GJYI8xjLipN/prQZsJ5L3/HvkGR/fRAzVUyWXa7mooyRSAr4KnAqK75iK1en3E+ZoDPn jIb4l9Sz6b+ZKzzojF8LcYeHLL4HSZSK/Vn0VlkITugpxv8eMURdAAGD57hb1O0hfe6z LWOPzmPjBZrqDu31KS8jByHzr+I+KahOoZqSKvF9OoTemWBuloZ/lBUJIoiWszr2FGUp S3SNJ5Re6M+xD5sfC5l8eO442mHh3VeBiImSsxB6QT2foBEV0oROtHpa2Qyd8ax3FTFe vTHg== X-Gm-Message-State: APjAAAV0qFOTFHyCGON8BtaPh8mtE8NtJMbSuqphvV8OoV5AqVWqxdoL 6DmJ1IbdX+irGkTJsQGzgFtGJFhm5Go= X-Received: by 2002:adf:f8c1:: with SMTP id f1mr33102513wrq.151.1553872475819; Fri, 29 Mar 2019 08:14:35 -0700 (PDT) Received: from vitty.brq.redhat.com (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id f9sm2924957wmb.36.2019.03.29.08.14.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 29 Mar 2019 08:14:35 -0700 (PDT) From: Vitaly Kuznetsov To: Paolo Bonzini , kvm@vger.kernel.org Cc: Radim =?utf-8?B?S3LEjW3DocWZ?= , Liran Alon , Sean Christopherson , linux-kernel@vger.kernel.org Subject: Re: [PATCH RFC] KVM: x86: vmx: throttle immediate exit through preemtion timer to assist buggy guests In-Reply-To: <89d4189b-de6a-7634-de8b-29a044a86e12@redhat.com> References: <20190328203110.20655-1-vkuznets@redhat.com> <87d0m93frp.fsf@vitty.brq.redhat.com> <89d4189b-de6a-7634-de8b-29a044a86e12@redhat.com> Date: Fri, 29 Mar 2019 16:14:34 +0100 Message-ID: <877ech3e79.fsf@vitty.brq.redhat.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Paolo Bonzini writes: > On 29/03/19 15:40, Vitaly Kuznetsov wrote: >> Paolo Bonzini writes: >> >>> On 28/03/19 21:31, Vitaly Kuznetsov wrote: >>>> >>>> The 'hang' scenario develops like this: >>>> 1) Hyper-V boots and QEMU is trying to inject two irq simultaneously. One >>>> of them is level-triggered. KVM injects the edge-triggered one and >>>> requests immediate exit to inject the level-triggered: >>>> >>>> kvm_set_irq: gsi 23 level 1 source 0 >>>> kvm_msi_set_irq: dst 0 vec 80 (Fixed|physical|level) >>>> kvm_apic_accept_irq: apicid 0 vec 80 (Fixed|edge) >>>> kvm_msi_set_irq: dst 0 vec 96 (Fixed|physical|edge) >>>> kvm_apic_accept_irq: apicid 0 vec 96 (Fixed|edge) >>>> kvm_nested_vmexit_inject: reason EXTERNAL_INTERRUPT info1 0 info2 0 int_info 80000060 int_info_err 0 >>>> >>>> 2) Hyper-V requires one of its VMs to run to handle the situation but >>>> immediate exit happens: >>>> >>>> kvm_entry: vcpu 0 >>>> kvm_exit: reason VMRESUME rip 0xfffff80006a40115 info 0 0 >>>> kvm_entry: vcpu 0 >>>> kvm_exit: reason PREEMPTION_TIMER rip 0xfffff8022f3d8350 info 0 0 >>>> kvm_nested_vmexit: rip fffff8022f3d8350 reason PREEMPTION_TIMER info1 0 info2 0 int_info 0 int_info_err 0 >>>> kvm_nested_vmexit_inject: reason EXTERNAL_INTERRUPT info1 0 info2 0 int_info 80000050 int_info_err 0 >>> >>> I supposed before this there was an eoi for vector 96? >> >> AFAIR: no, it seems that it is actually the VM it is trying to resume >> (Windows partition?) which needs to do some work and with the preemtion >> timer of 0 we don't allow it to. > > kvm_apic_accept_irq placed IRQ 96 in IRR, and Hyper-V should be running > with "acknowledge interrupt on exit" since int_info is nonzero in > kvm_nested_vmexit_inject. > > Therefore, at the kvm_nested_vmexit_inject tracepoint KVM should have > set bit 96 in ISR; and because PPR is now 96, interrupt 80 should have > never been delivered. Unless 96 is an auto-EOI interrupt, in which case > this comment would apply > > /* > * For auto-EOI interrupts, there might be another pending > * interrupt above PPR, so check whether to raise another > * KVM_REQ_EVENT. > */ > > IIRC there was an enlightenment to tell Windows "I support auto-EOI but > please don't use it". If this is what's happening, that would also fix it. > Oh, that's actually an interesting thought, thanks! Indeed, there is CPUID 0x40000004.EAX Bit 9: Recommend deprecating AutoEOI which we don't currently set. I'll try and report back. -- Vitaly