Z-team
    想深入了解下linux kernel中vfs这一subsystem,但是自己读相关的源码很是费力,希望以后能有这一知识的全面介绍,很是期待。
    留言板  发表时间:2016-10-10 21:13
    vachel
    请问ARMv8里面区分线性地址和虚拟地址吗? 比如kmalloc出来的地址通过virt_to_phys转换就能得到PA.但是Vmalloc就不能这么算. 测试方法, 将kmalloc和vmalloc的内存填好固定的值, 打印出对应的PA. 然后通过devmem PA 读对应的内容. 测试代码: //extern struct mm_struct init_mm; pgd_t *pgd; pgd_t *pgd_temp; pmd_t *pmd; pte_t *pte; pud_t *pud; unsigned long va; int* n_kmalloc = (int*)kmalloc(32, GFP_KERNEL); int* n_vmalloc = (int*)vmalloc(sizeof(int)); *n_kmalloc = 0x1234; *n_vmalloc = 0x4321; /**************************************************************test kmalloc**********************************************************/ va = (unsigned long)n_kmalloc; printk(" Test 1, use virt_to_phys get kmalloc PA\n"); printk("kmalloc virt_to_phy = %lx\n ", virt_to_phys(n_kmalloc)); printk(" Test 2, use kernel pgd translation kmalloc to PA \n"); // ffffffc000e88000 B swapper_pg_dir pgd = 0xffffffc000e88000; printk("pgd_index = 0x%x\n", pgd_index(va)); pgd_temp = pgd+pgd_index(va); printk("[%p][%08lx] *pgd = %016llx, pgd = %p, ", n_kmalloc,va, pgd_val(*pgd_temp), pgd_temp); do { if (pgd_none(*pgd_temp) || pgd_bad(*pgd_temp)) break; pud = pud_offset(pgd_temp, va); if (pud_none(*pud) || pud_bad(*pud)) break; pmd = pmd_offset(pud, va); printk(", *pmd=%016llx", pmd_val(*pmd)); if (pmd_none(*pmd) || pmd_bad(*pmd)) break; pte = pte_offset_map(pmd, va); printk(", *pte=%016llx", pte_val(*pte)); } while(0); printk("\n"); printk("Test 3, use mm_struct pgd translation kmalloc to PA\n"); pgd = current->mm->pgd; printk("pgd_index = 0x%x\n", pgd_index(va)); pgd_temp = pgd+pgd_index(va); printk("[%p] [%08lx] *pgd = %016llx, pgd = %p, ", n_kmalloc, va, pgd_val(*pgd_temp), pgd_temp); do { if (pgd_none(*pgd_temp) || pgd_bad(*pgd_temp)) break; pud = pud_offset(pgd_temp, va); if (pud_none(*pud) || pud_bad(*pud)) break; pmd = pmd_offset(pud, va); printk(", *pmd=%016llx", pmd_val(*pmd)); if (pmd_none(*pmd) || pmd_bad(*pmd)) break; pte = pte_offset_map(pmd, va); printk(", *pte=%016llx", pte_val(*pte)); } while(0); printk("\n"); /**************************************************************test vmalloc**********************************************************/ va = (unsigned long)n_vmalloc; printk(" Test 1, use virt_to_phys get vmalloc PA\n"); printk("vmalloc virt_to_phy = %lx\n ", virt_to_phys(n_vmalloc)); printk(" Test 2, use kernel pgd translation vmalloc to PA \n"); // ffffffc000e88000 B swapper_pg_dir pgd = 0xffffffc000e88000; printk("pgd_index = 0x%x\n", pgd_index(va)); pgd_temp = pgd+pgd_index(va); printk("[%p] [%08lx] *pgd = %016llx, pgd = %p, ", n_vmalloc, va, pgd_val(*pgd_temp), pgd_temp); do { if (pgd_none(*pgd_temp) || pgd_bad(*pgd_temp)) break; pud = pud_offset(pgd_temp, va); if (pud_none(*pud) || pud_bad(*pud)) break; pmd = pmd_offset(pud, va); printk(", *pmd=%016llx", pmd_val(*pmd)); if (pmd_none(*pmd) || pmd_bad(*pmd)) break; pte = pte_offset_map(pmd, va); printk(", *pte=%016llx", pte_val(*pte)); } while(0); printk("\n"); printk("Test 3, use mm_struct pgd translation vmalloc to PA\n"); pgd = current->mm->pgd; printk("pgd_index = 0x%x\n", pgd_index(va)); pgd_temp = pgd+pgd_index(va); printk("[%p] [%08lx]*pgd = %016llx, pgd = %p, ", n_vmalloc, va, pgd_val(*pgd_temp), pgd_temp); do { if (pgd_none(*pgd_temp) || pgd_bad(*pgd_temp)) break; pud = pud_offset(pgd_temp, va); if (pud_none(*pud) || pud_bad(*pud)) break; pmd = pmd_offset(pud, va); printk(", *pmd=%016llx", pmd_val(*pmd)); if (pmd_none(*pmd) || pmd_bad(*pmd)) break; pte = pte_offset_map(pmd, va); printk(", *pte=%016llx", pte_val(*pte)); } while(0); printk("\n"); //dump pgd // print_hex_dump(KERN_ERR, "PGD raw data:", DUMP_PREFIX_ADDRESS,16,1,pgd,4096,true); //panic // *(int*)0x2 = 0; /**/ while(true){ } /**/ 测试结论: # [ 4132.980000] Test 1, use virt_to_phys get kmalloc PA [ 4132.984000] kmalloc virt_to_phy = 32184ad40 Test 2, use kernel pgd translation kmalloc to PA [ 4132.992000] pgd_index = 0x102 [ 4132.996000] [ffffffc09d44ad40][ffffffc09d44ad40] *pgd = 000000005d1fa003, pgd = ffffffc000e88810, , *pmd=0040000321800711 [ 4133.008000] Test 3, use mm_struct pgd translation kmalloc to PA [ 4133.012000] pgd_index = 0x102 [ 4133.016000] [ffffffc09d44ad40] [ffffffc09d44ad40] *pgd = 0000000000000000, pgd = ffffffc09ab62810, [ 4133.024000] Test 1, use virt_to_phys get vmalloc PA [ 4133.032000] vmalloc virt_to_phy = ffffffc0260ed000 Test 2, use kernel pgd translation vmalloc to PA [ 4133.040000] pgd_index = 0x0 [ 4133.044000] [ffffff8005eed000] [ffffff8005eed000] *pgd = 000000033ac05003, pgd = ffffffc000e88000, , *pmd=00000000de236003, *pte=02e00003370e3713 [ 4133.056000] Test 3, use mm_struct pgd translation vmalloc to PA [ 4133.060000] pgd_index = 0x0 [ 4133.064000] [ffffff8005eed000] [ffffff8005eed000]*pgd = 0000000000000000, pgd = ffffffc09ab62000, busybox devmem 0x32184ad40 0x00001234 busybox devmem 0xffffffc0260ed000 devmem: mmap: Invalid argument
    macooma
    博主的文章对于我这样初学armv8的晚辈来讲真是提供了极大的参考啊,感谢博主的无私精神! 有个问题想请教一下,如下: idmap_pg_dir是为turn on MMU准备的一致性映射,物理地址的高16bit都是0,因此identity mapping必定是选择TTBR0_EL1指向的各级地址翻译表。 ------------------------------------------------------------------------------------- 请问这里的“必定”是因何而来呢? 谢谢!
    ARM64的启动过程之(四):打开MMU  发表时间:2016-10-10 14:21
    andreaji
    @linuxer:您好 Linuxer,感谢您的及时回复,不过我还有一事不明: posix-clock.c 中并没有使用 module_init 宏,所以我不理解 posix clock 如何能够成为独立的内核模块。 这也是我无法判断 posix_clock_file_operations.owner 到底是是指向 ptp_clock 模块还是指向 posix clock 的根本原因。 还请 Linuxer 指点一下。多谢!
    Linux时间子系统之(五):POSIX Clock  发表时间:2016-10-10 11:05
    coco
    @linuxer:原来是什么配置就保持什么配置,个人理解,这里的配置指的是chip层的配置。
    lamaboy
    @linuxer:下面的代码看看就明白了 set_handle_irq(gic_handle_irq); static void __exception_irq_entry gic_handle_irq(struct pt_regs *regs) { u32 irqstat, irqnr; struct gic_chip_data *gic = &gic_data[0]; void __iomem *cpu_base = gic_data_cpu_base(gic); do { irqstat = readl_relaxed(cpu_base + GIC_CPU_INTACK); irqnr = irqstat & GICC_IAR_INT_ID_MASK; if (likely(irqnr > 15 && irqnr < 1020)) { if (static_key_true(&supports_deactivate)) writel_relaxed(irqstat, cpu_base + GIC_CPU_EOI); handle_domain_irq(gic->domain, irqnr, regs); continue; } if (irqnr < 16) { writel_relaxed(irqstat, cpu_base + GIC_CPU_EOI); if (static_key_true(&supports_deactivate)) writel_relaxed(irqstat, cpu_base + GIC_CPU_DEACTIVATE); #ifdef CONFIG_SMP handle_IPI(irqnr, regs); #endif continue; } break; } while (1); }
    wowo
    @西人:之所以两个!,我的理解,他是要保持“形式上”的正确性,因为判断的是dev->power.can_wakeup == capable,而不是!dev->power.can_wakeup == !capable。当然,实际的效果是一样的。
    Linux电源管理(7)_Wakeup events framework  发表时间:2016-10-09 20:10
    wowo
    @twinkle:"会在下一篇文章继续分析"这篇文章确实没有接着写(考虑到PM domian使用还不是很广泛)~~
    Linux PM domain framework(1)_概述和使用流程  发表时间:2016-10-09 19:46
    wowo
    @温柔海洋:多谢鼓励,现在还只是写着玩玩,出书的事情还没考虑呢:-)
    X-012-KERNEL-serial early console的移植  发表时间:2016-10-09 19:45
    wowo
    @ooonebook:不用客气哈~~
    X-012-KERNEL-serial early console的移植  发表时间:2016-10-09 19:44

共6985条287/699上一页 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 下一页
Copyright @ 2013-2015 蜗窝科技 All rights reserved. Powered by emlog