From patchwork Fri Jan 6 08:55:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Xin3" X-Patchwork-Id: 40019 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp728091wrt; Fri, 6 Jan 2023 01:21:59 -0800 (PST) X-Google-Smtp-Source: AMrXdXvNBo9ZYHuqxKhj1R6EuC2k+hsrNHGse1FrArUJbrqyjo9FYjE6ydXIVtdCqHwMji9tdyZd X-Received: by 2002:a17:907:6f18:b0:837:3ed3:9c2b with SMTP id sy24-20020a1709076f1800b008373ed39c2bmr52180264ejc.5.1672996918957; Fri, 06 Jan 2023 01:21:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672996918; cv=none; d=google.com; s=arc-20160816; b=jH7qkv+7RzHbxuLmn/aMe88FRf8CyT61HQioBlOED8IccJXpTLVGGrTd3UhKzWk5kP di3QUefx7vDpByIwnBh9uLc/yAYj+DJThj4hLehWMsLkalN7VtHr5xsZrmFqcP4uiHeJ RbVd6UBW+8SHLMVWgSIH0UWWS99YYNAIeLMCNsCrxN4qHruUfSptTo4a2clXbwySFD8r v3EMgEFnElBRh55mM1luIWcbhEVSXU3NzQVmcWXcWTp3MpA+B7suckdJqZK0oCxreBHf YT6QkgHQW8s03D/mo2Gdh7YsBpE5XkQT31tmTtWxKyQJlfVtwCdtfJF/v3vCMaw2TFk+ 23RQ== 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=U8ItsaLXn60+CxvHZ/hYOiugu2KYKZAus2YWNCLQhrw=; b=jQdRaEBM+jjAyhDz7YWzWS2nXQkYRDEO3RKxxvmo9c0X3wDO6BVpM9JefztyS5/a5x s2DRQ/7pGw4TEtRIfww2hVcxeKTIe6zqtKuFKUaMBZaJBVo+PHF4cYptFoC8VU/Z83ku CFSsdbwQ3B7+jQi5J0gVFTvaXc5B8aJwmfzl7WFU9PTnqBhte9JY09KaGksXCBzhUuvM qNVKkPqUs7+al2l9g777CqgcSK25wM+bT2ToN/0Jwe96hshpcQRlb87DO/OUHsbhnW0P 79bKUbxTeKFm+bVQiB3Zf+y6t3INZX97i44qFyqkIG830z4hVfTIesz1jWEV0yR7F8Vs IDQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Y781nNFP; 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 ft31-20020a170907801f00b007c1745249a1si557549ejc.944.2023.01.06.01.21.32; Fri, 06 Jan 2023 01:21:58 -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=Y781nNFP; 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 S232757AbjAFJUn (ORCPT + 99 others); Fri, 6 Jan 2023 04:20:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232920AbjAFJUR (ORCPT ); Fri, 6 Jan 2023 04:20:17 -0500 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F32ED6B5DB; Fri, 6 Jan 2023 01:20:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1672996815; x=1704532815; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=b2h40hZlbzAYlSPYHfekdfFFlQufXWZBJiq+lRFxfWo=; b=Y781nNFPzv3PHOj9/ja92AZCyfGbEc6n0QQm07Rkv9gbKSnhLc9W4kjD xel75T7hb+LrKAgTqkdGDkYj79W2KI3CfDdABM4WQp2xcCpWGh83YvPJU GQW5FKR7ikIzoL1a5UmXIRGZPoq9UkPr+bzGHqPVYeZhc5K8PhnfNtNCI InMppAnDEvb4UZzDGN6AE+NL27RecCue/n6bSmrfb7TFxWUQx23tsYiu3 T62Q+/JzbzGguoArPQDNimqQeZBANTveMYwieoEj3CW5+uqaSGp3quy67 WctsxHdCGr1BU9zJAyTSId5ZzAksP684Nho519E6krrbMz35gk5G7r1q8 A==; X-IronPort-AV: E=McAfee;i="6500,9779,10581"; a="322511417" X-IronPort-AV: E=Sophos;i="5.96,304,1665471600"; d="scan'208";a="322511417" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jan 2023 01:20:12 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10581"; a="719139356" X-IronPort-AV: E=Sophos;i="5.96,304,1665471600"; d="scan'208";a="719139356" Received: from unknown (HELO fred..) ([172.25.112.68]) by fmsmga008.fm.intel.com with ESMTP; 06 Jan 2023 01:20:12 -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 v2 05/32] x86/traps: add exc_raise_irq() for VMX IRQ reinjection Date: Fri, 6 Jan 2023 00:55:50 -0800 Message-Id: <20230106085617.17248-6-xin3.li@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230106085617.17248-1-xin3.li@intel.com> References: <20230106085617.17248-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, 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?1754264417211118182?= X-GMAIL-MSGID: =?utf-8?q?1754264417211118182?= To eliminate dispatching IRQ through the IDT, add exc_raise_irq(), which calls external_interrupt() for IRQ reinjection. Signed-off-by: Xin Li --- arch/x86/include/asm/traps.h | 2 ++ arch/x86/kernel/traps.c | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/arch/x86/include/asm/traps.h b/arch/x86/include/asm/traps.h index 46f5e4e2a346..366b1675c033 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 exc_raise_irq(struct pt_regs *regs, u32 vector); + #endif /* _ASM_X86_TRAPS_H */ diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c index c35dd2b4d146..99386836b02e 100644 --- a/arch/x86/kernel/traps.c +++ b/arch/x86/kernel/traps.c @@ -1536,6 +1536,24 @@ 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. + */ +int exc_raise_irq(struct pt_regs *regs, u32 vector) +{ + return external_interrupt(regs, vector); +} +EXPORT_SYMBOL_GPL(exc_raise_irq); +#endif + void __init trap_init(void) { /* Init cpu_entry_area before IST entries are set up */