@@ -635,7 +635,7 @@ static bool is_reachable_by_call(unsigned long vtramp, unsigned long vaddr)
635
635
return delta >= INT_MIN && delta <= INT_MAX ;
636
636
}
637
637
638
- #define MASK_4GB ((1UL << 32) - 1)
638
+ #define MASK_4GB ~ ((1UL << 32) - 1)
639
639
640
640
static unsigned long find_nearest_page (unsigned long vaddr )
641
641
{
@@ -644,37 +644,66 @@ static unsigned long find_nearest_page(unsigned long vaddr)
644
644
.align_mask = ~PAGE_MASK ,
645
645
};
646
646
unsigned long low_limit = PAGE_SIZE , high_limit = TASK_SIZE ;
647
- unsigned long limit , tramp_low_4GB , tramp_high_4GB ;
648
- unsigned long call_end = vaddr + 5 , tramp1 , tramp2 ;
647
+ unsigned long tramp1 = ~0UL , tramp2 = ~0UL ;
648
+ unsigned long limit , low_4GB , high_4GB ;
649
+ unsigned long call_end = vaddr + 5 ;
649
650
650
651
if (!check_add_overflow (call_end , INT_MIN , & limit ))
651
652
low_limit = limit ;
652
653
if (!check_add_overflow (call_end , INT_MAX , & limit ))
653
654
high_limit = limit ;
654
655
655
- tramp_low_4GB = call_end & MASK_4GB ;
656
- tramp_high_4GB = tramp_low_4GB + (1UL << 32 );
656
+ printk ("find_nearest_page1 low_limit %lx high_limit %lx\n" , low_limit , high_limit );
657
657
658
- if (low_limit > tramp_low_4GB ) {
659
- info .low_limit = tramp_high_4GB ;
658
+ low_4GB = call_end & MASK_4GB ;
659
+ high_4GB = low_4GB + (1UL << 32 );
660
+
661
+ if (low_limit == PAGE_SIZE )
662
+ low_4GB = low_limit ;
663
+
664
+ printk ("find_nearest_page2 low_4GB %lx high_4GB %lx\n" , low_4GB , high_4GB );
665
+
666
+ #if 0
667
+ 0 4 8
668
+ | | |
669
+ '-------^-------'
670
+ '-------^-------'
671
+ '-------^-------'
672
+ #endif
673
+
674
+ if (low_limit <= low_4GB ) {
675
+ info .low_limit = low_4GB ;
660
676
info .high_limit = high_limit ;
661
677
} else {
662
- info .low_limit = tramp_low_4GB ;
663
- info .high_limit = high_limit ;;
678
+ info .low_limit = high_4GB ;
679
+ info .high_limit = high_limit ;
664
680
}
665
681
666
682
tramp1 = vm_unmapped_area (& info );
683
+ printk ("find_nearest_page3 tramp1 %lx low_limit %lx high_limit %lx\n" , tramp1 , info .low_limit , info .high_limit );
667
684
668
- if (low_limit > tramp_low_4GB ) {
685
+ if (low_limit <= low_4GB ) {
669
686
info .low_limit = low_limit ;
670
- info .high_limit = tramp_high_4GB ;
687
+ info .high_limit = low_4GB ;
671
688
} else {
672
689
info .low_limit = low_limit ;
673
- info .high_limit = tramp_low_4GB ;
690
+ info .high_limit = high_4GB ;
674
691
}
675
692
676
693
info .flags = VM_UNMAPPED_AREA_TOPDOWN ;
677
694
tramp2 = vm_unmapped_area (& info );
695
+ printk ("find_nearest_page4 tramp2 %lx low_limit %lx high_limit %lx\n" , tramp2 , info .low_limit , info .high_limit );
696
+
697
+ tramp1 = IS_ERR_VALUE (tramp1 ) ? ~0UL : tramp1 ;
698
+ tramp2 = IS_ERR_VALUE (tramp2 ) ? ~0UL : tramp2 ;
699
+
700
+ printk ("find_nearest_page5 tramp1 %lx tramp2 %lx\n" , tramp1 , tramp2 );
701
+
702
+ printk ("find_nearest_page6 mask %lx tramp1 %lx tramp2 %lx min %lx\n" ,
703
+ MASK_4GB ,
704
+ tramp1 & ~MASK_4GB ,
705
+ tramp2 & ~MASK_4GB ,
706
+ min (tramp1 & ~MASK_4GB , tramp2 & ~MASK_4GB ));
678
707
679
708
return min (tramp1 & ~MASK_4GB , tramp2 & ~MASK_4GB );
680
709
}
0 commit comments