Skip to content

Commit 0926439

Browse files
glaubitzkarcherm
andcommitted
gh-142342: Fix m68k assembler operand constraints for %fpcr access
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. Co-authored-by: Michael Karcher <github@mkarcher.dialup.fu-berlin.de>
1 parent d119443 commit 0926439

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

Include/internal/pycore_pymath.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,17 +146,17 @@ extern void _Py_set_387controlword(unsigned short);
146146
unsigned int old_fpcr, new_fpcr
147147
#define _Py_SET_53BIT_PRECISION_START \
148148
do { \
149-
__asm__ ("fmove.l %%fpcr,%0" : "=g" (old_fpcr)); \
149+
__asm__ ("fmove.l %%fpcr,%0" : "=dm" (old_fpcr)); \
150150
/* Set double precision / round to nearest. */ \
151151
new_fpcr = (old_fpcr & ~0xf0) | 0x80; \
152152
if (new_fpcr != old_fpcr) { \
153-
__asm__ volatile ("fmove.l %0,%%fpcr" : : "g" (new_fpcr));\
153+
__asm__ volatile ("fmove.l %0,%%fpcr" : : "dm" (new_fpcr)); \
154154
} \
155155
} while (0)
156156
#define _Py_SET_53BIT_PRECISION_END \
157157
do { \
158158
if (new_fpcr != old_fpcr) { \
159-
__asm__ volatile ("fmove.l %0,%%fpcr" : : "g" (old_fpcr)); \
159+
__asm__ volatile ("fmove.l %0,%%fpcr" : : "dm" (old_fpcr)); \
160160
} \
161161
} while (0)
162162
#endif

configure

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

configure.ac

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6126,8 +6126,8 @@ AS_VAR_IF([ac_cv_gcc_asm_for_x87], [yes], [
61266126
AC_CACHE_CHECK([whether we can use gcc inline assembler to get and set mc68881 fpcr], [ac_cv_gcc_asm_for_mc68881], [
61276127
AC_LINK_IFELSE( [AC_LANG_PROGRAM([[]], [[
61286128
unsigned int fpcr;
6129-
__asm__ __volatile__ ("fmove.l %%fpcr,%0" : "=g" (fpcr));
6130-
__asm__ __volatile__ ("fmove.l %0,%%fpcr" : : "g" (fpcr));
6129+
__asm__ __volatile__ ("fmove.l %%fpcr,%0" : "=dm" (fpcr));
6130+
__asm__ __volatile__ ("fmove.l %0,%%fpcr" : : "dm" (fpcr));
61316131
]])],[ac_cv_gcc_asm_for_mc68881=yes],[ac_cv_gcc_asm_for_mc68881=no])
61326132
])
61336133
AS_VAR_IF([ac_cv_gcc_asm_for_mc68881], [yes], [

0 commit comments

Comments
 (0)