* 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
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;
* 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))