Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4097341ybl; Mon, 13 Jan 2020 07:48:51 -0800 (PST) X-Google-Smtp-Source: APXvYqxVri3wee8ed/xB5p2GfV05BUQItolttEMmlTcWm6gEg9fW6V9+9AWrLh3HL9Ut3xVgTIAV X-Received: by 2002:aca:d483:: with SMTP id l125mr12533767oig.124.1578930531488; Mon, 13 Jan 2020 07:48:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578930531; cv=none; d=google.com; s=arc-20160816; b=fO5IKEK2Vo2N9+QuBgyyHh49Exq9Hf6kCK61HvDU+lOiv+9YqWrWT7nC4Fx4KjNKmk 9WEgQyGFQna9hs8GFzf93nmktXUGB8T6zpZTyEPW52VdllOJeS31ZgkUK7SAa5feJJGR IL1C4Lp+xjw2jST8/rtO8iTAHqhE5hsMOh+e0Iaccsh9IlHbIaX/oaFs33JGtruekh1m qnYd5o9BLkp4pT2ncsveZB4RtdlqDwmo33krJLHeF9/R38NYVcdDlQDljHZUkN7ZeFm/ oi1ThpP26xWlRFWvXrCiV38KX0NJ4MvdDrkIZt0SD67vuD++MqJviQw/IgoU4KT8v9R5 5FWQ== 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; bh=ChFe9qShyUOuZ5tGPkN8C3BJi+grvsqUW91W4CaiU70=; b=A74T/xaCxj3pHPJPeeghn90MqdX6XrM6Fq8Nkz7l/W8hHfZyIeh691PzMcKaydfslH aNSuopCNU/Re0172kjBJNBgSvj2Qm5DnzOyslNN69aX8JhkOJ80OWuM8mhKmIC2MYsDp nfqK12Iq8wWsCK7A6X84Lbv0TpydGLem6/fK15+Ycw3IkV330/af9liPhMdkQMzBlwfk TEH4OUqP9330Z5IsbIG3qDOWOpSR7E68Z748Q8+pDqYAcBvCc/MtLGiLdSjUj6mgf2NY 0zhQo0JCHU5SFXibNlEGWNr3sRsO3RO/DjMQIRl/AZn/geT4igoMwryEaUbzLzyK8Yle /4jw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w26si6219352otl.213.2020.01.13.07.48.39; Mon, 13 Jan 2020 07:48:51 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728738AbgAMPrn (ORCPT + 99 others); Mon, 13 Jan 2020 10:47:43 -0500 Received: from mail-yw1-f65.google.com ([209.85.161.65]:41390 "EHLO mail-yw1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726567AbgAMPrn (ORCPT ); Mon, 13 Jan 2020 10:47:43 -0500 Received: by mail-yw1-f65.google.com with SMTP id l22so6361695ywc.8; Mon, 13 Jan 2020 07:47:42 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=ChFe9qShyUOuZ5tGPkN8C3BJi+grvsqUW91W4CaiU70=; b=sb9j7bVv5w5DqVRlAnGzko6bpBEFCVnTQzfgd40wZwi2UzSPg7uDOPW5IWdaZNCWFm /4y0QTQ7ZsPssSeMWKIqStmEYByqotjTZmSQn/v3GMhngrwnj1N1TITGeK0lAnwgWTL7 PWW9eJLeYo+45ZVhw66zFnpBKh2H8a2+vVzsmkO2dBrBDKSljKRrN7cpedMfBsNxsx40 OvFWo1gGEXUhgP/eMNcPDpleMf6QQs3eZlQCt3Yl96wMXXGfM4HicO2D64zkWDw5MfSX r/AVsekKrtzw0vQIPkqToasr7TYD/qin+hW3oclEwfWk+SJIcXOpzjsKyxjA/Wgaxs0W tcFA== X-Gm-Message-State: APjAAAXqlVJWdm6xHOUWAPtMzD4j7eXvj3j5Fh1l17mJKyefzwJMNEvu 85ofvHNkkesrZPjAYzEcmg8= X-Received: by 2002:a25:3481:: with SMTP id b123mr14417705yba.16.1578930461921; Mon, 13 Jan 2020 07:47:41 -0800 (PST) Received: from 42.do-not-panic.com (42.do-not-panic.com. [157.230.128.187]) by smtp.gmail.com with ESMTPSA id 124sm5593686ywn.76.2020.01.13.07.47.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jan 2020 07:47:40 -0800 (PST) Received: by 42.do-not-panic.com (Postfix, from userid 1000) id 7BDDC4018C; Mon, 13 Jan 2020 15:47:39 +0000 (UTC) Date: Mon, 13 Jan 2020 15:47:39 +0000 From: Luis Chamberlain To: Jari Ruusu Cc: Borislav Petkov , Fenghua Yu , Linus Torvalds , johannes.berg@intel.com, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: Fix built-in early-load Intel microcode alignment Message-ID: <20200113154739.GB11244@42.do-not-panic.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 Sun, Jan 12, 2020 at 03:00:53PM +0200, Jari Ruusu wrote: > Intel Software Developer's Manual, volume 3, chapter 9.11.6 says: > "Note that the microcode update must be aligned on a 16-byte > boundary and the size of the microcode update must be 1-KByte > granular" > > When early-load Intel microcode is loaded from initramfs, > userspace tool 'iucode_tool' has already 16-byte aligned those > microcode bits in that initramfs image. Image that was created > something like this: > > iucode_tool --write-earlyfw=FOO.cpio microcode-files... > > However, when early-load Intel microcode is loaded from built-in > firmware BLOB using CONFIG_EXTRA_FIRMWARE= kernel config option, > that 16-byte alignment is not guaranteed. Thanks for the patch! So what happens with you use the built-in firmware loader for the Intel microcode at this time? I am surprised this issue wasn't reported earlier, so thanks for picking it up, but to be complete such a change requires a bit more information. What exactly happens now? > Fix this by forcing all built-in firmware BLOBs to 16-byte > alignment. That's a huge stretch, see below. > Signed-off-by: Jari Ruusu > > --- a/drivers/base/firmware_loader/builtin/Makefile > +++ b/drivers/base/firmware_loader/builtin/Makefile > @@ -17,7 +17,7 @@ > filechk_fwbin = \ > echo "/* Generated by $(src)/Makefile */" ;\ > echo " .section .rodata" ;\ > - echo " .p2align $(ASM_ALIGN)" ;\ > + echo " .p2align 4" ;\ You are forcing 16 byte alignment to *all* built-in firmware, and some architectures may have a different requirement. If things used to work with ASM_ALIGN which is a construct only used for this code, but your change fixes it with Intel microcode loading -- it however *may* break things for other built-in firmware used. In particular if you note above it used to align things to 2^3 so 8 bytes if on CONFIG_64BIT, otherwise things get aligned to 2^2 so 4 bytes. So I'd like to determine first if we really need this. Then if so, either add a new global config option, and worst comes to worst figure out a way to do it per driver. I don't think we'd need it per driver. If set as a global new config option, we can use the same logic and allow an architecture override if the user / architecture kconfig configures it such: config ARCH_DEFAULT_FIRMWARE_ALIGNMENT string "Default architecture firmware aligmnent" "4" if 64BIT "3" if !64BIT config FIRMWARE_BUILTIN_ALIGN string "Built in firmware aligment requirement" default ARCH_DEFAULT_FIRMWARE_ALIGNMENT if !ARCH_CUSTOM_FIRMWARE_ALIGNMENT default ARCH_CUSTOM_FIRMWARE_ALIGNMENT_VAL if ARCH_CUSTOM_FIRMWARE_ALIGNMENT Some good description goes here Or something like that. Luis