aboutsummaryrefslogtreecommitdiffstats
path: root/xen/arch/x86/hvm/nestedhvm.c
diff options
context:
space:
mode:
authorKeir Fraser <keir@xen.org>2011-05-31 13:52:42 +0100
committerKeir Fraser <keir@xen.org>2011-05-31 13:52:42 +0100
commitaef3e0b8f1c2a68676b72d3f68c2755e67dfc74d (patch)
treeae5e94d4bc0aaa15cf66611bab418b4997114197 /xen/arch/x86/hvm/nestedhvm.c
parent9405f63305fcda58fde390c38fb53db3a44963b0 (diff)
downloadxen-aef3e0b8f1c2a68676b72d3f68c2755e67dfc74d.tar.gz
xen-aef3e0b8f1c2a68676b72d3f68c2755e67dfc74d.tar.bz2
xen-aef3e0b8f1c2a68676b72d3f68c2755e67dfc74d.zip
nestedhvm: Fix wrong memory size of nested shadow_io_bitmap
Signed-off-by: Eddie Dong <eddie.dong@intel.com> While there, simplify and tidy the code. Signed-off-by: Keir Fraser <keir@xen.org>
Diffstat (limited to 'xen/arch/x86/hvm/nestedhvm.c')
-rw-r--r--xen/arch/x86/hvm/nestedhvm.c31
1 files changed, 9 insertions, 22 deletions
diff --git a/xen/arch/x86/hvm/nestedhvm.c b/xen/arch/x86/hvm/nestedhvm.c
index f77b84c286..67202c05bf 100644
--- a/xen/arch/x86/hvm/nestedhvm.c
+++ b/xen/arch/x86/hvm/nestedhvm.c
@@ -153,16 +153,16 @@ nestedhvm_is_n2(struct vcpu *v)
* iomap[2] set set
*/
-/* same format and size as hvm_io_bitmap */
-#define IOBITMAP_SIZE 3*PAGE_SIZE/BYTES_PER_LONG
-/* same format as hvm_io_bitmap */
-#define IOBITMAP_VMX_SIZE 2*PAGE_SIZE/BYTES_PER_LONG
-
static unsigned long *shadow_io_bitmap[3];
void
nestedhvm_setup(void)
{
+ /* Same format and size as hvm_io_bitmap (Intel needs only 2 pages). */
+ unsigned int sz = (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL)
+ ? 2*PAGE_SIZE : 3*PAGE_SIZE;
+ unsigned int i;
+
/* shadow_io_bitmaps can't be declared static because
* they must fulfill hw requirements (page aligned section)
* and doing so triggers the ASSERT(va >= XEN_VIRT_START)
@@ -173,23 +173,10 @@ nestedhvm_setup(void)
* it is valid to use _xmalloc()
*/
- /* shadow I/O permission bitmaps */
- if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL) {
- /* Same format as hvm_io_bitmap */
- shadow_io_bitmap[0] = _xmalloc(IOBITMAP_VMX_SIZE, PAGE_SIZE);
- shadow_io_bitmap[1] = _xmalloc(IOBITMAP_VMX_SIZE, PAGE_SIZE);
- shadow_io_bitmap[2] = _xmalloc(IOBITMAP_VMX_SIZE, PAGE_SIZE);
- memset(shadow_io_bitmap[0], ~0U, IOBITMAP_VMX_SIZE);
- memset(shadow_io_bitmap[1], ~0U, IOBITMAP_VMX_SIZE);
- memset(shadow_io_bitmap[2], ~0U, IOBITMAP_VMX_SIZE);
- } else {
- /* Same size and format as hvm_io_bitmap */
- shadow_io_bitmap[0] = _xmalloc(IOBITMAP_SIZE, PAGE_SIZE);
- shadow_io_bitmap[1] = _xmalloc(IOBITMAP_SIZE, PAGE_SIZE);
- shadow_io_bitmap[2] = _xmalloc(IOBITMAP_SIZE, PAGE_SIZE);
- memset(shadow_io_bitmap[0], ~0U, IOBITMAP_SIZE);
- memset(shadow_io_bitmap[1], ~0U, IOBITMAP_SIZE);
- memset(shadow_io_bitmap[2], ~0U, IOBITMAP_SIZE);
+ for ( i = 0; i < ARRAY_SIZE(shadow_io_bitmap); i++ )
+ {
+ shadow_io_bitmap[i] = _xmalloc(sz, PAGE_SIZE);
+ memset(shadow_io_bitmap[i], ~0U, sz);
}
__clear_bit(0x80, shadow_io_bitmap[0]);