Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp2525647ybk; Mon, 18 May 2020 01:02:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwNiEFfvbaRSbbjEu011wrt2HqjprzNg0w/heGH1thWSvXDF9vB6eJttzeUJ6Sp5wWwWr6g X-Received: by 2002:a05:6402:3106:: with SMTP id dc6mr12234372edb.19.1589788953743; Mon, 18 May 2020 01:02:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589788953; cv=none; d=google.com; s=arc-20160816; b=lHx4tgI/lKSwvZnel6R3ucKg78arJ36WrHYFNhmkP3jM0XgiaqjGQ8sjFpXsZq2JxB EAG2E2i4Ej73enVxGJ/cnyjuUrTezhPfCljcXEtLCVuN1Jn1nzI1i1IkW6SvhK0wO8Sr bSfz7sSGpc7D38Svsqm/5bUvye5wSvKj1XBCXpSob0N/R0y82q/XTcweIIuTd4BwFLPT k5MM9f+XlVU2dEt0vrqsP9DH+k3NtvYxOsPD92dMKGQ5hPfU9SMPJ0d6//I5/7v1CzCz YT52ATIw05NISnkomHX5A35rF/+LuMcsjatrjSK9pLuB0o7ivto+4T0fTT9jQMKu+EZ2 T+Lg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=Wa0lI6K9c2yizlhSExJV0yCXbar6s/0dBsIvA7fyzwA=; b=l0ysJMm7RdmmRJ4QHCOk7GilL7mB7IPjR95TcWF0wq3DmQ8U31dwG13IxylbdSSWgn sVFYHmTU7zRCArhpJLGT/mnBPGhaFmfuBbxPUaoVGXpCUKdxHyNFdzH34QH3ZjOhfuOz JtirmUKsSnItkAwshRrQKzWSNxlgzRGG+PafzyxhkNV+JojXk+PfnNfHlJt24Nqpbt2I DFGx8qWtb6TtnCU/fWVOd3cO0sg3cNTRcfsnofzQGgxdqxFJ5rWkc/O9L188239pSqpt 5DQIx2csI8dU0cQm5xT2VvIfq36ahWxqq/6DPHINMHjZfftesaMkc++SLmDVpZXXlgR8 yfKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=oPLDLtlC; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v28si5747829edi.192.2020.05.18.01.02.09; Mon, 18 May 2020 01:02:33 -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=@gmail.com header.s=20161025 header.b=oPLDLtlC; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726990AbgERIAv (ORCPT + 99 others); Mon, 18 May 2020 04:00:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726489AbgERIAv (ORCPT ); Mon, 18 May 2020 04:00:51 -0400 Received: from mail-lj1-x242.google.com (mail-lj1-x242.google.com [IPv6:2a00:1450:4864:20::242]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BCF0EC061A0C; Mon, 18 May 2020 01:00:50 -0700 (PDT) Received: by mail-lj1-x242.google.com with SMTP id b6so8804388ljj.1; Mon, 18 May 2020 01:00:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=Wa0lI6K9c2yizlhSExJV0yCXbar6s/0dBsIvA7fyzwA=; b=oPLDLtlCK3B2UirJcEaAVEMyyyarJuhdVpRe82gCi9qltMAuPD8+OrVGJNnsu287dw Q+QMgQPlK7qMFybK+ZqLbtPuTyn3Dq6KSa8oEoC+5QCSMdknUudt/2FTp7r2nwyilvHA nqz5JzFr7pde7P+TGvcGEHny8gHDgFqR9bMeFQ8ib76BiO+aleTsPs6qsf2/q5cLLd6v pih0UohBzTW47QmtMyw4IutJEaa9SQJsrRs4FW5YFDQu+SOvZtAP4euOrD8LRV9yJEdZ DsgilaN2qQZpqi00fMZjPpyz9tBhmgX4MG8okHdhPqhfQAam3mKhAs2Ga2/o6QHy2iCF rfvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=Wa0lI6K9c2yizlhSExJV0yCXbar6s/0dBsIvA7fyzwA=; b=DMjqZtyj4TMcMR299funv873V+nBkKKCzdBcXdJeh/j0rwkRTxei9SNWyaajOKDfOY qpbqc7XWICTAWVtrjGbaP6pNxXzHlox64o8ZnXTq5n4pBq03DDGHx8xqs8PA3wtCcONr u8vs27gv2J9kT9l2VLU0TQq6hZjd99v241xIPbWT/dwGbt0QD2Bdz6A9tZBzGAq01i42 Ev1WNrZ1q2FFhA0GXgaWM9EfVnmOKDheg7yzqiJh1TI48g3kyOm07Uk3j9pHI9kLBKnO UWx1aQfQ/p5Z43jxs/i3w+1cAmf0MjgeDeYJIOCvR0nmmK1HYeJIrvjb4Y0gugYL3rCQ JZsA== X-Gm-Message-State: AOAM530dHKiB8dq4V+VjnEkcfZJZcMMXRlPo7Viu0tHV6llBjfM6BAdO 95LGcHZasEO1mZfh6t3ZFMPjQFxW X-Received: by 2002:a2e:a211:: with SMTP id h17mr10103921ljm.289.1589788848104; Mon, 18 May 2020 01:00:48 -0700 (PDT) Received: from [192.168.2.145] (ppp91-78-208-152.pppoe.mtu-net.ru. [91.78.208.152]) by smtp.googlemail.com with ESMTPSA id m10sm6452213lfd.15.2020.05.18.01.00.46 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 18 May 2020 01:00:47 -0700 (PDT) Subject: Re: [PATCH v5 6/6] soc/tegra: Expose Boot Configuration Table via sysfs To: =?UTF-8?B?TWljaGHFgiBNaXJvc8WCYXc=?= Cc: Jens Axboe , Thierry Reding , Jonathan Hunter , David Heidelberg , Peter Geis , Stephen Warren , Nicolas Chauvet , Ulf Hansson , Adrian Hunter , Billy Laws , =?UTF-8?Q?Nils_=c3=96stlund?= , 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 References: <20200516153644.13748-1-digetx@gmail.com> <20200516153644.13748-7-digetx@gmail.com> <20200518074557.GA12306@qmqm.qmqm.pl> From: Dmitry Osipenko Message-ID: <75e7d242-268c-07a3-a4f9-7b8252769140@gmail.com> Date: Mon, 18 May 2020 11:00:46 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <20200518074557.GA12306@qmqm.qmqm.pl> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 18.05.2020 10:45, Michał Mirosław пишет: > 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? This is a good suggestion, thank you :) >> +} >> +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. Yes, I can add a clarifying comment about the 8K. It also should be possible to create a union of T20/T30 BCT structs and then use use sizeof(bct_union). I'll consider this change for the next version, thank you for the suggestion.