ia64/xen-unstable

annotate xen/arch/powerpc/domctl.c @ 13608:30af6cfdb05c

Make domctl/sysctl interfaces 32-/64-bit invariant.
This kills off a fair amount of unpleasant CONFIG_COMPAT shimming and
avoids needing to keep the compat paths in sync as these interfaces
continue to develop.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Wed Jan 24 16:33:19 2007 +0000 (2007-01-24)
parents 5442b2458e1b
children 271ffb1c12eb
rev   line source
hollisb@11515 1 /*
hollisb@11515 2 * This program is free software; you can redistribute it and/or modify
hollisb@11515 3 * it under the terms of the GNU General Public License as published by
hollisb@11515 4 * the Free Software Foundation; either version 2 of the License, or
hollisb@11515 5 * (at your option) any later version.
hollisb@11515 6 *
hollisb@11515 7 * This program is distributed in the hope that it will be useful,
hollisb@11515 8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
hollisb@11515 9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
hollisb@11515 10 * GNU General Public License for more details.
hollisb@11515 11 *
hollisb@11515 12 * You should have received a copy of the GNU General Public License
hollisb@11515 13 * along with this program; if not, write to the Free Software
hollisb@11515 14 * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
hollisb@11515 15 *
hollisb@11515 16 * Copyright (C) IBM Corp. 2005
hollisb@11515 17 *
hollisb@11515 18 * Authors: Jimi Xenidis <jimix@watson.ibm.com>
hollisb@11515 19 */
hollisb@11515 20
hollisb@11515 21 #include <xen/config.h>
hollisb@11515 22 #include <xen/types.h>
hollisb@11515 23 #include <xen/lib.h>
hollisb@11515 24 #include <xen/sched.h>
ack@13308 25 #include <xen/domain.h>
hollisb@11515 26 #include <xen/guest_access.h>
hollisb@11515 27 #include <xen/shadow.h>
hollisb@11515 28 #include <public/xen.h>
hollisb@11515 29 #include <public/domctl.h>
hollisb@11515 30 #include <public/sysctl.h>
hollisb@11515 31 #include <asm/processor.h>
hollisb@11515 32
ack@13308 33 void arch_get_info_guest(struct vcpu *v, vcpu_guest_context_u c)
hollisb@11515 34 {
ack@13308 35 memcpy(&c.nat->user_regs, &v->arch.ctxt, sizeof(struct cpu_user_regs));
hollisb@11515 36 /* XXX fill in rest of vcpu_guest_context_t */
hollisb@11515 37 }
hollisb@11515 38
hollisb@11515 39 long arch_do_domctl(struct xen_domctl *domctl,
hollisb@11515 40 XEN_GUEST_HANDLE(xen_domctl_t) u_domctl);
hollisb@11515 41 long arch_do_domctl(struct xen_domctl *domctl,
hollisb@11515 42 XEN_GUEST_HANDLE(xen_domctl_t) u_domctl)
hollisb@11515 43 {
hollisb@11515 44 long ret = 0;
hollisb@11515 45
hollisb@11515 46 switch (domctl->cmd) {
hollisb@11515 47 case XEN_DOMCTL_getmemlist:
hollisb@11515 48 {
hollisb@11515 49 int i;
hollisb@11515 50 struct domain *d = find_domain_by_id(domctl->domain);
hollisb@11515 51 unsigned long max_pfns = domctl->u.getmemlist.max_pfns;
kfraser@13608 52 uint64_t mfn;
hollisb@11515 53 struct list_head *list_ent;
hollisb@11515 54
hollisb@11515 55 ret = -EINVAL;
hollisb@11515 56 if ( d != NULL )
hollisb@11515 57 {
hollisb@11515 58 ret = 0;
hollisb@11515 59
hollisb@11515 60 spin_lock(&d->page_alloc_lock);
hollisb@11515 61 list_ent = d->page_list.next;
hollisb@11515 62 for ( i = 0; (i < max_pfns) && (list_ent != &d->page_list); i++ )
hollisb@11515 63 {
hollisb@11515 64 mfn = page_to_mfn(list_entry(
hollisb@11515 65 list_ent, struct page_info, list));
hollisb@11515 66 if ( copy_to_guest_offset(domctl->u.getmemlist.buffer,
hollisb@11515 67 i, &mfn, 1) )
hollisb@11515 68 {
hollisb@11515 69 ret = -EFAULT;
hollisb@11515 70 break;
hollisb@11515 71 }
hollisb@11515 72 list_ent = mfn_to_page(mfn)->list.next;
hollisb@11515 73 }
hollisb@11515 74 spin_unlock(&d->page_alloc_lock);
hollisb@11515 75
hollisb@11515 76 domctl->u.getmemlist.num_pfns = i;
hollisb@11515 77 copy_to_guest(u_domctl, domctl, 1);
hollisb@11515 78
hollisb@11515 79 put_domain(d);
hollisb@11515 80 }
hollisb@11515 81 }
hollisb@11515 82 break;
hollisb@11515 83 case XEN_DOMCTL_shadow_op:
hollisb@11515 84 {
hollisb@11515 85 struct domain *d;
hollisb@11515 86 ret = -ESRCH;
hollisb@11515 87 d = find_domain_by_id(domctl->domain);
hollisb@11515 88 if ( d != NULL )
hollisb@11515 89 {
hollisb@11515 90 ret = shadow_domctl(d, &domctl->u.shadow_op, u_domctl);
hollisb@11515 91 put_domain(d);
hollisb@11515 92 copy_to_guest(u_domctl, domctl, 1);
hollisb@11515 93 }
hollisb@11515 94 }
hollisb@11515 95 break;
hollisb@11515 96 case XEN_DOMCTL_real_mode_area:
hollisb@11515 97 {
hollisb@11515 98 struct domain *d;
jimix@12923 99 unsigned int order = domctl->u.real_mode_area.log - PAGE_SHIFT;
hollisb@11515 100
hollisb@11515 101 ret = -ESRCH;
hollisb@11515 102 d = find_domain_by_id(domctl->domain);
hollisb@11515 103 if (d != NULL) {
hollisb@11515 104 ret = -EINVAL;
jimix@12923 105 if (cpu_rma_valid(order))
jimix@12923 106 ret = allocate_rma(d, order);
hollisb@11515 107 put_domain(d);
hollisb@11515 108 }
hollisb@11515 109 }
hollisb@11515 110 break;
hollisb@11515 111
hollisb@11515 112 default:
hollisb@11515 113 ret = -ENOSYS;
hollisb@11515 114 break;
hollisb@11515 115 }
hollisb@11515 116
hollisb@11515 117 return ret;
hollisb@11515 118 }