Remove unused XENMEM_translate_pfn_list.

Never used by a guest OS (except in IA64 hcall translation layer) and
obsoleted in the tools for ages. Recent usage by qemu-dm is now
removed.

Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
This commit is contained in:
Keir Fraser committed 2009-01-14 11:15:01 +00:00
1 parent b1b4a612b6
commit 2d2f7977a0
11 files changed
+3 -512

No files matched your search

-27
View File
@@ -537,33 +537,6 @@ int xc_domain_memory_populate_physmap(int xc_handle,
return err;
}
int xc_domain_memory_translate_gpfn_list(int xc_handle,
uint32_t domid,
unsigned long nr_gpfns,
xen_pfn_t *gpfn_list,
xen_pfn_t *mfn_list)
{
int err;
struct xen_translate_gpfn_list translate_gpfn_list = {
.domid = domid,
.nr_gpfns = nr_gpfns,
};
set_xen_guest_handle(translate_gpfn_list.gpfn_list, gpfn_list);
set_xen_guest_handle(translate_gpfn_list.mfn_list, mfn_list);
err = xc_memory_op(xc_handle, XENMEM_translate_gpfn_list, &translate_gpfn_list);
if ( err != 0 )
{
DPRINTF("Failed translation for dom %d (%ld PFNs)\n",
domid, nr_gpfns);
errno = -err;
err = -1;
}
return err;
}
static int xc_domain_memory_pod_target(int xc_handle,
int op,
uint32_t domid,
-6
View File
@@ -628,12 +628,6 @@ int xc_domain_memory_populate_physmap(int xc_handle,
unsigned int mem_flags,
xen_pfn_t *extent_start);
int xc_domain_memory_translate_gpfn_list(int xc_handle,
uint32_t domid,
unsigned long nr_gpfns,
xen_pfn_t *gpfn_list,
xen_pfn_t *mfn_list);
int xc_domain_memory_set_pod_target(int xc_handle,
uint32_t domid,
uint64_t target_pages,
-48
View File
@@ -1,48 +0,0 @@
#
# xen/arch/ia64/tools/p2m_foreign
#
# Copyright (c) 2006 Isaku Yamahata <yamahata at valinux co jp>
# VA Linux Systems Japan K.K.
#
# 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, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
XEN_ROOT = ../../../../..
include $(XEN_ROOT)/tools/Rules.mk
CFLAGS += -Werror -ggdb3
CFLAGS += -I$(XEN_LIBXC) -I$(XEN_XENSTORE)
PROGRAMS = p2m_foreign
LDLIBS = -L$(XEN_LIBXC) -L$(XEN_XENSTORE) -lxenguest -lxenctrl
.PHONY: all
all: build
.PHONY: build
build: $(PROGRAMS)
$(PROGRAMS): %: %.o
$(CC) $(CFLAGS) $^ $(LDLIBS) -o $@
.PHONY: install
install:
.PHONY: clean
clean:
$(RM) *.o $(PROGRAMS)
$(RM) $(DEPS)
-include $(DEPS)
@@ -1,233 +0,0 @@
/*
* Foreign p2m exposure test.
*
* 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, write to the Free Software
* Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Copyright (c) 2007 Isaku Yamahata <yamahata at valinux co jp>
* VA Linux Systems Japan K.K.
*
*/
#include <sys/mman.h>
#include <err.h>
#include <errno.h>
#include <assert.h>
#include <xc_private.h>
#include <xenctrl.h>
#include <xenguest.h>
#include <xc_efi.h>
#include <ia64/xc_ia64.h>
#if 1
# define printd(fmt, args...) printf(fmt, ##args)
#else
# define printd(fmt, args...) ((void)0)
#endif
/* xc_memory_op() in xc_private.c doesn't support translate_gpfn_list */
static int
__xc_memory_op(int xc_handle, int cmd, void *arg)
{
DECLARE_HYPERCALL;
struct xen_translate_gpfn_list* translate = arg;
xen_ulong_t* gpfns;
xen_ulong_t* mfns;
size_t len;
long ret = -EINVAL;
hypercall.op = __HYPERVISOR_memory_op;
hypercall.arg[0] = (unsigned long)cmd;
hypercall.arg[1] = (unsigned long)arg;
assert(cmd == XENMEM_translate_gpfn_list);
get_xen_guest_handle(gpfns, translate->gpfn_list);
get_xen_guest_handle(mfns, translate->mfn_list);
len = sizeof(gpfns[0]) * translate->nr_gpfns;
if (lock_pages(translate, sizeof(*translate)) ||
lock_pages(gpfns, len) ||
lock_pages(mfns, len))
goto out;
ret = do_xen_hypercall(xc_handle, &hypercall);
out:
unlock_pages(mfns, len);
unlock_pages(gpfns, len);
unlock_pages(translate, sizeof(*translate));
return ret;
}
int
xc_translate_gpfn_list(int xc_handle, uint32_t domid, xen_ulong_t nr_gpfns,
xen_ulong_t* gpfns, xen_ulong_t* mfns)
{
struct xen_translate_gpfn_list translate = {
.domid = domid,
.nr_gpfns = nr_gpfns,
};
set_xen_guest_handle(translate.gpfn_list, gpfns);
set_xen_guest_handle(translate.mfn_list, mfns);
return __xc_memory_op(xc_handle,
XENMEM_translate_gpfn_list, &translate);
}
int
main(int argc, char** argv)
{
uint32_t domid;
int xc_handle;
xc_dominfo_t info;
shared_info_t* shinfo;
unsigned long map_size;
xen_ia64_memmap_info_t* memmap_info;
struct xen_ia64_p2m_table p2m_table;
char* p;
char* start;
char* end;
xen_ulong_t nr_gpfns;
xen_ulong_t* gpfns;
xen_ulong_t* mfns;
unsigned long i;
if (argc != 2)
errx(EXIT_FAILURE, "usage: %s <domid>", argv[0]);
domid = atol(argv[1]);
printd("xc_interface_open()\n");
xc_handle = xc_interface_open();
if (xc_handle < 0)
errx(EXIT_FAILURE, "can't open control interface");
printd("xc_domain_getinfo\n");
if (xc_domain_getinfo(xc_handle, domid, 1, &info) != 1)
errx(EXIT_FAILURE, "Could not get info for domain");
printd("shared info\n");
shinfo = xc_map_foreign_range(xc_handle, domid, PAGE_SIZE,
PROT_READ, info.shared_info_frame);
if (shinfo == NULL)
errx(EXIT_FAILURE, "can't map shared info");
printd("memmap_info\n");
map_size = PAGE_SIZE * shinfo->arch.memmap_info_num_pages;
memmap_info = xc_map_foreign_range(xc_handle, info.domid,
map_size, PROT_READ,
shinfo->arch.memmap_info_pfn);
if (memmap_info == NULL)
errx(EXIT_FAILURE, "can't map memmap_info");
#if 1
start = (char*)&memmap_info->memdesc;
end = start + memmap_info->efi_memmap_size;
i = 0;
for (p = start; p < end; p += memmap_info->efi_memdesc_size) {
efi_memory_desc_t* md = (efi_memory_desc_t*)p;
printd("%ld [0x%lx, 0x%lx) 0x%lx pages\n",
i, md->phys_addr,
md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT),
md->num_pages >> (PAGE_SHIFT - EFI_PAGE_SHIFT));
i++;
}
#endif
printd("p2m map\n");
if (xc_ia64_p2m_map(&p2m_table, xc_handle, domid, memmap_info, 0) < 0)
errx(EXIT_FAILURE, "can't map foreign p2m table");
printd("p2m map done\n");
start = (char*)&memmap_info->memdesc;
end = start + memmap_info->efi_memmap_size;
nr_gpfns = 0;
i = 0;
for (p = start; p < end; p += memmap_info->efi_memdesc_size) {
efi_memory_desc_t* md = (efi_memory_desc_t*)p;
if ( md->type != EFI_CONVENTIONAL_MEMORY ||
md->attribute != EFI_MEMORY_WB ||
md->num_pages == 0 )
continue;
printd("%ld [0x%lx, 0x%lx) 0x%lx pages\n",
i, md->phys_addr,
md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT),
md->num_pages >> (PAGE_SHIFT - EFI_PAGE_SHIFT));
nr_gpfns += md->num_pages >> (PAGE_SHIFT - EFI_PAGE_SHIFT);
i++;
}
printd("total 0x%lx gpfns\n", nr_gpfns);
gpfns = malloc(sizeof(gpfns[0]) * nr_gpfns);
mfns = malloc(sizeof(mfns[0]) * nr_gpfns);
if (gpfns == NULL || mfns == NULL)
err(EXIT_FAILURE, "can't allocate memory for gpfns/mfns");
i = 0;
for (p = start; p < end; p += memmap_info->efi_memdesc_size) {
efi_memory_desc_t* md = (efi_memory_desc_t*)p;
unsigned long j;
if ( md->type != EFI_CONVENTIONAL_MEMORY ||
md->attribute != EFI_MEMORY_WB ||
md->num_pages == 0 )
continue;
for (j = 0;
j < md->num_pages >> (PAGE_SHIFT - EFI_PAGE_SHIFT);
j++) {
gpfns[i] = (md->phys_addr >> PAGE_SHIFT) + j;
i++;
}
}
for (i = 0; i < nr_gpfns; i++)
mfns[i] = INVALID_MFN;
printd("issue translate gpfn list hypercall. "
"this may take a while\n");
if (xc_translate_gpfn_list(xc_handle,
domid, nr_gpfns, gpfns, mfns) < 0)
err(EXIT_FAILURE, "translate gpfn list hypercall failure");
printd("translate gpfn list hypercall done\n");
printd("checking p2m table\n");
for (i = 0; i < nr_gpfns; i++) {
unsigned long mfn_by_translated = mfns[i];
unsigned long mfn_by_p2m =
xc_ia64_p2m_mfn(&p2m_table, gpfns[i]);
if (mfn_by_translated != mfn_by_p2m &&
!(mfn_by_translated == 0 && mfn_by_p2m == INVALID_MFN)) {
printf("ERROR! i 0x%lx gpfn "
"0x%lx trnslated 0x%lx p2m 0x%lx\n",
i, gpfns[i], mfn_by_translated, mfn_by_p2m);
}
}
printd("checking p2m table done\n");
xc_ia64_p2m_unmap(&p2m_table);
munmap(memmap_info, map_size);
munmap(shinfo, PAGE_SIZE);
return EXIT_SUCCESS;
}
-69
View File
@@ -19,12 +19,10 @@ int compat_memory_op(unsigned int cmd, XEN_GUEST_HANDLE(void) compat)
XEN_GUEST_HANDLE(void) hnd;
struct xen_memory_reservation *rsrv;
struct xen_memory_exchange *xchg;
struct xen_translate_gpfn_list *xlat;
} nat;
union {
struct compat_memory_reservation rsrv;
struct compat_memory_exchange xchg;
struct compat_translate_gpfn_list xlat;
} cmp;
set_xen_guest_handle(nat.hnd, (void *)COMPAT_ARG_XLAT_VIRT_BASE);
@@ -182,52 +180,6 @@ int compat_memory_op(unsigned int cmd, XEN_GUEST_HANDLE(void) compat)
nat.hnd = compat;
break;
case XENMEM_translate_gpfn_list:
if ( copy_from_guest(&cmp.xlat, compat, 1) )
return -EFAULT;
/* Is size too large for us to encode a continuation? */
if ( cmp.xlat.nr_gpfns > (UINT_MAX >> MEMOP_EXTENT_SHIFT) )
return -EINVAL;
if ( !compat_handle_okay(cmp.xlat.gpfn_list, cmp.xlat.nr_gpfns) ||
!compat_handle_okay(cmp.xlat.mfn_list, cmp.xlat.nr_gpfns) )
return -EFAULT;
end_extent = start_extent + (COMPAT_ARG_XLAT_SIZE - sizeof(*nat.xlat)) /
sizeof(*space);
if ( end_extent > cmp.xlat.nr_gpfns )
end_extent = cmp.xlat.nr_gpfns;
space = (xen_pfn_t *)(nat.xlat + 1);
/* Code below depends upon .gpfn_list preceding .mfn_list. */
BUILD_BUG_ON(offsetof(xen_translate_gpfn_list_t, gpfn_list) > offsetof(xen_translate_gpfn_list_t, mfn_list));
#define XLAT_translate_gpfn_list_HNDL_gpfn_list(_d_, _s_) \
do \
{ \
set_xen_guest_handle((_d_)->gpfn_list, space - start_extent); \
for ( i = start_extent; i < end_extent; ++i ) \
{ \
compat_pfn_t pfn; \
if ( __copy_from_compat_offset(&pfn, (_s_)->gpfn_list, i, 1) ) \
return -EFAULT; \
*space++ = pfn; \
} \
} while (0)
#define XLAT_translate_gpfn_list_HNDL_mfn_list(_d_, _s_) \
(_d_)->mfn_list = (_d_)->gpfn_list
XLAT_translate_gpfn_list(nat.xlat, &cmp.xlat);
#undef XLAT_translate_gpfn_list_HNDL_mfn_list
#undef XLAT_translate_gpfn_list_HNDL_gpfn_list
if ( end_extent < cmp.xlat.nr_gpfns )
{
nat.xlat->nr_gpfns = end_extent;
++split;
}
break;
default:
return compat_arch_memory_op(cmd, compat);
}
@@ -335,27 +287,6 @@ int compat_memory_op(unsigned int cmd, XEN_GUEST_HANDLE(void) compat)
case XENMEM_maximum_gpfn:
break;
case XENMEM_translate_gpfn_list:
if ( split < 0 )
end_extent = cmd >> MEMOP_EXTENT_SHIFT;
else
BUG_ON(rc);
for ( ; start_extent < end_extent; ++start_extent )
{
compat_pfn_t pfn = nat.xlat->mfn_list.p[start_extent];
BUG_ON(pfn != nat.xlat->mfn_list.p[start_extent]);
if ( __copy_to_compat_offset(cmp.xlat.mfn_list, start_extent, &pfn, 1) )
{
if ( split < 0 )
/* Cannot cancel the continuation... */
domain_crash(current->domain);
return -EFAULT;
}
}
break;
default:
domain_crash(current->domain);
split = 0;
+1 -78
View File
@@ -215,72 +215,6 @@ static void decrease_reservation(struct memop_args *a)
a->nr_done = i;
}
static long translate_gpfn_list(
XEN_GUEST_HANDLE(xen_translate_gpfn_list_t) uop, unsigned long *progress)
{
struct xen_translate_gpfn_list op;
unsigned long i;
xen_pfn_t gpfn;
xen_pfn_t mfn;
struct domain *d;
int rc;
if ( copy_from_guest(&op, uop, 1) )
return -EFAULT;
/* Is size too large for us to encode a continuation? */
if ( op.nr_gpfns > (ULONG_MAX >> MEMOP_EXTENT_SHIFT) )
return -EINVAL;
if ( !guest_handle_subrange_okay(op.gpfn_list, *progress, op.nr_gpfns-1) ||
!guest_handle_subrange_okay(op.mfn_list, *progress, op.nr_gpfns-1) )
return -EFAULT;
rc = rcu_lock_target_domain_by_id(op.domid, &d);
if ( rc )
return rc;
if ( !paging_mode_translate(d) )
{
rcu_unlock_domain(d);
return -EINVAL;
}
for ( i = *progress; i < op.nr_gpfns; i++ )
{
if ( hypercall_preempt_check() )
{
rcu_unlock_domain(d);
*progress = i;
return -EAGAIN;
}
if ( unlikely(__copy_from_guest_offset(&gpfn, op.gpfn_list, i, 1)) )
{
rcu_unlock_domain(d);
return -EFAULT;
}
mfn = gmfn_to_mfn(d, gpfn);
rc = xsm_translate_gpfn_list(current->domain, mfn);
if ( rc )
{
rcu_unlock_domain(d);
return rc;
}
if ( unlikely(__copy_to_guest_offset(op.mfn_list, i, &mfn, 1)) )
{
rcu_unlock_domain(d);
return -EFAULT;
}
}
rcu_unlock_domain(d);
return 0;
}
static long memory_exchange(XEN_GUEST_HANDLE(xen_memory_exchange_t) arg)
{
struct xen_memory_exchange exch;
@@ -494,7 +428,7 @@ long do_memory_op(unsigned long cmd, XEN_GUEST_HANDLE(void) arg)
struct domain *d;
int rc, op;
unsigned int address_bits;
unsigned long start_extent, progress;
unsigned long start_extent;
struct xen_memory_reservation reservation;
struct memop_args args;
domid_t domid;
@@ -630,17 +564,6 @@ long do_memory_op(unsigned long cmd, XEN_GUEST_HANDLE(void) arg)
break;
case XENMEM_translate_gpfn_list:
progress = cmd >> MEMOP_EXTENT_SHIFT;
rc = translate_gpfn_list(
guest_handle_cast(arg, xen_translate_gpfn_list_t),
&progress);
if ( rc == -EAGAIN )
return hypercall_create_continuation(
__HYPERVISOR_memory_op, "lh",
op | (progress << MEMOP_EXTENT_SHIFT), arg);
break;
default:
rc = arch_memory_op(op, arg);
break;
+2 -23
View File
@@ -235,29 +235,8 @@ struct xen_remove_from_physmap {
typedef struct xen_remove_from_physmap xen_remove_from_physmap_t;
DEFINE_XEN_GUEST_HANDLE(xen_remove_from_physmap_t);
/*
* Translates a list of domain-specific GPFNs into MFNs. Returns a -ve error
* code on failure. This call only works for auto-translated guests.
*/
#define XENMEM_translate_gpfn_list 8
struct xen_translate_gpfn_list {
/* Which domain to translate for? */
domid_t domid;
/* Length of list. */
xen_ulong_t nr_gpfns;
/* List of GPFNs to translate. */
XEN_GUEST_HANDLE(xen_pfn_t) gpfn_list;
/*
* Output list to contain MFN translations. May be the same as the input
* list (in which case each input GPFN is overwritten with the output MFN).
*/
XEN_GUEST_HANDLE(xen_pfn_t) mfn_list;
};
typedef struct xen_translate_gpfn_list xen_translate_gpfn_list_t;
DEFINE_XEN_GUEST_HANDLE(xen_translate_gpfn_list_t);
/*** REMOVED ***/
/*#define XENMEM_translate_gpfn_list 8*/
/*
* Returns the pseudo-physical memory map as it was when the domain
-1
View File
@@ -39,7 +39,6 @@
! memory_map memory.h
! memory_reservation memory.h
! pod_target memory.h
! translate_gpfn_list memory.h
! sched_poll sched.h
? sched_remote_shutdown sched.h
? sched_shutdown sched.h
-6
View File
@@ -96,7 +96,6 @@ struct xsm_operations {
int (*alloc_security_evtchn) (struct evtchn *chn);
void (*free_security_evtchn) (struct evtchn *chn);
int (*translate_gpfn_list) (struct domain *d, unsigned long mfn);
int (*memory_adjust_reservation) (struct domain *d1, struct domain *d2);
int (*memory_stat_reservation) (struct domain *d1, struct domain *d2);
int (*memory_pin_page) (struct domain *d, struct page_info *page);
@@ -367,11 +366,6 @@ static inline void xsm_free_security_evtchn (struct evtchn *chn)
xsm_call(free_security_evtchn(chn));
}
static inline int xsm_translate_gpfn_list (struct domain *d, unsigned long mfn)
{
return xsm_call(translate_gpfn_list(d, mfn));
}
static inline int xsm_memory_adjust_reservation (struct domain *d1, struct
domain *d2)
{
-6
View File
@@ -180,11 +180,6 @@ static int dummy_grant_query_size (struct domain *d1, struct domain *d2)
return 0;
}
static int dummy_translate_gpfn_list (struct domain *d, unsigned long mfn)
{
return 0;
}
static int dummy_memory_adjust_reservation (struct domain *d1,
struct domain *d2)
{
@@ -522,7 +517,6 @@ void xsm_fixup_ops (struct xsm_operations *ops)
set_to_dummy_if_null(ops, alloc_security_evtchn);
set_to_dummy_if_null(ops, free_security_evtchn);
set_to_dummy_if_null(ops, translate_gpfn_list);
set_to_dummy_if_null(ops, memory_adjust_reservation);
set_to_dummy_if_null(ops, memory_stat_reservation);
set_to_dummy_if_null(ops, memory_pin_page);
-15
View File
@@ -367,20 +367,6 @@ static int get_mfn_sid(unsigned long mfn, u32 *sid)
return rc;
}
static int flask_translate_gpfn_list(struct domain *d, unsigned long mfn)
{
int rc = 0;
u32 sid;
struct domain_security_struct *dsec;
dsec = d->ssid;
rc = get_mfn_sid(mfn, &sid);
if ( rc )
return rc;
return avc_has_perm(dsec->sid, sid, SECCLASS_MMU, MMU__TRANSLATEGP, NULL);
}
static int flask_memory_adjust_reservation(struct domain *d1, struct domain *d2)
{
return domain_has_perm(d1, d2, SECCLASS_MMU, MMU__ADJUST);
@@ -1280,7 +1266,6 @@ static struct xsm_operations flask_ops = {
.alloc_security_evtchn = flask_alloc_security_evtchn,
.free_security_evtchn = flask_free_security_evtchn,
.translate_gpfn_list = flask_translate_gpfn_list,
.memory_adjust_reservation = flask_memory_adjust_reservation,
.memory_stat_reservation = flask_memory_stat_reservation,
.memory_pin_page = flask_memory_pin_page,
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.