Linux MultiMedia Card development
 help / color / mirror / Atom feed
From: Bart Van Assche <bvanassche@acm.org>
To: Shyam Saini <shyamsaini@linux.microsoft.com>,
	linux-kernel@vger.kernel.org
Cc: linux-mmc@vger.kernel.org, op-tee@lists.trustedfirmware.org,
	linux-scsi@vger.kernel.org,
	"Alex Bennée" <alex.bennee@linaro.org>,
	"Tomas Winkler" <tomas.winkler@intel.com>,
	"Ulf Hansson" <ulf.hansson@linaro.org>,
	"Linus Walleij" <linus.walleij@linaro.org>,
	"Arnd Bergmann" <arnd.bergmann@linaro.org>,
	"Ilias Apalodimas" <ilias.apalodimas@linaro.org>,
	"Sumit Garg" <sumit.garg@linaro.org>,
	"Tyler Hicks" <code@tyhicks.com>,
	"Srivatsa S . Bhat" <srivatsa@csail.mit.edu>,
	"Paul Moore" <paul@paul-moore.com>,
	"Allen Pais" <apais@linux.microsoft.com>
Subject: Re: [RFC, PATCH 1/1] rpmb: add Replay Protected Memory Block (RPMB) driver
Date: Mon, 7 Aug 2023 14:02:18 -0700	[thread overview]
Message-ID: <7c8945be-2549-ee79-fbdf-4870eca6f908@acm.org> (raw)
In-Reply-To: <20230722014037.42647-2-shyamsaini@linux.microsoft.com>

On 7/21/23 18:40, Shyam Saini wrote:
> +config RPMB
> +	tristate "RPMB partition interface"
> +	help
> +	  Unified RPMB partition interface for RPMB capable devices such as
> +          eMMC and UFS. Provides interface for in kernel security controllers to
> +	  access RPMB partition.
> +
> +	  If unsure, select N.

Please also mention NVMe.

Please change the word "partition" into "unit" to avoid confusion with 
the concept "LBA range partition".

> +static DEFINE_IDA(rpmb_ida);

How are accesses to this IDA serialized?

> +/**
> + * rpmb_get_capacity() - returns the capacity of the rpmb device
> + * @rdev: rpmb device
> + *
> + * Return:
> + * *        capacity of the device in units of 128K, on success
> + * *        -EINVAL on wrong parameters
> + * *        -EOPNOTSUPP if device doesn't support the requested operation
> + * *        < 0 if the operation fails
> + */

Why in units of 128 KiB?

> +/**
> + * rpmb_dev_find_by_device() - retrieve rpmb device from the parent device
> + * @parent: parent device of the rpmb device
> + * @target: RPMB target/region within the physical device
> + *
> + * Return: NULL if there is no rpmb device associated with the parent device
> + */

Can an NVMe controller have multiple RPMB units? From the NVMe 
specification: "The controller may support multiple RPMB targets."

Can rpmb_dev_find_by_device() be used if multiple RPMB units are 
associated with a single controller?

> +/**
> + * rpmb_dev_register - register RPMB partition with the RPMB subsystem
> + * @dev: storage device of the rpmb device
> + * @target: RPMB target/region within the physical device
> + * @ops: device specific operations
> + *
> + * Return: a pointer to rpmb device
> + */
> +struct rpmb_dev *rpmb_dev_register(struct device *dev, u8 target,
> +				   const struct rpmb_ops *ops)
> +{
> +	struct rpmb_dev *rdev;
> +	int id;
> +	int ret;
> +
> +	if (!dev || !ops)
> +		return ERR_PTR(-EINVAL);
> +
> +	if (!ops->program_key)
> +		return ERR_PTR(-EINVAL);
> +
> +	if (!ops->get_capacity)
> +		return ERR_PTR(-EINVAL);
> +
> +	if (!ops->get_write_counter)
> +		return ERR_PTR(-EINVAL);
> +
> +	if (!ops->write_blocks)
> +		return ERR_PTR(-EINVAL);
> +
> +	if (!ops->read_blocks)
> +		return ERR_PTR(-EINVAL);
> +
> +	rdev = kzalloc(sizeof(*rdev), GFP_KERNEL);
> +	if (!rdev)
> +		return ERR_PTR(-ENOMEM);
> +
> +	id = ida_simple_get(&rpmb_ida, 0, 0, GFP_KERNEL);
> +	if (id < 0) {
> +		ret = id;
> +		goto exit;
> +	}
> +
> +	mutex_init(&rdev->lock);
> +	rdev->ops = ops;
> +	rdev->id = id;
> +	rdev->target = target;
> +
> +	dev_set_name(&rdev->dev, "rpmb%d", id);
> +	rdev->dev.class = &rpmb_class;
> +	rdev->dev.parent = dev;
> +
> +	rpmb_cdev_prepare(rdev);
> +
> +	ret = device_register(&rdev->dev);
> +	if (ret)
> +		goto exit;
> +
> +	rpmb_cdev_add(rdev);
> +
> +	dev_dbg(&rdev->dev, "registered device\n");
> +
> +	return rdev;
> +
> +exit:
> +	if (id >= 0)
> +		ida_simple_remove(&rpmb_ida, id);
> +	kfree(rdev);
> +	return ERR_PTR(ret);
> +}

How is user space software supposed to map an NVMe RPMB target ID to an 
RPMB device name?

> +MODULE_AUTHOR("Intel Corporation");

Shouldn't this be the name of a person instead of the name of a company?

Thanks,

Bart.

  parent reply	other threads:[~2023-08-07 21:02 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-22  1:40 [RFC, PATCH 0/1] Replay Protected Memory Block (RPMB) driver Shyam Saini
2023-07-22  1:40 ` [RFC, PATCH 1/1] rpmb: add " Shyam Saini
2023-07-22  3:11   ` Randy Dunlap
2023-07-26 20:10     ` Shyam Saini
2023-08-07 15:00   ` Ulf Hansson
2023-08-16 23:31     ` Shyam Saini
2023-08-21  9:49       ` Jerome Forissier
2023-08-21 10:03         ` Sumit Garg
2023-08-21 11:18           ` Jens Wiklander
2023-08-21 11:54             ` Sumit Garg
2023-08-21 11:55             ` Ilias Apalodimas
2023-08-21 12:17               ` Sumit Garg
2023-08-22 19:07                 ` Shyam Saini
2023-08-23  8:04                   ` Linus Walleij
2023-08-24 14:07                     ` Sumit Garg
2023-08-21 12:35             ` Jerome Forissier
2023-08-22 18:59           ` Shyam Saini
2023-08-24 14:01             ` Sumit Garg
2023-08-22 18:47         ` Shyam Saini
2023-08-07 21:02   ` Bart Van Assche [this message]
2023-08-22 18:43     ` Shyam Saini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7c8945be-2549-ee79-fbdf-4870eca6f908@acm.org \
    --to=bvanassche@acm.org \
    --cc=alex.bennee@linaro.org \
    --cc=apais@linux.microsoft.com \
    --cc=arnd.bergmann@linaro.org \
    --cc=code@tyhicks.com \
    --cc=ilias.apalodimas@linaro.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=op-tee@lists.trustedfirmware.org \
    --cc=paul@paul-moore.com \
    --cc=shyamsaini@linux.microsoft.com \
    --cc=srivatsa@csail.mit.edu \
    --cc=sumit.garg@linaro.org \
    --cc=tomas.winkler@intel.com \
    --cc=ulf.hansson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox