Received: by 10.223.185.116 with SMTP id b49csp2050830wrg; Mon, 12 Feb 2018 03:31:14 -0800 (PST) X-Google-Smtp-Source: AH8x226oqKZRUtcXEDHk/gk6CekBKotCwCboPmm7mqdDxJEKs145oAk0WM1zWe1gDkJKNzkYt1+k X-Received: by 2002:a17:902:7e43:: with SMTP id a3-v6mr10689890pln.138.1518435074592; Mon, 12 Feb 2018 03:31:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518435074; cv=none; d=google.com; s=arc-20160816; b=bp9t6OatsyDk315EokdbV6Jo2rSyGkt8QzWQWV5JPcbDb5x979WEobkeyhuQExG6aP 4y5jLfGb3CyaEXYkcGo56xFrx+xLh1WiZE5gFxRkNswBqXP1y3MasceYrAOg2LE3J1u/ NiyJnhmGOetsTlLkZRVZT7iAp8ynfLz2FpVrqDRK/Jf4Anc9ix8qBjGU8b4eFCv5PYeX 1tpAzuFnRc5VgT6yLFgAy140H5NgnmL+k8Ovr+2SDroUq2ZHTWpZfNExhXFSy2dhCYnc yyODYYP49ctOTw3zO2krdoLRaaPOfNJwW/Ql52p+Xz5syYjNxYjV18YSFVD9ENo4Z4nC E0Pg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from :arc-authentication-results; bh=TT90DG3GV6JL1sCH+W3n1Q/Nx91HtBlyuT+bzE+qqew=; b=zEn0UJDnQEdU+8j3gNVLclxEZZ3NRQsgfCljccfNCTmSQQdpWeenYafbd3PC3TcUXQ +Z9ovTj9eBna0DEKhl/u0QH0q8cVV918eNeDkk7Fq75q4MoWlLMoeWKXHKuqkvf0/c/0 S7zHn00CU5KCyv+N9CXKSj5F6FsEqhbZnJ+OyE1VgqF/nxAV91dTgO3k0REK5lMh1z+r m/ZbZopPA3+ZAJ22oP6iueD2xeqsfL1s2b8nQoie7ucFH7Drhj/1EgRlBwG9Cfs6Tl++ IStW5i32YF1EpO0DilpBAXKUffQq2W8phIFMQYRMYJkEMsVMmbhH5rFE52ETX9ztqMWn fawQ== 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 z100-v6si399993plh.129.2018.02.12.03.30.52; Mon, 12 Feb 2018 03:31:14 -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 S934122AbeBLLaJ (ORCPT + 99 others); Mon, 12 Feb 2018 06:30:09 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:50010 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S934072AbeBLLaH (ORCPT ); Mon, 12 Feb 2018 06:30:07 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CDC5040FB633; Mon, 12 Feb 2018 11:30:06 +0000 (UTC) Received: from vitty.brq.redhat.com.redhat.com (unknown [10.43.2.155]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CDB252026DFD; Mon, 12 Feb 2018 11:30:05 +0000 (UTC) From: Vitaly Kuznetsov To: Peter Xu 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 References: <20180209130133.28387-1-vkuznets@redhat.com> <20180211052539.GA31261@xz-mi> Date: Mon, 12 Feb 2018 12:30:04 +0100 In-Reply-To: <20180211052539.GA31261@xz-mi> (Peter Xu's message of "Sun, 11 Feb 2018 13:25:39 +0800") Message-ID: <87r2pqxx6r.fsf@vitty.brq.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Mon, 12 Feb 2018 11:30:06 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Mon, 12 Feb 2018 11:30:06 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.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 Peter Xu writes: > 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. > My thoughts were: with in-kernel IOAPIC nobody does EOI broadcast disabling today or he's already broken -- there's no way to EOI level-triggered interrupts. And the patch changes nothing for QEMU ioapic implementation. What I'm not sure about is if we allow migration between in-kernel and QEMU ioapic implementations. I don't think so but in case we do it is again already broken because going down from 0x20 to 0x11 will leave you without EOI register. Migrating from 0x11 to 0x20 should be fine, the guest will continue without knowing there's a new feature available. But I may have missed something. Radim? :-) -- Vitaly