xen-hvm.c (98a99ce0840991ed28fd4c570ae549c371e89970) xen-hvm.c (697b66d006676620a56fb5b79720ce457158204b)
1/*
2 * Copyright (C) 2010 Citrix Ltd.
3 *
4 * This work is licensed under the terms of the GNU GPL, version 2. See
5 * the COPYING file in the top-level directory.
6 *
7 * Contributions after 2012-01-13 are licensed under the terms of the
8 * GNU GPL, version 2 or (at your option) any later version.

--- 290 unchanged lines hidden (view full) ---

299 if (range_covers_byte(physmap->phys_offset, physmap->size, addr)) {
300 return physmap->start_addr;
301 }
302 }
303
304 return start_addr;
305}
306
1/*
2 * Copyright (C) 2010 Citrix Ltd.
3 *
4 * This work is licensed under the terms of the GNU GPL, version 2. See
5 * the COPYING file in the top-level directory.
6 *
7 * Contributions after 2012-01-13 are licensed under the terms of the
8 * GNU GPL, version 2 or (at your option) any later version.

--- 290 unchanged lines hidden (view full) ---

299 if (range_covers_byte(physmap->phys_offset, physmap->size, addr)) {
300 return physmap->start_addr;
301 }
302 }
303
304 return start_addr;
305}
306
307static int xen_save_physmap(XenIOState *state, XenPhysmap *physmap)
308{
309 char path[80], value[17];
310
311 snprintf(path, sizeof(path),
312 "/local/domain/0/device-model/%d/physmap/%"PRIx64"/start_addr",
313 xen_domid, (uint64_t)physmap->phys_offset);
314 snprintf(value, sizeof(value), "%"PRIx64, (uint64_t)physmap->start_addr);
315 if (!xs_write(state->xenstore, 0, path, value, strlen(value))) {
316 return -1;
317 }
318 snprintf(path, sizeof(path),
319 "/local/domain/0/device-model/%d/physmap/%"PRIx64"/size",
320 xen_domid, (uint64_t)physmap->phys_offset);
321 snprintf(value, sizeof(value), "%"PRIx64, (uint64_t)physmap->size);
322 if (!xs_write(state->xenstore, 0, path, value, strlen(value))) {
323 return -1;
324 }
325 if (physmap->name) {
326 snprintf(path, sizeof(path),
327 "/local/domain/0/device-model/%d/physmap/%"PRIx64"/name",
328 xen_domid, (uint64_t)physmap->phys_offset);
329 if (!xs_write(state->xenstore, 0, path,
330 physmap->name, strlen(physmap->name))) {
331 return -1;
332 }
333 }
334 return 0;
335}
336
307static int xen_add_to_physmap(XenIOState *state,
308 hwaddr start_addr,
309 ram_addr_t size,
310 MemoryRegion *mr,
311 hwaddr offset_within_region)
312{
313 unsigned long i = 0;
314 int rc = 0;
315 XenPhysmap *physmap = NULL;
316 hwaddr pfn, start_gpfn;
317 hwaddr phys_offset = memory_region_get_ram_addr(mr);
337static int xen_add_to_physmap(XenIOState *state,
338 hwaddr start_addr,
339 ram_addr_t size,
340 MemoryRegion *mr,
341 hwaddr offset_within_region)
342{
343 unsigned long i = 0;
344 int rc = 0;
345 XenPhysmap *physmap = NULL;
346 hwaddr pfn, start_gpfn;
347 hwaddr phys_offset = memory_region_get_ram_addr(mr);
318 char path[80], value[17];
319 const char *mr_name;
320
321 if (get_physmapping(state, start_addr, size)) {
322 return 0;
323 }
324 if (size <= 0) {
325 return -1;
326 }

--- 35 unchanged lines hidden (view full) ---

362 physmap->phys_offset = phys_offset;
363
364 QLIST_INSERT_HEAD(&state->physmap, physmap, list);
365
366 xc_domain_pin_memory_cacheattr(xen_xc, xen_domid,
367 start_addr >> TARGET_PAGE_BITS,
368 (start_addr + size - 1) >> TARGET_PAGE_BITS,
369 XEN_DOMCTL_MEM_CACHEATTR_WB);
348 const char *mr_name;
349
350 if (get_physmapping(state, start_addr, size)) {
351 return 0;
352 }
353 if (size <= 0) {
354 return -1;
355 }

--- 35 unchanged lines hidden (view full) ---

391 physmap->phys_offset = phys_offset;
392
393 QLIST_INSERT_HEAD(&state->physmap, physmap, list);
394
395 xc_domain_pin_memory_cacheattr(xen_xc, xen_domid,
396 start_addr >> TARGET_PAGE_BITS,
397 (start_addr + size - 1) >> TARGET_PAGE_BITS,
398 XEN_DOMCTL_MEM_CACHEATTR_WB);
370
371 snprintf(path, sizeof(path),
372 "/local/domain/0/device-model/%d/physmap/%"PRIx64"/start_addr",
373 xen_domid, (uint64_t)phys_offset);
374 snprintf(value, sizeof(value), "%"PRIx64, (uint64_t)start_addr);
375 if (!xs_write(state->xenstore, 0, path, value, strlen(value))) {
376 return -1;
377 }
378 snprintf(path, sizeof(path),
379 "/local/domain/0/device-model/%d/physmap/%"PRIx64"/size",
380 xen_domid, (uint64_t)phys_offset);
381 snprintf(value, sizeof(value), "%"PRIx64, (uint64_t)size);
382 if (!xs_write(state->xenstore, 0, path, value, strlen(value))) {
383 return -1;
384 }
385 if (mr_name) {
386 snprintf(path, sizeof(path),
387 "/local/domain/0/device-model/%d/physmap/%"PRIx64"/name",
388 xen_domid, (uint64_t)phys_offset);
389 if (!xs_write(state->xenstore, 0, path, mr_name, strlen(mr_name))) {
390 return -1;
391 }
392 }
393
394 return 0;
399 return xen_save_physmap(state, physmap);
395}
396
397static int xen_remove_from_physmap(XenIOState *state,
398 hwaddr start_addr,
399 ram_addr_t size)
400{
401 unsigned long i = 0;
402 int rc = 0;

--- 1028 unchanged lines hidden ---
400}
401
402static int xen_remove_from_physmap(XenIOState *state,
403 hwaddr start_addr,
404 ram_addr_t size)
405{
406 unsigned long i = 0;
407 int rc = 0;

--- 1028 unchanged lines hidden ---