Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp3430130ybz; Mon, 20 Apr 2020 02:35:08 -0700 (PDT) X-Google-Smtp-Source: APiQypJHMIU09smZZCHiwwAAkgd/GvwzZ69BRTolbGyLpaNnn1ubdDsi+yucJvMA/K+oMtx9mwwP X-Received: by 2002:aa7:c497:: with SMTP id m23mr13121350edq.155.1587375308756; Mon, 20 Apr 2020 02:35:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587375308; cv=none; d=google.com; s=arc-20160816; b=K2jHCa96tHNCI2mgzX0x+nBk/+H0K718e419qPg6+pc8g6eEb8vULqp5+Qyid/xi02 nBHWGqpRnijwqT5Vt7PwWRvaaOokwU4VrsI2PtLqTTi4Ok6OFQmEstXsgXK84NuUdHg2 liXpVlJ3dmOpNpIqJolgJhSGAt+QQB+NSy044y/hMby+B3E7oF1AFYbDEzyqRU75VjSd yuHrnwgt1C7QQyoRnSXb/Ao0+31GwbIi4Q6cgYOkdH2P8m05OqrTK0QqhlKR020+3EJB gTsgdfFXrsfYODm0H4MTBymBTQMizG9T7fGC2OHlXlXc5rZ1Iqa0n5hz+yjK+V17KHaf 3u/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=CXhTfvXi11xyHHW7Yd77e/vXQQSj/cvzXDUeJIedA8g=; b=NpySBjh3mi37Pnn3aNnBtd13zXgFN1QYkL5ZPDHvzF+w00NyJT8T67VaKibLzX1+ek 45iOfEUkMMzaEvsskPx6qbuYwUuU+5Z0xJzdvvQZCLAMbGanM3V4iqRrqnM2qU6vTqjJ z/34ghacRlWV5pEu28Wfuz32g14erNhJcZOQwqM1qYwRq4thPZRA5lrxOJsURlZVg4gr QjtbuHzc976TfIeJ6Z2ZaIeGgbUigK5WVyUzHXu7Y35Q7JYC/7Q8bYcOaQJmQXu73pvi E8pD4oE/85G3TfCFdpFsGnaEXL/qBkAgmWo8idf4uu+h5BtznrFO40a40oprJ9YnTtKc MBrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=fynmVLdY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k11si192830ejp.508.2020.04.20.02.34.44; Mon, 20 Apr 2020 02:35:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=fynmVLdY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1726055AbgDTJbi (ORCPT + 99 others); Mon, 20 Apr 2020 05:31:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1725775AbgDTJbi (ORCPT ); Mon, 20 Apr 2020 05:31:38 -0400 Received: from mail.skyhub.de (mail.skyhub.de [IPv6:2a01:4f8:190:11c2::b:1457]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CCC81C061A0C for ; Mon, 20 Apr 2020 02:31:37 -0700 (PDT) Received: from zn.tnic (p200300EC2F08140068F64889F873250A.dip0.t-ipconnect.de [IPv6:2003:ec:2f08:1400:68f6:4889:f873:250a]) (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 5221D1EC0469; Mon, 20 Apr 2020 11:31:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1587375096; 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=CXhTfvXi11xyHHW7Yd77e/vXQQSj/cvzXDUeJIedA8g=; b=fynmVLdY6AUb68D6SdKAM4i7yRswJcGa/nZw0Ce5PtMXYuLkgWosT91CehApC5vMx+21lk Y+mGSvvLzToXwGFDVC6oYYlClGr866kd49Yqjn0u0XdohWOiLdU/+zAdxfhrUQWPAR9v+q BU2sMXvgX5YPZnaaHzu+8TASg8aaJZE= Date: Mon, 20 Apr 2020 11:31:29 +0200 From: Borislav Petkov To: Evalds Iodzevics Cc: linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org, tglx@linutronix.de, Ben Hutchings Subject: Re: [PATCH] x86/microcode/intel: replace sync_core() with native_cpuid_reg(eax) Message-ID: <20200420093129.GA21839@zn.tnic> References: <20200420120037.1537-1-evalds.iodzevics@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200420120037.1537-1-evalds.iodzevics@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Apr 20, 2020 at 03:00:37PM +0300, Evalds Iodzevics wrote: > sync_core() always jums past cpuid instruction on 32 bit machines > because data structure boot_cpu_data are not populated so early in boot. I'm guessing because boot_cpu_data.cpuid_level is not properly set and very early code in head_32.S sets it to -1 temporarily until the highest CPUID level has been detected (or not). But the microcode loading happens *before* that. I'd probably be interested how you trigger that but since the backport got changed (see below) and yours is correcting it to the upstream variant then perhaps maybe I don't care that much. :) > It depends on commit 5dedade6dfa243c130b85d1e4daba6f027805033 for > native_cpuid_reg(eax) definitions > > This patch is for 4.4 but also should apply to 4.9 > > Signed-off-by: Evalds Iodzevics > --- > arch/x86/include/asm/microcode_intel.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/x86/include/asm/microcode_intel.h b/arch/x86/include/asm/microcode_intel.h > index 90343ba50485..92ce9c8a508b 100644 > --- a/arch/x86/include/asm/microcode_intel.h > +++ b/arch/x86/include/asm/microcode_intel.h > @@ -60,7 +60,7 @@ static inline u32 intel_get_microcode_revision(void) > native_wrmsrl(MSR_IA32_UCODE_REV, 0); > > /* As documented in the SDM: Do a CPUID 1 here */ > - sync_core(); > + native_cpuid_eax(1); > > /* get the current revision from MSR 0x8B */ > native_rdmsr(MSR_IA32_UCODE_REV, dummy, rev); > -- Hrm, the original patch of mine did use native_cpuid_eax(): 4167709bbf82 ("x86/microcode/intel: Add a helper which gives the microcode revision") but the backport: commit 98cc1464cfd6edf9dc7fa96aaaf596aae952029b Author: Borislav Petkov Date: Mon Jan 9 12:41:45 2017 +0100 x86/microcode/intel: Add a helper which gives the microcode revision commit 4167709bbf826512a52ebd6aafda2be104adaec9 upstream. Since on Intel we're required to do CPUID(1) first, before reading the microcode revision MSR, let's add a special helper which does the required steps so that we don't forget to do them next time, when we want to read the microcode revision. Signed-off-by: Borislav Petkov Link: http://lkml.kernel.org/r/20170109114147.5082-4-bp@alien8.de Signed-off-by: Thomas Gleixner [bwh: Backported to 4.4: - Don't touch prev_rev variable in apply_microcode() - Keep using sync_core(), which will alway includes the necessary CPUID ^^^^^^^^^^^^^^^^^^^ decided to use sync_core() for whatever reason. Perhaps because the native_cpuid* things weren't there. Adding Ben to Cc. I believe this is the background info Greg needed to figure out *why* you're doing this. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette