Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp2496620rdb; Thu, 21 Sep 2023 23:28:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH4zDz/RtXEbKd/Ytnno88MHPWhpftjvmALpqwr9xRBPT1GcMGuAAAvYJXUHSoijjqc5TON X-Received: by 2002:a05:6870:b24d:b0:1be:d9cc:d902 with SMTP id b13-20020a056870b24d00b001bed9ccd902mr8225372oam.57.1695364101400; Thu, 21 Sep 2023 23:28:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695364101; cv=none; d=google.com; s=arc-20160816; b=en3EhqPRqljAMOy+l9MRK0KirWOj8vUR6+HjHzCxMPSNSCY3xd2Eth6S6JBWzDWqYA gRkbZXPMIz4sL3OyC/GenfhlDvfuVKzhfK1vShJDaLGDdTtwu2B8ivdMZypheCGT/PxS ytYJCS7qaTDCdCun7vlHhFxbggoiMBDszU07I3gsTAogrQ+Yg+z8fkokuRtUDRDwJt/W qsTarP3eU+X3qXl0amIbmX5Wd97bjRSOByAHJ45ol4I3Mb5bWOFljxH9tG0Z23wcx00Q 1jh3ovZe9PXDHe+Evvq2cUKJTKx7XYPEtrLcYerisHr7chChIff7n+DgvYcFOcONPTrl +mxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=NnqOeIozWLoSx9J0xtQeCKdqhemo3EjzKycC15MNaXI=; fh=E9hTE6OAcCscVUxqzvM4R3IVrsSe3HooEIYtjbefn7I=; b=bf4WZlhd+23W+euQDrjDDQJBloKxlumlNUPUR4wKK+xQVr7NHNlU9PODR3O8Yw0F8O S22SrgBLV7vhVSpj+u65X65clZjackkZeY0D/TMNMBGg/uMqyNILinaEIj2j9Idyhv+b UMsYlaccwwNLJYX1RdrAEK5vN/oBADkfkL0C6FOIzduSj++hzIBTPkbsE8Z2emLvu8ee YAznBg1ElGB/Mh3tyr5SxAS3GCNE54YLHJCFWDzTNGH1Rww2SSF2Alx9NAW/J9R+HjiP /ayFQ5L3DHKhoW0z2ftZDP0AMVuS8TlOToLTcS590fN9SWRJwHyYKUdNG92n5tgjZCml GIKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=SzKDMcCN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id w64-20020a638243000000b00578a2db484esi3113667pgd.248.2023.09.21.23.28.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 23:28:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=SzKDMcCN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id A07EE8040ED1; Wed, 20 Sep 2023 10:55:59 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229606AbjITRz7 (ORCPT + 99 others); Wed, 20 Sep 2023 13:55:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229541AbjITRz6 (ORCPT ); Wed, 20 Sep 2023 13:55:58 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1215ACF for ; Wed, 20 Sep 2023 10:55:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695232507; 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=NnqOeIozWLoSx9J0xtQeCKdqhemo3EjzKycC15MNaXI=; b=SzKDMcCNnBBP6byCzE2SirR83Sn6/tTo6qEk0byuZHezX5Sv9AN+4nKmL/sIZDvJlgdGJs H0R64p7wYptixyOx9rgL4GzGBr/H07NpCQevtkJkLNHgUrQLD3SSUjkRfFRpBFg0Yxwase dwKc2S6KA2/NgZZcnSbD5ZBbirOKUww= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-90-n8Hv9srlNnC_zxzHJ6YXdw-1; Wed, 20 Sep 2023 13:55:05 -0400 X-MC-Unique: n8Hv9srlNnC_zxzHJ6YXdw-1 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-320004980a2so63234f8f.1 for ; Wed, 20 Sep 2023 10:55:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695232504; x=1695837304; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=NnqOeIozWLoSx9J0xtQeCKdqhemo3EjzKycC15MNaXI=; b=lirQsRZxFcAVbygvATNMl2CPuUSoWGV01cTNPiORrHdHVWU3joAXVFYlFIepBC30Ea J3MV08yZCPjq9xqkInj7Id5ZOGH5jujUfl13RVHcxrhjcW2OWLiR7b575vYO+20CWhdl P7VprGfGanlnb+Ph8ej1N6d1CXwqLPCZPE2y+eB4BGKcFrios8sSvPO0geHTX7ASQ7dQ p3qMpZTOyjG0B/VIhbK2iliq4s4oUzVD9t5fyLsn/g3jlm4jJ8HoQZ6lO6fIfFN3P78d abROylD9OmB83dWw4Wo/T7EJwJqp9mxMB7y2zjIk211ysiPu+C4PEPmO2+vHg7pKXWZU gIwA== X-Gm-Message-State: AOJu0YwmhR9IlGQQdZTl8J5q3DYqcOt0cdyJWzVPHOu1QuQ/6xi6KVCk /dmYL42gn7XC6oj1SaW9x5QA80P/L/wN3ua3cUhVdUm5xjeHRBFggvEPmmnjP0Cke6QJO7RfxiA 0F/J6oWypdUvNUEPV9ae2VwW+ X-Received: by 2002:adf:ee88:0:b0:313:ecd3:7167 with SMTP id b8-20020adfee88000000b00313ecd37167mr2737757wro.42.1695232504611; Wed, 20 Sep 2023 10:55:04 -0700 (PDT) X-Received: by 2002:adf:ee88:0:b0:313:ecd3:7167 with SMTP id b8-20020adfee88000000b00313ecd37167mr2737745wro.42.1695232504286; Wed, 20 Sep 2023 10:55:04 -0700 (PDT) Received: from ?IPV6:2001:b07:6468:f312:9af8:e5f5:7516:fa89? ([2001:b07:6468:f312:9af8:e5f5:7516:fa89]) by smtp.googlemail.com with ESMTPSA id w11-20020a5d608b000000b0031ad5fb5a0fsm10876963wrt.58.2023.09.20.10.55.00 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 20 Sep 2023 10:55:03 -0700 (PDT) Message-ID: <26b92bbb-0519-8b94-07fc-75d900fde600@redhat.com> Date: Wed, 20 Sep 2023 19:54:59 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH v10 34/38] KVM: VMX: Call fred_entry_from_kvm() for IRQ/NMI handling Content-Language: en-US To: Xin Li , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-edac@vger.kernel.org, linux-hyperv@vger.kernel.org, kvm@vger.kernel.org, xen-devel@lists.xenproject.org Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, luto@kernel.org, seanjc@google.com, peterz@infradead.org, jgross@suse.com, ravi.v.shankar@intel.com, mhiramat@kernel.org, andrew.cooper3@citrix.com, jiangshanlai@gmail.com References: <20230914044805.301390-1-xin3.li@intel.com> <20230914044805.301390-35-xin3.li@intel.com> From: Paolo Bonzini In-Reply-To: <20230914044805.301390-35-xin3.li@intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 20 Sep 2023 10:55:59 -0700 (PDT) On 9/14/23 06:48, Xin Li wrote: > When FRED is enabled, call fred_entry_from_kvm() to handle IRQ/NMI in > IRQ/NMI induced VM exits. > > Tested-by: Shan Kang > Signed-off-by: Xin Li Acked-by: Paolo Bonzini > --- > arch/x86/kvm/vmx/vmx.c | 12 +++++++++--- > 1 file changed, 9 insertions(+), 3 deletions(-) > > diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c > index 72e3943f3693..db55b8418fa3 100644 > --- a/arch/x86/kvm/vmx/vmx.c > +++ b/arch/x86/kvm/vmx/vmx.c > @@ -38,6 +38,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -6962,14 +6963,16 @@ static void handle_external_interrupt_irqoff(struct kvm_vcpu *vcpu) > { > u32 intr_info = vmx_get_intr_info(vcpu); > unsigned int vector = intr_info & INTR_INFO_VECTOR_MASK; > - gate_desc *desc = (gate_desc *)host_idt_base + vector; > > if (KVM_BUG(!is_external_intr(intr_info), vcpu->kvm, > "unexpected VM-Exit interrupt info: 0x%x", intr_info)) > return; > > kvm_before_interrupt(vcpu, KVM_HANDLING_IRQ); > - vmx_do_interrupt_irqoff(gate_offset(desc)); > + if (cpu_feature_enabled(X86_FEATURE_FRED)) > + fred_entry_from_kvm(EVENT_TYPE_EXTINT, vector); > + else > + vmx_do_interrupt_irqoff(gate_offset((gate_desc *)host_idt_base + vector)); > kvm_after_interrupt(vcpu); > > vcpu->arch.at_instruction_boundary = true; > @@ -7262,7 +7265,10 @@ static noinstr void vmx_vcpu_enter_exit(struct kvm_vcpu *vcpu, > if ((u16)vmx->exit_reason.basic == EXIT_REASON_EXCEPTION_NMI && > is_nmi(vmx_get_intr_info(vcpu))) { > kvm_before_interrupt(vcpu, KVM_HANDLING_NMI); > - vmx_do_nmi_irqoff(); > + if (cpu_feature_enabled(X86_FEATURE_FRED)) > + fred_entry_from_kvm(EVENT_TYPE_NMI, NMI_VECTOR); > + else > + vmx_do_nmi_irqoff(); > kvm_after_interrupt(vcpu); > } >