Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp789526rwi; Thu, 20 Oct 2022 05:24:59 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4oK2XBaKFEs+t+51HhDzWhMdeboiHeF6QQcXbrMbh8VdfWCX9ERvcs+BGyNGfs7U/udIY2 X-Received: by 2002:a05:6402:40d0:b0:45c:ffa2:4b5a with SMTP id z16-20020a05640240d000b0045cffa24b5amr12033437edb.341.1666268699002; Thu, 20 Oct 2022 05:24:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666268698; cv=none; d=google.com; s=arc-20160816; b=hIsSSaDTHUa7cd2gVlaleifiueBpXmWSaTN6H2lori8c8hwKC16Ozu7x3PxWYznaxZ EJq+2u5isr7LbXm2QZjF5L5LETZOAOxhsiwa9iXAiq6uU0w2aMan83zYWFJ2Z7r9jWq/ xdZNOt2KqVn7GrzIuKQSs/QFr7Lv3ln+ibiFdGqCaXUnymFKHm+hTkEi4JAeYSPFpxCI gBYYY/rRf8wb7wad3A349XXxBu6f9RlF5oo1BMBZ54+uO/JAhvSdBQ4+MVsqZNeXQ/tY RGCcddJq4/S9vKFU34sT5imcr5MzH3yIufcVF/PYwstWIPqoqbM6dHvMBGxSW8CCd1I1 lJag== 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 Return-Path: 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.24.33; Thu, 20 Oct 2022 05:24:58 -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 Content-Transfer-Encoding: 8bit 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 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) -- 2.35.3