xen/arm: p2m: Simplify p2m type check by using bitmask

The resulting assembly code for the macros is much simpler and will
never contain more than one instruction branch.

The idea is taken from x86 (see include/asm-x86/p2m.h). Also move the
two helpers earlier to keep all the p2m type definitions together.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
This commit is contained in:
Julien Grall authored and Stefano Stabellini committed 2016-07-26 15:36:32 -07:00
1 parent 8cfe8bcf33
commit a97bedb212
1 file changed
+11 -3
+11 -3
View File
@@ -97,6 +97,17 @@ typedef enum {
p2m_max_real_type, /* Types after this won't be store in the p2m */
} p2m_type_t;
/* We use bitmaps and mask to handle groups of types */
#define p2m_to_mask(_t) (1UL << (_t))
/* RAM types, which map to real machine frames */
#define P2M_RAM_TYPES (p2m_to_mask(p2m_ram_rw) | \
p2m_to_mask(p2m_ram_ro))
/* Useful predicates */
#define p2m_is_ram(_t) (p2m_to_mask(_t) & P2M_RAM_TYPES)
#define p2m_is_foreign(_t) (p2m_to_mask(_t) & p2m_to_mask(p2m_map_foreign))
static inline
void p2m_mem_access_emulate_check(struct vcpu *v,
const vm_event_response_t *rsp)
@@ -110,9 +121,6 @@ void p2m_altp2m_check(struct vcpu *v, uint16_t idx)
/* Not supported on ARM. */
}
#define p2m_is_foreign(_t) ((_t) == p2m_map_foreign)
#define p2m_is_ram(_t) ((_t) == p2m_ram_rw || (_t) == p2m_ram_ro)
/* Initialise vmid allocator */
void p2m_vmid_allocator_init(void);
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.