From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9F307C17440 for ; Sun, 10 Nov 2019 02:47:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7421121D7E for ; Sun, 10 Nov 2019 02:47:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573354035; bh=QoUn/h3MNMbwtHEOTvmPQwcQ21/PcGqIt0aNnHTGS3k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=vKhG/P3eaBw8Ftb0jvDh10ABHgjb418tQpWmhMCbdYCOyqNVnFEA+x8xrh+UqWdz2 o5vLBAk/Za2peFaRE4v4brmXisk+Ib2L0gzFDF+2YPIqtpjBGmGTsmMmJxuDDLYTE2 RMEHaCqg55iOPtAjFuCxKQnBuK11DJJWHey895jw= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729305AbfKJCrO (ORCPT ); Sat, 9 Nov 2019 21:47:14 -0500 Received: from mail.kernel.org ([198.145.29.99]:52346 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729284AbfKJCrL (ORCPT ); Sat, 9 Nov 2019 21:47:11 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 154C42085B; Sun, 10 Nov 2019 02:47:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573354031; bh=QoUn/h3MNMbwtHEOTvmPQwcQ21/PcGqIt0aNnHTGS3k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i/zL4czTCSRLgpuB9pQZEwghjUONdkWHL9S5tT+8dUENxN5yFDP+owkHoZ4DUrILX AgIvkKB1a0jCYaw2C4RJqj5N3p17z757PlgWHv2FIFDNiyI6r2jMuWjGrvZswsVCO/ /dUDzx78C3y8jcGzqO5fboZqKO+xOtmLwsyX3sVY= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Matthew Whitehead , Andy Lutomirski , Borislav Petkov , David Woodhouse , "H . Peter Anvin" , Ingo Molnar , Konrad Rzeszutek Wilk , Peter Zijlstra , Thomas Gleixner , Sasha Levin Subject: [PATCH AUTOSEL 4.14 047/109] x86/CPU: Change query logic so CPUID is enabled before testing Date: Sat, 9 Nov 2019 21:44:39 -0500 Message-Id: <20191110024541.31567-47-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191110024541.31567-1-sashal@kernel.org> References: <20191110024541.31567-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Matthew Whitehead [ Upstream commit 2893cc8ff892fa74972d8dc0e1d0dc65116daaa3 ] Presently we check first if CPUID is enabled. If it is not already enabled, then we next call identify_cpu_without_cpuid() and clear X86_FEATURE_CPUID. Unfortunately, identify_cpu_without_cpuid() is the function where CPUID becomes _enabled_ on Cyrix 6x86/6x86L CPUs. Reverse the calling sequence so that CPUID is first enabled, and then check a second time to see if the feature has now been activated. [ bp: Massage commit message and remove trailing whitespace. ] Suggested-by: Andy Lutomirski Signed-off-by: Matthew Whitehead Signed-off-by: Borislav Petkov Reviewed-by: Andy Lutomirski Cc: David Woodhouse Cc: H. Peter Anvin Cc: Ingo Molnar Cc: Konrad Rzeszutek Wilk Cc: Peter Zijlstra Cc: Thomas Gleixner Link: http://lkml.kernel.org/r/20180921212041.13096-3-tedheadster@gmail.com Signed-off-by: Sasha Levin --- arch/x86/kernel/cpu/common.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index 551c6bed7c8ce..1784deefbc8c9 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -1037,6 +1037,9 @@ static void __init early_identify_cpu(struct cpuinfo_x86 *c) memset(&c->x86_capability, 0, sizeof c->x86_capability); c->extended_cpuid_level = 0; + if (!have_cpuid_p()) + identify_cpu_without_cpuid(c); + /* cyrix could have cpuid enabled via c_identify()*/ if (have_cpuid_p()) { cpu_detect(c); @@ -1053,7 +1056,6 @@ static void __init early_identify_cpu(struct cpuinfo_x86 *c) if (this_cpu->c_bsp_init) this_cpu->c_bsp_init(c); } else { - identify_cpu_without_cpuid(c); setup_clear_cpu_cap(X86_FEATURE_CPUID); } -- 2.20.1