[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen staging] x86/P2M: PoD, altp2m, and nested-p2m are HVM-only
commit 26c719f67e71d5ff4cabc44cba37de2155204cbb Author: Jan Beulich <jbeulich@xxxxxxxx> AuthorDate: Fri Apr 8 14:41:51 2022 +0200 Commit: Jan Beulich <jbeulich@xxxxxxxx> CommitDate: Fri Apr 8 14:41:51 2022 +0200 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> Reviewed-by: George Dunlap <george.dunlap@xxxxxxxxxx> --- xen/arch/x86/include/asm/p2m.h | 4 ---- xen/arch/x86/mm.c | 4 +++- xen/arch/x86/mm/p2m-pod.c | 7 +++++++ xen/arch/x86/mm/p2m.c | 6 +++++- xen/arch/x86/mm/p2m.h | 27 +++++++++++++++++++++++++++ 5 files changed, 42 insertions(+), 6 deletions(-) diff --git a/xen/arch/x86/include/asm/p2m.h b/xen/arch/x86/include/asm/p2m.h index 30236daba3..44c953c83a 100644 --- 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(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 diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 6cc73187ac..e90789085b 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -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 ) diff --git a/xen/arch/x86/mm/p2m-pod.c b/xen/arch/x86/mm/p2m-pod.c index afee09ab40..fd12f8ca73 100644 --- 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_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); diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c index 48bff44a6a..1f1eddac48 100644 --- 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 *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 diff --git a/xen/arch/x86/mm/p2m.h b/xen/arch/x86/mm/p2m.h new file mode 100644 index 0000000000..ec1d54f915 --- /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: + */ -- generated by git-patchbot for /home/xen/git/xen.git#staging
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |