From patchwork Tue Apr 4 10:26:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Xin3" X-Patchwork-Id: 79015 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2949933vqo; Tue, 4 Apr 2023 04:29:08 -0700 (PDT) X-Google-Smtp-Source: AKy350Zu6sduaEQlweg3yxtDZFZNipnb/wbDs9xZyrvBUXJD2GaAOKXb5KZk6fH3YULiPW6HL+Vm X-Received: by 2002:a17:906:2897:b0:932:4990:2563 with SMTP id o23-20020a170906289700b0093249902563mr1873282ejd.24.1680607748256; Tue, 04 Apr 2023 04:29:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680607748; cv=none; d=google.com; s=arc-20160816; b=tBn9FimWuzlqq3D+mfR5BV0pO1XOYauplHE7qsdduww6F205Znx2T7Rq6zy9USxgAd +3GMywsHhvaXoKT+KnsW8IYwnPRY9tR9Sv5R5QSe1Xgg9fM5gta8lj7OKJk8FKc8eRcs NRvA8HIwkw8fH1OAMKWCfxzQmR8/fl+QvrRQvbTOnIr1idf+pYYFbKlsGb7OqZF5bHbi rovB0Silm4DrUadhY7y1r0WuAehOtB44QgeYrB1emirBX6rEgL+1zOgj+S1d478pvwK3 FYCUuUWQqfVZl3+ZVdYwfLwzi5oWuQvb5oG8HpZy+d7J3Sd5H0Cx69dhhb+hTM8tCoeP SNIw== 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=+bKyrAJ4Sg6BfMRQkBUGYsVA8R9oXuG/B40jl5jzfJ0=; b=OyJrQZntxIsqMoIGtpVczcZu/rxhGhm/HwzqJstekO9A0dfqu47s9HFA1zWjIkCJWY P21CwKAjYK1NRxAdloSRr5JaYGMSqp25O4mskB52HjvQNbHzayC9UpdTg2x0l11be8N4 kR2gKMw5EvHwDcNrO98u1q8xYy/CWRrDmYSBBf7DVM5XwdH6qoK5kEeoT4O8oiYfjJea rm82hBycRacL5K4Mg4VOyVjGzO4njw04JxydY9sEn+9BzOeBUFRmPIbwSMInvDo7sgUo SbtGhs3JdnZSTRYUM2xIzG47S8TsFD7znRS5reFE7IH6WJHdEkfFv3a0PpLJHz0siKzr +ihw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=TrenjyG3; 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 q10-20020a1709064cca00b00934e2ca8548si7269099ejt.210.2023.04.04.04.28.44; Tue, 04 Apr 2023 04:29:08 -0700 (PDT) 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=TrenjyG3; 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 S234806AbjDDKyL (ORCPT + 99 others); Tue, 4 Apr 2023 06:54:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234747AbjDDKxZ (ORCPT ); Tue, 4 Apr 2023 06:53:25 -0400 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 057371FEE; Tue, 4 Apr 2023 03:53:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1680605586; x=1712141586; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=BCbf0Vj9ZyZPtbZTSgD/ohjbP2Y9NHqyEC0o1Sj/JgM=; b=TrenjyG3RJT0DCB6/zvBjzwIods1png+u5WY8Rp0LC3xZ0b+CXPfKyUq sbdts3mpd8DXMS3DbnZ5NgD/ky3lr4Z3OHMnKKYgfGBWNqUwNXKIEIW7Z 2Bl+vIa4I/n0htiCGHYOUdqt6CTw4u7QXoOxtQgmXOC855qYqapMlXRC5 p7HL2C4Mgr9mDhBpHzP3mNptsxVPVdVGNQDU0SPRUdGXlY2xZDunIbVtq jSqrCMIbMg8uY2OWdMAGYNAfoR7X5iy2zrmjgzJRUgx15Sx4oVL0GJlQL duPg8O4aeb3BU/LSAhH7BduwE3mnLoBclVTlNDWIT5xgOWjKEJinR5P/y w==; X-IronPort-AV: E=McAfee;i="6600,9927,10669"; a="330733969" X-IronPort-AV: E=Sophos;i="5.98,317,1673942400"; d="scan'208";a="330733969" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Apr 2023 03:53:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10669"; a="775597792" X-IronPort-AV: E=Sophos;i="5.98,317,1673942400"; d="scan'208";a="775597792" Received: from unknown (HELO fred..) ([172.25.112.68]) by FMSMGA003.fm.intel.com with ESMTP; 04 Apr 2023 03:53:00 -0700 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, jiangshanlai@gmail.com, shan.kang@intel.com Subject: [PATCH v7 05/33] x86/traps: add external_interrupt() to dispatch external interrupts Date: Tue, 4 Apr 2023 03:26:48 -0700 Message-Id: <20230404102716.1795-6-xin3.li@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230404102716.1795-1-xin3.li@intel.com> References: <20230404102716.1795-1-xin3.li@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.5 required=5.0 tests=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=unavailable 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?1762244950068451948?= X-GMAIL-MSGID: =?utf-8?q?1762244950068451948?= 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_handlers table, otherwise to dispatch_common_interrupt(). Signed-off-by: H. Peter Anvin (Intel) Co-developed-by: Xin Li Tested-by: Shan Kang Signed-off-by: Xin Li --- Changes since v5: * Initialize system_interrupt_handlers with dispatch_table_spurious_interrupt() instead of NULL to get rid of a branch (Peter Zijlstra). --- arch/x86/kernel/traps.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c index 12072e2af4a6..f86cd233b00b 100644 --- a/arch/x86/kernel/traps.c +++ b/arch/x86/kernel/traps.c @@ -1511,6 +1511,32 @@ static system_interrupt_handler system_interrupt_handlers[NR_SYSTEM_VECTORS] = { #undef SYSV +/* + * 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 = regs->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) + system_interrupt_handlers[sysvec](regs); + else + dispatch_common_interrupt(regs, vector); + + return 0; +} + #endif /* CONFIG_X86_64 */ void __init install_system_interrupt_handler(unsigned int n, const void *asm_addr, const void *addr)