Re: [PATCH v5 6/6] soc/tegra: Expose Boot Configuration Table via sysfs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.



[Index of Archives]     [ARM Kernel]     [Linux ARM]     [Linux ARM MSM]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux