Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

最後の楽園の開発をちょこっとだけ手伝った話

438 views

Published on

OpenBSD/sgiのPOWER Indigo2 R8000サポートをちょこっとだけ手伝ったときの記録です。
私のブログにも情報があります。
http://nullnilaki.hatenablog.com/entries/2015/12/23

Published in: Engineering
  • Be the first to comment

  • Be the first to like this

最後の楽園の開発をちょこっとだけ手伝った話

  1. 1. ? OSC 2016 Nagoya *BSD @nullnilaki
  2. 2. sgi Indigo2
  3. 3. MIPS R8000 >> hinv System: IP26 Processor: 75 Mhz R8000, with FPU Primary I-cache size: 16 Kbytes Primary D-cache size: 16 Kbytes Secondary cache size: 2 Mbytes Memory size: 512 Mbytes Graphics: GR5-XZ SCSI Disk: scsi(0)disk(1) Audio: Iris Audio Processor: version A2 revision 1.1.0
  4. 4. MIPS R8000 M88k ! http://forums.nekochan.net/viewtopic.php?t=16726745
  5. 5. MIPS R8000 TLB 384 …
  6. 6. MIPS R8000 /* * Initialize the kernel page table pointer. * This is a no-op on non-R8000 processors. */ LEAF(tlb_set_gbase, 0) j ra nop END(tlb_set_gbase) /* * void tlb_set_gbase(vaddr_t, vsize_t); */ LEAF(tlb_set_gbase, 0) /* { */ DMTC0 a0, COP_0_GBASE MTC0_HAZARD DMTC0 a1, COP_0_WORK1 MTC0_HAZARD j ra NOP END(tlb_set_gbase) /* } */ …
  7. 7. MIPS R8000 …
  8. 8. MIPS R8000 R8000 SGI Linux/MIPS R8000 TLB MIPS R10000 Silicon Graphics http://archive.linux.or.jp/JF/JFdocs/MIPS-HOWTO-9.html#ss9.8
  9. 9. R8000( )…
  10. 10. R8000( )…
  11. 11. R8000( )…
  12. 12. R8000( ) ( ´)
  13. 13. http://d.hatena.ne.jp/syuu1228/20090805 …
  14. 14. RAM disk kernel ? RAM disk kernel ? OpenBSD sgimips (Fuel )
  15. 15. ? Set name(s)? (or 'abort' or 'done') [done] Cannot determine prefetch area. Continue without verification? [no] yes Installing base57.tgz 100% |**************************| 56003 KB 03:49 Extracting etc.tgz 100% |**************************| 110 KB 00:00 Location of sets? (disk http nfs or 'done') [http] done Are you *SURE* your install is complete without 'bsd.IP26'? [no] yes Time appears wrong. Set to 'Sun Sep 6 08:56:36 JST 2015'? [yes] Saving configuration files...done. Making all device nodes...sh(8003) in realloc(): error: chunk info corrupted Abort trap done. Installing boot loader in volume header. Writing file /mnt/usr/mdec/boot-IP26 sgivol: stat /mnt/usr/mdec/boot-IP26: No such file or directory WARNING: Boot install failed. Booting from disk will not be possible IP26 RAM disk kernel RAM disk kernel netboot (ftp.jaist.ac.jp ) base57.tgz OpenBSD IP26 base57.tgz ” ”
  16. 16. ? /src/distrib/sgi/ramdisk/install.md md_installboot() { local _disk=$1 echo "Installing boot loader in volume header." if ! /usr/mdec/sgivol -w boot /mnt/usr/mdec/boot-$IPARCH $_disk; then echo "nWARNING: Boot install failed. Booting from disk will not be possible" fi for _k in /mnt/bsd{,.mp,.rd}; do [[ -f $_k.$IPARCH ]] && mv $_k.$IPARCH $_k done }
  17. 17. Makefile boot-IP26
  18. 18. RAM disk kernel ftp NetBSD sysinst(install kernel) ?ftp OpenBSD ftp anonymous ftp
  19. 19. # /mnt/usr/mdec/sgivol -w boot /mnt/usr/mdec/boot-IP26 sd0 Writing file /mnt/usr/mdec/boot-IP26 File /mnt/usr/mdec/boot-IP26 has 101640 bytes disklabel shows 17783112 sectors with 512 bytes per sector checksum: 00000000 root part: 0 swap part: 1 bootfile: /bsd Volume header files: boot offset 2 blocks, length 101640 bytes (199 blocks) SGI partitions: 0:a blocks 17779977 first 3135 type 4 (BSD4.2) 8:i blocks 3135 first 0 type 0 (Volume Header) 10:k blocks 17783112 first 0 type 6 (Volume) # mv /mnt/usr/mdec/bsd.IP26 /mnt/bsd ftp … !
  20. 20. NFS • OS NFS ! ( NIC ) • NFS NFS !
  21. 21. ?
  22. 22. ? OS panic R8000 R8000 OpenBSD R8000
  23. 23. utlbmod? >> bootp()bsd.rd.IP26 Obtaining bsd.rd.IP26 from server macbook2006 3577592+722344 entry: 0xa800000008010000 ARCS64 Firmware Found SGI-IP26, setting up. ... panic: trap: utlbmod: invalid pte Stopped at 0xa800000008294424: jr ra 0xa800000008294428: move zero,zero utlbmod panic !
  24. 24. TLB ?
  25. 25. TLB ? • OS panic utlbmod • OS panic … PTE ? • …. ? • C …
  26. 26. TLB ? …
  27. 27. C /sys/arch/mips64/include/pmap.h /* User virtual address to pte page entry */ #define uvtopte(va) (((va) >> PAGE_SHIFT) & (NPTEPG -1)) ”2”
  28. 28. Multi-user
  29. 29. ! OpenBSD …
  30. 30.
  31. 31. sgi CPU !
  32. 32. diff
  33. 33. ? • MIPS R8000 CPU … • MIPS R8000 … /src/sys/arch/mips64/mips64/cache_tfp.c /src/sys/arch/mips64/mips64/cache_tfp_subr.S /src/sys/arch/mips64/mips64/exception_tfp.S /src/sys/arch/mips64/mips64/tlb_tfp.S • miod
  34. 34. … SIGBUS SIGSEGV
  35. 35. … The 2 in the original code is log2(pte size); k0 >> PAGE_SHIFT will be the pte number. But in the page table, it is stored as an array of 32-bit words, so we need to shift it to the left by 2. The original instructions: PTR_SRL k0, PAGE_SHIFT - 2 andi k0, ((NPTEPG / 2) - 1) << 2 are equivalent to: PTR_SRL k0, PAGE_SHIFT andi k0, (NPTEPG / 2) - 1 PTR_SLL k0, 2 and guarantees the address is correctly aligned for the `lwu' instruction later.
  36. 36. 2 ! 0 0 1 4 2 8 3 12 … Page table index Page tabe Page fault Page table index PTE_LOG index PTR_SRL k0, PAGE_SHIFT - PTE_LOG andi k0, (NPTEPG - 1) << PTE_LOG Page table PTR_ADDU k1, k0 PTE_LOAD k0, 0(k1) # get pte #define PTE_LOG 2 @n_soda !
  37. 37. mips RISC -R2000/ R3000- ISBN-10: 4320025989 NIX ISBN-10: 4320025989 MIPS( ) R8000 User Manual …. http://nullnilaki.hatenablog.com/entries/2015/12/23 Miod @MiodVallat twitter BSD

×