mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 02:01:24 +01:00
xen/p2m: move xenmem_access_to_p2m_access() to common p2m.c
Memory access and ALTP2M are two seperate features, while both depending on helper xenmem_access_to_p2m_access(). So it betters lives in common p2m.c, other than mem_access.c which will be compiled out when VM_EVENT=n && ALTP2M=y. Guard xenmem_access_to_p2m_access() with VM_EVENT || ALTP2M, otherwise it will become unreachable when both VM_EVENT=n and ALTP2M=n, and hence violating Misra rule 2.1. Also move declaration from xen/mem_access.h to x86'es one, requiring to also move the inclusion point and condition of asm/mem_access.h there. An extra blank line is inserted after each case-block to correct coding style at the same time. Signed-off-by: Penny Zheng <Penny.Zheng@amd.com> Acked-by: Jan Beulich <jbeulich@suse.com> Reviewed-by: Jason Andryuk <jason.andryuk@amd.com> Acked-by: Tamas K Lengyel <tamas@tklengyel.com>
This commit is contained in:
1 parent
0f45da4098
commit
0288e87afc
4 files changed
+48
-44
No files matched your search
@@ -34,6 +34,11 @@ bool p2m_mem_access_emulate_check(struct vcpu *v,
|
||||
/* Sanity check for mem_access hardware support */
|
||||
bool p2m_mem_access_sanity_check(const struct domain *d);
|
||||
|
||||
struct p2m_domain;
|
||||
bool xenmem_access_to_p2m_access(const struct p2m_domain *p2m,
|
||||
xenmem_access_t xaccess,
|
||||
p2m_access_t *paccess);
|
||||
|
||||
#endif /*__ASM_X86_MEM_ACCESS_H__ */
|
||||
|
||||
/*
|
||||
|
||||
@@ -298,42 +298,6 @@ static int set_mem_access(struct domain *d, struct p2m_domain *p2m,
|
||||
return rc;
|
||||
}
|
||||
|
||||
bool xenmem_access_to_p2m_access(const struct p2m_domain *p2m,
|
||||
xenmem_access_t xaccess,
|
||||
p2m_access_t *paccess)
|
||||
{
|
||||
static const p2m_access_t memaccess[] = {
|
||||
#define ACCESS(ac) [XENMEM_access_##ac] = p2m_access_##ac
|
||||
ACCESS(n),
|
||||
ACCESS(r),
|
||||
ACCESS(w),
|
||||
ACCESS(rw),
|
||||
ACCESS(x),
|
||||
ACCESS(rx),
|
||||
ACCESS(wx),
|
||||
ACCESS(rwx),
|
||||
ACCESS(rx2rw),
|
||||
ACCESS(n2rwx),
|
||||
ACCESS(r_pw),
|
||||
#undef ACCESS
|
||||
};
|
||||
|
||||
switch ( xaccess )
|
||||
{
|
||||
case 0 ... ARRAY_SIZE(memaccess) - 1:
|
||||
xaccess = array_index_nospec(xaccess, ARRAY_SIZE(memaccess));
|
||||
*paccess = memaccess[xaccess];
|
||||
break;
|
||||
case XENMEM_access_default:
|
||||
*paccess = p2m->default_access;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set access type for a region of gfns.
|
||||
* If gfn == INVALID_GFN, sets the default access type.
|
||||
|
||||
@@ -2203,6 +2203,46 @@ void p2m_log_dirty_range(struct domain *d, unsigned long begin_pfn,
|
||||
guest_flush_tlb_mask(d, d->dirty_cpumask);
|
||||
}
|
||||
|
||||
#if defined(CONFIG_VM_EVENT) || defined(CONFIG_ALTP2M)
|
||||
bool xenmem_access_to_p2m_access(const struct p2m_domain *p2m,
|
||||
xenmem_access_t xaccess,
|
||||
p2m_access_t *paccess)
|
||||
{
|
||||
static const p2m_access_t memaccess[] = {
|
||||
#define ACCESS(ac) [XENMEM_access_##ac] = p2m_access_##ac
|
||||
ACCESS(n),
|
||||
ACCESS(r),
|
||||
ACCESS(w),
|
||||
ACCESS(rw),
|
||||
ACCESS(x),
|
||||
ACCESS(rx),
|
||||
ACCESS(wx),
|
||||
ACCESS(rwx),
|
||||
ACCESS(rx2rw),
|
||||
ACCESS(n2rwx),
|
||||
ACCESS(r_pw),
|
||||
#undef ACCESS
|
||||
};
|
||||
|
||||
switch ( xaccess )
|
||||
{
|
||||
case 0 ... ARRAY_SIZE(memaccess) - 1:
|
||||
xaccess = array_index_nospec(xaccess, ARRAY_SIZE(memaccess));
|
||||
*paccess = memaccess[xaccess];
|
||||
break;
|
||||
|
||||
case XENMEM_access_default:
|
||||
*paccess = p2m->default_access;
|
||||
break;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif /* VM_EVENT || ALTP2M */
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* mode: C
|
||||
|
||||
@@ -33,10 +33,6 @@
|
||||
*/
|
||||
struct vm_event_st;
|
||||
|
||||
#ifdef CONFIG_VM_EVENT
|
||||
#include <asm/mem_access.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Additional access types, which are used to further restrict
|
||||
* the permissions given my the p2m_type_t memory type. Violations
|
||||
@@ -73,10 +69,9 @@ typedef enum {
|
||||
/* NOTE: Assumed to be only 4 bits right now on x86. */
|
||||
} p2m_access_t;
|
||||
|
||||
struct p2m_domain;
|
||||
bool xenmem_access_to_p2m_access(const struct p2m_domain *p2m,
|
||||
xenmem_access_t xaccess,
|
||||
p2m_access_t *paccess);
|
||||
#if defined(CONFIG_VM_EVENT) || defined(CONFIG_ALTP2M)
|
||||
#include <asm/mem_access.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Set access type for a region of gfns.
|
||||
|
||||