mirror of
https://github.com/python/cpython.git
synced 2025-12-31 04:23:37 +00:00
[3.14] gh-142342: Fix m68k assembler operand constraints for %fpcr access (gh-142343) (#142458)
On m68k, an fmove instruction accessing %fpcr may only move from
or to a data register or a memory operand. The constraint "g" also
permits the use of address registers, which is invalid. The correct
constraint is "dm". Beginning with GCC 15, the register allocator
picks an address register in the code which causes SIGILL during
runtime.
(cherry picked from commit 02c085d48b)
Co-authored-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Co-authored-by: Michael Karcher <github@mkarcher.dialup.fu-berlin.de>
This commit is contained in:
parent
19968c8927
commit
43f696d942
4 changed files with 8 additions and 7 deletions
|
|
@ -146,17 +146,17 @@ extern void _Py_set_387controlword(unsigned short);
|
|||
unsigned int old_fpcr, new_fpcr
|
||||
#define _Py_SET_53BIT_PRECISION_START \
|
||||
do { \
|
||||
__asm__ ("fmove.l %%fpcr,%0" : "=g" (old_fpcr)); \
|
||||
__asm__ ("fmove.l %%fpcr,%0" : "=dm" (old_fpcr)); \
|
||||
/* Set double precision / round to nearest. */ \
|
||||
new_fpcr = (old_fpcr & ~0xf0) | 0x80; \
|
||||
if (new_fpcr != old_fpcr) { \
|
||||
__asm__ volatile ("fmove.l %0,%%fpcr" : : "g" (new_fpcr));\
|
||||
__asm__ volatile ("fmove.l %0,%%fpcr" : : "dm" (new_fpcr)); \
|
||||
} \
|
||||
} while (0)
|
||||
#define _Py_SET_53BIT_PRECISION_END \
|
||||
do { \
|
||||
if (new_fpcr != old_fpcr) { \
|
||||
__asm__ volatile ("fmove.l %0,%%fpcr" : : "g" (old_fpcr)); \
|
||||
__asm__ volatile ("fmove.l %0,%%fpcr" : : "dm" (old_fpcr)); \
|
||||
} \
|
||||
} while (0)
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
Fix SIGILL crash on m68k due to incorrect assembly constraint.
|
||||
4
configure
generated
vendored
4
configure
generated
vendored
|
|
@ -26010,8 +26010,8 @@ main (void)
|
|||
{
|
||||
|
||||
unsigned int fpcr;
|
||||
__asm__ __volatile__ ("fmove.l %%fpcr,%0" : "=g" (fpcr));
|
||||
__asm__ __volatile__ ("fmove.l %0,%%fpcr" : : "g" (fpcr));
|
||||
__asm__ __volatile__ ("fmove.l %%fpcr,%0" : "=dm" (fpcr));
|
||||
__asm__ __volatile__ ("fmove.l %0,%%fpcr" : : "dm" (fpcr));
|
||||
|
||||
;
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -6099,8 +6099,8 @@ AS_VAR_IF([ac_cv_gcc_asm_for_x87], [yes], [
|
|||
AC_CACHE_CHECK([whether we can use gcc inline assembler to get and set mc68881 fpcr], [ac_cv_gcc_asm_for_mc68881], [
|
||||
AC_LINK_IFELSE( [AC_LANG_PROGRAM([[]], [[
|
||||
unsigned int fpcr;
|
||||
__asm__ __volatile__ ("fmove.l %%fpcr,%0" : "=g" (fpcr));
|
||||
__asm__ __volatile__ ("fmove.l %0,%%fpcr" : : "g" (fpcr));
|
||||
__asm__ __volatile__ ("fmove.l %%fpcr,%0" : "=dm" (fpcr));
|
||||
__asm__ __volatile__ ("fmove.l %0,%%fpcr" : : "dm" (fpcr));
|
||||
]])],[ac_cv_gcc_asm_for_mc68881=yes],[ac_cv_gcc_asm_for_mc68881=no])
|
||||
])
|
||||
AS_VAR_IF([ac_cv_gcc_asm_for_mc68881], [yes], [
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue