[PATCH] linux-user/loongarch64: Detect vector stores in host_signal_write()

SignKirigami posted 1 patch 1 week, 1 day ago
linux-user/include/host/loongarch64/host-signal.h | 6 ++++++
1 file changed, 6 insertions(+)
[PATCH] linux-user/loongarch64: Detect vector stores in host_signal_write()
Posted by SignKirigami 1 week, 1 day ago
Recognize LSX/LASX stores in the LoongArch host signal handler to fix
internal QEMU crashes when RISC-V vector stores hit write-protected code
pages through host memcpy.

Signed-off-by: Felix Yan <felixonmars@archlinux.org>
Signed-off-by: SignKirigami <prcups@krgm.moe>
---
 linux-user/include/host/loongarch64/host-signal.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/linux-user/include/host/loongarch64/host-signal.h b/linux-user/include/host/loongarch64/host-signal.h
index d33c3fc03e..eb4308cf09 100644
--- a/linux-user/include/host/loongarch64/host-signal.h
+++ b/linux-user/include/host/loongarch64/host-signal.h
@@ -61,6 +61,10 @@ static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc)
             return true;
         }
         break;
+    case 0b001011: /* v{ld,st}, xv{ld,st} */
+        return (insn >> 22) & 1;
+    case 0b001100: /* v{ldrepl,stelm}, xv{ldrepl,stelm} */
+        return (insn >> 24) & 1;
     case 0b001110: /* indexed, atomic, bounds-checking memory operations */
         switch ((insn >> 15) & 0b11111111111) {
         case 0b00000100000: /* stx.b */
@@ -69,6 +73,8 @@ static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc)
         case 0b00000111000: /* stx.d */
         case 0b00001110000: /* fstx.s */
         case 0b00001111000: /* fstx.d */
+        case 0b00010001000: /* vstx */
+        case 0b00010011000: /* xvstx */
         case 0b00011101100: /* fstgt.s */
         case 0b00011101101: /* fstgt.d */
         case 0b00011101110: /* fstle.s */
-- 
2.55.0
Re: [PATCH] linux-user/loongarch64: Detect vector stores in host_signal_write()
Posted by Bibo Mao 6 days, 13 hours ago
On 2026/9/18 下午6:37, SignKirigami wrote:
> Recognize LSX/LASX stores in the LoongArch host signal handler to fix
> internal QEMU crashes when RISC-V vector stores hit write-protected code
> pages through host memcpy.
> 
> Signed-off-by: Felix Yan <felixonmars@archlinux.org>
> Signed-off-by: SignKirigami <prcups@krgm.moe>
> ---
>   linux-user/include/host/loongarch64/host-signal.h | 6 ++++++
>   1 file changed, 6 insertions(+)
> 
> diff --git a/linux-user/include/host/loongarch64/host-signal.h b/linux-user/include/host/loongarch64/host-signal.h
> index d33c3fc03e..eb4308cf09 100644
> --- a/linux-user/include/host/loongarch64/host-signal.h
> +++ b/linux-user/include/host/loongarch64/host-signal.h
> @@ -61,6 +61,10 @@ static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc)
>               return true;
>           }
>           break;
> +    case 0b001011: /* v{ld,st}, xv{ld,st} */
> +        return (insn >> 22) & 1;
> +    case 0b001100: /* v{ldrepl,stelm}, xv{ldrepl,stelm} */
> +        return (insn >> 24) & 1;
>       case 0b001110: /* indexed, atomic, bounds-checking memory operations */
>           switch ((insn >> 15) & 0b11111111111) {
>           case 0b00000100000: /* stx.b */
> @@ -69,6 +73,8 @@ static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc)
>           case 0b00000111000: /* stx.d */
>           case 0b00001110000: /* fstx.s */
>           case 0b00001111000: /* fstx.d */
> +        case 0b00010001000: /* vstx */
> +        case 0b00010011000: /* xvstx */
>           case 0b00011101100: /* fstgt.s */
>           case 0b00011101101: /* fstgt.d */
>           case 0b00011101110: /* fstle.s */
> 
Reviewed-by: Bibo Mao <maobibo@loongson.cn>