#endif
}
-#ifdef CONFIG_HVM
-/*
- * Set/clear the #VE suppress bit for a page. Only available on VMX.
- */
-int p2m_set_suppress_ve(struct domain *d, gfn_t gfn, bool suppress_ve,
- unsigned int altp2m_idx)
-{
- struct p2m_domain *host_p2m = p2m_get_hostp2m(d);
- struct p2m_domain *ap2m = NULL;
- struct p2m_domain *p2m;
- mfn_t mfn;
- p2m_access_t a;
- p2m_type_t t;
- int rc;
-
- if ( !cpu_has_vmx_virt_exceptions )
- return -EOPNOTSUPP;
-
- /* #VE should be enabled for this vcpu. */
- if ( gfn_eq(vcpu_altp2m(current).veinfo_gfn, INVALID_GFN) )
- return -ENXIO;
-
- if ( altp2m_idx > 0 )
- {
- if ( altp2m_idx >= MAX_ALTP2M ||
- d->arch.altp2m_eptp[altp2m_idx] == mfn_x(INVALID_MFN) )
- return -EINVAL;
-
- p2m = ap2m = d->arch.altp2m_p2m[altp2m_idx];
- }
- else
- p2m = host_p2m;
-
- gfn_lock(host_p2m, gfn, 0);
-
- if ( ap2m )
- p2m_lock(ap2m);
-
- mfn = p2m->get_entry(p2m, gfn, &t, &a, 0, NULL, NULL);
- if ( !mfn_valid(mfn) )
- {
- rc = -ESRCH;
- goto out;
- }
-
- rc = p2m->set_entry(p2m, gfn, mfn, PAGE_ORDER_4K, t, a, suppress_ve);
-
-out:
- if ( ap2m )
- p2m_unlock(ap2m);
-
- gfn_unlock(host_p2m, gfn, 0);
-
- return rc;
-}
-
-int p2m_get_suppress_ve(struct domain *d, gfn_t gfn, bool *suppress_ve,
- unsigned int altp2m_idx)
-{
- struct p2m_domain *host_p2m = p2m_get_hostp2m(d);
- struct p2m_domain *ap2m = NULL;
- struct p2m_domain *p2m;
- mfn_t mfn;
- p2m_access_t a;
- p2m_type_t t;
-
- if ( !cpu_has_vmx_virt_exceptions )
- return -EOPNOTSUPP;
-
- /* #VE should be enabled for this vcpu. */
- if ( gfn_eq(vcpu_altp2m(current).veinfo_gfn, INVALID_GFN) )
- return -ENXIO;
-
- if ( altp2m_idx > 0 )
- {
- if ( altp2m_idx >= MAX_ALTP2M ||
- d->arch.altp2m_eptp[altp2m_idx] == mfn_x(INVALID_MFN) )
- return -EINVAL;
-
- p2m = ap2m = d->arch.altp2m_p2m[altp2m_idx];
- }
- else
- p2m = host_p2m;
-
- gfn_lock(host_p2m, gfn, 0);
-
- if ( ap2m )
- p2m_lock(ap2m);
-
- mfn = p2m->get_entry(p2m, gfn, &t, &a, 0, NULL, suppress_ve);
- if ( !mfn_valid(mfn) )
- return -ESRCH;
-
- if ( ap2m )
- p2m_unlock(ap2m);
-
- gfn_unlock(host_p2m, gfn, 0);
-
- return 0;
-}
-#endif
-
/*
* Local variables:
* mode: C
struct domain *d = p2m->domain;
ASSERT(ept);
+
+ if ( !sve )
+ {
+ if ( !cpu_has_vmx_virt_exceptions )
+ return -EOPNOTSUPP;
+
+ /* #VE should be enabled for this vcpu. */
+ if ( gfn_eq(vcpu_altp2m(current).veinfo_gfn, INVALID_GFN) )
+ return -ENXIO;
+ }
+
/*
* the caller must make sure:
* 1. passing valid gfn and mfn at order boundary.
unsigned int flags, iommu_old_flags = 0;
unsigned long old_mfn = mfn_x(INVALID_MFN);
- ASSERT(sve != 0);
+ if ( !sve )
+ return -EOPNOTSUPP;
if ( tb_init_done )
{
rcu_unlock_domain(fdom);
return rc;
}
+
+#ifdef CONFIG_HVM
+/*
+ * Set/clear the #VE suppress bit for a page. Only available on VMX.
+ */
+int p2m_set_suppress_ve(struct domain *d, gfn_t gfn, bool suppress_ve,
+ unsigned int altp2m_idx)
+{
+ struct p2m_domain *host_p2m = p2m_get_hostp2m(d);
+ struct p2m_domain *ap2m = NULL;
+ struct p2m_domain *p2m;
+ mfn_t mfn;
+ p2m_access_t a;
+ p2m_type_t t;
+ int rc;
+
+ if ( altp2m_idx > 0 )
+ {
+ if ( altp2m_idx >= MAX_ALTP2M ||
+ d->arch.altp2m_eptp[altp2m_idx] == mfn_x(INVALID_MFN) )
+ return -EINVAL;
+
+ p2m = ap2m = d->arch.altp2m_p2m[altp2m_idx];
+ }
+ else
+ p2m = host_p2m;
+
+ gfn_lock(host_p2m, gfn, 0);
+
+ if ( ap2m )
+ p2m_lock(ap2m);
+
+ mfn = p2m->get_entry(p2m, gfn, &t, &a, 0, NULL, NULL);
+ if ( !mfn_valid(mfn) )
+ {
+ rc = -ESRCH;
+ goto out;
+ }
+
+ rc = p2m->set_entry(p2m, gfn, mfn, PAGE_ORDER_4K, t, a, suppress_ve);
+
+out:
+ if ( ap2m )
+ p2m_unlock(ap2m);
+
+ gfn_unlock(host_p2m, gfn, 0);
+
+ return rc;
+}
+
+int p2m_get_suppress_ve(struct domain *d, gfn_t gfn, bool *suppress_ve,
+ unsigned int altp2m_idx)
+{
+ struct p2m_domain *host_p2m = p2m_get_hostp2m(d);
+ struct p2m_domain *ap2m = NULL;
+ struct p2m_domain *p2m;
+ mfn_t mfn;
+ p2m_access_t a;
+ p2m_type_t t;
+ int rc = 0;
+
+ if ( altp2m_idx > 0 )
+ {
+ if ( altp2m_idx >= MAX_ALTP2M ||
+ d->arch.altp2m_eptp[altp2m_idx] == mfn_x(INVALID_MFN) )
+ return -EINVAL;
+
+ p2m = ap2m = d->arch.altp2m_p2m[altp2m_idx];
+ }
+ else
+ p2m = host_p2m;
+
+ gfn_lock(host_p2m, gfn, 0);
+
+ if ( ap2m )
+ p2m_lock(ap2m);
+
+ mfn = p2m->get_entry(p2m, gfn, &t, &a, 0, NULL, suppress_ve);
+ if ( !mfn_valid(mfn) )
+ rc = -ESRCH;
+
+ if ( ap2m )
+ p2m_unlock(ap2m);
+
+ gfn_unlock(host_p2m, gfn, 0);
+
+ return rc;
+}
+#endif
+
/*
* Local variables:
* mode: C