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)) {