Re: [RFC PATCH v2 14/26] x86/sgx: Move provisioning device creation out of SGX driver

Kai Huang
2021-01-21T00:00:53Z

> >
> > +const struct file_operations sgx_provision_fops = {
> > + .owner = THIS_MODULE,
> > +};
> > +
> > +static struct miscdevice sgx_dev_provision = {
> > + .minor = MISC_DYNAMIC_MINOR,
> > + .name = "sgx_provision",
> > + .nodename = "sgx_provision",
> > + .fops = &sgx_provision_fops,
> > +};
> > +
> > +int sgx_set_attribute(unsigned long *allowed_attributes,
> > + unsigned int attribute_fd)
>
> kdoc

Will do.

>
> > +{
> > + struct file *file;
> > +
> > + file = fget(attribute_fd);
> > + if (!file)
> > + return -EINVAL;
> > +
> > + if (file->f_op != &sgx_provision_fops) {
> > + fput(file);
> > + return -EINVAL;
> > + }
> > +
> > + *allowed_attributes |= SGX_ATTR_PROVISIONKEY;
> > +
> > + fput(file);
> > + return 0;
> > +}
> > +EXPORT_SYMBOL_GPL(sgx_set_attribute);
> > +