Received: by 10.223.176.5 with SMTP id f5csp644272wra; Fri, 9 Feb 2018 05:02:46 -0800 (PST) X-Google-Smtp-Source: AH8x224qE1osO5Rk/KlfrDPTEgga1MTOlReAgjyGmxfVQ2IZ9hgtm31w7aMAs3BbWKroh/p0tK0f X-Received: by 10.98.196.204 with SMTP id h73mr2847545pfk.143.1518181366312; Fri, 09 Feb 2018 05:02:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518181366; cv=none; d=google.com; s=arc-20160816; b=as9Ivjg1K+5c9qjZVIOkbpyktxoxau8g7aM0L1Mxe6FOzX9vDAD6Ou8A2iKRpu5jMq ricTKF5dkg/QHgeFjzIxnJkwT98WfBF7XtCjZyL8AG7u+JBoTSN1YAh/nXWLv/gTI2RZ WRU9wA1/e8VxD9Lxo7Bxuqbpg8JR4MkHHw5lYM7FWdtTRoCvWXbybdfYrliEBucGMEtM 5uCfo/CxYTVrD1d1cGFOUlG936w/fpvN3s/LWgsMojip1iaoQM+6bNIRHmXvgxeXZLzw IuGYCFKAmJ8t8f14c20SHhaA162jnZyuhWXJpa4DCATi7fn7lq2Zxf4a8pmxPXtECq3k loHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=YQaUHzMG/XShQSkHaGTUUpY9Swr67vU/y7XgFKbWQfo=; b=h3rcnsR8cmMykWQHXETNGn+68yLbYknyrk3NLHm079P/MW0PFJzHDlO7hmcxP4x5Qj jSn/OLsRe+ODNIkhhW2wNju50VvkEGee8lcgAYBgPPApMLVWiXwS+QDnaXhEEclzB1VA BdBPz7gko/s+Uup8Js5pVP9ATIyuuJvENpyq+aMqh/wQuofu2ikZwdKdsvJk9k3kLcfc OVJv7PJORofKi9fb0z6nDOIf2feumKxeIXb9Q/bByKx0IKyuDBkaZ+rsQ3FbPz5r5HSc izkBXsr1bohBdYAShJISZ3XP2KSXv3GErpqo4sbxZLOuxxmdP5Hd/fO/WKdo36KXDmSp mb/w== 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 n11si1360083pgq.230.2018.02.09.05.02.31; Fri, 09 Feb 2018 05:02:46 -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 S1751117AbeBINBh (ORCPT + 99 others); Fri, 9 Feb 2018 08:01:37 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:44968 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750993AbeBINBg (ORCPT ); Fri, 9 Feb 2018 08:01:36 -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 A85894040093; Fri, 9 Feb 2018 13:01:35 +0000 (UTC) Received: from vitty.brq.redhat.com (unknown [10.43.2.155]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8ECAB2166BAE; Fri, 9 Feb 2018 13:01:34 +0000 (UTC) From: Vitaly Kuznetsov To: kvm@vger.kernel.org Cc: linux-kernel@vger.kernel.org, x86@kernel.org, Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Peter Xu Subject: [PATCH] KVM: lapic: stop advertising DIRECTED_EOI when in-kernel IOAPIC is in use Date: Fri, 9 Feb 2018 14:01:33 +0100 Message-Id: <20180209130133.28387-1-vkuznets@redhat.com> 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]); Fri, 09 Feb 2018 13:01:35 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Fri, 09 Feb 2018 13:01:35 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'vkuznets@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Devices which use level-triggered interrupts under Windows 2016 with Hyper-V role enabled don't work: Windows disables EOI broadcast in SPIV unconditionally. Our in-kernel IOAPIC implementation emulates an old IOAPIC version which has no EOI register so EOI never happens. The issue was discovered and discussed a while ago: https://www.spinics.net/lists/kvm/msg148098.html While this is a guest OS bug (it should check that IOAPIC has the required capabilities before disabling EOI broadcast) we can workaround it in KVM: advertising DIRECTED_EOI with in-kernel IOAPIC makes little sense anyway. Signed-off-by: Vitaly Kuznetsov --- - Radim's suggestion was to disable DIRECTED_EOI unconditionally but I'm not that radical :-) In theory, we may have multiple IOAPICs in userspace in future and DIRECTED_EOI can be leveraged. --- arch/x86/kvm/lapic.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c index 924ac8ce9d50..5339287fee63 100644 --- a/arch/x86/kvm/lapic.c +++ b/arch/x86/kvm/lapic.c @@ -321,8 +321,16 @@ void kvm_apic_set_version(struct kvm_vcpu *vcpu) if (!lapic_in_kernel(vcpu)) return; + /* + * KVM emulates 82093AA datasheet (with in-kernel IOAPIC implementation) + * which doesn't have EOI register; Some buggy OSes (e.g. Windows with + * Hyper-V role) disable EOI broadcast in lapic not checking for IOAPIC + * version first and level-triggered interrupts never get EOIed in + * IOAPIC. + */ feat = kvm_find_cpuid_entry(apic->vcpu, 0x1, 0); - if (feat && (feat->ecx & (1 << (X86_FEATURE_X2APIC & 31)))) + if (feat && (feat->ecx & (1 << (X86_FEATURE_X2APIC & 31))) && + !ioapic_in_kernel(vcpu->kvm)) v |= APIC_LVR_DIRECTED_EOI; kvm_lapic_set_reg(apic, APIC_LVR, v); } -- 2.14.3