[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [RFC PATCH v3 04/10] arm/mem_access: Add short-descriptor pte typedefs



On 15/06/17 12:05, Sergej Proskurin wrote:
> The current implementation does not provide appropriate types for
> short-descriptor translation table entries. As such, this commit adds new
> types, which simplify managing the respective translation table entries.
>
> Signed-off-by: Sergej Proskurin <proskurin@xxxxxxxxxxxxx>
> ---
> Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>
> Cc: Julien Grall <julien.grall@xxxxxxx>
> ---
> v3: Add more short-descriptor related pte typedefs that will be used by
>     the following commits.
> ---
>  xen/include/asm-arm/page.h | 104 
> +++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 104 insertions(+)
>
> diff --git a/xen/include/asm-arm/page.h b/xen/include/asm-arm/page.h
> index e2e4b597a5..7a4aa64144 100644
> --- a/xen/include/asm-arm/page.h
> +++ b/xen/include/asm-arm/page.h
> @@ -205,6 +205,110 @@ typedef union {
>      lpae_walk_t walk;
>  } lpae_t;
>  
> +/*
> + *  Comprises bits of the level 1 short-descriptor format representing
> + *  a section.
> + */
> +typedef struct __packed {
> +    unsigned int pxn:1;         /* Privileged Execute Never */

(I'm not an ARM maintainer, but) can I recommend using bool bitfields
for boolean fields like this.

There's no difference when using the structure for reading data, but it
helps reduce subtle bugs such as

foo.pxn = (flags & NO_EXECUTE);

when using the structures to create a new value, or modify existing ones.

~Andrew

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.