From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 81569C48BD1 for ; Fri, 11 Jun 2021 18:50:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 54E6961042 for ; Fri, 11 Jun 2021 18:50:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230356AbhFKSwJ (ORCPT ); Fri, 11 Jun 2021 14:52:09 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:38356 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229540AbhFKSwH (ORCPT ); Fri, 11 Jun 2021 14:52:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623437408; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=roTUteXHqjpSedCzqHsMThZGFyhCsglA/t3yAGivQNQ=; b=ihkk3729k1+OfnxIlsqqC0+LAkWL40qShdiFA39DJ5MfEQTsrqjKYzUGY1i6lojom0YoNf s2LN/teCv2ss+NmvUR0c93OqMj3o+oRk/YvEEiJb1xIZKd1UpsL0dG3AzN8L6c9eS4EKSO cIwdTqe2Q4Yeuc+642D3MoKchCc62og= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-473-UoBMM9UUMl2TnYOXBU-soQ-1; Fri, 11 Jun 2021 14:50:07 -0400 X-MC-Unique: UoBMM9UUMl2TnYOXBU-soQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 740B3100C661; Fri, 11 Jun 2021 18:50:05 +0000 (UTC) Received: from starship (unknown [10.40.194.6]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1B5E31001281; Fri, 11 Jun 2021 18:50:02 +0000 (UTC) Message-ID: Subject: Re: [PATCH v3 0/4] KVM: x86: hyper-v: Conditionally allow SynIC with APICv/AVIC From: Maxim Levitsky To: Vitaly Kuznetsov , kvm@vger.kernel.org, Paolo Bonzini Cc: Sean Christopherson , Wanpeng Li , Jim Mattson , linux-kernel@vger.kernel.org Date: Fri, 11 Jun 2021 21:50:01 +0300 In-Reply-To: <20210609150911.1471882-1-vkuznets@redhat.com> References: <20210609150911.1471882-1-vkuznets@redhat.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.5 (3.36.5-2.fc32) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2021-06-09 at 17:09 +0200, Vitaly Kuznetsov wrote: > Changes since v2: > - First two patches got merged, rebase. > - Use 'enable_apicv = avic = ...' in PATCH1 [Paolo] > - Collect R-b tags for PATCH2 [Sean, Max] > - Use hv_apicv_update_work() to get out of SRCU lock [Max] > - "KVM: x86: Check for pending interrupts when APICv is getting disabled" > added. > > Original description: > > APICV_INHIBIT_REASON_HYPERV is currently unconditionally forced upon > SynIC activation as SynIC's AutoEOI is incompatible with APICv/AVIC. It is, > however, possible to track whether the feature was actually used by the > guest and only inhibit APICv/AVIC when needed. > > The series can be tested with the followin hack: > > diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c > index 9a48f138832d..65a9974f80d9 100644 > --- a/arch/x86/kvm/cpuid.c > +++ b/arch/x86/kvm/cpuid.c > @@ -147,6 +147,13 @@ void kvm_update_cpuid_runtime(struct kvm_vcpu *vcpu) > vcpu->arch.ia32_misc_enable_msr & > MSR_IA32_MISC_ENABLE_MWAIT); > } > + > + /* Dirty hack: force HV_DEPRECATING_AEOI_RECOMMENDED. Not to be merged! */ > + best = kvm_find_cpuid_entry(vcpu, HYPERV_CPUID_ENLIGHTMENT_INFO, 0); > + if (best) { > + best->eax &= ~HV_X64_APIC_ACCESS_RECOMMENDED; > + best->eax |= HV_DEPRECATING_AEOI_RECOMMENDED; > + } > } > EXPORT_SYMBOL_GPL(kvm_update_cpuid_runtime); > > Vitaly Kuznetsov (4): > KVM: x86: Use common 'enable_apicv' variable for both APICv and AVIC > KVM: x86: Drop vendor specific functions for APICv/AVIC enablement > KVM: x86: Check for pending interrupts when APICv is getting disabled > KVM: x86: hyper-v: Deactivate APICv only when AutoEOI feature is in > use > > arch/x86/include/asm/kvm_host.h | 9 +++++- > arch/x86/kvm/hyperv.c | 51 +++++++++++++++++++++++++++++---- > arch/x86/kvm/svm/avic.c | 14 ++++----- > arch/x86/kvm/svm/svm.c | 22 ++++++++------ > arch/x86/kvm/svm/svm.h | 2 -- > arch/x86/kvm/vmx/capabilities.h | 1 - > arch/x86/kvm/vmx/vmx.c | 2 -- > arch/x86/kvm/x86.c | 18 ++++++++++-- > 8 files changed, 86 insertions(+), 33 deletions(-) > Hi! I hate to say it, but at least one of my VMs doesn't boot amymore with avic=1, after the recent updates. I'll bisect this soon, but this is likely related to this series. I will also review this series very soon. When the VM fails, it hangs on the OVMF screen and I see this in qemu logs: KVM: injection failed, MSI lost (Operation not permitted) KVM: injection failed, MSI lost (Operation not permitted) KVM: injection failed, MSI lost (Operation not permitted) KVM: injection failed, MSI lost (Operation not permitted) KVM: injection failed, MSI lost (Operation not permitted) KVM: injection failed, MSI lost (Operation not permitted) Best regards, Maxim Levitsky