qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2 2/2] target/m68k: consolidate physical translation offset


From: Mark Cave-Ayland
Subject: Re: [PATCH v2 2/2] target/m68k: consolidate physical translation offset into get_physical_address()
Date: Tue, 30 Jun 2020 12:13:01 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0

On 30/06/2020 08:23, Laurent Vivier wrote:

> Le 30/06/2020 à 08:10, Mark Cave-Ayland a écrit :
>> Since all callers to get_physical_address() now apply the same page offset to
>> the translation result, move the logic into get_physical_address() itself to
>> avoid duplication.
>>
>> Suggested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
>> ---
>>  target/m68k/helper.c | 12 +++---------
>>  1 file changed, 3 insertions(+), 9 deletions(-)
>>
>> diff --git a/target/m68k/helper.c b/target/m68k/helper.c
>> index 631eab7774..ddd8a2667e 100644
>> --- a/target/m68k/helper.c
>> +++ b/target/m68k/helper.c
>> @@ -771,7 +771,8 @@ static int get_physical_address(CPUM68KState *env, 
>> hwaddr *physical,
>>      }
>>      *page_size = 1 << page_bits;
>>      page_mask = ~(*page_size - 1);
>> -    *physical = next & page_mask;
>> +    address &= TARGET_PAGE_MASK;
>> +    *physical = (next & page_mask) + (address & (*page_size - 1));
> 
> You didn't update the Transparent Translation Register part.

Ooops yes - looks like TARGET_PAGE_MASK needs to be removed from the TTR part.

>>      if (access_type & ACCESS_PTEST) {
>>          env->mmu.mmusr |= next & M68K_MMU_SR_MASK_040;
>> @@ -826,8 +827,6 @@ hwaddr m68k_cpu_get_phys_page_debug(CPUState *cs, vaddr 
>> addr)
>>          return -1;
>>      }
>>  
>> -    addr &= TARGET_PAGE_MASK;
>> -    phys_addr += addr & (page_size - 1);
>>      return phys_addr;
>>  }
>>  
>> @@ -891,10 +890,7 @@ bool m68k_cpu_tlb_fill(CPUState *cs, vaddr address, int 
>> size,
>>      ret = get_physical_address(&cpu->env, &physical, &prot,
>>                                 address, access_type, &page_size);
>>      if (likely(ret == 0)) {
>> -        address &= TARGET_PAGE_MASK;
>> -        physical += address & (page_size - 1);
>> -        tlb_set_page(cs, address, physical,
>> -                     prot, mmu_idx, TARGET_PAGE_SIZE);
>> +        tlb_set_page(cs, address, physical, prot, mmu_idx, page_size);
> 
> but now we use "address" which is not the exact virtual address but the
> virtual address of the page. According to the name, tlb_set_page(), and
> the other users in QEMU, it should be:
> 
> 
>  tlb_set_page(cs, address & TARGET_PAGE_MASK,
>                   physical & TARGET_PAGE_MASK, prot, mmu_idx,
>                   page_size);

The tlb_set_page() contract seems a bit confusing, since 
tlb_set_page_with_attrs()
applies TARGET_PAGE_MASK regardless, but I agree that it's clearer this way.

I also spotted that this needs to be done for the tlb_set_page() call in the 
ptest
helper, so I'll go ahead and make these changes. Assuming all looks good I will 
send
along v3 shortly.


ATB,

Mark.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]