Received: by 10.223.185.116 with SMTP id b49csp830706wrg; Sat, 10 Feb 2018 21:27:11 -0800 (PST) X-Google-Smtp-Source: AH8x226KWt5Lg3S5/MxqJyw+cK36BUjNHy7H8Ur8Fa1+qoSHTLM4IgSlg+8fSQPbWYZTAx5PS+5F X-Received: by 10.98.22.65 with SMTP id 62mr7758213pfw.211.1518326831077; Sat, 10 Feb 2018 21:27:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518326831; cv=none; d=google.com; s=arc-20160816; b=xsNisLHupsK5I0u5ULMzbiERXT3XO84FFo3maPXSVNIRAlFEYdsYzyo0kmOS97dVU6 DJtcW2zUr1u1nlnJ5Ll4oMB8TpAhep5/Sbawd/ofn/qhNfYfhoxsrl9snnVyO/IAL+qu xceWmsCfR5Ddmla9qwYn5/JFHgRSXJHEJVdVRJFvNfWU5fWH14iRkCqjaKQ7zURVh0Q4 uYobHn/ctFRu5guRKULNWr750zFaqQULL40+ypjewlsAR6YYpzI33s2y1bHvGYqXsAi3 6N2ijJ47fNEgVVRzzdDIQYHeepu2V6d2VfhbSfMZex4So9bF0PLNMvlbEjKNWX3v8lWe BGxA== 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=kfUMsyDVEu+6NMvMFsjGCJNmlRLs3lrJr8mKyWbGTzw=; b=ZcuvBr0lhslB5wO7Qzqlj4uoo8Gu/b3uIQeUnT4EfTvxsv+E8nxSoJD8eC4aW9hTf+ 5SOahwUvj26CsJZ7x8kWfq9mxHjmFs5AgRBPS+0SZnixdkKRf0DT4QTrLItYhSqbitYT 83LqPG6YAL8SLRMTA7+h0zbqyTC9yViSK1rRgPVaQ+YLq+2hdl6bwFXpDR1c1Kk0B335 w/YiI6OF1y1v5YthJEZ9/0aRa1d02O3zozrBxtL5aahrmFidz78f62sST+zY+TvmF68M zaF976WHxw4svSjn7zwvCoQc0WSfYbWIDtL3tGxn1xwc7FpnBn3G5KIeM02ElzEcsm2M p0Qg== 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 f4-v6si2386046plf.59.2018.02.10.21.26.57; Sat, 10 Feb 2018 21:27:11 -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 S1753718AbeBKFZs (ORCPT + 99 others); Sun, 11 Feb 2018 00:25:48 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:41406 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752784AbeBKFZp (ORCPT ); Sun, 11 Feb 2018 00:25:45 -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 4AAC140FB63F; Sun, 11 Feb 2018 05:25:44 +0000 (UTC) Received: from xz-mi (dhcp-14-120.nay.redhat.com [10.66.14.120]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 066DD2166BAE; Sun, 11 Feb 2018 05:25:41 +0000 (UTC) Date: Sun, 11 Feb 2018 13:25:39 +0800 From: Peter Xu To: Vitaly Kuznetsov Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org, Paolo Bonzini , Radim =?utf-8?B?S3LEjW3DocWZ?= Subject: Re: [PATCH] KVM: lapic: stop advertising DIRECTED_EOI when in-kernel IOAPIC is in use Message-ID: <20180211052539.GA31261@xz-mi> References: <20180209130133.28387-1-vkuznets@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20180209130133.28387-1-vkuznets@redhat.com> User-Agent: Mutt/1.9.1 (2017-09-22) 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.7]); Sun, 11 Feb 2018 05:25:44 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Sun, 11 Feb 2018 05:25:44 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'peterx@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 09, 2018 at 02:01:33PM +0100, Vitaly Kuznetsov wrote: > 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. I sort of agree on this, especially considering that we already have IOAPIC version 0x20 support in QEMU already. > --- > 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 > Does this mean that we can avoid the migration problem that Radim raised in previous discussion? Basically the OSs should only probe this version once for each boot, if so I think it should be fine. But since you didn't mention that in either commit message and comment, I would like to ask and confirm. For the change itself, it looks sane to me. Thanks, -- Peter Xu