From patchwork Tue Aug 1 08:35:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Xin3" X-Patchwork-Id: 129135 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp2567492vqg; Tue, 1 Aug 2023 03:16:58 -0700 (PDT) X-Google-Smtp-Source: APBJJlGAB5M1+RCh+qmGMshX0Zr20kU9DSYyoxdW3s7Z0PJDm+1AxG7apFhwzuTUw998OVWQEj38 X-Received: by 2002:a05:6a21:329c:b0:13e:99c0:fe6e with SMTP id yt28-20020a056a21329c00b0013e99c0fe6emr1172705pzb.5.1690885017962; Tue, 01 Aug 2023 03:16:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690885017; cv=none; d=google.com; s=arc-20160816; b=eJpKlBRQsVhLTkxcs647zwHF79s3wSe/AGbi1ZHK2rpl2sb+GtyYl4gkbUPk6daOJV sSt24GebwyNe8MKrysoWD/3eofs3wU06SUVRmRUUmvJCShnkwcGTErehWAuN0PSZjZg2 SX8UtvyFGD0hEkuwnrNvZ5hDXzR65YEdzc6oRggsNcACQDLzscOD0G6fNeK6OnKg2ZNW hq7LJOzoJPDC++UK2Gljv8E0J3a0ef7XxAcy6WdYKAdXrZVF54dLkvmW4+w/H1QGbSVC x7zmTGEjn0LFhBlwYBGpyL70EhnxbggoP75szXAwXArafPSJWTm8g3EjfY5eWxkItdMY o3Vg== 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=HTikNJH9/vjaJ3HA/TnrigaFcTpRfHwXlSnhqLBQ5Fs=; fh=nYO9ukkM7JnAAJZcChGC8UWBlCLXeJxIDT82cxoIaf0=; b=YPoVUYrL1+0y0y6y4nwI3WOW/e2w1PJSZv03xHTiFbPBlh7292nvlAchckUtQO3fAP IUaPBWtpBAFCdh1KwRTDpEMJrGOVJpRrOtLG3zueiz6Mte2seq5epV2YiHPhLp+bEoix WJgl4SVTIaDdXWp0IVkZADC1QU4qEFvo0CKkeaIIMdbSGvsFGTJmhLG5OwmP43zFaxa6 rPcEmhJbe4JJFCiOiTaS4zxsIcclwEJEzyNDCZlfrYXdvM/FXrwJab0HujsttOAhiKNq nyw+LyNIOZkZByllv+RZROu9fINz54/PFPDUZyjLP5fGjAa5eRP8vhA3KVVW3jEniNsO PvmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=TeKJeL09; 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 g5-20020a056a001a0500b0067af445c0f0si1753449pfv.291.2023.08.01.03.16.45; Tue, 01 Aug 2023 03:16:57 -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=TeKJeL09; 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 S232750AbjHAJIo (ORCPT + 99 others); Tue, 1 Aug 2023 05:08:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232968AbjHAJIV (ORCPT ); Tue, 1 Aug 2023 05:08:21 -0400 Received: from mgamail.intel.com (unknown [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 51D235241; Tue, 1 Aug 2023 02:06:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1690880772; x=1722416772; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Aa5CvA7MmnPHyksJQgqEteFVOvaio1lA17Ke5qS+vL0=; b=TeKJeL09lRyNMh9np7dJphOGhvm7/hKmwoPDqiYSGbjPlDfIAI4A+nkV j9ut8EzGwL2ILHE+igV0Lc+8XUIUnGbuVVo7rj4u1Pin07vEsWmfrbpLo ym59JUW5u0CIqqpBdocVd7Qe0lujlMjIuNgha7Hn2cuLur/ICdLIqUX5z xamcbFx7NP8TxITQ0bHvwoYOCb18foB1J6rnnvjSS86g3Y0Sv83226rz2 kaSpwgBp7XWv/r8uRGuNPGTmWjG6crgFs/cIle2vI80IyetnKCjv+GsfQ pV1ZwuAB+m4qG4U4FzqYACsFWXo+qa52DbLjTXQePhefEzK6SbkIJ8RLN Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10788"; a="366713486" X-IronPort-AV: E=Sophos;i="6.01,246,1684825200"; d="scan'208";a="366713486" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Aug 2023 02:04:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10788"; a="722420715" X-IronPort-AV: E=Sophos;i="6.01,246,1684825200"; d="scan'208";a="722420715" Received: from unknown (HELO fred..) ([172.25.112.68]) by orsmga007.jf.intel.com with ESMTP; 01 Aug 2023 02:04:27 -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 , 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 RESEND v9 28/36] x86/idtentry: Incorporate declaration/definition of the FRED exception handler type Date: Tue, 1 Aug 2023 01:35:45 -0700 Message-Id: <20230801083553.8468-2-xin3.li@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230801083553.8468-1-xin3.li@intel.com> References: <20230801083553.8468-1-xin3.li@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED 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: INBOX X-GMAIL-THRID: 1773021448292372510 X-GMAIL-MSGID: 1773021448292372510 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)