debuggers.hg
changeset 555:93c7dcf4a80e
bitkeeper revision 1.284 (3f094675ELP7S7P0f1aKb_RV95PM4Q)
Merge steve/keir changes
Merge steve/keir changes
line diff
1.1 --- a/.rootkeys Mon Jul 07 09:51:04 2003 +0000 1.2 +++ b/.rootkeys Mon Jul 07 10:07:49 2003 +0000 1.3 @@ -105,17 +105,6 @@ 3ec41f7ecn3uvsSrOVxKC8G8ACuulg tools/con 1.4 3ec41f7ek1RffqN2yRUzSTkD5m1J6w tools/control/web/tmpl/xenohead.def 1.5 3ec41f7e1ZpfCsgQ2qRJBooBn_iRtA tools/control/web/tmpl/xenostyle.css 1.6 3eb781fc6vgq5yhkJRGDLY9gWWRY2A tools/control/xenctl 1.7 -3e4d00468-FN2VDeEHo96zxrMHK_mA tools/domain_builder/Makefile 1.8 -3e4d0046SPau_y0sw2WLJz8QkqNoRA tools/domain_builder/README 1.9 -3e4d0046bbdH0GsI9J_1Eb4ZQHfIiQ tools/domain_builder/dom0_defs.h 1.10 -3ee609abdxnu1GvbtXnPlMfEkTEIwQ tools/domain_builder/dom0_ops.h 1.11 -3e4d0046ouLij_CMN_j7-dUHZIBI_A tools/domain_builder/dom_builder.c 1.12 -3e4d0046EKs06fY0CWDEgZQcn7DYUg tools/domain_builder/dom_kill.c 1.13 -3e4d0046aPbGiRTtdWxqY5b3ytWurA tools/domain_builder/hypervisor_defs.h 1.14 -3e4d00468aE86IfyjfrJwYoxzM7pAw tools/domain_builder/mem_defs.h 1.15 -3e71afadoAI0VvAGKebLpToVQxUKfQ tools/domain_builder/mynewdom 1.16 -3e4d0046VHhXwFuG5FK34AVxqd5A_A tools/domain_builder/newdom 1.17 -3e4d0046IBzDIeaMbQB-e2QB2ahbig tools/domain_builder/vifinit 1.18 3eb781fdl4lXWYZzmqDDUAYhAThRqQ tools/internal/Makefile 1.19 3eb781fdc539MQQm47rYRCCR3N5i-Q tools/internal/dom0_defs.h 1.20 3ee609b3Yr4aggmLSKmhiIzT8-nURA tools/internal/dom0_ops.h
2.1 --- a/Makefile Mon Jul 07 09:51:04 2003 +0000 2.2 +++ b/Makefile Mon Jul 07 10:07:49 2003 +0000 2.3 @@ -21,7 +21,6 @@ all: 2.4 $(MAKE) -C xen 2.5 $(MAKE) -C tools/balloon 2.6 $(MAKE) -C tools/control 2.7 - $(MAKE) -C tools/domain_builder 2.8 $(MAKE) -C tools/internal 2.9 $(MAKE) -C tools/vdmanager 2.10 2.11 @@ -29,7 +28,6 @@ install: all 2.12 $(MAKE) -C xen install 2.13 $(MAKE) -C tools/balloon install 2.14 $(MAKE) -C tools/control install 2.15 - $(MAKE) -C tools/domain_builder install 2.16 $(MAKE) -C tools/internal install 2.17 $(MAKE) -C tools/vdmanager install 2.18 2.19 @@ -38,7 +36,6 @@ clean: 2.20 $(MAKE) -C xen clean 2.21 $(MAKE) -C tools/balloon clean 2.22 $(MAKE) -C tools/control clean 2.23 - $(MAKE) -C tools/domain_builder clean 2.24 $(MAKE) -C tools/internal clean 2.25 $(MAKE) -C tools/vdmanager clean 2.26
3.1 --- a/tools/domain_builder/Makefile Mon Jul 07 09:51:04 2003 +0000 3.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 3.3 @@ -1,20 +0,0 @@ 3.4 -CC = gcc 3.5 -BUILDER = domain_builder 3.6 -KILL = kill_domain 3.7 - 3.8 -all: dom_builder.o dom_kill.o 3.9 - $(CC) -o $(BUILDER) dom_builder.o 3.10 - $(CC) -o $(KILL) dom_kill.o 3.11 - 3.12 -install: all 3.13 - cp domain_builder kill_domain ../../../install/bin 3.14 - 3.15 -dom_builder.o: dom_builder.c dom0_defs.h dom0_ops.h hypervisor_defs.h mem_defs.h 3.16 - $(CC) -c dom_builder.c 3.17 - 3.18 -dom_kill.o: dom_kill.c dom0_ops.h dom0_defs.h 3.19 - $(CC) -c dom_kill.c 3.20 - 3.21 -clean: 3.22 - $(RM) *.o domain_builder kill_domain 3.23 -
4.1 --- a/tools/domain_builder/README Mon Jul 07 09:51:04 2003 +0000 4.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 4.3 @@ -1,29 +0,0 @@ 4.4 -A couple of simple steps to get you going: 4.5 - 4.6 -1. do make (suitable Makefile is in the source dir) 4.7 -2. copy over andy's vifinit script to local dir 4.8 -3. copy over xenolinux guestos image (NB. image needs to be uncompressed, so 4.9 -if the only image you have is image.gz do gunzip image.gz before doing 4.10 -anything further) 4.11 -4. add executable permissions to newdom and vifint 4.12 -5. edit newdom script and change it as it suits you 4.13 - 4.14 -newdom script takes guestos image file name as first parameter and newdom id 4.15 -as second parameter, eg.: 4.16 - 4.17 -./newdom xenolinux 1 4.18 - 4.19 -should initiate building of dom1 with the image contained in file named 4.20 -xenolinux in local dir. 4.21 - 4.22 -in general, domain_builder application takes three parameters: requested 4.23 -memory in kb, guestos image file name and number of vifs to be created, eg. 4.24 - 4.25 -./domain_builder 16000 xenolinux 1 4.26 - 4.27 -would build domX reserving 16MB mem, creating 1 vif and using os image stored 4.28 -as xenolinux in local dir. 4.29 - 4.30 -happy booting! 4.31 - 4.32 -boris
5.1 --- a/tools/domain_builder/dom0_defs.h Mon Jul 07 09:51:04 2003 +0000 5.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 5.3 @@ -1,8 +0,0 @@ 5.4 -#define PROC_XENO_ROOT "xeno" 5.5 -#define PROC_CMD "dom0_cmd" 5.6 -#define PROC_DOM_PREFIX "dom" 5.7 -#define PROC_DOM_MEM "mem" 5.8 -#define PROC_DOM_DATA "new_dom_data" 5.9 - 5.10 -#define MAX_PATH 256 5.11 -
6.1 --- a/tools/domain_builder/dom0_ops.h Mon Jul 07 09:51:04 2003 +0000 6.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 6.3 @@ -1,5 +0,0 @@ 6.4 - 6.5 -#define NO_DOM0_OP_T 6.6 -#include "../../xen/include/hypervisor-ifs/dom0_ops.h" 6.7 -#undef NO_DOM0_OP_T 6.8 -#include "../../xenolinux-2.4.21-sparse/arch/xeno/drivers/dom0/dom0_ops.h"
7.1 --- a/tools/domain_builder/dom_builder.c Mon Jul 07 09:51:04 2003 +0000 7.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 7.3 @@ -1,559 +0,0 @@ 7.4 -/* 7.5 - * XenoDomainBuilder, copyright (c) Boris Dragovic, bd240@cl.cam.ac.uk 7.6 - * This code is released under terms and conditions of GNU GPL :). 7.7 - * Usage: <executable> <mem_kb> <os image> <num_vifs> 7.8 - */ 7.9 - 7.10 -#include <unistd.h> 7.11 -#include <stdio.h> 7.12 -#include <errno.h> 7.13 -#include <fcntl.h> 7.14 -#include <sys/mman.h> 7.15 -#include <sys/types.h> 7.16 -#include <sys/stat.h> 7.17 -#include <stdlib.h> 7.18 - 7.19 -#include "hypervisor_defs.h" 7.20 -#include "dom0_ops.h" 7.21 -#include "dom0_defs.h" 7.22 -#include "mem_defs.h" 7.23 - 7.24 -#define PERR_STRING "Xeno Domain Builder" 7.25 - 7.26 -#define GUEST_SIG "XenoGues" 7.27 -#define SIG_LEN 8 7.28 - 7.29 -/* 7.30 - * NB. No ring-3 access in initial guestOS pagetables. Note that we allow 7.31 - * ring-3 privileges in the page directories, so that the guestOS may later 7.32 - * decide to share a 4MB region with applications. 7.33 - */ 7.34 -#define L1_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED) 7.35 -#define L2_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_DIRTY|_PAGE_USER) 7.36 - 7.37 -/* standardized error reporting function */ 7.38 -static void dberr(char *msg) 7.39 -{ 7.40 - printf("%s: %s\n", PERR_STRING, msg); 7.41 -} 7.42 - 7.43 -/* status reporting function */ 7.44 -static void dbstatus(char * msg) 7.45 -{ 7.46 - printf("Domain Builder: %s\n", msg); 7.47 -} 7.48 - 7.49 -static int do_kill_domain(int dom_id, int force) 7.50 -{ 7.51 - char cmd_path[MAX_PATH]; 7.52 - dom0_op_t dop; 7.53 - int cmd_fd; 7.54 - 7.55 - dop.cmd = DOM0_DESTROYDOMAIN; 7.56 - dop.u.killdomain.domain = dom_id; 7.57 - dop.u.killdomain.force = force; 7.58 - 7.59 - /* open the /proc command interface */ 7.60 - sprintf(cmd_path, "%s%s%s%s", "/proc/", PROC_XENO_ROOT, "/", PROC_CMD); 7.61 - cmd_fd = open(cmd_path, O_WRONLY); 7.62 - if(cmd_fd < 0){ 7.63 - perror(PERR_STRING); 7.64 - return -1; 7.65 - } 7.66 - 7.67 - write(cmd_fd, &dop, sizeof(dom0_op_t)); 7.68 - close(cmd_fd); 7.69 - 7.70 - return 0; 7.71 -} 7.72 - 7.73 -/* clean up domain's memory allocations */ 7.74 -static void dom_mem_cleanup(dom_mem_t * dom_mem) 7.75 -{ 7.76 - char mem_path[MAX_PATH]; 7.77 - int mem_fd; 7.78 - 7.79 - /* open the domain's /proc mem interface */ 7.80 - sprintf(mem_path, "%s%s%s%s%d%s%s", "/proc/", PROC_XENO_ROOT, "/", 7.81 - PROC_DOM_PREFIX, dom_mem->domain, "/", PROC_DOM_MEM); 7.82 - 7.83 - mem_fd = open(mem_path, O_WRONLY); 7.84 - if(mem_fd < 0){ 7.85 - perror(PERR_STRING); 7.86 - } 7.87 - 7.88 - if(write(mem_fd, (dom_mem_t *)dom_mem, sizeof(dom_mem_t)) < 0){ 7.89 - dbstatus("Error unmapping domain's memory.\n"); 7.90 - } 7.91 - 7.92 - close(mem_fd); 7.93 -} 7.94 - 7.95 -/* ask dom0 to export domains memory through /proc */ 7.96 -static int setup_dom_memmap(unsigned long pfn, int pages, int dom) 7.97 -{ 7.98 - char cmd_path[MAX_PATH]; 7.99 - dom0_op_t dop; 7.100 - int cmd_fd; 7.101 - 7.102 - dop.cmd = MAP_DOM_MEM; 7.103 - dop.u.dommem.start_pfn = pfn; 7.104 - dop.u.dommem.tot_pages = pages; 7.105 - dop.u.dommem.domain = dom; 7.106 - 7.107 - /* open the /proc command interface */ 7.108 - sprintf(cmd_path, "%s%s%s%s", "/proc/", PROC_XENO_ROOT, "/", PROC_CMD); 7.109 - cmd_fd = open(cmd_path, O_WRONLY); 7.110 - if(cmd_fd < 0){ 7.111 - perror(PERR_STRING); 7.112 - return -1; 7.113 - } 7.114 - 7.115 - write(cmd_fd, &dop, sizeof(dom0_op_t)); 7.116 - close(cmd_fd); 7.117 - 7.118 - return 0; 7.119 -} 7.120 - 7.121 -/* request the actual mapping from dom0 */ 7.122 -static unsigned long get_vaddr(unsigned int dom) 7.123 -{ 7.124 - char mem_path[MAX_PATH]; 7.125 - unsigned long addr; 7.126 - int mem_fd; 7.127 - 7.128 - /* open the domain's /proc mem interface */ 7.129 - sprintf(mem_path, "%s%s%s%s%d%s%s", "/proc/", PROC_XENO_ROOT, "/", 7.130 - PROC_DOM_PREFIX, dom, "/", PROC_DOM_MEM); 7.131 - 7.132 - mem_fd = open(mem_path, O_RDONLY); 7.133 - if(mem_fd < 0){ 7.134 - perror(PERR_STRING); 7.135 - return 0; 7.136 - } 7.137 - 7.138 - /* get virtual address of mapped region */ 7.139 - read(mem_fd, &addr, sizeof(addr)); 7.140 - 7.141 - close(mem_fd); 7.142 - 7.143 - return addr; 7.144 -} 7.145 - 7.146 -static int map_dom_mem(unsigned long pfn, int pages, int dom, 7.147 - dom_mem_t * dom_mem) 7.148 -{ 7.149 - 7.150 - if(setup_dom_memmap(pfn, pages, dom)){ 7.151 - perror(PERR_STRING); 7.152 - return -1; 7.153 - } 7.154 - 7.155 - dom_mem->domain = dom; 7.156 - dom_mem->start_pfn = pfn; 7.157 - dom_mem->tot_pages = pages; 7.158 - if((dom_mem->vaddr = get_vaddr(dom)) == 0){ 7.159 - dberr("Error mapping dom memory."); 7.160 - return -1; 7.161 - } 7.162 - 7.163 - return 0; 7.164 -} 7.165 - 7.166 -/* create new domain */ 7.167 -static dom0_newdomain_t * create_new_domain(long req_mem) 7.168 -{ 7.169 - dom0_newdomain_t * dom_data; 7.170 - char cmd_path[MAX_PATH]; 7.171 - char dom_id_path[MAX_PATH]; 7.172 - dom0_op_t dop; 7.173 - int cmd_fd; 7.174 - int id_fd; 7.175 - 7.176 - /* open the /proc command interface */ 7.177 - sprintf(cmd_path, "%s%s%s%s", "/proc/", PROC_XENO_ROOT, "/", PROC_CMD); 7.178 - cmd_fd = open(cmd_path, O_WRONLY); 7.179 - if(cmd_fd < 0){ 7.180 - perror(PERR_STRING); 7.181 - return 0; 7.182 - } 7.183 - 7.184 - dop.cmd = DOM0_CREATEDOMAIN; 7.185 - dop.u.newdomain.memory_kb = req_mem; 7.186 - dop.u.newdomain.name[0] = 0; 7.187 - 7.188 - write(cmd_fd, &dop, sizeof(dom0_op_t)); 7.189 - close(cmd_fd); 7.190 - 7.191 - sprintf(dom_id_path, "%s%s%s%s", "/proc/", PROC_XENO_ROOT, "/", 7.192 - PROC_DOM_DATA); 7.193 - while((id_fd = open(dom_id_path, O_RDONLY)) < 0) continue; 7.194 - dom_data = (dom0_newdomain_t *)malloc(sizeof(dom0_newdomain_t)); 7.195 - read(id_fd, dom_data, sizeof(dom0_newdomain_t)); 7.196 - close(id_fd); 7.197 - 7.198 - sprintf(cmd_path, "Reserved %ld kbytes memory and assigned id %d to the" 7.199 - " new domain.", req_mem, dom_data->domain); 7.200 - dbstatus(cmd_path); 7.201 - 7.202 - return dom_data; 7.203 -} 7.204 - 7.205 -/* open kernel image and do some sanity checks */ 7.206 -static int do_kernel_chcks(char *image, long dom_size, 7.207 - unsigned long * load_addr, size_t * ksize) 7.208 -{ 7.209 - char signature[8]; 7.210 - char status[MAX_PATH]; 7.211 - struct stat stat; 7.212 - int fd; 7.213 - int ret; 7.214 - 7.215 - fd = open(image, O_RDONLY); 7.216 - if(fd < 0){ 7.217 - perror(PERR_STRING); 7.218 - ret = -1; 7.219 - goto out; 7.220 - } 7.221 - 7.222 - if(fstat(fd, &stat) < 0){ 7.223 - perror(PERR_STRING); 7.224 - ret = -1; 7.225 - close(fd); 7.226 - goto out; 7.227 - } 7.228 - 7.229 - if(stat.st_size > (dom_size << 10)){ 7.230 - sprintf(status, "Kernel image size %ld larger than requested " 7.231 - "domain size %ld\n Terminated.\n", stat.st_size, dom_size); 7.232 - dberr(status); 7.233 - ret = -1; 7.234 - close(fd); 7.235 - goto out; 7.236 - } 7.237 - 7.238 - read(fd, signature, SIG_LEN); 7.239 - if(strncmp(signature, GUEST_SIG, SIG_LEN)){ 7.240 - dberr("Kernel image does not contain required signature. " 7.241 - "Terminating.\n"); 7.242 - ret = -1; 7.243 - close(fd); 7.244 - goto out; 7.245 - } 7.246 - 7.247 - read(fd, load_addr, sizeof(unsigned long)); 7.248 - 7.249 - *ksize = stat.st_size - SIG_LEN - sizeof(unsigned long); 7.250 - 7.251 - sprintf(status, "Kernel image %s valid, kernel virtual load address %lx", 7.252 - image, *load_addr); 7.253 - dbstatus(status); 7.254 - 7.255 - ret = fd; 7.256 - 7.257 -out: 7.258 - return ret; 7.259 -} 7.260 - 7.261 -/* this is the main guestos setup function, 7.262 - * returnes domain descriptor structure to be used when launching 7.263 - * the domain by hypervisor to do some last minute initialization. 7.264 - * page table initialization is done by making a list of page table 7.265 - * requests that are handeled by the hypervisor in the ordinary 7.266 - * manner. this way, many potentially messy things are avoided... 7.267 - */ 7.268 -#define PAGE_TO_VADDR(_pfn) ((void *)(dom_mem->vaddr + ((_pfn) * PAGE_SIZE))) 7.269 -static dom_meminfo_t *setup_guestos(int dom, int kernel_fd, int initrd_fd, 7.270 - unsigned long virt_load_addr, size_t ksize, dom_mem_t *dom_mem) 7.271 -{ 7.272 - dom_meminfo_t *meminfo; 7.273 - unsigned long *page_array; 7.274 - page_update_request_t *pgt_updates; 7.275 - dom_mem_t mem_map; 7.276 - dom_meminfo_t *ret = NULL; 7.277 - int alloc_index, num_pt_pages; 7.278 - unsigned long l2tab; 7.279 - unsigned long l1tab = 0; 7.280 - unsigned long num_pgt_updates = 0; 7.281 - unsigned long count, pt_start; 7.282 - dom0_op_t pgupdate_req; 7.283 - char cmd_path[MAX_PATH]; 7.284 - int cmd_fd; 7.285 - 7.286 - meminfo = (dom_meminfo_t *)malloc(sizeof(dom_meminfo_t)); 7.287 - page_array = malloc(dom_mem->tot_pages * 4); 7.288 - pgt_updates = (page_update_request_t *)dom_mem->vaddr; 7.289 - alloc_index = dom_mem->tot_pages - 1; 7.290 - 7.291 - memset(meminfo, 0, sizeof(meminfo)); 7.292 - 7.293 - memcpy(page_array, (void *)dom_mem->vaddr, dom_mem->tot_pages * 4); 7.294 - 7.295 - /* Count bottom-level PTs, rounding up. Include one PTE for shared info. */ 7.296 - num_pt_pages = 7.297 - (l1_table_offset(virt_load_addr) + dom_mem->tot_pages + 1024) / 1024; 7.298 - 7.299 - /* We must also count the page directory. */ 7.300 - num_pt_pages++; 7.301 - 7.302 - /* Index of first PT page. */ 7.303 - pt_start = dom_mem->tot_pages - num_pt_pages; 7.304 - 7.305 - /* first allocate page for page dir. allocation goes backwards from the 7.306 - * end of the allocated physical address space. 7.307 - */ 7.308 - l2tab = *(page_array + alloc_index) << PAGE_SHIFT; 7.309 - memset(PAGE_TO_VADDR(alloc_index), 0, PAGE_SIZE); 7.310 - alloc_index--; 7.311 - meminfo->l2_pgt_addr = l2tab; 7.312 - meminfo->virt_shinfo_addr = virt_load_addr + nr_2_page(dom_mem->tot_pages); 7.313 - 7.314 - /* pin down l2tab addr as page dir page - causes hypervisor to provide 7.315 - * correct protection for the page 7.316 - */ 7.317 - pgt_updates->ptr = l2tab | PGREQ_EXTENDED_COMMAND; 7.318 - pgt_updates->val = PGEXT_PIN_L2_TABLE; 7.319 - pgt_updates++; 7.320 - num_pgt_updates++; 7.321 - 7.322 - /* 7.323 - * Initialise the page tables. The final iteration is for the shared_info 7.324 - * PTE -- we break out before filling in the entry, as that is done by 7.325 - * Xen during final setup. 7.326 - */ 7.327 - l2tab += l2_table_offset(virt_load_addr) * sizeof(l2_pgentry_t); 7.328 - for ( count = 0; count < (dom_mem->tot_pages + 1); count++ ) 7.329 - { 7.330 - if ( !((unsigned long)l1tab & (PAGE_SIZE-1)) ) 7.331 - { 7.332 - l1tab = *(page_array + alloc_index) << PAGE_SHIFT; 7.333 - memset(PAGE_TO_VADDR(alloc_index), 0, PAGE_SIZE); 7.334 - alloc_index--; 7.335 - 7.336 - l1tab += l1_table_offset(virt_load_addr + nr_2_page(count)) 7.337 - * sizeof(l1_pgentry_t); 7.338 - 7.339 - /* make apropriate entry in the page directory */ 7.340 - pgt_updates->ptr = l2tab; 7.341 - pgt_updates->val = l1tab | L2_PROT; 7.342 - pgt_updates++; 7.343 - num_pgt_updates++; 7.344 - l2tab += sizeof(l2_pgentry_t); 7.345 - } 7.346 - 7.347 - /* The last PTE we consider is filled in later by Xen. */ 7.348 - if ( count == dom_mem->tot_pages ) break; 7.349 - 7.350 - if ( count < pt_start ) 7.351 - { 7.352 - pgt_updates->ptr = l1tab; 7.353 - pgt_updates->val = (*(page_array + count) << PAGE_SHIFT) | L1_PROT; 7.354 - pgt_updates++; 7.355 - num_pgt_updates++; 7.356 - l1tab += sizeof(l1_pgentry_t); 7.357 - } 7.358 - else 7.359 - { 7.360 - pgt_updates->ptr = l1tab; 7.361 - pgt_updates->val = 7.362 - ((*(page_array + count) << PAGE_SHIFT) | L1_PROT) & ~_PAGE_RW; 7.363 - pgt_updates++; 7.364 - num_pgt_updates++; 7.365 - l1tab += sizeof(l1_pgentry_t); 7.366 - } 7.367 - 7.368 - pgt_updates->ptr = 7.369 - (*(page_array + count) << PAGE_SHIFT) | PGREQ_MPT_UPDATE; 7.370 - pgt_updates->val = count; 7.371 - pgt_updates++; 7.372 - num_pgt_updates++; 7.373 - } 7.374 - 7.375 - meminfo->virt_startinfo_addr = virt_load_addr + nr_2_page(alloc_index - 1); 7.376 - meminfo->domain = dom; 7.377 - 7.378 - /* 7.379 - * Send the page update requests down to the hypervisor. 7.380 - * NB. We must do this before loading the guest OS image! 7.381 - */ 7.382 - sprintf(cmd_path, "%s%s%s%s", "/proc/", PROC_XENO_ROOT, "/", PROC_CMD); 7.383 - if ( (cmd_fd = open(cmd_path, O_WRONLY)) < 0 ) goto out; 7.384 - pgupdate_req.cmd = DO_PGUPDATES; 7.385 - pgupdate_req.u.pgupdate.pgt_update_arr = (unsigned long)dom_mem->vaddr; 7.386 - pgupdate_req.u.pgupdate.num_pgt_updates = num_pgt_updates; 7.387 - write(cmd_fd, &pgupdate_req, sizeof(dom0_op_t)); 7.388 - close(cmd_fd); 7.389 - 7.390 - /* Load the guest OS image. */ 7.391 - if( read(kernel_fd, (char *)dom_mem->vaddr, ksize) != ksize ) 7.392 - { 7.393 - dberr("Error reading kernel image, could not" 7.394 - " read the whole image. Terminating.\n"); 7.395 - goto out; 7.396 - } 7.397 - 7.398 - if( initrd_fd ) 7.399 - { 7.400 - struct stat stat; 7.401 - unsigned long isize; 7.402 - 7.403 - if(fstat(initrd_fd, &stat) < 0){ 7.404 - perror(PERR_STRING); 7.405 - close(initrd_fd); 7.406 - goto out; 7.407 - } 7.408 - isize = stat.st_size; 7.409 - 7.410 - if( read(initrd_fd, ((char *)dom_mem->vaddr)+ksize, isize) != isize ) 7.411 - { 7.412 - dberr("Error reading initrd image, could not" 7.413 - " read the whole image. Terminating.\n"); 7.414 - goto out; 7.415 - } 7.416 - 7.417 - meminfo->virt_mod_addr = virt_load_addr + ksize; 7.418 - meminfo->virt_mod_len = isize; 7.419 - 7.420 - } 7.421 - 7.422 - 7.423 - ret = meminfo; 7.424 -out: 7.425 - 7.426 - return ret; 7.427 -} 7.428 - 7.429 -static int launch_domain(dom_meminfo_t * meminfo) 7.430 -{ 7.431 - char cmd_path[MAX_PATH]; 7.432 - dom0_op_t dop; 7.433 - int cmd_fd; 7.434 - 7.435 - sprintf(cmd_path, "%s%s%s%s", "/proc/", PROC_XENO_ROOT, "/", PROC_CMD); 7.436 - cmd_fd = open(cmd_path, O_WRONLY); 7.437 - if(cmd_fd < 0){ 7.438 - perror(PERR_STRING); 7.439 - return -1; 7.440 - } 7.441 - 7.442 - dop.cmd = DOM0_BUILDDOMAIN; 7.443 - memcpy(&dop.u.meminfo, meminfo, sizeof(dom_meminfo_t)); 7.444 - write(cmd_fd, &dop, sizeof(dom0_op_t)); 7.445 - 7.446 - dop.cmd = DOM0_STARTDOMAIN; 7.447 - memcpy(&dop.u.meminfo, meminfo, sizeof(dom_meminfo_t)); 7.448 - write(cmd_fd, &dop, sizeof(dom0_op_t)); 7.449 - 7.450 - dbstatus("Launched the new domain!"); 7.451 - 7.452 - close(cmd_fd); 7.453 - return 0; 7.454 -} 7.455 - 7.456 -int main(int argc, char **argv) 7.457 -{ 7.458 - 7.459 - dom0_newdomain_t * dom_data; 7.460 - dom_mem_t dom_os_image; 7.461 - dom_mem_t dom_pgt; 7.462 - dom_meminfo_t * meminfo; 7.463 - size_t ksize; 7.464 - unsigned long load_addr; 7.465 - char status[1024]; 7.466 - int kernel_fd, initrd_fd = 0; 7.467 - int count; 7.468 - int cmd_len; 7.469 - int rc = -1; 7.470 - int args_start = 4; 7.471 - char initrd_name[1024]; 7.472 - 7.473 - unsigned long addr; 7.474 - 7.475 - /**** this argument parsing code is really _gross_. rewrite me! ****/ 7.476 - 7.477 - if(argc < 4) { 7.478 - dberr("Usage: dom_builder <kbytes_mem> <image> <num_vifs> " 7.479 - "[<initrd=initrd_name>] <boot_params>\n"); 7.480 - return -1; 7.481 - } 7.482 - 7.483 - /* create new domain and set up all the neccessary mappings */ 7.484 - 7.485 - kernel_fd = do_kernel_chcks(argv[2], atol(argv[1]), &load_addr, &ksize); 7.486 - if(kernel_fd < 0) 7.487 - return -1; 7.488 - 7.489 - /* request the creation of new domain */ 7.490 - if(!(dom_data = create_new_domain(atol(argv[1])))) 7.491 - return -1; 7.492 - 7.493 - /* map domain's memory */ 7.494 - if(map_dom_mem(dom_data->pg_head, dom_data->memory_kb >> (PAGE_SHIFT-10), 7.495 - dom_data->domain, &dom_os_image)) 7.496 - goto out; 7.497 - 7.498 - if( strncmp("initrd=", argv[args_start], 7) == 0 ) 7.499 - { 7.500 - strncpy( initrd_name, argv[args_start]+7, sizeof(initrd_name) ); 7.501 - initrd_name[sizeof(initrd_name)-1] = 0; 7.502 - printf("initrd present, name = %s\n", initrd_name ); 7.503 - args_start++; 7.504 - 7.505 - initrd_fd = open(initrd_name, O_RDONLY); 7.506 - if(initrd_fd < 0){ 7.507 - perror(PERR_STRING); 7.508 - goto out; 7.509 - } 7.510 - } 7.511 - 7.512 - /* the following code does the actual domain building */ 7.513 - meminfo = setup_guestos(dom_data->domain, kernel_fd, initrd_fd, load_addr, 7.514 - ksize, &dom_os_image); 7.515 - 7.516 - /* and unmap the new domain's memory image since we no longer need it */ 7.517 - dom_mem_cleanup(&dom_os_image); 7.518 - 7.519 - if(!meminfo) { 7.520 - printf("Domain Builder: debug: meminfo NULL\n"); 7.521 - goto out; 7.522 - } 7.523 - 7.524 - meminfo->virt_load_addr = load_addr; 7.525 - meminfo->num_vifs = atoi(argv[3]); 7.526 - meminfo->cmd_line[0] = '\0'; 7.527 - cmd_len = 0; 7.528 - for(count = args_start; count < argc; count++){ 7.529 - if(cmd_len + strlen(argv[count]) > MAX_CMD_LEN - 1){ 7.530 - dberr("Size of image boot params too big!\n"); 7.531 - break; 7.532 - } 7.533 - strcat(meminfo->cmd_line, argv[count]); 7.534 - strcat(meminfo->cmd_line, " "); 7.535 - cmd_len += strlen(argv[count] + 1); 7.536 - } 7.537 - 7.538 - sprintf(status, 7.539 - "About to launch new domain %d with folowing parameters:\n" 7.540 - " * page table base: %lx \n * load address: %lx \n" 7.541 - " * shared info address: %lx \n * start info address: %lx \n" 7.542 - " * number of vifs: %d \n * cmd line: %s \n", meminfo->domain, 7.543 - meminfo->l2_pgt_addr, meminfo->virt_load_addr, 7.544 - meminfo->virt_shinfo_addr, meminfo->virt_startinfo_addr, 7.545 - meminfo->num_vifs, meminfo->cmd_line); 7.546 - dbstatus(status); 7.547 - 7.548 - /* and launch the domain */ 7.549 - rc = launch_domain(meminfo); 7.550 - 7.551 -out: 7.552 - if( rc >= 0 ) 7.553 - { 7.554 - return meminfo->domain; 7.555 - } 7.556 - else 7.557 - { 7.558 - if ( dom_data->domain != 0 ) 7.559 - do_kill_domain(dom_data->domain, 1); 7.560 - return rc; 7.561 - } 7.562 -}
8.1 --- a/tools/domain_builder/dom_kill.c Mon Jul 07 09:51:04 2003 +0000 8.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 8.3 @@ -1,61 +0,0 @@ 8.4 -/* 8.5 - * A very(!) simple program to kill a domain. (c) Boris Dragovic 8.6 - * Usage: <executable> <mem_kb> <os image> <num_vifs> 8.7 - */ 8.8 - 8.9 -#include <unistd.h> 8.10 -#include <stdio.h> 8.11 -#include <errno.h> 8.12 -#include <fcntl.h> 8.13 -#include <sys/stat.h> 8.14 -#include <sys/types.h> 8.15 - 8.16 -#include "dom0_ops.h" 8.17 -#include "dom0_defs.h" 8.18 - 8.19 -#define PERR_STRING "Xen Domain Killer" 8.20 - 8.21 -static int do_kill_domain(int dom_id, int force) 8.22 -{ 8.23 - char cmd_path[MAX_PATH]; 8.24 - dom0_op_t dop; 8.25 - int cmd_fd; 8.26 - 8.27 - dop.cmd = DOM0_DESTROYDOMAIN; 8.28 - dop.u.killdomain.domain = dom_id; 8.29 - dop.u.killdomain.force = force; 8.30 - 8.31 - /* open the /proc command interface */ 8.32 - sprintf(cmd_path, "%s%s%s%s", "/proc/", PROC_XENO_ROOT, "/", PROC_CMD); 8.33 - cmd_fd = open(cmd_path, O_WRONLY); 8.34 - if(cmd_fd < 0){ 8.35 - perror(PERR_STRING); 8.36 - return -1; 8.37 - } 8.38 - 8.39 - write(cmd_fd, &dop, sizeof(dom0_op_t)); 8.40 - close(cmd_fd); 8.41 - 8.42 - return 0; 8.43 -} 8.44 - 8.45 -int main(int argc, char **argv) 8.46 -{ 8.47 - int ret; 8.48 - 8.49 - if ( (argc < 2) || (argc > 3) ) 8.50 - { 8.51 - usage: 8.52 - printf("Usage: kill_domain [-f] <domain_id>\n"); 8.53 - printf(" -f: Forces immediate destruction of specified domain\n"); 8.54 - ret = -1; 8.55 - goto out; 8.56 - } 8.57 - 8.58 - if ( (argc == 3) && strcmp("-f", argv[1]) ) goto usage; 8.59 - 8.60 - ret = do_kill_domain(atoi(argv[argc-1]), argc == 3); 8.61 - 8.62 -out: 8.63 - return ret; 8.64 -}
9.1 --- a/tools/domain_builder/hypervisor_defs.h Mon Jul 07 09:51:04 2003 +0000 9.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 9.3 @@ -1,36 +0,0 @@ 9.4 -/****************************************************************************** 9.5 - * hypervisor_defs.h 9.6 - * 9.7 - * This needs to be kept in sync with Xen's pagetable update interface! 9.8 - * 9.9 - * Copyright (c) 2002-2003, Keir Fraser & Boris Dragovic 9.10 - */ 9.11 - 9.12 -/* taken from include/hypervisor-ifs/hypervisor-if.h */ 9.13 -typedef struct 9.14 -{ 9.15 -/* 9.16 - * PGREQ_XXX: specified in least-significant bits of 'ptr' field. All requests 9.17 - * specify relevent PTE or PT address in 'ptr'. Normal requests specify update 9.18 - * value in 'value'. Extended requests specify command in least 8 bits of 9.19 - * 'value'. 9.20 - */ 9.21 - unsigned long ptr, val; /* *ptr = val */ 9.22 -} page_update_request_t; 9.23 - 9.24 -/* A normal page-table update request. */ 9.25 -#define PGREQ_NORMAL 0 9.26 -#define PGREQ_MPT_UPDATE 1 9.27 -/* An extended command. */ 9.28 -#define PGREQ_EXTENDED_COMMAND 2 9.29 -/* Announce a new top-level page table. */ 9.30 -#define PGEXT_PIN_L1_TABLE 0 9.31 -#define PGEXT_PIN_L2_TABLE 1 9.32 -#define PGEXT_PIN_L3_TABLE 2 9.33 -#define PGEXT_PIN_L4_TABLE 3 9.34 -#define PGEXT_UNPIN_TABLE 4 9.35 -#define PGEXT_NEW_BASEPTR 5 9.36 -#define PGEXT_TLB_FLUSH 6 9.37 -#define PGEXT_INVLPG 7 9.38 -#define PGEXT_CMD_MASK 255 9.39 -#define PGEXT_CMD_SHIFT 8
10.1 --- a/tools/domain_builder/mem_defs.h Mon Jul 07 09:51:04 2003 +0000 10.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 10.3 @@ -1,45 +0,0 @@ 10.4 -/* 10.5 - * memory related definitions needed for userspace domain builder dom0 application. these _need_ to 10.6 - * be kept in sync with the kernel .h files they were copied over from or something horrible will 10.7 - * happen. remmember: god kills a kitten every time you forget to keep these in sync. 10.8 - * 10.9 - * KAF: Boris, these constants are all fixed by x86 hardware. So the kittens are safe for now :-) 10.10 - * 10.11 - * Copyright 2002 by B Dragovic 10.12 - */ 10.13 - 10.14 -/* copied over from hypervisor: include/asm-i386/page.h */ 10.15 - 10.16 -#define _PAGE_PRESENT 0x001 10.17 -#define _PAGE_RW 0x002 10.18 -#define _PAGE_USER 0x004 10.19 -#define _PAGE_PWT 0x008 10.20 -#define _PAGE_PCD 0x010 10.21 -#define _PAGE_ACCESSED 0x020 10.22 -#define _PAGE_DIRTY 0x040 10.23 -#define _PAGE_PAT 0x080 10.24 -#define _PAGE_PSE 0x080 10.25 -#define _PAGE_GLOBAL 0x100 10.26 - 10.27 - 10.28 -#define L1_PAGETABLE_SHIFT 12 10.29 -#define L2_PAGETABLE_SHIFT 22 10.30 - 10.31 -#define ENTRIES_PER_L1_PAGETABLE 1024 10.32 -#define ENTRIES_PER_L2_PAGETABLE 1024 10.33 - 10.34 -#define PAGE_SHIFT L1_PAGETABLE_SHIFT 10.35 -#define PAGE_SIZE (1UL << PAGE_SHIFT) 10.36 -#define PAGE_MASK (~(PAGE_SIZE-1)) 10.37 - 10.38 -typedef struct { unsigned long l1_lo; } l1_pgentry_t; 10.39 -typedef struct { unsigned long l2_lo; } l2_pgentry_t; 10.40 - 10.41 -#define l1_table_offset(_a) \ 10.42 - (((_a) >> L1_PAGETABLE_SHIFT) & (ENTRIES_PER_L1_PAGETABLE - 1)) 10.43 -#define l2_table_offset(_a) \ 10.44 - ((_a) >> L2_PAGETABLE_SHIFT) 10.45 - 10.46 -/* local definitions */ 10.47 - 10.48 -#define nr_2_page(x) (x << PAGE_SHIFT)
11.1 --- a/tools/domain_builder/mynewdom Mon Jul 07 09:51:04 2003 +0000 11.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 11.3 @@ -1,65 +0,0 @@ 11.4 -#!/bin/sh 11.5 - 11.6 -# mynewdom <size> <extra args> 11.7 - 11.8 -SIZE=${1:?"size missing"} 11.9 - 11.10 -SITE_NFS=128.232.32.20 11.11 -SITE_GW=128.232.32.1 11.12 -SITE_MASK=255.255.240.0 11.13 - 11.14 -shift; 11.15 - 11.16 -ARGS="$*" 11.17 - 11.18 -IMAGE=../../../xenolinux-2.4.21/arch/xeno/boot/image 11.19 - 11.20 - 11.21 -LASTDOM=`/bin/ls /proc/xeno/ | grep -v cmd | cut -c4- | sort -rn | head -1` 11.22 -DOM=$[LASTDOM+1] 11.23 - 11.24 -echo Domain ${DOM} looks free 11.25 - 11.26 -ADDR=`/sbin/ifconfig eth0 | grep inet.addr | sed -e 's/.*inet addr:\([0-9.]*\) .*/\1/'` 11.27 -LO=`echo $ADDR | sed -e 's/[0-9]\+\.[0-9]\+\.[0-9]\+\.\([0-9]\+\)/\1/'` 11.28 -HI=`echo $ADDR | sed -e 's/\([0-9]\+\.[0-9]\+\.[0-9]\+\)\.[0-9]\+/\1/'` 11.29 -NEWADDR=$HI.$[LO+DOM] 11.30 - 11.31 -NEWNAME=$NEWADDR 11.32 -LOOKUP=`host $NEWADDR` 11.33 -echo $LOOKUP | grep 'domain name pointer' && NEWNAME=`echo $LOOKUP | sed -e 's!.*domain name pointer \([^ ]\+\).$!\1!'` 11.34 -echo New IP address : ${NEWADDR} name : ${NEWNAME} 11.35 - 11.36 -#SITE_GW=`netstat -rn|while read a b c;do case "$a" in 0.0.0.0)echo "$b";;esac;done` 11.37 -NEWNAME='' 11.38 -#${NEWADDR} 11.39 -IP_CONFIG="ip=${NEWADDR}:${SITE_NFS}:${SITE_GW}:${SITE_MASK}:${NEWNAME}:eth0:off" 11.40 -echo IP_CONFIG : ${IP_CONFIG} 11.41 - 11.42 -CMDLINE=`cat /proc/cmdline` 11.43 -case $CMDLINE in 11.44 -*root=/dev/nfs*) 11.45 -ROOT_DIR=`echo $CMDLINE | sed -e 's,.*nfsroot=\([^ ]*\).*,\1,'` 11.46 -ROOT_PATH=`echo $ROOT_DIR | sed -e 's!^\(.*\)[0-9]\+$!\1!'` 11.47 -ROOT_NUM=`echo $ROOT_DIR | sed -e 's!^.*\([0-9]\+\)$!\1!'` 11.48 -NEWROOT_DEV="root=/dev/nfs nfsroot=${ROOT_PATH}$[ROOT_NUM+DOM]" 11.49 -;; 11.50 -*root=/dev/[hs]d[abcd][0-9]*|*root=/dev/x[hs]d[abcd][0-9]*) 11.51 -ROOT_DEV=`echo $CMDLINE | sed -e 's!^.*root=\(/dev/[x]*[hs]da[0-9]\+\).*$!\1!'` 11.52 -ROOT_DISK=`echo $ROOT_DEV | sed -e 's!\(/dev/[x]\?[hs]d[a-z]\)[0-9]\+!\1!'` 11.53 -ROOT_PART=`echo $ROOT_DEV | sed -e 's!/dev/[x]\?[hs]d[a-z]\([0-9]\+\)!\1!'` 11.54 -NEWROOT_DEV="root=${ROOT_DISK}$[ROOT_PART+DOM] ro" 11.55 -;; 11.56 -*) 11.57 -echo Could not determine root from /proc/cmdline 11.58 -exit 11.59 -;; 11.60 -esac 11.61 - 11.62 -echo New root arguments : ${NEWROOT_DEV} 11.63 - 11.64 -echo ./newdom ${SIZE} ${IMAGE} ${NEWADDR} ${IP_CONFIG} ${NEWROOT_DEV} ${EXTRA_ARGS} 11.65 - 11.66 -./newdom ${SIZE} ${IMAGE} ${NEWADDR} ${IP_CONFIG} ${NEWROOT_DEV} ${EXTRA_ARGS} 11.67 - 11.68 -
12.1 --- a/tools/domain_builder/newdom Mon Jul 07 09:51:04 2003 +0000 12.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 12.3 @@ -1,26 +0,0 @@ 12.4 -#!/bin/sh 12.5 - 12.6 -# newdom <size> <image> <ip> <root details> 12.7 -# newdom 262144 ../../../xenolinux-2.4.16-kdb/arch/xeno/boot/image 128.232.35.240 root=/dev/nfs nfsroot=/usr/groups/srgboot/xxx/roots/root0 12.8 -# newdom 262144 ../../../xenolinux-2.4.16-kdb/arch/xeno/boot/image 128.232.35.240 root=/dev/xhda7 12.9 - 12.10 - 12.11 -VIFINIT=./vifinit 12.12 -DOM_BUILDER=./domain_builder 12.13 - 12.14 -SIZE=${1:?"size missing"} 12.15 -IMAGE=${2:?"image missing"} 12.16 -IP=${3:?"IP missing"} 12.17 - 12.18 -shift; shift; shift 12.19 - 12.20 -echo ARGS $* 12.21 - 12.22 -$DOM_BUILDER $SIZE $IMAGE 1 $* 12.23 -DOM=$? 12.24 - 12.25 -echo DOM= $DOM 12.26 - 12.27 -$VIFINIT $DOM 0 $IP 12.28 - 12.29 -
13.1 --- a/tools/domain_builder/vifinit Mon Jul 07 09:51:04 2003 +0000 13.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 13.3 @@ -1,25 +0,0 @@ 13.4 -#!/bin/bash 13.5 -# 13.6 -# vifinit 13.7 -# 13.8 -# This is a silly little script to dump a couple of simple rules down to 13.9 -# the hypervisor to assign a full static IP to a given virtual interface. 13.10 -# 13.11 -# Usage is: 13.12 -# 13.13 -# vifinit [vif dom] [vif idx] [dotted decimal ip address] 13.14 -# 13.15 -if [ $# -ne 3 ] ; 13.16 -then 13.17 - echo "usage: vifinit [vif dom] [vif idx] [dotted decimal ip address]" 13.18 - exit 13.19 -fi 13.20 - 13.21 -#outbound rule: 13.22 -echo "ADD ACCEPT srcaddr=$3 srcaddrmask=255.255.255.255 srcdom=$1 srcidx=$2 dst=PHYS proto=any" > /proc/vfr 13.23 - 13.24 -#inbound rule: 13.25 -echo "ADD ACCEPT dstaddr=$3 dstaddrmask=255.255.255.255 src=ANY dstdom=$1 dstidx=$2 proto=any" > /proc/vfr 13.26 - 13.27 -#----] done. 13.28 -
14.1 --- a/xen/Rules.mk Mon Jul 07 09:51:04 2003 +0000 14.2 +++ b/xen/Rules.mk Mon Jul 07 10:07:49 2003 +0000 14.3 @@ -32,7 +32,7 @@ HOSTCFLAGS = -Wall -Wstrict-prototypes - 14.4 include $(BASEDIR)/arch/$(ARCH)/Rules.mk 14.5 14.6 %.o: %.c $(HDRS) Makefile 14.7 - $(CC) -g $(CFLAGS) -c $< -o $@ 14.8 + $(CC) $(CFLAGS) -c $< -o $@ 14.9 14.10 %.o: %.S $(HDRS) Makefile 14.11 $(CC) $(CFLAGS) -D__ASSEMBLY__ -c $< -o $@
15.1 --- a/xen/arch/i386/entry.S Mon Jul 07 09:51:04 2003 +0000 15.2 +++ b/xen/arch/i386/entry.S Mon Jul 07 10:07:49 2003 +0000 15.3 @@ -647,7 +647,6 @@ ENTRY(hypervisor_call_table) 15.4 .long SYMBOL_NAME(do_dom_mem_op) 15.5 .long SYMBOL_NAME(do_multicall) 15.6 .long SYMBOL_NAME(do_kbd_op) 15.7 - .long SYMBOL_NAME(do_set_priv_levels) 15.8 .rept NR_syscalls-((.-hypervisor_call_table)/4) 15.9 .long SYMBOL_NAME(sys_ni_syscall) 15.10 .endr
16.1 --- a/xen/arch/i386/process.c Mon Jul 07 09:51:04 2003 +0000 16.2 +++ b/xen/arch/i386/process.c Mon Jul 07 10:07:49 2003 +0000 16.3 @@ -348,19 +348,10 @@ void __switch_to(struct task_struct *pre 16.4 } 16.5 16.6 16.7 -long do_set_priv_levels(unsigned int new_io_pl, unsigned int new_hypercall_pl) 16.8 +/* XXX Currently the 'domain' field is ignored! XXX */ 16.9 +long do_iopl(unsigned int domain, unsigned int new_io_pl) 16.10 { 16.11 struct pt_regs *regs = GET_SYSCALL_REGS(current); 16.12 - 16.13 - /* 16.14 - * Any domain can reduce privilege required for hypercall access. 16.15 - * Note that access from ring 1 cannot be relinquished. 16.16 - */ 16.17 - current->thread.hypercall_pl = new_hypercall_pl & 3; 16.18 - 16.19 - /* Only privileged domains can acquire access to I/O ports. */ 16.20 - if ( IS_PRIV(current) ) 16.21 - regs->eflags = (regs->eflags & 0xffffcfff) | ((new_io_pl&3) << 12); 16.22 - 16.23 + regs->eflags = (regs->eflags & 0xffffcfff) | ((new_io_pl&3) << 12); 16.24 return 0; 16.25 }
17.1 --- a/xen/arch/i386/traps.c Mon Jul 07 09:51:04 2003 +0000 17.2 +++ b/xen/arch/i386/traps.c Mon Jul 07 10:07:49 2003 +0000 17.3 @@ -401,23 +401,6 @@ asmlinkage void do_general_protection(st 17.4 */ 17.5 if ( (error_code & 3) == 2 ) 17.6 { 17.7 - /* 17.8 - * Hypercalls from rings 2 or 3 fall through to here. If permitted, we 17.9 - * will transfer control to the requested hypercall. 17.10 - */ 17.11 - if ( ((error_code>>3) == HYPERVISOR_CALL_VECTOR) && 17.12 - (current->thread.hypercall_pl >= (regs->xcs & 3)) ) 17.13 - { 17.14 - __asm__ __volatile__ ( 17.15 - "movl %0,%%esp \n" 17.16 - "sti \n" 17.17 - "andl $255,%%eax \n" 17.18 - "call *hypervisor_call_table(,%%eax,4) \n" 17.19 - "movl %%eax,0x18(%%esp) \n" 17.20 - "jmp ret_from_intr \n" 17.21 - : : "r" (regs) ); 17.22 - } 17.23 - 17.24 /* This fault must be due to <INT n> instruction. */ 17.25 ti = current->thread.traps + (error_code>>3); 17.26 if ( ti->dpl >= (regs->xcs & 3) )
18.1 --- a/xen/common/dom0_ops.c Mon Jul 07 09:51:04 2003 +0000 18.2 +++ b/xen/common/dom0_ops.c Mon Jul 07 10:07:49 2003 +0000 18.3 @@ -67,7 +67,7 @@ long do_dom0_op(dom0_op_t *u_dom0_op) 18.4 long ret = 0; 18.5 dom0_op_t op; 18.6 18.7 - if ( current->domain != 0 ) 18.8 + if ( !IS_PRIV(current) ) 18.9 return -EPERM; 18.10 18.11 if ( copy_from_user(&op, u_dom0_op, sizeof(op)) ) 18.12 @@ -239,6 +239,13 @@ long do_dom0_op(dom0_op_t *u_dom0_op) 18.13 break; 18.14 } 18.15 18.16 + case DOM0_IOPL: 18.17 + { 18.18 + extern long do_iopl(unsigned int, unsigned int); 18.19 + ret = do_iopl(op.u.iopl.domain, op.u.iopl.iopl); 18.20 + } 18.21 + break; 18.22 + 18.23 default: 18.24 ret = -ENOSYS; 18.25
19.1 --- a/xen/include/asm-i386/processor.h Mon Jul 07 09:51:04 2003 +0000 19.2 +++ b/xen/include/asm-i386/processor.h Mon Jul 07 10:07:49 2003 +0000 19.3 @@ -356,7 +356,6 @@ struct thread_struct { 19.4 int fast_trap_idx; 19.5 struct desc_struct fast_trap_desc; 19.6 trap_info_t traps[256]; 19.7 - int hypercall_pl; 19.8 }; 19.9 19.10 #define IDT_ENTRIES 256
20.1 --- a/xen/include/hypervisor-ifs/dom0_ops.h Mon Jul 07 09:51:04 2003 +0000 20.2 +++ b/xen/include/hypervisor-ifs/dom0_ops.h Mon Jul 07 10:07:49 2003 +0000 20.3 @@ -19,9 +19,10 @@ 20.4 #define DOM0_STOPDOMAIN 11 20.5 #define DOM0_GETDOMAININFO 12 20.6 #define DOM0_BUILDDOMAIN 13 20.7 +#define DOM0_IOPL 14 20.8 20.9 -#define MAX_CMD_LEN 256 20.10 -#define MAX_DOMAIN_NAME 16 20.11 +#define MAX_CMD_LEN 256 20.12 +#define MAX_DOMAIN_NAME 16 20.13 20.14 typedef struct dom0_newdomain_st 20.15 { 20.16 @@ -60,32 +61,38 @@ typedef struct domain_launch 20.17 20.18 typedef struct dom0_bvtctl_st 20.19 { 20.20 - unsigned long ctx_allow; /* context switch allowance */ 20.21 + unsigned long ctx_allow; /* context switch allowance */ 20.22 } dom0_bvtctl_t; 20.23 20.24 typedef struct dom0_adjustdom_st 20.25 { 20.26 unsigned int domain; /* domain id */ 20.27 - unsigned long mcu_adv; /* mcu advance: inverse of weight */ 20.28 - unsigned long warp; /* time warp */ 20.29 - unsigned long warpl; /* warp limit */ 20.30 - unsigned long warpu; /* unwarp time requirement */ 20.31 + unsigned long mcu_adv; /* mcu advance: inverse of weight */ 20.32 + unsigned long warp; /* time warp */ 20.33 + unsigned long warpl; /* warp limit */ 20.34 + unsigned long warpu; /* unwarp time requirement */ 20.35 } dom0_adjustdom_t; 20.36 20.37 typedef struct dom0_getdominfo_st 20.38 { 20.39 - unsigned int domain; /* All returns except domain */ 20.40 - char name[MAX_DOMAIN_NAME]; 20.41 - int processor; 20.42 - int has_cpu; 20.43 - int state; 20.44 - int hyp_events; 20.45 - unsigned long mcu_advance; 20.46 - unsigned long pg_head; 20.47 - unsigned int tot_pages; 20.48 - long long cpu_time; 20.49 + unsigned int domain; /* All returns except domain */ 20.50 + char name[MAX_DOMAIN_NAME]; 20.51 + int processor; 20.52 + int has_cpu; 20.53 + int state; 20.54 + int hyp_events; 20.55 + unsigned long mcu_advance; 20.56 + unsigned long pg_head; 20.57 + unsigned int tot_pages; 20.58 + long long cpu_time; 20.59 } dom0_getdominfo_t; 20.60 20.61 +typedef struct dom0_iopl_st 20.62 +{ 20.63 + unsigned int domain; 20.64 + unsigned int iopl; 20.65 +} dom0_iopl_t; 20.66 + 20.67 #ifndef NO_DOM0_OP_T 20.68 typedef struct dom0_op_st 20.69 { 20.70 @@ -95,11 +102,12 @@ typedef struct dom0_op_st 20.71 dom0_newdomain_t newdomain; 20.72 dom0_killdomain_t killdomain; 20.73 dom0_getmemlist_t getmemlist; 20.74 - dom0_bvtctl_t bvtctl; 20.75 - dom0_adjustdom_t adjustdom; 20.76 + dom0_bvtctl_t bvtctl; 20.77 + dom0_adjustdom_t adjustdom; 20.78 dom_meminfo_t meminfo; 20.79 dom0_getdominfo_t getdominfo; 20.80 - } 20.81 + dom0_iopl_t iopl; 20.82 + } 20.83 u; 20.84 } dom0_op_t; 20.85 #endif
21.1 --- a/xen/include/hypervisor-ifs/hypervisor-if.h Mon Jul 07 09:51:04 2003 +0000 21.2 +++ b/xen/include/hypervisor-ifs/hypervisor-if.h Mon Jul 07 10:07:49 2003 +0000 21.3 @@ -48,7 +48,6 @@ 21.4 #define __HYPERVISOR_dom_mem_op 17 21.5 #define __HYPERVISOR_multicall 18 21.6 #define __HYPERVISOR_kbd_op 19 21.7 -#define __HYPERVISOR_set_priv_levels 20 21.8 21.9 /* And the trap vector is... */ 21.10 #define TRAP_INSTR "int $0x82"
22.1 --- a/xenolinux-2.4.21-sparse/arch/xeno/drivers/dom0/dom0_core.c Mon Jul 07 09:51:04 2003 +0000 22.2 +++ b/xenolinux-2.4.21-sparse/arch/xeno/drivers/dom0/dom0_core.c Mon Jul 07 10:07:49 2003 +0000 22.3 @@ -32,9 +32,6 @@ 22.4 22.5 #include "dom0_ops.h" 22.6 22.7 -#define TRUE 1 22.8 -#define FALSE 0 22.9 - 22.10 /* Private proc-file data structures. */ 22.11 typedef struct proc_data { 22.12 unsigned int domain; 22.13 @@ -46,18 +43,7 @@ typedef struct proc_mem_data { 22.14 int tot_pages; 22.15 } proc_memdata_t; 22.16 22.17 -#define XENO_BASE "xeno" 22.18 -#define DOM0_CMD_INTF "dom0_cmd" 22.19 -#define DOM0_NEWDOM "new_dom_data" 22.20 -#define DOM_LIST_INTF "domains" 22.21 - 22.22 -#define MAX_LEN 16 22.23 -#define DOM_DIR "dom" 22.24 -#define DOM_MEM "mem" 22.25 -#define DOM_VIF "vif" 22.26 -#define DOM_USAGE "usage" 22.27 #define DOM_PHD "phd" 22.28 - 22.29 #define MAP_DISCONT 1 22.30 22.31 extern struct file_operations dom0_phd_fops; 22.32 @@ -73,7 +59,7 @@ int direct_disc_unmap(unsigned long, uns 22.33 static unsigned char readbuf[1204]; 22.34 22.35 static int cmd_read_proc(char *page, char **start, off_t off, 22.36 - int count, int *eof, void *data) 22.37 + int count, int *eof, void *data) 22.38 { 22.39 strcpy(page, readbuf); 22.40 *readbuf = '\0'; 22.41 @@ -82,50 +68,6 @@ static int cmd_read_proc(char *page, cha 22.42 return strlen(page); 22.43 } 22.44 22.45 -static ssize_t dom_vif_read(struct file * file, char * buff, size_t size, loff_t * off) 22.46 -{ 22.47 - int hyp_buf[32]; 22.48 - char buf[128]; 22.49 - network_op_t op; 22.50 - static int finished = 0; 22.51 - 22.52 - if ( finished ) 22.53 - { 22.54 - finished = 0; 22.55 - return 0; 22.56 - } 22.57 - 22.58 - op.cmd = NETWORK_OP_VIFQUERY; 22.59 - op.u.vif_query.domain = (unsigned int) 22.60 - ((struct proc_dir_entry *)file->f_dentry->d_inode->u.generic_ip)->data; 22.61 - op.u.vif_query.buf = hyp_buf; 22.62 - 22.63 - (void) HYPERVISOR_network_op(&op); 22.64 - 22.65 - if(hyp_buf[0] < 0) { 22.66 - strcpy(buf, "Error getting domain's vif list from hypervisor.\n"); 22.67 - } else { 22.68 - int i; 22.69 - int len = 0; 22.70 - strcpy(buf, "No vif found"); 22.71 - 22.72 - for(i = 1; i <= hyp_buf[0] && len < 127; i++) 22.73 - len += snprintf(buf + len, 127 - len, "%d\n", hyp_buf[i]); 22.74 - } 22.75 - 22.76 - if (*off >= (strlen(buf)+1)) return 0; 22.77 - 22.78 - copy_to_user(buff, buf, strlen(buf)); 22.79 - 22.80 - finished = 1; 22.81 - 22.82 - return strlen(buf)+1; 22.83 -} 22.84 - 22.85 -struct file_operations dom_vif_ops = { 22.86 - read: dom_vif_read 22.87 -}; 22.88 - 22.89 static ssize_t dom_usage_read(struct file * file, char * buff, size_t size, loff_t * off) 22.90 { 22.91 char str[256]; 22.92 @@ -166,13 +108,13 @@ static ssize_t dom_usage_read(struct fil 22.93 (void) HYPERVISOR_network_op(&netop); 22.94 22.95 end += snprintf(str + end, 255 - end, 22.96 - "vif%d: sent %lld bytes (%lld packets) " 22.97 - "received %lld bytes (%lld packets)\n", 22.98 - vifs[i], 22.99 - netop.u.vif_getinfo.total_bytes_sent, 22.100 - netop.u.vif_getinfo.total_packets_sent, 22.101 - netop.u.vif_getinfo.total_bytes_received, 22.102 - netop.u.vif_getinfo.total_packets_received); 22.103 + "vif%d: sent %lld bytes (%lld packets) " 22.104 + "received %lld bytes (%lld packets)\n", 22.105 + vifs[i], 22.106 + netop.u.vif_getinfo.total_bytes_sent, 22.107 + netop.u.vif_getinfo.total_packets_sent, 22.108 + netop.u.vif_getinfo.total_bytes_received, 22.109 + netop.u.vif_getinfo.total_packets_received); 22.110 } 22.111 22.112 if (*off >= end + 1) return 0; 22.113 @@ -193,10 +135,10 @@ static void create_proc_dom_entries(int 22.114 { 22.115 struct proc_dir_entry * dir; 22.116 dom_procdata_t * dom_data; 22.117 - char dir_name[MAX_LEN]; 22.118 + char dir_name[16]; 22.119 struct proc_dir_entry * file; 22.120 22.121 - snprintf(dir_name, MAX_LEN, "%s%d", DOM_DIR, dom); 22.122 + sprintf(dir_name, "dom%d", dom); 22.123 22.124 dom_data = (dom_procdata_t *)kmalloc(sizeof(dom_procdata_t), GFP_KERNEL); 22.125 dom_data->domain = dom; 22.126 @@ -204,16 +146,7 @@ static void create_proc_dom_entries(int 22.127 dir = proc_mkdir(dir_name, xeno_base); 22.128 dir->data = dom_data; 22.129 22.130 - file = create_proc_entry(DOM_VIF, 0600, dir); 22.131 - if (file != NULL) 22.132 - { 22.133 - file->owner = THIS_MODULE; 22.134 - file->nlink = 1; 22.135 - file->proc_fops = &dom_vif_ops; 22.136 - file->data = (void *) dom; 22.137 - } 22.138 - 22.139 - file = create_proc_entry(DOM_USAGE, 0600, dir); 22.140 + file = create_proc_entry("usage", 0600, dir); 22.141 if (file != NULL) 22.142 { 22.143 file->owner = THIS_MODULE; 22.144 @@ -233,14 +166,14 @@ static void create_proc_dom_entries(int 22.145 } 22.146 22.147 static ssize_t dom_mem_write(struct file * file, const char * buff, 22.148 - size_t size , loff_t * off) 22.149 + size_t size , loff_t * off) 22.150 { 22.151 dom_mem_t mem_data; 22.152 22.153 copy_from_user(&mem_data, (dom_mem_t *)buff, sizeof(dom_mem_t)); 22.154 22.155 if(direct_disc_unmap(mem_data.vaddr, mem_data.start_pfn, 22.156 - mem_data.tot_pages) == 0){ 22.157 + mem_data.tot_pages) == 0){ 22.158 return sizeof(sizeof(dom_mem_t)); 22.159 } else { 22.160 return -1; 22.161 @@ -284,12 +217,12 @@ static int dom_map_mem(unsigned int dom, 22.162 /* check if there is already an entry for mem and if so 22.163 * remove it. 22.164 */ 22.165 - remove_proc_entry(DOM_MEM, pd); 22.166 + remove_proc_entry("mem", pd); 22.167 22.168 /* create new entry with parameters describing what to do 22.169 * when it is mmaped. 22.170 */ 22.171 - file = create_proc_entry(DOM_MEM, 0600, pd); 22.172 + file = create_proc_entry("mem", 0600, pd); 22.173 if(file != NULL) 22.174 { 22.175 file->owner = THIS_MODULE; 22.176 @@ -322,7 +255,7 @@ static ssize_t dom_data_read(struct file 22.177 22.178 copy_to_user((dom0_newdomain_t *)buff, dom_data, sizeof(dom0_newdomain_t)); 22.179 22.180 - remove_proc_entry(DOM0_NEWDOM, xeno_base); 22.181 + remove_proc_entry("new_dom_data", xeno_base); 22.182 22.183 kfree(dom_data); 22.184 22.185 @@ -334,7 +267,7 @@ struct file_operations newdom_data_fops 22.186 }; 22.187 22.188 static int cmd_write_proc(struct file *file, const char *buffer, 22.189 - u_long count, void *data) 22.190 + u_long count, void *data) 22.191 { 22.192 dom0_op_t op; 22.193 int ret = 0; 22.194 @@ -343,16 +276,10 @@ static int cmd_write_proc(struct file *f 22.195 22.196 copy_from_user(&op, buffer, sizeof(dom0_op_t)); 22.197 22.198 - /* do some sanity checks */ 22.199 - if(op.cmd > MAX_CMD){ 22.200 - ret = -ENOSYS; 22.201 - goto out; 22.202 - } 22.203 - 22.204 if ( op.cmd == MAP_DOM_MEM ) 22.205 { 22.206 ret = dom_map_mem(op.u.dommem.domain, op.u.dommem.start_pfn, 22.207 - op.u.dommem.tot_pages); 22.208 + op.u.dommem.tot_pages); 22.209 } 22.210 else if ( op.cmd == DO_PGUPDATES ) 22.211 { 22.212 @@ -368,14 +295,14 @@ static int cmd_write_proc(struct file *f 22.213 create_proc_dom_entries(ret); 22.214 22.215 params = (dom0_newdomain_t *)kmalloc(sizeof(dom0_newdomain_t), 22.216 - GFP_KERNEL); 22.217 + GFP_KERNEL); 22.218 params->memory_kb = op.u.newdomain.memory_kb; 22.219 params->pg_head = op.u.newdomain.pg_head; 22.220 params->num_vifs = op.u.newdomain.num_vifs; 22.221 params->domain = op.u.newdomain.domain; 22.222 22.223 /* now notify user space of the new domain's id */ 22.224 - new_dom_id = create_proc_entry(DOM0_NEWDOM, 0600, xeno_base); 22.225 + new_dom_id = create_proc_entry("new_dom_data", 0600, xeno_base); 22.226 if ( new_dom_id != NULL ) 22.227 { 22.228 new_dom_id->owner = THIS_MODULE; 22.229 @@ -383,14 +310,11 @@ static int cmd_write_proc(struct file *f 22.230 new_dom_id->proc_fops = &newdom_data_fops; 22.231 new_dom_id->data = (void *)params; 22.232 } 22.233 - 22.234 } 22.235 - 22.236 } 22.237 22.238 -out: 22.239 - return ret; 22.240 - 22.241 + out: 22.242 + return ret; 22.243 } 22.244 22.245 /*********************************************************************** 22.246 @@ -404,83 +328,87 @@ static rwlock_t proc_xeno_domains_lock = 22.247 22.248 static void *xeno_domains_next(struct seq_file *s, void *v, loff_t *pos) 22.249 { 22.250 - int ret; 22.251 + int ret; 22.252 + 22.253 + if ( pos != NULL ) 22.254 + ++(*pos); 22.255 22.256 - if (pos != NULL) { ++ (*pos); } 22.257 - if (!proc_domains_finished) { 22.258 - proc_domains_op.u.getdominfo.domain ++; 22.259 - ret = HYPERVISOR_dom0_op(&proc_domains_op); 22.260 - if (ret < 0) proc_domains_finished = TRUE; 22.261 - } 22.262 + if ( !proc_domains_finished ) 22.263 + { 22.264 + proc_domains_op.u.getdominfo.domain++; 22.265 + ret = HYPERVISOR_dom0_op(&proc_domains_op); 22.266 + if ( ret < 0 ) 22.267 + proc_domains_finished = 1; 22.268 + } 22.269 22.270 - return (proc_domains_finished) ? NULL : &proc_domains_op; 22.271 + return (proc_domains_finished) ? NULL : &proc_domains_op; 22.272 } 22.273 22.274 static void *xeno_domains_start(struct seq_file *s, loff_t *ppos) 22.275 { 22.276 - loff_t pos = *ppos; 22.277 + loff_t pos = *ppos; 22.278 22.279 - write_lock (&proc_xeno_domains_lock); 22.280 - proc_domains_op.cmd = DOM0_GETDOMAININFO; 22.281 - proc_domains_op.u.getdominfo.domain = 0; 22.282 - (void)HYPERVISOR_dom0_op(&proc_domains_op); 22.283 - proc_domains_finished = FALSE; 22.284 + write_lock (&proc_xeno_domains_lock); 22.285 + proc_domains_op.cmd = DOM0_GETDOMAININFO; 22.286 + proc_domains_op.u.getdominfo.domain = 0; 22.287 + (void)HYPERVISOR_dom0_op(&proc_domains_op); 22.288 + proc_domains_finished = 0; 22.289 22.290 - while (pos > 0) { 22.291 - pos --; 22.292 - xeno_domains_next (s, NULL, NULL); 22.293 - } 22.294 + while (pos > 0) { 22.295 + pos --; 22.296 + xeno_domains_next (s, NULL, NULL); 22.297 + } 22.298 22.299 - return (proc_domains_finished) ? NULL : &proc_domains_op; 22.300 + return (proc_domains_finished) ? NULL : &proc_domains_op; 22.301 } 22.302 22.303 static void xeno_domains_stop(struct seq_file *s, void *v) 22.304 { 22.305 - write_unlock (&proc_xeno_domains_lock); 22.306 + write_unlock (&proc_xeno_domains_lock); 22.307 } 22.308 22.309 static int xeno_domains_show(struct seq_file *s, void *v) 22.310 { 22.311 - dom0_op_t *di = v; 22.312 + dom0_op_t *di = v; 22.313 22.314 - /* 22.315 - * Output one domain's details to dom0. 22.316 - * 22.317 - * If you update this format string then change xi_list to match. 22.318 - */ 22.319 + /* 22.320 + * Output one domain's details to dom0. 22.321 + * 22.322 + * If you update this format string then change xi_list to match. 22.323 + */ 22.324 22.325 - seq_printf (s, 22.326 - "%8d %2d %1d %2d %8d %8ld %p %8d %s\n", 22.327 - di -> u.getdominfo.domain, 22.328 - di -> u.getdominfo.processor, 22.329 - di -> u.getdominfo.has_cpu, 22.330 - di -> u.getdominfo.state, 22.331 - di -> u.getdominfo.hyp_events, 22.332 - di -> u.getdominfo.mcu_advance, 22.333 - (void *)di -> u.getdominfo.pg_head, 22.334 - di -> u.getdominfo.tot_pages, 22.335 - di -> u.getdominfo.name); 22.336 + seq_printf (s, 22.337 + "%8d %2d %1d %2d %8d %8ld %p %8d %s\n", 22.338 + di -> u.getdominfo.domain, 22.339 + di -> u.getdominfo.processor, 22.340 + di -> u.getdominfo.has_cpu, 22.341 + di -> u.getdominfo.state, 22.342 + di -> u.getdominfo.hyp_events, 22.343 + di -> u.getdominfo.mcu_advance, 22.344 + di -> u.getdominfo.pg_head, 22.345 + di -> u.getdominfo.tot_pages, 22.346 + di -> u.getdominfo.name); 22.347 + return 0; 22.348 22.349 - return 0; 22.350 } 22.351 22.352 struct seq_operations xeno_domains_op = { 22.353 - .start = xeno_domains_start, 22.354 - .next = xeno_domains_next, 22.355 - .stop = xeno_domains_stop, 22.356 - .show = xeno_domains_show, 22.357 + .start = xeno_domains_start, 22.358 + .next = xeno_domains_next, 22.359 + .stop = xeno_domains_stop, 22.360 + .show = xeno_domains_show, 22.361 }; 22.362 22.363 static int xeno_domains_open(struct inode *inode, struct file *file) 22.364 { 22.365 - return seq_open(file, &xeno_domains_op); 22.366 + return seq_open(file, &xeno_domains_op); 22.367 } 22.368 22.369 static struct file_operations proc_xeno_domains_operations = { 22.370 - open: xeno_domains_open, 22.371 - read: seq_read, 22.372 - llseek: seq_lseek, 22.373 - release: seq_release, 22.374 + open: xeno_domains_open, 22.375 + read: seq_read, 22.376 + llseek: seq_lseek, 22.377 + release: seq_release, 22.378 }; 22.379 22.380 /***********************************************************************/ 22.381 @@ -490,11 +418,11 @@ static struct file_operations proc_xeno_ 22.382 static int __init init_module(void) 22.383 { 22.384 /* xeno proc root setup */ 22.385 - xeno_base = proc_mkdir(XENO_BASE, &proc_root); 22.386 + xeno_base = proc_mkdir("xeno", &proc_root); 22.387 22.388 /* xeno control interface */ 22.389 *readbuf = '\0'; 22.390 - dom0_cmd_intf = create_proc_entry (DOM0_CMD_INTF, 0600, xeno_base); 22.391 + dom0_cmd_intf = create_proc_entry("dom0_cmd", 0600, xeno_base); 22.392 if ( dom0_cmd_intf != NULL ) 22.393 { 22.394 dom0_cmd_intf->owner = THIS_MODULE; 22.395 @@ -504,13 +432,13 @@ static int __init init_module(void) 22.396 } 22.397 22.398 /* domain list interface */ 22.399 - dom_list_intf = create_proc_entry (DOM_LIST_INTF, 0400, xeno_base); 22.400 + dom_list_intf = create_proc_entry("domains", 0400, xeno_base); 22.401 if ( dom_list_intf != NULL ) 22.402 - { 22.403 - dom_list_intf -> owner = THIS_MODULE; 22.404 - dom_list_intf -> nlink = 1; 22.405 - dom_list_intf -> proc_fops = &proc_xeno_domains_operations; 22.406 - } 22.407 + { 22.408 + dom_list_intf->owner = THIS_MODULE; 22.409 + dom_list_intf->nlink = 1; 22.410 + dom_list_intf->proc_fops = &proc_xeno_domains_operations; 22.411 + } 22.412 22.413 /* set up /proc entries for dom 0 */ 22.414 create_proc_dom_entries(0);
23.1 --- a/xenolinux-2.4.21-sparse/arch/xeno/drivers/dom0/dom0_ops.h Mon Jul 07 09:51:04 2003 +0000 23.2 +++ b/xenolinux-2.4.21-sparse/arch/xeno/drivers/dom0/dom0_ops.h Mon Jul 07 10:07:49 2003 +0000 23.3 @@ -18,9 +18,8 @@ 23.4 #endif 23.5 23.6 /* Extra commands dealt with by Xenolinux. */ 23.7 -#define MAP_DOM_MEM 14 23.8 -#define DO_PGUPDATES 15 23.9 -#define MAX_CMD 16 23.10 +#define MAP_DOM_MEM 1014 23.11 +#define DO_PGUPDATES 1015 23.12 23.13 typedef struct dom_mem 23.14 { 23.15 @@ -50,8 +49,8 @@ typedef struct dom0_op_st 23.16 dom_pgupdate_t pgupdate; 23.17 dom_meminfo_t meminfo; 23.18 dom0_getdominfo_t getdominfo; 23.19 - } 23.20 - u; 23.21 + dom0_iopl_t iopl; 23.22 + } u; 23.23 } dom0_op_t; 23.24 23.25 #endif /* __DOM0_DOM0_OPS_H__ */
24.1 --- a/xenolinux-2.4.21-sparse/arch/xeno/kernel/ioport.c Mon Jul 07 09:51:04 2003 +0000 24.2 +++ b/xenolinux-2.4.21-sparse/arch/xeno/kernel/ioport.c Mon Jul 07 10:07:49 2003 +0000 24.3 @@ -3,6 +3,7 @@ 24.4 #include <linux/errno.h> 24.5 #include <linux/types.h> 24.6 #include <linux/stddef.h> 24.7 +#include <asm/hypervisor-ifs/dom0_ops.h> 24.8 24.9 24.10 asmlinkage int sys_ioperm(unsigned long from, unsigned long num, int turn_on) 24.11 @@ -15,32 +16,32 @@ asmlinkage int sys_ioperm(unsigned long 24.12 asmlinkage int sys_iopl(unsigned long unused) 24.13 { 24.14 struct pt_regs *regs = (struct pt_regs *)&unused; 24.15 - unsigned int new_io_pl = regs->ebx & 3; 24.16 + unsigned int new_io_pl = regs->ebx; 24.17 unsigned int old_io_pl = current->thread.io_pl; 24.18 - unsigned int new_hypercall_pl = (regs->ebx >> 2) & 3; 24.19 - unsigned int old_hypercall_pl = current->thread.hypercall_pl; 24.20 + dom0_op_t op; 24.21 + 24.22 + if ( !(start_info.flags & SIF_PRIVILEGED) ) 24.23 + return -EPERM; 24.24 + 24.25 + if ( new_io_pl > 3 ) 24.26 + return -EINVAL; 24.27 24.28 /* Need "raw I/O" privileges for direct port access. */ 24.29 - if ( (new_io_pl > old_io_pl) && 24.30 - (!capable(CAP_SYS_RAWIO) || !(start_info.flags & SIF_PRIVILEGED)) ) 24.31 - return -EPERM; 24.32 - 24.33 - /* Just need generic root/admin privileges for direct hypercall access. */ 24.34 - if ( (new_hypercall_pl > old_hypercall_pl) && !capable(CAP_SYS_ADMIN) ) 24.35 + if ( (new_io_pl > old_io_pl) && !capable(CAP_SYS_RAWIO) ) 24.36 return -EPERM; 24.37 24.38 /* Maintain OS privileges even if user attempts to relinquish them. */ 24.39 - if ( new_hypercall_pl == 0 ) 24.40 - new_hypercall_pl = 1; 24.41 if ( (new_io_pl == 0) && (start_info.flags & SIF_PRIVILEGED) ) 24.42 new_io_pl = 1; 24.43 24.44 /* Change our version of the privilege levels. */ 24.45 - current->thread.io_pl = new_io_pl; 24.46 - current->thread.hypercall_pl = new_hypercall_pl; 24.47 + current->thread.io_pl = new_io_pl; 24.48 24.49 /* Force the change at ring 0. */ 24.50 - HYPERVISOR_set_priv_levels(new_io_pl, new_hypercall_pl); 24.51 + op.cmd = DOM0_IOPL; 24.52 + op.u.iopl.domain = start_info.dom_id; 24.53 + op.u.iopl.iopl = new_io_pl; 24.54 + HYPERVISOR_dom0_op(&op); 24.55 24.56 return 0; 24.57 }
25.1 --- a/xenolinux-2.4.21-sparse/arch/xeno/kernel/process.c Mon Jul 07 09:51:04 2003 +0000 25.2 +++ b/xenolinux-2.4.21-sparse/arch/xeno/kernel/process.c Mon Jul 07 10:07:49 2003 +0000 25.3 @@ -44,6 +44,7 @@ 25.4 #include <asm/desc.h> 25.5 #include <asm/mmu_context.h> 25.6 #include <asm/multicall.h> 25.7 +#include <asm/hypervisor-ifs/dom0_ops.h> 25.8 25.9 #include <linux/irq.h> 25.10 25.11 @@ -274,9 +275,6 @@ int copy_thread(int nr, unsigned long cl 25.12 __asm__ __volatile__ ( "pushfl; popl %0" : "=r" (eflags) : ); 25.13 p->thread.io_pl = (eflags >> 12) & 3; 25.14 25.15 - /* We're careful with hypercall privileges. Don't allow inheritance. */ 25.16 - p->thread.hypercall_pl = 1; 25.17 - 25.18 return 0; 25.19 } 25.20 25.21 @@ -370,9 +368,14 @@ void __switch_to(struct task_struct *pre 25.22 } 25.23 25.24 queue_multicall2(__HYPERVISOR_stack_switch, __KERNEL_DS, next->esp0); 25.25 - /* Next call will silently fail if we are a non-privileged guest OS. */ 25.26 - queue_multicall2(__HYPERVISOR_set_priv_levels, 25.27 - next->io_pl, next->hypercall_pl); 25.28 + if ( start_info.flags & SIF_PRIVILEGED ) 25.29 + { 25.30 + dom0_op_t op; 25.31 + op.cmd = DOM0_IOPL; 25.32 + op.u.iopl.domain = start_info.dom_id; 25.33 + op.u.iopl.iopl = next->io_pl; 25.34 + queue_multicall1(__HYPERVISOR_dom0_op, (unsigned long)&op); 25.35 + } 25.36 25.37 /* EXECUTE ALL TASK SWITCH XEN SYSCALLS AT THIS POINT. */ 25.38 execute_multicall_list();
26.1 --- a/xenolinux-2.4.21-sparse/arch/xeno/kernel/setup.c Mon Jul 07 09:51:04 2003 +0000 26.2 +++ b/xenolinux-2.4.21-sparse/arch/xeno/kernel/setup.c Mon Jul 07 10:07:49 2003 +0000 26.3 @@ -43,6 +43,7 @@ 26.4 #include <asm/mpspec.h> 26.5 #include <asm/mmu_context.h> 26.6 #include <asm/hypervisor.h> 26.7 +#include <asm/hypervisor-ifs/dom0_ops.h> 26.8 26.9 shared_info_t *HYPERVISOR_shared_info; 26.10 26.11 @@ -301,12 +302,16 @@ void __init setup_arch(char **cmdline_p) 26.12 26.13 paging_init(); 26.14 26.15 - current->thread.hypercall_pl = 1; 26.16 - if ( start_info.flags & SIF_PRIVILEGED ) { 26.17 + /* We are privileged guest os - should have IO privileges. */ 26.18 + if ( start_info.flags & SIF_PRIVILEGED ) 26.19 + { 26.20 + dom0_op_t op; 26.21 + op.cmd = DOM0_IOPL; 26.22 + op.u.iopl.domain = start_info.dom_id; 26.23 + op.u.iopl.iopl = 1; 26.24 + if( HYPERVISOR_dom0_op(&op) != 0 ) 26.25 + panic("Unable to obtain IOPL, despite being SIF_PRIVILEGED"); 26.26 current->thread.io_pl = 1; 26.27 - /* We are privileged guest os - should have IO privileges. */ 26.28 - if( HYPERVISOR_set_priv_levels(1, 1) ) 26.29 - panic("Unable to obtain IOPL, despite being SIF_PRIVILEGED"); 26.30 } 26.31 26.32 if(start_info.flags & SIF_CONSOLE)
27.1 --- a/xenolinux-2.4.21-sparse/arch/xeno/mm/get_unmapped_area.c Mon Jul 07 09:51:04 2003 +0000 27.2 +++ b/xenolinux-2.4.21-sparse/arch/xeno/mm/get_unmapped_area.c Mon Jul 07 10:07:49 2003 +0000 27.3 @@ -14,60 +14,11 @@ 27.4 #include <asm/uaccess.h> 27.5 #include <asm/pgalloc.h> 27.6 27.7 -/* 27.8 -static int direct_mapped(unsigned long addr) 27.9 +struct list_head *find_direct(struct list_head *list, unsigned long addr) 27.10 { 27.11 - direct_mmap_node_t * node; 27.12 struct list_head * curr; 27.13 struct list_head * direct_list = ¤t->mm->context.direct_list; 27.14 - 27.15 - curr = direct_list->next; 27.16 - while(curr != direct_list){ 27.17 - node = list_entry(curr, direct_mmap_node_t, list); 27.18 - if(node->addr == addr) 27.19 - break; 27.20 - curr = curr->next; 27.21 - } 27.22 - 27.23 - if(curr == direct_list) 27.24 - return 0; 27.25 - 27.26 - return 1; 27.27 -} 27.28 -*/ 27.29 -/* 27.30 -unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags) 27.31 -{ 27.32 - struct vm_area_struct *vma; 27.33 - 27.34 - if (len > TASK_SIZE) 27.35 - return -ENOMEM; 27.36 - 27.37 - if (addr) { 27.38 - addr = PAGE_ALIGN(addr); 27.39 - vma = find_vma(current->mm, addr); 27.40 - if (TASK_SIZE - len >= addr && 27.41 - (!vma || addr + len <= vma->vm_start)) 27.42 - return addr; 27.43 - } 27.44 - addr = PAGE_ALIGN(TASK_UNMAPPED_BASE); 27.45 - 27.46 - for (vma = find_vma(current->mm, addr); ; vma = vma->vm_next) { 27.47 - if (TASK_SIZE - len < addr) 27.48 - return -ENOMEM; 27.49 - 27.50 - if ((!vma || addr + len <= vma->vm_start) && !direct_mapped(addr)) 27.51 - return addr; 27.52 - 27.53 - addr = vma->vm_end; 27.54 - } 27.55 -} 27.56 -*/ 27.57 -struct list_head *find_direct(struct list_head *list, unsigned long addr) 27.58 -{ 27.59 - struct list_head * curr; 27.60 - struct list_head * direct_list = ¤t->mm->context.direct_list; 27.61 - direct_mmap_node_t * node; 27.62 + direct_mmap_node_t * node; 27.63 27.64 for ( curr = direct_list->next; curr != direct_list; curr = curr->next ) 27.65 { 27.66 @@ -78,15 +29,18 @@ struct list_head *find_direct(struct lis 27.67 return curr; 27.68 } 27.69 27.70 -unsigned long arch_get_unmapped_area(struct file *filp, unsigned long 27.71 -addr, unsigned long len, unsigned long pgoff, unsigned long flags) 27.72 +unsigned long arch_get_unmapped_area(struct file *filp, 27.73 + unsigned long addr, 27.74 + unsigned long len, 27.75 + unsigned long pgoff, 27.76 + unsigned long flags) 27.77 { 27.78 struct vm_area_struct *vma; 27.79 direct_mmap_node_t * node; 27.80 struct list_head * curr; 27.81 struct list_head * direct_list = ¤t->mm->context.direct_list; 27.82 27.83 - if (len > TASK_SIZE) 27.84 + if ( len > TASK_SIZE ) 27.85 return -ENOMEM; 27.86 27.87 if ( addr ) 27.88 @@ -113,7 +67,8 @@ addr, unsigned long len, unsigned long p 27.89 { 27.90 if ( TASK_SIZE - len < addr ) return -ENOMEM; 27.91 27.92 - if ( vma && ((curr == direct_list) || (vma->vm_start < node->vm_start))) 27.93 + if ( vma && ((curr == direct_list) || 27.94 + (vma->vm_start < node->vm_start)) ) 27.95 { 27.96 /* Do we fit before VMA node? */ 27.97 if ( addr + len <= vma->vm_start ) return addr;
28.1 --- a/xenolinux-2.4.21-sparse/include/asm-xeno/hypervisor.h Mon Jul 07 09:51:04 2003 +0000 28.2 +++ b/xenolinux-2.4.21-sparse/include/asm-xeno/hypervisor.h Mon Jul 07 10:07:49 2003 +0000 28.3 @@ -364,16 +364,4 @@ static inline long HYPERVISOR_kbd_op(uns 28.4 return ret; 28.5 } 28.6 28.7 -static inline long HYPERVISOR_set_priv_levels(unsigned int new_io_pl, 28.8 - unsigned int new_hypercall_pl) 28.9 -{ 28.10 - int ret; 28.11 - __asm__ __volatile__ ( 28.12 - TRAP_INSTR 28.13 - : "=a" (ret) : "0" (__HYPERVISOR_set_priv_levels), 28.14 - "b" (new_io_pl), "c" (new_hypercall_pl) ); 28.15 - 28.16 - return ret; 28.17 -} 28.18 - 28.19 #endif /* __HYPERVISOR_H__ */
29.1 --- a/xenolinux-2.4.21-sparse/include/asm-xeno/processor.h Mon Jul 07 09:51:04 2003 +0000 29.2 +++ b/xenolinux-2.4.21-sparse/include/asm-xeno/processor.h Mon Jul 07 10:07:49 2003 +0000 29.3 @@ -358,7 +358,7 @@ struct thread_struct { 29.4 unsigned long esp; 29.5 unsigned long fs; 29.6 unsigned long gs; 29.7 - unsigned int io_pl, hypercall_pl; 29.8 + unsigned int io_pl; 29.9 /* Hardware debugging registers */ 29.10 unsigned long debugreg[8]; /* %%db0-7 debug registers */ 29.11 /* fault info */