On Thu, Nov 05, 2026 at 09:05:36PM +0000, Lorenzo Stoakes (ARM) wrote:
> Move from the deprecated mmap hook to the new mmap_prepare hook. The hook
> only checks that the mapping is shared and sets VMA flags, operations and
> private data.
> 
> Signed-off-by: Lorenzo Stoakes (ARM) <[email protected]>
> ---
>  arch/x86/kernel/cpu/sgx/virt.c | 15 ++++++++-------
>  1 file changed, 8 insertions(+), 7 deletions(-)
> 
> diff --git a/arch/x86/kernel/cpu/sgx/virt.c b/arch/x86/kernel/cpu/sgx/virt.c
> index 6a1933ddc6fc..850990519ca5 100644
> --- a/arch/x86/kernel/cpu/sgx/virt.c
> +++ b/arch/x86/kernel/cpu/sgx/virt.c
> @@ -98,17 +98,18 @@ static const struct vm_operations_struct sgx_vepc_vm_ops 
> = {
>       .fault = sgx_vepc_fault,
>  };
>  
> -static int sgx_vepc_mmap(struct file *file, struct vm_area_struct *vma)
> +static int sgx_vepc_mmap_prepare(struct vm_area_desc *desc)
>  {
> -     struct sgx_vepc *vepc = file->private_data;
> +     struct sgx_vepc *vepc = desc->file->private_data;
>  
> -     if (!(vma->vm_flags & VM_SHARED))
> +     if (!vma_desc_test(desc, VMA_SHARED_BIT))
>               return -EINVAL;
>  
> -     vma->vm_ops = &sgx_vepc_vm_ops;
> +     desc->vm_ops = &sgx_vepc_vm_ops;
>       /* Don't copy VMA in fork() */
> -     vm_flags_set(vma, VM_PFNMAP | VM_IO | VM_DONTDUMP | VM_DONTCOPY);
> -     vma->vm_private_data = vepc;
> +     vma_desc_set_flags(desc, VMA_PFNMAP_BIT, VMA_IO_BIT, VMA_DONTDUMP_BIT,
> +                        VMA_DONTCOPY_BIT);
> +     desc->private_data = vepc;
>  
>       return 0;
>  }
> @@ -315,7 +316,7 @@ static const struct file_operations sgx_vepc_fops = {
>       .unlocked_ioctl = sgx_vepc_ioctl,
>       .compat_ioctl   = sgx_vepc_ioctl,
>       .release        = sgx_vepc_release,
> -     .mmap           = sgx_vepc_mmap,
> +     .mmap_prepare   = sgx_vepc_mmap_prepare,
>  };
>  
>  static struct miscdevice sgx_vepc_dev = {
> 
> -- 
> 2.56.0
> 

Reviewed-by: Jarkko Sakkinen <[email protected]>

Br, Jarkko

Reply via email to