From nobody Fri Apr 17 14:19:47 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2F976C4332F for ; Sat, 19 Nov 2022 16:24:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234215AbiKSQYb (ORCPT ); Sat, 19 Nov 2022 11:24:31 -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: quoted-printable 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/8382fee3bb86526bde1bfb1a06834f056= 140e0dd 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@inte= l.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/i= ntel/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[] = =3D { [2] =3D "Chunk authentication error. The hash of chunk did not match expe= cted value" }; =20 +#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 me= ta_type) +{ + struct metadata_header *meta_header; + unsigned long data_size, total_meta; + unsigned long meta_size =3D 0; + + data_size =3D get_datasize(ucode); + total_meta =3D ((struct microcode_intel *)ucode)->hdr.metasize; + if (!total_meta) + return NULL; + + meta_header =3D (ucode + MC_HEADER_SIZE + data_size) - total_meta; + + while (meta_header->type !=3D MC_HEADER_META_TYPE_END && + meta_header->blk_size && + meta_size < total_meta) { + meta_size +=3D meta_header->blk_size; + if (meta_header->type =3D=3D meta_type) + return meta_header; + + meta_header =3D (void *)meta_header + meta_header->blk_size; + } + return NULL; +} + /* * To copy scan hashes and authenticate test chunks, the initiating cpu mu= st point * to the EDX:EAX to the test image in linear address.