From patchwork Sat Nov 19 16:24:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 23282 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp779767wrr; Sat, 19 Nov 2022 08:25:16 -0800 (PST) X-Google-Smtp-Source: AA0mqf7Lva9xSZcyykuiP5i/b+fFFNIqPvEw6lQ4JC7ew6aHDQ4wdnLCTb2RBx7xJuZQ8wgTSjqT X-Received: by 2002:aa7:8f01:0:b0:56d:6450:9e48 with SMTP id x1-20020aa78f01000000b0056d64509e48mr13012955pfr.14.1668875116637; Sat, 19 Nov 2022 08:25:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668875116; cv=none; d=google.com; s=arc-20160816; b=Z6tVRmm4648NJj1m+ANninCeHtkxofnO6mIFvIaskwPAuxQ66DrFdi74KnByRY5H0C dRjfBfcdjiH30r8OeYht4qIBWYjlT2t0CkBbn12QnAE7rwNenqsNc2FQxrMEdaXzBftf AD5ZkSluEb7R8wxewSHkismq4NFPs30w5jKFHTwj/mHUMU1NyhM7kB18/dtFoxLSJnvy a5WpPkmsZi6VpBzLn433VqRhulcTmkj38mOoIYdxZvSYbh4w10ruaFLH0HcqXT3vYlT7 vC9bdT3lpALyEIsthIqj61hkSNs4WAB0knSCCLxVCyTyQTyXRolF4KhxBrFqLs57PRcn 4Yuw== 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 header.s=2020e header.b=2aTIIBvR; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u18-20020a170902e5d200b00186bc66d2cdsi7862374plf.75.2022.11.19.08.25.03; Sat, 19 Nov 2022 08:25:16 -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 header.s=2020e header.b=2aTIIBvR; 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 + 99 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748879880756249924?= X-GMAIL-MSGID: =?utf-8?q?1749942394380901040?= 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.