{"id":4076,"date":"2016-07-12T14:33:43","date_gmt":"2016-07-12T04:33:43","guid":{"rendered":"https:\/\/www.flamingspork.com\/blog\/?p=4076"},"modified":"2016-07-12T14:33:43","modified_gmt":"2016-07-12T04:33:43","slug":"using-smatch-static-analysis-on-openpower-opal-firmware","status":"publish","type":"post","link":"https:\/\/www.flamingspork.com\/blog\/2016\/07\/12\/using-smatch-static-analysis-on-openpower-opal-firmware\/","title":{"rendered":"Using Smatch static analysis on OpenPOWER OPAL firmware"},"content":{"rendered":"<p>For <a href=\"https:\/\/github.com\/open-power\/skiboot\">Skiboot<\/a>, I&#8217;m always looking at new automated systems to find bugs in the code. A little while ago, I read about the <a href=\"http:\/\/smatch.sourceforge.net\/\">Smatch<\/a> tool developed by some folks at Oracle (<a href=\"https:\/\/blogs.oracle.com\/linuxkernel\/entry\/smatch_static_analysis_tool_overview\">they also wrote about using it on the Linux kernel<\/a>).<\/p>\n<p>I was eager to try it with skiboot to see if it could find anything.<\/p>\n<p>Luckily, it was pretty easy. I built Smatch according to their documentation and then built skiboot:<\/p>\n<pre>make CHECK=\"\/home\/stewart\/smatch\/smatch\" C=1 -j20 all check<\/pre>\n<p>Due to some differences in how we implement abort() and assert() in skiboot, I added &#8220;_abort&#8221;, &#8220;abort&#8221; and &#8220;assert_fail&#8221; to smatch_data\/no_return_funcs in the Smatch source tree to silence some false positives.<\/p>\n<p>It seems that there&#8217;s a few useful warnings there (some of which I&#8217;ve fixed in skiboot master already), along with some false positives around the preprocessor\/complier tricks we do to ensure at compile time that an OPAL call definition has the correct number of arguments specified.<\/p>\n<p>So far, so good though. Try it on your project!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>For Skiboot, I&#8217;m always looking at new automated systems to find bugs in the code. A little while ago, I read about the Smatch tool developed by some folks at Oracle (they also wrote about using it on the Linux &hellip; <a href=\"https:\/\/www.flamingspork.com\/blog\/2016\/07\/12\/using-smatch-static-analysis-on-openpower-opal-firmware\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[76,570,588,615],"tags":[636,668,667,666],"class_list":["post-4076","post","type-post","status-publish","format-standard","hentry","category-code","category-ibm-work-et-al","category-opal","category-powerpc","tag-opal","tag-skibooto","tag-smatch","tag-static-analysis"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p5a6n8-13K","jetpack-related-posts":[{"id":3940,"url":"https:\/\/www.flamingspork.com\/blog\/2015\/02\/03\/building-openpower-firmware-for-use-in-power8-simulator\/","url_meta":{"origin":4076,"position":0},"title":"Building OpenPower firmware for use in POWER8 Simulator","author":"Stewart Smith","date":"2015-02-03","format":false,"excerpt":"Previously, I blogged on how to Run skiboot (OPAL) on the POWER8 Simulator. If you want to build the full Open Power firmware environment, including the Petitboot bootloader and kernel, you can now do so! My pull request for an op-build target for the simulator has been merged, so you\u2026","rel":"","context":"In &quot;code&quot;","block_context":{"text":"code","link":"https:\/\/www.flamingspork.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3919,"url":"https:\/\/www.flamingspork.com\/blog\/2014\/12\/11\/skiboot-4-1\/","url_meta":{"origin":4076,"position":1},"title":"skiboot-4.1","author":"Stewart Smith","date":"2014-12-11","format":false,"excerpt":"I just posted this to the mailing list, but I've tagged skiboot-4.1, so we have another release! There's a good amount of changes since 4.0 nearly a month ago and this is the second release since we hit github back in July. For the full set of changes, \"git log\"\u2026","rel":"","context":"In &quot;code&quot;","block_context":{"text":"code","link":"https:\/\/www.flamingspork.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3912,"url":"https:\/\/www.flamingspork.com\/blog\/2014\/12\/03\/running-skiboot-opal-on-the-power8-simulator\/","url_meta":{"origin":4076,"position":2},"title":"Running skiboot (OPAL) on the POWER8 Simulator","author":"Stewart Smith","date":"2014-12-03","format":false,"excerpt":"skiboot is open source boot and runtime firmware for OpenPOWER. On real POWER8 hardware, you will also need HostBoot to do this (basically, to make the chip work) but in a functional simulator (such as this one released by IBM) you don't need a bunch of hardware procedures to make\u2026","rel":"","context":"In &quot;code&quot;","block_context":{"text":"code","link":"https:\/\/www.flamingspork.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3972,"url":"https:\/\/www.flamingspork.com\/blog\/2015\/06\/16\/opal-firmware-specification-conformance-and-documentation\/","url_meta":{"origin":4076,"position":3},"title":"OPAL firmware specification, conformance and documentation","author":"Stewart Smith","date":"2015-06-16","format":false,"excerpt":"Now that we have an increasing amount of things that run on top of OPAL: Linux hello_world (in skiboot tree) ppc64le_hello (as I wrote about yesterday) FreeBSD and that the OpenPower ecosystem is rapidly growing (especially around people building OpenPower machines), the need for more formal specification, conformance testing and\u2026","rel":"","context":"In &quot;code&quot;","block_context":{"text":"code","link":"https:\/\/www.flamingspork.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3775,"url":"https:\/\/www.flamingspork.com\/blog\/2014\/07\/17\/openpower-firmware-up-on-github\/","url_meta":{"origin":4076,"position":4},"title":"OpenPower firmware up on github!","author":"Stewart Smith","date":"2014-07-17","format":false,"excerpt":"With the whole OpenPower thing, a lot of low level firmware is being open sourced, which is really exciting for the platform - the less proprietary code sitting in memory the better in my books. If you go to https:\/\/github.com\/open-power you'll see code for a bunch of the low level\u2026","rel":"","context":"In &quot;code&quot;","block_context":{"text":"code","link":"https:\/\/www.flamingspork.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3965,"url":"https:\/\/www.flamingspork.com\/blog\/2015\/06\/12\/gcov-code-coverage-for-openpower-firmware\/","url_meta":{"origin":4076,"position":5},"title":"gcov code coverage for OpenPower firmware","author":"Stewart Smith","date":"2015-06-12","format":false,"excerpt":"For skiboot (which provides the OPAL boot and runtime firmware for OpenPower machines), I've been pretty interested at getting some automated code coverage data for booting on real hardware (as well as in a simulator). Why? Well, it's useful to see that various test suites are actually testing what you\u2026","rel":"","context":"In &quot;code&quot;","block_context":{"text":"code","link":"https:\/\/www.flamingspork.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/www.flamingspork.com\/blog\/wp-json\/wp\/v2\/posts\/4076","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.flamingspork.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.flamingspork.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.flamingspork.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.flamingspork.com\/blog\/wp-json\/wp\/v2\/comments?post=4076"}],"version-history":[{"count":1,"href":"https:\/\/www.flamingspork.com\/blog\/wp-json\/wp\/v2\/posts\/4076\/revisions"}],"predecessor-version":[{"id":4077,"href":"https:\/\/www.flamingspork.com\/blog\/wp-json\/wp\/v2\/posts\/4076\/revisions\/4077"}],"wp:attachment":[{"href":"https:\/\/www.flamingspork.com\/blog\/wp-json\/wp\/v2\/media?parent=4076"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.flamingspork.com\/blog\/wp-json\/wp\/v2\/categories?post=4076"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.flamingspork.com\/blog\/wp-json\/wp\/v2\/tags?post=4076"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}