Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp887194rwb; Wed, 9 Nov 2022 09:49:16 -0800 (PST) X-Google-Smtp-Source: AMsMyM7UNNSFwH+DwRDMody5lIq/zHKfxmoFYGrC3qNThq0aZOeaOZa93Htn1Pm2Q6fPntT/RbFJ X-Received: by 2002:a17:906:fe45:b0:791:9624:9ea4 with SMTP id wz5-20020a170906fe4500b0079196249ea4mr57123109ejb.147.1668016156032; Wed, 09 Nov 2022 09:49:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668016156; cv=none; d=google.com; s=arc-20160816; b=G7SQwysy7LvEerVFZb+4My3ciX4LRDTn5I1cqBhu+kHPbpJQuQI2ngZtoIL+I855ns RxUOSYcKa5QllQ4dYLvTXlTUAdc/EWHuo8eLwZxRKG9FKCpSr03r7Psx089Hb4SUc/oE gccGanPNj6SQDrZDaziKocx7jcJORx75wsYqa18fo/Bf4NRbtjwPV/wH7miO6K5v/hEx /Qlghajw6Je/jxvq4bdRBMU5K0o94wWFTN/+vb8S6sLjZ0Dl6r7XqUA4jC6ByYfg1dTl fBMbzCs8/sx8Kf0z1O64lz0DDH7XrRA58iNdL5TIF/uz2Q/ebMmaruYJlnqbI9D0LCtW iBOA== 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=U8E7Jm8e1876qUqey5/8BiJLc1XaDBvWcjC7yx9ROzg=; b=eppJxcy0aId+6eE0Z41UYvmu8lsnNQ2oLk0ojWpNlYL9rr06LkTv8t1pnjeRUapRYJ 3yEFq//sQeVjgUn/Y30EeUnSseYsmux2o8HNCBS7Eg/7QZjPVKGQ4SB1LmwYExWBXy5e AjEoocg7t/hFwzVB4ticiVSIuE+m2nHnmCiNM3lWIVhmG5LWQTwJhiVePx+G2lf+dFk8 jmaXunfcQJpk96ZQOO3BDovmFlFE29WwBJOBTryB/K+jub7eZM0LZiPJqbm3oFXPcWKO d4KIwwcO4+9yVF1riGgk5Mf2N1/gxraktLXEjLzOsQaHR1+jHrp1cwtt7R7gUH5qLrYy mX0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b="gmH5h/mQ"; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h12-20020a05640250cc00b00452dfa2bb27si4842498edb.134.2022.11.09.09.48.53; Wed, 09 Nov 2022 09:49: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=@infradead.org header.s=casper.20170209 header.b="gmH5h/mQ"; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231418AbiKIRVQ (ORCPT + 92 others); Wed, 9 Nov 2022 12:21:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229750AbiKIRVO (ORCPT ); Wed, 9 Nov 2022 12:21:14 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 551E125C8; Wed, 9 Nov 2022 09:21:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=U8E7Jm8e1876qUqey5/8BiJLc1XaDBvWcjC7yx9ROzg=; b=gmH5h/mQ6qEquszdoCqVrpILhD iK+Kn9JHkuehJ2b1rL/vezAXYWk0g3pgHr7Iy/bU1gc3he4FIVq3yXOY55t5UfEjBxHetnvUf7TEN sA7IMRXPsK/N42x13tITnCCN/virflVFzUjbq/NWOF+5NR7/TJJCqt76qufO0ugPmwCpdfJJivc5a osQkbkyKeXSgy0E4O0x9ZfTPlAFK/2N170Qq7YhrJqYEP+1KaiC2loLtcK8AdIBu3jn/6awOQon6Z jv7RxpJFjzlqVSJ4ty0ykIzFEYXt2wMLx5Hh5VwgxdpsOcaf/3h9HS4qDfKuj4uHxAEnu4qohzwjs 2sB3e4pQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1osol3-00BLdJ-H0; Wed, 09 Nov 2022 17:21:01 +0000 Date: Wed, 9 Nov 2022 17:21:01 +0000 From: Matthew Wilcox To: Daniel Golle Cc: Jens Axboe , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Davidlohr Bueso , "Martin K. Petersen" , Chaitanya Kulkarni , Ming Lei , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, linux-efi@vger.kernel.org Subject: Re: [PATCH v4 2/5] block: add partition parser for U-Boot uImage.FIT Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,PDS_OTHER_BAD_TLD, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE 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 On Wed, Nov 09, 2022 at 02:36:11PM +0000, Daniel Golle wrote: > On Wed, Nov 09, 2022 at 01:58:29PM +0000, Matthew Wilcox wrote: > > ... actually, why can't you call read_part_sector() and avoid all of > > this? > > I've tried that before and the problem is that read_part_sector() > returns a pointer to one sector (typically 512 bytes) of data. > And this pointer should not be accesses beyond sector boundaries, > right? You'd have to call read_part_sector() again for the next > sector. > > The FIT structure, however, usually exceeds the size of one sector, > and having a continous memory area covering the structure as a whole > is crucial for libfdt to do its job. > > I could, of course, use read_part_sector() to copy all sectors > covering the FIT structure into a buffer, but that seemed strange > given that read_part_sector() actually used read_mapping_page() > (and now uses read_mapping_folio()) internally and then returns a > pointer to the offset within the page/folio. So why not read it in one > piece in first place instead of having it first split up to sectors > by read_part_sector() just to then having to reassemble it into a > continous buffer again. Are you guaranteed that it's "sufficiently" aligned on storage so that it fits entirely within a single page? If not, you'll have to copy it, vmap it, or fix libfdt to handle a segmented buffer.