Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2119835rwb; Sat, 19 Nov 2022 09:15:40 -0800 (PST) X-Google-Smtp-Source: AA0mqf49gXuE03Jmswb6tron8W/NIxW2glWABgTMs55dOL+bLbAuAcFZM5vKWZeJ1Rpjwz4/x8Av X-Received: by 2002:a17:902:7d94:b0:187:4920:3a7e with SMTP id a20-20020a1709027d9400b0018749203a7emr322739plm.171.1668878139774; Sat, 19 Nov 2022 09:15:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668878139; cv=none; d=google.com; s=arc-20160816; b=moH39p87VHS+dPDMyYuYdhvtDZMdwCEjv/gkToE6CHKuRBribDGmlCNEOlrAN1Po2+ 5ukSGRd9MDhbOxuk9Vz1IUtA+0NTyIxRq7CCuc+tuSbJuEJRK+nXEQzot3sk5vAO3CLv xMD27qSW9kYKhC++ghRprIJKl5Wt7WM8LJqTNl1zyxAH1gylQNVgCwbstOmsH5bQmFGC OGFW1f/cFTKQa4KdY3QmVEnZJtpa5PgcmhW9PEHzyKttKGyszX9KlyLgjnN80bgaVqtG k0OgOU1aB/47iGhBdJSfFfeEpjbvpulNHklbc2pBNiV9N4y9BDAWzfVO84sVrrDwqu0J REGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=rnvaBUgwxaTzZjATZ0cFB//becWThwWnxKEPTtTTkkw=; b=BzypgPhX5beSZnshMiDS3RgbV/z7ZeyB2Fbpixpnl4cjdrw4OLmleIhUPsqZ92OpU+ 9jXpidu+yTeW5bo3eL8rFAtGgrmcs58rzrlVuvO+4hPaX7zCE+oFzn38rBYytNViXvNc CEQ5EdABCV/1/t7CRbpKngNWItM0T7OxncRa2pum1twsOH+ZoSRpGkCxOmYMmsvR/O0t ErgvqNahdQtKKY/TnkD4ek5yeyD8U8oeYUChVohfBaLzLTrnvZXg8kUSN0iuLcU3lvTs Pvk+0xzE68ermk17jbs1r66IFTXe72nFGyeHrg4qaX9CEOaStEW51rcucO8hOTMjOPHZ 2RXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=L6L2PBwa; dkim=neutral (no key) header.i=@linutronix.de; 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=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t11-20020a17090a448b00b00213ff43fdf1si9636971pjg.185.2022.11.19.09.15.28; Sat, 19 Nov 2022 09:15:39 -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=@linutronix.de header.s=2020 header.b=L6L2PBwa; dkim=neutral (no key) header.i=@linutronix.de; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234411AbiKSQY3 (ORCPT + 90 others); Sat, 19 Nov 2022 11:24:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233639AbiKSQYI (ORCPT ); Sat, 19 Nov 2022 11:24:08 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18D5C317D3; Sat, 19 Nov 2022 08:24:07 -0800 (PST) Date: Sat, 19 Nov 2022 16:24:04 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668875045; h=from:from:sender:sender:reply-to: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rnvaBUgwxaTzZjATZ0cFB//becWThwWnxKEPTtTTkkw=; b=L6L2PBwallYphAMdrmceM44VTbuzV2tcxVVnYchYn6YFW2UPumnJ6/rxxd+ZfX8xCjkfIx 7qWAfJ8KUKMJqtD4PnF3+MNtaO/oWkCq8pXzrz3FhE5W6YT/yb4Yo8A8702bqWl/98aTwV NLM9GlgU0cTlCZsH2/Y7pxogeutWSsq21TgEInKf3ln/gak+O0VQIgKitwF2z7kgA6qntj oS5BFWiH451xqunMoEVoh6Sxu5CJBUEDA3qkk1SrQnns+iQlNg2Lny44C3YaHFEIxqnAMI ECQiluQTobzuJ2HlxMc7ecWcSoporz1I8v9cozpkDZK2+uigPt89x1dCT9loLg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668875045; h=from:from:sender:sender:reply-to: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rnvaBUgwxaTzZjATZ0cFB//becWThwWnxKEPTtTTkkw=; b=2aTIIBvRGLl6yGxtGXQwuxX1/AYc11+Gi1zTW5fgx84lPmL7R7xhy5JogmesbGkjhdSMy6 hjZeuTO8Xzopf0Ag== From: "tip-bot2 for Ashok Raj" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/microcode] platform/x86/intel/ifs: Add metadata support Cc: Ashok Raj , Jithu Joseph , Borislav Petkov , Tony Luck , Sohil Mehta , Hans de Goede , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20221117035935.4136738-11-jithu.joseph@intel.com> References: <20221117035935.4136738-11-jithu.joseph@intel.com> MIME-Version: 1.0 Message-ID: <166887504441.4906.15999663009202907278.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,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 The following commit has been merged into the x86/microcode branch of tip: Commit-ID: 8382fee3bb86526bde1bfb1a06834f056140e0dd Gitweb: https://git.kernel.org/tip/8382fee3bb86526bde1bfb1a06834f056140e0dd Author: Ashok Raj AuthorDate: Wed, 16 Nov 2022 19:59:29 -08:00 Committer: Borislav Petkov CommitterDate: Sat, 19 Nov 2022 10:39:08 +01:00 platform/x86/intel/ifs: Add metadata support One of the existing reserved fields in the microcode header has been allocated to indicate the size of metadata structures. The location of metadata section within microcode header is as shown below: Microcode Blob Format +----------------------+ Base |Header Version | +----------------------+ |Update revision | +----------------------+ |Date DDMMYYYY | +----------------------+ |Sig | +----------------------+ |Checksum | +----------------------+ |Loader Version | +----------------------+ |Processor Flags | +----------------------+ |Data Size | +----------------------+ |Total Size | +----------------------+ |Meta Size | +----------------------+ |Reserved | +----------------------+ |Reserved | +----------------------+ Base+48 | | | Microcode | | Data | | | +----------------------+ Base+48+data_size- | | meta_size | Meta Data | | structure(s) | | | +----------------------+ Base+48+data_size | | | Extended Signature | | Table | | | +----------------------+ Base+total_size Add an accessor function which will return a pointer to the start of a specific meta_type being queried. [ bp: Massage commit message. ] Signed-off-by: Ashok Raj Signed-off-by: Jithu Joseph Signed-off-by: Borislav Petkov Reviewed-by: Tony Luck Reviewed-by: Sohil Mehta Reviewed-by: Hans de Goede Link: https://lore.kernel.org/r/20221117035935.4136738-11-jithu.joseph@intel.com --- drivers/platform/x86/intel/ifs/load.c | 32 ++++++++++++++++++++++++++- 1 file changed, 32 insertions(+) diff --git a/drivers/platform/x86/intel/ifs/load.c b/drivers/platform/x86/intel/ifs/load.c index 8423c48..9228da5 100644 --- a/drivers/platform/x86/intel/ifs/load.c +++ b/drivers/platform/x86/intel/ifs/load.c @@ -43,6 +43,38 @@ static const char * const scan_authentication_status[] = { [2] = "Chunk authentication error. The hash of chunk did not match expected value" }; +#define MC_HEADER_META_TYPE_END (0) + +struct metadata_header { + unsigned int type; + unsigned int blk_size; +}; + +static struct metadata_header *find_meta_data(void *ucode, unsigned int meta_type) +{ + struct metadata_header *meta_header; + unsigned long data_size, total_meta; + unsigned long meta_size = 0; + + data_size = get_datasize(ucode); + total_meta = ((struct microcode_intel *)ucode)->hdr.metasize; + if (!total_meta) + return NULL; + + meta_header = (ucode + MC_HEADER_SIZE + data_size) - total_meta; + + while (meta_header->type != MC_HEADER_META_TYPE_END && + meta_header->blk_size && + meta_size < total_meta) { + meta_size += meta_header->blk_size; + if (meta_header->type == meta_type) + return meta_header; + + meta_header = (void *)meta_header + meta_header->blk_size; + } + return NULL; +} + /* * To copy scan hashes and authenticate test chunks, the initiating cpu must point * to the EDX:EAX to the test image in linear address.