Commit cc73cc6
LoongArch: Make do_xyz() exception handlers more robust
Currently, interrupts need to be disabled before single-step mode is
set, it requires that CSR_PRMD_PIE be cleared in save_local_irqflag()
which is called by setup_singlestep(), this is reasonable.
But in the first kprobe breakpoint exception, if the irq is enabled at
the beginning of do_bp(), it will not be disabled at the end of do_bp()
due to the CSR_PRMD_PIE has been cleared in save_local_irqflag(). So for
this case, it may corrupt exception context when restoring the exception
after do_bp() in handle_bp(), this is not reasonable.
In order to restore exception safely in handle_bp(), it needs to ensure
the irq is disabled at the end of do_bp(), so just add a local variable
to record the original interrupt status in the parent context, then use
it as the check condition to enable and disable irq in do_bp().
While at it, do the similar thing for other do_xyz() exception handlers
to make them more robust.
Fixes: 6d4cc40 ("LoongArch: Add kprobes support")
Suggested-by: Jinyang He <hejinyang@loongson.cn>
Suggested-by: Huacai Chen <chenhuacai@loongson.cn>
Co-developed-by: Tianyang Zhang <zhangtianyang@loongson.cn>
Signed-off-by: Tianyang Zhang <zhangtianyang@loongson.cn>
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>1 parent bb0511d commit cc73cc6
1 file changed
+12
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
553 | 553 | | |
554 | 554 | | |
555 | 555 | | |
| 556 | + | |
556 | 557 | | |
557 | 558 | | |
558 | | - | |
| 559 | + | |
559 | 560 | | |
560 | 561 | | |
561 | 562 | | |
| |||
582 | 583 | | |
583 | 584 | | |
584 | 585 | | |
585 | | - | |
| 586 | + | |
586 | 587 | | |
587 | 588 | | |
588 | 589 | | |
| |||
621 | 622 | | |
622 | 623 | | |
623 | 624 | | |
| 625 | + | |
624 | 626 | | |
625 | 627 | | |
626 | 628 | | |
627 | 629 | | |
628 | 630 | | |
629 | | - | |
| 631 | + | |
630 | 632 | | |
631 | 633 | | |
632 | 634 | | |
| |||
692 | 694 | | |
693 | 695 | | |
694 | 696 | | |
695 | | - | |
| 697 | + | |
696 | 698 | | |
697 | 699 | | |
698 | 700 | | |
| |||
710 | 712 | | |
711 | 713 | | |
712 | 714 | | |
| 715 | + | |
713 | 716 | | |
714 | 717 | | |
715 | 718 | | |
716 | 719 | | |
717 | | - | |
| 720 | + | |
718 | 721 | | |
719 | 722 | | |
720 | 723 | | |
| |||
780 | 783 | | |
781 | 784 | | |
782 | 785 | | |
783 | | - | |
| 786 | + | |
784 | 787 | | |
785 | 788 | | |
786 | 789 | | |
| |||
1015 | 1018 | | |
1016 | 1019 | | |
1017 | 1020 | | |
| 1021 | + | |
1018 | 1022 | | |
1019 | 1023 | | |
1020 | 1024 | | |
| |||
1024 | 1028 | | |
1025 | 1029 | | |
1026 | 1030 | | |
1027 | | - | |
| 1031 | + | |
1028 | 1032 | | |
1029 | 1033 | | |
1030 | 1034 | | |
| |||
1038 | 1042 | | |
1039 | 1043 | | |
1040 | 1044 | | |
1041 | | - | |
| 1045 | + | |
1042 | 1046 | | |
1043 | 1047 | | |
1044 | 1048 | | |
| |||
0 commit comments