åã³ãç§ãšç§ãã¡ã¯ãåã®åã®äžã«ããŸããŸãªUEFIã®å®è£ ãæãäžããŸãã å€ãäžåœã®GSMã¢ãã ã1ã€ãããŸããããã¯ãDell Vostro 3360ã§äžåºŠæ€åºãããå€ãã©ãããããã§ã¯æ£åžžã§ãã ã¢ããã¿ãŒãä»ããŠã¡ã€ã³PCã«æ¥ç¶ããããã€ãã®å®éšã®åŸãäœããã®çç±ã§ãPCIe Gen2ãä»ããæ¥ç¶ãæ°ã«å ¥ãããããŒããGen1ã«åãæ¿ãããã®ã§ãããå¿ èŠãªèšå®ãUEFIã»ããã¢ããã§èŠã€ãããŸããã§ããã æ²ããããšã§ãããèŽåœçã§ã¯ãããŸãããå€ãã®å Žåãããã€ã¹ã¡ãŒã«ãŒã¯å ã®UEFIã¡ãŒã«ãŒã®ã¡ãã¥ãŒãåé€ãããåã«ããããé衚瀺ã«ãããã代ããã«ç¬èªã®ã¡ãã¥ãŒã衚瀺ããŸãããã®ãããå°ããªããŒã¹ãšã³ãžãã¢ãªã³ã°ããåŸãå ã®ã¡ãã¥ãŒãå ã®å Žæã«æ»ãããšãã§ããŸãã ä»åã¯ã1ã€ã®IDAãã¢ã§ã¯äžååã§ãã ææ°ã®UEFIã®DXEãã©ã€ããŒã¯x86-64ã¢ãŒããã¯ãã£çšã«æ§ç¯ãããŠããããã代ããã«radare2ã䜿çšããŸãã
ç§ã¯æŒé£æã«100幎ã«ããã£ãŠæ å ãåæ§ã®ä¿®æ£ã®çºèŠè ã®ãµããããŸãããããã®ãããªä¿®æ£ãèªåã§è¡ãæ¹æ³ã瀺ããŠã¿ãŸãã
ãŸã èå³ããããªããç«ãžããããã
ããæ°
ã¡ãã¥ãŒã®å€æŽã¯ãæåã¯äœããã®çç±ã§ã¡ãã¥ãŒã«ã»ãšãã©ã¢ã¯ã»ã¹ã§ããªã人ãã¡ã®éã§ãããªãå€ããããç¥ããã人æ°ã®ããå€æŽã§ãã ã»ãšãã©ã®å Žåããããã®çç±ã¯ãã§ããããããšã¯èšããªãããMEãã»ãŒå®å šã«ç¡å¹ã«ããæ©èœãUSBãããã°ïŒEHCIãããã°ããŒãïŒãæå¹ã«ããæ©èœãPCIeã¢ãŒããèšå®ããæ©èœãªã©ãéèŠãªèšå®ãé ãããŠããããšãèµ·ãããŸãã éã®çç£è ã¯ãããã¥ã¡ã³ãã§èª¬æããŠãµããŒãã«ãéããããããããã誰ã§ãã§ã¯ãªããã¡ãã¥ãŒé ç®ãé衚瀺ã«ããæ¹ãç°¡åã§ããããã®ãããªé衚瀺é ç®ã¯ã»ãšãã©ã®å Žå埩å ã§ããŸãã ããããåå¿è åã-ããã€ã¹ã®ã»ããã¢ããã¡ãã¥ãŒã«é¢ããå¿ èŠãªæ å ±ã
UEFIã»ããã¢ããã«ã€ããŠç°¡åã«
UEFIã®ã»ããã¢ããã¡ãã¥ãŒã¯èå³æ·±ãæ¹æ³ã§é 眮ãããŠãããUEFIãã¥ãŒãã³ã€ã³ã¿ãŒãã§ã€ã¹ã€ã³ãã©ã¹ãã©ã¯ãã£ã®ä»æ§ïŒ 29ã31ç« ïŒã§èª¬æãããŠããŸãããçãèšäºã§ãã¹ãŠã説æããããšã¯ã§ããŸããã詳现ã«èå³ãããå Žåã¯ãã³ã¡ã³ããæžããŠãã ããã
ããã§ããåºæ¬ã¯èª¬æãã䟡å€ããããŸãã ãã®ã¡ãã¥ãŒã¯ã VFRããã³Unicodeæååã®èšèªã§èšè¿°ããããã©ãŒã ã§æ§æãããŠããŸãïŒãã ããããã¯å®å šã«æ£çŽãªUnicodeã§ã¯ãªããUCS-2ã®ã¿ã§ãïŒã ãã©ãŒã ã¯IDãä»ããŠæååã«é¢é£ä»ããããããŒã«ã©ã€ãºã容æã«ãªããŸãã
VFRã®æãäžè¬çãªã¡ãã¥ãŒé ç®ã§ããã³ã³ãããã¯ã¹ã¯ã次ã®ãããªãã®ã§ãã
oneof varid = SETUP_DATA.PrimaryPcie, prompt = STRING_TOKEN(STR_PRIMARY_PCIE), help = STRING_TOKEN(STR_PRIMARY_PCIE_HELP), option text = STRING_TOKEN(STR_COMMON_AUTO), value = 0, flags = DEFAULT | MANUFACTURING | RESET_REQUIRED; option text = STRING_TOKEN(STR_COMMON_PCIE1), value = 1, flags = RESET_REQUIRED; option text = STRING_TOKEN(STR_COMMON_PCIE2), value = 2, flags = RESET_REQUIRED; option text = STRING_TOKEN(STR_COMMON_PCIE3), value = 3, flags = RESET_REQUIRED; option text = STRING_TOKEN(STR_COMMON_PCIE4), value = 4, flags = RESET_REQUIRED; option text = STRING_TOKEN(STR_COMMON_PCIE5), value = 5, flags = RESET_REQUIRED; option text = STRING_TOKEN(STR_COMMON_PCIE6), value = 6, flags = RESET_REQUIRED; option text = STRING_TOKEN(STR_COMMON_PCIE7), value = 7, flags = RESET_REQUIRED; endoneof;
ãããŠããã®è¡ã¯æ¬¡ã®ããã«ãªããŸãã
#string STR_PRIMARY_PCIE #language eng "Primary PCIe"
ãããããvarid = SETUP_DATA.PrimaryPcieã®ã¿ã«èª¬æãå¿ èŠã§ãã äºå®ãã¡ãã¥ãŒå ã®95ïŒ ã¯ã NVRAMã®å€æ°ãžã®åãªãã€ã³ã¿ãŒãã§ã€ã¹ã«ãããŸããã å€æ°ã¯ããŸããŸãªãããã¯ïŒããããvarstoreïŒã«é 眮ã§ããŸãããã»ãšãã©ã®å Žåãã»ããã¢ããããã¢ã¯ã»ã¹ã§ããèšå®ã¯éåžžã«å€§ããªSETUP_DATAãããã¯ã«æ ŒçŽãããŸãããã®ãããã¯ã¯ãã»ããã¢ãããšåŒã°ããå€æ°ã«å®å šã«æ ŒçŽãããŸãã æ®ãã®5ïŒ ã¯ãçŸåšã®æéãã³ã³ããŒãã³ãã®æž©åºŠããã¡ã³é床ãªã©ã®å€ã®ãããªã€ã³ã¿ã©ã¯ãã£ããªã¡ãã¥ãŒé ç®ã§ããã察å¿ããã¡ãã¥ãŒé ç®ã«é¢é£ä»ããããã³ãŒã«ããã¯é¢æ°ã«ãã£ãŠåŠçãããŸãããããã¯å¥ã®è©±ã§ãã
ã¡ãã¥ãŒé ç®ã¯ãã©ãŒã ã«åéããããã©ãŒã ã¯å éšè¡šçŸïŒ IFR ïŒã«ã³ã³ãã€ã«ããããã©ãŒã ã»ããã«ã¢ã»ã³ãã«ããããŠãŒã¶ãŒãåãåã£ããã¹ãŠã®ãã©ãŒã ãUIãšããŠè¡šç€ºãããšã³ãžã³ã§ããFormBrowserã®å ¥åã«éãããŸãã FormBrowsersã®å®è£ ã¯ããã€ãã®è©³çŽ°ãç°ãªããã»ãšãã©ã®å ŽåãAMIã®Intelããã®ãªãã¡ã¬ã³ã¹å®è£ ããé ããããŸãããåçŽãªçç±ã«ãããæåã¯ãªãã¡ã¬ã³ã¹å®è£ ãå€§å¹ ã«é ããªããŸããã ã¡ãã¥ãŒã¯12ãæã®ç°ãªãå Žæã«ä¿åãããUIãåŒã³åºããããã³ã«åéããå¿ èŠããã£ããããAMIã¯TSEå®è£ ãAMIBIOS8ããUEFIã«é©åãããŸããïŒçŸåšã§ãããŸããŸãªæåãåããŠããŸãïŒã
ç§ã®å ŽåãUEFIã¯Phoenix SecureCore Tiano 2.3ãã©ãããã©ãŒã ã«åºã¥ããŠãããFormBrowserã¯ã»ãŒæšæºçã«æ§ç¯ãããŠããŸããåã¿ãïŒã¡ã€ã³ãã¢ããã³ã¹ãã»ãã¥ãªãã£ãããŒããçµäºïŒã®ãã©ãŒã ã»ããã¯åå¥ã®DXEãã©ã€ããŒã«æ ŒçŽãããFormBrowserã¯ããããšéä¿¡ããŸãç»é²ãããããã³ã«ã ç®çã®ãã©ã€ããŒïŒå ã®[詳现èšå®]ã¡ãã¥ãŒãå«ãïŒãèŠã€ããããã衚瀺ããå¿ èŠãããããšãFormBrowserã«èª¬æããçŸåšã®éåžžã®[詳现èšå®]ã®ä»£ããã«è¡šç€ºãããã®ã§ã¯ãããŸããã è¡ããïŒ
å¿ èŠãªããŒã«
UEFIToolã䜿çšããŠç»åãç·šéãã Universal IFR Extractorã䜿çšããŠãã©ãŒã ãååŸãã radare2ã䜿çšããŠformsetãã©ã€ããŒãšFormBrowserèªäœãéã¢ã»ã³ãã«ããã³æ€æ»ããå€æŽããããã¡ã€ã«ã5ãã«ã§ãã©ãã·ã¥ããããšãä¿¡é ŒããŸãã
æ€çŽ¢ãã
ãã¡ãŒã ãŠã§ã¢ãã³ããåé€ããUEFIToolã§éããæåã«å¿ èŠãªãã®ãæ¢ããŸã-ãGen1ããšããååã®PCIeããŒãã®é床ãèšå®ããŸãã
4ã€ã®ãšã³ããªã®ãã¡ã3ã€ã¯PlatfromHiiAdvancedDxeãšããååã®ãã©ã€ãã«ãããŸããPlatfromHiiAdvancedDxeã¯ããã©ãŒã ãååŸããŠå解ããããã®æ¢è£œã®åè£ã§ãã
Universal IFR Extractorãèµ·åããæœåºããããã¡ã€ã«ãžã®ãã¹ãæå®ãã[æœåº]ãã¯ãªãã¯ããŠãå¿ èŠãªãã©ãŒã ã®[詳现èšå®]ã¡ãã¥ãŒã®æ§é ã説æããããã¹ããã¡ã€ã«ãååŸããŸãã
ãã®ãã¡ã€ã«ã§ãGen1ããæ€çŽ¢ãããã®èšå®ãèŠã€ããŸãã
0x0B018 Form Set: Advanced ... 0x44020 Setting: PCIe Speed, Variable: 0x25 0x44046 Default: 8 Bit, Value: 0x0 0x44053 Default: 8 Bit, Value: 0x0 0x44060 Option: Auto, Value: 0x0 0x4406E Option: Gen1, Value: 0x1 0x4407C Option: Gen2, Value: 0x2
ããã¯ééããããŸãã-ããã¯ç®çã®ãã¡ã€ã«ã§ããããã®èšå®ã¯UEFIã»ããã¢ããã«è¡šç€ºãããŸããã
ãã ããDellSetupAdvancedDxeãã¡ã€ã«ïŒUEFIToolã®Advancedè¡ãæ€çŽ¢ããããšã§èŠã€ããïŒã«ããå¥ã®Advancedã衚瀺ãããŠãããããããã«å®è¡ããããã«å®è¡å¯èœã»ã¯ã·ã§ã³ããæœåºããŸãã
ããŠããã¡ã€ã«éã®éãã調ã¹ãäœãã©ãã§å€æŽããå¿ èŠãããã®ãââãç解ããŠã2çªç®ã§ã¯ãªã1çªç®ã®ãã¡ã€ã«ã衚瀺ãããããã«ããŸãã
ãªãµãŒã
äž¡æ¹ã®ãã¡ã€ã«ãLinux VMã«ã³ããŒããradere2ãåéããŠ2ã€ã®ç«¯æ«ãéããŸãã1ã€ã¯r2 PlatfromHiiAdvancedDxe.binãå®è¡ãããã1ã€ã¯r2 DellSetupAdvancedDxe.binãå®è¡ããŸããèµ·ååŸã Vpã³ãã³ãã䜿çšããŠéã¢ã»ã³ãã©ãŒã§èŠèŠã¢ãŒãã«åãæ¿ããŸãïŒ
ç§ãã¡ã¯ãç°ãªã移è¡ã¢ãã¬ã¹ã«ãã£ãŠã®ã¿éåããããé©ãã¹ãäžèŽã芳å¯ããŸãã ãã¹ãŠãåããã³ãã¬ãŒãããã³ãŒããçæãããããšã瀺åããŠããã®ã§ãããã»ã©éãã¯ãããŸããã FormBrowserã®ã¢ãŒããã¯ãã£ãç¥ã£ãŠããã°ããã¡ã€ã«ã¯ç°ãªãGUIDã§ã¢ã¯ã»ã¹ããããã®ãããã³ã«ãå ¬éãããšããç¹ã§ç°ãªããšä»®å®ã§ããŸãã ãããã³ã«ã¯ã gBS-> InstallProtocolInterfaceã®åŒã³åºããä»ããŠå ¬éã§ããŸãããªã¹ãã§ã¯ã次ã®ããã«ãªããŸãã
mov reg, offset gBS ; BootServices lea rcx, Handle ; - NULL lea rdx, ProtocolGuid ; - GUID xor r8d, r8d ; - , 0 lea r9, Interface ; - NULL call [reg + 80h] ; gBS->InstallProtocolInterface
çãæ€çŽ¢ã®åŸãäž¡æ¹ã®ãã¡ã€ã«ã«éåžžã«é¡äŒŒãããã³ãã¬ãŒããèŠã€ãããŸããã
ãã§ã«lea rdxãšã¯å察ã®radare2ã®ã³ã¡ã³ããããç»é²æžã¿ãããã³ã«ã®GUIDãç°ãªãããšã¯æããã§ãã
ããã§ãPlatfromHiiAdvancedDxeãã¡ã€ã«ã®GUIDãDellSetupAdvancedDxeã®GUIDã§çœ®ãæããŠåé€ã§ããŸãããDellSetupAdvancedDxeã®GUIDã§ãããã³ã«ã䜿çšããŠãããŠãŒã¶ãŒãæ£ç¢ºã«æ¢ããæ¢ã«çœ®ãæããŠããæ¹ãããã§ãããã æ€çŽ¢ã«é²ã¿ãŸãã
2ã€ã®ãšã³ããªãèŠã€ããŸããã1ã€ã¯æ¢ã«ç¥ã£ãŠããŠããã1ã€ã¯SystemFormBrowserCoreDxeãã©ã€ãã®å é ãã2C0hã®ãªãã»ããã«ãããŸãã 亀æããŠè©ŠããŠãã ããã
UPD ïŒåå¿gorodianskyiã¯ãFormBrowserã®SCTã®ä»ã®ããŒãžã§ã³ã«ã¯å€ãã®GUIDãååšããå¯èœæ§ãããããããããã¹ãŠçœ®ãæããŠããå¿ èŠãªã¿ãã¯è¡šç€ºãããªãããæ¢åã®ã¿ãã¯æ¶ãããšå ±åããŸãã 圌ã®ã±ãŒã¹ã§ã¯ãSystemSetupInfoDxeã®äžèŠãªInfoããŒãžããPlatformSetupAdvancedDxeã®GUIDãSystemSetupInfoDxeã§äœ¿çšãããŠãããã®ã«çœ®ãæãããã®ãã©ã€ããŒãåé€ããããšã§ãPlatformSetupAdvancedDxeã®ç®çã®AdvancedããŒãžïŒäœããã®çç±ã§IntelãšåŒã°ããŸãïŒã«çœ®ãæããŸãããããã®ãã©ã€ããŒã¯äžèŠã«ãªããŸããã
ã ã£ã
ã«ãªã£ãŠããŸã
ãã¹ããšçµè«
èŠã€ãã£ãGUIDã眮ãæããå€æŽãä¿åããã€ã¡ãŒãžãåæ§ç¯ããŠããã°ã©ããŒã«ãã©ãã·ã¥ããUEFIã»ããã¢ããã«ç§»åããŠã[詳现èšå®]ãéããå ã®èšå®ãå®å šã«è¡šç€ºããŸãã ãã¡ããã觊ããªãã»ããããããåããªããã®ããããŸãããæãéèŠãªããšã¯ãæçµçã«PCIeããŒã1ã®é床å¶éãèšå®ã§ããããšã§ãããã®ããã«ãç§ã¯ãããã®ãã³ã¹ãã¿ã³ããªã³ã§å§ããŸããã
å®éãããã¹ããã¡ã€ã«ãIFRã§èª¿ã¹ãŠãNVRAMã®1ãã€ããç®çã®ãã€ãã«çœ®ãæããããšã«éå®ããããšã¯ã§ããŸããããå ã®ã¡ãã¥ãŒã«æ»ãããšãå€æãããããããã§ãã
ä»ã®ãã³ããŒã®å Žåããã¹ãŠãç°ãªãæ¹æ³ã§é 眮ã§ããŸãããããã£ãŠããã®èšäºãæ®éçãªã¬ã€ããšããŠåãåããªãã§ãã ããã
ãæž èŽããããšãããããŸããã