Received: by 2002:a25:5b86:0:0:0:0:0 with SMTP id p128csp1601385ybb; Fri, 29 Mar 2019 07:41:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqyVcpmRx1WPr2cZONsM7tpcDllYeNP2fgLH7VuiHukihDuqdXj/+5i+Zb0icfFvpTErJ0ny X-Received: by 2002:a17:902:9881:: with SMTP id s1mr19613716plp.99.1553870508561; Fri, 29 Mar 2019 07:41:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553870508; cv=none; d=google.com; s=arc-20160816; b=y/AJ6zfdl+Ko/jt0BCB/q5JW+Kded5etFpp6Eg/RUCv1xIfccRx1DC8r0n3CirBc/X z3x3qFai3V895ESuHchbCDQlzUHqQOCUDxaM7qzeuQaDk+bU/9NNZxtEFf3RbisP6BkS n8LauWzWj1tMpLFVDDMPQARWjOsltAUFMrGge96MmHKswM5oqENiUfErirWKoNLDqSGn VeHpeGQ72umUbI4nrWPZlU7Mfkz7grnQmgx2uvfWfHImhHGepQNflUGzM871JuvjuqY4 M5963DGRP7JvDzl3w7whf6sZYHhOwV0EhfymTUoEkDsCot1NlwQwm1CBK21hZEP+93/M rNdA== 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=m1U/9No1om/xpwk+9c7FZnuMILDfo7dttqFsNyKRglk=; b=nsJiqafMFzkycg4yydnXQQ1/dQwm0K99IVPtij8EH/QYjc+37zz1cc+IVncRCjgQRR 41uP/d+9BS9dU2XKVfyhpjmPMdFZZB+w5EYq90o4sROSRBsK0qCT1DMlG4fjpxQtfQoW TWam/ERmvBMZsVXYMyqzbuuwiasifAz7ec+V1vm1XlXjK+w+zlEeOx56H8oLmrQjtSaW WhzX9i6TkdgMu/uVkiiTF8BedBK1SDfPdsY30nIPyE+tXJ1oLYexeO93kwpBw5oEoCI3 BeLVVxahx5ubOrWAV9NS1YE4hUMIzHtMKGix25USkXKowEL/OP8a3xY+ZfIFF8WCIPI/ X6sA== 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 f18si2120952pgj.188.2019.03.29.07.41.32; Fri, 29 Mar 2019 07:41:48 -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 S1729376AbfC2Okt (ORCPT + 99 others); Fri, 29 Mar 2019 10:40:49 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:40067 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729021AbfC2Okq (ORCPT ); Fri, 29 Mar 2019 10:40:46 -0400 Received: by mail-wm1-f67.google.com with SMTP id z24so3114947wmi.5 for ; Fri, 29 Mar 2019 07:40:45 -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=m1U/9No1om/xpwk+9c7FZnuMILDfo7dttqFsNyKRglk=; b=uHYznqsNI9LkTImzhS1LE4WDmDQ571IvSFjVsNE9TPLiprAw+JmkTgsXZbk3VIFRoM TgjKQN6Tndr8DDKzTuZvb/Do4FrA0AJepdhMiX0Y0aDM3DS/QD1PwfGXJZA58PkXHwFr coxVSQ+6R69YtUj7DJY/stt6nqxrB0hDZ7+lIuUOVHOYsAe3JvmuUconTihtfgukXYO0 p/S+1EHXAX7f+/rErdgiCZ0o+dTJuZwSDQGsucLI1G/B/mjX5VAyHXf31AYBTXmwfmDY 2hg+0NKfV2FrUIn9YPSICSfGg7HKTAPYYFRUmmRAffLtVtpeL/asGfskC3sz1a3oHuBG g7RQ== X-Gm-Message-State: APjAAAUy0HLesVmf7yqTPosnmTMl+U2beJSWQvkRvy2weDe9BC8Nvezb nmaPTUlbiUE6FZgd8nTWerJkDiYh2pk= X-Received: by 2002:a7b:cd08:: with SMTP id f8mr3803304wmj.86.1553870444620; Fri, 29 Mar 2019 07:40:44 -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 z13sm2998735wrw.36.2019.03.29.07.40.43 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 29 Mar 2019 07:40:43 -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: References: <20190328203110.20655-1-vkuznets@redhat.com> Date: Fri, 29 Mar 2019 15:40:42 +0100 Message-ID: <87d0m93frp.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 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. > > The main issue with your patch is that the preemption timer is buggy on > some processors (it runs too fast) and on those processors we shouldn't > use it with nonzero deadline. In particular because it runs too fast it > may not hide the bug. > > I think level-triggered interrupts are required for the bug to show. > Edge-triggered interrupts usually have to be acknowledged with a device > register before the host device will trigger another interrupt; or at > least the interrupt event, for example an incoming network packet, must > happen again. This way, when the guest hangs it puts some back pressure > on the host. > > I think we should do in QEMU the same fix that was done in the in-kernel > IOAPIC. Yes, I have this in my plan. Stay tuned! -- Vitaly