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: 13333788 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 lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AC458C001DF for ; Mon, 31 Jul 2023 07:09:47 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.572696.896708 (Exim 4.92) (envelope-from ) id 1qQN2D-0007i1-4x; Mon, 31 Jul 2023 07:09:41 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 572696.896708; Mon, 31 Jul 2023 07:09:41 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qQN2D-0007hu-2B; Mon, 31 Jul 2023 07:09:41 +0000 Received: by outflank-mailman (input) for mailman id 572696; Mon, 31 Jul 2023 07:09:40 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qQN2C-0007Jb-5x for xen-devel@lists.xenproject.org; Mon, 31 Jul 2023 07:09:40 +0000 Received: from mgamail.intel.com (unknown [134.134.136.31]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 36089a85-2f71-11ee-8613-37d641c3527e; Mon, 31 Jul 2023 09:09:38 +0200 (CEST) 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 Received: from unknown (HELO fred..) ([172.25.112.68]) by fmsmga007.fm.intel.com with ESMTP; 31 Jul 2023 00:09:35 -0700 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 36089a85-2f71-11ee-8613-37d641c3527e DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1690787378; x=1722323378; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=Aa5CvA7MmnPHyksJQgqEteFVOvaio1lA17Ke5qS+vL0=; b=N72tAZR+vkIV66rxfC9UqMmtaL6m9M6WWG9cpgkn/2EnLP7fOXS6EI/+ itBGSuzlRjj2Tntnj3Jj20DPWn5otb4PlvUC0+kjqk3N9yOlWlihgpUuQ rN70j89iZZd244rAWJr+rJEaqZweDhY+oNxMNf0KUtg6c74Fs+lwn+wfG l0rUN3Itl5EeRsZFfG0pQzX/kZhO6R8ZNSOOuaRnOiIkCGPo0/fz0Z0Uc TLaqf5/DrJoVK/pp2SIaH9P0rNxklprCke2v4xAVMmv+z7RJ7h0a6MwA2 Abm8yiX8OmufieFNaW4zymVAAPPkHZbV3iOA+c33XrQMg3LHWRSk+Xx0a A==; X-IronPort-AV: E=McAfee;i="6600,9927,10787"; a="432749913" X-IronPort-AV: E=Sophos;i="6.01,244,1684825200"; d="scan'208";a="432749913" 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" 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 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)