Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp3398279pxp; Mon, 14 Mar 2022 18:58:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxrbT5SJ6p6dOYRQ+aWkHBp1LtTTuBw9wStukbbhJx2aq4Kp/LjQcLbH6lAOZriTarIJkN0 X-Received: by 2002:a17:907:7e97:b0:6db:c1ef:6a68 with SMTP id qb23-20020a1709077e9700b006dbc1ef6a68mr10054250ejc.475.1647309489681; Mon, 14 Mar 2022 18:58:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647309489; cv=none; d=google.com; s=arc-20160816; b=j2BhdMyBfjiliZbh/wK28H5AwjZwFi1FFusdNtl63Cp60sKToYgDxCkbPiM+CYeZNW 1t36jGuaX3Ue1NiKAQlhMKPE9ktJcvrPBil4xgctxOG3vmY34rZusPIjs0C/Nd6U7U74 6H99LAW/XsA0jzJ3zspp3vn6S9q/eWw0YP5pDExwWouYSztFjiW/vI+6+hV6n624NO8E qht6KwdQz30G5jYMyMz7rzmrtvXOWGjPqKQvMcXeALBhpg7OAyfDozT1663C6OMv3VEq 9CX6MV87zVmoG5+osDdJn5B8iEMusryy6EvSpiXsnRPLt/12GbsV7hnmpKVvIpsNFbC2 USZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=dUCDcXZS7EoqoudGE0FdznmjftIpkoEAoTLtVV2h2DQ=; b=ixqk1TFaQ7vxN51815nCeOAuS8EIxtA1bkCrt9uc1D24S5+aNf37D+XRBXpK3goS+K MS10APEAYk+uBkN67+N9mM234W/Dl/oaalxFBz9e4rVOBbcpVrngVG+qDQaODw83Y1VQ Aaimly5uSXPBOlkeKNFd+HP+VzawjbPV6LysF2eHtP7soh+0sgJc8zfxuBVd4vx+yi7U Fa8iuiBBQTa0g/vmD2NUn/SDcvMo1XdldzzapguIepfRwSmSDzxb3pyjsZzgb0HCUX8d KvuMHLaHhXIeB+TvjOazDoyAbaqJ5s1fhufwhd4GJZRr9smz1aUYK0CM5F5l5XMMBUyL npbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=opwe8jBw; 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=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l7-20020a056402254700b004186ff5a455si4472450edb.367.2022.03.14.18.57.45; Mon, 14 Mar 2022 18:58:09 -0700 (PDT) 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=@linuxfoundation.org header.s=korg header.b=opwe8jBw; 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=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235539AbiCNMWD (ORCPT + 99 others); Mon, 14 Mar 2022 08:22:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240935AbiCNMMf (ORCPT ); Mon, 14 Mar 2022 08:12:35 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 314BC34678; Mon, 14 Mar 2022 05:10:45 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 98B5F61343; Mon, 14 Mar 2022 12:10:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A83C7C36AE9; Mon, 14 Mar 2022 12:10:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1647259843; bh=TZFCzcRAJ2ywtVw4hszyoiDKGNP7GMYuWJEWqOZtKEI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=opwe8jBwttNQUgVEn1Ai9kRFTJlkoHADStNL1DOHOn23IXboFRp5hc5CHmUde6jBU y6AgyED+As5bQEvZgec79Yp/TBEtsjpZVg+zmplIItoP7MLOdwe61fpMfeahRjiSPi D2QK57LnBf+qSI5PZGPhLS0nucUDuyAaADHmqIZU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ross Philipson , Borislav Petkov , Daniel Kiper Subject: [PATCH 5.15 102/110] x86/boot: Add setup_indirect support in early_memremap_is_setup_data() Date: Mon, 14 Mar 2022 12:54:44 +0100 Message-Id: <20220314112745.873715665@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220314112743.029192918@linuxfoundation.org> References: <20220314112743.029192918@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 From: Ross Philipson commit 445c1470b6ef96440e7cfc42dfc160f5004fd149 upstream. The x86 boot documentation describes the setup_indirect structures and how they are used. Only one of the two functions in ioremap.c that needed to be modified to be aware of the introduction of setup_indirect functionality was updated. Adds comparable support to the other function where it was missing. Fixes: b3c72fc9a78e ("x86/boot: Introduce setup_indirect") Signed-off-by: Ross Philipson Signed-off-by: Borislav Petkov Reviewed-by: Daniel Kiper Cc: Link: https://lore.kernel.org/r/1645668456-22036-3-git-send-email-ross.philipson@oracle.com Signed-off-by: Greg Kroah-Hartman --- arch/x86/mm/ioremap.c | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) --- a/arch/x86/mm/ioremap.c +++ b/arch/x86/mm/ioremap.c @@ -675,22 +675,51 @@ static bool memremap_is_setup_data(resou static bool __init early_memremap_is_setup_data(resource_size_t phys_addr, unsigned long size) { + struct setup_indirect *indirect; struct setup_data *data; u64 paddr, paddr_next; paddr = boot_params.hdr.setup_data; while (paddr) { - unsigned int len; + unsigned int len, size; if (phys_addr == paddr) return true; data = early_memremap_decrypted(paddr, sizeof(*data)); + if (!data) { + pr_warn("failed to early memremap setup_data entry\n"); + return false; + } + + size = sizeof(*data); paddr_next = data->next; len = data->len; - early_memunmap(data, sizeof(*data)); + if ((phys_addr > paddr) && (phys_addr < (paddr + len))) { + early_memunmap(data, sizeof(*data)); + return true; + } + + if (data->type == SETUP_INDIRECT) { + size += len; + early_memunmap(data, sizeof(*data)); + data = early_memremap_decrypted(paddr, size); + if (!data) { + pr_warn("failed to early memremap indirect setup_data\n"); + return false; + } + + indirect = (struct setup_indirect *)data->data; + + if (indirect->type != SETUP_INDIRECT) { + paddr = indirect->addr; + len = indirect->len; + } + } + + early_memunmap(data, size); if ((phys_addr > paddr) && (phys_addr < (paddr + len))) return true;