Files
xen/tools/libs/ctrl/xc_core_arm.c
T
Juergen Gross 2b23bb664f tools/libs/ctrl: fix xc_core_arch_map_p2m() to support linear p2m table
The core of a pv linux guest produced via "xl dump-core" is not usable
as since kernel 4.14 only the linear p2m table is kept if Xen indicates
it is supporting that. Unfortunately xc_core_arch_map_p2m() is still
supporting the 3-level p2m tree only.

Fix that by copying the functionality of map_p2m() from libxenguest to
libxenctrl.

Additionally the mapped p2m isn't of a fixed length now, so the
interface to the mapping functions needs to be adapted. In order not to
add even more parameters, expand struct domain_info_context and use a
pointer to that as a parameter.

This is a backport of upstream commit bd7a29c3d0.

As the original patch includes a modification of a data structure
passed via pointer to a library function, the related function in the
library is renamed in order to be able to spot any external users of
that function. Note that it is extremely unlikely any such users
outside the Xen git tree are existing, so the risk to break any
existing programs is very unlikely. In case such a user is existing,
changing the name of xc_map_domain_meminfo() will at least avoid
silent breakage.

Fixes: dc6d609371 ("libxc: set flag for support of linear p2m list in domain builder")
Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Ian Jackson <iwj@xenproject.org>
2021-08-19 17:12:10 +01:00

114 lines
3.0 KiB
C

/*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; If not, see <http://www.gnu.org/licenses/>.
*
* Copyright (c) 2011 Citrix Systems
*
*/
#include "xc_private.h"
#include "xc_core.h"
#include <xen-tools/libs.h>
int
xc_core_arch_gpfn_may_present(struct xc_core_arch_context *arch_ctxt,
unsigned long pfn)
{
/* TODO: memory from DT */
if (pfn >= 0x80000 && pfn < 0x88000)
return 1;
return 0;
}
int
xc_core_arch_auto_translated_physmap(const xc_dominfo_t *info)
{
return 1;
}
int
xc_core_arch_memory_map_get(xc_interface *xch, struct xc_core_arch_context *unused,
xc_dominfo_t *info, shared_info_any_t *live_shinfo,
xc_core_memory_map_t **mapp,
unsigned int *nr_entries)
{
xen_pfn_t p2m_size = 0;
xc_core_memory_map_t *map;
if ( xc_domain_nr_gpfns(xch, info->domid, &p2m_size) < 0 )
return -1;
map = malloc(sizeof(*map));
if ( map == NULL )
{
PERROR("Could not allocate memory");
return -1;
}
map->addr = 0;
map->size = ((uint64_t)p2m_size) << PAGE_SHIFT;
*mapp = map;
*nr_entries = 1;
return 0;
}
static int
xc_core_arch_map_p2m_rw(xc_interface *xch, struct domain_info_context *dinfo, xc_dominfo_t *info,
shared_info_any_t *live_shinfo, xen_pfn_t **live_p2m, int rw)
{
errno = ENOSYS;
return -1;
}
int
xc_core_arch_map_p2m(xc_interface *xch, struct domain_info_context *dinfo, xc_dominfo_t *info,
shared_info_any_t *live_shinfo, xen_pfn_t **live_p2m)
{
return xc_core_arch_map_p2m_rw(xch, dinfo, info, live_shinfo, live_p2m, 0);
}
int
xc_core_arch_map_p2m_writable(xc_interface *xch, struct domain_info_context *dinfo, xc_dominfo_t *info,
shared_info_any_t *live_shinfo, xen_pfn_t **live_p2m)
{
return xc_core_arch_map_p2m_rw(xch, dinfo, info, live_shinfo, live_p2m, 1);
}
int
xc_core_arch_get_scratch_gpfn(xc_interface *xch, uint32_t domid,
xen_pfn_t *gpfn)
{
/*
* The Grant Table region space is not used until the guest is
* booting. Use the first page for the scratch pfn.
*/
BUILD_BUG_ON(GUEST_GNTTAB_SIZE < XC_PAGE_SIZE);
*gpfn = GUEST_GNTTAB_BASE >> XC_PAGE_SHIFT;
return 0;
}
/*
* Local variables:
* mode: C
* c-file-style: "BSD"
* c-basic-offset: 4
* tab-width: 4
* indent-tabs-mode: nil
* End:
*/