Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1307623ybl; Wed, 28 Aug 2019 12:39:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqwoKhn/sXUxWOme4xH8dR6z96c0TSMBbdxO76OPJOdjz7aqh0MNOoJvQuFQEWewHiYM+xjS X-Received: by 2002:a62:2c94:: with SMTP id s142mr6638169pfs.45.1567021177180; Wed, 28 Aug 2019 12:39:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567021177; cv=none; d=google.com; s=arc-20160816; b=gLGiSCM6EtPffHKYon97rSuy6/4lX84VM5C+9SiVbRsKde8NF64vCEhZjvw5tQLtz3 d0YD5oV98UAYquvmzSwX0zcYzYDHJxvCBBB1GkW8bq4Wx4MzcQRjFWpjXoXJ4nFHTrpo SHKUbDaDPOYdXJjdR+9JgK+zqePWmCUa7MQyOCvpKwKA+TkkSHO56nzasG0ShN3ndX+a v9JLxL4sV2MVVwnsWWxnHU97lHNJeppDwW5JPrYhpcW0z1VBm5GZQPv47WG1bARwX80G r6tOPlaXCvE7UwWMFvtn3z9BvwDCmMU070NJ0NgScHnpkpCrLTkoVZgKJBPfYL9mjUYW 3Sww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from:dkim-signature; bh=0/zETLT6OxlsuzV2h4cI2jALLd91yg4iSxzLtVcgnvs=; b=ymt8/BcG113M9TJtNcJMxQfdYCPaNZKKNDfemeSNMsX+aXIUmlb9LA4yYaaaHT6bcx lx/KTud72j2/JSeQH7ZQEIVd13ymx+OhKoxM5IvdxRbxp06iKpTFWBRlEn9JovNIcYSa cQas/KH/32+w+OZM6Clr5v22IymTs0VTXurTIPGsr9d/w9h22gyEJN2r8aR59gRav98w aynMkZsuuBfpGpPLeVzFsdynpxHQUIJx15BMRJaM5/W2szb3wDO24BtighWlk49g+tcq fJsC58wIaSJ5Gcu7OZPEXz5Yj6lfHTEsi9S58GOkBczInc7LbvMZt9U05ses1tY9aFD0 vwJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.de header.s=amazon201209 header.b=VCY2K4Rr; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 63si117213pfz.212.2019.08.28.12.39.14; Wed, 28 Aug 2019 12:39:37 -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=@amazon.de header.s=amazon201209 header.b=VCY2K4Rr; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726907AbfH1Thb (ORCPT + 99 others); Wed, 28 Aug 2019 15:37:31 -0400 Received: from smtp-fw-33001.amazon.com ([207.171.190.10]:63712 "EHLO smtp-fw-33001.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726591AbfH1Thb (ORCPT ); Wed, 28 Aug 2019 15:37:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1567021050; x=1598557050; h=from:to:cc:subject:date:message-id:references: in-reply-to:mime-version:content-transfer-encoding; bh=0/zETLT6OxlsuzV2h4cI2jALLd91yg4iSxzLtVcgnvs=; b=VCY2K4RrpK6UMEW21DASV1UktYIj5ssljwK8Itd6VWYX+5QoOnKDt8xp 3WRMAgRzNO5EKVVNV/YGaFdUIX43dAZrWgqUFHEWyPeWw36ucIS2o+xvX guVuIWp+iFLvjIy9xRgJhwxCGvj3I+UwHf2KcSa9LZihelPwjpgpWEctC s=; X-IronPort-AV: E=Sophos;i="5.64,442,1559520000"; d="scan'208";a="824873404" Received: from sea3-co-svc-lb6-vlan2.sea.amazon.com (HELO email-inbound-relay-2c-168cbb73.us-west-2.amazon.com) ([10.47.22.34]) by smtp-border-fw-out-33001.sea14.amazon.com with ESMTP; 28 Aug 2019 19:37:28 +0000 Received: from EX13MTAUEA001.ant.amazon.com (pdx4-ws-svc-p6-lb7-vlan2.pdx.amazon.com [10.170.41.162]) by email-inbound-relay-2c-168cbb73.us-west-2.amazon.com (Postfix) with ESMTPS id 33854A269C; Wed, 28 Aug 2019 19:37:28 +0000 (UTC) Received: from EX13D01EUA002.ant.amazon.com (10.43.165.199) by EX13MTAUEA001.ant.amazon.com (10.43.61.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Wed, 28 Aug 2019 19:37:27 +0000 Received: from EX13D20UWC001.ant.amazon.com (10.43.162.244) by EX13D01EUA002.ant.amazon.com (10.43.165.199) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Wed, 28 Aug 2019 19:37:26 +0000 Received: from EX13D20UWC001.ant.amazon.com ([10.43.162.244]) by EX13D20UWC001.ant.amazon.com ([10.43.162.244]) with mapi id 15.00.1367.000; Wed, 28 Aug 2019 19:37:25 +0000 From: "Graf (AWS), Alexander" To: "Suthikulpanit, Suravee" CC: "linux-kernel@vger.kernel.org" , "kvm@vger.kernel.org" , "pbonzini@redhat.com" , "rkrcmar@redhat.com" , "joro@8bytes.org" , "Schoenherr, Jan H." , "Raslan, KarimAllah" , "Lukaszewicz, Rimas" , "Grimm, Jon" Subject: Re: [PATCH v2 11/15] svm: Temporary deactivate AVIC during ExtINT handling Thread-Topic: [PATCH v2 11/15] svm: Temporary deactivate AVIC during ExtINT handling Thread-Index: AQHVU4YZx2GIhsHgJkOSwpBQnjkrXqcCTLuAgA5zxoCAAEh7gA== Date: Wed, 28 Aug 2019 19:37:24 +0000 Message-ID: <82C8A08D-6CB3-4268-BF79-802E1015E365@amazon.de> References: <1565886293-115836-1-git-send-email-suravee.suthikulpanit@amd.com> <1565886293-115836-12-git-send-email-suravee.suthikulpanit@amd.com> <1ed5bf9c-177e-b41c-b5ac-4c76155ead2a@amazon.com>,<5aaef6f4-4bee-4cc4-8eb0-d9b4c412988b@amd.com> In-Reply-To: <5aaef6f4-4bee-4cc4-8eb0-d9b4c412988b@amd.com> Accept-Language: en-US Content-Language: de-DE X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > Am 28.08.2019 um 17:19 schrieb Suthikulpanit, Suravee : > = > Alex, > = >> On 8/19/19 5:35 AM, Alexander Graf wrote: >> = >> = >>> On 15.08.19 18:25, Suthikulpanit, Suravee wrote: >>> AMD AVIC does not support ExtINT. Therefore, AVIC must be temporary >>> deactivated and fall back to using legacy interrupt injection via vINTR >>> and interrupt window. >>> = >>> Signed-off-by: Suravee Suthikulpanit >>> --- >>> arch/x86/kvm/svm.c | 49 = >>> +++++++++++++++++++++++++++++++++++++++++++++---- >>> 1 file changed, 45 insertions(+), 4 deletions(-) >>> = >>> diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c >>> index cfa4b13..4690351 100644 >>> --- a/arch/x86/kvm/svm.c >>> +++ b/arch/x86/kvm/svm.c >>> @@ -384,6 +384,7 @@ struct amd_svm_iommu_ir { >>> static void svm_set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0); >>> static void svm_flush_tlb(struct kvm_vcpu *vcpu, bool invalidate_gpa); >>> static void svm_complete_interrupts(struct vcpu_svm *svm); >>> +static void svm_request_activate_avic(struct kvm_vcpu *vcpu); >>> static bool svm_get_enable_apicv(struct kvm *kvm); >>> static inline void avic_post_state_restore(struct kvm_vcpu *vcpu); >>> @@ -4494,6 +4495,15 @@ static int interrupt_window_interception(struct = >>> vcpu_svm *svm) >>> { >>> kvm_make_request(KVM_REQ_EVENT, &svm->vcpu); >>> svm_clear_vintr(svm); >>> + >>> + /* >>> + * For AVIC, the only reason to end up here is ExtINTs. >>> + * In this case AVIC was temporarily disabled for >>> + * requesting the IRQ window and we have to re-enable it. >>> + */ >>> + if (svm_get_enable_apicv(svm->vcpu.kvm)) >>> + svm_request_activate_avic(&svm->vcpu); >> = >> Would it make sense to add a trace point here and to the other call = >> sites, so that it becomes obvious in a trace when and why exactly avic = >> was active/inactive? >> = >> The trace point could add additional information on the why. > = > Sure, sounds good. > = >>> .... >>> @@ -5522,9 +5558,6 @@ static void enable_irq_window(struct kvm_vcpu = >>> *vcpu) >>> { >>> struct vcpu_svm *svm =3D to_svm(vcpu); >>> - if (kvm_vcpu_apicv_active(vcpu)) >>> - return; >>> - >>> /* >>> * In case GIF=3D0 we can't rely on the CPU to tell us when GIF = >>> becomes >>> * 1, because that's a separate STGI/VMRUN intercept. The next = >>> time we >>> @@ -5534,6 +5567,14 @@ static void enable_irq_window(struct kvm_vcpu = >>> *vcpu) >>> * window under the assumption that the hardware will set the GIF. >>> */ >>> if ((vgif_enabled(svm) || gif_set(svm)) && nested_svm_intr(svm)) { >>> + /* >>> + * IRQ window is not needed when AVIC is enabled, >>> + * unless we have pending ExtINT since it cannot be injected >>> + * via AVIC. In such case, we need to temporarily disable AVIC, >>> + * and fallback to injecting IRQ via V_IRQ. >>> + */ >>> + if (kvm_vcpu_apicv_active(vcpu)) >>> + svm_request_deactivate_avic(&svm->vcpu); >> = >> Did you test AVIC with nesting? Did you actually run across this issue = >> there? > = > Currently, we have not claimed that AVIC is supported w/ nested VM. = > That's why we have not enabled AVIC by default yet. We will be looking = > more into that next. If it's not supported, please suspend it when we enter a nested guest then?= In that case, the above change is also unnecessary, as it only affects nes= ted guests, no? Alex > = > Suravee Amazon Development Center Germany GmbH Krausenstr. 38 10117 Berlin Geschaeftsfuehrung: Christian Schlaeger, Ralf Herbrich Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B Sitz: Berlin Ust-ID: DE 289 237 879