From patchwork Fri Feb 24 07:01:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Xin3" X-Patchwork-Id: 61147 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp756102wrd; Thu, 23 Feb 2023 23:29:03 -0800 (PST) X-Google-Smtp-Source: AK7set8yp+h+kWxgNuLe4eqdL/1tMRe4f9fdwdAJZBR76YHzBSxpomiKQWLzCc+VnBYMGYo/b1Of X-Received: by 2002:a17:906:9bc3:b0:8a5:3d1e:6302 with SMTP id de3-20020a1709069bc300b008a53d1e6302mr21033451ejc.56.1677223743619; Thu, 23 Feb 2023 23:29:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677223743; cv=none; d=google.com; s=arc-20160816; b=EK7BUo4dV4DvkgqJHIoXG6aV0CmijG4X591RJ9AX5tt/8HHQobucZJ5+/tcjfqOfQB iTjLJLrzNvYFsfCi5uw6NVXv/amJUeig8H9v4TvMn6JHV0WKdOH5QCrnJq0Ga6Nwr0dT TsJKC3022sVbNNCJWj1Bx7FF4f16aEv+urlom98+XiLqhqoXXPhUQmZykdbMO8fBkMh1 mPjsne7yDbh1D7BweWATsIYiJ7YLvX1PRHM3JnL5vvph7KKnkJt/A6mWQkhStwrpCz1e L9pkgb72l/ZACZqSucJI26nzdwGGMECpnKhwNzARlyY2GVXkFc2duYF0S/Bd9TYPVc/Z 3fsw== 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=vxvM33R06ENED5vY5yl9XKwLxS74+dWqc3NhpufiffY=; b=jPx8PUAd067OHksq67bd9p2eFJut/9Wo/xSeiDPhmyeAbuaN3+T5oKsWvVricWW6Aw DG4aeKWdr+Swd+Fh2/aC1+gXrSmdyKJ8x/VJdZgOm1GizaZlgNHIUd2HaF/lejSGjGfF idYWqi+vjZ4LHURWwrvjx1AvmbCFFMpRQMUjzKKR5XGZvEDQCpjmoVVRf7Zv48/sn7Yb hAXVXtQTNYyIwA6uuqaxHA2Lt8xSTodDw8YrOFJqkz8REbwbfYZXDH3S0xpAtyr4aSHB LrOIvOrw5nBhizHKKmCY8Jsh7JpklPV2RksLG4PWUlU3yXzbH2PFnWOQkpJErOqV3NwQ deyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Tp63Vz3g; 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 22-20020a170906019600b008ddf3c182fesi12930823ejb.313.2023.02.23.23.28.39; Thu, 23 Feb 2023 23:29:03 -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=Tp63Vz3g; 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 S229866AbjBXH2Q (ORCPT + 99 others); Fri, 24 Feb 2023 02:28:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229785AbjBXH2A (ORCPT ); Fri, 24 Feb 2023 02:28:00 -0500 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0475865AD; Thu, 23 Feb 2023 23:27:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1677223675; x=1708759675; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5ojl4mrz7EluvMPfPkXTnSlfudBddxu4Pmb5fcSRBp4=; b=Tp63Vz3gpKZhF217zJNL3ZZ6XzIRQ0GD+MZOhoYw0XZIPXlNh/vdLLjP wf1M4gksykRmZ/m0jCBV6r4RJfCyOybh1ap6/I85Rtp6NOYZU2vq75+LF yPTfBbkM7PbpztJyyHMck0kbE6jp/AzswcQ6GajRpS5pf0H19QPMT2ETD EPuw9uBJj5sfv4jv/n8+6v5liiJDTpTlBmZs/bPhNzGlv4l7Z/HnlnotQ HKQMRr3xraXQC0nEDio/o7+kyeR4ywSy1wCXY4XsbkJTQWml6hTfYnEpa gHP+k1ed3AFa1y6RqncyA5IWkq+j+mo1NKzeO+h9lnqwmw/Ju1gb2ufsH g==; X-IronPort-AV: E=McAfee;i="6500,9779,10630"; a="334835959" X-IronPort-AV: E=Sophos;i="5.97,324,1669104000"; d="scan'208";a="334835959" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Feb 2023 23:27:21 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10630"; a="815639200" X-IronPort-AV: E=Sophos;i="5.97,324,1669104000"; d="scan'208";a="815639200" Received: from unknown (HELO fred..) ([172.25.112.68]) by fmsmga001.fm.intel.com with ESMTP; 23 Feb 2023 23:27:20 -0800 From: Xin Li 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: [RFC PATCH v3 05/32] x86/traps: export external_interrupt() for VMX IRQ reinjection Date: Thu, 23 Feb 2023 23:01:18 -0800 Message-Id: <20230224070145.3572-6-xin3.li@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230224070145.3572-1-xin3.li@intel.com> References: <20230224070145.3572-1-xin3.li@intel.com> MIME-Version: 1.0 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, 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758696564293509957?= X-GMAIL-MSGID: =?utf-8?q?1758696564293509957?= To eliminate dispatching IRQ through the IDT, export external_interrupt() for VMX IRQ reinjection. Signed-off-by: Xin Li --- arch/x86/include/asm/traps.h | 2 ++ arch/x86/kernel/traps.c | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/arch/x86/include/asm/traps.h b/arch/x86/include/asm/traps.h index 46f5e4e2a346..da4c21ed68b4 100644 --- a/arch/x86/include/asm/traps.h +++ b/arch/x86/include/asm/traps.h @@ -56,4 +56,6 @@ void __noreturn handle_stack_overflow(struct pt_regs *regs, void f (struct pt_regs *regs) typedef DECLARE_SYSTEM_INTERRUPT_HANDLER((*system_interrupt_handler)); +int external_interrupt(struct pt_regs *regs, unsigned int vector); + #endif /* _ASM_X86_TRAPS_H */ diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c index 31ad645be2fb..cebba1f49e19 100644 --- a/arch/x86/kernel/traps.c +++ b/arch/x86/kernel/traps.c @@ -1540,6 +1540,20 @@ int external_interrupt(struct pt_regs *regs, unsigned int vector) return 0; } +#if IS_ENABLED(CONFIG_KVM_INTEL) +/* + * KVM VMX reinjects IRQ on its current stack, it's a sync call + * thus the values in the pt_regs structure are not used in + * executing IRQ handlers, except cs.RPL and flags.IF, which + * are both always 0 in the VMX IRQ reinjection context. + * + * However, the pt_regs structure is sometimes used in stack + * dump, e.g., show_regs(). So let the caller, i.e., KVM VMX + * decide how to initialize the input pt_regs structure. + */ +EXPORT_SYMBOL_GPL(external_interrupt); +#endif + void __init trap_init(void) { /* Init cpu_entry_area before IST entries are set up */