From patchwork Fri Feb 24 07:01:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Xin3" X-Patchwork-Id: 61146 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp756054wrd; Thu, 23 Feb 2023 23:28:55 -0800 (PST) X-Google-Smtp-Source: AK7set+L3N3Y7fEY04ykNIO4LrGV2FtxZt40sF0BiqsBhoH0erTaPL0teYv05pflwH1Oq7F14xgK X-Received: by 2002:a05:6402:1287:b0:4ab:b0d5:6bb0 with SMTP id w7-20020a056402128700b004abb0d56bb0mr14111839edv.18.1677223735250; Thu, 23 Feb 2023 23:28:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677223735; cv=none; d=google.com; s=arc-20160816; b=cas3QTyfCHLvYkCBzD+LEfzcOTZ5bpv98dyRXOBS4cvou6afrFI43laPMPqFgFMTux t7vyyTVjQIrJUBgujQ6AYFwQD4kmCXqf+wuhYYoNwEcYxk7GB5RMsMwna280EoG3CFCG gg16wNcsYebhV7p/Md5VLc439LrRIoeweczo21svfy0jUfWn4Z3bR50P7S0Y3sB6byG5 FRbq67oDjZBsllHRkAIi8V4Ho01x/y5FVBFHqM6cXD96t4o1+xwdp6aZgJK0UeObmKZo 6B8fw9b9lSn32BhreOMW+S+b+vXTLl0tucV5Sl1dRdmpb1e0LxapfRKRgIs4Nyy/Ldkl 6aJg== 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=0mkXAJw9nAvOJT776wHuEpQBHwZigNdAo5NAWvBAxqs=; b=brkJBqQ5X7bWqqwy9Bxbmv3sbu0U0HvN86TWZzgs6FcyAk5Xfrv4WMs+qG7v9zgADN SuEv4NEGvdxtwlch28fTkHGgpQY16Hjh5a111ffYy7nVbXzPk2RhCuPPfuwK5FG8I9oM 4qrFgDRlMwabayJuTCyS743OgCEM3Kue8bjQzwf8XoVghPxmG5Tx0BR7EmgDNDPVE4Dx EvpOIZZW8hJ/+ZA+eSkPrVBi0Uzu6AjxmvlFeaOjkgTtQyEiVW48C2OIn95xqMCp1u8Q 9Qf7dmGGcDrBCPRaSBOJvS5XiL2utsENjB7Ibcrxm8qO6y+2NWN7LwaLKHnQSNE8pst+ LHBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=jPugHKnk; 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 y24-20020a50e618000000b004ad79f4686dsi15878576edm.86.2023.02.23.23.28.31; Thu, 23 Feb 2023 23:28:55 -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=jPugHKnk; 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 S229821AbjBXH2J (ORCPT + 99 others); Fri, 24 Feb 2023 02:28:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229712AbjBXH15 (ORCPT ); Fri, 24 Feb 2023 02:27:57 -0500 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24F9F63DD1; Thu, 23 Feb 2023 23:27:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1677223650; x=1708759650; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=pa/cUeOfLDEP4cCNm1hlvFI0kYRiN/TNYCvAsLAxF3I=; b=jPugHKnk4TE7Gtx3DQcFx9EeDvFRCFz/ZZyEmATFUx7tBZfTOOq9FMF1 vYufS7WkRzCH4mJoKoVsie0ixlHZVr5cUTRrVEGwHV0Ce210hWF5AaTSl bqB02dsWQAmZZkrJyMf8DFfWK9994xQFjrIb9ptJS70SdGWI2OaHXWAEy 4/PHKCcqF4qeQcr/ptxDDbfkrFhKj1gNcXDIKBysaxawsao3z8Z+xIyM8 ycajb5Eg3A4UE5mqF36nIpgKe/oRPHjbveYkE5owwA4A0j1LeG2PRaspO oGD+tHj6IotiNigX+N8lWi8zqljpH9/Cv5UllGWk0VUGIzJJKOaLAAzK+ g==; X-IronPort-AV: E=McAfee;i="6500,9779,10630"; a="334835948" X-IronPort-AV: E=Sophos;i="5.97,324,1669104000"; d="scan'208";a="334835948" 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="815639197" X-IronPort-AV: E=Sophos;i="5.97,324,1669104000"; d="scan'208";a="815639197" 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 04/32] x86/traps: add external_interrupt() to dispatch external interrupts Date: Thu, 23 Feb 2023 23:01:17 -0800 Message-Id: <20230224070145.3572-5-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?1758696555376909771?= X-GMAIL-MSGID: =?utf-8?q?1758696555376909771?= From: "H. Peter Anvin (Intel)" 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 dispatch_common_interrupt(). Signed-off-by: H. Peter Anvin (Intel) Co-developed-by: Xin Li Signed-off-by: Xin Li --- arch/x86/kernel/traps.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c index c0f7666140da..31ad645be2fb 100644 --- a/arch/x86/kernel/traps.c +++ b/arch/x86/kernel/traps.c @@ -1499,6 +1499,47 @@ void __init install_system_interrupt_handler(unsigned int n, const void *asm_add alloc_intr_gate(n, asm_addr); } +#ifndef CONFIG_X86_LOCAL_APIC +/* + * Used when local APIC is not compiled into the kernel, but + * external_interrupt() needs dispatch_spurious_interrupt(). + */ +DEFINE_IDTENTRY_IRQ(spurious_interrupt) +{ + pr_info("Spurious interrupt (vector 0x%x) on CPU#%d, should never happen.\n", + vector, smp_processor_id()); +} +#endif + +/* + * External interrupt dispatch function. + * + * Until/unless dispatch_common_interrupt() can be taught to deal with the + * special system vectors, split the dispatch. + * + * Note: dispatch_common_interrupt() already deals with IRQ_MOVE_CLEANUP_VECTOR. + */ +int external_interrupt(struct pt_regs *regs, unsigned int vector) +{ + unsigned int sysvec = vector - FIRST_SYSTEM_VECTOR; + + if (vector < FIRST_EXTERNAL_VECTOR) { + pr_err("invalid external interrupt vector %d\n", vector); + return -EINVAL; + } + + if (sysvec < NR_SYSTEM_VECTORS) { + if (system_interrupt_handlers[sysvec]) + system_interrupt_handlers[sysvec](regs); + else + dispatch_spurious_interrupt(regs, vector); + } else { + dispatch_common_interrupt(regs, vector); + } + + return 0; +} + void __init trap_init(void) { /* Init cpu_entry_area before IST entries are set up */