The ahci map_page() function checks whenever it got a full page mapped. This is wrong. The data structures are much smaller: command list is 1k and fis is 256 bytes. Checking whenever we can access that much bytes without crossing a page border is good enougth.
Signed-off-by: Gerd Hoffmann <kra...@redhat.com> --- hw/ahci.c | 14 +++++++------- 1 files changed, 7 insertions(+), 7 deletions(-) diff --git a/hw/ahci.c b/hw/ahci.c index 0ee021e..fdd5572 100644 --- a/hw/ahci.c +++ b/hw/ahci.c @@ -411,16 +411,16 @@ static void ahci_check_irq(AHCIState *s) } } -static void map_page(uint8_t **ptr, uint64_t addr) +static void map_page(uint8_t **ptr, uint64_t addr, uint32_t wanted) { - target_phys_addr_t len = 4096; + target_phys_addr_t len = wanted; if (*ptr) { cpu_physical_memory_unmap(*ptr, 1, len, len); } *ptr = cpu_physical_memory_map(addr, &len, 1); - if (len < 4096) { + if (len < wanted) { *ptr = NULL; } } @@ -435,22 +435,22 @@ static void ahci_port_write(AHCIState *s, int port, int offset, uint32_t val) case PORT_LST_ADDR: pr->lst_addr = val; map_page(&s->dev[port].lst, - ((uint64_t)pr->lst_addr_hi << 32) | pr->lst_addr); + ((uint64_t)pr->lst_addr_hi << 32) | pr->lst_addr, 1024); break; case PORT_LST_ADDR_HI: pr->lst_addr_hi = val; map_page(&s->dev[port].lst, - ((uint64_t)pr->lst_addr_hi << 32) | pr->lst_addr); + ((uint64_t)pr->lst_addr_hi << 32) | pr->lst_addr, 1024); break; case PORT_FIS_ADDR: pr->fis_addr = val; map_page(&s->dev[port].res_fis, - ((uint64_t)pr->fis_addr_hi << 32) | pr->fis_addr); + ((uint64_t)pr->fis_addr_hi << 32) | pr->fis_addr, 256); break; case PORT_FIS_ADDR_HI: pr->fis_addr_hi = val; map_page(&s->dev[port].res_fis, - ((uint64_t)pr->fis_addr_hi << 32) | pr->fis_addr); + ((uint64_t)pr->fis_addr_hi << 32) | pr->fis_addr, 256); break; case PORT_IRQ_STAT: pr->irq_stat &= ~val; -- 1.7.1