Received: by 10.223.176.5 with SMTP id f5csp802909wra; Fri, 9 Feb 2018 07:27:31 -0800 (PST) X-Google-Smtp-Source: AH8x225+rLxwL3bbxOdFfMz3fPtpzrY2yabhJOB96ViftN6KGbexCrtV8nBDY2rVmMM2F0FCmest X-Received: by 2002:a17:902:9686:: with SMTP id n6-v6mr2857722plp.333.1518190051841; Fri, 09 Feb 2018 07:27:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518190051; cv=none; d=google.com; s=arc-20160816; b=MnG8mvNzC6zS4LSuQ1CL6Gs2LuVIrGym3q8aLD4oA0jypqdurUEnF8eTyoWiHgtHxN fsWi9gDomPrFM+9QgxXuk00KTiUiYBNTeJDdhBJnSMdscky9IcHui+94ufLUfXRMTwvO lrXrWub+GvSfBndbh1Gzf2a6EuVCRk3m+3WswW3RiuI9K/1rHMtl8vsumXN90dX03LOS NcQR1EVEXeQP766Z2wd6LXVACg0COlCzGdINM0GSnb8ss+XGk55xiwikl8MZxxCsTvYN cb4EUnHS4ym/GSCj4rqoE3BpFvg2W9vFZb3Cerr7geEH5w8qzusreE94xCUDw3lHR0qo JIBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version:dkim-signature:arc-authentication-results; bh=AJK4j03n/+1tOJOTP0vbC28M/+t7tex+TdfjQsOepeY=; b=mZuMBQpBfPcLG6W7cx8CBIufWCg8qw1XECrsNW1f/9OdeQ5huKpDUuX3ezxLbSLslF UGYYnplYtYE9BVpuMeCyUh5RQXnlpdQFXFErJzvnOY1qF8pQ7Pbybh38h7+3Jn5UNNa1 uyezqKV+/fwiRbrubN6VLclMiI12SC50GGuwKgg53zhB2Wa8itC275Wx7N4U2EjhyMG1 dZLu+msKmtIX17pQbQWE3JPsJyVIIhe0oGfjGNK1pGRjZ9AUsgNhkV6crwwkiuRdTErm SOhvHG6ZHdiJg0nlq/7LTyakuwlrIvayGCUn40eK7dD4FNO1ZZH6utvPrw8JXFWWzZxA ZuZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=ru5HeLUZ; 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=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a14-v6si1657338plm.719.2018.02.09.07.27.02; Fri, 09 Feb 2018 07:27:31 -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; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=ru5HeLUZ; 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=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751092AbeBIP0E (ORCPT + 99 others); Fri, 9 Feb 2018 10:26:04 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:53646 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751024AbeBIP0C (ORCPT ); Fri, 9 Feb 2018 10:26:02 -0500 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w19FMFup140539; Fri, 9 Feb 2018 15:25:58 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=content-type : mime-version : subject : from : in-reply-to : date : cc : content-transfer-encoding : message-id : references : to; s=corp-2017-10-26; bh=AJK4j03n/+1tOJOTP0vbC28M/+t7tex+TdfjQsOepeY=; b=ru5HeLUZ9zINlfCi373mLL6VSMmLrYHCbfYQ9hzTnP4BfZRy4T1dUE+oHqYMSoS9ZJJQ qqCjE3iCWwm8rFK3mLd/6mW1btQRWtxKUBehQtL7Zerjdqz/26AOunTyUy+xLsJgUGk4 fqArC8T9zhSgjs3896V5EWyujeTRsQGxgOy1v7C9OrpAsnhDPXWPtOVLZM/RGUr5Wo57 YyWJLKKZk0zYc/a1bzY2tTQ4c6BnrOlNTCXNmqSCe/jK1/BIGHFuoQ9FIG+AGeCtTPhg cVFbFD0ivdXM8+3QyDSxutf41GkfCAR8JtJbDDlVQaHqLrw/afUcLhu3U8aiyagrr039 Yg== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2120.oracle.com with ESMTP id 2g1dp8r8qp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 09 Feb 2018 15:25:58 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w19FKvrA004699 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 9 Feb 2018 15:20:57 GMT Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w19FKu28023745; Fri, 9 Feb 2018 15:20:56 GMT Received: from [10.30.2.6] (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 09 Feb 2018 07:20:56 -0800 Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: Re: [PATCH] KVM: lapic: stop advertising DIRECTED_EOI when in-kernel IOAPIC is in use From: Nikita Leshenko In-Reply-To: <20180209130133.28387-1-vkuznets@redhat.com> Date: Fri, 9 Feb 2018 17:20:48 +0200 Cc: kvm , linux-kernel@vger.kernel.org, x86@kernel.org, Paolo Bonzini , =?utf-8?B?UmFkaW0gS3LEjW3DocWZ?= , Peter Xu Content-Transfer-Encoding: quoted-printable Message-Id: <292414F1-6978-497E-9CE2-3847E171150B@oracle.com> References: <20180209130133.28387-1-vkuznets@redhat.com> To: Vitaly Kuznetsov X-Mailer: Apple Mail (2.3273) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8799 signatures=668665 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1802090195 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The patch looks correct, however I=E2=80=99m confused about why you = consider this to be a bug in the guest rather than a bug in KVM. The spec for x2APIC states: "The support for Directed EOI capability can be detected by means of bit 24 in the Local APIC Version Register=E2=80=9D (Intel=E2=80=99s = x2APIC spec, 2.5.1 Directed EOI) It seems to me that Windows did the right thing by testing for the presence of directed EOI feature rather than implying it exists by testing a version number. KVM did the wrong thing by advertising a feature it doesn=E2=80=99t support. Therefore I think that you should change the comment to something like =E2=80=9CKVM=E2=80=99s in-kernel IOAPIC doesn=E2=80=99t support Directed = EOI register, so don=E2=80=99t advertise this capability in the LAPIC Version Register.=E2=80=9D = instead of talking about buggy guests, as it may confuse future readers of this code. Thanks, Nikita > On 9 Feb 2018, at 15:01, Vitaly Kuznetsov wrote: >=20 > 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. >=20 > The issue was discovered and discussed a while ago: > = https://urldefense.proofpoint.com/v2/url?u=3Dhttps-3A__www.spinics.net_lis= ts_kvm_msg148098.html&d=3DDwIBAg&c=3DRoP1YumCXCgaWHvlZYR8PZh8Bv7qIrMUB65ea= pI_JnE&r=3DJD7W0KpKqI3xo5AglC-aIVDRz_ysy5CrQRnZ9Jb7je0&m=3DGWIw1X7PvyWESZa= Iau591RwjCXYZTi6THVNSOEcdaxU&s=3D5QUI6ED5i6frC8BzcF_e7hp6Kd_OqAxkg0z73R-UI= DI&e=3D >=20 > 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. >=20 > 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(-) >=20 > 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; >=20 > + /* > + * 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 =3D 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 |=3D APIC_LVR_DIRECTED_EOI; > kvm_lapic_set_reg(apic, APIC_LVR, v); > } > --=20 > 2.14.3 >=20