[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v2 06/14] 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@xxxxxxxx> --- v2: Also guard XENMEM_{get,set}_pod_target handling. Re-base over wider p2m_add_identity_entry() exposure in earlier patch. Add missing inclusion of "p2m.h". Mention the p2m_pod_demand_populate() adjustment separately in the description. --- Perhaps p2m_pod_init() could be invoked from p2m_init_hostp2m(), leaving all other p2m's PoD state uninitialized. Of course at that point the question would be whether the PoD pieces of struct p2m_domain wouldn't better move into a separate structure, present only for host P2Ms. Together with the p2m_pod_demand_populate() adjustment this might then better be a separate change ... --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -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 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 --- /dev/null +++ b/xen/arch/x86/mm/p2m.h @@ -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: + */ --- a/xen/arch/x86/mm/p2m-pod.c +++ b/xen/arch/x86/mm/p2m-pod.c @@ -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_domai 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); --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -4810,7 +4810,9 @@ long arch_memory_op(unsigned long cmd, X 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 ) --- a/xen/arch/x86/include/asm/p2m.h +++ b/xen/arch/x86/include/asm/p2m.h @@ -679,8 +679,6 @@ static inline long p2m_pod_entry_count(c 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(c return 0; } -static inline void p2m_pod_init(struct p2m_domain *p2m) {} - #endif
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |