~ubuntu-branches/debian/wheezy/linux-2.6/wheezy

« back to all changes in this revision

Viewing changes to arch/sh/kernel/dwarf.c

  • Committer: Bazaar Package Importer
  • Author(s): Ben Hutchings, Ben Hutchings, Aurelien Jarno, Martin Michlmayr
  • Date: 2011-04-06 13:53:30 UTC
  • mfrom: (43.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20110406135330-wjufxhd0tvn3zx4z
Tags: 2.6.38-3
[ Ben Hutchings ]
* [ppc64] Add to linux-tools package architectures (Closes: #620124)
* [amd64] Save cr4 to mmu_cr4_features at boot time (Closes: #620284)
* appletalk: Fix bugs introduced when removing use of BKL
* ALSA: Fix yet another race in disconnection
* cciss: Fix lost command issue
* ath9k: Fix kernel panic in AR2427
* ses: Avoid kernel panic when lun 0 is not mapped
* PCI/ACPI: Report ASPM support to BIOS if not disabled from command line

[ Aurelien Jarno ]
* rtlwifi: fix build when PCI is not enabled.

[ Martin Michlmayr ]
* rtlwifi: Eliminate udelay calls with too large values (Closes: #620204)

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
#include <linux/list.h>
21
21
#include <linux/mempool.h>
22
22
#include <linux/mm.h>
 
23
#include <linux/elf.h>
23
24
#include <linux/ftrace.h>
 
25
#include <linux/module.h>
 
26
#include <linux/slab.h>
24
27
#include <asm/dwarf.h>
25
28
#include <asm/unwinder.h>
26
29
#include <asm/sections.h>
38
41
static struct kmem_cache *dwarf_reg_cachep;
39
42
static mempool_t *dwarf_reg_pool;
40
43
 
41
 
static LIST_HEAD(dwarf_cie_list);
 
44
static struct rb_root cie_root;
42
45
static DEFINE_SPINLOCK(dwarf_cie_lock);
43
46
 
44
 
static LIST_HEAD(dwarf_fde_list);
 
47
static struct rb_root fde_root;
45
48
static DEFINE_SPINLOCK(dwarf_fde_lock);
46
49
 
47
50
static struct dwarf_cie *cached_cie;
48
51
 
 
52
static unsigned int dwarf_unwinder_ready;
 
53
 
49
54
/**
50
55
 *      dwarf_frame_alloc_reg - allocate memory for a DWARF register
51
56
 *      @frame: the DWARF frame whose list of registers we insert on
300
305
 */
301
306
static struct dwarf_cie *dwarf_lookup_cie(unsigned long cie_ptr)
302
307
{
303
 
        struct dwarf_cie *cie;
 
308
        struct rb_node **rb_node = &cie_root.rb_node;
 
309
        struct dwarf_cie *cie = NULL;
304
310
        unsigned long flags;
305
311
 
306
312
        spin_lock_irqsave(&dwarf_cie_lock, flags);
314
320
                goto out;
315
321
        }
316
322
 
317
 
        list_for_each_entry(cie, &dwarf_cie_list, link) {
318
 
                if (cie->cie_pointer == cie_ptr) {
319
 
                        cached_cie = cie;
320
 
                        break;
 
323
        while (*rb_node) {
 
324
                struct dwarf_cie *cie_tmp;
 
325
 
 
326
                cie_tmp = rb_entry(*rb_node, struct dwarf_cie, node);
 
327
                BUG_ON(!cie_tmp);
 
328
 
 
329
                if (cie_ptr == cie_tmp->cie_pointer) {
 
330
                        cie = cie_tmp;
 
331
                        cached_cie = cie_tmp;
 
332
                        goto out;
 
333
                } else {
 
334
                        if (cie_ptr < cie_tmp->cie_pointer)
 
335
                                rb_node = &(*rb_node)->rb_left;
 
336
                        else
 
337
                                rb_node = &(*rb_node)->rb_right;
321
338
                }
322
339
        }
323
340
 
324
 
        /* Couldn't find the entry in the list. */
325
 
        if (&cie->link == &dwarf_cie_list)
326
 
                cie = NULL;
327
341
out:
328
342
        spin_unlock_irqrestore(&dwarf_cie_lock, flags);
329
343
        return cie;
335
349
 */
336
350
struct dwarf_fde *dwarf_lookup_fde(unsigned long pc)
337
351
{
338
 
        struct dwarf_fde *fde;
 
352
        struct rb_node **rb_node = &fde_root.rb_node;
 
353
        struct dwarf_fde *fde = NULL;
339
354
        unsigned long flags;
340
355
 
341
356
        spin_lock_irqsave(&dwarf_fde_lock, flags);
342
357
 
343
 
        list_for_each_entry(fde, &dwarf_fde_list, link) {
344
 
                unsigned long start, end;
345
 
 
346
 
                start = fde->initial_location;
347
 
                end = fde->initial_location + fde->address_range;
348
 
 
349
 
                if (pc >= start && pc < end)
350
 
                        break;
 
358
        while (*rb_node) {
 
359
                struct dwarf_fde *fde_tmp;
 
360
                unsigned long tmp_start, tmp_end;
 
361
 
 
362
                fde_tmp = rb_entry(*rb_node, struct dwarf_fde, node);
 
363
                BUG_ON(!fde_tmp);
 
364
 
 
365
                tmp_start = fde_tmp->initial_location;
 
366
                tmp_end = fde_tmp->initial_location + fde_tmp->address_range;
 
367
 
 
368
                if (pc < tmp_start) {
 
369
                        rb_node = &(*rb_node)->rb_left;
 
370
                } else {
 
371
                        if (pc < tmp_end) {
 
372
                                fde = fde_tmp;
 
373
                                goto out;
 
374
                        } else
 
375
                                rb_node = &(*rb_node)->rb_right;
 
376
                }
351
377
        }
352
378
 
353
 
        /* Couldn't find the entry in the list. */
354
 
        if (&fde->link == &dwarf_fde_list)
355
 
                fde = NULL;
356
 
 
 
379
out:
357
380
        spin_unlock_irqrestore(&dwarf_fde_lock, flags);
358
381
 
359
382
        return fde;
530
553
}
531
554
 
532
555
/**
533
 
 *      dwarf_unwind_stack - recursively unwind the stack
 
556
 *      dwarf_free_frame - free the memory allocated for @frame
 
557
 *      @frame: the frame to free
 
558
 */
 
559
void dwarf_free_frame(struct dwarf_frame *frame)
 
560
{
 
561
        dwarf_frame_free_regs(frame);
 
562
        mempool_free(frame, dwarf_frame_pool);
 
563
}
 
564
 
 
565
extern void ret_from_irq(void);
 
566
 
 
567
/**
 
568
 *      dwarf_unwind_stack - unwind the stack
 
569
 *
534
570
 *      @pc: address of the function to unwind
535
571
 *      @prev: struct dwarf_frame of the previous stackframe on the callstack
536
572
 *
538
574
 *      on the callstack. Each of the lower (older) stack frames are
539
575
 *      linked via the "prev" member.
540
576
 */
541
 
struct dwarf_frame * dwarf_unwind_stack(unsigned long pc,
542
 
                                        struct dwarf_frame *prev)
 
577
struct dwarf_frame *dwarf_unwind_stack(unsigned long pc,
 
578
                                       struct dwarf_frame *prev)
543
579
{
544
580
        struct dwarf_frame *frame;
545
581
        struct dwarf_cie *cie;
548
584
        unsigned long addr;
549
585
 
550
586
        /*
551
 
         * If this is the first invocation of this recursive function we
552
 
         * need get the contents of a physical register to get the CFA
553
 
         * in order to begin the virtual unwinding of the stack.
 
587
         * If we've been called in to before initialization has
 
588
         * completed, bail out immediately.
 
589
         */
 
590
        if (!dwarf_unwinder_ready)
 
591
                return NULL;
 
592
 
 
593
        /*
 
594
         * If we're starting at the top of the stack we need get the
 
595
         * contents of a physical register to get the CFA in order to
 
596
         * begin the virtual unwinding of the stack.
554
597
         *
555
598
         * NOTE: the return address is guaranteed to be setup by the
556
599
         * time this function makes its first function call.
593
636
        fde = dwarf_lookup_fde(pc);
594
637
        if (!fde) {
595
638
                /*
596
 
                 * This is our normal exit path - the one that stops the
597
 
                 * recursion. There's two reasons why we might exit
598
 
                 * here,
 
639
                 * This is our normal exit path. There are two reasons
 
640
                 * why we might exit here,
599
641
                 *
600
642
                 *      a) pc has no asscociated DWARF frame info and so
601
643
                 *      we don't know how to unwind this frame. This is
637
679
 
638
680
                } else {
639
681
                        /*
640
 
                         * Again, this is the first invocation of this
641
 
                         * recurisve function. We need to physically
642
 
                         * read the contents of a register in order to
643
 
                         * get the Canonical Frame Address for this
 
682
                         * Again, we're starting from the top of the
 
683
                         * stack. We need to physically read
 
684
                         * the contents of a register in order to get
 
685
                         * the Canonical Frame Address for this
644
686
                         * function.
645
687
                         */
646
688
                        frame->cfa = dwarf_read_arch_reg(frame->cfa_register);
667
709
        addr = frame->cfa + reg->addr;
668
710
        frame->return_addr = __raw_readl(addr);
669
711
 
 
712
        /*
 
713
         * Ah, the joys of unwinding through interrupts.
 
714
         *
 
715
         * Interrupts are tricky - the DWARF info needs to be _really_
 
716
         * accurate and unfortunately I'm seeing a lot of bogus DWARF
 
717
         * info. For example, I've seen interrupts occur in epilogues
 
718
         * just after the frame pointer (r14) had been restored. The
 
719
         * problem was that the DWARF info claimed that the CFA could be
 
720
         * reached by using the value of the frame pointer before it was
 
721
         * restored.
 
722
         *
 
723
         * So until the compiler can be trusted to produce reliable
 
724
         * DWARF info when it really matters, let's stop unwinding once
 
725
         * we've calculated the function that was interrupted.
 
726
         */
 
727
        if (prev && prev->pc == (unsigned long)ret_from_irq)
 
728
                frame->return_addr = 0;
 
729
 
670
730
        return frame;
671
731
 
672
732
bail:
673
 
        dwarf_frame_free_regs(frame);
674
 
        mempool_free(frame, dwarf_frame_pool);
 
733
        dwarf_free_frame(frame);
675
734
        return NULL;
676
735
}
677
736
 
678
737
static int dwarf_parse_cie(void *entry, void *p, unsigned long len,
679
 
                           unsigned char *end)
 
738
                           unsigned char *end, struct module *mod)
680
739
{
 
740
        struct rb_node **rb_node = &cie_root.rb_node;
 
741
        struct rb_node *parent = *rb_node;
681
742
        struct dwarf_cie *cie;
682
743
        unsigned long flags;
683
744
        int count;
774
835
 
775
836
        /* Add to list */
776
837
        spin_lock_irqsave(&dwarf_cie_lock, flags);
777
 
        list_add_tail(&cie->link, &dwarf_cie_list);
 
838
 
 
839
        while (*rb_node) {
 
840
                struct dwarf_cie *cie_tmp;
 
841
 
 
842
                cie_tmp = rb_entry(*rb_node, struct dwarf_cie, node);
 
843
 
 
844
                parent = *rb_node;
 
845
 
 
846
                if (cie->cie_pointer < cie_tmp->cie_pointer)
 
847
                        rb_node = &parent->rb_left;
 
848
                else if (cie->cie_pointer >= cie_tmp->cie_pointer)
 
849
                        rb_node = &parent->rb_right;
 
850
                else
 
851
                        WARN_ON(1);
 
852
        }
 
853
 
 
854
        rb_link_node(&cie->node, parent, rb_node);
 
855
        rb_insert_color(&cie->node, &cie_root);
 
856
 
 
857
#ifdef CONFIG_MODULES
 
858
        if (mod != NULL)
 
859
                list_add_tail(&cie->link, &mod->arch.cie_list);
 
860
#endif
 
861
 
778
862
        spin_unlock_irqrestore(&dwarf_cie_lock, flags);
779
863
 
780
864
        return 0;
782
866
 
783
867
static int dwarf_parse_fde(void *entry, u32 entry_type,
784
868
                           void *start, unsigned long len,
785
 
                           unsigned char *end)
 
869
                           unsigned char *end, struct module *mod)
786
870
{
 
871
        struct rb_node **rb_node = &fde_root.rb_node;
 
872
        struct rb_node *parent = *rb_node;
787
873
        struct dwarf_fde *fde;
788
874
        struct dwarf_cie *cie;
789
875
        unsigned long flags;
833
919
 
834
920
        /* Add to list. */
835
921
        spin_lock_irqsave(&dwarf_fde_lock, flags);
836
 
        list_add_tail(&fde->link, &dwarf_fde_list);
 
922
 
 
923
        while (*rb_node) {
 
924
                struct dwarf_fde *fde_tmp;
 
925
                unsigned long tmp_start, tmp_end;
 
926
                unsigned long start, end;
 
927
 
 
928
                fde_tmp = rb_entry(*rb_node, struct dwarf_fde, node);
 
929
 
 
930
                start = fde->initial_location;
 
931
                end = fde->initial_location + fde->address_range;
 
932
 
 
933
                tmp_start = fde_tmp->initial_location;
 
934
                tmp_end = fde_tmp->initial_location + fde_tmp->address_range;
 
935
 
 
936
                parent = *rb_node;
 
937
 
 
938
                if (start < tmp_start)
 
939
                        rb_node = &parent->rb_left;
 
940
                else if (start >= tmp_end)
 
941
                        rb_node = &parent->rb_right;
 
942
                else
 
943
                        WARN_ON(1);
 
944
        }
 
945
 
 
946
        rb_link_node(&fde->node, parent, rb_node);
 
947
        rb_insert_color(&fde->node, &fde_root);
 
948
 
 
949
#ifdef CONFIG_MODULES
 
950
        if (mod != NULL)
 
951
                list_add_tail(&fde->link, &mod->arch.fde_list);
 
952
#endif
 
953
 
837
954
        spin_unlock_irqrestore(&dwarf_fde_lock, flags);
838
955
 
839
956
        return 0;
854
971
        while (1) {
855
972
                frame = dwarf_unwind_stack(return_addr, _frame);
856
973
 
857
 
                if (_frame) {
858
 
                        dwarf_frame_free_regs(_frame);
859
 
                        mempool_free(_frame, dwarf_frame_pool);
860
 
                }
 
974
                if (_frame)
 
975
                        dwarf_free_frame(_frame);
861
976
 
862
977
                _frame = frame;
863
978
 
867
982
                return_addr = frame->return_addr;
868
983
                ops->address(data, return_addr, 1);
869
984
        }
 
985
 
 
986
        if (frame)
 
987
                dwarf_free_frame(frame);
870
988
}
871
989
 
872
990
static struct unwinder dwarf_unwinder = {
877
995
 
878
996
static void dwarf_unwinder_cleanup(void)
879
997
{
880
 
        struct dwarf_cie *cie;
881
 
        struct dwarf_fde *fde;
 
998
        struct rb_node **fde_rb_node = &fde_root.rb_node;
 
999
        struct rb_node **cie_rb_node = &cie_root.rb_node;
882
1000
 
883
1001
        /*
884
1002
         * Deallocate all the memory allocated for the DWARF unwinder.
885
1003
         * Traverse all the FDE/CIE lists and remove and free all the
886
1004
         * memory associated with those data structures.
887
1005
         */
888
 
        list_for_each_entry(cie, &dwarf_cie_list, link)
 
1006
        while (*fde_rb_node) {
 
1007
                struct dwarf_fde *fde;
 
1008
 
 
1009
                fde = rb_entry(*fde_rb_node, struct dwarf_fde, node);
 
1010
                rb_erase(*fde_rb_node, &fde_root);
 
1011
                kfree(fde);
 
1012
        }
 
1013
 
 
1014
        while (*cie_rb_node) {
 
1015
                struct dwarf_cie *cie;
 
1016
 
 
1017
                cie = rb_entry(*cie_rb_node, struct dwarf_cie, node);
 
1018
                rb_erase(*cie_rb_node, &cie_root);
889
1019
                kfree(cie);
890
 
 
891
 
        list_for_each_entry(fde, &dwarf_fde_list, link)
892
 
                kfree(fde);
 
1020
        }
893
1021
 
894
1022
        kmem_cache_destroy(dwarf_reg_cachep);
895
1023
        kmem_cache_destroy(dwarf_frame_cachep);
896
1024
}
897
1025
 
898
1026
/**
899
 
 *      dwarf_unwinder_init - initialise the dwarf unwinder
 
1027
 *      dwarf_parse_section - parse DWARF section
 
1028
 *      @eh_frame_start: start address of the .eh_frame section
 
1029
 *      @eh_frame_end: end address of the .eh_frame section
 
1030
 *      @mod: the kernel module containing the .eh_frame section
900
1031
 *
901
 
 *      Build the data structures describing the .dwarf_frame section to
902
 
 *      make it easier to lookup CIE and FDE entries. Because the
903
 
 *      .eh_frame section is packed as tightly as possible it is not
904
 
 *      easy to lookup the FDE for a given PC, so we build a list of FDE
905
 
 *      and CIE entries that make it easier.
 
1032
 *      Parse the information in a .eh_frame section.
906
1033
 */
907
 
static int __init dwarf_unwinder_init(void)
 
1034
static int dwarf_parse_section(char *eh_frame_start, char *eh_frame_end,
 
1035
                               struct module *mod)
908
1036
{
909
1037
        u32 entry_type;
910
1038
        void *p, *entry;
911
1039
        int count, err = 0;
912
 
        unsigned long len;
 
1040
        unsigned long len = 0;
913
1041
        unsigned int c_entries, f_entries;
914
1042
        unsigned char *end;
915
 
        INIT_LIST_HEAD(&dwarf_cie_list);
916
 
        INIT_LIST_HEAD(&dwarf_fde_list);
917
1043
 
918
1044
        c_entries = 0;
919
1045
        f_entries = 0;
920
 
        entry = &__start_eh_frame;
921
 
 
922
 
        dwarf_frame_cachep = kmem_cache_create("dwarf_frames",
923
 
                        sizeof(struct dwarf_frame), 0,
924
 
                        SLAB_PANIC | SLAB_HWCACHE_ALIGN | SLAB_NOTRACK, NULL);
925
 
 
926
 
        dwarf_reg_cachep = kmem_cache_create("dwarf_regs",
927
 
                        sizeof(struct dwarf_reg), 0,
928
 
                        SLAB_PANIC | SLAB_HWCACHE_ALIGN | SLAB_NOTRACK, NULL);
929
 
 
930
 
        dwarf_frame_pool = mempool_create(DWARF_FRAME_MIN_REQ,
931
 
                                          mempool_alloc_slab,
932
 
                                          mempool_free_slab,
933
 
                                          dwarf_frame_cachep);
934
 
 
935
 
        dwarf_reg_pool = mempool_create(DWARF_REG_MIN_REQ,
936
 
                                         mempool_alloc_slab,
937
 
                                         mempool_free_slab,
938
 
                                         dwarf_reg_cachep);
939
 
 
940
 
        while ((char *)entry < __stop_eh_frame) {
 
1046
        entry = eh_frame_start;
 
1047
 
 
1048
        while ((char *)entry < eh_frame_end) {
941
1049
                p = entry;
942
1050
 
943
1051
                count = dwarf_entry_len(p, &len);
949
1057
                         * entry and move to the next one because 'len'
950
1058
                         * tells us where our next entry is.
951
1059
                         */
 
1060
                        err = -EINVAL;
952
1061
                        goto out;
953
1062
                } else
954
1063
                        p += count;
960
1069
                p += 4;
961
1070
 
962
1071
                if (entry_type == DW_EH_FRAME_CIE) {
963
 
                        err = dwarf_parse_cie(entry, p, len, end);
 
1072
                        err = dwarf_parse_cie(entry, p, len, end, mod);
964
1073
                        if (err < 0)
965
1074
                                goto out;
966
1075
                        else
967
1076
                                c_entries++;
968
1077
                } else {
969
 
                        err = dwarf_parse_fde(entry, entry_type, p, len, end);
 
1078
                        err = dwarf_parse_fde(entry, entry_type, p, len,
 
1079
                                              end, mod);
970
1080
                        if (err < 0)
971
1081
                                goto out;
972
1082
                        else
979
1089
        printk(KERN_INFO "DWARF unwinder initialised: read %u CIEs, %u FDEs\n",
980
1090
               c_entries, f_entries);
981
1091
 
 
1092
        return 0;
 
1093
 
 
1094
out:
 
1095
        return err;
 
1096
}
 
1097
 
 
1098
#ifdef CONFIG_MODULES
 
1099
int module_dwarf_finalize(const Elf_Ehdr *hdr, const Elf_Shdr *sechdrs,
 
1100
                          struct module *me)
 
1101
{
 
1102
        unsigned int i, err;
 
1103
        unsigned long start, end;
 
1104
        char *secstrings = (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset;
 
1105
 
 
1106
        start = end = 0;
 
1107
 
 
1108
        for (i = 1; i < hdr->e_shnum; i++) {
 
1109
                /* Alloc bit cleared means "ignore it." */
 
1110
                if ((sechdrs[i].sh_flags & SHF_ALLOC)
 
1111
                    && !strcmp(secstrings+sechdrs[i].sh_name, ".eh_frame")) {
 
1112
                        start = sechdrs[i].sh_addr;
 
1113
                        end = start + sechdrs[i].sh_size;
 
1114
                        break;
 
1115
                }
 
1116
        }
 
1117
 
 
1118
        /* Did we find the .eh_frame section? */
 
1119
        if (i != hdr->e_shnum) {
 
1120
                INIT_LIST_HEAD(&me->arch.cie_list);
 
1121
                INIT_LIST_HEAD(&me->arch.fde_list);
 
1122
                err = dwarf_parse_section((char *)start, (char *)end, me);
 
1123
                if (err) {
 
1124
                        printk(KERN_WARNING "%s: failed to parse DWARF info\n",
 
1125
                               me->name);
 
1126
                        return err;
 
1127
                }
 
1128
        }
 
1129
 
 
1130
        return 0;
 
1131
}
 
1132
 
 
1133
/**
 
1134
 *      module_dwarf_cleanup - remove FDE/CIEs associated with @mod
 
1135
 *      @mod: the module that is being unloaded
 
1136
 *
 
1137
 *      Remove any FDEs and CIEs from the global lists that came from
 
1138
 *      @mod's .eh_frame section because @mod is being unloaded.
 
1139
 */
 
1140
void module_dwarf_cleanup(struct module *mod)
 
1141
{
 
1142
        struct dwarf_fde *fde, *ftmp;
 
1143
        struct dwarf_cie *cie, *ctmp;
 
1144
        unsigned long flags;
 
1145
 
 
1146
        spin_lock_irqsave(&dwarf_cie_lock, flags);
 
1147
 
 
1148
        list_for_each_entry_safe(cie, ctmp, &mod->arch.cie_list, link) {
 
1149
                list_del(&cie->link);
 
1150
                rb_erase(&cie->node, &cie_root);
 
1151
                kfree(cie);
 
1152
        }
 
1153
 
 
1154
        spin_unlock_irqrestore(&dwarf_cie_lock, flags);
 
1155
 
 
1156
        spin_lock_irqsave(&dwarf_fde_lock, flags);
 
1157
 
 
1158
        list_for_each_entry_safe(fde, ftmp, &mod->arch.fde_list, link) {
 
1159
                list_del(&fde->link);
 
1160
                rb_erase(&fde->node, &fde_root);
 
1161
                kfree(fde);
 
1162
        }
 
1163
 
 
1164
        spin_unlock_irqrestore(&dwarf_fde_lock, flags);
 
1165
}
 
1166
#endif /* CONFIG_MODULES */
 
1167
 
 
1168
/**
 
1169
 *      dwarf_unwinder_init - initialise the dwarf unwinder
 
1170
 *
 
1171
 *      Build the data structures describing the .dwarf_frame section to
 
1172
 *      make it easier to lookup CIE and FDE entries. Because the
 
1173
 *      .eh_frame section is packed as tightly as possible it is not
 
1174
 *      easy to lookup the FDE for a given PC, so we build a list of FDE
 
1175
 *      and CIE entries that make it easier.
 
1176
 */
 
1177
static int __init dwarf_unwinder_init(void)
 
1178
{
 
1179
        int err = -ENOMEM;
 
1180
 
 
1181
        dwarf_frame_cachep = kmem_cache_create("dwarf_frames",
 
1182
                        sizeof(struct dwarf_frame), 0,
 
1183
                        SLAB_PANIC | SLAB_HWCACHE_ALIGN | SLAB_NOTRACK, NULL);
 
1184
 
 
1185
        dwarf_reg_cachep = kmem_cache_create("dwarf_regs",
 
1186
                        sizeof(struct dwarf_reg), 0,
 
1187
                        SLAB_PANIC | SLAB_HWCACHE_ALIGN | SLAB_NOTRACK, NULL);
 
1188
 
 
1189
        dwarf_frame_pool = mempool_create(DWARF_FRAME_MIN_REQ,
 
1190
                                          mempool_alloc_slab,
 
1191
                                          mempool_free_slab,
 
1192
                                          dwarf_frame_cachep);
 
1193
        if (!dwarf_frame_pool)
 
1194
                goto out;
 
1195
 
 
1196
        dwarf_reg_pool = mempool_create(DWARF_REG_MIN_REQ,
 
1197
                                         mempool_alloc_slab,
 
1198
                                         mempool_free_slab,
 
1199
                                         dwarf_reg_cachep);
 
1200
        if (!dwarf_reg_pool)
 
1201
                goto out;
 
1202
 
 
1203
        err = dwarf_parse_section(__start_eh_frame, __stop_eh_frame, NULL);
 
1204
        if (err)
 
1205
                goto out;
 
1206
 
982
1207
        err = unwinder_register(&dwarf_unwinder);
983
1208
        if (err)
984
1209
                goto out;
985
1210
 
 
1211
        dwarf_unwinder_ready = 1;
 
1212
 
986
1213
        return 0;
987
1214
 
988
1215
out:
989
1216
        printk(KERN_ERR "Failed to initialise DWARF unwinder: %d\n", err);
990
1217
        dwarf_unwinder_cleanup();
991
 
        return -EINVAL;
 
1218
        return err;
992
1219
}
993
1220
early_initcall(dwarf_unwinder_init);