>
> +static int sgx_open(struct inode *inode, struct file *file)
> +{
> + int ret;
> +
> + ret = sgx_inc_usage_count();
> + if (ret)
> + return ret;
> +
> + ret = __sgx_open(inode, file);
> + if (ret) {
> + sgx_dec_usage_count();
> + return ret;
> + }
> +
> + return 0;
> +}
> +
> static int sgx_release(struct inode *inode, struct file *file)
> {
> struct sgx_encl *encl = file->private_data;
> @@ -126,7 +143,7 @@ static long sgx_compat_ioctl(struct file *filep, unsigned
> int cmd,
>
> static const struct file_operations sgx_encl_fops = {
> .owner = THIS_MODULE,
> - .open = __sgx_open,
> + .open = sgx_open,
If you merge the first patch to this one, you can avoid such chunk in the
diff.
In fact, I think merging the first patch to this one makes sense because
__sgx_open() only makes sense when you have sgx_inc_usage_count().
[...]
>
> +/* Counter to count the active SGX users */
> +static int __maybe_unused sgx_usage_count;
As replied to the patch 6, I think you can just introduce this variable in
that patch.
> +
> +int sgx_inc_usage_count(void)
> +{
> + return 0;
> +}
> +
> +void sgx_dec_usage_count(void)
> +{
> + return;
> +}
> +
>
[...]
> @@ -265,6 +266,7 @@ static int __sgx_vepc_open(struct inode *inode, struct
> file *file)
> vepc = kzalloc(sizeof(struct sgx_vepc), GFP_KERNEL);
> if (!vepc)
> return -ENOMEM;
> +
Unintended change?
> mutex_init(&vepc->lock);
> xa_init(&vepc->page_array);
>
> @@ -273,6 +275,23 @@ static int __sgx_vepc_open(struct inode *inode, struct
> file *file)
> return 0;
> }
>
> +static int sgx_vepc_open(struct inode *inode, struct file *file)
> +{
> + int ret;
> +
> + ret = sgx_inc_usage_count();
> + if (ret)
> + return ret;
> +
> + ret = __sgx_vepc_open(inode, file);
> + if (ret) {
> + sgx_dec_usage_count();
> + return ret;
> + }
> +
> + return 0;
> +}
> +
> static long sgx_vepc_ioctl(struct file *file,
> unsigned int cmd, unsigned long arg)
> {
> @@ -291,7 +310,7 @@ static long sgx_vepc_ioctl(struct file *file,
>
> static const struct file_operations sgx_vepc_fops = {
> .owner = THIS_MODULE,
> - .open = __sgx_vepc_open,
> + .open = sgx_vepc_open,
Ditto to sgx_open().