From patchwork Thu Oct 20 11:59:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juergen Gross X-Patchwork-Id: 6181 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp76988wrr; Thu, 20 Oct 2022 05:24:07 -0700 (PDT) X-Google-Smtp-Source: AMsMyM46V5VNR/6kZaTPIiWd+07sSJZlqrjX2wflCCKElrJDfUULZ3EYSzZClqK17Mby0+PF5nH/ X-Received: by 2002:a17:907:3201:b0:741:94f2:aeaf with SMTP id xg1-20020a170907320100b0074194f2aeafmr10664842ejb.505.1666268646895; Thu, 20 Oct 2022 05:24:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666268646; cv=none; d=google.com; s=arc-20160816; b=HRbDtkoOtBNyll6LAyunmowHVNhb+IpEI7UFTHGoNgDL/NxR4zwRsd+xO3YdfwOsZC xfT5K4gPdWEdRX//ymlIMI8L8dPbZiaRcRPNSRqMtcjqgKlhq4RHn+5i7yWwPMcc7jVD lDMkakXy663dZlOFcLvprqVpHUEwt0/ahLDM4jU6NAJuiqsvvA5z2S3QmQlRKZwIc4VM wBBv26XPvYYQkvh5yFSdIU4sqBsK2otfxj99u8/51mn08ln14BFnojPUlEt/5xHCH9Z1 I3PidgE2OYz523A+dpaDyYWzL0hO+1fVfaxtj5eZaG8xfNyz9hQlZH2nPgk6CbqQohAt L+Sw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=oySpgM5g+r0WCk6Eq8kGRfyxgEAOWxWakiY/c8kh3qw=; b=hcfmAam6C0pUSaaSdcQqjEjRWA/Tv5eXOoG4QJ5al5Yx/NQQ7EcWQxLvyAjWG6M9td agiG2vmLQXqbcLli+Vn2Xcmfti3+89MP4Swkmin0SbIhSUAYmq0hIQVlATaVmTYleUCa wX9ZqU4I0maeiQTzpXCI9EhEONKXKb1/JjWOzg0ckah9DSgpg/3bgCtVJtmTwhsWo2se Pvop93JnZUBsQerlYecmoTGoeKu6IZcCzleFRfd7fXR8NkDhvCwCE9I9oVM/0dJIxi1J tGnGSvicgAOKMWz18cfP+NuSUB9/a4AYiVw0kMaI7NNCF4Y390Bjmvg55EuSoHGLH7Fj fdSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=JGPhQj1Z; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r11-20020a05640251cb00b0045d9ceae6d8si9942245edd.492.2022.10.20.05.23.42; Thu, 20 Oct 2022 05:24:06 -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=@suse.com header.s=susede1 header.b=JGPhQj1Z; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229853AbiJTL75 (ORCPT + 99 others); Thu, 20 Oct 2022 07:59:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53572 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229956AbiJTL7x (ORCPT ); Thu, 20 Oct 2022 07:59:53 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E9DCE3C8FE for ; Thu, 20 Oct 2022 04:59:50 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 53C0920A44; Thu, 20 Oct 2022 11:59:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1666267188; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=oySpgM5g+r0WCk6Eq8kGRfyxgEAOWxWakiY/c8kh3qw=; b=JGPhQj1ZV+Sm3I4LVtq4L2JrCJZGFxiejo9qvyBgS68IuVh2HOzZyizIwaITr4r3lBXAam rB78ZqWe8tgRiWX2mcORmHaemwL1xdxp0yjq8zNmUfeecmJtUvLa7dUoD6pFb8YPEHLFd4 /SlQGRy9MJC4I/CPIUhDGbvRjCNvmiM= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 1077413494; Thu, 20 Oct 2022 11:59:48 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id zs6/AjQ4UWNSFAAAMHmgww (envelope-from ); Thu, 20 Oct 2022 11:59:48 +0000 From: Juergen Gross To: linux-kernel@vger.kernel.org, x86@kernel.org Cc: Juergen Gross , Boris Ostrovsky , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , xen-devel@lists.xenproject.org Subject: [PATCH v2] x86/xen: simplify sysenter and syscall setup Date: Thu, 20 Oct 2022 13:59:46 +0200 Message-Id: <20221020115946.18772-1-jgross@suse.com> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS,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: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747206915069568215?= X-GMAIL-MSGID: =?utf-8?q?1747209312530306915?= xen_enable_sysenter() and xen_enable_syscall() can be simplified a lot. While at it, switch to use cpu_feature_enabled() instead of boot_cpu_has(). Signed-off-by: Juergen Gross --- V2: - use cpu_feature_enabled() (Borislav Petkov) --- arch/x86/xen/setup.c | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c index cfa99e8f054b..4f4309500559 100644 --- a/arch/x86/xen/setup.c +++ b/arch/x86/xen/setup.c @@ -910,17 +910,9 @@ static int register_callback(unsigned type, const void *func) void xen_enable_sysenter(void) { - int ret; - unsigned sysenter_feature; - - sysenter_feature = X86_FEATURE_SYSENTER32; - - if (!boot_cpu_has(sysenter_feature)) - return; - - ret = register_callback(CALLBACKTYPE_sysenter, xen_entry_SYSENTER_compat); - if(ret != 0) - setup_clear_cpu_cap(sysenter_feature); + if (cpu_feature_enabled(X86_FEATURE_SYSENTER32) && + register_callback(CALLBACKTYPE_sysenter, xen_entry_SYSENTER_compat)) + setup_clear_cpu_cap(X86_FEATURE_SYSENTER32); } void xen_enable_syscall(void) @@ -934,12 +926,9 @@ void xen_enable_syscall(void) mechanism for syscalls. */ } - if (boot_cpu_has(X86_FEATURE_SYSCALL32)) { - ret = register_callback(CALLBACKTYPE_syscall32, - xen_entry_SYSCALL_compat); - if (ret != 0) - setup_clear_cpu_cap(X86_FEATURE_SYSCALL32); - } + if (cpu_feature_enabled(X86_FEATURE_SYSCALL32) && + register_callback(CALLBACKTYPE_syscall32, xen_entry_SYSCALL_compat)) + setup_clear_cpu_cap(X86_FEATURE_SYSCALL32); } static void __init xen_pvmmu_arch_setup(void)