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@citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
This commit is contained in:
Andrew Cooper committed 2016-12-13 17:23:42 +00:00
1 parent 7a0c704825
commit 4045953527
3 files changed
+13 -6

No files matched your search

+9 -4
View File
@@ -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
+1 -2
View File
@@ -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;
+3
View File
@@ -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))
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.