From patchwork Mon Jul 31 06:41:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Xin3" X-Patchwork-Id: 13333815 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0C306C04FDF for ; Mon, 31 Jul 2023 07:12:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231373AbjGaHMS (ORCPT ); Mon, 31 Jul 2023 03:12:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229718AbjGaHMD (ORCPT ); Mon, 31 Jul 2023 03:12:03 -0400 Received: from mgamail.intel.com (unknown [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E0F130D4; Mon, 31 Jul 2023 00:09:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1690787397; x=1722323397; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=Aa5CvA7MmnPHyksJQgqEteFVOvaio1lA17Ke5qS+vL0=; b=AbdaPJ+VIc7cPfldf602/AZUYaW7Unuiw0w18eM/ivyOPxxIEicCESIQ zltxFd6hK6QC8vVXIPJL0bLwZQfDiqloZoVV2zxeFEqjG2Zxzc9E4R5xy sT8YBCEJTEX9wZLBTxXEYNYmtSBmYCqMYo/bRkeKJOzb1G6OXTe/1fRee PcqDvC+XK92gmvRDHDApoFBmTy+p9PyrChzVMQjP1aBH4IB5lyfnEOGS3 wUirEAMdbNJysaCYMYFnEAi1CDCsJfUxZjpjorzGOZTBLKO0gH4rxDrCS sTY08frLXJ/RsSTxNvEq4asKuE5jCt1eZ5IACI2V8+hvdE+7wbTExSirp w==; X-IronPort-AV: E=McAfee;i="6600,9927,10787"; a="432749914" X-IronPort-AV: E=Sophos;i="6.01,244,1684825200"; d="scan'208";a="432749914" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Jul 2023 00:09:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10787"; a="731491679" X-IronPort-AV: E=Sophos;i="6.01,244,1684825200"; d="scan'208";a="731491679" Received: from unknown (HELO fred..) ([172.25.112.68]) by fmsmga007.fm.intel.com with ESMTP; 31 Jul 2023 00:09:35 -0700 From: Xin Li To: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-edac@vger.kernel.org, linux-hyperv@vger.kernel.org, kvm@vger.kernel.org, xen-devel@lists.xenproject.org Cc: Jonathan Corbet , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H . Peter Anvin" , Andy Lutomirski , Oleg Nesterov , Tony Luck , "K . Y . Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Paolo Bonzini , Wanpeng Li , Vitaly Kuznetsov , Sean Christopherson , Peter Zijlstra , Juergen Gross , Stefano Stabellini , Oleksandr Tyshchenko , Josh Poimboeuf , "Paul E . McKenney" , Catalin Marinas , Randy Dunlap , Steven Rostedt , Kim Phillips , Xin Li , Hyeonggon Yoo <42.hyeyoo@gmail.com>, "Liam R . Howlett" , Sebastian Reichel , "Kirill A . Shutemov" , Suren Baghdasaryan , Pawan Gupta , Jiaxi Chen , Babu Moger , Jim Mattson , Sandipan Das , Lai Jiangshan , Hans de Goede , Reinette Chatre , Daniel Sneddon , Breno Leitao , Nikunj A Dadhania , Brian Gerst , Sami Tolvanen , Alexander Potapenko , Andrew Morton , Arnd Bergmann , "Eric W . Biederman" , Kees Cook , Masami Hiramatsu , Masahiro Yamada , Ze Gao , Fei Li , Conghui , Ashok Raj , "Jason A . Donenfeld" , Mark Rutland , Jacob Pan , Jiapeng Chong , Jane Malalane , David Woodhouse , Boris Ostrovsky , Arnaldo Carvalho de Melo , Yantengsi , Christophe Leroy , Sathvika Vasireddy Subject: [PATCH v9 28/36] x86/idtentry: Incorporate declaration/definition of the FRED exception handler type Date: Sun, 30 Jul 2023 23:41:05 -0700 Message-Id: <20230731064105.3857-1-xin3.li@intel.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-edac@vger.kernel.org The existing IDT exception C-handlers of X86_TRAP_TS, X86_TRAP_NP, X86_TRAP_SS, X86_TRAP_GP, X86_TRAP_AC and X86_TRAP_CP take an error code as the second argument, thus their FRED version handlers simply call the corresponding existing IDT handlers with orig_ax from the pt_regs structure as the second argument. Tested-by: Shan Kang Signed-off-by: Xin Li --- arch/x86/include/asm/idtentry.h | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/arch/x86/include/asm/idtentry.h b/arch/x86/include/asm/idtentry.h index e67d111bf932..3b743c3fbe91 100644 --- a/arch/x86/include/asm/idtentry.h +++ b/arch/x86/include/asm/idtentry.h @@ -11,6 +11,7 @@ #include #include +#include #include /** @@ -67,13 +68,16 @@ static __always_inline void __##func(struct pt_regs *regs) /** * DECLARE_IDTENTRY_ERRORCODE - Declare functions for simple IDT entry points + * and their corresponding software based + * dispatch handler * Error code pushed by hardware * @vector: Vector number (ignored for C) * @func: Function name of the entry point * - * Declares three functions: + * Declares four functions: * - The ASM entry point: asm_##func * - The XEN PV trap entry point: xen_##func (maybe unused) + * - The C handler called from the FRED event dispatch framework * - The C handler called from the ASM entry point * * Same as DECLARE_IDTENTRY, but has an extra error_code argument for the @@ -82,14 +86,19 @@ static __always_inline void __##func(struct pt_regs *regs) #define DECLARE_IDTENTRY_ERRORCODE(vector, func) \ asmlinkage void asm_##func(void); \ asmlinkage void xen_asm_##func(void); \ + __visible DECLARE_FRED_HANDLER(fred_##func); \ __visible void func(struct pt_regs *regs, unsigned long error_code) /** * DEFINE_IDTENTRY_ERRORCODE - Emit code for simple IDT entry points + * and their corresponding software based + * dispatch handler * Error code pushed by hardware * @func: Function name of the entry point * - * Same as DEFINE_IDTENTRY, but has an extra error_code argument + * Same as DEFINE_IDTENTRY, but has an extra error_code argument. The + * fred_func() simply calls func() with passing orig_ax as its second + * argument. */ #define DEFINE_IDTENTRY_ERRORCODE(func) \ static __always_inline void __##func(struct pt_regs *regs, \ @@ -106,6 +115,11 @@ __visible noinstr void func(struct pt_regs *regs, \ irqentry_exit(regs, state); \ } \ \ +__visible DEFINE_FRED_HANDLER(fred_##func) \ +{ \ + func(regs, regs->orig_ax); \ +} \ + \ static __always_inline void __##func(struct pt_regs *regs, \ unsigned long error_code)