ahci: fix lst+fis mapping
PATCH 1/1 ahci: fix lst+fis mapping
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.
--- hw/ahci.c | 14 +++++++------- 1 files changed, 7 insertions(+), 7 deletions(-)
hw/ahci.c +7 -7
@@ -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;
Signature · 1 line
1.7.1
Quoted 4 lines · Gerd Hoffmann
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.
Looks good :). Do you want me to incorporate this with the next revision of my patch set or keep it separate?
Alex
Quoted 11 lines · Alexander Graf
Quoted 5 lines · Gerd Hoffmann
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.Looks good :). Do you want me to incorporate this with the next revision of my patch set or keep it separate?
Feel free to squash it in.
cheers,
Gerd