aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm64/kernel/insn.c
diff options
context:
space:
mode:
authorMark Brown <broonie@kernel.org>2014-09-16 12:42:33 -0400
committerCatalin Marinas <catalin.marinas@arm.com>2014-09-25 10:32:48 -0400
commita9ae04c9faeff1ad617e4f4492af3143d8c5ad9b (patch)
tree62653998e9b5f2519ab235c2db8463b2ab30e2de /arch/arm64/kernel/insn.c
parent1059c6bf8534acda249e7e65c81e7696fb074dc1 (diff)
arm64: insn: Add return statements after BUG_ON()
Following a recent series of enhancements to the insn code the ARMv8 allnoconfig build has been generating a large number of warnings in the form of: arch/arm64/kernel/insn.c:689:8: warning: 'insn' may be used uninitialized in this function [-Wmaybe-uninitialized] This is because BUG() and related macros can be compiled out so we get execution paths which normally result in a panic compiling out to noops instead. I wasn't able to immediately identify a sensible return value to use in these cases so just return AARCH64_BREAK_FAULT - this is all "should never happen" code so hopefully it never has a practical impact. Signed-off-by: Mark Brown <broonie@kernel.org> [catalin.marinas@arm.com: AARCH64_BREAK_FAULT definition contributed by Daniel Borkmann] [catalin.marinas@arm.com: replace return 0 with AARCH64_BREAK_FAULT] Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Diffstat (limited to 'arch/arm64/kernel/insn.c')
-rw-r--r--arch/arm64/kernel/insn.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/arch/arm64/kernel/insn.c b/arch/arm64/kernel/insn.c
index 0668ee5c5bf9..e007714ded04 100644
--- a/arch/arm64/kernel/insn.c
+++ b/arch/arm64/kernel/insn.c
@@ -22,7 +22,9 @@
22#include <linux/smp.h> 22#include <linux/smp.h>
23#include <linux/stop_machine.h> 23#include <linux/stop_machine.h>
24#include <linux/uaccess.h> 24#include <linux/uaccess.h>
25
25#include <asm/cacheflush.h> 26#include <asm/cacheflush.h>
27#include <asm/debug-monitors.h>
26#include <asm/insn.h> 28#include <asm/insn.h>
27 29
28#define AARCH64_INSN_SF_BIT BIT(31) 30#define AARCH64_INSN_SF_BIT BIT(31)
@@ -388,6 +390,7 @@ u32 __kprobes aarch64_insn_gen_branch_imm(unsigned long pc, unsigned long addr,
388 break; 390 break;
389 default: 391 default:
390 BUG_ON(1); 392 BUG_ON(1);
393 return AARCH64_BREAK_FAULT;
391 } 394 }
392 395
393 return aarch64_insn_encode_immediate(AARCH64_INSN_IMM_26, insn, 396 return aarch64_insn_encode_immediate(AARCH64_INSN_IMM_26, insn,
@@ -413,6 +416,7 @@ u32 aarch64_insn_gen_comp_branch_imm(unsigned long pc, unsigned long addr,
413 break; 416 break;
414 default: 417 default:
415 BUG_ON(1); 418 BUG_ON(1);
419 return AARCH64_BREAK_FAULT;
416 } 420 }
417 421
418 switch (variant) { 422 switch (variant) {
@@ -423,6 +427,7 @@ u32 aarch64_insn_gen_comp_branch_imm(unsigned long pc, unsigned long addr,
423 break; 427 break;
424 default: 428 default:
425 BUG_ON(1); 429 BUG_ON(1);
430 return AARCH64_BREAK_FAULT;
426 } 431 }
427 432
428 insn = aarch64_insn_encode_register(AARCH64_INSN_REGTYPE_RT, insn, reg); 433 insn = aarch64_insn_encode_register(AARCH64_INSN_REGTYPE_RT, insn, reg);
@@ -475,6 +480,7 @@ u32 aarch64_insn_gen_branch_reg(enum aarch64_insn_register reg,
475 break; 480 break;
476 default: 481 default:
477 BUG_ON(1); 482 BUG_ON(1);
483 return AARCH64_BREAK_FAULT;
478 } 484 }
479 485
480 return aarch64_insn_encode_register(AARCH64_INSN_REGTYPE_RN, insn, reg); 486 return aarch64_insn_encode_register(AARCH64_INSN_REGTYPE_RN, insn, reg);
@@ -497,6 +503,7 @@ u32 aarch64_insn_gen_load_store_reg(enum aarch64_insn_register reg,
497 break; 503 break;
498 default: 504 default:
499 BUG_ON(1); 505 BUG_ON(1);
506 return AARCH64_BREAK_FAULT;
500 } 507 }
501 508
502 insn = aarch64_insn_encode_ldst_size(size, insn); 509 insn = aarch64_insn_encode_ldst_size(size, insn);
@@ -535,6 +542,7 @@ u32 aarch64_insn_gen_load_store_pair(enum aarch64_insn_register reg1,
535 break; 542 break;
536 default: 543 default:
537 BUG_ON(1); 544 BUG_ON(1);
545 return AARCH64_BREAK_FAULT;
538 } 546 }
539 547
540 switch (variant) { 548 switch (variant) {
@@ -553,6 +561,7 @@ u32 aarch64_insn_gen_load_store_pair(enum aarch64_insn_register reg1,
553 break; 561 break;
554 default: 562 default:
555 BUG_ON(1); 563 BUG_ON(1);
564 return AARCH64_BREAK_FAULT;
556 } 565 }
557 566
558 insn = aarch64_insn_encode_register(AARCH64_INSN_REGTYPE_RT, insn, 567 insn = aarch64_insn_encode_register(AARCH64_INSN_REGTYPE_RT, insn,
@@ -590,6 +599,7 @@ u32 aarch64_insn_gen_add_sub_imm(enum aarch64_insn_register dst,
590 break; 599 break;
591 default: 600 default:
592 BUG_ON(1); 601 BUG_ON(1);
602 return AARCH64_BREAK_FAULT;
593 } 603 }
594 604
595 switch (variant) { 605 switch (variant) {
@@ -600,6 +610,7 @@ u32 aarch64_insn_gen_add_sub_imm(enum aarch64_insn_register dst,
600 break; 610 break;
601 default: 611 default:
602 BUG_ON(1); 612 BUG_ON(1);
613 return AARCH64_BREAK_FAULT;
603 } 614 }
604 615
605 BUG_ON(imm & ~(SZ_4K - 1)); 616 BUG_ON(imm & ~(SZ_4K - 1));
@@ -632,6 +643,7 @@ u32 aarch64_insn_gen_bitfield(enum aarch64_insn_register dst,
632 break; 643 break;
633 default: 644 default:
634 BUG_ON(1); 645 BUG_ON(1);
646 return AARCH64_BREAK_FAULT;
635 } 647 }
636 648
637 switch (variant) { 649 switch (variant) {
@@ -644,6 +656,7 @@ u32 aarch64_insn_gen_bitfield(enum aarch64_insn_register dst,
644 break; 656 break;
645 default: 657 default:
646 BUG_ON(1); 658 BUG_ON(1);
659 return AARCH64_BREAK_FAULT;
647 } 660 }
648 661
649 BUG_ON(immr & ~mask); 662 BUG_ON(immr & ~mask);
@@ -677,6 +690,7 @@ u32 aarch64_insn_gen_movewide(enum aarch64_insn_register dst,
677 break; 690 break;
678 default: 691 default:
679 BUG_ON(1); 692 BUG_ON(1);
693 return AARCH64_BREAK_FAULT;
680 } 694 }
681 695
682 BUG_ON(imm & ~(SZ_64K - 1)); 696 BUG_ON(imm & ~(SZ_64K - 1));
@@ -692,6 +706,7 @@ u32 aarch64_insn_gen_movewide(enum aarch64_insn_register dst,
692 break; 706 break;
693 default: 707 default:
694 BUG_ON(1); 708 BUG_ON(1);
709 return AARCH64_BREAK_FAULT;
695 } 710 }
696 711
697 insn |= (shift >> 4) << 21; 712 insn |= (shift >> 4) << 21;
@@ -725,6 +740,7 @@ u32 aarch64_insn_gen_add_sub_shifted_reg(enum aarch64_insn_register dst,
725 break; 740 break;
726 default: 741 default:
727 BUG_ON(1); 742 BUG_ON(1);
743 return AARCH64_BREAK_FAULT;
728 } 744 }
729 745
730 switch (variant) { 746 switch (variant) {
@@ -737,6 +753,7 @@ u32 aarch64_insn_gen_add_sub_shifted_reg(enum aarch64_insn_register dst,
737 break; 753 break;
738 default: 754 default:
739 BUG_ON(1); 755 BUG_ON(1);
756 return AARCH64_BREAK_FAULT;
740 } 757 }
741 758
742 759
@@ -769,6 +786,7 @@ u32 aarch64_insn_gen_data1(enum aarch64_insn_register dst,
769 break; 786 break;
770 default: 787 default:
771 BUG_ON(1); 788 BUG_ON(1);
789 return AARCH64_BREAK_FAULT;
772 } 790 }
773 791
774 switch (variant) { 792 switch (variant) {
@@ -779,6 +797,7 @@ u32 aarch64_insn_gen_data1(enum aarch64_insn_register dst,
779 break; 797 break;
780 default: 798 default:
781 BUG_ON(1); 799 BUG_ON(1);
800 return AARCH64_BREAK_FAULT;
782 } 801 }
783 802
784 insn = aarch64_insn_encode_register(AARCH64_INSN_REGTYPE_RD, insn, dst); 803 insn = aarch64_insn_encode_register(AARCH64_INSN_REGTYPE_RD, insn, dst);
@@ -815,6 +834,7 @@ u32 aarch64_insn_gen_data2(enum aarch64_insn_register dst,
815 break; 834 break;
816 default: 835 default:
817 BUG_ON(1); 836 BUG_ON(1);
837 return AARCH64_BREAK_FAULT;
818 } 838 }
819 839
820 switch (variant) { 840 switch (variant) {
@@ -825,6 +845,7 @@ u32 aarch64_insn_gen_data2(enum aarch64_insn_register dst,
825 break; 845 break;
826 default: 846 default:
827 BUG_ON(1); 847 BUG_ON(1);
848 return AARCH64_BREAK_FAULT;
828 } 849 }
829 850
830 insn = aarch64_insn_encode_register(AARCH64_INSN_REGTYPE_RD, insn, dst); 851 insn = aarch64_insn_encode_register(AARCH64_INSN_REGTYPE_RD, insn, dst);
@@ -852,6 +873,7 @@ u32 aarch64_insn_gen_data3(enum aarch64_insn_register dst,
852 break; 873 break;
853 default: 874 default:
854 BUG_ON(1); 875 BUG_ON(1);
876 return AARCH64_BREAK_FAULT;
855 } 877 }
856 878
857 switch (variant) { 879 switch (variant) {
@@ -862,6 +884,7 @@ u32 aarch64_insn_gen_data3(enum aarch64_insn_register dst,
862 break; 884 break;
863 default: 885 default:
864 BUG_ON(1); 886 BUG_ON(1);
887 return AARCH64_BREAK_FAULT;
865 } 888 }
866 889
867 insn = aarch64_insn_encode_register(AARCH64_INSN_REGTYPE_RD, insn, dst); 890 insn = aarch64_insn_encode_register(AARCH64_INSN_REGTYPE_RD, insn, dst);
@@ -911,6 +934,7 @@ u32 aarch64_insn_gen_logical_shifted_reg(enum aarch64_insn_register dst,
911 break; 934 break;
912 default: 935 default:
913 BUG_ON(1); 936 BUG_ON(1);
937 return AARCH64_BREAK_FAULT;
914 } 938 }
915 939
916 switch (variant) { 940 switch (variant) {
@@ -923,6 +947,7 @@ u32 aarch64_insn_gen_logical_shifted_reg(enum aarch64_insn_register dst,
923 break; 947 break;
924 default: 948 default:
925 BUG_ON(1); 949 BUG_ON(1);
950 return AARCH64_BREAK_FAULT;
926 } 951 }
927 952
928 953