{"id":20342,"date":"2018-01-29T09:26:18","date_gmt":"2018-01-29T14:26:18","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=20342"},"modified":"2020-07-17T16:04:29","modified_gmt":"2020-07-17T20:04:29","slug":"finding-a-cpu-design-bug-in-the-xbox-360","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2018\/01\/29\/finding-a-cpu-design-bug-in-the-xbox-360\/","title":{"rendered":"Finding a CPU Design Bug in the Xbox 360"},"content":{"rendered":"<p><a href=\"https:\/\/randomascii.wordpress.com\/2018\/01\/07\/finding-a-cpu-design-bug-in-the-xbox-360\/\">Bruce Dawson<\/a> (via <a href=\"https:\/\/twitter.com\/mikeash\/status\/950371016278138880\">Mike Ash<\/a>, <a href=\"https:\/\/news.ycombinator.com\/item?id=16094925\">Hacker News<\/a>):<\/p>\n<blockquote cite=\"https:\/\/randomascii.wordpress.com\/2018\/01\/07\/finding-a-cpu-design-bug-in-the-xbox-360\/\"><p>But, the CPU was for a video game console and performance trumped all so a new instruction was added &#x2013; <a href=\"https:\/\/en.wikipedia.org\/wiki\/Xbox_360_technical_specifications#CPU_data_streaming\"><em>xdcbt<\/em><\/a>. The normal PowerPC <em>dcbt<\/em> instruction was a typical prefetch instruction. The <em><a href=\"https:\/\/xathrya.id\/2015\/12\/05\/architecture-of-xbox-360\/\">xdcbt<\/a><\/em> instruction was an <em>extended<\/em> prefetch instruction that fetched straight from memory to the L1 d-cache, skipping L2. This meant that memory coherency was no longer guaranteed, but hey, we&rsquo;re video game programmers, we know what we&rsquo;re doing, it will be fine.<\/p><p>[&#8230;]<\/p><p>So, the branch predictor makes a prediction and the predicted instructions are fetched, decoded, and executed &#x2013; but not retired until the prediction is known to be correct. Sound familiar? The realization I had &#x2013; it was new to me at the time &#x2013; was what it meant to speculatively execute a prefetch. The latencies were long, so it was important to get the prefetch transaction on the bus as soon as possible, and once a prefetch had been initiated there was no way to cancel it. So a speculatively-executed <em>xdcbt<\/em> was <em>identical to a real<\/em><em>xdcbt!<\/em> (a speculatively-executed load instruction was just a prefetch, FWIW).<\/p><p>And that was the problem &#x2013; the branch predictor would sometimes cause <em>xdcbt<\/em> instructions to be speculatively executed and that was just as bad as really executing them.<\/p><p>[&#8230;]<\/p><p>I <em>knew<\/em> that would be the result and yet it was still amazing. All these years later, and even after reading about <em>Meltdown<\/em>, it&rsquo;s still nerdy cool to see solid proof that instructions that <em>were not executed<\/em> were causing crashes.<\/p><\/blockquote>\n\n<p>Previously: <a href=\"https:\/\/mjtsai.com\/blog\/2018\/01\/03\/intel-cpu-design-flaw-necessitates-kernel-page-table-isolation\/\">Intel CPU Design Flaw Necessitates Kernel Page Table Isolation<\/a>.<\/p>","protected":false},"excerpt":{"rendered":"<p>Bruce Dawson (via Mike Ash, Hacker News): But, the CPU was for a video game console and performance trumped all so a new instruction was added &#x2013; xdcbt. The normal PowerPC dcbt instruction was a typical prefetch instruction. The xdcbt instruction was an extended prefetch instruction that fetched straight from memory to the L1 d-cache, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"2020-07-17T20:04:31Z","apple_news_api_id":"57818671-6895-4160-8c79-db07ccb2217a","apple_news_api_modified_at":"2020-07-17T20:04:31Z","apple_news_api_revision":"AAAAAAAAAAD\/\/\/\/\/\/\/\/\/\/w==","apple_news_api_share_url":"https:\/\/apple.news\/AV4GGcWiVQWCMedsHzLIheg","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[2],"tags":[131,402,260,970],"class_list":["post-20342","post","type-post","status-publish","format-standard","hentry","category-technology","tag-bug","tag-powerpc","tag-processors","tag-xbox-360"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/20342","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=20342"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/20342\/revisions"}],"predecessor-version":[{"id":20343,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/20342\/revisions\/20343"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=20342"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=20342"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=20342"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}