From mboxrd@z Thu Jan 1 00:00:00 1970 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 A1242C433F5 for ; Fri, 11 Feb 2022 18:41:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352743AbiBKSl3 (ORCPT ); Fri, 11 Feb 2022 13:41:29 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:44826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233923AbiBKSl0 (ORCPT ); Fri, 11 Feb 2022 13:41:26 -0500 Received: from mail.skyhub.de (mail.skyhub.de [IPv6:2a01:4f8:190:11c2::b:1457]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F078D25B for ; Fri, 11 Feb 2022 10:41:23 -0800 (PST) Received: from zn.tnic (dslb-088-067-221-104.088.067.pools.vodafone-ip.de [88.67.221.104]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 4E2EE1EC05DE; Fri, 11 Feb 2022 19:41:18 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1644604878; h=from:from: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:in-reply-to:in-reply-to: references:references; bh=zMuJMdA0rBX7JUREv1an+M91xZteNtLKe6TL7rOUDm8=; b=kny4RIW1G1W4VL7Wc34nYKT92JoAEzIr63ES31EjSCuJ01fu1n4Qpg3sFS03D+1hWGbblS mXFVRHkY8rbaQRI0haxrNESCOgROeQ1QVQkB4UL/yPupUF0XHpz9epkjVAEyf8zX+kF3Wg kwqrEBHzJenvAFM6dx6jZ7OTnSWIMEU= Date: Fri, 11 Feb 2022 19:41:20 +0100 From: Borislav Petkov To: Ross Philipson Cc: linux-kernel@vger.kernel.org, x86@kernel.org, daniel.kiper@oracle.com, dpsmith@apertussolutions.com, tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, luto@amacapital.net, kanth.ghatraju@oracle.com, trenchboot-devel@googlegroups.com Subject: Re: [PATCH 2/2] x86/boot: Add setup_indirect support in early_memremap_is_setup_data Message-ID: References: <1643303056-22272-1-git-send-email-ross.philipson@oracle.com> <1643303056-22272-3-git-send-email-ross.philipson@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <1643303056-22272-3-git-send-email-ross.philipson@oracle.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 27, 2022 at 12:04:16PM -0500, Ross Philipson wrote: > 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. This adds comparable support to the other s/This adds/Add/ > function where it was missing. > > Fixes: b3c72fc9a78e ("x86/boot: Introduce setup_indirect") > No need for a newline here. > Signed-off-by: Ross Philipson > Reviewed-by: Daniel Kiper > --- > 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 b45e86e..9129b29 100644 > --- a/arch/x86/mm/ioremap.c > +++ b/arch/x86/mm/ioremap.c > @@ -670,17 +670,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); That can return NULL. > + > + if (((struct setup_indirect *)data->data)->type != SETUP_INDIRECT) { > + paddr = ((struct setup_indirect *)data->data)->addr; > + len = ((struct setup_indirect *)data->data)->len; As before, use a helper variable here pls. Thx. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette