kvmvapic: align start address as well as size
PATCH 1/1 kvmvapic: align start address as well as size
The kvmvapic code remaps a section of ROM as RAM to allow the guest to maintain state there. It is careful to align the section size to a page boundary, to avoid creating subpages, but neglects to do the same for the start address. These leads to an assert later on when the memory core tries to create a page which is half RAM and half ROM.
Fix by aligning the start address to a page boundary.
This can be triggered by running qemu-system-x86_64 -enable-kvm -vga none.
--- hw/kvmvapic.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
hw/kvmvapic.c +3 -1
@@ -578,8 +578,10 @@ static void vapic_map_rom_writable(VAPICROMState *s) rom_size = ram[rom_paddr +2 ] *ROM_BLOCK_SIZE ; s->rom_size = rom_size; -/* We need to round up to avoid creating subpages +/* We need to round to avoid creating subpages * from which we cannot run code. */ + rom_size += rom_paddr & ~TARGET_PAGE_MASK ; + rom_paddr &=TARGET_PAGE_MASK ; rom_size =TARGET_PAGE_ALIGN (rom_size); memory_region_init_alias(&s->rom, "kvmvapic-rom", section.mr, rom_paddr,
Signature · 1 line
1.7.9
Quoted 21 lines · Avi Kivity
The kvmvapic code remaps a section of ROM as RAM to allow the guest to maintain state there. It is careful to align the section size to a page boundary, to avoid creating subpages, but neglects to do the same for the start address. These leads to an assert later on when the memory core tries to create a page which is half RAM and half ROM.
Fix by aligning the start address to a page boundary.
This can be triggered by running qemu-system-x86_64 -enable-kvm -vga none.
Signed-off-by Avi Kivity <[email protected]>--- hw/kvmvapic.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)hw/kvmvapic.c +0
-0@@ -578,8 +578,10 @@ static void vapic_map_rom_writable(VAPICROMState *s) rom_size = ram[rom_paddr +2 ] *ROM_BLOCK_SIZE ;
hw/kvmvapic.c static void vapic_map_rom_writable(VAPICROMState *s) · line 587
Quoted 10 lines
hw/kvmvapic.c +3
-1s->rom_size = rom_size; -/* We need to round up to avoid creating subpages +/* We need to round to avoid creating subpages * from which we cannot run code. */ + rom_size += rom_paddr & ~TARGET_PAGE_MASK ; + rom_paddr &=TARGET_PAGE_MASK ; rom_size =TARGET_PAGE_ALIGN (rom_size); memory_region_init_alias(&s->rom, "kvmvapic-rom", section.mr, rom_paddr,
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Quoted 11 lines · Avi Kivity
The kvmvapic code remaps a section of ROM as RAM to allow the guest to maintain state there. It is careful to align the section size to a page boundary, to avoid creating subpages, but neglects to do the same for the start address. These leads to an assert later on when the memory core tries to create a page which is half RAM and half ROM.
Fix by aligning the start address to a page boundary.
This can be triggered by running qemu-system-x86_64 -enable-kvm -vga none.
Signed-off-by Avi Kivity<[email protected]>
Are you going to do a PULL request or do you want me to apply directly?
Regards,
Anthony Liguori
Quoted 20 lines
--- hw/kvmvapic.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)hw/kvmvapic.c +3
-1@@ -578,8 +578,10 @@ static void vapic_map_rom_writable(VAPICROMState *s) rom_size = ram[rom_paddr +2 ] *ROM_BLOCK_SIZE ; s->rom_size = rom_size; -/* We need to round up to avoid creating subpages +/* We need to round to avoid creating subpages * from which we cannot run code. */ + rom_size += rom_paddr& ~TARGET_PAGE_MASK ; + rom_paddr&=TARGET_PAGE_MASK ; rom_size =TARGET_PAGE_ALIGN (rom_size); memory_region_init_alias(&s->rom, "kvmvapic-rom", section.mr, rom_paddr,
Anthony Liguori
AppliedQuoted 11 lines · Avi Kivity
The kvmvapic code remaps a section of ROM as RAM to allow the guest to maintain state there. It is careful to align the section size to a page boundary, to avoid creating subpages, but neglects to do the same for the start address. These leads to an assert later on when the memory core tries to create a page which is half RAM and half ROM.
Fix by aligning the start address to a page boundary.
This can be triggered by running qemu-system-x86_64 -enable-kvm -vga none.
Signed-off-by Avi Kivity<[email protected]>
Applied. Thanks.
Regards,
Anthony Liguori
Quoted 20 lines
--- hw/kvmvapic.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)hw/kvmvapic.c +3
-1@@ -578,8 +578,10 @@ static void vapic_map_rom_writable(VAPICROMState *s) rom_size = ram[rom_paddr +2 ] *ROM_BLOCK_SIZE ; s->rom_size = rom_size; -/* We need to round up to avoid creating subpages +/* We need to round to avoid creating subpages * from which we cannot run code. */ + rom_size += rom_paddr& ~TARGET_PAGE_MASK ; + rom_paddr&=TARGET_PAGE_MASK ; rom_size =TARGET_PAGE_ALIGN (rom_size); memory_region_init_alias(&s->rom, "kvmvapic-rom", section.mr, rom_paddr,
Quoted 9 lines · Anthony Liguori
Quoted 8 lines · Avi Kivity
The kvmvapic code remaps a section of ROM as RAM to allow the guest to maintain state there. It is careful to align the section size to a page boundary, to avoid creating subpages, but neglects to do the same for the start address. These leads to an assert later on when the memory core tries to create a page which is half RAM and half ROM.
Fix by aligning the start address to a page boundary.
Quoted 8 lines
Quoted 4 lines
This can be triggered by running qemu-system-x86_64 -enable-kvm -vga none.
Signed-off-by Avi Kivity<[email protected]>Tested-by Anthony Liguori <[email protected]>Are you going to do a PULL request or do you want me to apply directly?
I forgot all about it, sorry.
Signature · 1 line
error compiling committee.c: too many arguments to function
Quoted 13 lines · Avi Kivity
Quoted 12 lines · Anthony Liguori
Quoted 11 lines · Avi Kivity
The kvmvapic code remaps a section of ROM as RAM to allow the guest to maintain state there. It is careful to align the section size to a page boundary, to avoid creating subpages, but neglects to do the same for the start address. These leads to an assert later on when the memory core tries to create a page which is half RAM and half ROM.
Fix by aligning the start address to a page boundary.
This can be triggered by running qemu-system-x86_64 -enable-kvm -vga none.
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Signed-off-by Avi Kivity<[email protected]>Tested-by Anthony Liguori<[email protected]>Are you going to do a PULL request or do you want me to apply directly?
I forgot all about it, sorry.
No worries. I actually caught the bug in the original pull request but do to a bug in qemu-test, when I tried to bisect, things got weird and I mistakenly thought the real problem had been introduced earlier.
Regards,
Anthony Liguori