lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 24 Feb 2020 11:30:43 -0700
From:   Mathieu Poirier <mathieu.poirier@...aro.org>
To:     Siddharth Gupta <sidgup@...eaurora.org>
Cc:     ohad@...ery.com, bjorn.andersson@...aro.org,
        linux-remoteproc@...r.kernel.org, linux-kernel@...r.kernel.org,
        linux-arm-msm@...r.kernel.org,
        linux-arm-kernel@...ts.infradead.org, tsoni@...eaurora.org,
        psodagud@...eaurora.org, rishabhb@...eaurora.org
Subject: Re: [PATCH 1/2] remoteproc: core: Add an API for booting with
 firmware name

Hi Siddharth,

On Wed, Feb 19, 2020 at 06:11:52PM -0800, Siddharth Gupta wrote:
> Add an API which allows to change the name of the firmware to be booted on
> the specified rproc. This change gives us the flixibility to change the
> firmware at run-time depending on the usecase. Some remoteprocs might use
> a different firmware for testing, production and development purposes,
> which may be selected based on the fuse settings during bootup.
> 
> Signed-off-by: Siddharth Gupta <sidgup@...eaurora.org>
> ---
>  drivers/remoteproc/remoteproc_core.c | 34 ++++++++++++++++++++++++++++++++++
>  include/linux/remoteproc.h           |  1 +
>  2 files changed, 35 insertions(+)
> 
> diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
> index 097f33e..5ab65a4 100644
> --- a/drivers/remoteproc/remoteproc_core.c
> +++ b/drivers/remoteproc/remoteproc_core.c
> @@ -1779,6 +1779,40 @@ int rproc_boot(struct rproc *rproc)
>  EXPORT_SYMBOL(rproc_boot);
>  
>  /**
> + * rproc_boot_with_fw() - boot a remote processor with the specified firmware
> + * @rproc: handle of a remote processor
> + * @firmware: name of the firmware to boot with
> + *
> + * Change the name of the firmware to be loaded to @firmware in the rproc
> + * structure, and call rproc_boot().
> + *
> + * Returns 0 on success, and an appropriate error value otherwise.
> + */
> +int rproc_boot_with_fw(struct rproc *rproc, const char *firmware)
> +{
> +	char *p;
> +
> +	if (!rproc) {
> +		pr_err("invalid rproc handle\n");
> +		return -EINVAL;
> +	}

        if (!rproc || !firmware)
                return -EINVAL;

There is no user involved here so no point in printing anything.  If @rproc or
@firmware is NULL than callers should be smart enough to figure it out from the
error code.

> +
> +	if (firmware) {
> +		p = kstrdup(firmware, GFP_KERNEL);
> +		if (!p)
> +			return -ENOMEM;

As in firmware_store() I think it is a good idea to mandate the MCU be offline
before changing the firmware name.  That way we avoid situations where what is
running on the MCU is not what gets reported in sysfs.

> +
> +		mutex_lock(&rproc->lock);
> +		kfree(rproc->firmware);
> +		rproc->firmware = p;

> +		mutex_unlock(&rproc->lock);
> +	}
> +
> +	return rproc_boot(rproc);

Function rproc_boot() is also an exported symbol and belongs in the caller -
please move it out of here.  When that is done rproc_boot_with_fw() can become
rproc_set_firmware_name() and concentrate on doing just that.

> +}
> +EXPORT_SYMBOL(rproc_boot_with_fw);

Although choosing the firmware image to boot without user involvement seems like
a valid scenario to me, this can't be added until there is an actual user of
this API.

> +
> +/**
>   * rproc_shutdown() - power off the remote processor
>   * @rproc: the remote processor
>   *
> diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h
> index 16ad666..e2eaba9 100644
> --- a/include/linux/remoteproc.h
> +++ b/include/linux/remoteproc.h
> @@ -609,6 +609,7 @@ rproc_of_resm_mem_entry_init(struct device *dev, u32 of_resm_idx, int len,
>  			     u32 da, const char *name, ...);
>  
>  int rproc_boot(struct rproc *rproc);
> +int rproc_boot_with_fw(struct rproc *rproc, const char *firmware);
>  void rproc_shutdown(struct rproc *rproc);
>  void rproc_report_crash(struct rproc *rproc, enum rproc_crash_type type);
>  int rproc_coredump_add_segment(struct rproc *rproc, dma_addr_t da, size_t size);
> -- 
> Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
> a Linux Foundation Collaborative Project

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ