Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/amd64/amd64 Fix PR kern/57007. I missed applying a...



details:   https://anonhg.NetBSD.org/src/rev/ec2d88c0183f
branches:  trunk
changeset: 370030:ec2d88c0183f
user:      knakahara <knakahara%NetBSD.org@localhost>
date:      Tue Sep 13 05:36:29 2022 +0000

description:
Fix PR kern/57007.  I missed applying a part of the original patch.

diffstat:

 sys/arch/amd64/amd64/lock_stubs.S |  30 +++++++++++++++++-------------
 1 files changed, 17 insertions(+), 13 deletions(-)

diffs (63 lines):

diff -r 4a66b20112db -r ec2d88c0183f sys/arch/amd64/amd64/lock_stubs.S
--- a/sys/arch/amd64/amd64/lock_stubs.S Tue Sep 13 01:22:12 2022 +0000
+++ b/sys/arch/amd64/amd64/lock_stubs.S Tue Sep 13 05:36:29 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lock_stubs.S,v 1.37 2022/09/07 00:40:18 knakahara Exp $        */
+/*     $NetBSD: lock_stubs.S,v 1.38 2022/09/13 05:36:29 knakahara Exp $        */
 
 /*
  * Copyright (c) 2006, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -124,13 +124,13 @@
        movl    CPU_INFO_MTX_OLDSPL(%r8), %edi
        incl    CPU_INFO_MTX_COUNT(%r8)
        jnz     1f
-       cmpl    CPU_INFO_ILEVEL(%r8), %edi
+       cmpb    CPU_INFO_ILEVEL(%r8), %dil
        jae     1f
-       movl    CPU_INFO_IUNMASK(%r8,%rdi,4), %esi
+       movq    CPU_INFO_IUNMASK(%r8,%rdi,8), %rsi
        CLI(ax)
-       testl   CPU_INFO_IPENDING(%r8), %esi
+       testq   CPU_INFO_IPENDING(%r8), %rsi
        jnz     _C_LABEL(Xspllower)
-       movl    %edi, CPU_INFO_ILEVEL(%r8)
+       movb    %dil, CPU_INFO_ILEVEL(%r8)
        STI(ax)
 1:     rep                                     /* double byte ret as branch */
        ret                                     /* target: see AMD docs */
@@ -141,23 +141,27 @@
        movb    $0x00, MTX_LOCK(%rdi)
        movl    CPU_INFO_MTX_OLDSPL(%rsi), %ecx
        incl    CPU_INFO_MTX_COUNT(%rsi)
-       movl    CPU_INFO_ILEVEL(%rsi),%edx
+       movzbl  CPU_INFO_ILEVEL(%rsi),%edx
        cmovnzl %edx,%ecx
-       pushq   %rbx
        cmpl    %edx,%ecx                       /* new level is lower? */
        jae     2f
+       xorq    %rdi,%rdi                       /* rdi: ci_ipending mask */
+       notq    %rdi
+       shrq    $8,%rdi
+       movq    %rcx,%r9                        /* r9: shifted new level */
+       shlq    $56,%r9
 1:
-       movl    CPU_INFO_IPENDING(%rsi),%eax
-       testl   %eax,CPU_INFO_IUNMASK(%rsi,%rcx,4)/* deferred interrupts? */
+       movq    CPU_INFO_IPENDING(%rsi),%rax
+       testq   %rax,CPU_INFO_IUNMASK(%rsi,%rcx,8)/* deferred interrupts? */
        jnz     3f
-       movl    %eax,%ebx
-       cmpxchg8b CPU_INFO_ISTATE(%rsi)         /* swap in new ilevel */
+       movq    %rax,%r8
+       andq    %rdi,%r8
+       orq     %r9,%r8
+       cmpxchgq %r8,CPU_INFO_ISTATE(%rsi)      /* swap in new ilevel */
        jnz     4f
 2:
-       popq    %rbx
        ret
 3:
-       popq    %rbx
        movl    %ecx, %edi
        jmp     _C_LABEL(Xspllower)
 4:



Home | Main Index | Thread Index | Old Index