Message ID | 20221110061545.1531-5-xin3.li@intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp760182wru; Wed, 9 Nov 2022 22:40:50 -0800 (PST) X-Google-Smtp-Source: AMsMyM73hM5+tSICDmB6uhE8hCrH//n8j3BB9xyJE0SGpYQm8M8Pnuq06vBLT3/YxkDnHD6nXACm X-Received: by 2002:a50:d71a:0:b0:458:e445:992c with SMTP id t26-20020a50d71a000000b00458e445992cmr1719843edi.417.1668062450785; Wed, 09 Nov 2022 22:40:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668062450; cv=none; d=google.com; s=arc-20160816; b=iGEE9pvkVBQ2+Wc4B9GIWpmed7BwJZun3Rj9+Oqc9x0qd87j7UB0b1veDqc4eRRd+X vfRRSMZHj7ycHhTm7u0l2zSoLuIAFZrItlzw1F5hjL/2A4K/AuovwbqqrvtDFJxCri93 e83SrkcOq14Ih0KzjAaC3Y6Kv1rOesjbWvpHp2Kx4xc51QyB8ZhQX2ZnI1l0yPmNqyFX tiZzJEgU4ct9Muy+Jj88v85b578+vi8lD+PA1pxEiVDvOUYDZ6C2bqcwJ8HmGlp4u9zp 2zhnPq4f2yzs2swt+iSK/KDgbPf5D/uSbnZkaDIG2A2NHxPhDGhYRxRZsC5MPNQZSFAe uJ4A== 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=wUIZ119WF10QK2/6t2FvQiNCsFoXJESZSw9TTr/xs1I=; b=FfnVybldqbUevxMbBOfHqvPxl/JZAoVVW/txsby2Umyej8hxez7LQlmnVzZ6bg/FjO 2S6BfZ50zb2jW7mocF/6o/jTiRm2oEI/vNHnMPwEj6ejUYLNeKoBpiLlTTOpYCU4YBMq GTGf1bxBYNpZItzFLJP6F49TRHy6op54xvPvkf+TlPFFdYMBg99924Lk8zeNjFVaJ6Jo loVOMCi1yePXLafJPGMPSuJKWlzllUURbApKGEanAwgu6c5kXPtz4IBVXPa9iagARB23 ekTzzY+z42XRbSXnoZ9laoH3PuqrtjAnRjvDXt3/oEHOUYuVkw+7leN56IJavEqBxPcT 4uxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=fuHH37zA; 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 b11-20020a056402278b00b0045ca3839229si21241964ede.274.2022.11.09.22.40.27; Wed, 09 Nov 2022 22:40:50 -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=fuHH37zA; 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 S232589AbiKJGje (ORCPT <rfc822;dexuan.linux@gmail.com> + 99 others); Thu, 10 Nov 2022 01:39:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232560AbiKJGj2 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 10 Nov 2022 01:39:28 -0500 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F11FA2A94F; Wed, 9 Nov 2022 22:39:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1668062363; x=1699598363; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Oc0mQKbv3vl2yWZXC3YWNJd1AfkG2RvOnJu/bF1aWjE=; b=fuHH37zAkdJQrJAzoNSJWpN/L1cY1vNCU+UvuRAliNUEsvlj+HL8gVkt AHAclFPQQQ+gpM1AKS1j0x0BHgyGey7dfgl15IJTLU6oQxKwYePndnSbm hnRWgV/JiABXdArZ17Qyt9DYV46vdv0JO8H3GUyoKhsn564PGoZaZ3vw4 vviw2c9QaQahJqqSmtZOOzezVyTVsZw2FchejMpzIMB2+Utt90tr62Kxj GSO2oFN3J7d7qBrtNdSscmA+s/ztJpMEOO4GhShjE2XU2HhDJ9h8f+BLB hCgq2LbL5WNz+88bTXiBfMCeoTNBKPB7LbRp4tQzN2Aea/EOZ4hrRUYTh w==; X-IronPort-AV: E=McAfee;i="6500,9779,10526"; a="375474007" X-IronPort-AV: E=Sophos;i="5.96,153,1665471600"; d="scan'208";a="375474007" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Nov 2022 22:39:22 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10526"; a="588057232" X-IronPort-AV: E=Sophos;i="5.96,153,1665471600"; d="scan'208";a="588057232" Received: from unknown (HELO fred..) ([172.25.112.68]) by orsmga003.jf.intel.com with ESMTP; 09 Nov 2022 22:39:21 -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, seanjc@google.com, pbonzini@redhat.com, kevin.tian@intel.com Subject: [RESEND PATCH 4/6] x86/traps: add external_interrupt() to dispatch external interrupts Date: Wed, 9 Nov 2022 22:15:43 -0800 Message-Id: <20221110061545.1531-5-xin3.li@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221110061545.1531-1-xin3.li@intel.com> References: <20221110061545.1531-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?1749090252597997579?= X-GMAIL-MSGID: =?utf-8?q?1749090252597997579?= |
Series |
x86/traps,VMX: implement software based NMI/IRQ dispatch for VMX NMI/IRQ reinjection
|
|
Commit Message
Li, Xin3
Nov. 10, 2022, 6:15 a.m. UTC
Add external_interrupt() to dispatch external interrupts to their handlers. If an external interrupt is a system interrupt, dipatch it through system_interrupt_handler_table, otherwise call into common_interrupt(). Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com> Signed-off-by: Xin Li <xin3.li@intel.com> --- arch/x86/kernel/traps.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
Comments
On Wed, Nov 09, 2022, Xin Li wrote: > +__visible noinstr void external_interrupt(struct pt_regs *regs, > + unsigned int vector) > +{ > + unsigned int sysvec = vector - FIRST_SYSTEM_VECTOR; > + > + BUG_ON(vector < FIRST_EXTERNAL_VECTOR); Why not return an error up the stack? KVM and/or CPU bugs aren't unheard of. Dropping an IRQ obviously isn't ideal, but there's a non-zero chance that letting KVM WARN and kill the VM will keep the host alive and thus other VMs running. A somewhat sophisticated setup might even react to the VM being killed by migrating other VMs off the system and initiating host maintenance.
> > +__visible noinstr void external_interrupt(struct pt_regs *regs, > > + unsigned int vector) > > +{ > > + unsigned int sysvec = vector - FIRST_SYSTEM_VECTOR; > > + > > + BUG_ON(vector < FIRST_EXTERNAL_VECTOR); > > Why not return an error up the stack? KVM and/or CPU bugs aren't unheard > of. > Dropping an IRQ obviously isn't ideal, but there's a non-zero chance that letting > KVM WARN and kill the VM will keep the host alive and thus other VMs > running. A somewhat sophisticated setup might even react to the VM being > killed by migrating other VMs off the system and initiating host maintenance. Make sense. What about having it return a signed integer?
On Thu, Nov 10, 2022, Li, Xin3 wrote: > > > +__visible noinstr void external_interrupt(struct pt_regs *regs, > > > + unsigned int vector) > > > +{ > > > + unsigned int sysvec = vector - FIRST_SYSTEM_VECTOR; > > > + > > > + BUG_ON(vector < FIRST_EXTERNAL_VECTOR); > > > > Why not return an error up the stack? KVM and/or CPU bugs aren't unheard > > of. > > Dropping an IRQ obviously isn't ideal, but there's a non-zero chance that letting > > KVM WARN and kill the VM will keep the host alive and thus other VMs > > running. A somewhat sophisticated setup might even react to the VM being > > killed by migrating other VMs off the system and initiating host maintenance. > > Make sense. > > What about having it return a signed integer? Ya, the standard 0/-errno will do nicely.
diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c index 9c7826e588bc..c1eb3bd335ce 100644 --- a/arch/x86/kernel/traps.c +++ b/arch/x86/kernel/traps.c @@ -1507,6 +1507,27 @@ void __init install_system_interrupt_handler(unsigned int n, const void *asm_add alloc_intr_gate(n, asm_addr); } +/* + * External interrupt dispatch function. + * + * Until/unless common_interrupt() can be taught to deal with the + * special system vectors, split the dispatch. + * + * Note: common_interrupt() already deals with IRQ_MOVE_CLEANUP_VECTOR. + */ +__visible noinstr void external_interrupt(struct pt_regs *regs, + unsigned int vector) +{ + unsigned int sysvec = vector - FIRST_SYSTEM_VECTOR; + + BUG_ON(vector < FIRST_EXTERNAL_VECTOR); + + if (sysvec < NR_SYSTEM_VECTORS) + return system_interrupt_handler_table[sysvec](regs, vector); + + common_interrupt(regs, vector); +} + void __init trap_init(void) { /* Init cpu_entry_area before IST entries are set up */