Skip to content

Commit a236441

Browse files
committed
sparc64: Fix illegal relative branches in hypervisor patched TLB cross-call code.
Just like the non-cross-call TLB flush handlers, the cross-call ones need to avoid doing PC-relative branches outside of their code blocks. Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 830cda3 commit a236441

File tree

1 file changed

+30
-12
lines changed

1 file changed

+30
-12
lines changed

arch/sparc/mm/ultra.S

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ cheetah_patch_cachetlbops:
484484
*/
485485
.align 32
486486
.globl xcall_flush_tlb_mm
487-
xcall_flush_tlb_mm: /* 21 insns */
487+
xcall_flush_tlb_mm: /* 24 insns */
488488
mov PRIMARY_CONTEXT, %g2
489489
ldxa [%g2] ASI_DMMU, %g3
490490
srlx %g3, CTX_PGSZ1_NUC_SHIFT, %g4
@@ -506,9 +506,12 @@ xcall_flush_tlb_mm: /* 21 insns */
506506
nop
507507
nop
508508
nop
509+
nop
510+
nop
511+
nop
509512

510513
.globl xcall_flush_tlb_page
511-
xcall_flush_tlb_page: /* 17 insns */
514+
xcall_flush_tlb_page: /* 20 insns */
512515
/* %g5=context, %g1=vaddr */
513516
mov PRIMARY_CONTEXT, %g4
514517
ldxa [%g4] ASI_DMMU, %g2
@@ -527,9 +530,12 @@ xcall_flush_tlb_page: /* 17 insns */
527530
retry
528531
nop
529532
nop
533+
nop
534+
nop
535+
nop
530536

531537
.globl xcall_flush_tlb_kernel_range
532-
xcall_flush_tlb_kernel_range: /* 25 insns */
538+
xcall_flush_tlb_kernel_range: /* 28 insns */
533539
sethi %hi(PAGE_SIZE - 1), %g2
534540
or %g2, %lo(PAGE_SIZE - 1), %g2
535541
andn %g1, %g2, %g1
@@ -555,6 +561,9 @@ xcall_flush_tlb_kernel_range: /* 25 insns */
555561
nop
556562
nop
557563
nop
564+
nop
565+
nop
566+
nop
558567

559568
/* This runs in a very controlled environment, so we do
560569
* not need to worry about BH races etc.
@@ -737,7 +746,7 @@ __hypervisor_tlb_xcall_error:
737746
ba,a,pt %xcc, rtrap
738747

739748
.globl __hypervisor_xcall_flush_tlb_mm
740-
__hypervisor_xcall_flush_tlb_mm: /* 21 insns */
749+
__hypervisor_xcall_flush_tlb_mm: /* 24 insns */
741750
/* %g5=ctx, g1,g2,g3,g4,g7=scratch, %g6=unusable */
742751
mov %o0, %g2
743752
mov %o1, %g3
@@ -751,7 +760,7 @@ __hypervisor_xcall_flush_tlb_mm: /* 21 insns */
751760
mov HV_FAST_MMU_DEMAP_CTX, %o5
752761
ta HV_FAST_TRAP
753762
mov HV_FAST_MMU_DEMAP_CTX, %g6
754-
brnz,pn %o0, __hypervisor_tlb_xcall_error
763+
brnz,pn %o0, 1f
755764
mov %o0, %g5
756765
mov %g2, %o0
757766
mov %g3, %o1
@@ -760,9 +769,12 @@ __hypervisor_xcall_flush_tlb_mm: /* 21 insns */
760769
mov %g7, %o5
761770
membar #Sync
762771
retry
772+
1: sethi %hi(__hypervisor_tlb_xcall_error), %g4
773+
jmpl %g4 + %lo(__hypervisor_tlb_xcall_error), %g0
774+
nop
763775

764776
.globl __hypervisor_xcall_flush_tlb_page
765-
__hypervisor_xcall_flush_tlb_page: /* 17 insns */
777+
__hypervisor_xcall_flush_tlb_page: /* 20 insns */
766778
/* %g5=ctx, %g1=vaddr */
767779
mov %o0, %g2
768780
mov %o1, %g3
@@ -774,16 +786,19 @@ __hypervisor_xcall_flush_tlb_page: /* 17 insns */
774786
sllx %o0, PAGE_SHIFT, %o0
775787
ta HV_MMU_UNMAP_ADDR_TRAP
776788
mov HV_MMU_UNMAP_ADDR_TRAP, %g6
777-
brnz,a,pn %o0, __hypervisor_tlb_xcall_error
789+
brnz,a,pn %o0, 1f
778790
mov %o0, %g5
779791
mov %g2, %o0
780792
mov %g3, %o1
781793
mov %g4, %o2
782794
membar #Sync
783795
retry
796+
1: sethi %hi(__hypervisor_tlb_xcall_error), %g4
797+
jmpl %g4 + %lo(__hypervisor_tlb_xcall_error), %g0
798+
nop
784799

785800
.globl __hypervisor_xcall_flush_tlb_kernel_range
786-
__hypervisor_xcall_flush_tlb_kernel_range: /* 25 insns */
801+
__hypervisor_xcall_flush_tlb_kernel_range: /* 28 insns */
787802
/* %g1=start, %g7=end, g2,g3,g4,g5,g6=scratch */
788803
sethi %hi(PAGE_SIZE - 1), %g2
789804
or %g2, %lo(PAGE_SIZE - 1), %g2
@@ -800,7 +815,7 @@ __hypervisor_xcall_flush_tlb_kernel_range: /* 25 insns */
800815
mov HV_MMU_ALL, %o2 /* ARG2: flags */
801816
ta HV_MMU_UNMAP_ADDR_TRAP
802817
mov HV_MMU_UNMAP_ADDR_TRAP, %g6
803-
brnz,pn %o0, __hypervisor_tlb_xcall_error
818+
brnz,pn %o0, 1f
804819
mov %o0, %g5
805820
sethi %hi(PAGE_SIZE), %o2
806821
brnz,pt %g3, 1b
@@ -810,6 +825,9 @@ __hypervisor_xcall_flush_tlb_kernel_range: /* 25 insns */
810825
mov %g7, %o2
811826
membar #Sync
812827
retry
828+
1: sethi %hi(__hypervisor_tlb_xcall_error), %g4
829+
jmpl %g4 + %lo(__hypervisor_tlb_xcall_error), %g0
830+
nop
813831

814832
/* These just get rescheduled to PIL vectors. */
815833
.globl xcall_call_function
@@ -894,21 +912,21 @@ hypervisor_patch_cachetlbops:
894912
sethi %hi(__hypervisor_xcall_flush_tlb_mm), %o1
895913
or %o1, %lo(__hypervisor_xcall_flush_tlb_mm), %o1
896914
call tlb_patch_one
897-
mov 21, %o2
915+
mov 24, %o2
898916

899917
sethi %hi(xcall_flush_tlb_page), %o0
900918
or %o0, %lo(xcall_flush_tlb_page), %o0
901919
sethi %hi(__hypervisor_xcall_flush_tlb_page), %o1
902920
or %o1, %lo(__hypervisor_xcall_flush_tlb_page), %o1
903921
call tlb_patch_one
904-
mov 17, %o2
922+
mov 20, %o2
905923

906924
sethi %hi(xcall_flush_tlb_kernel_range), %o0
907925
or %o0, %lo(xcall_flush_tlb_kernel_range), %o0
908926
sethi %hi(__hypervisor_xcall_flush_tlb_kernel_range), %o1
909927
or %o1, %lo(__hypervisor_xcall_flush_tlb_kernel_range), %o1
910928
call tlb_patch_one
911-
mov 25, %o2
929+
mov 28, %o2
912930
#endif /* CONFIG_SMP */
913931

914932
ret

0 commit comments

Comments
 (0)