diff options
author | Xiao Guangrong <xiaoguangrong@cn.fujitsu.com> | 2010-03-19 05:58:53 -0400 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2010-05-17 05:16:42 -0400 |
commit | f815bce8940bc28e42e6b924825bb31df2a4bff5 (patch) | |
tree | 1c3df0f34d93d6f84c82dba30211ddfb08c051b1 /arch/x86 | |
parent | 041b1359a29b9301bc8baed6efcdbad29f80f6af (diff) |
KVM: MMU: check reserved bits only if CR4.PSE=1 or CR4.PAE=1
- Check reserved bits only if CR4.PAE=1 or CR4.PSE=1 when guest #PF occurs
- Fix a typo in reset_rsvds_bits_mask()
Signed-off-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
Reviewed-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/x86')
-rw-r--r-- | arch/x86/kvm/mmu.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index 064c3efb49dc..83d2ebce9ea9 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c | |||
@@ -2297,13 +2297,19 @@ static void reset_rsvds_bits_mask(struct kvm_vcpu *vcpu, int level) | |||
2297 | /* no rsvd bits for 2 level 4K page table entries */ | 2297 | /* no rsvd bits for 2 level 4K page table entries */ |
2298 | context->rsvd_bits_mask[0][1] = 0; | 2298 | context->rsvd_bits_mask[0][1] = 0; |
2299 | context->rsvd_bits_mask[0][0] = 0; | 2299 | context->rsvd_bits_mask[0][0] = 0; |
2300 | context->rsvd_bits_mask[1][0] = context->rsvd_bits_mask[0][0]; | ||
2301 | |||
2302 | if (!is_pse(vcpu)) { | ||
2303 | context->rsvd_bits_mask[1][1] = 0; | ||
2304 | break; | ||
2305 | } | ||
2306 | |||
2300 | if (is_cpuid_PSE36()) | 2307 | if (is_cpuid_PSE36()) |
2301 | /* 36bits PSE 4MB page */ | 2308 | /* 36bits PSE 4MB page */ |
2302 | context->rsvd_bits_mask[1][1] = rsvd_bits(17, 21); | 2309 | context->rsvd_bits_mask[1][1] = rsvd_bits(17, 21); |
2303 | else | 2310 | else |
2304 | /* 32 bits PSE 4MB page */ | 2311 | /* 32 bits PSE 4MB page */ |
2305 | context->rsvd_bits_mask[1][1] = rsvd_bits(13, 21); | 2312 | context->rsvd_bits_mask[1][1] = rsvd_bits(13, 21); |
2306 | context->rsvd_bits_mask[1][0] = context->rsvd_bits_mask[1][0]; | ||
2307 | break; | 2313 | break; |
2308 | case PT32E_ROOT_LEVEL: | 2314 | case PT32E_ROOT_LEVEL: |
2309 | context->rsvd_bits_mask[0][2] = | 2315 | context->rsvd_bits_mask[0][2] = |
@@ -2316,7 +2322,7 @@ static void reset_rsvds_bits_mask(struct kvm_vcpu *vcpu, int level) | |||
2316 | context->rsvd_bits_mask[1][1] = exb_bit_rsvd | | 2322 | context->rsvd_bits_mask[1][1] = exb_bit_rsvd | |
2317 | rsvd_bits(maxphyaddr, 62) | | 2323 | rsvd_bits(maxphyaddr, 62) | |
2318 | rsvd_bits(13, 20); /* large page */ | 2324 | rsvd_bits(13, 20); /* large page */ |
2319 | context->rsvd_bits_mask[1][0] = context->rsvd_bits_mask[1][0]; | 2325 | context->rsvd_bits_mask[1][0] = context->rsvd_bits_mask[0][0]; |
2320 | break; | 2326 | break; |
2321 | case PT64_ROOT_LEVEL: | 2327 | case PT64_ROOT_LEVEL: |
2322 | context->rsvd_bits_mask[0][3] = exb_bit_rsvd | | 2328 | context->rsvd_bits_mask[0][3] = exb_bit_rsvd | |
@@ -2334,7 +2340,7 @@ static void reset_rsvds_bits_mask(struct kvm_vcpu *vcpu, int level) | |||
2334 | context->rsvd_bits_mask[1][1] = exb_bit_rsvd | | 2340 | context->rsvd_bits_mask[1][1] = exb_bit_rsvd | |
2335 | rsvd_bits(maxphyaddr, 51) | | 2341 | rsvd_bits(maxphyaddr, 51) | |
2336 | rsvd_bits(13, 20); /* large page */ | 2342 | rsvd_bits(13, 20); /* large page */ |
2337 | context->rsvd_bits_mask[1][0] = context->rsvd_bits_mask[1][0]; | 2343 | context->rsvd_bits_mask[1][0] = context->rsvd_bits_mask[0][0]; |
2338 | break; | 2344 | break; |
2339 | } | 2345 | } |
2340 | } | 2346 | } |