* [PULL 0/3] M68k next patches
@ 2020-07-06 20:05 Laurent Vivier
2020-07-06 20:05 ` [PULL 1/3] target/m68k: fix physical address translation in m68k_cpu_get_phys_page_debug() Laurent Vivier
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Laurent Vivier @ 2020-07-06 20:05 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Alex Bennée, Laurent Vivier, Aurelien Jarno
The following changes since commit 64f0ad8ad8e13257e7c912df470d46784b55c3fd:
Merge remote-tracking branch 'remotes/armbru/tags/pull-error-2020-07-02' into staging (2020-07-02 15:54:09 +0100)
are available in the Git repository at:
git://github.com/vivier/qemu-m68k.git tags/m68k-next-pull-request
for you to fetch changes up to d159dd058c7dc48a9291fde92eaae52a9f26a4d1:
softfloat,m68k: disable floatx80_invalid_encoding() for m68k (2020-07-06 21:41:52 +0200)
----------------------------------------------------------------
m68k pull-request 20200706
disable floatx80_invalid_encoding() for m68k
fix m68k_cpu_get_phys_page_debug()
----------------------------------------------------------------
Laurent Vivier (1):
softfloat,m68k: disable floatx80_invalid_encoding() for m68k
Mark Cave-Ayland (2):
target/m68k: fix physical address translation in
m68k_cpu_get_phys_page_debug()
target/m68k: consolidate physical translation offset into
get_physical_address()
include/fpu/softfloat.h | 24 ++++++++++++++++++++++++
target/m68k/helper.c | 17 ++++++++---------
2 files changed, 32 insertions(+), 9 deletions(-)
--
2.26.2
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PULL 1/3] target/m68k: fix physical address translation in m68k_cpu_get_phys_page_debug()
2020-07-06 20:05 [PULL 0/3] M68k next patches Laurent Vivier
@ 2020-07-06 20:05 ` Laurent Vivier
2020-07-06 20:05 ` [PULL 2/3] target/m68k: consolidate physical translation offset into get_physical_address() Laurent Vivier
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Laurent Vivier @ 2020-07-06 20:05 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Mark Cave-Ayland, Laurent Vivier,
Philippe Mathieu-Daudé, Alex Bennée, Aurelien Jarno
From: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
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>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20200701201531.13828-2-mark.cave-ayland@ilande.co.uk>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
target/m68k/helper.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/target/m68k/helper.c b/target/m68k/helper.c
index 79b0b10ea9bc..631eab777494 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.26.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PULL 2/3] target/m68k: consolidate physical translation offset into get_physical_address()
2020-07-06 20:05 [PULL 0/3] M68k next patches Laurent Vivier
2020-07-06 20:05 ` [PULL 1/3] target/m68k: fix physical address translation in m68k_cpu_get_phys_page_debug() Laurent Vivier
@ 2020-07-06 20:05 ` Laurent Vivier
2020-07-06 20:05 ` [PULL 3/3] softfloat, m68k: disable floatx80_invalid_encoding() for m68k Laurent Vivier
2020-07-09 10:29 ` [PULL 0/3] M68k next patches Peter Maydell
3 siblings, 0 replies; 5+ messages in thread
From: Laurent Vivier @ 2020-07-06 20:05 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Mark Cave-Ayland, Laurent Vivier,
Philippe Mathieu-Daudé, Alex Bennée, Aurelien Jarno
From: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
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>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20200701201531.13828-3-mark.cave-ayland@ilande.co.uk>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
target/m68k/helper.c | 17 ++++++-----------
1 file changed, 6 insertions(+), 11 deletions(-)
diff --git a/target/m68k/helper.c b/target/m68k/helper.c
index 631eab777494..3ff57657958c 100644
--- a/target/m68k/helper.c
+++ b/target/m68k/helper.c
@@ -643,7 +643,7 @@ static int get_physical_address(CPUM68KState *env, hwaddr *physical,
/* Transparent Translation Register bit */
env->mmu.mmusr = M68K_MMU_T_040 | M68K_MMU_R_040;
}
- *physical = address & TARGET_PAGE_MASK;
+ *physical = address;
*page_size = TARGET_PAGE_SIZE;
return 0;
}
@@ -771,7 +771,7 @@ static int get_physical_address(CPUM68KState *env, hwaddr *physical,
}
*page_size = 1 << page_bits;
page_mask = ~(*page_size - 1);
- *physical = next & page_mask;
+ *physical = (next & page_mask) + (address & (*page_size - 1));
if (access_type & ACCESS_PTEST) {
env->mmu.mmusr |= next & M68K_MMU_SR_MASK_040;
@@ -826,8 +826,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 +889,8 @@ 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 & TARGET_PAGE_MASK,
+ physical & TARGET_PAGE_MASK, prot, mmu_idx, page_size);
return true;
}
@@ -1383,9 +1379,8 @@ void HELPER(ptest)(CPUM68KState *env, uint32_t addr, uint32_t is_read)
ret = get_physical_address(env, &physical, &prot, addr,
access_type, &page_size);
if (ret == 0) {
- addr &= TARGET_PAGE_MASK;
- physical += addr & (page_size - 1);
- tlb_set_page(env_cpu(env), addr, physical,
+ tlb_set_page(env_cpu(env), addr & TARGET_PAGE_MASK,
+ physical & TARGET_PAGE_MASK,
prot, access_type & ACCESS_SUPER ?
MMU_KERNEL_IDX : MMU_USER_IDX, page_size);
}
--
2.26.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PULL 3/3] softfloat, m68k: disable floatx80_invalid_encoding() for m68k
2020-07-06 20:05 [PULL 0/3] M68k next patches Laurent Vivier
2020-07-06 20:05 ` [PULL 1/3] target/m68k: fix physical address translation in m68k_cpu_get_phys_page_debug() Laurent Vivier
2020-07-06 20:05 ` [PULL 2/3] target/m68k: consolidate physical translation offset into get_physical_address() Laurent Vivier
@ 2020-07-06 20:05 ` Laurent Vivier
2020-07-09 10:29 ` [PULL 0/3] M68k next patches Peter Maydell
3 siblings, 0 replies; 5+ messages in thread
From: Laurent Vivier @ 2020-07-06 20:05 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Alex Bennée, Laurent Vivier, Aurelien Jarno
According to the comment, this definition of invalid encoding is given
by intel developer's manual, and doesn't comply with 680x0 FPU.
With m68k, the explicit integer bit can be zero in the case of:
- zeros (exp == 0, mantissa == 0)
- denormalized numbers (exp == 0, mantissa != 0)
- unnormalized numbers (exp != 0, exp < 0x7FFF)
- infinities (exp == 0x7FFF, mantissa == 0)
- not-a-numbers (exp == 0x7FFF, mantissa != 0)
For infinities and NaNs, the explicit integer bit can be either one or
zero.
The IEEE 754 standard does not define a zero integer bit. Such a number
is an unnormalized number. Hardware does not directly support
denormalized and unnormalized numbers, but implicitly supports them by
trapping them as unimplemented data types, allowing efficient conversion
in software.
See "M68000 FAMILY PROGRAMMER’S REFERENCE MANUAL",
"1.6 FLOATING-POINT DATA TYPES"
We will implement in the m68k TCG emulator the FP_UNIMP exception to
trap into the kernel to normalize the number. In case of linux-user,
the number will be normalized by QEMU.
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20200612140400.2130118-1-laurent@vivier.eu>
---
include/fpu/softfloat.h | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h
index ff4e2605b16d..f1a19df066b7 100644
--- a/include/fpu/softfloat.h
+++ b/include/fpu/softfloat.h
@@ -794,7 +794,31 @@ static inline bool floatx80_unordered_quiet(floatx80 a, floatx80 b,
*----------------------------------------------------------------------------*/
static inline bool floatx80_invalid_encoding(floatx80 a)
{
+#if defined(TARGET_M68K)
+ /*-------------------------------------------------------------------------
+ | With m68k, the explicit integer bit can be zero in the case of:
+ | - zeros (exp == 0, mantissa == 0)
+ | - denormalized numbers (exp == 0, mantissa != 0)
+ | - unnormalized numbers (exp != 0, exp < 0x7FFF)
+ | - infinities (exp == 0x7FFF, mantissa == 0)
+ | - not-a-numbers (exp == 0x7FFF, mantissa != 0)
+ |
+ | For infinities and NaNs, the explicit integer bit can be either one or
+ | zero.
+ |
+ | The IEEE 754 standard does not define a zero integer bit. Such a number
+ | is an unnormalized number. Hardware does not directly support
+ | denormalized and unnormalized numbers, but implicitly supports them by
+ | trapping them as unimplemented data types, allowing efficient conversion
+ | in software.
+ |
+ | See "M68000 FAMILY PROGRAMMER’S REFERENCE MANUAL",
+ | "1.6 FLOATING-POINT DATA TYPES"
+ *------------------------------------------------------------------------*/
+ return false;
+#else
return (a.low & (1ULL << 63)) == 0 && (a.high & 0x7FFF) != 0;
+#endif
}
#define floatx80_zero make_floatx80(0x0000, 0x0000000000000000LL)
--
2.26.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PULL 0/3] M68k next patches
2020-07-06 20:05 [PULL 0/3] M68k next patches Laurent Vivier
` (2 preceding siblings ...)
2020-07-06 20:05 ` [PULL 3/3] softfloat, m68k: disable floatx80_invalid_encoding() for m68k Laurent Vivier
@ 2020-07-09 10:29 ` Peter Maydell
3 siblings, 0 replies; 5+ messages in thread
From: Peter Maydell @ 2020-07-09 10:29 UTC (permalink / raw)
To: Laurent Vivier; +Cc: Alex Bennée, QEMU Developers, Aurelien Jarno
On Mon, 6 Jul 2020 at 21:06, Laurent Vivier <laurent@vivier.eu> wrote:
>
> The following changes since commit 64f0ad8ad8e13257e7c912df470d46784b55c3fd:
>
> Merge remote-tracking branch 'remotes/armbru/tags/pull-error-2020-07-02' into staging (2020-07-02 15:54:09 +0100)
>
> are available in the Git repository at:
>
> git://github.com/vivier/qemu-m68k.git tags/m68k-next-pull-request
>
> for you to fetch changes up to d159dd058c7dc48a9291fde92eaae52a9f26a4d1:
>
> softfloat,m68k: disable floatx80_invalid_encoding() for m68k (2020-07-06 21:41:52 +0200)
>
> ----------------------------------------------------------------
> m68k pull-request 20200706
>
> disable floatx80_invalid_encoding() for m68k
> fix m68k_cpu_get_phys_page_debug()
>
Applied, thanks.
Please update the changelog at https://wiki.qemu.org/ChangeLog/5.1
for any user-visible changes.
-- PMM
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-07-09 10:30 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-07-06 20:05 [PULL 0/3] M68k next patches Laurent Vivier
2020-07-06 20:05 ` [PULL 1/3] target/m68k: fix physical address translation in m68k_cpu_get_phys_page_debug() Laurent Vivier
2020-07-06 20:05 ` [PULL 2/3] target/m68k: consolidate physical translation offset into get_physical_address() Laurent Vivier
2020-07-06 20:05 ` [PULL 3/3] softfloat, m68k: disable floatx80_invalid_encoding() for m68k Laurent Vivier
2020-07-09 10:29 ` [PULL 0/3] M68k next patches Peter Maydell
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).