From patchwork Thu Mar 2 05:25:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Xin3" X-Patchwork-Id: 63231 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp4063714wrd; Wed, 1 Mar 2023 21:53:56 -0800 (PST) X-Google-Smtp-Source: AK7set/xo5sykpZdaXAu/6mty2D3xmQqJfybtbYhxNbwok/SiWhSDfi8nQr2fPGYCpP4nJJEeMBa X-Received: by 2002:a05:6402:189:b0:4a0:e31a:434 with SMTP id r9-20020a056402018900b004a0e31a0434mr8274987edv.27.1677736436355; Wed, 01 Mar 2023 21:53:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677736436; cv=none; d=google.com; s=arc-20160816; b=k3sJFfblDlR9yH9be6NQrxcah3z/xlFu0E+x5WgULh90lF+h8ryhzewqhmbFwmDnoi KRWkYZ0V0cuCZyXJXUCqdleL0xdukcxkt11TXVg1QTvYWzisz7pSe/DrNReJB+1o+YFj iDnBbhWA6gDb4yaXmzH9jE6sK8Gbx9tvyc5zroGC3hJNiSQIoEQIAuy2Q5WzfmfgunxV iwIATi1gHv8o8chA93WZErBi5ZW+C6l3PQb4fTdmIasSFKjPQiFaoJ64ZUdjyPlCgQvB hSwcOhEO+4go3ssoaFvftFDeW+AGnccxmCTmL/DQN41TF27NdCM/dRSkODECBxH90pU8 ejpA== 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=4BTz/OYFP659MTV9jAlMUDj6IzhLOKvkYwE26MSR2Sg=; b=dGhfpL5dF5UVm5NDvnIc/bQbMV0uOYWUG3eH9/P8FrdOS756/NmPn9Dzy6PKzScga4 kNXszLFHOwrzB4CNEwFiY8VUaj08QaXxd6knHOFXLDlhiwsV4vKUh8h9umffVM4IbiCs 92rgKB1qeGEWCOEhUuKLp+eIKM3QzfagP0AYaoFs8ws3TsMeha2yZSEUUpZlixv9aqEb vi542UCr4XvEcjx2gP+tajmx1H6qWcWe7+zFA5X1lpg0fZuePWI2mbbVOs06J72QZ/DL cp1e02kvz5wa+Zc+NkKLBBslJaSCxppi+TacaEkolmZxpVJp5BfncZupBvwhBqqJaSGP Amiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=SMfaJpmT; 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 lf22-20020a170906ae5600b008be2daad941si16405255ejb.648.2023.03.01.21.53.33; Wed, 01 Mar 2023 21:53:56 -0800 (PST) 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=SMfaJpmT; 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 S229998AbjCBFwt (ORCPT + 99 others); Thu, 2 Mar 2023 00:52:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229988AbjCBFwR (ORCPT ); Thu, 2 Mar 2023 00:52:17 -0500 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A9E77515C8; Wed, 1 Mar 2023 21:51:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1677736279; x=1709272279; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=dQrYcTRM4xVVKpWEBRpp2gh8m1WDXg1zEAfOSTgEfys=; b=SMfaJpmTdnGP2YeSs8uNdFfQWmfprf/klOvS4uq3tMfUm2zpeNzYIHoX 308BCxIwwjfNvsIiJSprxdw8E6fHly0BRAv/Ut7jQEa+hUeOmfDY3+ATe ChpO85h/c9fv1A2yoQfwuErePmy/+r+rmCggauA7yHgxDbnhkcC9xB9NG +pbG+km+hdCr3G3i30YKgVew0FVrDJeEThwl82zzrf8U3NrK9gm/zsw+z qYPA4paMdAOaS1NBSJAd3uOUu0CXylvn0wOSp8boaRDRiDfSBWQ/Wsszo JAI7Qnh0+yRaGlq5yUKw9OM48dW7dOD6HwKpe3i0zt77hmqF4wP+IdyuF A==; X-IronPort-AV: E=McAfee;i="6500,9779,10636"; a="420887256" X-IronPort-AV: E=Sophos;i="5.98,226,1673942400"; d="scan'208";a="420887256" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Mar 2023 21:50:52 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10636"; a="920530954" X-IronPort-AV: E=Sophos;i="5.98,226,1673942400"; d="scan'208";a="920530954" Received: from unknown (HELO fred..) ([172.25.112.68]) by fmsmga006.fm.intel.com with ESMTP; 01 Mar 2023 21:50:50 -0800 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 Subject: [PATCH v4 24/34] x86/fred: let ret_from_fork() jmp to fred_exit_user when FRED is enabled Date: Wed, 1 Mar 2023 21:25:01 -0800 Message-Id: <20230302052511.1918-25-xin3.li@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230302052511.1918-1-xin3.li@intel.com> References: <20230302052511.1918-1-xin3.li@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE 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: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759234161503263034?= X-GMAIL-MSGID: =?utf-8?q?1759234161503263034?= From: "H. Peter Anvin (Intel)" Let ret_from_fork() jmp to fred_exit_user when FRED is enabled, otherwise the existing IDT code is chosen. Signed-off-by: H. Peter Anvin (Intel) Tested-by: Shan Kang Signed-off-by: Xin Li --- arch/x86/entry/entry_64.S | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S index 7ecd2aeeeffc..7ffd20578b8c 100644 --- a/arch/x86/entry/entry_64.S +++ b/arch/x86/entry/entry_64.S @@ -299,7 +299,12 @@ SYM_CODE_START_NOALIGN(ret_from_fork) UNWIND_HINT_REGS movq %rsp, %rdi call syscall_exit_to_user_mode /* returns with IRQs disabled */ +#ifdef CONFIG_X86_FRED + ALTERNATIVE "jmp swapgs_restore_regs_and_return_to_usermode", \ + "jmp fred_exit_user", X86_FEATURE_FRED +#else jmp swapgs_restore_regs_and_return_to_usermode +#endif 1: /* kernel thread */