Skip to content

Commit

Permalink
Respect size of io bitmap in vcpu_cell_init()
Browse files Browse the repository at this point in the history
Previous code copied the IO bitmap without respect to its actual size.
This patch simplifies the copying process and respects the size of the
destination.

Signed-off-by: Ralf Ramsauer <ralf@ramses-pyramidenbau.de>
[Jan: fine-tuned comments]
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
  • Loading branch information
rralf authored and jan-kiszka committed Nov 4, 2015
1 parent dc2ea31 commit 592b2b3
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions hypervisor/arch/x86/vcpu.c
Expand Up @@ -74,15 +74,14 @@ int vcpu_cell_init(struct cell *cell)
return err;

vcpu_vendor_get_cell_io_bitmap(cell, &cell_iobm);

/* initialize io bitmap to trap all accesses */
memset(cell_iobm.data, -1, cell_iobm.size);

for (n = 0; n < 2; n++) {
size = pio_bitmap_size <= PAGE_SIZE ?
pio_bitmap_size : PAGE_SIZE;
memcpy(cell_iobm.data + n * PAGE_SIZE, pio_bitmap, size);
pio_bitmap += size;
pio_bitmap_size -= size;
}
/* copy io bitmap from cell config */
size = pio_bitmap_size > cell_iobm.size ?
cell_iobm.size : pio_bitmap_size;
memcpy(cell_iobm.data, pio_bitmap, size);

/* moderate access to i8042 command register */
cell_iobm.data[I8042_CMD_REG / 8] |= 1 << (I8042_CMD_REG % 8);
Expand All @@ -94,7 +93,6 @@ int vcpu_cell_init(struct cell *cell)
*/
vcpu_vendor_get_cell_io_bitmap(&root_cell, &root_cell_iobm);
pio_bitmap = jailhouse_cell_pio_bitmap(cell->config);
pio_bitmap_size = cell->config->pio_bitmap_size;
for (b = root_cell_iobm.data; pio_bitmap_size > 0;
b++, pio_bitmap++, pio_bitmap_size--)
*b |= ~*pio_bitmap;
Expand Down

0 comments on commit 592b2b3

Please sign in to comment.