x86/domctl: Make XEN_DOMCTL_set_address_size singleshot

Toolstacks (including some out-of-tree ones) use XEN_DOMCTL_set_address_size
at most once per domain, and it ends up having a destructive effect on the
available CPUID policy for a domain.

To avoid ordering issues between altering the policy via domctl, and the
constructive effects which would have to happen from switching back to native,
explicitly reject this case.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
This commit is contained in:
Andrew Cooper committed 2017-01-06 19:22:01 +00:00
1 parent 9422b16a50
commit 02e78311cd
3 files changed
+7 -44

No files matched your search

+1 -32
View File
@@ -322,43 +322,12 @@ static void release_compat_l4(struct vcpu *v)
v->arch.guest_table_user = pagetable_null();
}
static inline int may_switch_mode(struct domain *d)
{
return (!is_hvm_domain(d) && (d->tot_pages == 0));
}
int switch_native(struct domain *d)
{
struct vcpu *v;
if ( !may_switch_mode(d) )
return -EACCES;
if ( !is_pv_32bit_domain(d) && !is_pvh_32bit_domain(d) )
return 0;
d->arch.is_32bit_pv = d->arch.has_32bit_shinfo = 0;
for_each_vcpu( d, v )
{
free_compat_arg_xlat(v);
if ( !is_pvh_domain(d) )
release_compat_l4(v);
else
hvm_set_mode(v, 8);
}
d->arch.x87_fip_width = cpu_has_fpu_sel ? 0 : 8;
return 0;
}
int switch_compat(struct domain *d)
{
struct vcpu *v;
int rc;
if ( !may_switch_mode(d) )
if ( is_hvm_domain(d) || d->tot_pages != 0 )
return -EACCES;
if ( is_pv_32bit_domain(d) || is_pvh_32bit_domain(d) )
return 0;
+6 -11
View File
@@ -514,18 +514,13 @@ long arch_do_domctl(
break;
case XEN_DOMCTL_set_address_size:
switch ( domctl->u.address_size.size )
{
case 32:
if ( ((domctl->u.address_size.size == 64) && !d->arch.is_32bit_pv) ||
((domctl->u.address_size.size == 32) && d->arch.is_32bit_pv) )
ret = 0;
else if ( domctl->u.address_size.size == 32 )
ret = switch_compat(d);
break;
case 64:
ret = switch_native(d);
break;
default:
ret = (domctl->u.address_size.size == BITS_PER_LONG) ? 0 : -EINVAL;
break;
}
else
ret = -EINVAL;
break;
case XEN_DOMCTL_get_address_size:
-1
View File
@@ -231,7 +231,6 @@ struct vcpu_runstate_info;
void xlat_vcpu_runstate_info(struct vcpu_runstate_info *);
int switch_compat(struct domain *);
int switch_native(struct domain *);
#else
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.