mirror of
https://github.com/xen-project/xen.git
synced 2026-10-30 03:00:05 +01:00
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:
1 parent
8cfe8bcf33
commit
a97bedb212
1 file changed
+11
-3
@@ -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);
|
||||
|
||||
|
||||