mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 18:50:05 +01:00
x86/P2M: PoD, altp2m, and nested-p2m are HVM-only
There's no need to initialize respective data for PV domains. Note that
p2m_teardown_{alt,nested}p2m() will handle the lack-of-initialization
case fine.
As a result, despite PV domains having a host P2M associated with them
and hence using XENMEM_get_pod_target on such may not be a real problem,
calling p2m_pod_set_mem_target() for a PV domain is surely wrong, even
if benign at present. Add a guard there as well.
In p2m_pod_demand_populate() the situation is a little different: This
function is reachable only for HVM domains anyway, but following from
other PoD functions only ever acting on the host P2M (and hence PoD
entries only ever existing in host P2Ms), assert and bail from there for
non-host-P2Ms.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: George Dunlap <george.dunlap@citrix.com>
This commit is contained in:
1 parent
033ff90aa9
commit
26c719f67e
5 files changed
+42
-6
No files matched your search
@@ -679,8 +679,6 @@ static inline long p2m_pod_entry_count(const struct p2m_domain *p2m)
|
||||
return p2m->pod.entry_count;
|
||||
}
|
||||
|
||||
void p2m_pod_init(struct p2m_domain *p2m);
|
||||
|
||||
#else
|
||||
|
||||
static inline bool
|
||||
@@ -709,8 +707,6 @@ static inline long p2m_pod_entry_count(const struct p2m_domain *p2m)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void p2m_pod_init(struct p2m_domain *p2m) {}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
+3
-1
@@ -4810,7 +4810,9 @@ long arch_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
|
||||
if ( d == NULL )
|
||||
return -ESRCH;
|
||||
|
||||
if ( cmd == XENMEM_set_pod_target )
|
||||
if ( !is_hvm_domain(d) )
|
||||
rc = -EINVAL;
|
||||
else if ( cmd == XENMEM_set_pod_target )
|
||||
{
|
||||
rc = xsm_set_pod_target(XSM_PRIV, d);
|
||||
if ( rc )
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include <asm/p2m.h>
|
||||
|
||||
#include "mm-locks.h"
|
||||
#include "p2m.h"
|
||||
|
||||
#define superpage_aligned(_x) (((_x)&(SUPERPAGE_PAGES-1))==0)
|
||||
|
||||
@@ -1162,6 +1163,12 @@ p2m_pod_demand_populate(struct p2m_domain *p2m, gfn_t gfn,
|
||||
mfn_t mfn;
|
||||
unsigned long i;
|
||||
|
||||
if ( !p2m_is_hostp2m(p2m) )
|
||||
{
|
||||
ASSERT_UNREACHABLE();
|
||||
return false;
|
||||
}
|
||||
|
||||
ASSERT(gfn_locked_by_me(p2m, gfn));
|
||||
pod_lock(p2m);
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -101,6 +102,9 @@ static int p2m_initialise(struct domain *d, struct p2m_domain *p2m)
|
||||
p2m->default_access = p2m_access_rwx;
|
||||
p2m->p2m_class = p2m_host;
|
||||
|
||||
if ( !is_hvm_domain(d) )
|
||||
return 0;
|
||||
|
||||
p2m_pod_init(p2m);
|
||||
p2m_nestedp2m_init(p2m);
|
||||
|
||||
@@ -258,7 +262,7 @@ int p2m_init(struct domain *d)
|
||||
int rc;
|
||||
|
||||
rc = p2m_init_hostp2m(d);
|
||||
if ( rc )
|
||||
if ( rc || !is_hvm_domain(d) )
|
||||
return rc;
|
||||
|
||||
#ifdef CONFIG_HVM
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
/******************************************************************************
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
void p2m_pod_init(struct p2m_domain *p2m);
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* mode: C
|
||||
* c-file-style: "BSD"
|
||||
* c-basic-offset: 4
|
||||
* indent-tabs-mode: nil
|
||||
* End:
|
||||
*/
|
||||