aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86
diff options
context:
space:
mode:
authorXudong Hao <xudong.hao@intel.com>2012-05-21 23:23:15 -0400
committerAvi Kivity <avi@redhat.com>2012-06-05 09:31:05 -0400
commit3f6d8c8a478dd1ab2a4944b0d65474df06ecd882 (patch)
tree87eb511e0ec229ee179fc054b1eba10768cfcab2 /arch/x86
parentb38f99347871d7fc49e6367395dce0d757f6ab8d (diff)
KVM: VMX: Use EPT Access bit in response to memory notifiers
Signed-off-by: Haitao Shan <haitao.shan@intel.com> Signed-off-by: Xudong Hao <xudong.hao@intel.com> Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/x86')
-rw-r--r--arch/x86/kvm/mmu.c14
-rw-r--r--arch/x86/kvm/vmx.c6
2 files changed, 12 insertions, 8 deletions
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index be3cea4407ff..d07e436b7a42 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -1242,7 +1242,8 @@ static int kvm_age_rmapp(struct kvm *kvm, unsigned long *rmapp,
1242 int young = 0; 1242 int young = 0;
1243 1243
1244 /* 1244 /*
1245 * Emulate the accessed bit for EPT, by checking if this page has 1245 * In case of absence of EPT Access and Dirty Bits supports,
1246 * emulate the accessed bit for EPT, by checking if this page has
1246 * an EPT mapping, and clearing it if it does. On the next access, 1247 * an EPT mapping, and clearing it if it does. On the next access,
1247 * a new EPT mapping will be established. 1248 * a new EPT mapping will be established.
1248 * This has some overhead, but not as much as the cost of swapping 1249 * This has some overhead, but not as much as the cost of swapping
@@ -1253,11 +1254,12 @@ static int kvm_age_rmapp(struct kvm *kvm, unsigned long *rmapp,
1253 1254
1254 for (sptep = rmap_get_first(*rmapp, &iter); sptep; 1255 for (sptep = rmap_get_first(*rmapp, &iter); sptep;
1255 sptep = rmap_get_next(&iter)) { 1256 sptep = rmap_get_next(&iter)) {
1256 BUG_ON(!(*sptep & PT_PRESENT_MASK)); 1257 BUG_ON(!is_shadow_present_pte(*sptep));
1257 1258
1258 if (*sptep & PT_ACCESSED_MASK) { 1259 if (*sptep & shadow_accessed_mask) {
1259 young = 1; 1260 young = 1;
1260 clear_bit(PT_ACCESSED_SHIFT, (unsigned long *)sptep); 1261 clear_bit((ffs(shadow_accessed_mask) - 1),
1262 (unsigned long *)sptep);
1261 } 1263 }
1262 } 1264 }
1263 1265
@@ -1281,9 +1283,9 @@ static int kvm_test_age_rmapp(struct kvm *kvm, unsigned long *rmapp,
1281 1283
1282 for (sptep = rmap_get_first(*rmapp, &iter); sptep; 1284 for (sptep = rmap_get_first(*rmapp, &iter); sptep;
1283 sptep = rmap_get_next(&iter)) { 1285 sptep = rmap_get_next(&iter)) {
1284 BUG_ON(!(*sptep & PT_PRESENT_MASK)); 1286 BUG_ON(!is_shadow_present_pte(*sptep));
1285 1287
1286 if (*sptep & PT_ACCESSED_MASK) { 1288 if (*sptep & shadow_accessed_mask) {
1287 young = 1; 1289 young = 1;
1288 break; 1290 break;
1289 } 1291 }
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index d392e5427ca0..396148ab089b 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -7289,8 +7289,10 @@ static int __init vmx_init(void)
7289 vmx_disable_intercept_for_msr(MSR_IA32_SYSENTER_EIP, false); 7289 vmx_disable_intercept_for_msr(MSR_IA32_SYSENTER_EIP, false);
7290 7290
7291 if (enable_ept) { 7291 if (enable_ept) {
7292 kvm_mmu_set_mask_ptes(0ull, 0ull, 0ull, 0ull, 7292 kvm_mmu_set_mask_ptes(0ull,
7293 VMX_EPT_EXECUTABLE_MASK); 7293 (enable_ept_ad_bits) ? VMX_EPT_ACCESS_BIT : 0ull,
7294 (enable_ept_ad_bits) ? VMX_EPT_DIRTY_BIT : 0ull,
7295 0ull, VMX_EPT_EXECUTABLE_MASK);
7294 ept_set_mmio_spte_mask(); 7296 ept_set_mmio_spte_mask();
7295 kvm_enable_tdp(); 7297 kvm_enable_tdp();
7296 } else 7298 } else