[v4,33/34] KVM: x86/vmx: call external_interrupt() for IRQ reinjection when FRED is enabled
Message ID | 20230302052511.1918-34-xin3.li@intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp4067596wrd; Wed, 1 Mar 2023 22:05:36 -0800 (PST) X-Google-Smtp-Source: AK7set81fQF2Yoa9njVb2phjnv4xjA5UOMvhNka4YogsQFsCC8Lc/9EICr3x43sOuIrsJwZi6v8P X-Received: by 2002:a17:90b:38c7:b0:236:704d:ab8c with SMTP id nn7-20020a17090b38c700b00236704dab8cmr10167514pjb.26.1677737136558; Wed, 01 Mar 2023 22:05:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677737136; cv=none; d=google.com; s=arc-20160816; b=zkp19tIPVL7KdKwG+Ht1cJh3Y69q4JQpKXxpOrVmzSulreMGR++YaQMilahu1AaaGt gbTsI8wJn+PpSvvSz3KkajAQ/EjDZKmUXStBUcHMxG/Gdoal7QrmowIBgbXjhrA9bi66 E5/bkmFNI6CWgaD7UNGC/Vph4QO1720w2MiXrMRjOWzaiGAHun5pdD/1s69pzRYaNbmd r+7QGR0Tx9GvN2THYyYLCY4eINTIVRo79EZMgKsOvbtrddv1meuCnY2bQE6LaLNxw2lv 9UksWCOO20eb1ZxUuuNyH5oLd5ca2dUZr1eHd8TLT2aZh8a4MYOfs/SQ1P8uvuPc6kgN du1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=SqHjZXDgyS1oVc60Lvg2+40vBxpCajlVSkR5hchHg+Q=; b=R16LLDB2Hj1ApXP+SVX8kuCxDWqdfuzqssuCFvyDJkMMXOCXuXCLOfPZf67PkakaCr tCy9So+GrwizAd+xn0/oy67YXgE1OjxttmH76sXRh5B5H6i3STK3ekF3rk0V8LDfhHm7 D+ayktagicuoccZTpvgVLQnygRF8bfKvUhgcrjGTu5oCZvZIR+RDLoQXZOu5Qb3onDIR FjkBHldWP7q0qtLyP0QvoHbVSqcLa5JQRerrlO/gIe5M18W122/7IU6i7WUOKbsUFy9r cG4HoQFuBk6nFRa/OM6w1IG/2O+DC3HXcwV5zys6IwbKlaYywj3QS+/Grm6dKMtBj6IN 5egA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Swxnp4HC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 11-20020a17090a004b00b0021918bc9a47si1391517pjb.174.2023.03.01.22.05.22; Wed, 01 Mar 2023 22:05:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Swxnp4HC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229982AbjCBFxL (ORCPT <rfc822;davidbtadokoro@gmail.com> + 99 others); Thu, 2 Mar 2023 00:53:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46464 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229910AbjCBFwp (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 2 Mar 2023 00:52:45 -0500 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 513B14BE9D; Wed, 1 Mar 2023 21:51:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1677736298; x=1709272298; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=RB+pcoV+8WefgwtLPP9+JmvXNsCQtNuVUpY6dnzCLDE=; b=Swxnp4HCb91tti4020hv6rCY46wgARud6jyH+qTRuPT64oW1y3CdwNzL XuogKFv7751KYpgY7olljw5k5I9EA0p8l9/Jt48CzCzgyfgTdEomFeSuR nN8zb8hbxLP/D3JBgsIXlmqE9l80khtINTXnKBiA7Iy1rOgPA3Aewnjlu QNl/ytgKDyoG2s0/zT+AJgGe2nIb6qqRVm/oO+OomLBO4zZlxqNKSLOi5 LQJdtQvXC9nz9R+Di6tGy0jud/4Y0ldAi6mW0//J+YPanqK9xhhPQ6WZE isreuOdhxkltPB2NcxhFwWSQFriTYA0rOU7HBJeVmN+mou2U2WTPUvyUR A==; X-IronPort-AV: E=McAfee;i="6500,9779,10636"; a="420887332" X-IronPort-AV: E=Sophos;i="5.98,226,1673942400"; d="scan'208";a="420887332" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Mar 2023 21:50:52 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10636"; a="920530983" X-IronPort-AV: E=Sophos;i="5.98,226,1673942400"; d="scan'208";a="920530983" Received: from unknown (HELO fred..) ([172.25.112.68]) by fmsmga006.fm.intel.com with ESMTP; 01 Mar 2023 21:50:52 -0800 From: Xin Li <xin3.li@intel.com> To: linux-kernel@vger.kernel.org, x86@kernel.org, kvm@vger.kernel.org Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, peterz@infradead.org, andrew.cooper3@citrix.com, seanjc@google.com, pbonzini@redhat.com, ravi.v.shankar@intel.com Subject: [PATCH v4 33/34] KVM: x86/vmx: call external_interrupt() for IRQ reinjection when FRED is enabled Date: Wed, 1 Mar 2023 21:25:10 -0800 Message-Id: <20230302052511.1918-34-xin3.li@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230302052511.1918-1-xin3.li@intel.com> References: <20230302052511.1918-1-xin3.li@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759234895282555515?= X-GMAIL-MSGID: =?utf-8?q?1759234895282555515?= |
Series |
x86: enable FRED for x86-64
|
|
Commit Message
Li, Xin3
March 2, 2023, 5:25 a.m. UTC
When FRED is enabled, IDT is gone, thus call external_interrupt() for IRQ reinjection. Create an event return stack frame with the host context immediately after a VM exit for calling external_interrupt(). All other fields of the pt_regs structure are cleared to 0. Refer to the discussion about the register values in the pt_regs structure at: https://lore.kernel.org/kvm/ef2c54f7-14b9-dcbb-c3c4-1533455e7a18@redhat.com/ Tested-by: Shan Kang <shan.kang@intel.com> Signed-off-by: Xin Li <xin3.li@intel.com> --- arch/x86/kvm/vmx/vmx.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-)
Comments
> arch/x86/kvm/vmx/vmx.c | 22 +++++++++++++++++++++- > 1 file changed, 21 insertions(+), 1 deletion(-) > > diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index > bcac3efcde41..30f854015c8c 100644 > --- a/arch/x86/kvm/vmx/vmx.c > +++ b/arch/x86/kvm/vmx/vmx.c > @@ -47,6 +47,7 @@ > #include <asm/mshyperv.h> > #include <asm/mwait.h> > #include <asm/spec-ctrl.h> > +#include <asm/traps.h> > #include <asm/virtext.h> > #include <asm/vmx.h> > > @@ -6923,7 +6924,26 @@ static void handle_external_interrupt_irqoff(struct > kvm_vcpu *vcpu) > return; > > kvm_before_interrupt(vcpu, KVM_HANDLING_IRQ); > - vmx_do_interrupt_irqoff(gate_offset(desc)); > + if (cpu_feature_enabled(X86_FEATURE_FRED)) { > + struct vcpu_vmx *vmx = to_vmx(vcpu); > + struct pt_regs regs = {}; > + > + /* > + * Create an event return stack frame with the > + * host context immediately after a VM exit. > + * > + * All other fields of the pt_regs structure are > + * cleared to 0. > + */ > + regs.ssx = __KERNEL_DS; This breaks i386 build, and should use ss. > + regs.sp = vmx->loaded_vmcs->host_state.rsp; > + regs.flags = X86_EFLAGS_FIXED; > + regs.csx = __KERNEL_CS; And cs. > + regs.ip = (unsigned long)vmx_vmexit; > + > + external_interrupt(®s, vector); > + } else > + vmx_do_interrupt_irqoff(gate_offset(desc)); > kvm_after_interrupt(vcpu); > > vcpu->arch.at_instruction_boundary = true; > -- > 2.34.1
diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index bcac3efcde41..30f854015c8c 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -47,6 +47,7 @@ #include <asm/mshyperv.h> #include <asm/mwait.h> #include <asm/spec-ctrl.h> +#include <asm/traps.h> #include <asm/virtext.h> #include <asm/vmx.h> @@ -6923,7 +6924,26 @@ static void handle_external_interrupt_irqoff(struct kvm_vcpu *vcpu) return; kvm_before_interrupt(vcpu, KVM_HANDLING_IRQ); - vmx_do_interrupt_irqoff(gate_offset(desc)); + if (cpu_feature_enabled(X86_FEATURE_FRED)) { + struct vcpu_vmx *vmx = to_vmx(vcpu); + struct pt_regs regs = {}; + + /* + * Create an event return stack frame with the + * host context immediately after a VM exit. + * + * All other fields of the pt_regs structure are + * cleared to 0. + */ + regs.ssx = __KERNEL_DS; + regs.sp = vmx->loaded_vmcs->host_state.rsp; + regs.flags = X86_EFLAGS_FIXED; + regs.csx = __KERNEL_CS; + regs.ip = (unsigned long)vmx_vmexit; + + external_interrupt(®s, vector); + } else + vmx_do_interrupt_irqoff(gate_offset(desc)); kvm_after_interrupt(vcpu); vcpu->arch.at_instruction_boundary = true;