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) 2011, Jack Lange <jarusl@cs.northwestern.edu>
11 * Copyright (c) 2011, 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".
20 #include <palacios/vmm_mtrr.h>
21 #include <palacios/vmm_extensions.h>
22 #include <palacios/vmm.h>
23 #include <palacios/vm_guest.h>
24 #include <palacios/vmm_msr.h>
27 #define MTRR_CAP_MSR 0x00fe
28 #define MTRR_PHYS_BASE_0 0x0200
29 #define MTRR_PHYS_BASE_1 0x0202
30 #define MTRR_PHYS_BASE_2 0x0204
31 #define MTRR_PHYS_BASE_3 0x0206
32 #define MTRR_PHYS_BASE_4 0x0208
33 #define MTRR_PHYS_BASE_5 0x020a
34 #define MTRR_PHYS_BASE_6 0x020c
35 #define MTRR_PHYS_BASE_7 0x020e
36 #define MTRR_PHYS_MASK_0 0x0201
37 #define MTRR_PHYS_MASK_1 0x0203
38 #define MTRR_PHYS_MASK_2 0x0205
39 #define MTRR_PHYS_MASK_3 0x0207
40 #define MTRR_PHYS_MASK_4 0x0209
41 #define MTRR_PHYS_MASK_5 0x020b
42 #define MTRR_PHYS_MASK_6 0x020d
43 #define MTRR_PHYS_MASK_7 0x020f
44 #define MTRR_FIX_64K_00000 0x0250
45 #define MTRR_FIX_16K_80000 0x0258
46 #define MTRR_FIX_16K_A0000 0x0259
47 #define MTRR_FIX_4K_C0000 0x0268
48 #define MTRR_FIX_4K_C8000 0x0269
49 #define MTRR_FIX_4K_D0000 0x026a
50 #define MTRR_FIX_4K_D8000 0x026b
51 #define MTRR_FIX_4K_E0000 0x026c
52 #define MTRR_FIX_4K_E8000 0x026d
53 #define MTRR_FIX_4K_F0000 0x026e
54 #define MTRR_FIX_4K_F8000 0x026f
69 static int mtrr_cap_read(struct guest_info * core, uint32_t msr, struct v3_msr * dst, void * priv_data) {
73 static int mtrr_cap_write(struct guest_info * core, uint32_t msr, struct v3_msr src, void * priv_data) {
80 static int init_mtrrs(struct v3_vm_info * vm, v3_cfg_tree_t * cfg, void ** priv_data) {
83 V3_Print("Intializing MTRR extension\n");
85 v3_hook_msr(vm, MTRR_CAP_MSR, mtrr_cap_read, mtrr_cap_write, NULL);
92 static struct v3_extension_impl mtrr_ext = {
102 register_extension(&mtrr_ext);