Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error: invalid operand for instruction in arch/arm/vfp/vfpmodule.c #905

Closed
agners opened this issue Feb 24, 2020 · 4 comments
Closed

error: invalid operand for instruction in arch/arm/vfp/vfpmodule.c #905

agners opened this issue Feb 24, 2020 · 4 comments
Assignees
Labels
[ARCH] arm32 This bug impacts ARCH=arm [BUG] linux A bug that should be fixed in the mainline kernel. [FIXED][LINUX] 5.9 This bug was fixed in Linux 5.9 [TOOL] integrated-as The issue is relevant to LLVM integrated assembler

Comments

@agners
Copy link

agners commented Feb 24, 2020

Clang warns when compiling arch/arm/vfp/vfpmodule.c with integrated assembler:

arch/arm/vfp/vfpmodule.c:342:2: error: invalid operand for instruction
        fmxr(FPEXC, fpexc & ~(FPEXC_EX|FPEXC_DEX|FPEXC_FP2V|FPEXC_VV|FPEXC_TRAP_MASK));
        ^
arch/arm/vfp/vfpinstr.h:79:6: note: expanded from macro 'fmxr'
        asm("mcr p10, 7, %0, " vfpreg(_vfp_) ", cr0, 0 @ fmxr   " #_vfp_ ", %0" \
            ^
<inline asm>:1:6: note: instantiated into assembly here
        mcr p10, 7, r0, cr8, cr0, 0 @ fmxr      FPEXC, r0
            ^

This has been previously tracked by #306, but since this can be solved separately lets use a separate issue. It is not technically a bug in Linux, but it should be straight forward to solve the issue in Linux.

@agners agners added [BUG] linux A bug that should be fixed in the mainline kernel. [TOOL] integrated-as The issue is relevant to LLVM integrated assembler [ARCH] arm32 This bug impacts ARCH=arm labels Feb 24, 2020
@agners agners self-assigned this Feb 24, 2020
@agners agners added the [PATCH] Submitted A patch has been submitted for review label Feb 25, 2020
@agners
Copy link
Author

agners commented Feb 25, 2020

agners added a commit that referenced this issue Mar 1, 2020
Clang's integrated assembler does not allow to to use the mcr
instruction to access floating point co-processor registers:
arch/arm/vfp/vfpmodule.c:342:2: error: invalid operand for instruction
        fmxr(FPEXC, fpexc & ~(FPEXC_EX|FPEXC_DEX|FPEXC_FP2V|FPEXC_VV|FPEXC_TRAP_MASK));
        ^
arch/arm/vfp/vfpinstr.h:79:6: note: expanded from macro 'fmxr'
        asm("mcr p10, 7, %0, " vfpreg(_vfp_) ", cr0, 0 @ fmxr   " #_vfp_ ", %0" \
            ^
<inline asm>:1:6: note: instantiated into assembly here
        mcr p10, 7, r0, cr8, cr0, 0 @ fmxr      FPEXC, r0
            ^

Ideally we would replace this code with the unified assembler language
mnemonics vmrs/vmsr on call sites along with .fpu assembler directives.
The GNU assembler supports the .fpu directive at least since 2.17 (when
documentation has been added). Since Linux requires binutils 2.21 it is
safe to use .fpu directive. However, binutils does not allow to use
FPINST or FPINST2 as an argument to vmrs/vmsr instructions up to
binutils 2.24 (see binutils commit 16d02dc907c5).

Use as-instr to check if FPINST/FPINST2 can be used. If they can be used
make use of .fpu directives and UAL VFP mnemonics for register access.

This allows to build vfpmodule.c with Clang and its integrated assembler.

Link: #905
Signed-off-by: Stefan Agner <[email protected]>
fengguang pushed a commit to 0day-ci/linux that referenced this issue Mar 10, 2020
Clang's integrated assembler does not allow to to use the mcr
instruction to access floating point co-processor registers:
arch/arm/vfp/vfpmodule.c:342:2: error: invalid operand for instruction
        fmxr(FPEXC, fpexc & ~(FPEXC_EX|FPEXC_DEX|FPEXC_FP2V|FPEXC_VV|FPEXC_TRAP_MASK));
        ^
arch/arm/vfp/vfpinstr.h:79:6: note: expanded from macro 'fmxr'
        asm("mcr p10, 7, %0, " vfpreg(_vfp_) ", cr0, 0 @ fmxr   " #_vfp_ ", %0" \
            ^
<inline asm>:1:6: note: instantiated into assembly here
        mcr p10, 7, r0, cr8, cr0, 0 @ fmxr      FPEXC, r0
            ^

Ideally we would replace this code with the unified assembler language
mnemonics vmrs/vmsr on call sites along with .fpu assembler directives.
The GNU assembler supports the .fpu directive at least since 2.17 (when
documentation has been added). Since Linux requires binutils 2.21 it is
safe to use .fpu directive. However, binutils does not allow to use
FPINST or FPINST2 as an argument to vmrs/vmsr instructions up to
binutils 2.24 (see binutils commit 16d02dc907c5).

Use as-instr to check if FPINST/FPINST2 can be used. If they can be used
make use of .fpu directives and UAL VFP mnemonics for register access.

This allows to build vfpmodule.c with Clang and its integrated assembler.

Link: ClangBuiltLinux#905
Signed-off-by: Stefan Agner <[email protected]>
@agners
Copy link
Author

agners commented Mar 30, 2020

fengguang pushed a commit to 0day-ci/linux that referenced this issue Apr 21, 2020
Clang's integrated assembler does not allow to access the VFP registers
through the coprocessor load/store instructions:
<instantiation>:4:6: error: invalid operand for instruction
 LDC p11, cr0, [r10],torvalds#32*4 @ FLDMIAD r10!, {d0-d15}
     ^

Replace the coprocessor load/store instructions with explicit assembler
mnemonics to accessing the floating point coprocessor registers. Use
assembler directives to select the appropriate FPU version.

This allows to build these macros with GNU assembler as well as with
Clang's built-in assembler.

Link: ClangBuiltLinux#905
Signed-off-by: Stefan Agner <[email protected]>
fengguang pushed a commit to 0day-ci/linux that referenced this issue Apr 21, 2020
Clang's integrated assembler does not allow to to use the mcr
instruction to access floating point co-processor registers:
arch/arm/vfp/vfpmodule.c:342:2: error: invalid operand for instruction
        fmxr(FPEXC, fpexc & ~(FPEXC_EX|FPEXC_DEX|FPEXC_FP2V|FPEXC_VV|FPEXC_TRAP_MASK));
        ^
arch/arm/vfp/vfpinstr.h:79:6: note: expanded from macro 'fmxr'
        asm("mcr p10, 7, %0, " vfpreg(_vfp_) ", cr0, 0 @ fmxr   " #_vfp_ ", %0" \
            ^
<inline asm>:1:6: note: instantiated into assembly here
        mcr p10, 7, r0, cr8, cr0, 0 @ fmxr      FPEXC, r0
            ^

Ideally we would replace this code with the unified assembler language
mnemonics vmrs/vmsr on call sites along with .fpu assembler directives.
The GNU assembler supports the .fpu directive at least since 2.17 (when
documentation has been added). Since Linux requires binutils 2.21 it is
safe to use .fpu directive. However, binutils does not allow to use
FPINST or FPINST2 as an argument to vmrs/vmsr instructions up to
binutils 2.24 (see binutils commit 16d02dc907c5):
arch/arm/vfp/vfphw.S: Assembler messages:
arch/arm/vfp/vfphw.S:162: Error: operand 0 must be FPSID or FPSCR pr FPEXC -- `vmsr FPINST,r6'
arch/arm/vfp/vfphw.S:165: Error: operand 0 must be FPSID or FPSCR pr FPEXC -- `vmsr FPINST2,r8'
arch/arm/vfp/vfphw.S:235: Error: operand 1 must be a VFP extension System Register -- `vmrs r3,FPINST'
arch/arm/vfp/vfphw.S:238: Error: operand 1 must be a VFP extension System Register -- `vmrs r12,FPINST2'

Use as-instr in Kconfig to check if FPINST/FPINST2 can be used. If they
can be used make use of .fpu directives and UAL VFP mnemonics for
register access.

This allows to build vfpmodule.c with Clang and its integrated assembler.

Link: ClangBuiltLinux#905
Signed-off-by: Stefan Agner <[email protected]>
parthibx24 pushed a commit to parthibx24/android_kernel_mediatek_k80 that referenced this issue Apr 26, 2020
Clang's integrated assembler does not allow to to use the mcr
instruction to access floating point co-processor registers:
arch/arm/vfp/vfpmodule.c:342:2: error: invalid operand for instruction
        fmxr(FPEXC, fpexc & ~(FPEXC_EX|FPEXC_DEX|FPEXC_FP2V|FPEXC_VV|FPEXC_TRAP_MASK));
        ^
arch/arm/vfp/vfpinstr.h:79:6: note: expanded from macro 'fmxr'
        asm("mcr p10, 7, %0, " vfpreg(_vfp_) ", cr0, 0 @ fmxr   " #_vfp_ ", %0" \
            ^
<inline asm>:1:6: note: instantiated into assembly here
        mcr p10, 7, r0, cr8, cr0, 0 @ fmxr      FPEXC, r0
            ^

The GNU assembler supports the .fpu directive at least since 2.17 (when
documentation has been added). Since Linux requires binutils 2.21 it is
safe to use .fpu directive. Use the .fpu directive and mnemonics for VFP
register access.

This allows to build vfpmodule.c with Clang and its integrated assembler.

Link: ClangBuiltLinux/linux#905
Signed-off-by: Stefan Agner <[email protected]>
nathanchance pushed a commit to nathanchance/pi-kernel that referenced this issue May 12, 2020
Clang's integrated assembler does not allow to to use the mcr
instruction to access floating point co-processor registers:
arch/arm/vfp/vfpmodule.c:342:2: error: invalid operand for instruction
        fmxr(FPEXC, fpexc & ~(FPEXC_EX|FPEXC_DEX|FPEXC_FP2V|FPEXC_VV|FPEXC_TRAP_MASK));
        ^
arch/arm/vfp/vfpinstr.h:79:6: note: expanded from macro 'fmxr'
        asm("mcr p10, 7, %0, " vfpreg(_vfp_) ", cr0, 0 @ fmxr   " #_vfp_ ", %0" \
            ^
<inline asm>:1:6: note: instantiated into assembly here
        mcr p10, 7, r0, cr8, cr0, 0 @ fmxr      FPEXC, r0
            ^

Ideally we would replace this code with the unified assembler language
mnemonics vmrs/vmsr on call sites along with .fpu assembler directives.
The GNU assembler supports the .fpu directive at least since 2.17 (when
documentation has been added). Since Linux requires binutils 2.21 it is
safe to use .fpu directive. However, binutils does not allow to use
FPINST or FPINST2 as an argument to vmrs/vmsr instructions up to
binutils 2.24 (see binutils commit 16d02dc907c5).

Use as-instr to check if FPINST/FPINST2 can be used. If they can be used
make use of .fpu directives and UAL VFP mnemonics for register access.

This allows to build vfpmodule.c with Clang and its integrated assembler.

Signed-off-by: Stefan Agner <[email protected]>
Link: ClangBuiltLinux/linux#905
Link: https://lore.kernel.org/lkml/3c8127839ced991fadb08c0a5a7beebb3ff489af.1583360296.git.stefan@agner.ch/
Signed-off-by: Nathan Chancellor <[email protected]>
nathanchance pushed a commit to nathanchance/pi-kernel that referenced this issue May 12, 2020
Clang's integrated assembler does not allow to to use the mcr
instruction to access floating point co-processor registers:
arch/arm/vfp/vfpmodule.c:342:2: error: invalid operand for instruction
        fmxr(FPEXC, fpexc & ~(FPEXC_EX|FPEXC_DEX|FPEXC_FP2V|FPEXC_VV|FPEXC_TRAP_MASK));
        ^
arch/arm/vfp/vfpinstr.h:79:6: note: expanded from macro 'fmxr'
        asm("mcr p10, 7, %0, " vfpreg(_vfp_) ", cr0, 0 @ fmxr   " #_vfp_ ", %0" \
            ^
<inline asm>:1:6: note: instantiated into assembly here
        mcr p10, 7, r0, cr8, cr0, 0 @ fmxr      FPEXC, r0
            ^

Ideally we would replace this code with the unified assembler language
mnemonics vmrs/vmsr on call sites along with .fpu assembler directives.
The GNU assembler supports the .fpu directive at least since 2.17 (when
documentation has been added). Since Linux requires binutils 2.21 it is
safe to use .fpu directive. However, binutils does not allow to use
FPINST or FPINST2 as an argument to vmrs/vmsr instructions up to
binutils 2.24 (see binutils commit 16d02dc907c5).

Use as-instr to check if FPINST/FPINST2 can be used. If they can be used
make use of .fpu directives and UAL VFP mnemonics for register access.

This allows to build vfpmodule.c with Clang and its integrated assembler.

Signed-off-by: Stefan Agner <[email protected]>
Link: ClangBuiltLinux/linux#905
Link: https://lore.kernel.org/lkml/3c8127839ced991fadb08c0a5a7beebb3ff489af.1583360296.git.stefan@agner.ch/
Signed-off-by: Nathan Chancellor <[email protected]>
fengguang pushed a commit to 0day-ci/linux that referenced this issue Jun 26, 2020
The integrated assembler of Clang 10 and earlier do not allow to access
the VFP registers through the coprocessor load/store instructions:
<instantiation>:4:6: error: invalid operand for instruction
 LDC p11, cr0, [r10],torvalds#32*4 @ FLDMIAD r10!, {d0-d15}
     ^

This has been addressed with Clang 11 [0]. However, to support earlier
versions of Clang and for better readability use of VFP assembler
mnemonics still is preferred.

Replace the coprocessor load/store instructions with explicit assembler
mnemonics to accessing the floating point coprocessor registers. Use
assembler directives to select the appropriate FPU version.

This allows to build these macros with GNU assembler as well as with
Clang's built-in assembler.

[0] https://reviews.llvm.org/D59733

Link: ClangBuiltLinux#905
Signed-off-by: Stefan Agner <[email protected]>
fengguang pushed a commit to 0day-ci/linux that referenced this issue Jun 26, 2020
The integrated assembler of Clang 10 and earlier do not allow to access
the VFP registers through the coprocessor load/store instructions:
arch/arm/vfp/vfpmodule.c:342:2: error: invalid operand for instruction
        fmxr(FPEXC, fpexc & ~(FPEXC_EX|FPEXC_DEX|FPEXC_FP2V|FPEXC_VV|FPEXC_TRAP_MASK));
        ^
arch/arm/vfp/vfpinstr.h:79:6: note: expanded from macro 'fmxr'
        asm("mcr p10, 7, %0, " vfpreg(_vfp_) ", cr0, 0 @ fmxr   " #_vfp_ ", %0" \
            ^
<inline asm>:1:6: note: instantiated into assembly here
        mcr p10, 7, r0, cr8, cr0, 0 @ fmxr      FPEXC, r0
            ^

This has been addressed with Clang 11 [0]. However, to support earlier
versions of Clang and for better readability use of VFP assembler
mnemonics still is preferred.

Ideally we would replace this code with the unified assembler language
mnemonics vmrs/vmsr on call sites along with .fpu assembler directives.
The GNU assembler supports the .fpu directive at least since 2.17 (when
documentation has been added). Since Linux requires binutils 2.21 it is
safe to use .fpu directive. However, binutils does not allow to use
FPINST or FPINST2 as an argument to vmrs/vmsr instructions up to
binutils 2.24 (see binutils commit 16d02dc907c5):
arch/arm/vfp/vfphw.S: Assembler messages:
arch/arm/vfp/vfphw.S:162: Error: operand 0 must be FPSID or FPSCR pr FPEXC -- `vmsr FPINST,r6'
arch/arm/vfp/vfphw.S:165: Error: operand 0 must be FPSID or FPSCR pr FPEXC -- `vmsr FPINST2,r8'
arch/arm/vfp/vfphw.S:235: Error: operand 1 must be a VFP extension System Register -- `vmrs r3,FPINST'
arch/arm/vfp/vfphw.S:238: Error: operand 1 must be a VFP extension System Register -- `vmrs r12,FPINST2'

Use as-instr in Kconfig to check if FPINST/FPINST2 can be used. If they
can be used make use of .fpu directives and UAL VFP mnemonics for
register access.

This allows to build vfpmodule.c with Clang and its integrated assembler.

[0] https://reviews.llvm.org/D59733

Link: ClangBuiltLinux#905
Signed-off-by: Stefan Agner <[email protected]>
ruscur pushed a commit to ruscur/linux that referenced this issue Jul 21, 2020
The integrated assembler of Clang 10 and earlier do not allow to access
the VFP registers through the coprocessor load/store instructions:
<instantiation>:4:6: error: invalid operand for instruction
 LDC p11, cr0, [r10],torvalds#32*4 @ FLDMIAD r10!, {d0-d15}
     ^

This has been addressed with Clang 11 [0]. However, to support earlier
versions of Clang and for better readability use of VFP assembler
mnemonics still is preferred.

Replace the coprocessor load/store instructions with explicit assembler
mnemonics to accessing the floating point coprocessor registers. Use
assembler directives to select the appropriate FPU version.

This allows to build these macros with GNU assembler as well as with
Clang's built-in assembler.

[0] https://reviews.llvm.org/D59733

Link: ClangBuiltLinux#905

Signed-off-by: Stefan Agner <[email protected]>
Signed-off-by: Russell King <[email protected]>
ruscur pushed a commit to ruscur/linux that referenced this issue Jul 21, 2020
The integrated assembler of Clang 10 and earlier do not allow to access
the VFP registers through the coprocessor load/store instructions:
arch/arm/vfp/vfpmodule.c:342:2: error: invalid operand for instruction
        fmxr(FPEXC, fpexc & ~(FPEXC_EX|FPEXC_DEX|FPEXC_FP2V|FPEXC_VV|FPEXC_TRAP_MASK));
        ^
arch/arm/vfp/vfpinstr.h:79:6: note: expanded from macro 'fmxr'
        asm("mcr p10, 7, %0, " vfpreg(_vfp_) ", cr0, 0 @ fmxr   " #_vfp_ ", %0"
            ^
<inline asm>:1:6: note: instantiated into assembly here
        mcr p10, 7, r0, cr8, cr0, 0 @ fmxr      FPEXC, r0
            ^

This has been addressed with Clang 11 [0]. However, to support earlier
versions of Clang and for better readability use of VFP assembler
mnemonics still is preferred.

Ideally we would replace this code with the unified assembler language
mnemonics vmrs/vmsr on call sites along with .fpu assembler directives.
The GNU assembler supports the .fpu directive at least since 2.17 (when
documentation has been added). Since Linux requires binutils 2.21 it is
safe to use .fpu directive. However, binutils does not allow to use
FPINST or FPINST2 as an argument to vmrs/vmsr instructions up to
binutils 2.24 (see binutils commit 16d02dc907c5):
arch/arm/vfp/vfphw.S: Assembler messages:
arch/arm/vfp/vfphw.S:162: Error: operand 0 must be FPSID or FPSCR pr FPEXC -- `vmsr FPINST,r6'
arch/arm/vfp/vfphw.S:165: Error: operand 0 must be FPSID or FPSCR pr FPEXC -- `vmsr FPINST2,r8'
arch/arm/vfp/vfphw.S:235: Error: operand 1 must be a VFP extension System Register -- `vmrs r3,FPINST'
arch/arm/vfp/vfphw.S:238: Error: operand 1 must be a VFP extension System Register -- `vmrs r12,FPINST2'

Use as-instr in Kconfig to check if FPINST/FPINST2 can be used. If they
can be used make use of .fpu directives and UAL VFP mnemonics for
register access.

This allows to build vfpmodule.c with Clang and its integrated assembler.

[0] https://reviews.llvm.org/D59733

Link: ClangBuiltLinux#905

Signed-off-by: Stefan Agner <[email protected]>
Signed-off-by: Russell King <[email protected]>
ruscur pushed a commit to ruscur/linux that referenced this issue Jul 22, 2020
The integrated assembler of Clang 10 and earlier do not allow to access
the VFP registers through the coprocessor load/store instructions:
<instantiation>:4:6: error: invalid operand for instruction
 LDC p11, cr0, [r10],torvalds#32*4 @ FLDMIAD r10!, {d0-d15}
     ^

This has been addressed with Clang 11 [0]. However, to support earlier
versions of Clang and for better readability use of VFP assembler
mnemonics still is preferred.

Replace the coprocessor load/store instructions with explicit assembler
mnemonics to accessing the floating point coprocessor registers. Use
assembler directives to select the appropriate FPU version.

This allows to build these macros with GNU assembler as well as with
Clang's built-in assembler.

[0] https://reviews.llvm.org/D59733

Link: ClangBuiltLinux#905

Signed-off-by: Stefan Agner <[email protected]>
Signed-off-by: Russell King <[email protected]>
ruscur pushed a commit to ruscur/linux that referenced this issue Jul 22, 2020
The integrated assembler of Clang 10 and earlier do not allow to access
the VFP registers through the coprocessor load/store instructions:
arch/arm/vfp/vfpmodule.c:342:2: error: invalid operand for instruction
        fmxr(FPEXC, fpexc & ~(FPEXC_EX|FPEXC_DEX|FPEXC_FP2V|FPEXC_VV|FPEXC_TRAP_MASK));
        ^
arch/arm/vfp/vfpinstr.h:79:6: note: expanded from macro 'fmxr'
        asm("mcr p10, 7, %0, " vfpreg(_vfp_) ", cr0, 0 @ fmxr   " #_vfp_ ", %0"
            ^
<inline asm>:1:6: note: instantiated into assembly here
        mcr p10, 7, r0, cr8, cr0, 0 @ fmxr      FPEXC, r0
            ^

This has been addressed with Clang 11 [0]. However, to support earlier
versions of Clang and for better readability use of VFP assembler
mnemonics still is preferred.

Ideally we would replace this code with the unified assembler language
mnemonics vmrs/vmsr on call sites along with .fpu assembler directives.
The GNU assembler supports the .fpu directive at least since 2.17 (when
documentation has been added). Since Linux requires binutils 2.21 it is
safe to use .fpu directive. However, binutils does not allow to use
FPINST or FPINST2 as an argument to vmrs/vmsr instructions up to
binutils 2.24 (see binutils commit 16d02dc907c5):
arch/arm/vfp/vfphw.S: Assembler messages:
arch/arm/vfp/vfphw.S:162: Error: operand 0 must be FPSID or FPSCR pr FPEXC -- `vmsr FPINST,r6'
arch/arm/vfp/vfphw.S:165: Error: operand 0 must be FPSID or FPSCR pr FPEXC -- `vmsr FPINST2,r8'
arch/arm/vfp/vfphw.S:235: Error: operand 1 must be a VFP extension System Register -- `vmrs r3,FPINST'
arch/arm/vfp/vfphw.S:238: Error: operand 1 must be a VFP extension System Register -- `vmrs r12,FPINST2'

Use as-instr in Kconfig to check if FPINST/FPINST2 can be used. If they
can be used make use of .fpu directives and UAL VFP mnemonics for
register access.

This allows to build vfpmodule.c with Clang and its integrated assembler.

[0] https://reviews.llvm.org/D59733

Link: ClangBuiltLinux#905

Signed-off-by: Stefan Agner <[email protected]>
Signed-off-by: Russell King <[email protected]>
@nickdesaulniers nickdesaulniers added [PATCH] Accepted A submitted patch has been accepted upstream and removed [PATCH] Submitted A patch has been submitted for review labels Jul 23, 2020
@nickdesaulniers
Copy link
Member

Looks like these got merged/accepted: https://www.arm.linux.org.uk/developer/patches/section.php?section=20&page=133

@nickdesaulniers nickdesaulniers added [FIXED][LINUX] 5.9 This bug was fixed in Linux 5.9 and removed [PATCH] Accepted A submitted patch has been accepted upstream labels Aug 6, 2020
mrchapp pushed a commit to mrchapp/linux that referenced this issue Mar 15, 2021
commit ee44033 upstream.

The integrated assembler of Clang 10 and earlier do not allow to access
the VFP registers through the coprocessor load/store instructions:
<instantiation>:4:6: error: invalid operand for instruction
 LDC p11, cr0, [r10],torvalds#32*4 @ FLDMIAD r10!, {d0-d15}
     ^

This has been addressed with Clang 11 [0]. However, to support earlier
versions of Clang and for better readability use of VFP assembler
mnemonics still is preferred.

Replace the coprocessor load/store instructions with explicit assembler
mnemonics to accessing the floating point coprocessor registers. Use
assembler directives to select the appropriate FPU version.

This allows to build these macros with GNU assembler as well as with
Clang's built-in assembler.

[0] https://reviews.llvm.org/D59733

Link: ClangBuiltLinux#905

Signed-off-by: Stefan Agner <[email protected]>
Signed-off-by: Russell King <[email protected]>
Signed-off-by: Nick Desaulniers <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
Vishalcj17 pushed a commit to Vishalcj17/sm8350-kernel-rebase that referenced this issue Jan 25, 2024
commit 2cbd1cc3dcd3e84be1fc1987da24b190ddf24a70 upstream.

The integrated assembler of Clang 10 and earlier do not allow to access
the VFP registers through the coprocessor load/store instructions:
arch/arm/vfp/vfpmodule.c:342:2: error: invalid operand for instruction
        fmxr(FPEXC, fpexc & ~(FPEXC_EX|FPEXC_DEX|FPEXC_FP2V|FPEXC_VV|FPEXC_TRAP_MASK));
        ^
arch/arm/vfp/vfpinstr.h:79:6: note: expanded from macro 'fmxr'
        asm("mcr p10, 7, %0, " vfpreg(_vfp_) ", cr0, 0 @ fmxr   " #_vfp_ ", %0"
            ^
<inline asm>:1:6: note: instantiated into assembly here
        mcr p10, 7, r0, cr8, cr0, 0 @ fmxr      FPEXC, r0
            ^

This has been addressed with Clang 11 [0]. However, to support earlier
versions of Clang and for better readability use of VFP assembler
mnemonics still is preferred.

Ideally we would replace this code with the unified assembler language
mnemonics vmrs/vmsr on call sites along with .fpu assembler directives.
The GNU assembler supports the .fpu directive at least since 2.17 (when
documentation has been added). Since Linux requires binutils 2.21 it is
safe to use .fpu directive. However, binutils does not allow to use
FPINST or FPINST2 as an argument to vmrs/vmsr instructions up to
binutils 2.24 (see binutils commit 16d02dc907c5):
arch/arm/vfp/vfphw.S: Assembler messages:
arch/arm/vfp/vfphw.S:162: Error: operand 0 must be FPSID or FPSCR pr FPEXC -- `vmsr FPINST,r6'
arch/arm/vfp/vfphw.S:165: Error: operand 0 must be FPSID or FPSCR pr FPEXC -- `vmsr FPINST2,r8'
arch/arm/vfp/vfphw.S:235: Error: operand 1 must be a VFP extension System Register -- `vmrs r3,FPINST'
arch/arm/vfp/vfphw.S:238: Error: operand 1 must be a VFP extension System Register -- `vmrs r12,FPINST2'

Use as-instr in Kconfig to check if FPINST/FPINST2 can be used. If they
can be used make use of .fpu directives and UAL VFP mnemonics for
register access.

This allows to build vfpmodule.c with Clang and its integrated assembler.

[0] https://reviews.llvm.org/D59733

Link: ClangBuiltLinux/linux#905

Signed-off-by: Stefan Agner <[email protected]>
Signed-off-by: Russell King <[email protected]>
[nd: Adjusted hunk from arch/arm/Kconfig due to missing
     commit 8a90a3228b6a ("arm: Unplug KVM from the build system").
     Replace __ACCESS_VFP with fmrx/fmxr for arch/arm/kvm/switch.c.
     CONFIG_KVM was removed in
     commit 541ad0150ca4 ("arm: Remove 32bit KVM host support") in
     v5.7.1. CONFIG_KVM is not enabled as part of allmodconfig or
     alldefconfig, but axm55xx_defconfig explicitly does enable it.
     Adjusted arch/arm/vfp/vfphw.S due to conflict with
     commit a47b395 ("ARM: 9030/1: entry: omit FP emulation for UND
     exceptions taken in kernel mode").]
Bug: 141693040
Signed-off-by: Nick Desaulniers <[email protected]>
Change-Id: I84733bd8649784e1e636e107c1dac03ef7d48136
Vishalcj17 pushed a commit to Vishalcj17/sm8350-kernel-rebase that referenced this issue Jan 25, 2024
commit 2cbd1cc3dcd3e84be1fc1987da24b190ddf24a70 upstream.

The integrated assembler of Clang 10 and earlier do not allow to access
the VFP registers through the coprocessor load/store instructions:
arch/arm/vfp/vfpmodule.c:342:2: error: invalid operand for instruction
        fmxr(FPEXC, fpexc & ~(FPEXC_EX|FPEXC_DEX|FPEXC_FP2V|FPEXC_VV|FPEXC_TRAP_MASK));
        ^
arch/arm/vfp/vfpinstr.h:79:6: note: expanded from macro 'fmxr'
        asm("mcr p10, 7, %0, " vfpreg(_vfp_) ", cr0, 0 @ fmxr   " #_vfp_ ", %0"
            ^
<inline asm>:1:6: note: instantiated into assembly here
        mcr p10, 7, r0, cr8, cr0, 0 @ fmxr      FPEXC, r0
            ^

This has been addressed with Clang 11 [0]. However, to support earlier
versions of Clang and for better readability use of VFP assembler
mnemonics still is preferred.

Ideally we would replace this code with the unified assembler language
mnemonics vmrs/vmsr on call sites along with .fpu assembler directives.
The GNU assembler supports the .fpu directive at least since 2.17 (when
documentation has been added). Since Linux requires binutils 2.21 it is
safe to use .fpu directive. However, binutils does not allow to use
FPINST or FPINST2 as an argument to vmrs/vmsr instructions up to
binutils 2.24 (see binutils commit 16d02dc907c5):
arch/arm/vfp/vfphw.S: Assembler messages:
arch/arm/vfp/vfphw.S:162: Error: operand 0 must be FPSID or FPSCR pr FPEXC -- `vmsr FPINST,r6'
arch/arm/vfp/vfphw.S:165: Error: operand 0 must be FPSID or FPSCR pr FPEXC -- `vmsr FPINST2,r8'
arch/arm/vfp/vfphw.S:235: Error: operand 1 must be a VFP extension System Register -- `vmrs r3,FPINST'
arch/arm/vfp/vfphw.S:238: Error: operand 1 must be a VFP extension System Register -- `vmrs r12,FPINST2'

Use as-instr in Kconfig to check if FPINST/FPINST2 can be used. If they
can be used make use of .fpu directives and UAL VFP mnemonics for
register access.

This allows to build vfpmodule.c with Clang and its integrated assembler.

[0] https://reviews.llvm.org/D59733

Link: ClangBuiltLinux/linux#905

Signed-off-by: Stefan Agner <[email protected]>
Signed-off-by: Russell King <[email protected]>
[nd: Adjusted hunk from arch/arm/Kconfig due to missing
     commit 8a90a3228b6a ("arm: Unplug KVM from the build system").
     Replace __ACCESS_VFP with fmrx/fmxr for arch/arm/kvm/switch.c.
     CONFIG_KVM was removed in
     commit 541ad0150ca4 ("arm: Remove 32bit KVM host support") in
     v5.7.1. CONFIG_KVM is not enabled as part of allmodconfig or
     alldefconfig, but axm55xx_defconfig explicitly does enable it.
     Adjusted arch/arm/vfp/vfphw.S due to conflict with
     commit a47b395 ("ARM: 9030/1: entry: omit FP emulation for UND
     exceptions taken in kernel mode").]
Bug: 141693040
Signed-off-by: Nick Desaulniers <[email protected]>
Change-Id: I84733bd8649784e1e636e107c1dac03ef7d48136
pa-gerrit pushed a commit to AOSPA/android_kernel_oneplus_sm8350 that referenced this issue Jan 27, 2024
commit 2cbd1cc3dcd3e84be1fc1987da24b190ddf24a70 upstream.

The integrated assembler of Clang 10 and earlier do not allow to access
the VFP registers through the coprocessor load/store instructions:
arch/arm/vfp/vfpmodule.c:342:2: error: invalid operand for instruction
        fmxr(FPEXC, fpexc & ~(FPEXC_EX|FPEXC_DEX|FPEXC_FP2V|FPEXC_VV|FPEXC_TRAP_MASK));
        ^
arch/arm/vfp/vfpinstr.h:79:6: note: expanded from macro 'fmxr'
        asm("mcr p10, 7, %0, " vfpreg(_vfp_) ", cr0, 0 @ fmxr   " #_vfp_ ", %0"
            ^
<inline asm>:1:6: note: instantiated into assembly here
        mcr p10, 7, r0, cr8, cr0, 0 @ fmxr      FPEXC, r0
            ^

This has been addressed with Clang 11 [0]. However, to support earlier
versions of Clang and for better readability use of VFP assembler
mnemonics still is preferred.

Ideally we would replace this code with the unified assembler language
mnemonics vmrs/vmsr on call sites along with .fpu assembler directives.
The GNU assembler supports the .fpu directive at least since 2.17 (when
documentation has been added). Since Linux requires binutils 2.21 it is
safe to use .fpu directive. However, binutils does not allow to use
FPINST or FPINST2 as an argument to vmrs/vmsr instructions up to
binutils 2.24 (see binutils commit 16d02dc907c5):
arch/arm/vfp/vfphw.S: Assembler messages:
arch/arm/vfp/vfphw.S:162: Error: operand 0 must be FPSID or FPSCR pr FPEXC -- `vmsr FPINST,r6'
arch/arm/vfp/vfphw.S:165: Error: operand 0 must be FPSID or FPSCR pr FPEXC -- `vmsr FPINST2,r8'
arch/arm/vfp/vfphw.S:235: Error: operand 1 must be a VFP extension System Register -- `vmrs r3,FPINST'
arch/arm/vfp/vfphw.S:238: Error: operand 1 must be a VFP extension System Register -- `vmrs r12,FPINST2'

Use as-instr in Kconfig to check if FPINST/FPINST2 can be used. If they
can be used make use of .fpu directives and UAL VFP mnemonics for
register access.

This allows to build vfpmodule.c with Clang and its integrated assembler.

[0] https://reviews.llvm.org/D59733

Link: ClangBuiltLinux/linux#905

Signed-off-by: Stefan Agner <[email protected]>
Signed-off-by: Russell King <[email protected]>
[nd: Adjusted hunk from arch/arm/Kconfig due to missing
     commit 8a90a3228b6a ("arm: Unplug KVM from the build system").
     Replace __ACCESS_VFP with fmrx/fmxr for arch/arm/kvm/switch.c.
     CONFIG_KVM was removed in
     commit 541ad0150ca4 ("arm: Remove 32bit KVM host support") in
     v5.7.1. CONFIG_KVM is not enabled as part of allmodconfig or
     alldefconfig, but axm55xx_defconfig explicitly does enable it.
     Adjusted arch/arm/vfp/vfphw.S due to conflict with
     commit a47b395 ("ARM: 9030/1: entry: omit FP emulation for UND
     exceptions taken in kernel mode").]
Bug: 141693040
Signed-off-by: Nick Desaulniers <[email protected]>
Change-Id: I84733bd8649784e1e636e107c1dac03ef7d48136
TogoFire pushed a commit to dev-sm8350/kernel_oneplus_sm8350 that referenced this issue Jan 30, 2024
commit 2cbd1cc upstream.

The integrated assembler of Clang 10 and earlier do not allow to access
the VFP registers through the coprocessor load/store instructions:
arch/arm/vfp/vfpmodule.c:342:2: error: invalid operand for instruction
        fmxr(FPEXC, fpexc & ~(FPEXC_EX|FPEXC_DEX|FPEXC_FP2V|FPEXC_VV|FPEXC_TRAP_MASK));
        ^
arch/arm/vfp/vfpinstr.h:79:6: note: expanded from macro 'fmxr'
        asm("mcr p10, 7, %0, " vfpreg(_vfp_) ", cr0, 0 @ fmxr   " #_vfp_ ", %0"
            ^
<inline asm>:1:6: note: instantiated into assembly here
        mcr p10, 7, r0, cr8, cr0, 0 @ fmxr      FPEXC, r0
            ^

This has been addressed with Clang 11 [0]. However, to support earlier
versions of Clang and for better readability use of VFP assembler
mnemonics still is preferred.

Ideally we would replace this code with the unified assembler language
mnemonics vmrs/vmsr on call sites along with .fpu assembler directives.
The GNU assembler supports the .fpu directive at least since 2.17 (when
documentation has been added). Since Linux requires binutils 2.21 it is
safe to use .fpu directive. However, binutils does not allow to use
FPINST or FPINST2 as an argument to vmrs/vmsr instructions up to
binutils 2.24 (see binutils commit 16d02dc907c5):
arch/arm/vfp/vfphw.S: Assembler messages:
arch/arm/vfp/vfphw.S:162: Error: operand 0 must be FPSID or FPSCR pr FPEXC -- `vmsr FPINST,r6'
arch/arm/vfp/vfphw.S:165: Error: operand 0 must be FPSID or FPSCR pr FPEXC -- `vmsr FPINST2,r8'
arch/arm/vfp/vfphw.S:235: Error: operand 1 must be a VFP extension System Register -- `vmrs r3,FPINST'
arch/arm/vfp/vfphw.S:238: Error: operand 1 must be a VFP extension System Register -- `vmrs r12,FPINST2'

Use as-instr in Kconfig to check if FPINST/FPINST2 can be used. If they
can be used make use of .fpu directives and UAL VFP mnemonics for
register access.

This allows to build vfpmodule.c with Clang and its integrated assembler.

[0] https://reviews.llvm.org/D59733

Link: ClangBuiltLinux/linux#905

Signed-off-by: Stefan Agner <[email protected]>
Change-Id: I0c22586d1f2bf15692d809d6d517ecd5309a9981
Signed-off-by: Russell King <[email protected]>
[nd: Adjusted hunk from arch/arm/Kconfig due to missing
     commit 8a90a32 ("arm: Unplug KVM from the build system").
     Replace __ACCESS_VFP with fmrx/fmxr for arch/arm/kvm/switch.c.
     CONFIG_KVM was removed in
     commit 541ad01 ("arm: Remove 32bit KVM host support") in
     v5.7.1. CONFIG_KVM is not enabled as part of allmodconfig or
     alldefconfig, but axm55xx_defconfig explicitly does enable it.
     Adjusted arch/arm/vfp/vfphw.S due to conflict with
     commit a47b395 ("ARM: 9030/1: entry: omit FP emulation for UND
     exceptions taken in kernel mode").]
Bug: 141693040
Signed-off-by: Nick Desaulniers <[email protected]>
(cherry picked from commit 5208d4f)
Signed-off-by: TogoFire <[email protected]>
TogoFire pushed a commit to dev-sm8350/kernel_oneplus_sm8350 that referenced this issue Jan 31, 2024
commit 2cbd1cc upstream.

The integrated assembler of Clang 10 and earlier do not allow to access
the VFP registers through the coprocessor load/store instructions:
arch/arm/vfp/vfpmodule.c:342:2: error: invalid operand for instruction
        fmxr(FPEXC, fpexc & ~(FPEXC_EX|FPEXC_DEX|FPEXC_FP2V|FPEXC_VV|FPEXC_TRAP_MASK));
        ^
arch/arm/vfp/vfpinstr.h:79:6: note: expanded from macro 'fmxr'
        asm("mcr p10, 7, %0, " vfpreg(_vfp_) ", cr0, 0 @ fmxr   " #_vfp_ ", %0"
            ^
<inline asm>:1:6: note: instantiated into assembly here
        mcr p10, 7, r0, cr8, cr0, 0 @ fmxr      FPEXC, r0
            ^

This has been addressed with Clang 11 [0]. However, to support earlier
versions of Clang and for better readability use of VFP assembler
mnemonics still is preferred.

Ideally we would replace this code with the unified assembler language
mnemonics vmrs/vmsr on call sites along with .fpu assembler directives.
The GNU assembler supports the .fpu directive at least since 2.17 (when
documentation has been added). Since Linux requires binutils 2.21 it is
safe to use .fpu directive. However, binutils does not allow to use
FPINST or FPINST2 as an argument to vmrs/vmsr instructions up to
binutils 2.24 (see binutils commit 16d02dc907c5):
arch/arm/vfp/vfphw.S: Assembler messages:
arch/arm/vfp/vfphw.S:162: Error: operand 0 must be FPSID or FPSCR pr FPEXC -- `vmsr FPINST,r6'
arch/arm/vfp/vfphw.S:165: Error: operand 0 must be FPSID or FPSCR pr FPEXC -- `vmsr FPINST2,r8'
arch/arm/vfp/vfphw.S:235: Error: operand 1 must be a VFP extension System Register -- `vmrs r3,FPINST'
arch/arm/vfp/vfphw.S:238: Error: operand 1 must be a VFP extension System Register -- `vmrs r12,FPINST2'

Use as-instr in Kconfig to check if FPINST/FPINST2 can be used. If they
can be used make use of .fpu directives and UAL VFP mnemonics for
register access.

This allows to build vfpmodule.c with Clang and its integrated assembler.

[0] https://reviews.llvm.org/D59733

Link: ClangBuiltLinux/linux#905

Signed-off-by: Stefan Agner <[email protected]>
Change-Id: Id3c84f0246bc6c6b2a461bec95253fa119539015
Signed-off-by: Russell King <[email protected]>
[nd: Adjusted hunk from arch/arm/Kconfig due to missing
     commit 8a90a32 ("arm: Unplug KVM from the build system").
     Replace __ACCESS_VFP with fmrx/fmxr for arch/arm/kvm/switch.c.
     CONFIG_KVM was removed in
     commit 541ad01 ("arm: Remove 32bit KVM host support") in
     v5.7.1. CONFIG_KVM is not enabled as part of allmodconfig or
     alldefconfig, but axm55xx_defconfig explicitly does enable it.
     Adjusted arch/arm/vfp/vfphw.S due to conflict with
     commit a47b395 ("ARM: 9030/1: entry: omit FP emulation for UND
     exceptions taken in kernel mode").]
Bug: 141693040
Signed-off-by: Nick Desaulniers <[email protected]>
(cherry picked from commit 5208d4f)
Signed-off-by: TogoFire <[email protected]>
TogoFire pushed a commit to dev-sm8350/kernel_oneplus_sm8350 that referenced this issue Jan 31, 2024
commit 2cbd1cc upstream.

The integrated assembler of Clang 10 and earlier do not allow to access
the VFP registers through the coprocessor load/store instructions:
arch/arm/vfp/vfpmodule.c:342:2: error: invalid operand for instruction
        fmxr(FPEXC, fpexc & ~(FPEXC_EX|FPEXC_DEX|FPEXC_FP2V|FPEXC_VV|FPEXC_TRAP_MASK));
        ^
arch/arm/vfp/vfpinstr.h:79:6: note: expanded from macro 'fmxr'
        asm("mcr p10, 7, %0, " vfpreg(_vfp_) ", cr0, 0 @ fmxr   " #_vfp_ ", %0"
            ^
<inline asm>:1:6: note: instantiated into assembly here
        mcr p10, 7, r0, cr8, cr0, 0 @ fmxr      FPEXC, r0
            ^

This has been addressed with Clang 11 [0]. However, to support earlier
versions of Clang and for better readability use of VFP assembler
mnemonics still is preferred.

Ideally we would replace this code with the unified assembler language
mnemonics vmrs/vmsr on call sites along with .fpu assembler directives.
The GNU assembler supports the .fpu directive at least since 2.17 (when
documentation has been added). Since Linux requires binutils 2.21 it is
safe to use .fpu directive. However, binutils does not allow to use
FPINST or FPINST2 as an argument to vmrs/vmsr instructions up to
binutils 2.24 (see binutils commit 16d02dc907c5):
arch/arm/vfp/vfphw.S: Assembler messages:
arch/arm/vfp/vfphw.S:162: Error: operand 0 must be FPSID or FPSCR pr FPEXC -- `vmsr FPINST,r6'
arch/arm/vfp/vfphw.S:165: Error: operand 0 must be FPSID or FPSCR pr FPEXC -- `vmsr FPINST2,r8'
arch/arm/vfp/vfphw.S:235: Error: operand 1 must be a VFP extension System Register -- `vmrs r3,FPINST'
arch/arm/vfp/vfphw.S:238: Error: operand 1 must be a VFP extension System Register -- `vmrs r12,FPINST2'

Use as-instr in Kconfig to check if FPINST/FPINST2 can be used. If they
can be used make use of .fpu directives and UAL VFP mnemonics for
register access.

This allows to build vfpmodule.c with Clang and its integrated assembler.

[0] https://reviews.llvm.org/D59733

Link: ClangBuiltLinux/linux#905

Signed-off-by: Stefan Agner <[email protected]>
Change-Id: Id3c84f0246bc6c6b2a461bec95253fa119539015
Signed-off-by: Russell King <[email protected]>
[nd: Adjusted hunk from arch/arm/Kconfig due to missing
     commit 8a90a32 ("arm: Unplug KVM from the build system").
     Replace __ACCESS_VFP with fmrx/fmxr for arch/arm/kvm/switch.c.
     CONFIG_KVM was removed in
     commit 541ad01 ("arm: Remove 32bit KVM host support") in
     v5.7.1. CONFIG_KVM is not enabled as part of allmodconfig or
     alldefconfig, but axm55xx_defconfig explicitly does enable it.
     Adjusted arch/arm/vfp/vfphw.S due to conflict with
     commit a47b395 ("ARM: 9030/1: entry: omit FP emulation for UND
     exceptions taken in kernel mode").]
Bug: 141693040
Signed-off-by: Nick Desaulniers <[email protected]>
(cherry picked from commit 5208d4f)
Signed-off-by: TogoFire <[email protected]>
awakened1712 pushed a commit to aospa-pp/android_kernel_oneplus_sm8350 that referenced this issue Feb 3, 2024
commit 2cbd1cc3dcd3e84be1fc1987da24b190ddf24a70 upstream.

The integrated assembler of Clang 10 and earlier do not allow to access
the VFP registers through the coprocessor load/store instructions:
arch/arm/vfp/vfpmodule.c:342:2: error: invalid operand for instruction
        fmxr(FPEXC, fpexc & ~(FPEXC_EX|FPEXC_DEX|FPEXC_FP2V|FPEXC_VV|FPEXC_TRAP_MASK));
        ^
arch/arm/vfp/vfpinstr.h:79:6: note: expanded from macro 'fmxr'
        asm("mcr p10, 7, %0, " vfpreg(_vfp_) ", cr0, 0 @ fmxr   " #_vfp_ ", %0"
            ^
<inline asm>:1:6: note: instantiated into assembly here
        mcr p10, 7, r0, cr8, cr0, 0 @ fmxr      FPEXC, r0
            ^

This has been addressed with Clang 11 [0]. However, to support earlier
versions of Clang and for better readability use of VFP assembler
mnemonics still is preferred.

Ideally we would replace this code with the unified assembler language
mnemonics vmrs/vmsr on call sites along with .fpu assembler directives.
The GNU assembler supports the .fpu directive at least since 2.17 (when
documentation has been added). Since Linux requires binutils 2.21 it is
safe to use .fpu directive. However, binutils does not allow to use
FPINST or FPINST2 as an argument to vmrs/vmsr instructions up to
binutils 2.24 (see binutils commit 16d02dc907c5):
arch/arm/vfp/vfphw.S: Assembler messages:
arch/arm/vfp/vfphw.S:162: Error: operand 0 must be FPSID or FPSCR pr FPEXC -- `vmsr FPINST,r6'
arch/arm/vfp/vfphw.S:165: Error: operand 0 must be FPSID or FPSCR pr FPEXC -- `vmsr FPINST2,r8'
arch/arm/vfp/vfphw.S:235: Error: operand 1 must be a VFP extension System Register -- `vmrs r3,FPINST'
arch/arm/vfp/vfphw.S:238: Error: operand 1 must be a VFP extension System Register -- `vmrs r12,FPINST2'

Use as-instr in Kconfig to check if FPINST/FPINST2 can be used. If they
can be used make use of .fpu directives and UAL VFP mnemonics for
register access.

This allows to build vfpmodule.c with Clang and its integrated assembler.

[0] https://reviews.llvm.org/D59733

Link: ClangBuiltLinux/linux#905

Signed-off-by: Stefan Agner <[email protected]>
Signed-off-by: Russell King <[email protected]>
[nd: Adjusted hunk from arch/arm/Kconfig due to missing
     commit 8a90a3228b6a ("arm: Unplug KVM from the build system").
     Replace __ACCESS_VFP with fmrx/fmxr for arch/arm/kvm/switch.c.
     CONFIG_KVM was removed in
     commit 541ad0150ca4 ("arm: Remove 32bit KVM host support") in
     v5.7.1. CONFIG_KVM is not enabled as part of allmodconfig or
     alldefconfig, but axm55xx_defconfig explicitly does enable it.
     Adjusted arch/arm/vfp/vfphw.S due to conflict with
     commit a47b395 ("ARM: 9030/1: entry: omit FP emulation for UND
     exceptions taken in kernel mode").]
Bug: 141693040
Signed-off-by: Nick Desaulniers <[email protected]>
Change-Id: I84733bd8649784e1e636e107c1dac03ef7d48136
awakened1712 pushed a commit to aospa-pp/android_kernel_oneplus_sm8350 that referenced this issue Feb 3, 2024
commit 2cbd1cc3dcd3e84be1fc1987da24b190ddf24a70 upstream.

The integrated assembler of Clang 10 and earlier do not allow to access
the VFP registers through the coprocessor load/store instructions:
arch/arm/vfp/vfpmodule.c:342:2: error: invalid operand for instruction
        fmxr(FPEXC, fpexc & ~(FPEXC_EX|FPEXC_DEX|FPEXC_FP2V|FPEXC_VV|FPEXC_TRAP_MASK));
        ^
arch/arm/vfp/vfpinstr.h:79:6: note: expanded from macro 'fmxr'
        asm("mcr p10, 7, %0, " vfpreg(_vfp_) ", cr0, 0 @ fmxr   " #_vfp_ ", %0"
            ^
<inline asm>:1:6: note: instantiated into assembly here
        mcr p10, 7, r0, cr8, cr0, 0 @ fmxr      FPEXC, r0
            ^

This has been addressed with Clang 11 [0]. However, to support earlier
versions of Clang and for better readability use of VFP assembler
mnemonics still is preferred.

Ideally we would replace this code with the unified assembler language
mnemonics vmrs/vmsr on call sites along with .fpu assembler directives.
The GNU assembler supports the .fpu directive at least since 2.17 (when
documentation has been added). Since Linux requires binutils 2.21 it is
safe to use .fpu directive. However, binutils does not allow to use
FPINST or FPINST2 as an argument to vmrs/vmsr instructions up to
binutils 2.24 (see binutils commit 16d02dc907c5):
arch/arm/vfp/vfphw.S: Assembler messages:
arch/arm/vfp/vfphw.S:162: Error: operand 0 must be FPSID or FPSCR pr FPEXC -- `vmsr FPINST,r6'
arch/arm/vfp/vfphw.S:165: Error: operand 0 must be FPSID or FPSCR pr FPEXC -- `vmsr FPINST2,r8'
arch/arm/vfp/vfphw.S:235: Error: operand 1 must be a VFP extension System Register -- `vmrs r3,FPINST'
arch/arm/vfp/vfphw.S:238: Error: operand 1 must be a VFP extension System Register -- `vmrs r12,FPINST2'

Use as-instr in Kconfig to check if FPINST/FPINST2 can be used. If they
can be used make use of .fpu directives and UAL VFP mnemonics for
register access.

This allows to build vfpmodule.c with Clang and its integrated assembler.

[0] https://reviews.llvm.org/D59733

Link: ClangBuiltLinux/linux#905

Signed-off-by: Stefan Agner <[email protected]>
Signed-off-by: Russell King <[email protected]>
[nd: Adjusted hunk from arch/arm/Kconfig due to missing
     commit 8a90a3228b6a ("arm: Unplug KVM from the build system").
     Replace __ACCESS_VFP with fmrx/fmxr for arch/arm/kvm/switch.c.
     CONFIG_KVM was removed in
     commit 541ad0150ca4 ("arm: Remove 32bit KVM host support") in
     v5.7.1. CONFIG_KVM is not enabled as part of allmodconfig or
     alldefconfig, but axm55xx_defconfig explicitly does enable it.
     Adjusted arch/arm/vfp/vfphw.S due to conflict with
     commit a47b395 ("ARM: 9030/1: entry: omit FP emulation for UND
     exceptions taken in kernel mode").]
Bug: 141693040
Signed-off-by: Nick Desaulniers <[email protected]>
Change-Id: I84733bd8649784e1e636e107c1dac03ef7d48136
TogoFire pushed a commit to dev-sm8350/kernel_oneplus_sm8350 that referenced this issue Feb 7, 2024
commit 2cbd1cc upstream.

The integrated assembler of Clang 10 and earlier do not allow to access
the VFP registers through the coprocessor load/store instructions:
arch/arm/vfp/vfpmodule.c:342:2: error: invalid operand for instruction
        fmxr(FPEXC, fpexc & ~(FPEXC_EX|FPEXC_DEX|FPEXC_FP2V|FPEXC_VV|FPEXC_TRAP_MASK));
        ^
arch/arm/vfp/vfpinstr.h:79:6: note: expanded from macro 'fmxr'
        asm("mcr p10, 7, %0, " vfpreg(_vfp_) ", cr0, 0 @ fmxr   " #_vfp_ ", %0"
            ^
<inline asm>:1:6: note: instantiated into assembly here
        mcr p10, 7, r0, cr8, cr0, 0 @ fmxr      FPEXC, r0
            ^

This has been addressed with Clang 11 [0]. However, to support earlier
versions of Clang and for better readability use of VFP assembler
mnemonics still is preferred.

Ideally we would replace this code with the unified assembler language
mnemonics vmrs/vmsr on call sites along with .fpu assembler directives.
The GNU assembler supports the .fpu directive at least since 2.17 (when
documentation has been added). Since Linux requires binutils 2.21 it is
safe to use .fpu directive. However, binutils does not allow to use
FPINST or FPINST2 as an argument to vmrs/vmsr instructions up to
binutils 2.24 (see binutils commit 16d02dc907c5):
arch/arm/vfp/vfphw.S: Assembler messages:
arch/arm/vfp/vfphw.S:162: Error: operand 0 must be FPSID or FPSCR pr FPEXC -- `vmsr FPINST,r6'
arch/arm/vfp/vfphw.S:165: Error: operand 0 must be FPSID or FPSCR pr FPEXC -- `vmsr FPINST2,r8'
arch/arm/vfp/vfphw.S:235: Error: operand 1 must be a VFP extension System Register -- `vmrs r3,FPINST'
arch/arm/vfp/vfphw.S:238: Error: operand 1 must be a VFP extension System Register -- `vmrs r12,FPINST2'

Use as-instr in Kconfig to check if FPINST/FPINST2 can be used. If they
can be used make use of .fpu directives and UAL VFP mnemonics for
register access.

This allows to build vfpmodule.c with Clang and its integrated assembler.

[0] https://reviews.llvm.org/D59733

Link: ClangBuiltLinux/linux#905

Signed-off-by: Stefan Agner <[email protected]>
Change-Id: If9b319a4b4e74d889062cb1abf3c6899a1ff6f10
Signed-off-by: Russell King <[email protected]>
[nd: Adjusted hunk from arch/arm/Kconfig due to missing
     commit 8a90a32 ("arm: Unplug KVM from the build system").
     Replace __ACCESS_VFP with fmrx/fmxr for arch/arm/kvm/switch.c.
     CONFIG_KVM was removed in
     commit 541ad01 ("arm: Remove 32bit KVM host support") in
     v5.7.1. CONFIG_KVM is not enabled as part of allmodconfig or
     alldefconfig, but axm55xx_defconfig explicitly does enable it.
     Adjusted arch/arm/vfp/vfphw.S due to conflict with
     commit a47b395 ("ARM: 9030/1: entry: omit FP emulation for UND
     exceptions taken in kernel mode").]
Bug: 141693040
Signed-off-by: Nick Desaulniers <[email protected]>
(cherry picked from commit 5208d4f)
Signed-off-by: TogoFire <[email protected]>
TogoFire pushed a commit to dev-sm8350/kernel_oneplus_sm8350 that referenced this issue Feb 7, 2024
commit 2cbd1cc upstream.

The integrated assembler of Clang 10 and earlier do not allow to access
the VFP registers through the coprocessor load/store instructions:
arch/arm/vfp/vfpmodule.c:342:2: error: invalid operand for instruction
        fmxr(FPEXC, fpexc & ~(FPEXC_EX|FPEXC_DEX|FPEXC_FP2V|FPEXC_VV|FPEXC_TRAP_MASK));
        ^
arch/arm/vfp/vfpinstr.h:79:6: note: expanded from macro 'fmxr'
        asm("mcr p10, 7, %0, " vfpreg(_vfp_) ", cr0, 0 @ fmxr   " #_vfp_ ", %0"
            ^
<inline asm>:1:6: note: instantiated into assembly here
        mcr p10, 7, r0, cr8, cr0, 0 @ fmxr      FPEXC, r0
            ^

This has been addressed with Clang 11 [0]. However, to support earlier
versions of Clang and for better readability use of VFP assembler
mnemonics still is preferred.

Ideally we would replace this code with the unified assembler language
mnemonics vmrs/vmsr on call sites along with .fpu assembler directives.
The GNU assembler supports the .fpu directive at least since 2.17 (when
documentation has been added). Since Linux requires binutils 2.21 it is
safe to use .fpu directive. However, binutils does not allow to use
FPINST or FPINST2 as an argument to vmrs/vmsr instructions up to
binutils 2.24 (see binutils commit 16d02dc907c5):
arch/arm/vfp/vfphw.S: Assembler messages:
arch/arm/vfp/vfphw.S:162: Error: operand 0 must be FPSID or FPSCR pr FPEXC -- `vmsr FPINST,r6'
arch/arm/vfp/vfphw.S:165: Error: operand 0 must be FPSID or FPSCR pr FPEXC -- `vmsr FPINST2,r8'
arch/arm/vfp/vfphw.S:235: Error: operand 1 must be a VFP extension System Register -- `vmrs r3,FPINST'
arch/arm/vfp/vfphw.S:238: Error: operand 1 must be a VFP extension System Register -- `vmrs r12,FPINST2'

Use as-instr in Kconfig to check if FPINST/FPINST2 can be used. If they
can be used make use of .fpu directives and UAL VFP mnemonics for
register access.

This allows to build vfpmodule.c with Clang and its integrated assembler.

[0] https://reviews.llvm.org/D59733

Link: ClangBuiltLinux/linux#905

Signed-off-by: Stefan Agner <[email protected]>
Change-Id: Ie8daf6804d8cd001ba8fc2e6856fb1ce53f06c60
Signed-off-by: Russell King <[email protected]>
[nd: Adjusted hunk from arch/arm/Kconfig due to missing
     commit 8a90a32 ("arm: Unplug KVM from the build system").
     Replace __ACCESS_VFP with fmrx/fmxr for arch/arm/kvm/switch.c.
     CONFIG_KVM was removed in
     commit 541ad01 ("arm: Remove 32bit KVM host support") in
     v5.7.1. CONFIG_KVM is not enabled as part of allmodconfig or
     alldefconfig, but axm55xx_defconfig explicitly does enable it.
     Adjusted arch/arm/vfp/vfphw.S due to conflict with
     commit a47b395 ("ARM: 9030/1: entry: omit FP emulation for UND
     exceptions taken in kernel mode").]
Bug: 141693040
Signed-off-by: Nick Desaulniers <[email protected]>
(cherry picked from commit 5208d4f)
Signed-off-by: TogoFire <[email protected]>
TogoFire pushed a commit to dev-sm8350/kernel_oneplus_sm8350 that referenced this issue Feb 7, 2024
commit 2cbd1cc upstream.

The integrated assembler of Clang 10 and earlier do not allow to access
the VFP registers through the coprocessor load/store instructions:
arch/arm/vfp/vfpmodule.c:342:2: error: invalid operand for instruction
        fmxr(FPEXC, fpexc & ~(FPEXC_EX|FPEXC_DEX|FPEXC_FP2V|FPEXC_VV|FPEXC_TRAP_MASK));
        ^
arch/arm/vfp/vfpinstr.h:79:6: note: expanded from macro 'fmxr'
        asm("mcr p10, 7, %0, " vfpreg(_vfp_) ", cr0, 0 @ fmxr   " #_vfp_ ", %0"
            ^
<inline asm>:1:6: note: instantiated into assembly here
        mcr p10, 7, r0, cr8, cr0, 0 @ fmxr      FPEXC, r0
            ^

This has been addressed with Clang 11 [0]. However, to support earlier
versions of Clang and for better readability use of VFP assembler
mnemonics still is preferred.

Ideally we would replace this code with the unified assembler language
mnemonics vmrs/vmsr on call sites along with .fpu assembler directives.
The GNU assembler supports the .fpu directive at least since 2.17 (when
documentation has been added). Since Linux requires binutils 2.21 it is
safe to use .fpu directive. However, binutils does not allow to use
FPINST or FPINST2 as an argument to vmrs/vmsr instructions up to
binutils 2.24 (see binutils commit 16d02dc907c5):
arch/arm/vfp/vfphw.S: Assembler messages:
arch/arm/vfp/vfphw.S:162: Error: operand 0 must be FPSID or FPSCR pr FPEXC -- `vmsr FPINST,r6'
arch/arm/vfp/vfphw.S:165: Error: operand 0 must be FPSID or FPSCR pr FPEXC -- `vmsr FPINST2,r8'
arch/arm/vfp/vfphw.S:235: Error: operand 1 must be a VFP extension System Register -- `vmrs r3,FPINST'
arch/arm/vfp/vfphw.S:238: Error: operand 1 must be a VFP extension System Register -- `vmrs r12,FPINST2'

Use as-instr in Kconfig to check if FPINST/FPINST2 can be used. If they
can be used make use of .fpu directives and UAL VFP mnemonics for
register access.

This allows to build vfpmodule.c with Clang and its integrated assembler.

[0] https://reviews.llvm.org/D59733

Link: ClangBuiltLinux/linux#905

Signed-off-by: Stefan Agner <[email protected]>
Change-Id: Id03aac1781c4ff992c87d696cd9b3e8b9716505b
Signed-off-by: Russell King <[email protected]>
[nd: Adjusted hunk from arch/arm/Kconfig due to missing
     commit 8a90a32 ("arm: Unplug KVM from the build system").
     Replace __ACCESS_VFP with fmrx/fmxr for arch/arm/kvm/switch.c.
     CONFIG_KVM was removed in
     commit 541ad01 ("arm: Remove 32bit KVM host support") in
     v5.7.1. CONFIG_KVM is not enabled as part of allmodconfig or
     alldefconfig, but axm55xx_defconfig explicitly does enable it.
     Adjusted arch/arm/vfp/vfphw.S due to conflict with
     commit a47b395 ("ARM: 9030/1: entry: omit FP emulation for UND
     exceptions taken in kernel mode").]
Bug: 141693040
Signed-off-by: Nick Desaulniers <[email protected]>
(cherry picked from commit 5208d4f)
Signed-off-by: TogoFire <[email protected]>
TogoFire pushed a commit to dev-sm8350/kernel_oneplus_sm8350 that referenced this issue Feb 9, 2024
commit 2cbd1cc upstream.

The integrated assembler of Clang 10 and earlier do not allow to access
the VFP registers through the coprocessor load/store instructions:
arch/arm/vfp/vfpmodule.c:342:2: error: invalid operand for instruction
        fmxr(FPEXC, fpexc & ~(FPEXC_EX|FPEXC_DEX|FPEXC_FP2V|FPEXC_VV|FPEXC_TRAP_MASK));
        ^
arch/arm/vfp/vfpinstr.h:79:6: note: expanded from macro 'fmxr'
        asm("mcr p10, 7, %0, " vfpreg(_vfp_) ", cr0, 0 @ fmxr   " #_vfp_ ", %0"
            ^
<inline asm>:1:6: note: instantiated into assembly here
        mcr p10, 7, r0, cr8, cr0, 0 @ fmxr      FPEXC, r0
            ^

This has been addressed with Clang 11 [0]. However, to support earlier
versions of Clang and for better readability use of VFP assembler
mnemonics still is preferred.

Ideally we would replace this code with the unified assembler language
mnemonics vmrs/vmsr on call sites along with .fpu assembler directives.
The GNU assembler supports the .fpu directive at least since 2.17 (when
documentation has been added). Since Linux requires binutils 2.21 it is
safe to use .fpu directive. However, binutils does not allow to use
FPINST or FPINST2 as an argument to vmrs/vmsr instructions up to
binutils 2.24 (see binutils commit 16d02dc907c5):
arch/arm/vfp/vfphw.S: Assembler messages:
arch/arm/vfp/vfphw.S:162: Error: operand 0 must be FPSID or FPSCR pr FPEXC -- `vmsr FPINST,r6'
arch/arm/vfp/vfphw.S:165: Error: operand 0 must be FPSID or FPSCR pr FPEXC -- `vmsr FPINST2,r8'
arch/arm/vfp/vfphw.S:235: Error: operand 1 must be a VFP extension System Register -- `vmrs r3,FPINST'
arch/arm/vfp/vfphw.S:238: Error: operand 1 must be a VFP extension System Register -- `vmrs r12,FPINST2'

Use as-instr in Kconfig to check if FPINST/FPINST2 can be used. If they
can be used make use of .fpu directives and UAL VFP mnemonics for
register access.

This allows to build vfpmodule.c with Clang and its integrated assembler.

[0] https://reviews.llvm.org/D59733

Link: ClangBuiltLinux/linux#905

Signed-off-by: Stefan Agner <[email protected]>
Change-Id: I4556fb88e294a4501a2112088c3997f29d40feb3
Signed-off-by: Russell King <[email protected]>
[nd: Adjusted hunk from arch/arm/Kconfig due to missing
     commit 8a90a32 ("arm: Unplug KVM from the build system").
     Replace __ACCESS_VFP with fmrx/fmxr for arch/arm/kvm/switch.c.
     CONFIG_KVM was removed in
     commit 541ad01 ("arm: Remove 32bit KVM host support") in
     v5.7.1. CONFIG_KVM is not enabled as part of allmodconfig or
     alldefconfig, but axm55xx_defconfig explicitly does enable it.
     Adjusted arch/arm/vfp/vfphw.S due to conflict with
     commit a47b395 ("ARM: 9030/1: entry: omit FP emulation for UND
     exceptions taken in kernel mode").]
Bug: 141693040
Signed-off-by: Nick Desaulniers <[email protected]>
(cherry picked from commit 5208d4f)
Signed-off-by: TogoFire <[email protected]>
awakened1712 pushed a commit to aospa-pp/android_kernel_oneplus_sm8350 that referenced this issue Feb 11, 2024
commit 2cbd1cc3dcd3e84be1fc1987da24b190ddf24a70 upstream.

The integrated assembler of Clang 10 and earlier do not allow to access
the VFP registers through the coprocessor load/store instructions:
arch/arm/vfp/vfpmodule.c:342:2: error: invalid operand for instruction
        fmxr(FPEXC, fpexc & ~(FPEXC_EX|FPEXC_DEX|FPEXC_FP2V|FPEXC_VV|FPEXC_TRAP_MASK));
        ^
arch/arm/vfp/vfpinstr.h:79:6: note: expanded from macro 'fmxr'
        asm("mcr p10, 7, %0, " vfpreg(_vfp_) ", cr0, 0 @ fmxr   " #_vfp_ ", %0"
            ^
<inline asm>:1:6: note: instantiated into assembly here
        mcr p10, 7, r0, cr8, cr0, 0 @ fmxr      FPEXC, r0
            ^

This has been addressed with Clang 11 [0]. However, to support earlier
versions of Clang and for better readability use of VFP assembler
mnemonics still is preferred.

Ideally we would replace this code with the unified assembler language
mnemonics vmrs/vmsr on call sites along with .fpu assembler directives.
The GNU assembler supports the .fpu directive at least since 2.17 (when
documentation has been added). Since Linux requires binutils 2.21 it is
safe to use .fpu directive. However, binutils does not allow to use
FPINST or FPINST2 as an argument to vmrs/vmsr instructions up to
binutils 2.24 (see binutils commit 16d02dc907c5):
arch/arm/vfp/vfphw.S: Assembler messages:
arch/arm/vfp/vfphw.S:162: Error: operand 0 must be FPSID or FPSCR pr FPEXC -- `vmsr FPINST,r6'
arch/arm/vfp/vfphw.S:165: Error: operand 0 must be FPSID or FPSCR pr FPEXC -- `vmsr FPINST2,r8'
arch/arm/vfp/vfphw.S:235: Error: operand 1 must be a VFP extension System Register -- `vmrs r3,FPINST'
arch/arm/vfp/vfphw.S:238: Error: operand 1 must be a VFP extension System Register -- `vmrs r12,FPINST2'

Use as-instr in Kconfig to check if FPINST/FPINST2 can be used. If they
can be used make use of .fpu directives and UAL VFP mnemonics for
register access.

This allows to build vfpmodule.c with Clang and its integrated assembler.

[0] https://reviews.llvm.org/D59733

Link: ClangBuiltLinux/linux#905

Signed-off-by: Stefan Agner <[email protected]>
Signed-off-by: Russell King <[email protected]>
[nd: Adjusted hunk from arch/arm/Kconfig due to missing
     commit 8a90a3228b6a ("arm: Unplug KVM from the build system").
     Replace __ACCESS_VFP with fmrx/fmxr for arch/arm/kvm/switch.c.
     CONFIG_KVM was removed in
     commit 541ad0150ca4 ("arm: Remove 32bit KVM host support") in
     v5.7.1. CONFIG_KVM is not enabled as part of allmodconfig or
     alldefconfig, but axm55xx_defconfig explicitly does enable it.
     Adjusted arch/arm/vfp/vfphw.S due to conflict with
     commit a47b395 ("ARM: 9030/1: entry: omit FP emulation for UND
     exceptions taken in kernel mode").]
Bug: 141693040
Signed-off-by: Nick Desaulniers <[email protected]>
Change-Id: I84733bd8649784e1e636e107c1dac03ef7d48136
markakash pushed a commit to AOSP-KONA-MSMNILE-LAHAINA-KALAMA/kernel_xiaomi_sm8350 that referenced this issue Feb 12, 2024
commit 2cbd1cc3dcd3e84be1fc1987da24b190ddf24a70 upstream.

The integrated assembler of Clang 10 and earlier do not allow to access
the VFP registers through the coprocessor load/store instructions:
arch/arm/vfp/vfpmodule.c:342:2: error: invalid operand for instruction
        fmxr(FPEXC, fpexc & ~(FPEXC_EX|FPEXC_DEX|FPEXC_FP2V|FPEXC_VV|FPEXC_TRAP_MASK));
        ^
arch/arm/vfp/vfpinstr.h:79:6: note: expanded from macro 'fmxr'
        asm("mcr p10, 7, %0, " vfpreg(_vfp_) ", cr0, 0 @ fmxr   " #_vfp_ ", %0"
            ^
<inline asm>:1:6: note: instantiated into assembly here
        mcr p10, 7, r0, cr8, cr0, 0 @ fmxr      FPEXC, r0
            ^

This has been addressed with Clang 11 [0]. However, to support earlier
versions of Clang and for better readability use of VFP assembler
mnemonics still is preferred.

Ideally we would replace this code with the unified assembler language
mnemonics vmrs/vmsr on call sites along with .fpu assembler directives.
The GNU assembler supports the .fpu directive at least since 2.17 (when
documentation has been added). Since Linux requires binutils 2.21 it is
safe to use .fpu directive. However, binutils does not allow to use
FPINST or FPINST2 as an argument to vmrs/vmsr instructions up to
binutils 2.24 (see binutils commit 16d02dc907c5):
arch/arm/vfp/vfphw.S: Assembler messages:
arch/arm/vfp/vfphw.S:162: Error: operand 0 must be FPSID or FPSCR pr FPEXC -- `vmsr FPINST,r6'
arch/arm/vfp/vfphw.S:165: Error: operand 0 must be FPSID or FPSCR pr FPEXC -- `vmsr FPINST2,r8'
arch/arm/vfp/vfphw.S:235: Error: operand 1 must be a VFP extension System Register -- `vmrs r3,FPINST'
arch/arm/vfp/vfphw.S:238: Error: operand 1 must be a VFP extension System Register -- `vmrs r12,FPINST2'

Use as-instr in Kconfig to check if FPINST/FPINST2 can be used. If they
can be used make use of .fpu directives and UAL VFP mnemonics for
register access.

This allows to build vfpmodule.c with Clang and its integrated assembler.

[0] https://reviews.llvm.org/D59733

Link: ClangBuiltLinux/linux#905

Signed-off-by: Stefan Agner <[email protected]>
Signed-off-by: Russell King <[email protected]>
[nd: Adjusted hunk from arch/arm/Kconfig due to missing
     commit 8a90a3228b6a ("arm: Unplug KVM from the build system").
     Replace __ACCESS_VFP with fmrx/fmxr for arch/arm/kvm/switch.c.
     CONFIG_KVM was removed in
     commit 541ad0150ca4 ("arm: Remove 32bit KVM host support") in
     v5.7.1. CONFIG_KVM is not enabled as part of allmodconfig or
     alldefconfig, but axm55xx_defconfig explicitly does enable it.
     Adjusted arch/arm/vfp/vfphw.S due to conflict with
     commit a47b395 ("ARM: 9030/1: entry: omit FP emulation for UND
     exceptions taken in kernel mode").]
Bug: 141693040
Signed-off-by: Nick Desaulniers <[email protected]>
Change-Id: I84733bd8649784e1e636e107c1dac03ef7d48136
Pascoato pushed a commit to Pascoato/android_kernel_xiaomi_lahaina that referenced this issue Feb 18, 2024
commit 2cbd1cc3dcd3e84be1fc1987da24b190ddf24a70 upstream.

The integrated assembler of Clang 10 and earlier do not allow to access
the VFP registers through the coprocessor load/store instructions:
arch/arm/vfp/vfpmodule.c:342:2: error: invalid operand for instruction
        fmxr(FPEXC, fpexc & ~(FPEXC_EX|FPEXC_DEX|FPEXC_FP2V|FPEXC_VV|FPEXC_TRAP_MASK));
        ^
arch/arm/vfp/vfpinstr.h:79:6: note: expanded from macro 'fmxr'
        asm("mcr p10, 7, %0, " vfpreg(_vfp_) ", cr0, 0 @ fmxr   " #_vfp_ ", %0"
            ^
<inline asm>:1:6: note: instantiated into assembly here
        mcr p10, 7, r0, cr8, cr0, 0 @ fmxr      FPEXC, r0
            ^

This has been addressed with Clang 11 [0]. However, to support earlier
versions of Clang and for better readability use of VFP assembler
mnemonics still is preferred.

Ideally we would replace this code with the unified assembler language
mnemonics vmrs/vmsr on call sites along with .fpu assembler directives.
The GNU assembler supports the .fpu directive at least since 2.17 (when
documentation has been added). Since Linux requires binutils 2.21 it is
safe to use .fpu directive. However, binutils does not allow to use
FPINST or FPINST2 as an argument to vmrs/vmsr instructions up to
binutils 2.24 (see binutils commit 16d02dc907c5):
arch/arm/vfp/vfphw.S: Assembler messages:
arch/arm/vfp/vfphw.S:162: Error: operand 0 must be FPSID or FPSCR pr FPEXC -- `vmsr FPINST,r6'
arch/arm/vfp/vfphw.S:165: Error: operand 0 must be FPSID or FPSCR pr FPEXC -- `vmsr FPINST2,r8'
arch/arm/vfp/vfphw.S:235: Error: operand 1 must be a VFP extension System Register -- `vmrs r3,FPINST'
arch/arm/vfp/vfphw.S:238: Error: operand 1 must be a VFP extension System Register -- `vmrs r12,FPINST2'

Use as-instr in Kconfig to check if FPINST/FPINST2 can be used. If they
can be used make use of .fpu directives and UAL VFP mnemonics for
register access.

This allows to build vfpmodule.c with Clang and its integrated assembler.

[0] https://reviews.llvm.org/D59733

Link: ClangBuiltLinux/linux#905

[nd: Adjusted hunk from arch/arm/Kconfig due to missing
     commit 8a90a3228b6a ("arm: Unplug KVM from the build system").
     Replace __ACCESS_VFP with fmrx/fmxr for arch/arm/kvm/switch.c.
     CONFIG_KVM was removed in
     commit 541ad0150ca4 ("arm: Remove 32bit KVM host support") in
     v5.7.1. CONFIG_KVM is not enabled as part of allmodconfig or
     alldefconfig, but axm55xx_defconfig explicitly does enable it.
     Adjusted arch/arm/vfp/vfphw.S due to conflict with
     commit a47b395 ("ARM: 9030/1: entry: omit FP emulation for UND
     exceptions taken in kernel mode").]
Bug: 141693040
Change-Id: I84733bd8649784e1e636e107c1dac03ef7d48136

Change-Id: I1cf2b486cefd5805c0be8716b86b43e2cc0caf4a
awakened1712 pushed a commit to aospa-pp/android_kernel_oneplus_sm8350 that referenced this issue Feb 22, 2024
commit 2cbd1cc3dcd3e84be1fc1987da24b190ddf24a70 upstream.

The integrated assembler of Clang 10 and earlier do not allow to access
the VFP registers through the coprocessor load/store instructions:
arch/arm/vfp/vfpmodule.c:342:2: error: invalid operand for instruction
        fmxr(FPEXC, fpexc & ~(FPEXC_EX|FPEXC_DEX|FPEXC_FP2V|FPEXC_VV|FPEXC_TRAP_MASK));
        ^
arch/arm/vfp/vfpinstr.h:79:6: note: expanded from macro 'fmxr'
        asm("mcr p10, 7, %0, " vfpreg(_vfp_) ", cr0, 0 @ fmxr   " #_vfp_ ", %0"
            ^
<inline asm>:1:6: note: instantiated into assembly here
        mcr p10, 7, r0, cr8, cr0, 0 @ fmxr      FPEXC, r0
            ^

This has been addressed with Clang 11 [0]. However, to support earlier
versions of Clang and for better readability use of VFP assembler
mnemonics still is preferred.

Ideally we would replace this code with the unified assembler language
mnemonics vmrs/vmsr on call sites along with .fpu assembler directives.
The GNU assembler supports the .fpu directive at least since 2.17 (when
documentation has been added). Since Linux requires binutils 2.21 it is
safe to use .fpu directive. However, binutils does not allow to use
FPINST or FPINST2 as an argument to vmrs/vmsr instructions up to
binutils 2.24 (see binutils commit 16d02dc907c5):
arch/arm/vfp/vfphw.S: Assembler messages:
arch/arm/vfp/vfphw.S:162: Error: operand 0 must be FPSID or FPSCR pr FPEXC -- `vmsr FPINST,r6'
arch/arm/vfp/vfphw.S:165: Error: operand 0 must be FPSID or FPSCR pr FPEXC -- `vmsr FPINST2,r8'
arch/arm/vfp/vfphw.S:235: Error: operand 1 must be a VFP extension System Register -- `vmrs r3,FPINST'
arch/arm/vfp/vfphw.S:238: Error: operand 1 must be a VFP extension System Register -- `vmrs r12,FPINST2'

Use as-instr in Kconfig to check if FPINST/FPINST2 can be used. If they
can be used make use of .fpu directives and UAL VFP mnemonics for
register access.

This allows to build vfpmodule.c with Clang and its integrated assembler.

[0] https://reviews.llvm.org/D59733

Link: ClangBuiltLinux/linux#905

Signed-off-by: Stefan Agner <[email protected]>
Signed-off-by: Russell King <[email protected]>
[nd: Adjusted hunk from arch/arm/Kconfig due to missing
     commit 8a90a3228b6a ("arm: Unplug KVM from the build system").
     Replace __ACCESS_VFP with fmrx/fmxr for arch/arm/kvm/switch.c.
     CONFIG_KVM was removed in
     commit 541ad0150ca4 ("arm: Remove 32bit KVM host support") in
     v5.7.1. CONFIG_KVM is not enabled as part of allmodconfig or
     alldefconfig, but axm55xx_defconfig explicitly does enable it.
     Adjusted arch/arm/vfp/vfphw.S due to conflict with
     commit a47b395 ("ARM: 9030/1: entry: omit FP emulation for UND
     exceptions taken in kernel mode").]
Bug: 141693040
Signed-off-by: Nick Desaulniers <[email protected]>
Change-Id: I84733bd8649784e1e636e107c1dac03ef7d48136
glikched pushed a commit to glikched/android_kernel_samsung_sm8350 that referenced this issue Feb 23, 2024
commit 2cbd1cc3dcd3e84be1fc1987da24b190ddf24a70 upstream.

The integrated assembler of Clang 10 and earlier do not allow to access
the VFP registers through the coprocessor load/store instructions:
arch/arm/vfp/vfpmodule.c:342:2: error: invalid operand for instruction
        fmxr(FPEXC, fpexc & ~(FPEXC_EX|FPEXC_DEX|FPEXC_FP2V|FPEXC_VV|FPEXC_TRAP_MASK));
        ^
arch/arm/vfp/vfpinstr.h:79:6: note: expanded from macro 'fmxr'
        asm("mcr p10, 7, %0, " vfpreg(_vfp_) ", cr0, 0 @ fmxr   " #_vfp_ ", %0"
            ^
<inline asm>:1:6: note: instantiated into assembly here
        mcr p10, 7, r0, cr8, cr0, 0 @ fmxr      FPEXC, r0
            ^

This has been addressed with Clang 11 [0]. However, to support earlier
versions of Clang and for better readability use of VFP assembler
mnemonics still is preferred.

Ideally we would replace this code with the unified assembler language
mnemonics vmrs/vmsr on call sites along with .fpu assembler directives.
The GNU assembler supports the .fpu directive at least since 2.17 (when
documentation has been added). Since Linux requires binutils 2.21 it is
safe to use .fpu directive. However, binutils does not allow to use
FPINST or FPINST2 as an argument to vmrs/vmsr instructions up to
binutils 2.24 (see binutils commit 16d02dc907c5):
arch/arm/vfp/vfphw.S: Assembler messages:
arch/arm/vfp/vfphw.S:162: Error: operand 0 must be FPSID or FPSCR pr FPEXC -- `vmsr FPINST,r6'
arch/arm/vfp/vfphw.S:165: Error: operand 0 must be FPSID or FPSCR pr FPEXC -- `vmsr FPINST2,r8'
arch/arm/vfp/vfphw.S:235: Error: operand 1 must be a VFP extension System Register -- `vmrs r3,FPINST'
arch/arm/vfp/vfphw.S:238: Error: operand 1 must be a VFP extension System Register -- `vmrs r12,FPINST2'

Use as-instr in Kconfig to check if FPINST/FPINST2 can be used. If they
can be used make use of .fpu directives and UAL VFP mnemonics for
register access.

This allows to build vfpmodule.c with Clang and its integrated assembler.

[0] https://reviews.llvm.org/D59733

Link: ClangBuiltLinux/linux#905

Signed-off-by: Stefan Agner <[email protected]>
Change-Id: I4556fb88e294a4501a2112088c3997f29d40feb3
Signed-off-by: Russell King <[email protected]>
[nd: Adjusted hunk from arch/arm/Kconfig due to missing
     commit 8a90a3228b6a ("arm: Unplug KVM from the build system").
     Replace __ACCESS_VFP with fmrx/fmxr for arch/arm/kvm/switch.c.
     CONFIG_KVM was removed in
     commit 541ad0150ca4 ("arm: Remove 32bit KVM host support") in
     v5.7.1. CONFIG_KVM is not enabled as part of allmodconfig or
     alldefconfig, but axm55xx_defconfig explicitly does enable it.
     Adjusted arch/arm/vfp/vfphw.S due to conflict with
     commit a47b395 ("ARM: 9030/1: entry: omit FP emulation for UND
     exceptions taken in kernel mode").]
Bug: 141693040
Signed-off-by: Nick Desaulniers <[email protected]>
(cherry picked from commit 5208d4f108cff264abc2cc968c3c91d76e08a301)
Signed-off-by: TogoFire <[email protected]>
Pascoato pushed a commit to Pascoato/android_kernel_xiaomi_lahaina that referenced this issue Feb 24, 2024
commit 2cbd1cc3dcd3e84be1fc1987da24b190ddf24a70 upstream.

The integrated assembler of Clang 10 and earlier do not allow to access
the VFP registers through the coprocessor load/store instructions:
arch/arm/vfp/vfpmodule.c:342:2: error: invalid operand for instruction
        fmxr(FPEXC, fpexc & ~(FPEXC_EX|FPEXC_DEX|FPEXC_FP2V|FPEXC_VV|FPEXC_TRAP_MASK));
        ^
arch/arm/vfp/vfpinstr.h:79:6: note: expanded from macro 'fmxr'
        asm("mcr p10, 7, %0, " vfpreg(_vfp_) ", cr0, 0 @ fmxr   " #_vfp_ ", %0"
            ^
<inline asm>:1:6: note: instantiated into assembly here
        mcr p10, 7, r0, cr8, cr0, 0 @ fmxr      FPEXC, r0
            ^

This has been addressed with Clang 11 [0]. However, to support earlier
versions of Clang and for better readability use of VFP assembler
mnemonics still is preferred.

Ideally we would replace this code with the unified assembler language
mnemonics vmrs/vmsr on call sites along with .fpu assembler directives.
The GNU assembler supports the .fpu directive at least since 2.17 (when
documentation has been added). Since Linux requires binutils 2.21 it is
safe to use .fpu directive. However, binutils does not allow to use
FPINST or FPINST2 as an argument to vmrs/vmsr instructions up to
binutils 2.24 (see binutils commit 16d02dc907c5):
arch/arm/vfp/vfphw.S: Assembler messages:
arch/arm/vfp/vfphw.S:162: Error: operand 0 must be FPSID or FPSCR pr FPEXC -- `vmsr FPINST,r6'
arch/arm/vfp/vfphw.S:165: Error: operand 0 must be FPSID or FPSCR pr FPEXC -- `vmsr FPINST2,r8'
arch/arm/vfp/vfphw.S:235: Error: operand 1 must be a VFP extension System Register -- `vmrs r3,FPINST'
arch/arm/vfp/vfphw.S:238: Error: operand 1 must be a VFP extension System Register -- `vmrs r12,FPINST2'

Use as-instr in Kconfig to check if FPINST/FPINST2 can be used. If they
can be used make use of .fpu directives and UAL VFP mnemonics for
register access.

This allows to build vfpmodule.c with Clang and its integrated assembler.

[0] https://reviews.llvm.org/D59733

Link: ClangBuiltLinux/linux#905

[nd: Adjusted hunk from arch/arm/Kconfig due to missing
     commit 8a90a3228b6a ("arm: Unplug KVM from the build system").
     Replace __ACCESS_VFP with fmrx/fmxr for arch/arm/kvm/switch.c.
     CONFIG_KVM was removed in
     commit 541ad0150ca4 ("arm: Remove 32bit KVM host support") in
     v5.7.1. CONFIG_KVM is not enabled as part of allmodconfig or
     alldefconfig, but axm55xx_defconfig explicitly does enable it.
     Adjusted arch/arm/vfp/vfphw.S due to conflict with
     commit a47b395 ("ARM: 9030/1: entry: omit FP emulation for UND
     exceptions taken in kernel mode").]
Bug: 141693040
Change-Id: I84733bd8649784e1e636e107c1dac03ef7d48136

Change-Id: I1cf2b486cefd5805c0be8716b86b43e2cc0caf4a
Pascoato pushed a commit to Pascoato/android_kernel_xiaomi_lahaina that referenced this issue Feb 24, 2024
commit 2cbd1cc3dcd3e84be1fc1987da24b190ddf24a70 upstream.

The integrated assembler of Clang 10 and earlier do not allow to access
the VFP registers through the coprocessor load/store instructions:
arch/arm/vfp/vfpmodule.c:342:2: error: invalid operand for instruction
        fmxr(FPEXC, fpexc & ~(FPEXC_EX|FPEXC_DEX|FPEXC_FP2V|FPEXC_VV|FPEXC_TRAP_MASK));
        ^
arch/arm/vfp/vfpinstr.h:79:6: note: expanded from macro 'fmxr'
        asm("mcr p10, 7, %0, " vfpreg(_vfp_) ", cr0, 0 @ fmxr   " #_vfp_ ", %0"
            ^
<inline asm>:1:6: note: instantiated into assembly here
        mcr p10, 7, r0, cr8, cr0, 0 @ fmxr      FPEXC, r0
            ^

This has been addressed with Clang 11 [0]. However, to support earlier
versions of Clang and for better readability use of VFP assembler
mnemonics still is preferred.

Ideally we would replace this code with the unified assembler language
mnemonics vmrs/vmsr on call sites along with .fpu assembler directives.
The GNU assembler supports the .fpu directive at least since 2.17 (when
documentation has been added). Since Linux requires binutils 2.21 it is
safe to use .fpu directive. However, binutils does not allow to use
FPINST or FPINST2 as an argument to vmrs/vmsr instructions up to
binutils 2.24 (see binutils commit 16d02dc907c5):
arch/arm/vfp/vfphw.S: Assembler messages:
arch/arm/vfp/vfphw.S:162: Error: operand 0 must be FPSID or FPSCR pr FPEXC -- `vmsr FPINST,r6'
arch/arm/vfp/vfphw.S:165: Error: operand 0 must be FPSID or FPSCR pr FPEXC -- `vmsr FPINST2,r8'
arch/arm/vfp/vfphw.S:235: Error: operand 1 must be a VFP extension System Register -- `vmrs r3,FPINST'
arch/arm/vfp/vfphw.S:238: Error: operand 1 must be a VFP extension System Register -- `vmrs r12,FPINST2'

Use as-instr in Kconfig to check if FPINST/FPINST2 can be used. If they
can be used make use of .fpu directives and UAL VFP mnemonics for
register access.

This allows to build vfpmodule.c with Clang and its integrated assembler.

[0] https://reviews.llvm.org/D59733

Link: ClangBuiltLinux/linux#905

[nd: Adjusted hunk from arch/arm/Kconfig due to missing
     commit 8a90a3228b6a ("arm: Unplug KVM from the build system").
     Replace __ACCESS_VFP with fmrx/fmxr for arch/arm/kvm/switch.c.
     CONFIG_KVM was removed in
     commit 541ad0150ca4 ("arm: Remove 32bit KVM host support") in
     v5.7.1. CONFIG_KVM is not enabled as part of allmodconfig or
     alldefconfig, but axm55xx_defconfig explicitly does enable it.
     Adjusted arch/arm/vfp/vfphw.S due to conflict with
     commit a47b395 ("ARM: 9030/1: entry: omit FP emulation for UND
     exceptions taken in kernel mode").]
Bug: 141693040
Change-Id: I84733bd8649784e1e636e107c1dac03ef7d48136

Change-Id: I1cf2b486cefd5805c0be8716b86b43e2cc0caf4a
TogoFire pushed a commit to dev-sm8350/kernel_oneplus_sm8350 that referenced this issue Feb 25, 2024
commit 2cbd1cc upstream.

The integrated assembler of Clang 10 and earlier do not allow to access
the VFP registers through the coprocessor load/store instructions:
arch/arm/vfp/vfpmodule.c:342:2: error: invalid operand for instruction
        fmxr(FPEXC, fpexc & ~(FPEXC_EX|FPEXC_DEX|FPEXC_FP2V|FPEXC_VV|FPEXC_TRAP_MASK));
        ^
arch/arm/vfp/vfpinstr.h:79:6: note: expanded from macro 'fmxr'
        asm("mcr p10, 7, %0, " vfpreg(_vfp_) ", cr0, 0 @ fmxr   " #_vfp_ ", %0"
            ^
<inline asm>:1:6: note: instantiated into assembly here
        mcr p10, 7, r0, cr8, cr0, 0 @ fmxr      FPEXC, r0
            ^

This has been addressed with Clang 11 [0]. However, to support earlier
versions of Clang and for better readability use of VFP assembler
mnemonics still is preferred.

Ideally we would replace this code with the unified assembler language
mnemonics vmrs/vmsr on call sites along with .fpu assembler directives.
The GNU assembler supports the .fpu directive at least since 2.17 (when
documentation has been added). Since Linux requires binutils 2.21 it is
safe to use .fpu directive. However, binutils does not allow to use
FPINST or FPINST2 as an argument to vmrs/vmsr instructions up to
binutils 2.24 (see binutils commit 16d02dc907c5):
arch/arm/vfp/vfphw.S: Assembler messages:
arch/arm/vfp/vfphw.S:162: Error: operand 0 must be FPSID or FPSCR pr FPEXC -- `vmsr FPINST,r6'
arch/arm/vfp/vfphw.S:165: Error: operand 0 must be FPSID or FPSCR pr FPEXC -- `vmsr FPINST2,r8'
arch/arm/vfp/vfphw.S:235: Error: operand 1 must be a VFP extension System Register -- `vmrs r3,FPINST'
arch/arm/vfp/vfphw.S:238: Error: operand 1 must be a VFP extension System Register -- `vmrs r12,FPINST2'

Use as-instr in Kconfig to check if FPINST/FPINST2 can be used. If they
can be used make use of .fpu directives and UAL VFP mnemonics for
register access.

This allows to build vfpmodule.c with Clang and its integrated assembler.

[0] https://reviews.llvm.org/D59733

Link: ClangBuiltLinux/linux#905

Signed-off-by: Stefan Agner <[email protected]>
Change-Id: Ibe43b4f40e924759f9a6bca4a7a7ae7cea473077
Signed-off-by: Russell King <[email protected]>
[nd: Adjusted hunk from arch/arm/Kconfig due to missing
     commit 8a90a32 ("arm: Unplug KVM from the build system").
     Replace __ACCESS_VFP with fmrx/fmxr for arch/arm/kvm/switch.c.
     CONFIG_KVM was removed in
     commit 541ad01 ("arm: Remove 32bit KVM host support") in
     v5.7.1. CONFIG_KVM is not enabled as part of allmodconfig or
     alldefconfig, but axm55xx_defconfig explicitly does enable it.
     Adjusted arch/arm/vfp/vfphw.S due to conflict with
     commit a47b395 ("ARM: 9030/1: entry: omit FP emulation for UND
     exceptions taken in kernel mode").]
Bug: 141693040
Signed-off-by: Nick Desaulniers <[email protected]>
(cherry picked from commit 5208d4f)
Signed-off-by: TogoFire <[email protected]>
Pascoato pushed a commit to Pascoato/android_kernel_xiaomi_lahaina that referenced this issue Mar 15, 2024
commit 2cbd1cc3dcd3e84be1fc1987da24b190ddf24a70 upstream.

The integrated assembler of Clang 10 and earlier do not allow to access
the VFP registers through the coprocessor load/store instructions:
arch/arm/vfp/vfpmodule.c:342:2: error: invalid operand for instruction
        fmxr(FPEXC, fpexc & ~(FPEXC_EX|FPEXC_DEX|FPEXC_FP2V|FPEXC_VV|FPEXC_TRAP_MASK));
        ^
arch/arm/vfp/vfpinstr.h:79:6: note: expanded from macro 'fmxr'
        asm("mcr p10, 7, %0, " vfpreg(_vfp_) ", cr0, 0 @ fmxr   " #_vfp_ ", %0"
            ^
<inline asm>:1:6: note: instantiated into assembly here
        mcr p10, 7, r0, cr8, cr0, 0 @ fmxr      FPEXC, r0
            ^

This has been addressed with Clang 11 [0]. However, to support earlier
versions of Clang and for better readability use of VFP assembler
mnemonics still is preferred.

Ideally we would replace this code with the unified assembler language
mnemonics vmrs/vmsr on call sites along with .fpu assembler directives.
The GNU assembler supports the .fpu directive at least since 2.17 (when
documentation has been added). Since Linux requires binutils 2.21 it is
safe to use .fpu directive. However, binutils does not allow to use
FPINST or FPINST2 as an argument to vmrs/vmsr instructions up to
binutils 2.24 (see binutils commit 16d02dc907c5):
arch/arm/vfp/vfphw.S: Assembler messages:
arch/arm/vfp/vfphw.S:162: Error: operand 0 must be FPSID or FPSCR pr FPEXC -- `vmsr FPINST,r6'
arch/arm/vfp/vfphw.S:165: Error: operand 0 must be FPSID or FPSCR pr FPEXC -- `vmsr FPINST2,r8'
arch/arm/vfp/vfphw.S:235: Error: operand 1 must be a VFP extension System Register -- `vmrs r3,FPINST'
arch/arm/vfp/vfphw.S:238: Error: operand 1 must be a VFP extension System Register -- `vmrs r12,FPINST2'

Use as-instr in Kconfig to check if FPINST/FPINST2 can be used. If they
can be used make use of .fpu directives and UAL VFP mnemonics for
register access.

This allows to build vfpmodule.c with Clang and its integrated assembler.

[0] https://reviews.llvm.org/D59733

Link: ClangBuiltLinux/linux#905

[nd: Adjusted hunk from arch/arm/Kconfig due to missing
     commit 8a90a3228b6a ("arm: Unplug KVM from the build system").
     Replace __ACCESS_VFP with fmrx/fmxr for arch/arm/kvm/switch.c.
     CONFIG_KVM was removed in
     commit 541ad0150ca4 ("arm: Remove 32bit KVM host support") in
     v5.7.1. CONFIG_KVM is not enabled as part of allmodconfig or
     alldefconfig, but axm55xx_defconfig explicitly does enable it.
     Adjusted arch/arm/vfp/vfphw.S due to conflict with
     commit a47b395 ("ARM: 9030/1: entry: omit FP emulation for UND
     exceptions taken in kernel mode").]
Bug: 141693040
Change-Id: I84733bd8649784e1e636e107c1dac03ef7d48136

Change-Id: I1cf2b486cefd5805c0be8716b86b43e2cc0caf4a
pa-gerrit pushed a commit to AOSPA/android_kernel_nothing_sm7325 that referenced this issue Apr 14, 2024
commit 2cbd1cc3dcd3e84be1fc1987da24b190ddf24a70 upstream.

The integrated assembler of Clang 10 and earlier do not allow to access
the VFP registers through the coprocessor load/store instructions:
arch/arm/vfp/vfpmodule.c:342:2: error: invalid operand for instruction
        fmxr(FPEXC, fpexc & ~(FPEXC_EX|FPEXC_DEX|FPEXC_FP2V|FPEXC_VV|FPEXC_TRAP_MASK));
        ^
arch/arm/vfp/vfpinstr.h:79:6: note: expanded from macro 'fmxr'
        asm("mcr p10, 7, %0, " vfpreg(_vfp_) ", cr0, 0 @ fmxr   " #_vfp_ ", %0"
            ^
<inline asm>:1:6: note: instantiated into assembly here
        mcr p10, 7, r0, cr8, cr0, 0 @ fmxr      FPEXC, r0
            ^

This has been addressed with Clang 11 [0]. However, to support earlier
versions of Clang and for better readability use of VFP assembler
mnemonics still is preferred.

Ideally we would replace this code with the unified assembler language
mnemonics vmrs/vmsr on call sites along with .fpu assembler directives.
The GNU assembler supports the .fpu directive at least since 2.17 (when
documentation has been added). Since Linux requires binutils 2.21 it is
safe to use .fpu directive. However, binutils does not allow to use
FPINST or FPINST2 as an argument to vmrs/vmsr instructions up to
binutils 2.24 (see binutils commit 16d02dc907c5):
arch/arm/vfp/vfphw.S: Assembler messages:
arch/arm/vfp/vfphw.S:162: Error: operand 0 must be FPSID or FPSCR pr FPEXC -- `vmsr FPINST,r6'
arch/arm/vfp/vfphw.S:165: Error: operand 0 must be FPSID or FPSCR pr FPEXC -- `vmsr FPINST2,r8'
arch/arm/vfp/vfphw.S:235: Error: operand 1 must be a VFP extension System Register -- `vmrs r3,FPINST'
arch/arm/vfp/vfphw.S:238: Error: operand 1 must be a VFP extension System Register -- `vmrs r12,FPINST2'

Use as-instr in Kconfig to check if FPINST/FPINST2 can be used. If they
can be used make use of .fpu directives and UAL VFP mnemonics for
register access.

This allows to build vfpmodule.c with Clang and its integrated assembler.

[0] https://reviews.llvm.org/D59733

Link: ClangBuiltLinux/linux#905

Signed-off-by: Stefan Agner <[email protected]>
Signed-off-by: Russell King <[email protected]>
[nd: Adjusted hunk from arch/arm/Kconfig due to missing
     commit 8a90a3228b6a ("arm: Unplug KVM from the build system").
     Replace __ACCESS_VFP with fmrx/fmxr for arch/arm/kvm/switch.c.
     CONFIG_KVM was removed in
     commit 541ad0150ca4 ("arm: Remove 32bit KVM host support") in
     v5.7.1. CONFIG_KVM is not enabled as part of allmodconfig or
     alldefconfig, but axm55xx_defconfig explicitly does enable it.
     Adjusted arch/arm/vfp/vfphw.S due to conflict with
     commit a47b395 ("ARM: 9030/1: entry: omit FP emulation for UND
     exceptions taken in kernel mode").]
Bug: 141693040
Signed-off-by: Nick Desaulniers <[email protected]>
Change-Id: I84733bd8649784e1e636e107c1dac03ef7d48136
gotenksIN pushed a commit to gotenksIN/android_kernel_nothing_sm7325 that referenced this issue Apr 17, 2024
commit 2cbd1cc3dcd3e84be1fc1987da24b190ddf24a70 upstream.

The integrated assembler of Clang 10 and earlier do not allow to access
the VFP registers through the coprocessor load/store instructions:
arch/arm/vfp/vfpmodule.c:342:2: error: invalid operand for instruction
        fmxr(FPEXC, fpexc & ~(FPEXC_EX|FPEXC_DEX|FPEXC_FP2V|FPEXC_VV|FPEXC_TRAP_MASK));
        ^
arch/arm/vfp/vfpinstr.h:79:6: note: expanded from macro 'fmxr'
        asm("mcr p10, 7, %0, " vfpreg(_vfp_) ", cr0, 0 @ fmxr   " #_vfp_ ", %0"
            ^
<inline asm>:1:6: note: instantiated into assembly here
        mcr p10, 7, r0, cr8, cr0, 0 @ fmxr      FPEXC, r0
            ^

This has been addressed with Clang 11 [0]. However, to support earlier
versions of Clang and for better readability use of VFP assembler
mnemonics still is preferred.

Ideally we would replace this code with the unified assembler language
mnemonics vmrs/vmsr on call sites along with .fpu assembler directives.
The GNU assembler supports the .fpu directive at least since 2.17 (when
documentation has been added). Since Linux requires binutils 2.21 it is
safe to use .fpu directive. However, binutils does not allow to use
FPINST or FPINST2 as an argument to vmrs/vmsr instructions up to
binutils 2.24 (see binutils commit 16d02dc907c5):
arch/arm/vfp/vfphw.S: Assembler messages:
arch/arm/vfp/vfphw.S:162: Error: operand 0 must be FPSID or FPSCR pr FPEXC -- `vmsr FPINST,r6'
arch/arm/vfp/vfphw.S:165: Error: operand 0 must be FPSID or FPSCR pr FPEXC -- `vmsr FPINST2,r8'
arch/arm/vfp/vfphw.S:235: Error: operand 1 must be a VFP extension System Register -- `vmrs r3,FPINST'
arch/arm/vfp/vfphw.S:238: Error: operand 1 must be a VFP extension System Register -- `vmrs r12,FPINST2'

Use as-instr in Kconfig to check if FPINST/FPINST2 can be used. If they
can be used make use of .fpu directives and UAL VFP mnemonics for
register access.

This allows to build vfpmodule.c with Clang and its integrated assembler.

[0] https://reviews.llvm.org/D59733

Link: ClangBuiltLinux/linux#905

Signed-off-by: Stefan Agner <[email protected]>
Signed-off-by: Russell King <[email protected]>
[nd: Adjusted hunk from arch/arm/Kconfig due to missing
     commit 8a90a3228b6a ("arm: Unplug KVM from the build system").
     Replace __ACCESS_VFP with fmrx/fmxr for arch/arm/kvm/switch.c.
     CONFIG_KVM was removed in
     commit 541ad0150ca4 ("arm: Remove 32bit KVM host support") in
     v5.7.1. CONFIG_KVM is not enabled as part of allmodconfig or
     alldefconfig, but axm55xx_defconfig explicitly does enable it.
     Adjusted arch/arm/vfp/vfphw.S due to conflict with
     commit a47b395 ("ARM: 9030/1: entry: omit FP emulation for UND
     exceptions taken in kernel mode").]
Bug: 141693040
Signed-off-by: Nick Desaulniers <[email protected]>
Change-Id: I84733bd8649784e1e636e107c1dac03ef7d48136
gotenksIN pushed a commit to gotenksIN/android_kernel_nothing_sm7325 that referenced this issue Apr 17, 2024
commit 2cbd1cc3dcd3e84be1fc1987da24b190ddf24a70 upstream.

The integrated assembler of Clang 10 and earlier do not allow to access
the VFP registers through the coprocessor load/store instructions:
arch/arm/vfp/vfpmodule.c:342:2: error: invalid operand for instruction
        fmxr(FPEXC, fpexc & ~(FPEXC_EX|FPEXC_DEX|FPEXC_FP2V|FPEXC_VV|FPEXC_TRAP_MASK));
        ^
arch/arm/vfp/vfpinstr.h:79:6: note: expanded from macro 'fmxr'
        asm("mcr p10, 7, %0, " vfpreg(_vfp_) ", cr0, 0 @ fmxr   " #_vfp_ ", %0"
            ^
<inline asm>:1:6: note: instantiated into assembly here
        mcr p10, 7, r0, cr8, cr0, 0 @ fmxr      FPEXC, r0
            ^

This has been addressed with Clang 11 [0]. However, to support earlier
versions of Clang and for better readability use of VFP assembler
mnemonics still is preferred.

Ideally we would replace this code with the unified assembler language
mnemonics vmrs/vmsr on call sites along with .fpu assembler directives.
The GNU assembler supports the .fpu directive at least since 2.17 (when
documentation has been added). Since Linux requires binutils 2.21 it is
safe to use .fpu directive. However, binutils does not allow to use
FPINST or FPINST2 as an argument to vmrs/vmsr instructions up to
binutils 2.24 (see binutils commit 16d02dc907c5):
arch/arm/vfp/vfphw.S: Assembler messages:
arch/arm/vfp/vfphw.S:162: Error: operand 0 must be FPSID or FPSCR pr FPEXC -- `vmsr FPINST,r6'
arch/arm/vfp/vfphw.S:165: Error: operand 0 must be FPSID or FPSCR pr FPEXC -- `vmsr FPINST2,r8'
arch/arm/vfp/vfphw.S:235: Error: operand 1 must be a VFP extension System Register -- `vmrs r3,FPINST'
arch/arm/vfp/vfphw.S:238: Error: operand 1 must be a VFP extension System Register -- `vmrs r12,FPINST2'

Use as-instr in Kconfig to check if FPINST/FPINST2 can be used. If they
can be used make use of .fpu directives and UAL VFP mnemonics for
register access.

This allows to build vfpmodule.c with Clang and its integrated assembler.

[0] https://reviews.llvm.org/D59733

Link: ClangBuiltLinux/linux#905

Signed-off-by: Stefan Agner <[email protected]>
Signed-off-by: Russell King <[email protected]>
[nd: Adjusted hunk from arch/arm/Kconfig due to missing
     commit 8a90a3228b6a ("arm: Unplug KVM from the build system").
     Replace __ACCESS_VFP with fmrx/fmxr for arch/arm/kvm/switch.c.
     CONFIG_KVM was removed in
     commit 541ad0150ca4 ("arm: Remove 32bit KVM host support") in
     v5.7.1. CONFIG_KVM is not enabled as part of allmodconfig or
     alldefconfig, but axm55xx_defconfig explicitly does enable it.
     Adjusted arch/arm/vfp/vfphw.S due to conflict with
     commit a47b395 ("ARM: 9030/1: entry: omit FP emulation for UND
     exceptions taken in kernel mode").]
Bug: 141693040
Signed-off-by: Nick Desaulniers <[email protected]>
Change-Id: I84733bd8649784e1e636e107c1dac03ef7d48136
pa-gerrit pushed a commit to AOSPA/android_kernel_nothing_sm7325 that referenced this issue Apr 18, 2024
commit 2cbd1cc3dcd3e84be1fc1987da24b190ddf24a70 upstream.

The integrated assembler of Clang 10 and earlier do not allow to access
the VFP registers through the coprocessor load/store instructions:
arch/arm/vfp/vfpmodule.c:342:2: error: invalid operand for instruction
        fmxr(FPEXC, fpexc & ~(FPEXC_EX|FPEXC_DEX|FPEXC_FP2V|FPEXC_VV|FPEXC_TRAP_MASK));
        ^
arch/arm/vfp/vfpinstr.h:79:6: note: expanded from macro 'fmxr'
        asm("mcr p10, 7, %0, " vfpreg(_vfp_) ", cr0, 0 @ fmxr   " #_vfp_ ", %0"
            ^
<inline asm>:1:6: note: instantiated into assembly here
        mcr p10, 7, r0, cr8, cr0, 0 @ fmxr      FPEXC, r0
            ^

This has been addressed with Clang 11 [0]. However, to support earlier
versions of Clang and for better readability use of VFP assembler
mnemonics still is preferred.

Ideally we would replace this code with the unified assembler language
mnemonics vmrs/vmsr on call sites along with .fpu assembler directives.
The GNU assembler supports the .fpu directive at least since 2.17 (when
documentation has been added). Since Linux requires binutils 2.21 it is
safe to use .fpu directive. However, binutils does not allow to use
FPINST or FPINST2 as an argument to vmrs/vmsr instructions up to
binutils 2.24 (see binutils commit 16d02dc907c5):
arch/arm/vfp/vfphw.S: Assembler messages:
arch/arm/vfp/vfphw.S:162: Error: operand 0 must be FPSID or FPSCR pr FPEXC -- `vmsr FPINST,r6'
arch/arm/vfp/vfphw.S:165: Error: operand 0 must be FPSID or FPSCR pr FPEXC -- `vmsr FPINST2,r8'
arch/arm/vfp/vfphw.S:235: Error: operand 1 must be a VFP extension System Register -- `vmrs r3,FPINST'
arch/arm/vfp/vfphw.S:238: Error: operand 1 must be a VFP extension System Register -- `vmrs r12,FPINST2'

Use as-instr in Kconfig to check if FPINST/FPINST2 can be used. If they
can be used make use of .fpu directives and UAL VFP mnemonics for
register access.

This allows to build vfpmodule.c with Clang and its integrated assembler.

[0] https://reviews.llvm.org/D59733

Link: ClangBuiltLinux/linux#905

Signed-off-by: Stefan Agner <[email protected]>
Signed-off-by: Russell King <[email protected]>
[nd: Adjusted hunk from arch/arm/Kconfig due to missing
     commit 8a90a3228b6a ("arm: Unplug KVM from the build system").
     Replace __ACCESS_VFP with fmrx/fmxr for arch/arm/kvm/switch.c.
     CONFIG_KVM was removed in
     commit 541ad0150ca4 ("arm: Remove 32bit KVM host support") in
     v5.7.1. CONFIG_KVM is not enabled as part of allmodconfig or
     alldefconfig, but axm55xx_defconfig explicitly does enable it.
     Adjusted arch/arm/vfp/vfphw.S due to conflict with
     commit a47b395 ("ARM: 9030/1: entry: omit FP emulation for UND
     exceptions taken in kernel mode").]
Bug: 141693040
Signed-off-by: Nick Desaulniers <[email protected]>
Change-Id: I84733bd8649784e1e636e107c1dac03ef7d48136
Pascoato pushed a commit to Pascoato/android_kernel_xiaomi_lahaina that referenced this issue May 7, 2024
commit 2cbd1cc3dcd3e84be1fc1987da24b190ddf24a70 upstream.

The integrated assembler of Clang 10 and earlier do not allow to access
the VFP registers through the coprocessor load/store instructions:
arch/arm/vfp/vfpmodule.c:342:2: error: invalid operand for instruction
        fmxr(FPEXC, fpexc & ~(FPEXC_EX|FPEXC_DEX|FPEXC_FP2V|FPEXC_VV|FPEXC_TRAP_MASK));
        ^
arch/arm/vfp/vfpinstr.h:79:6: note: expanded from macro 'fmxr'
        asm("mcr p10, 7, %0, " vfpreg(_vfp_) ", cr0, 0 @ fmxr   " #_vfp_ ", %0"
            ^
<inline asm>:1:6: note: instantiated into assembly here
        mcr p10, 7, r0, cr8, cr0, 0 @ fmxr      FPEXC, r0
            ^

This has been addressed with Clang 11 [0]. However, to support earlier
versions of Clang and for better readability use of VFP assembler
mnemonics still is preferred.

Ideally we would replace this code with the unified assembler language
mnemonics vmrs/vmsr on call sites along with .fpu assembler directives.
The GNU assembler supports the .fpu directive at least since 2.17 (when
documentation has been added). Since Linux requires binutils 2.21 it is
safe to use .fpu directive. However, binutils does not allow to use
FPINST or FPINST2 as an argument to vmrs/vmsr instructions up to
binutils 2.24 (see binutils commit 16d02dc907c5):
arch/arm/vfp/vfphw.S: Assembler messages:
arch/arm/vfp/vfphw.S:162: Error: operand 0 must be FPSID or FPSCR pr FPEXC -- `vmsr FPINST,r6'
arch/arm/vfp/vfphw.S:165: Error: operand 0 must be FPSID or FPSCR pr FPEXC -- `vmsr FPINST2,r8'
arch/arm/vfp/vfphw.S:235: Error: operand 1 must be a VFP extension System Register -- `vmrs r3,FPINST'
arch/arm/vfp/vfphw.S:238: Error: operand 1 must be a VFP extension System Register -- `vmrs r12,FPINST2'

Use as-instr in Kconfig to check if FPINST/FPINST2 can be used. If they
can be used make use of .fpu directives and UAL VFP mnemonics for
register access.

This allows to build vfpmodule.c with Clang and its integrated assembler.

[0] https://reviews.llvm.org/D59733

Link: ClangBuiltLinux/linux#905

[nd: Adjusted hunk from arch/arm/Kconfig due to missing
     commit 8a90a3228b6a ("arm: Unplug KVM from the build system").
     Replace __ACCESS_VFP with fmrx/fmxr for arch/arm/kvm/switch.c.
     CONFIG_KVM was removed in
     commit 541ad0150ca4 ("arm: Remove 32bit KVM host support") in
     v5.7.1. CONFIG_KVM is not enabled as part of allmodconfig or
     alldefconfig, but axm55xx_defconfig explicitly does enable it.
     Adjusted arch/arm/vfp/vfphw.S due to conflict with
     commit a47b395 ("ARM: 9030/1: entry: omit FP emulation for UND
     exceptions taken in kernel mode").]
Bug: 141693040
Change-Id: I84733bd8649784e1e636e107c1dac03ef7d48136

Change-Id: I1cf2b486cefd5805c0be8716b86b43e2cc0caf4a
TogoFire pushed a commit to dev-sm8350/kernel_oneplus_sm8350 that referenced this issue May 19, 2024
commit 2cbd1cc upstream.

The integrated assembler of Clang 10 and earlier do not allow to access
the VFP registers through the coprocessor load/store instructions:
arch/arm/vfp/vfpmodule.c:342:2: error: invalid operand for instruction
        fmxr(FPEXC, fpexc & ~(FPEXC_EX|FPEXC_DEX|FPEXC_FP2V|FPEXC_VV|FPEXC_TRAP_MASK));
        ^
arch/arm/vfp/vfpinstr.h:79:6: note: expanded from macro 'fmxr'
        asm("mcr p10, 7, %0, " vfpreg(_vfp_) ", cr0, 0 @ fmxr   " #_vfp_ ", %0"
            ^
<inline asm>:1:6: note: instantiated into assembly here
        mcr p10, 7, r0, cr8, cr0, 0 @ fmxr      FPEXC, r0
            ^

This has been addressed with Clang 11 [0]. However, to support earlier
versions of Clang and for better readability use of VFP assembler
mnemonics still is preferred.

Ideally we would replace this code with the unified assembler language
mnemonics vmrs/vmsr on call sites along with .fpu assembler directives.
The GNU assembler supports the .fpu directive at least since 2.17 (when
documentation has been added). Since Linux requires binutils 2.21 it is
safe to use .fpu directive. However, binutils does not allow to use
FPINST or FPINST2 as an argument to vmrs/vmsr instructions up to
binutils 2.24 (see binutils commit 16d02dc907c5):
arch/arm/vfp/vfphw.S: Assembler messages:
arch/arm/vfp/vfphw.S:162: Error: operand 0 must be FPSID or FPSCR pr FPEXC -- `vmsr FPINST,r6'
arch/arm/vfp/vfphw.S:165: Error: operand 0 must be FPSID or FPSCR pr FPEXC -- `vmsr FPINST2,r8'
arch/arm/vfp/vfphw.S:235: Error: operand 1 must be a VFP extension System Register -- `vmrs r3,FPINST'
arch/arm/vfp/vfphw.S:238: Error: operand 1 must be a VFP extension System Register -- `vmrs r12,FPINST2'

Use as-instr in Kconfig to check if FPINST/FPINST2 can be used. If they
can be used make use of .fpu directives and UAL VFP mnemonics for
register access.

This allows to build vfpmodule.c with Clang and its integrated assembler.

[0] https://reviews.llvm.org/D59733

Link: ClangBuiltLinux/linux#905

Signed-off-by: Stefan Agner <[email protected]>
Change-Id: Ibe43b4f40e924759f9a6bca4a7a7ae7cea473077
Signed-off-by: Russell King <[email protected]>
[nd: Adjusted hunk from arch/arm/Kconfig due to missing
     commit 8a90a32 ("arm: Unplug KVM from the build system").
     Replace __ACCESS_VFP with fmrx/fmxr for arch/arm/kvm/switch.c.
     CONFIG_KVM was removed in
     commit 541ad01 ("arm: Remove 32bit KVM host support") in
     v5.7.1. CONFIG_KVM is not enabled as part of allmodconfig or
     alldefconfig, but axm55xx_defconfig explicitly does enable it.
     Adjusted arch/arm/vfp/vfphw.S due to conflict with
     commit a47b395 ("ARM: 9030/1: entry: omit FP emulation for UND
     exceptions taken in kernel mode").]
Bug: 141693040
Signed-off-by: Nick Desaulniers <[email protected]>
(cherry picked from commit 5208d4f)
Signed-off-by: TogoFire <[email protected]>
ElectroPerf pushed a commit to aospa-dubai/android_kernel_motorola_sm7325 that referenced this issue Jun 18, 2024
commit 2cbd1cc3dcd3e84be1fc1987da24b190ddf24a70 upstream.

The integrated assembler of Clang 10 and earlier do not allow to access
the VFP registers through the coprocessor load/store instructions:
arch/arm/vfp/vfpmodule.c:342:2: error: invalid operand for instruction
        fmxr(FPEXC, fpexc & ~(FPEXC_EX|FPEXC_DEX|FPEXC_FP2V|FPEXC_VV|FPEXC_TRAP_MASK));
        ^
arch/arm/vfp/vfpinstr.h:79:6: note: expanded from macro 'fmxr'
        asm("mcr p10, 7, %0, " vfpreg(_vfp_) ", cr0, 0 @ fmxr   " #_vfp_ ", %0"
            ^
<inline asm>:1:6: note: instantiated into assembly here
        mcr p10, 7, r0, cr8, cr0, 0 @ fmxr      FPEXC, r0
            ^

This has been addressed with Clang 11 [0]. However, to support earlier
versions of Clang and for better readability use of VFP assembler
mnemonics still is preferred.

Ideally we would replace this code with the unified assembler language
mnemonics vmrs/vmsr on call sites along with .fpu assembler directives.
The GNU assembler supports the .fpu directive at least since 2.17 (when
documentation has been added). Since Linux requires binutils 2.21 it is
safe to use .fpu directive. However, binutils does not allow to use
FPINST or FPINST2 as an argument to vmrs/vmsr instructions up to
binutils 2.24 (see binutils commit 16d02dc907c5):
arch/arm/vfp/vfphw.S: Assembler messages:
arch/arm/vfp/vfphw.S:162: Error: operand 0 must be FPSID or FPSCR pr FPEXC -- `vmsr FPINST,r6'
arch/arm/vfp/vfphw.S:165: Error: operand 0 must be FPSID or FPSCR pr FPEXC -- `vmsr FPINST2,r8'
arch/arm/vfp/vfphw.S:235: Error: operand 1 must be a VFP extension System Register -- `vmrs r3,FPINST'
arch/arm/vfp/vfphw.S:238: Error: operand 1 must be a VFP extension System Register -- `vmrs r12,FPINST2'

Use as-instr in Kconfig to check if FPINST/FPINST2 can be used. If they
can be used make use of .fpu directives and UAL VFP mnemonics for
register access.

This allows to build vfpmodule.c with Clang and its integrated assembler.

[0] https://reviews.llvm.org/D59733

Link: ClangBuiltLinux/linux#905

Signed-off-by: Stefan Agner <[email protected]>
Signed-off-by: Russell King <[email protected]>
[nd: Adjusted hunk from arch/arm/Kconfig due to missing
     commit 8a90a3228b6a ("arm: Unplug KVM from the build system").
     Replace __ACCESS_VFP with fmrx/fmxr for arch/arm/kvm/switch.c.
     CONFIG_KVM was removed in
     commit 541ad0150ca4 ("arm: Remove 32bit KVM host support") in
     v5.7.1. CONFIG_KVM is not enabled as part of allmodconfig or
     alldefconfig, but axm55xx_defconfig explicitly does enable it.
     Adjusted arch/arm/vfp/vfphw.S due to conflict with
     commit a47b395 ("ARM: 9030/1: entry: omit FP emulation for UND
     exceptions taken in kernel mode").]
Bug: 141693040
Signed-off-by: Nick Desaulniers <[email protected]>
Change-Id: I84733bd8649784e1e636e107c1dac03ef7d48136
ElectroPerf pushed a commit to aospa-dubai/android_kernel_motorola_sm7325 that referenced this issue Jun 18, 2024
commit 2cbd1cc3dcd3e84be1fc1987da24b190ddf24a70 upstream.

The integrated assembler of Clang 10 and earlier do not allow to access
the VFP registers through the coprocessor load/store instructions:
arch/arm/vfp/vfpmodule.c:342:2: error: invalid operand for instruction
        fmxr(FPEXC, fpexc & ~(FPEXC_EX|FPEXC_DEX|FPEXC_FP2V|FPEXC_VV|FPEXC_TRAP_MASK));
        ^
arch/arm/vfp/vfpinstr.h:79:6: note: expanded from macro 'fmxr'
        asm("mcr p10, 7, %0, " vfpreg(_vfp_) ", cr0, 0 @ fmxr   " #_vfp_ ", %0"
            ^
<inline asm>:1:6: note: instantiated into assembly here
        mcr p10, 7, r0, cr8, cr0, 0 @ fmxr      FPEXC, r0
            ^

This has been addressed with Clang 11 [0]. However, to support earlier
versions of Clang and for better readability use of VFP assembler
mnemonics still is preferred.

Ideally we would replace this code with the unified assembler language
mnemonics vmrs/vmsr on call sites along with .fpu assembler directives.
The GNU assembler supports the .fpu directive at least since 2.17 (when
documentation has been added). Since Linux requires binutils 2.21 it is
safe to use .fpu directive. However, binutils does not allow to use
FPINST or FPINST2 as an argument to vmrs/vmsr instructions up to
binutils 2.24 (see binutils commit 16d02dc907c5):
arch/arm/vfp/vfphw.S: Assembler messages:
arch/arm/vfp/vfphw.S:162: Error: operand 0 must be FPSID or FPSCR pr FPEXC -- `vmsr FPINST,r6'
arch/arm/vfp/vfphw.S:165: Error: operand 0 must be FPSID or FPSCR pr FPEXC -- `vmsr FPINST2,r8'
arch/arm/vfp/vfphw.S:235: Error: operand 1 must be a VFP extension System Register -- `vmrs r3,FPINST'
arch/arm/vfp/vfphw.S:238: Error: operand 1 must be a VFP extension System Register -- `vmrs r12,FPINST2'

Use as-instr in Kconfig to check if FPINST/FPINST2 can be used. If they
can be used make use of .fpu directives and UAL VFP mnemonics for
register access.

This allows to build vfpmodule.c with Clang and its integrated assembler.

[0] https://reviews.llvm.org/D59733

Link: ClangBuiltLinux/linux#905

Signed-off-by: Stefan Agner <[email protected]>
Signed-off-by: Russell King <[email protected]>
[nd: Adjusted hunk from arch/arm/Kconfig due to missing
     commit 8a90a3228b6a ("arm: Unplug KVM from the build system").
     Replace __ACCESS_VFP with fmrx/fmxr for arch/arm/kvm/switch.c.
     CONFIG_KVM was removed in
     commit 541ad0150ca4 ("arm: Remove 32bit KVM host support") in
     v5.7.1. CONFIG_KVM is not enabled as part of allmodconfig or
     alldefconfig, but axm55xx_defconfig explicitly does enable it.
     Adjusted arch/arm/vfp/vfphw.S due to conflict with
     commit a47b395 ("ARM: 9030/1: entry: omit FP emulation for UND
     exceptions taken in kernel mode").]
Bug: 141693040
Signed-off-by: Nick Desaulniers <[email protected]>
Change-Id: I84733bd8649784e1e636e107c1dac03ef7d48136
Theimposter65 pushed a commit to Theimposter65/android_kernel_motorola_sm6375 that referenced this issue Jun 24, 2024
commit 2cbd1cc3dcd3e84be1fc1987da24b190ddf24a70 upstream.

The integrated assembler of Clang 10 and earlier do not allow to access
the VFP registers through the coprocessor load/store instructions:
arch/arm/vfp/vfpmodule.c:342:2: error: invalid operand for instruction
        fmxr(FPEXC, fpexc & ~(FPEXC_EX|FPEXC_DEX|FPEXC_FP2V|FPEXC_VV|FPEXC_TRAP_MASK));
        ^
arch/arm/vfp/vfpinstr.h:79:6: note: expanded from macro 'fmxr'
        asm("mcr p10, 7, %0, " vfpreg(_vfp_) ", cr0, 0 @ fmxr   " #_vfp_ ", %0"
            ^
<inline asm>:1:6: note: instantiated into assembly here
        mcr p10, 7, r0, cr8, cr0, 0 @ fmxr      FPEXC, r0
            ^

This has been addressed with Clang 11 [0]. However, to support earlier
versions of Clang and for better readability use of VFP assembler
mnemonics still is preferred.

Ideally we would replace this code with the unified assembler language
mnemonics vmrs/vmsr on call sites along with .fpu assembler directives.
The GNU assembler supports the .fpu directive at least since 2.17 (when
documentation has been added). Since Linux requires binutils 2.21 it is
safe to use .fpu directive. However, binutils does not allow to use
FPINST or FPINST2 as an argument to vmrs/vmsr instructions up to
binutils 2.24 (see binutils commit 16d02dc907c5):
arch/arm/vfp/vfphw.S: Assembler messages:
arch/arm/vfp/vfphw.S:162: Error: operand 0 must be FPSID or FPSCR pr FPEXC -- `vmsr FPINST,r6'
arch/arm/vfp/vfphw.S:165: Error: operand 0 must be FPSID or FPSCR pr FPEXC -- `vmsr FPINST2,r8'
arch/arm/vfp/vfphw.S:235: Error: operand 1 must be a VFP extension System Register -- `vmrs r3,FPINST'
arch/arm/vfp/vfphw.S:238: Error: operand 1 must be a VFP extension System Register -- `vmrs r12,FPINST2'

Use as-instr in Kconfig to check if FPINST/FPINST2 can be used. If they
can be used make use of .fpu directives and UAL VFP mnemonics for
register access.

This allows to build vfpmodule.c with Clang and its integrated assembler.

[0] https://reviews.llvm.org/D59733

Link: ClangBuiltLinux/linux#905

Signed-off-by: Stefan Agner <[email protected]>
Signed-off-by: Russell King <[email protected]>
[nd: Adjusted hunk from arch/arm/Kconfig due to missing
     commit 8a90a3228b6a ("arm: Unplug KVM from the build system").
     Replace __ACCESS_VFP with fmrx/fmxr for arch/arm/kvm/switch.c.
     CONFIG_KVM was removed in
     commit 541ad0150ca4 ("arm: Remove 32bit KVM host support") in
     v5.7.1. CONFIG_KVM is not enabled as part of allmodconfig or
     alldefconfig, but axm55xx_defconfig explicitly does enable it.
     Adjusted arch/arm/vfp/vfphw.S due to conflict with
     commit a47b395 ("ARM: 9030/1: entry: omit FP emulation for UND
     exceptions taken in kernel mode").]
Bug: 141693040
Signed-off-by: Nick Desaulniers <[email protected]>
Change-Id: I84733bd8649784e1e636e107c1dac03ef7d48136
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[ARCH] arm32 This bug impacts ARCH=arm [BUG] linux A bug that should be fixed in the mainline kernel. [FIXED][LINUX] 5.9 This bug was fixed in Linux 5.9 [TOOL] integrated-as The issue is relevant to LLVM integrated assembler
Projects
None yet
Development

No branches or pull requests

2 participants