Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp3722016pxt; Tue, 10 Aug 2021 09:49:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzW+IoeCECGlnwYXFgVXRXoPUCtgVwuG6zP8fierFJOCKyi/DYB0s2Bt/8jBTsVyUt5qYrV X-Received: by 2002:a17:906:5393:: with SMTP id g19mr3633340ejo.93.1628614140016; Tue, 10 Aug 2021 09:49:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628614140; cv=none; d=google.com; s=arc-20160816; b=KTDPIdohW6IkJxoogwMMQZmXj/bGNfwNTnVR0JIaay5TU/Zg/vQMgMySKWKQzqnI0W Qe10Ah8fV0ZHqOUtyWAuKp2R2D+WI5yWEn1a5WYInYU87c8DA7Aq+cSwhXglcDR7M6QF Vng9coxyZuiRRfO70+lxYa9/2zkPv0GRmZvtpQinMPjt59NoD7dqNVmHqIobhb0tLipr dUF9B8W0qS4f5b09ifbRbEbXI5RAbiVAYQCmfc1xcTs6n3kZr3Acgq8Kzkpc36GnkM2Y vYoKGeaxOo4TYcNqRL5zRNG2GDF1JkQOC/GZcYIwtcyVc52VdEgcbicIqOojxMsJuN3a x+gw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=V0eusVDK9wWE0WxacBn7YW+rUSQH8RQmqc2ghKNLOOo=; b=fr65PBoZiKEKAwrnr9fFyx7fTPZfw5PUXO3tJtOp/Ahq9D9w/tNZcJNiuHoB81DLBY d5BY5TBefDMCD+ZdSgZcoZrBQCG98IWlJxUemHkbfJ8NNENGYF+8JfVCgqUSOA1nKR6o 1LNDhYMPhQJoDZXprdakpUY0WKQ6/5Sppyn5VRKBQVwTH/1D5DWV5vSKaaFDjLrClhof P+Sew2uei+4QHOp7P/TfiX9Y7zMxLW7vElP2Iytl8qZcEXT4NjqX2Ff0IP/RKXaC4+Qz 1AWXT0Km/wGHHcjvHipYR/3IB3ytE1DdX0ixl2iHIzsGpPQMqgyC51Ir69nYGfWL2R8d 3M7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="FoKJI/tW"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cw2si22690968ejc.730.2021.08.10.09.48.32; Tue, 10 Aug 2021 09:49:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="FoKJI/tW"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231654AbhHJQT5 (ORCPT + 99 others); Tue, 10 Aug 2021 12:19:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:52626 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229783AbhHJQT4 (ORCPT ); Tue, 10 Aug 2021 12:19:56 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0D515600CC; Tue, 10 Aug 2021 16:19:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1628612374; bh=rUrQspPgCz1GB/kLMPpAV5Oz5uFIYwUtwRxo8l8CgxQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=FoKJI/tWK/6kSLtIxyJfheigFp9Dbk39gOIdQawyWlg/IV94uf8MeVLmFCk/QQFGZ nrURh8v2Y/B2Ah/51rD46AOuFfzffVzne77EWYedGNlu+fHlDNjC/TI0ahcurePvdQ MRbnVzVIw3VloWG+nu87QnB1v4o+O5LBh8KhXkybvvbw7+Z0+xXZajZMOnP5Zy6vMx yYLnP9WMwnDJVHB+x0oKDdtdOqdf8pStAfdCAqjQzZjXJxNo/bsOltJkph/KE8sFoa J/M+fytEJTw0ReNNrAkT0GAGy4pF2vseBrTdWNnLtxsewLz4VYcDA+jV7RlAr0AEMR jXgBkj8miZhkA== Date: Tue, 10 Aug 2021 19:19:32 +0300 From: Jarkko Sakkinen To: Ross Philipson Cc: linux-kernel@vger.kernel.org, x86@kernel.org, iommu@lists.linux-foundation.org, linux-integrity@vger.kernel.org, linux-doc@vger.kernel.org, dpsmith@apertussolutions.com, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, hpa@zytor.com, luto@amacapital.net, kanth.ghatraju@oracle.com, trenchboot-devel@googlegroups.com Subject: Re: [PATCH v3 02/14] x86/boot: Add missing handling of setup_indirect structures Message-ID: <20210810161932.wdwfu3wosjytdj4h@kernel.org> References: <1628527136-2478-1-git-send-email-ross.philipson@oracle.com> <1628527136-2478-3-git-send-email-ross.philipson@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1628527136-2478-3-git-send-email-ross.philipson@oracle.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Aug 09, 2021 at 12:38:44PM -0400, Ross Philipson wrote: > One of the two functions in ioremap.c that handles setup_data was > missing the correct handling of setup_indirect structures. What is "correct handling", and how was it broken? What is 'setup_indirect'? > Functionality missing from original commit: Remove this sentence. > commit b3c72fc9a78e (x86/boot: Introduce setup_indirect) Should be. Fixes: b3c72fc9a78e ("x86/boot: Introduce setup_indirect") > Signed-off-by: Ross Philipson > --- > arch/x86/mm/ioremap.c | 21 +++++++++++++++++++-- > 1 file changed, 19 insertions(+), 2 deletions(-) > > diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c > index ab74e4f..f2b34c5 100644 > --- a/arch/x86/mm/ioremap.c > +++ b/arch/x86/mm/ioremap.c > @@ -669,17 +669,34 @@ static bool __init early_memremap_is_setup_data(resource_size_t phys_addr, > > 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)); > + 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 (((struct setup_indirect *)data->data)->type != SETUP_INDIRECT) { > + paddr = ((struct setup_indirect *)data->data)->addr; > + len = ((struct setup_indirect *)data->data)->len; > + } > + } > + > + early_memunmap(data, size); > > if ((phys_addr > paddr) && (phys_addr < (paddr + len))) > return true; > -- > 1.8.3.1 > > /Jarkko