Re: [PATCH RFC 01/10] vmalloc: Add basic perm alloc implementation

From: Christoph Hellwig
Date: Mon Nov 23 2020 - 04:00:58 EST


First thanks for doing this, having a vmalloc variant that starts out
with proper permissions has been on my todo list for a while.


> +#define PERM_R 1
> +#define PERM_W 2
> +#define PERM_X 4
> +#define PERM_RWX (PERM_R | PERM_W | PERM_X)
> +#define PERM_RW (PERM_R | PERM_W)
> +#define PERM_RX (PERM_R | PERM_X)

Why can't this use the normal pgprot flags?

> +typedef u8 virtual_perm;

This would need __bitwise annotations to allow sparse to typecheck the
flags.

> +/*
> + * Allocate a special permission kva region. The region may not be mapped
> + * until a call to perm_writable_finish(). A writable region will be mapped
> + * immediately at the address returned by perm_writable_addr(). The allocation
> + * will be made between the start and end virtual addresses.
> + */
> +struct perm_allocation *perm_alloc(unsigned long vstart, unsigned long vend, unsigned long page_cnt,
> + virtual_perm perms);

Please avoid totally pointless overly long line (all over the series)

Also I find the unsigned long for kernel virtual address interface
strange, but I'll take a look at the callers later.