From patchwork Tue Aug 1 08:35:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Xin3" X-Patchwork-Id: 129210 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp2598954vqg; Tue, 1 Aug 2023 04:24:24 -0700 (PDT) X-Google-Smtp-Source: APBJJlEDc9gKzSM1J1d38d56sprh16zsrJEO2oo4dS2ZbxZf/gdZQZ9E/zt+bPVK5E94ApcpPVnU X-Received: by 2002:a17:907:78d8:b0:994:1956:2331 with SMTP id kv24-20020a17090778d800b0099419562331mr2231848ejc.13.1690889063766; Tue, 01 Aug 2023 04:24:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690889063; cv=none; d=google.com; s=arc-20160816; b=w02bOOC1icJENsgCs9qjZm5rH7KfwpHPS2IUW6sqrSdplvsT9Q2h3aKahZLVBrBt8k KPmfMSbnOp0w5L8tIxmyWshhlwOtcyuUEOGm5C6YM1aDJobVpvfRCN4TRXdjwUiiK5eQ jHCjD/gQdOdrCSwzjPAW9E84VRfLaVo2b9CL4+BrUakplON6+NykLNvoXalCrOTE0c00 08xledikxxv0G2J5QTbP/KcZ5N/tj7jNfQIUbiQcUODdmp4hqihSi/CFAqDTTsb5XZYh aBuAh0olKTesEziUahJF8cvdBNRr9ctPghte8NmoLyeNKJNf1kkqIMNhFkOV50pJ+Znz 4WdQ== 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=ucgayTU9xprW1DrLb130VIy7lq+f482cjgC+m6pNIlk=; fh=nYO9ukkM7JnAAJZcChGC8UWBlCLXeJxIDT82cxoIaf0=; b=H/pTfiJluQL+/c07qg92Vowqugbz7dejVkOrErwayn2ghIyx9QZEOt4El+NZwwSZxS sr3Luq0TBF+/fzGHh3qBm/8Cj7MhIsstdVce4frtzkAiwBvbM0r/TOQb6MC601NiVBjx 0ifv7/191m8M3hasKlg3odtjoSM1tLN4mrOwPzhWpzhIm/6VdeLH4lElG8TtmMOKAEQl yb9mLcvQLSmiUu2ITVcXdP6Mo3pd9JgHUscdaps2D8Z7HS3AdUJoF+/lwnzdyp0iUs1R Zil7e9hKoOP1yfeqnWarQvWnUGF3OIIgITaYBlo9/exzoCcCm2KB29IboO4UPjI76jxR Q1+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=CskaN2z4; 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 kk20-20020a170907767400b00988c552332fsi7753325ejc.300.2023.08.01.04.24.00; Tue, 01 Aug 2023 04:24:23 -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=CskaN2z4; 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 S232815AbjHAJJN (ORCPT + 99 others); Tue, 1 Aug 2023 05:09:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233015AbjHAJIb (ORCPT ); Tue, 1 Aug 2023 05:08:31 -0400 Received: from mgamail.intel.com (unknown [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49FBB3C04; Tue, 1 Aug 2023 02:06:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1690880778; x=1722416778; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=g76n0qqOm69A/O2uudI0FugS1H+Frufn6xIPQbl7rb0=; b=CskaN2z4UARL14QSHzFw2NLXOwRNGulDfwwIWhiAYsDKxtOq6AfING0h ODYFJQ4aRQDJJroG32nyGeLfhiCiffRDzbqah0nK4D4twfcC/5LOXAhzA ARiY9PaFu3DeWQsReRzRdfKamE9OJYI/TvO0XqgiNe/CMxwcqqVuwHdpB k9CYwLB13lAPbHUw1+EAsXdM7s0sVRh0EU1BIbXmSiXlhkZXxdujGNB5S t+RSyXQSdAXpcRtSdbG1fvuLKN3+afwuKK+2b8MRTXcP0h1VcuTRYQF2d 61WRQj2/BhT9BTqBEzPXQBFgm/03SBDyDgIHLy74h04j7Cv4RzTWBTJxO A==; X-IronPort-AV: E=McAfee;i="6600,9927,10788"; a="366713719" X-IronPort-AV: E=Sophos;i="6.01,246,1684825200"; d="scan'208";a="366713719" 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:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10788"; a="722420755" X-IronPort-AV: E=Sophos;i="6.01,246,1684825200"; d="scan'208";a="722420755" Received: from unknown (HELO fred..) ([172.25.112.68]) by orsmga007.jf.intel.com with ESMTP; 01 Aug 2023 02:04:38 -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 34/36] x86/syscall: Split IDT syscall setup code into idt_syscall_init() Date: Tue, 1 Aug 2023 01:35:51 -0700 Message-Id: <20230801083553.8468-8-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: 1773025691044161073 X-GMAIL-MSGID: 1773025691044161073 Split IDT syscall setup code into idt_syscall_init() to make it cleaner to add FRED syscall setup code. Suggested-by: Thomas Gleixner Tested-by: Shan Kang Signed-off-by: Xin Li --- arch/x86/kernel/cpu/common.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index 331b06d19f7f..bb03dacc5fb8 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -2027,10 +2027,8 @@ static void wrmsrl_cstar(unsigned long val) wrmsrl(MSR_CSTAR, val); } -/* May not be marked __init: used by software suspend */ -void syscall_init(void) +static inline void idt_syscall_init(void) { - wrmsr(MSR_STAR, 0, (__USER32_CS << 16) | __KERNEL_CS); wrmsrl(MSR_LSTAR, (unsigned long)entry_SYSCALL_64); #ifdef CONFIG_IA32_EMULATION @@ -2064,6 +2062,15 @@ void syscall_init(void) X86_EFLAGS_AC|X86_EFLAGS_ID); } +/* May not be marked __init: used by software suspend */ +void syscall_init(void) +{ + /* The default user and kernel segments */ + wrmsr(MSR_STAR, 0, (__USER32_CS << 16) | __KERNEL_CS); + + idt_syscall_init(); +} + #else /* CONFIG_X86_64 */ #ifdef CONFIG_STACKPROTECTOR