@@ -43,6 +43,7 @@
#include <xsm/xsm.h>
#include "mm-locks.h"
+#include "p2m.h"
/* Override macro from asm/page.h to make work with mfn_t */
#undef virt_to_mfn
@@ -1366,12 +1367,9 @@ int clear_mmio_p2m_entry(struct domain *
return rc;
}
-#endif /* CONFIG_HVM */
-
-int set_identity_p2m_entry(struct domain *d, unsigned long gfn_l,
+int p2m_add_identity_entry(struct domain *d, unsigned long gfn_l,
p2m_access_t p2ma, unsigned int flag)
{
-#ifdef CONFIG_HVM
p2m_type_t p2mt;
p2m_access_t a;
gfn_t gfn = _gfn(gfn_l);
@@ -1381,13 +1379,8 @@ int set_identity_p2m_entry(struct domain
if ( !paging_mode_translate(d) )
{
-#endif
- if ( !is_iommu_enabled(d) )
- return 0;
- return iommu_legacy_map(d, _dfn(gfn_l), _mfn(gfn_l),
- 1ul << PAGE_ORDER_4K,
- IOMMUF_readable | IOMMUF_writable);
-#ifdef CONFIG_HVM
+ ASSERT_UNREACHABLE();
+ return -EPERM;
}
gfn_lock(p2m, gfn, 0);
@@ -1413,12 +1406,10 @@ int set_identity_p2m_entry(struct domain
gfn_unlock(p2m, gfn, 0);
return ret;
-#endif
}
-int clear_identity_p2m_entry(struct domain *d, unsigned long gfn_l)
+int p2m_remove_identity_entry(struct domain *d, unsigned long gfn_l)
{
-#ifdef CONFIG_HVM
p2m_type_t p2mt;
p2m_access_t a;
gfn_t gfn = _gfn(gfn_l);
@@ -1428,11 +1419,8 @@ int clear_identity_p2m_entry(struct doma
if ( !paging_mode_translate(d) )
{
-#endif
- if ( !is_iommu_enabled(d) )
- return 0;
- return iommu_legacy_unmap(d, _dfn(gfn_l), 1ul << PAGE_ORDER_4K);
-#ifdef CONFIG_HVM
+ ASSERT_UNREACHABLE();
+ return -EPERM;
}
gfn_lock(p2m, gfn, 0);
@@ -1454,7 +1442,6 @@ int clear_identity_p2m_entry(struct doma
}
return ret;
-#endif
}
#ifdef CONFIG_MEM_SHARING
@@ -1499,8 +1486,6 @@ int set_shared_p2m_entry(struct domain *
#endif /* CONFIG_MEM_SHARING */
-#ifdef CONFIG_HVM
-
static struct p2m_domain *
p2m_getlru_nestedp2m(struct domain *d, struct p2m_domain *p2m)
{
@@ -0,0 +1,31 @@
+/******************************************************************************
+ * arch/x86/mm/p2m.h
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <xen/mem_access.h>
+
+int p2m_add_identity_entry(struct domain *d, unsigned long gfn,
+ p2m_access_t p2ma, unsigned int flag);
+int p2m_remove_identity_entry(struct domain *d, unsigned long gfn);
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
@@ -21,9 +21,11 @@
* along with this program; If not, see <http://www.gnu.org/licenses/>.
*/
+#include <xen/iommu.h>
#include <asm/p2m.h>
#include "mm-locks.h"
+#include "p2m.h"
int
guest_physmap_add_page(struct domain *d, gfn_t gfn, mfn_t mfn,
@@ -75,6 +77,33 @@ guest_physmap_remove_page(struct domain
return p2m_remove_page(d, gfn, mfn, page_order);
}
+int set_identity_p2m_entry(struct domain *d, unsigned long gfn,
+ p2m_access_t p2ma, unsigned int flag)
+{
+ if ( !paging_mode_translate(d) )
+ {
+ if ( !is_iommu_enabled(d) )
+ return 0;
+ return iommu_legacy_map(d, _dfn(gfn), _mfn(gfn),
+ 1ul << PAGE_ORDER_4K,
+ IOMMUF_readable | IOMMUF_writable);
+ }
+
+ return p2m_add_identity_entry(d, gfn, p2ma, flag);
+}
+
+int clear_identity_p2m_entry(struct domain *d, unsigned long gfn)
+{
+ if ( !paging_mode_translate(d) )
+ {
+ if ( !is_iommu_enabled(d) )
+ return 0;
+ return iommu_legacy_unmap(d, _dfn(gfn), 1ul << PAGE_ORDER_4K);
+ }
+
+ return p2m_remove_identity_entry(d, gfn);
+}
+
/*
* Local variables:
* mode: C
..., moving the former into the new physmap.c. Signed-off-by: Jan Beulich <jbeulich@suse.com>