[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 1/3] x86/paging: Enforce PG_external == PG_translate == PG_refcounts
Setting PG_refcounts but not PG_translate is not useful. While adjusting this, make a few other improvements. * Have paging_enable() unilaterally reject any unknown modes. * Drop the or'ing of PG_{HAP,SH}_enable. The underlying functions already do this. Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> Acked-by: Tim Deegan <tim@xxxxxxx> Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx> --- CC: George Dunlap <george.dunlap@xxxxxxxxxxxxx> v2: * Drop references to logdirty --- xen/arch/x86/mm/paging.c | 13 +++++++++---- xen/arch/x86/mm/shadow/common.c | 3 +-- xen/include/asm-x86/paging.h | 3 +++ 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/xen/arch/x86/mm/paging.c b/xen/arch/x86/mm/paging.c index 853a035..4437611 100644 --- a/xen/arch/x86/mm/paging.c +++ b/xen/arch/x86/mm/paging.c @@ -846,19 +846,24 @@ void paging_final_teardown(struct domain *d) * creation. */ int paging_enable(struct domain *d, u32 mode) { - switch ( mode & (PG_external | PG_translate) ) + /* Unrecognised paging mode? */ + if ( mode & ~PG_MASK ) + return -EINVAL; + + /* All of external|translate|refcounts, or none. */ + switch ( mode & (PG_external | PG_translate | PG_refcounts) ) { case 0: - case PG_external | PG_translate: + case PG_external | PG_translate | PG_refcounts: break; default: return -EINVAL; } if ( hap_enabled(d) ) - return hap_enable(d, mode | PG_HAP_enable); + return hap_enable(d, mode); else - return shadow_enable(d, mode | PG_SH_enable); + return shadow_enable(d, mode); } /* Called from the guest to indicate that a process is being torn down diff --git a/xen/arch/x86/mm/shadow/common.c b/xen/arch/x86/mm/shadow/common.c index acb35c2..79bb12e 100644 --- a/xen/arch/x86/mm/shadow/common.c +++ b/xen/arch/x86/mm/shadow/common.c @@ -3144,8 +3144,7 @@ int shadow_enable(struct domain *d, u32 mode) domain_pause(d); /* Sanity check the arguments */ - if ( shadow_mode_enabled(d) || - ((mode & PG_translate) && !(mode & PG_refcounts)) ) + if ( shadow_mode_enabled(d) ) { rv = -EINVAL; goto out_unlocked; diff --git a/xen/include/asm-x86/paging.h b/xen/include/asm-x86/paging.h index f83ed8b..cc29f9b 100644 --- a/xen/include/asm-x86/paging.h +++ b/xen/include/asm-x86/paging.h @@ -57,6 +57,9 @@ * requires VT or similar mechanisms */ #define PG_external (XEN_DOMCTL_SHADOW_ENABLE_EXTERNAL << PG_mode_shift) +/* All paging modes. */ +#define PG_MASK (PG_refcounts | PG_log_dirty | PG_translate | PG_external) + #define paging_mode_enabled(_d) (!!(_d)->arch.paging.mode) #define paging_mode_shadow(_d) (!!((_d)->arch.paging.mode & PG_SH_enable)) #define paging_mode_hap(_d) (!!((_d)->arch.paging.mode & PG_HAP_enable)) -- 2.1.4 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |