* [PATCH] target/m68k: fix physical address translation in m68k_cpu_get_phys_page_debug()
@ 2020-06-29 16:26 Mark Cave-Ayland
2020-06-29 17:56 ` Philippe Mathieu-Daudé
0 siblings, 1 reply; 3+ messages in thread
From: Mark Cave-Ayland @ 2020-06-29 16:26 UTC (permalink / raw)
To: qemu-devel, laurent
The result of the get_physical_address() function should be combined with the
offset of the original page access before being returned. Otherwise the
m68k_cpu_get_phys_page_debug() function can round to the wrong page causing
incorrect lookups in gdbstub and various "Disassembler disagrees with
translator over instruction decoding" warnings to appear at translation time.
Fixes: 88b2fef6c3 ("target/m68k: add MC68040 MMU")
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
target/m68k/helper.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/target/m68k/helper.c b/target/m68k/helper.c
index 79b0b10ea9..631eab7774 100644
--- a/target/m68k/helper.c
+++ b/target/m68k/helper.c
@@ -820,10 +820,14 @@ hwaddr m68k_cpu_get_phys_page_debug(CPUState *cs, vaddr addr)
if (env->sr & SR_S) {
access_type |= ACCESS_SUPER;
}
+
if (get_physical_address(env, &phys_addr, &prot,
addr, access_type, &page_size) != 0) {
return -1;
}
+
+ addr &= TARGET_PAGE_MASK;
+ phys_addr += addr & (page_size - 1);
return phys_addr;
}
--
2.20.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] target/m68k: fix physical address translation in m68k_cpu_get_phys_page_debug()
2020-06-29 16:26 [PATCH] target/m68k: fix physical address translation in m68k_cpu_get_phys_page_debug() Mark Cave-Ayland
@ 2020-06-29 17:56 ` Philippe Mathieu-Daudé
2020-06-29 19:50 ` Laurent Vivier
0 siblings, 1 reply; 3+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-06-29 17:56 UTC (permalink / raw)
To: Mark Cave-Ayland, qemu-devel, laurent
On 6/29/20 6:26 PM, Mark Cave-Ayland wrote:
> The result of the get_physical_address() function should be combined with the
> offset of the original page access before being returned. Otherwise the
> m68k_cpu_get_phys_page_debug() function can round to the wrong page causing
> incorrect lookups in gdbstub and various "Disassembler disagrees with
> translator over instruction decoding" warnings to appear at translation time.
>
> Fixes: 88b2fef6c3 ("target/m68k: add MC68040 MMU")
> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
> ---
> target/m68k/helper.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/target/m68k/helper.c b/target/m68k/helper.c
> index 79b0b10ea9..631eab7774 100644
> --- a/target/m68k/helper.c
> +++ b/target/m68k/helper.c
> @@ -820,10 +820,14 @@ hwaddr m68k_cpu_get_phys_page_debug(CPUState *cs, vaddr addr)
> if (env->sr & SR_S) {
> access_type |= ACCESS_SUPER;
> }
> +
> if (get_physical_address(env, &phys_addr, &prot,
> addr, access_type, &page_size) != 0) {
> return -1;
> }
> +
> + addr &= TARGET_PAGE_MASK;
> + phys_addr += addr & (page_size - 1);
Correct but all the callers do the same, maybe this can somehow
be moved to the callee? Anyway:
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> return phys_addr;
> }
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] target/m68k: fix physical address translation in m68k_cpu_get_phys_page_debug()
2020-06-29 17:56 ` Philippe Mathieu-Daudé
@ 2020-06-29 19:50 ` Laurent Vivier
0 siblings, 0 replies; 3+ messages in thread
From: Laurent Vivier @ 2020-06-29 19:50 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, Mark Cave-Ayland, qemu-devel
Le 29/06/2020 à 19:56, Philippe Mathieu-Daudé a écrit :
> On 6/29/20 6:26 PM, Mark Cave-Ayland wrote:
>> The result of the get_physical_address() function should be combined with the
>> offset of the original page access before being returned. Otherwise the
>> m68k_cpu_get_phys_page_debug() function can round to the wrong page causing
>> incorrect lookups in gdbstub and various "Disassembler disagrees with
>> translator over instruction decoding" warnings to appear at translation time.
>>
>> Fixes: 88b2fef6c3 ("target/m68k: add MC68040 MMU")
>> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
>> ---
>> target/m68k/helper.c | 4 ++++
>> 1 file changed, 4 insertions(+)
>>
>> diff --git a/target/m68k/helper.c b/target/m68k/helper.c
>> index 79b0b10ea9..631eab7774 100644
>> --- a/target/m68k/helper.c
>> +++ b/target/m68k/helper.c
>> @@ -820,10 +820,14 @@ hwaddr m68k_cpu_get_phys_page_debug(CPUState *cs, vaddr addr)
>> if (env->sr & SR_S) {
>> access_type |= ACCESS_SUPER;
>> }
>> +
>> if (get_physical_address(env, &phys_addr, &prot,
>> addr, access_type, &page_size) != 0) {
>> return -1;
>> }
>> +
>> + addr &= TARGET_PAGE_MASK;
>> + phys_addr += addr & (page_size - 1);
>
> Correct but all the callers do the same, maybe this can somehow
> be moved to the callee? Anyway:
I agree.
Anyway:
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Thanks,
Laurent
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-06-29 19:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-29 16:26 [PATCH] target/m68k: fix physical address translation in m68k_cpu_get_phys_page_debug() Mark Cave-Ayland
2020-06-29 17:56 ` Philippe Mathieu-Daudé
2020-06-29 19:50 ` Laurent Vivier
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.