Received: by 2002:a25:5b86:0:0:0:0:0 with SMTP id p128csp1649279ybb; Fri, 29 Mar 2019 08:33:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqzmQ2qAMtnjPm19A3wmfnRDbvOpl8HOLFcl4O0F65Fhh6dvNe+FCTWlsa9bNua0IRrti1w9 X-Received: by 2002:a17:902:9006:: with SMTP id a6mr3738885plp.259.1553873635814; Fri, 29 Mar 2019 08:33:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553873635; cv=none; d=google.com; s=arc-20160816; b=Autqj9Pw9GuNZV2Se4gBh9wQJhk20x3BedvSJiQnMnvxbDj5IEk1CaKoTKUh6oFbkp 87dcckNGaixVm8Ds3BLVTVenb+Ra/AZikD4jEeS3PKAen/bFqZHZxmdpAh0fq0QRRDTA Ba4zLSWnMyC65G2ZRSM5qIwC/pfobiE/kWkpwSRSoGVY2OXCNjRdIKsxVHg76KZH3mOy BaApdMZAOcPacNQtWmY680oupQonlK1SxKDsJsl4aEeoLtGtCCHFH8eWvWr6dn7ikJ8S 0QUWUgEwcO6i8tWeKocwnjl5ZyR5GVhgXFg5ui5xFBLvc6EVkwaUwC6BV1LbesKQzFUA c3Og== 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; bh=mGWSACrkMo1yya3P4I6MhhCZpSkW9f4Lh5S0L5Z85JM=; b=PLC1zsm0Yu8Cza8pTWkXat+JiJYl7XcPOSiJvScmMn8XloDRVS1jjmvmtk7uXebhXo Ros7ibqhvnJ41u8gXjG01Yn/hLQPX2F/OZNFlXiZuiqLWghvH9E4wrIqfoawgnrY66CC otNp6Cekc5KN1ay98Amz/0quuezebyV5w8F9f+krOMP/esZYC5wImktPy4mElElNMUp9 v4oM//KYc4JD6o+zlDkettqCCV5T/lWGx6bS4MOMywZP8tSQpCq5HhlT9qXie4btgPwi HvjeZeAIucUUxcv/Wl6I0zZNHv8vLfqKm5ID+9nIDmGqJKZ/JTvnUhzFvD9/Jhb/9w49 oExw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=m8JViSNA; 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 33si2200100plq.275.2019.03.29.08.33.39; Fri, 29 Mar 2019 08:33:55 -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; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=m8JViSNA; 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 S1729614AbfC2Pco (ORCPT + 99 others); Fri, 29 Mar 2019 11:32:44 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:54730 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728720AbfC2Pcn (ORCPT ); Fri, 29 Mar 2019 11:32:43 -0400 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x2TFT5cn076374; Fri, 29 Mar 2019 15:32:39 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-2018-07-02; bh=mGWSACrkMo1yya3P4I6MhhCZpSkW9f4Lh5S0L5Z85JM=; b=m8JViSNAvwbT4lmmEiRlcbwRmXlWr/6C9hgfE1kSmV6FeMska8h/1B37NyqilxlXxQFo 80ewalnT+8EApPFEHIu0n93X9kwb0iWDv50ngCiEBYBqWIVE3nr9dyaL7j9iQva1YDl3 d8/04t2hc5T6vl2nE94RfFdELvcnNJbBt4auwBiBg8qYSMqEpWFcDFfV5idy4E6z3qOy alNX0RXOwwX3pVXHCRVyP1RBr4uxMbCOf6sJxOJkR4DF6pgj8kdUKnH5EmH+Ws3Kvn4I QYlJ2Qrn6bSR/WPZLkTZGBrGsnWuZnw6zTo26Fkn/fwjpKylQRMOtYJjzgpZ9cIBIYJa bg== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp2130.oracle.com with ESMTP id 2re6g1d5v8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 29 Mar 2019 15:32:38 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id x2TFWb5E004311 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 29 Mar 2019 15:32:37 GMT Received: from abhmp0002.oracle.com (abhmp0002.oracle.com [141.146.116.8]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x2TFWakK024417; Fri, 29 Mar 2019 15:32:36 GMT Received: from [192.168.14.112] (/79.183.242.215) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 29 Mar 2019 08:32:36 -0700 Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 11.1 \(3445.4.7\)) Subject: Re: [PATCH RFC] KVM: x86: vmx: throttle immediate exit through preemtion timer to assist buggy guests From: Liran Alon In-Reply-To: <89d4189b-de6a-7634-de8b-29a044a86e12@redhat.com> Date: Fri, 29 Mar 2019 18:32:32 +0300 Cc: Vitaly Kuznetsov , kvm@vger.kernel.org, =?utf-8?B?UmFkaW0gS3LEjW3DocWZ?= , Sean Christopherson , linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Message-Id: <63F1B6AE-F7A0-40D9-9582-558723800682@oracle.com> References: <20190328203110.20655-1-vkuznets@redhat.com> <87d0m93frp.fsf@vitty.brq.redhat.com> <89d4189b-de6a-7634-de8b-29a044a86e12@redhat.com> To: Paolo Bonzini X-Mailer: Apple Mail (2.3445.4.7) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9211 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1903290110 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On 29 Mar 2019, at 18:01, Paolo Bonzini wrote: >=20 > On 29/03/19 15:40, Vitaly Kuznetsov wrote: >> Paolo Bonzini writes: >>=20 >>> On 28/03/19 21:31, Vitaly Kuznetsov wrote: >>>>=20 >>>> 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: >>>>=20 >>>> 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 >>>>=20 >>>> 2) Hyper-V requires one of its VMs to run to handle the situation = but >>>> immediate exit happens: >>>>=20 >>>> 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 >>>=20 >>> I supposed before this there was an eoi for vector 96? >>=20 >> 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. >=20 > kvm_apic_accept_irq placed IRQ 96 in IRR, and Hyper-V should be = running > with "acknowledge interrupt on exit" since int_info is nonzero in > kvm_nested_vmexit_inject. >=20 > Therefore, at the kvm_nested_vmexit_inject tracepoint KVM should have > set bit 96 in ISR; and because PPR is now 96, interrupt 80 should have > never been delivered. Unless 96 is an auto-EOI interrupt, in which = case > this comment would apply >=20 > /* > * For auto-EOI interrupts, there might be another pending > * interrupt above PPR, so check whether to raise another > * KVM_REQ_EVENT. > */ >=20 > IIRC there was an enlightenment to tell Windows "I support auto-EOI = but > please don't use it". If this is what's happening, that would also = fix it. >=20 > Thanks, >=20 > Paolo Paolo I am not sure this is the case here. Please read my other replies in this email thread. I think this is just a standard issue of a level-triggered interrupt = handler in L1 (Hyper-V) that performs EOI before it lowers the irq-line. I don=E2=80=99t think vector 96 is even related to the issue at hand = here. This is why after it was already handled, the loop of = EXTERNAL_INTERRUPT happens on vector 80 and not vector 96. In addition, there is a missing optimisation from Hyper-V that after it = handles an EXTERNAL_INTERRUPT exit, it doesn=E2=80=99t enable interrupts to receive other pending host interrupts (In our case, the pending = vector 80) and will therefore only receive it once it enters back to L2 which will cause another EXTERNAL_INTERRUPT exit but this time on vector = 80. -Liran