2 * This file is part of the Palacios Virtual Machine Monitor developed
3 * by the V3VEE Project with funding from the United States National
4 * Science Foundation and the Department of Energy.
6 * The V3VEE Project is a joint project between Northwestern University
7 * and the University of New Mexico. You can find out more at
10 * Copyright (c) 2008, Jack Lange <jarusl@cs.northwestern.edu>
11 * Copyright (c) 2008, The V3VEE Project <http://www.v3vee.org>
12 * All rights reserved.
14 * Author: Jack Lange <jarusl@cs.northwestern.edu>
16 * This is free software. You are permitted to use,
17 * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
19 #include <palacios/vmm.h>
22 #include <palacios/vmm_sym_swap.h>
24 // this is hardcoded in linux, but we should expose it via a sym interface
25 #define SWAP_DEV_SHIFT 5
27 int v3_init_sym_swap(struct guest_info * info) {
29 memset(&(info->swap_state), 0, sizeof(struct v3_sym_swap_state));
35 int v3_register_swap_disk(struct guest_info * info, int dev_index,
36 struct v3_swap_ops * ops, void * private_data) {
37 struct v3_sym_swap_state * swap_state = &(info->swap_state);
39 swap_state->devs[dev_index].present = 1;
40 swap_state->devs[dev_index].private_data = private_data;
41 swap_state->devs[dev_index].ops = ops;
47 addr_t v3_get_swapped_pg_addr(struct guest_info * info, pte32_t * pte) {
48 struct v3_sym_swap_state * swap_state = &(info->swap_state);
49 uint32_t dev_index = *(uint32_t *)pte & ((1 << SWAP_DEV_SHIFT) - 1);
50 uint32_t pg_index = (*(uint32_t *)pte) >> SWAP_DEV_SHIFT;
51 struct v3_swap_dev * swp_dev = &(swap_state->devs[dev_index]);
53 return (addr_t)swp_dev->ops->get_swap_entry(pg_index, swp_dev->private_data);
58 int v3_swap_out_notify(struct guest_info * info, int pg_index, int dev_index) {