~ubuntu-branches/ubuntu/utopic/crash/utopic-updates

« back to all changes in this revision

Viewing changes to x86_64.c

  • Committer: Bazaar Package Importer
  • Author(s): Stephan Hermann
  • Date: 2008-01-19 12:49:55 UTC
  • mfrom: (0.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20080119124955-svviv1n03l4p3b6l
Tags: 4.0-4.13-1ubuntu1
* Merge from debian unstable, remaining changes:
  - debian/patches/01_spu_commands.dpatch:
    + SPU extension support
  - debian/rules:
    + Build SPU on powerpc

Show diffs side-by-side

added added

removed removed

Lines of Context:
184
184
                        machdep->machspec->modules_vaddr = MODULES_VADDR_2_6_11;
185
185
                        machdep->machspec->modules_end = MODULES_END_2_6_11;
186
186
 
 
187
                        /* 2.6.24 layout */
 
188
                        machdep->machspec->vmemmap_vaddr = VMEMMAP_VADDR_2_6_24;
 
189
                        machdep->machspec->vmemmap_end = VMEMMAP_END_2_6_24;
 
190
                        if (symbol_exists("vmemmap_populate"))
 
191
                                machdep->flags |= VMEMMAP;
 
192
 
187
193
                        machdep->uvtop = x86_64_uvtop_level4;
188
194
                        break;
189
195
 
342
348
                fprintf(fp, "%sVM_XEN", others++ ? "|" : "");
343
349
        if (machdep->flags & VM_XEN_RHEL4)
344
350
                fprintf(fp, "%sVM_XEN_RHEL4", others++ ? "|" : "");
 
351
        if (machdep->flags & VMEMMAP)
 
352
                fprintf(fp, "%sVMEMMAP", others++ ? "|" : "");
345
353
        if (machdep->flags & NO_TSS)
346
354
                fprintf(fp, "%sNO_TSS", others++ ? "|" : "");
347
355
        if (machdep->flags & SCHED_TEXT)
438
446
        fprintf(fp, "              vmalloc_end: %016lx\n", (ulong)ms->vmalloc_end);
439
447
        fprintf(fp, "            modules_vaddr: %016lx\n", (ulong)ms->modules_vaddr);
440
448
        fprintf(fp, "              modules_end: %016lx\n", (ulong)ms->modules_end);
 
449
        fprintf(fp, "            vmemmap_vaddr: %016lx %s\n", (ulong)ms->vmemmap_vaddr,
 
450
                machdep->flags & VMEMMAP ? "" : "(unused)");
 
451
        fprintf(fp, "              vmemmap_end: %016lx %s\n", (ulong)ms->vmemmap_end,
 
452
                machdep->flags & VMEMMAP ? "" : "(unused)");
441
453
        fprintf(fp, "                phys_base: %lx\n", (ulong)ms->phys_base);
442
454
        fprintf(fp, "                     pml4: %lx\n", (ulong)ms->pml4);
443
455
        fprintf(fp, "           last_pml4_read: %lx\n", (ulong)ms->last_pml4_read);
827
839
x86_64_IS_VMALLOC_ADDR(ulong vaddr)
828
840
{
829
841
        return ((vaddr >= VMALLOC_START && vaddr <= VMALLOC_END) ||
 
842
                ((machdep->flags & VMEMMAP) && 
 
843
                 (vaddr >= VMEMMAP_VADDR && vaddr <= VMEMMAP_END)) ||
830
844
                (vaddr >= MODULES_VADDR && vaddr <= MODULES_END));
831
845
}
832
846
 
3952
3966
//      fprintf(fp, "      L1 CACHE SIZE: %d\n", l1_cache_size());
3953
3967
        fprintf(fp, "KERNEL VIRTUAL BASE: %lx\n", machdep->kvbase);
3954
3968
        fprintf(fp, "KERNEL VMALLOC BASE: %lx\n", vt->vmalloc_start);
 
3969
        if (machdep->flags & VMEMMAP)
 
3970
                fprintf(fp, "KERNEL VMEMMAP BASE: %lx\n", machdep->machspec->vmemmap_vaddr);
3955
3971
        fprintf(fp, "   KERNEL START MAP: %lx\n", __START_KERNEL_map);
3956
3972
        fprintf(fp, "KERNEL MODULES BASE: %lx\n", MODULES_VADDR);
3957
3973
        fprintf(fp, "  KERNEL STACK SIZE: %ld\n", STACKSIZE());
4323
4339
#include "netdump.h"
4324
4340
 
4325
4341
/*
4326
 
 *  Determine the physical address base for relocatable kernels.
4327
 
 */
4328
 
static void
4329
 
x86_64_calc_phys_base(void)
4330
 
{
4331
 
        int i;
4332
 
        FILE *iomem;
4333
 
        char buf[BUFSIZE];
4334
 
        char *p1;
4335
 
        ulong phys_base, text_start, kernel_code_start;
4336
 
        int errflag;
4337
 
        struct vmcore_data *vd;
4338
 
        Elf64_Phdr *phdr;
4339
 
 
4340
 
        if (machdep->flags & PHYS_BASE)     /* --machdep override */
4341
 
                return;
4342
 
 
4343
 
        machdep->machspec->phys_base = 0;   /* default/traditional */
4344
 
 
4345
 
        if (!kernel_symbol_exists("phys_base"))
4346
 
                return;
4347
 
 
4348
 
        if (!symbol_exists("_text"))
4349
 
                return;
4350
 
        else
4351
 
                text_start = symbol_value("_text");
4352
 
 
4353
 
        if (ACTIVE()) {
4354
 
                if ((iomem = fopen("/proc/iomem", "r")) == NULL)
4355
 
                        return;
4356
 
        
4357
 
                errflag = 1;
4358
 
                while (fgets(buf, BUFSIZE, iomem)) {
4359
 
                        if (strstr(buf, ": Kernel code")) {
4360
 
                                clean_line(buf);
4361
 
                                errflag = 0;
4362
 
                                break;
4363
 
                        }
4364
 
                }
4365
 
                fclose(iomem);
4366
 
        
4367
 
                if (errflag)
4368
 
                        return;
4369
 
        
4370
 
                if (!(p1 = strstr(buf, "-")))
4371
 
                        return;
4372
 
                else
4373
 
                        *p1 = NULLCHAR;
4374
 
        
4375
 
                errflag = 0;
4376
 
                kernel_code_start = htol(buf, RETURN_ON_ERROR|QUIET, &errflag);
4377
 
                if (errflag)
4378
 
                        return;
4379
 
        
4380
 
                machdep->machspec->phys_base = kernel_code_start -
4381
 
                        (text_start - __START_KERNEL_map);
4382
 
        
4383
 
                if (CRASHDEBUG(1)) {
4384
 
                        fprintf(fp, "_text: %lx  ", text_start);
4385
 
                        fprintf(fp, "Kernel code: %lx -> ", kernel_code_start);
4386
 
                        fprintf(fp, "phys_base: %lx\n\n", 
4387
 
                                machdep->machspec->phys_base);
4388
 
                }
4389
 
 
4390
 
                return;
4391
 
        }
4392
 
 
4393
 
        /*
4394
 
         *  Get relocation value from whatever dumpfile format is being used.
4395
 
         */
4396
 
 
4397
 
        if (DISKDUMP_DUMPFILE()) {
4398
 
                if (diskdump_phys_base(&phys_base)) {
4399
 
                        machdep->machspec->phys_base = phys_base;
4400
 
                        if (CRASHDEBUG(1))
4401
 
                                fprintf(fp, "compressed kdump: phys_base: %lx\n",
4402
 
                                        phys_base);
4403
 
                }
4404
 
                return;
4405
 
        }
4406
 
 
4407
 
        if ((vd = get_kdump_vmcore_data())) {
4408
 
                for (i = 0; i < vd->num_pt_load_segments; i++) {
4409
 
                        phdr = vd->load64 + i;
4410
 
                        if ((phdr->p_vaddr >= __START_KERNEL_map) &&
4411
 
                            !(IS_VMALLOC_ADDR(phdr->p_vaddr))) {
4412
 
 
4413
 
                                machdep->machspec->phys_base = phdr->p_paddr - 
4414
 
                                    (phdr->p_vaddr & ~(__START_KERNEL_map));
4415
 
 
4416
 
                                if (CRASHDEBUG(1)) {
4417
 
                                        fprintf(fp, "p_vaddr: %lx p_paddr: %lx -> ",
4418
 
                                                phdr->p_vaddr, phdr->p_paddr);
4419
 
                                        fprintf(fp, "phys_base: %lx\n\n", 
4420
 
                                                machdep->machspec->phys_base);
4421
 
                                }
4422
 
                                break;
4423
 
                        }
4424
 
                }
4425
 
 
4426
 
                return;
4427
 
        }
4428
 
 
4429
 
        if (XENDUMP_DUMPFILE() && (text_start == __START_KERNEL_map)) {
4430
 
                /* 
4431
 
                 *  Xen kernels are not relocable (yet) and don't have the
4432
 
                 *  "phys_base" entry point, so this must be a xendump of a 
4433
 
                 *  fully-virtualized relocatable kernel.  No clues exist in 
4434
 
                 *  the xendump header, so hardwire phys_base to 2MB and hope
4435
 
                 *  for the best.
4436
 
                 */
4437
 
                machdep->machspec->phys_base = 0x200000;
4438
 
                if (CRASHDEBUG(1))
4439
 
                        fprintf(fp, 
4440
 
                            "default relocatable default phys_base: %lx\n",
4441
 
                                machdep->machspec->phys_base);
4442
 
        }
4443
 
}
4444
 
 
4445
 
/*
4446
4342
 *  From the xen vmcore, create an index of mfns for each page that makes
4447
4343
 *  up the dom0 kernel's complete phys_to_machine_mapping[max_pfn] array.
4448
4344
 */
4702
4598
#include "xendump.h"
4703
4599
 
4704
4600
/*
 
4601
 *  Determine the physical address base for relocatable kernels.
 
4602
 */
 
4603
static void
 
4604
x86_64_calc_phys_base(void)
 
4605
{
 
4606
        int i;
 
4607
        FILE *iomem;
 
4608
        char buf[BUFSIZE];
 
4609
        char *p1;
 
4610
        ulong phys_base, text_start, kernel_code_start;
 
4611
        int errflag;
 
4612
        struct vmcore_data *vd;
 
4613
        static struct xendump_data *xd;
 
4614
        Elf64_Phdr *phdr;
 
4615
 
 
4616
        if (machdep->flags & PHYS_BASE)     /* --machdep override */
 
4617
                return;
 
4618
 
 
4619
        machdep->machspec->phys_base = 0;   /* default/traditional */
 
4620
 
 
4621
        if (!kernel_symbol_exists("phys_base"))
 
4622
                return;
 
4623
 
 
4624
        if (!symbol_exists("_text"))
 
4625
                return;
 
4626
        else
 
4627
                text_start = symbol_value("_text");
 
4628
 
 
4629
        if (ACTIVE()) {
 
4630
                if ((iomem = fopen("/proc/iomem", "r")) == NULL)
 
4631
                        return;
 
4632
        
 
4633
                errflag = 1;
 
4634
                while (fgets(buf, BUFSIZE, iomem)) {
 
4635
                        if (strstr(buf, ": Kernel code")) {
 
4636
                                clean_line(buf);
 
4637
                                errflag = 0;
 
4638
                                break;
 
4639
                        }
 
4640
                }
 
4641
                fclose(iomem);
 
4642
        
 
4643
                if (errflag)
 
4644
                        return;
 
4645
        
 
4646
                if (!(p1 = strstr(buf, "-")))
 
4647
                        return;
 
4648
                else
 
4649
                        *p1 = NULLCHAR;
 
4650
        
 
4651
                errflag = 0;
 
4652
                kernel_code_start = htol(buf, RETURN_ON_ERROR|QUIET, &errflag);
 
4653
                if (errflag)
 
4654
                        return;
 
4655
        
 
4656
                machdep->machspec->phys_base = kernel_code_start -
 
4657
                        (text_start - __START_KERNEL_map);
 
4658
        
 
4659
                if (CRASHDEBUG(1)) {
 
4660
                        fprintf(fp, "_text: %lx  ", text_start);
 
4661
                        fprintf(fp, "Kernel code: %lx -> ", kernel_code_start);
 
4662
                        fprintf(fp, "phys_base: %lx\n\n", 
 
4663
                                machdep->machspec->phys_base);
 
4664
                }
 
4665
 
 
4666
                return;
 
4667
        }
 
4668
 
 
4669
        /*
 
4670
         *  Get relocation value from whatever dumpfile format is being used.
 
4671
         */
 
4672
 
 
4673
        if (DISKDUMP_DUMPFILE()) {
 
4674
                if (diskdump_phys_base(&phys_base)) {
 
4675
                        machdep->machspec->phys_base = phys_base;
 
4676
                        if (CRASHDEBUG(1))
 
4677
                                fprintf(fp, "compressed kdump: phys_base: %lx\n",
 
4678
                                        phys_base);
 
4679
                }
 
4680
                return;
 
4681
        }
 
4682
 
 
4683
        if ((vd = get_kdump_vmcore_data())) {
 
4684
                for (i = 0; i < vd->num_pt_load_segments; i++) {
 
4685
                        phdr = vd->load64 + i;
 
4686
                        if ((phdr->p_vaddr >= __START_KERNEL_map) &&
 
4687
                            !(IS_VMALLOC_ADDR(phdr->p_vaddr))) {
 
4688
 
 
4689
                                machdep->machspec->phys_base = phdr->p_paddr - 
 
4690
                                    (phdr->p_vaddr & ~(__START_KERNEL_map));
 
4691
 
 
4692
                                if (CRASHDEBUG(1)) {
 
4693
                                        fprintf(fp, "p_vaddr: %lx p_paddr: %lx -> ",
 
4694
                                                phdr->p_vaddr, phdr->p_paddr);
 
4695
                                        fprintf(fp, "phys_base: %lx\n\n", 
 
4696
                                                machdep->machspec->phys_base);
 
4697
                                }
 
4698
                                break;
 
4699
                        }
 
4700
                }
 
4701
 
 
4702
                return;
 
4703
        }
 
4704
 
 
4705
        if ((xd = get_xendump_data())) {
 
4706
                if (text_start == __START_KERNEL_map) {
 
4707
                       /* 
 
4708
                        *  Xen kernels are not relocable (yet) and don't have
 
4709
                        *  the "phys_base" entry point, so this is most likely 
 
4710
                        *  a xendump of a fully-virtualized relocatable kernel.
 
4711
                        *  No clues exist in the xendump header, so hardwire 
 
4712
                        *  phys_base to 2MB and hope for the best.
 
4713
                        */
 
4714
                        machdep->machspec->phys_base = 0x200000;
 
4715
                        if (CRASHDEBUG(1))
 
4716
                                fprintf(fp, 
 
4717
                                    "default relocatable phys_base: %lx\n",
 
4718
                                        machdep->machspec->phys_base);
 
4719
 
 
4720
                } else if (text_start > __START_KERNEL_map) {
 
4721
                        switch (xd->flags & (XC_CORE_ELF|XC_CORE_NO_P2M))       
 
4722
                        {
 
4723
                        /*
 
4724
                         *  If this is a new ELF-style xendump with no
 
4725
                         *  p2m information, then it also must be a
 
4726
                         *  fully-virtualized relocatable kernel.  Again,
 
4727
                         *  the xendump header is useless, and we don't
 
4728
                         *  have /proc/iomem, so presume that the kernel 
 
4729
                         *  code starts at 2MB.
 
4730
                         */ 
 
4731
                        case (XC_CORE_ELF|XC_CORE_NO_P2M):
 
4732
                                machdep->machspec->phys_base = 0x200000 - 
 
4733
                                        (text_start - __START_KERNEL_map);
 
4734
                                if (CRASHDEBUG(1))
 
4735
                                        fprintf(fp, "default relocatable " 
 
4736
                                            "phys_base: %lx\n",
 
4737
                                                machdep->machspec->phys_base);
 
4738
                                break;
 
4739
 
 
4740
                        default:
 
4741
                                break;
 
4742
                        }
 
4743
                }
 
4744
        }
 
4745
}
 
4746
 
 
4747
 
 
4748
/*
4705
4749
 *  Create an index of mfns for each page that makes up the
4706
4750
 *  kernel's complete phys_to_machine_mapping[max_pfn] array.
4707
4751
 */