ia64/xen-unstable
changeset 11626:7de1715d185e
[VMXASSIST] Fix virt-to-phys translation routine.
Signed-off-by: Keir Fraser <keir@xensource.com>
Signed-off-by: Keir Fraser <keir@xensource.com>
author | kfraser@localhost.localdomain |
---|---|
date | Mon Sep 25 18:19:30 2006 +0100 (2006-09-25) |
parents | 0f9908c2c5c7 |
children | b042bf974f3a |
files | tools/firmware/vmxassist/vm86.c |
line diff
1.1 --- a/tools/firmware/vmxassist/vm86.c Mon Sep 25 17:46:08 2006 +0100 1.2 +++ b/tools/firmware/vmxassist/vm86.c Mon Sep 25 18:19:30 2006 +0100 1.3 @@ -69,28 +69,23 @@ guest_linear_to_real(uint32_t base) 1.4 1.5 if (!(oldctx.cr4 & CR4_PAE)) { 1.6 l1_mfn = ((uint32_t *)gcr3)[(base >> 22) & 0x3ff]; 1.7 + if (!(l1_mfn & PT_ENTRY_PRESENT)) 1.8 + panic("l2 entry not present\n"); 1.9 1.10 - if (oldctx.cr4 & CR4_PSE || l1_mfn & PDE_PS) { 1.11 - /* 1 level page table */ 1.12 - l0_mfn = l1_mfn; 1.13 - if (!(l0_mfn & PT_ENTRY_PRESENT)) 1.14 - panic("l1 entry not present\n"); 1.15 - 1.16 - l0_mfn &= 0xffc00000; 1.17 + if ((oldctx.cr4 & CR4_PSE) && (l1_mfn & PDE_PS)) { 1.18 + l0_mfn = l1_mfn & 0xffc00000; 1.19 return l0_mfn + (base & 0x3fffff); 1.20 } 1.21 1.22 - if (!(l1_mfn & PT_ENTRY_PRESENT)) 1.23 - panic("l2 entry not present\n"); 1.24 + l1_mfn &= 0xfffff000; 1.25 1.26 - l1_mfn &= 0xfffff000; 1.27 l0_mfn = ((uint32_t *)l1_mfn)[(base >> 12) & 0x3ff]; 1.28 if (!(l0_mfn & PT_ENTRY_PRESENT)) 1.29 panic("l1 entry not present\n"); 1.30 l0_mfn &= 0xfffff000; 1.31 1.32 return l0_mfn + (base & 0xfff); 1.33 - } else if (oldctx.cr4 & CR4_PAE && !(oldctx.cr4 & CR4_PSE)) { 1.34 + } else { 1.35 l2_mfn = ((uint64_t *)gcr3)[(base >> 30) & 0x3]; 1.36 if (!(l2_mfn & PT_ENTRY_PRESENT)) 1.37 panic("l3 entry not present\n"); 1.38 @@ -99,6 +94,12 @@ guest_linear_to_real(uint32_t base) 1.39 l1_mfn = ((uint64_t *)l2_mfn)[(base >> 21) & 0x1ff]; 1.40 if (!(l1_mfn & PT_ENTRY_PRESENT)) 1.41 panic("l2 entry not present\n"); 1.42 + 1.43 + if ((oldctx.cr4 & CR4_PSE) && (l1_mfn & PDE_PS)) { 1.44 + l0_mfn = l1_mfn & 0x3ffe00000ULL; 1.45 + return l0_mfn + (base & 0x1fffff); 1.46 + } 1.47 + 1.48 l1_mfn &= 0x3fffff000ULL; 1.49 1.50 l0_mfn = ((uint64_t *)l1_mfn)[(base >> 12) & 0x1ff]; 1.51 @@ -107,18 +108,6 @@ guest_linear_to_real(uint32_t base) 1.52 l0_mfn &= 0x3fffff000ULL; 1.53 1.54 return l0_mfn + (base & 0xfff); 1.55 - } else { /* oldctx.cr4 & CR4_PAE && oldctx.cr4 & CR4_PSE */ 1.56 - l1_mfn = ((uint64_t *)gcr3)[(base >> 30) & 0x3]; 1.57 - if (!(l1_mfn & PT_ENTRY_PRESENT)) 1.58 - panic("l2 entry not present\n"); 1.59 - l1_mfn &= 0x3fffff000ULL; 1.60 - 1.61 - l0_mfn = ((uint64_t *)l1_mfn)[(base >> 21) & 0x1ff]; 1.62 - if (!(l0_mfn & PT_ENTRY_PRESENT)) 1.63 - panic("l1 entry not present\n"); 1.64 - l0_mfn &= 0x3ffe00000ULL; 1.65 - 1.66 - return l0_mfn + (base & 0x1fffff); 1.67 } 1.68 } 1.69