From patchwork Sat Dec 17 17:05:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Borislav Petkov X-Patchwork-Id: 34219 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp1608806wrn; Sat, 17 Dec 2022 09:30:34 -0800 (PST) X-Google-Smtp-Source: AA0mqf6IVYkbe9hUkYiU9cHdZqRY21Oakb8rjfGLa0NJcUFQrDOPlxJoxGyDcIs6GK1omaHFnYDg X-Received: by 2002:a05:6a20:c705:b0:a2:c3b0:f637 with SMTP id hi5-20020a056a20c70500b000a2c3b0f637mr43330262pzb.26.1671298233994; Sat, 17 Dec 2022 09:30:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671298233; cv=none; d=google.com; s=arc-20160816; b=GEv9v6OnYmmVo1733T83PuYFTcyB/y88wo3qr2XA2KDNZNv0XfArbXFOXHhLmkvjSC lSQ3yCLc7CMWTKooSpezQD9I/gUJE8DvEUbtaAV0pwUgvcz4rnGDxMRhpsw2LLz6Cn3O jwAt5jh5w+QEOHZ3wEJZ44xRN4cmIFvPDLJL6ngPNjcfmh2AB7jbNrGhgXqjsRTH5Dwp MobnH3xXjPPx/t1FJiwAIXiiwahijbC1O0J9HoudgDfvYM6DG9EPB5xmN1CibcJUTCRA hXG4MASw6nhgr2Qgm6nsd2eVZl4dh4p88/daf6gIi6dhdt7xDDjsfJ0Jj7en3QW7dgeI IcOA== 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=958fwmQI7KTWuzn/D4GxGa7J+15DtyU/BiSwRZxayC8=; b=wU0pvEArWnKklAkCq4sdHeNRBoSJlgw/W+ZwjhlFzkSOn1OC9kCStuc6h409MWyjxZ 0/YuBITKLJQrR8d56yRBR6BfXsYPCsbzu8XU3lZSw7b0F3l/kfLqUXVqFVjWHiFO3atd 883hktwNJs5ymP4iLRdM2mSE4UaOitAEXbb51lw2AQB+L3c0j6nbOtR8C5+47i5AJPyS E3UTbqPWiq4wJbOnEypzpcHDGfCEKBe2jbQEukx+R2p3CFg3jd/urkIDkHLNNCG5aSwj 7mYR6BUpfvHwUP6WKgOGSxdiWoKrswM52mALiqUr9FWilnvIhQhHGUn50PW4YyJFZKOz 4OYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b="dMse5ZM/"; 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=alien8.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z10-20020a634c0a000000b00477b29bb008si5867896pga.631.2022.12.17.09.30.19; Sat, 17 Dec 2022 09:30:33 -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=@alien8.de header.s=dkim header.b="dMse5ZM/"; 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=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229705AbiLQRFZ (ORCPT + 99 others); Sat, 17 Dec 2022 12:05:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229549AbiLQRFW (ORCPT ); Sat, 17 Dec 2022 12:05:22 -0500 Received: from mail.skyhub.de (mail.skyhub.de [5.9.137.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E12B2DC for ; Sat, 17 Dec 2022 09:05:20 -0800 (PST) Received: from zn.tnic (p5de8e9fe.dip0.t-ipconnect.de [93.232.233.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 811CA1EC064D; Sat, 17 Dec 2022 18:05:19 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1671296719; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references; bh=958fwmQI7KTWuzn/D4GxGa7J+15DtyU/BiSwRZxayC8=; b=dMse5ZM/ErhdFuvcejSzjPoXsN9KV2DU70tIzaWbNIMVh/XfH+ftHRAxLuA6aiLpdu/2mK xt6WRzVEqeuXCqEQidcsSYK9xgmQWgWXzyLfECL//N3ZFdE0BN4vBLijTBtpHZ6k15GT0z wrluO2jZkS5YkNDbi//hoJyG9dDODT4= From: Borislav Petkov To: X86 ML Cc: LKML Subject: [PATCH] x86/tsc: Make recalibrate_cpu_khz() export GPL only Date: Sat, 17 Dec 2022 18:05:11 +0100 Message-Id: <20221217170511.21872-1-bp@alien8.de> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS 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?1752483217381298231?= X-GMAIL-MSGID: =?utf-8?q?1752483217381298231?= From: "Borislav Petkov (AMD)" A quick search doesn't reveal any use outside of the kernel - which would be questionable to begin with anyway - so make the export GPL only. Signed-off-by: Borislav Petkov (AMD) --- arch/x86/kernel/tsc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c index a78e73da4a74..8979df1959d3 100644 --- a/arch/x86/kernel/tsc.c +++ b/arch/x86/kernel/tsc.c @@ -913,7 +913,7 @@ void recalibrate_cpu_khz(void) #endif } -EXPORT_SYMBOL(recalibrate_cpu_khz); +EXPORT_SYMBOL_GPL(recalibrate_cpu_khz); static unsigned long long cyc2ns_suspend; From patchwork Sun Dec 18 20:53:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Borislav Petkov X-Patchwork-Id: 34334 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp2068000wrn; Sun, 18 Dec 2022 13:08:09 -0800 (PST) X-Google-Smtp-Source: AA0mqf7jQiV4x1eytxQr5onKihBH40rSUp4pGDNj0Pc/8OTraDMBFgklVlOnSd88M87KjZ808ew6 X-Received: by 2002:a17:902:cec9:b0:189:71b7:d419 with SMTP id d9-20020a170902cec900b0018971b7d419mr54775166plg.54.1671397689239; Sun, 18 Dec 2022 13:08:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671397689; cv=none; d=google.com; s=arc-20160816; b=z129SBIO75L9oe7ZQfFoABX08mxqhAZWVTAELFa60L8Wo7bpTPmpkKs4wa7EibsB2J hkMmn0G5cKxW49U7PIHzhBUH3b/1IWKTcEBMn1pjX1W8qfO2j4yq9DtKas6XwKYe8HYP 2+KIwXk66ZOUi9C6mBbdOyfx2Y2N+Zfa8Md2c7Dr1lqLaEsDTXDu3MDMu7xy6nqcemB4 +oBPzirFjebRrCaTYu5U540ZcbxKhLz2TC/7NlC3IevjErc29Ngof1g+629rJt5i5CLp Yj/sOaNvcrqMdyjYPzxpzrc4MyokdlDwiHXH5Oi8XbIPZxC7wKXa1Fla4t8S9aA2aLxg paHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=EXFCNNlpJezbQHAX7KkO9d4XUv9kiX1NDPUmXFyc624=; b=Lkjlf4YbMj8abFUqRW86q+O6cULt96fqTjl8PGXCb1JWr4OnAPerkxd7Jr90QPcQcU tQj377rSXM8XyeFfrsv59rzDl3+VP6pukg3YQnmgOcIm7uIYZFU15yqaf2STdjDSzzPD tOCQ7fI8+HC0XYMx1dERgnFZrWqqf9GbGbWfUtro3o78fC4zA0asYeW61M4xDdlntAG8 5jzsMwTGEv6UvkmQR2xgtFsO/H02cIsUpO4rPirciGvnDqXbzwgSm1bn9sFdPI/58hIi iciAqxfuPaQDSD3hEWseSC8PxnnpyU/qxUWlU7smT25JX4BTy0kcn4w/Naairh67rEHe q02Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=YKj90guW; 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=alien8.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i10-20020a170902c94a00b00177e5c1d5d0si9936163pla.347.2022.12.18.13.07.56; Sun, 18 Dec 2022 13:08:09 -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=@alien8.de header.s=dkim header.b=YKj90guW; 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=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230261AbiLRUxm (ORCPT + 99 others); Sun, 18 Dec 2022 15:53:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229507AbiLRUxk (ORCPT ); Sun, 18 Dec 2022 15:53:40 -0500 Received: from mail.skyhub.de (mail.skyhub.de [5.9.137.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75AF2B1FF for ; Sun, 18 Dec 2022 12:53:38 -0800 (PST) Received: from zn.tnic (p5de8e9fe.dip0.t-ipconnect.de [93.232.233.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 1F6CE1EC058A; Sun, 18 Dec 2022 21:53:37 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1671396817; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=EXFCNNlpJezbQHAX7KkO9d4XUv9kiX1NDPUmXFyc624=; b=YKj90guWFdH35JwqgMtCkX0RWlEELOrlB9LHhN07RNwpwss9/sAtIPQ0l2TKL5goIaxu6O xAPZmy1eF05XOZf7h0Hjdk9u25sS2vsWfRT6Go4h64mM00fDD0amoKh6TLFqv1caiK835a wCS2mIEwKPV6Xg+bWVm2cKECKAe4YOY= Date: Sun, 18 Dec 2022 21:53:36 +0100 From: Borislav Petkov To: X86 ML Cc: LKML Subject: [PATCH 2/2] x86/tsc: Do feature check as the very first thing Message-ID: References: <20221217170511.21872-1-bp@alien8.de> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20221217170511.21872-1-bp@alien8.de> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS 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?1752587503083831475?= X-GMAIL-MSGID: =?utf-8?q?1752587503083831475?= From: "Borislav Petkov (AMD)" Do the feature check as the very first thing in the function. Everything else comes after that and is meaningless work if the TSC CPUID bit is not even set. No functional changes. Signed-off-by: Borislav Petkov (AMD) --- arch/x86/kernel/tsc.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c index eaeffef93a12..1d509c8b3556 100644 --- a/arch/x86/kernel/tsc.c +++ b/arch/x86/kernel/tsc.c @@ -1509,6 +1509,11 @@ void __init tsc_early_init(void) void __init tsc_init(void) { + if (!boot_cpu_has(X86_FEATURE_TSC)) { + setup_clear_cpu_cap(X86_FEATURE_TSC_DEADLINE_TIMER); + return; + } + /* * native_calibrate_cpu_early can only calibrate using methods that are * available early in boot. @@ -1516,11 +1521,6 @@ void __init tsc_init(void) if (x86_platform.calibrate_cpu == native_calibrate_cpu_early) x86_platform.calibrate_cpu = native_calibrate_cpu; - if (!boot_cpu_has(X86_FEATURE_TSC)) { - setup_clear_cpu_cap(X86_FEATURE_TSC_DEADLINE_TIMER); - return; - } - if (!tsc_khz) { /* We failed to determine frequencies earlier, try again */ if (!determine_cpu_tsc_frequencies(false)) {