Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp2518501ybk; Mon, 18 May 2020 00:48:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy9vzomyD58ihyNIxLZso2u9Nnd0tvsYWxfXauOOx88vo86MMwcxmMWK45YR0X8kDcP8yR3 X-Received: by 2002:a50:a365:: with SMTP id 92mr12765185edn.220.1589788089717; Mon, 18 May 2020 00:48:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589788089; cv=none; d=google.com; s=arc-20160816; b=KLsZ2eK8L09c7qTYVLz1B26FHgYpVo61vj/8/0hRM9QKthbPlqGjhixDZN5eMZbvRD PZgcWfNBGXVRjloVQ4uLptP5TJsYCp5hyTJcArAPEDZlDKgDXgKHNojVsm5YkykUvLgP d86G30iWImm+OMq50pcK7OauULUVktj+akWd9cUFv5xfpRru7i7WDJz4LnHfE91iuUi+ W6ifSbaoMcZMy6vUoG9wD6QIi8+ovjTMF85DA4S1mRBoUpnaJY9S8xZ0uZNkISFohRK5 7c+DokZW7fzCGheH5cqd9dFdnMUbaNUZBkWBPRtmnrmIo/xH768rw2yuU4CD1zm2ggSU zLFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=5Q2YrBj3FIoOK3rww59t4kufG8k4EsVRd1X/gCXGg6Q=; b=r4tw6NlgdCcBiOPzPJMDiSDYuHJTVkdB94IhQdXikIKekEhUm5f91/14ujIjj16RwB E/U4dB2i4tesWPlV/3GvgjUcI5rnstmIM1eNCI0vbQ8s42iRnURW2mVnJZy/fn0xVjUk MXUUyx0Phpmiurw6dRM0HY55wnGGK0i9yJpKfZ6hkf4ZhDr8NW63UMsBxeHRfm5d8xaV lP2fOrRfhHcEIgBh+CJuYbF5TLVC77wzJO6jhfXNd9BrTUWClVanoxtRc0LnYgvdwdGl kd/CT/1bIerdMSbV2+FY2cisgCrpeRkpPd1Q+JHXlnhm8TDPhQ0tGCKTyw//SO8m+9j5 mkXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rere.qmqm.pl header.s=1 header.b=JZwOONPR; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j93si5639619edd.458.2020.05.18.00.47.46; Mon, 18 May 2020 00:48:09 -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=@rere.qmqm.pl header.s=1 header.b=JZwOONPR; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727779AbgERHqS (ORCPT + 99 others); Mon, 18 May 2020 03:46:18 -0400 Received: from rere.qmqm.pl ([91.227.64.183]:25019 "EHLO rere.qmqm.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726489AbgERHqR (ORCPT ); Mon, 18 May 2020 03:46:17 -0400 Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 49QWKR03ryz7B; Mon, 18 May 2020 09:46:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1589787974; bh=gPgFXLS9rqplDfNULQiE4ZROGZg9KYP2t+MjXReQkrE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=JZwOONPRMimCnZ8qniI9/Og5meUwlsIwQu+SaDF0mP6iulU3o5QvOf7xeqHe46+sv eM7V/V9PiHVeuopUdxf8J4DFbhmaTDDnB1Q1x2Okc3h1iYhNzP2FueTo9R2/MVswxy AvqAUFezPqiW6ysElMburvQJvgC/+hl5A3IrmSMCWum8924jYCkDSwmH3KQe3f0vv8 nlsoCJRuz8reG7AO9pUamTVfSmlVHBV+naAZZDJ3EgIJeFfkYxbGufzRrhrlSZQ7pa isZ/roE3heIX/MFBVYam3L7+rWxMnzA6wbHp2aTUF9FyEU719lqxI/4QLlfpkcqTtL aSEmu/DQrtMSg== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.102.2 at mail Date: Mon, 18 May 2020 09:45:57 +0200 From: =?iso-8859-2?Q?Micha=B3_Miros=B3aw?= To: Dmitry Osipenko Cc: Jens Axboe , Thierry Reding , Jonathan Hunter , David Heidelberg , Peter Geis , Stephen Warren , Nicolas Chauvet , Ulf Hansson , Adrian Hunter , Billy Laws , Nils =?iso-8859-2?Q?=D6stlund?= , Christoph Hellwig , Ard Biesheuvel , Davidlohr Bueso , linux-tegra@vger.kernel.org, linux-block@vger.kernel.org, Andrey Danin , Gilles Grandou , Ryan Grachek , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, Steve McIntyre , Randy Dunlap , linux-efi Subject: Re: [PATCH v5 6/6] soc/tegra: Expose Boot Configuration Table via sysfs Message-ID: <20200518074557.GA12306@qmqm.qmqm.pl> References: <20200516153644.13748-1-digetx@gmail.com> <20200516153644.13748-7-digetx@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-2 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20200516153644.13748-7-digetx@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, May 16, 2020 at 06:36:44PM +0300, Dmitry Osipenko wrote: > It's quite useful to have unencrypted BCT exposed to userspace for > debugging purposes, so let's expose it via sysfs. The BCT data will be > present in '/sys/tegra/boot_config_table' binary file if BCT is available. [...] > +/* > + * spare_bct[] will be released once kernel is booted, hence not wasting > + * kernel space if BCT is missing. The tegra_bct can't be allocated during > + * of BCT setting up because it's too early for the slab allocator. > + */ > +static u8 spare_bct[SZ_8K] __initdata; > +static u8 *tegra_bct; > + > +static ssize_t boot_config_table_read(struct file *filp, > + struct kobject *kobj, > + struct bin_attribute *bin_attr, > + char *buf, loff_t off, size_t count) > +{ > + memcpy(buf, tegra_bct + off, count); > + return count; > +} > +static BIN_ATTR_RO(boot_config_table, 0); > + > +static int __init tegra_bootdata_bct_sysfs_init(void) > +{ > + if (!bin_attr_boot_config_table.size) > + return 0; > + > + tegra_bct = kmalloc(GFP_KERNEL, bin_attr_boot_config_table.size); > + if (!tegra_bct) > + return -ENOMEM; > + > + memcpy(tegra_bct, spare_bct, bin_attr_boot_config_table.size); > + > + return sysfs_create_bin_file(tegra_soc_kobj, > + &bin_attr_boot_config_table); Should we consider freeing the table if sysfs registration fails? > +} > +late_initcall(tegra_bootdata_bct_sysfs_init) > + > +void __init tegra_bootdata_bct_setup(void __iomem *bct_ptr, size_t bct_size) > +{ > + memcpy_fromio(spare_bct, bct_ptr, bct_size); > + bin_attr_boot_config_table.size = bct_size; [...] The size isn't checked anywhere. How the maximum is obtained? At least a comment would be good if the 8k limit is guaranteed by other means. Best Regards, Micha? Miros?aw