Hi Andrew,

On 06/15/2017 01:03 PM, Andrew Cooper wrote:
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 <prosku...@sec.in.tum.de>
---
Cc: Stefano Stabellini <sstabell...@kernel.org>
Cc: Julien Grall <julien.gr...@arm.com>
---
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.

I was not aware it was possible to do boolean fields. I am all for it.


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


Cheers,

--
Julien Grall

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

Reply via email to