{"action":"created","comment":{"url":"https://api.github.com/repos/intel/haxm/pulls/comments/231063757","pull_request_review_id":171942408,"id":231063757,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzMTA2Mzc1Nw==","diff_hunk":"@@ -0,0 +1,290 @@\n+/*\n+ * Copyright (c) 2018 Kryptos Logic\n+ *\n+ * Redistribution and use in source and binary forms, with or without\n+ * modification, are permitted provided that the following conditions are met:\n+ *\n+ *   1. Redistributions of source code must retain the above copyright notice,\n+ *      this list of conditions and the following disclaimer.\n+ *\n+ *   2. Redistributions in binary form must reproduce the above copyright\n+ *      notice, this list of conditions and the following disclaimer in the\n+ *      documentation and/or other materials provided with the distribution.\n+ *\n+ *   3. Neither the name of the copyright holder nor the names of its\n+ *      contributors may be used to endorse or promote products derived from\n+ *      this software without specific prior written permission.\n+ *\n+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\n+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n+ * POSSIBILITY OF SUCH DAMAGE.\n+ */\n+\n+#include \"include/name.h\"\n+#include \"include/vmx.h\"\n+\n+const char *name_vmcs_component(int value)\n+{\n+    // Intel SDM Vol. 3C: Table 24-17. Structure of VMCS Component Encoding\n+#define HASH(x) \\\n+    (((x) & 0x003E) >> 1) /* Index */ | \\","path":"core/name.c","position":38,"original_position":38,"commit_id":"24fdff5da8a15347463bfe12e35da56fbdd74cef","original_commit_id":"e4b9aac0370f1386974a646779c58460f6ecb98e","user":{"login":"raphaelning","id":4811885,"node_id":"MDQ6VXNlcjQ4MTE4ODU=","avatar_url":"https://avatars2.githubusercontent.com/u/4811885?v=4","gravatar_id":"","url":"https://api.github.com/users/raphaelning","html_url":"https://github.com/raphaelning","followers_url":"https://api.github.com/users/raphaelning/followers","following_url":"https://api.github.com/users/raphaelning/following{/other_user}","gists_url":"https://api.github.com/users/raphaelning/gists{/gist_id}","starred_url":"https://api.github.com/users/raphaelning/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/raphaelning/subscriptions","organizations_url":"https://api.github.com/users/raphaelning/orgs","repos_url":"https://api.github.com/users/raphaelning/repos","events_url":"https://api.github.com/users/raphaelning/events{/privacy}","received_events_url":"https://api.github.com/users/raphaelning/received_events","type":"User","site_admin":false},"body":"> [...] since we can directly observe the component_index_t values, and simply \"see\" if our mask is compact enough.\r\n\r\nAh, that's an interesting perspective. I was going through all the tables in Appendix B and focusing on the Index column... Sure, please keep the hardcoded bitmasks.","created_at":"2018-11-06T10:07:47Z","updated_at":"2018-11-06T10:07:48Z","html_url":"https://github.com/intel/haxm/pull/119#discussion_r231063757","pull_request_url":"https://api.github.com/repos/intel/haxm/pulls/119","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/intel/haxm/pulls/comments/231063757"},"html":{"href":"https://github.com/intel/haxm/pull/119#discussion_r231063757"},"pull_request":{"href":"https://api.github.com/repos/intel/haxm/pulls/119"}},"in_reply_to_id":231019141},"pull_request":{"url":"https://api.github.com/repos/intel/haxm/pulls/119","id":228539427,"node_id":"MDExOlB1bGxSZXF1ZXN0MjI4NTM5NDI3","html_url":"https://github.com/intel/haxm/pull/119","diff_url":"https://github.com/intel/haxm/pull/119.diff","patch_url":"https://github.com/intel/haxm/pull/119.patch","issue_url":"https://api.github.com/repos/intel/haxm/issues/119","number":119,"state":"open","locked":false,"title":"Refactored dumping and logging code","user":{"login":"AlexAltea","id":5306886,"node_id":"MDQ6VXNlcjUzMDY4ODY=","avatar_url":"https://avatars3.githubusercontent.com/u/5306886?v=4","gravatar_id":"","url":"https://api.github.com/users/AlexAltea","html_url":"https://github.com/AlexAltea","followers_url":"https://api.github.com/users/AlexAltea/followers","following_url":"https://api.github.com/users/AlexAltea/following{/other_user}","gists_url":"https://api.github.com/users/AlexAltea/gists{/gist_id}","starred_url":"https://api.github.com/users/AlexAltea/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AlexAltea/subscriptions","organizations_url":"https://api.github.com/users/AlexAltea/orgs","repos_url":"https://api.github.com/users/AlexAltea/repos","events_url":"https://api.github.com/users/AlexAltea/events{/privacy}","received_events_url":"https://api.github.com/users/AlexAltea/received_events","type":"User","site_admin":false},"body":"As discussed in https://github.com/intel/haxm/pull/108#issuecomment-435691965, there's few improvements that seemed to me a step in the right direction.\r\nLet me know your thoughts on the matter.\r\n\r\n## Changes\r\n\r\n- **Refactored VMCS dumping code**: The previous implementation of `dump_vmcs` obtained the VMCS component name by hashing its value with a gperf-generated perfect hash function at *vmcs_names.c*. These compact hashes were used as indices in a manually-initialized table of names. This results in lots of boilerplate code, manual initialization/deinitialization and a dependency in gperf.\r\n\r\n   This new approach uses a switch/case to dispatch the component names and compactifies the component encoding with the macro `HASH` to \"encourage\" the compiler to implement the switch/case via jump tables. The approach works in GCC, Clang, MSVC ([check Godbolt snippet](https://godbolt.org/z/-davh9)). Advantages:\r\n\r\n   - Less code.\r\n   - No external dependencies.\r\n   - No memory allocated at runtime.\r\n   - Better performance: No need to query an extra table to compute the perfect hash.\r\n   - Perfect hashing tested at build-time: If the hash macro maps two components to the same value, the file won't compile.\r\n\r\n* Centralized all dumping-related functions in *dump.c* (renamed from *dump_vmcs.c*). Not sure if this is the best location, but it probably is better than having inlined snippets (that are either commented out or disabled via preprocessor). More functions could be added to this file, e.g. dumping segment selectors.\r\n\r\n* Created *name.c* to handle all enum-to-string conversions via functions prefixed with `name_`. For now I've handled just VMX error and exit codes (aside from the previous VMCS components), but more codes could be added there if required.\r\n\r\n* **Improved old logging messages**: It looks as if certain log messages (in particular `hax_debug`/`hax_log` ones), had been written long time ago and thus do not fully comply with most of the codebase. Changes done:\r\n   - Removed unnecessary \"HAX: \" prefix from certain calls to log functions. This was most likely a leftover from older HAXM revisions, since nowadays log functions add automatically the corresponding prefix.\r\n   - Promoted some `hax_debug`/`hax_log` to `hax_error` in the case of actual errors, e.g. in `cpu_vmentry_failed`.\r\n\r\n---\r\n\r\n@raphaelning Is there any reason to preserve `hax_log` functions as-is instead of promoting them directly to `hax_info`? At the moment they are macro'ed to `hax_info`: Was this intentional, e.g. to change the macro during as a \"debugging hack during development\", or can we just remove the macro?\r\n\r\nIf you think we could get rid of this macro, I can amend the last commit and force-push the change.\r\n","created_at":"2018-11-06T00:39:59Z","updated_at":"2018-11-06T10:07:48Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3f050f31c69b067d99b054fda44bbdda50797710","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/intel/haxm/pulls/119/commits","review_comments_url":"https://api.github.com/repos/intel/haxm/pulls/119/comments","review_comment_url":"https://api.github.com/repos/intel/haxm/pulls/comments{/number}","comments_url":"https://api.github.com/repos/intel/haxm/issues/119/comments","statuses_url":"https://api.github.com/repos/intel/haxm/statuses/24fdff5da8a15347463bfe12e35da56fbdd74cef","head":{"label":"kryptoslogic:dump","ref":"dump","sha":"24fdff5da8a15347463bfe12e35da56fbdd74cef","user":{"login":"kryptoslogic","id":43409078,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQzNDA5MDc4","avatar_url":"https://avatars2.githubusercontent.com/u/43409078?v=4","gravatar_id":"","url":"https://api.github.com/users/kryptoslogic","html_url":"https://github.com/kryptoslogic","followers_url":"https://api.github.com/users/kryptoslogic/followers","following_url":"https://api.github.com/users/kryptoslogic/following{/other_user}","gists_url":"https://api.github.com/users/kryptoslogic/gists{/gist_id}","starred_url":"https://api.github.com/users/kryptoslogic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kryptoslogic/subscriptions","organizations_url":"https://api.github.com/users/kryptoslogic/orgs","repos_url":"https://api.github.com/users/kryptoslogic/repos","events_url":"https://api.github.com/users/kryptoslogic/events{/privacy}","received_events_url":"https://api.github.com/users/kryptoslogic/received_events","type":"Organization","site_admin":false},"repo":{"id":152140978,"node_id":"MDEwOlJlcG9zaXRvcnkxNTIxNDA5Nzg=","name":"haxm","full_name":"kryptoslogic/haxm","private":false,"owner":{"login":"kryptoslogic","id":43409078,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQzNDA5MDc4","avatar_url":"https://avatars2.githubusercontent.com/u/43409078?v=4","gravatar_id":"","url":"https://api.github.com/users/kryptoslogic","html_url":"https://github.com/kryptoslogic","followers_url":"https://api.github.com/users/kryptoslogic/followers","following_url":"https://api.github.com/users/kryptoslogic/following{/other_user}","gists_url":"https://api.github.com/users/kryptoslogic/gists{/gist_id}","starred_url":"https://api.github.com/users/kryptoslogic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kryptoslogic/subscriptions","organizations_url":"https://api.github.com/users/kryptoslogic/orgs","repos_url":"https://api.github.com/users/kryptoslogic/repos","events_url":"https://api.github.com/users/kryptoslogic/events{/privacy}","received_events_url":"https://api.github.com/users/kryptoslogic/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/kryptoslogic/haxm","description":"Intel® Hardware Accelerated Execution Manager (Intel® HAXM)","fork":true,"url":"https://api.github.com/repos/kryptoslogic/haxm","forks_url":"https://api.github.com/repos/kryptoslogic/haxm/forks","keys_url":"https://api.github.com/repos/kryptoslogic/haxm/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kryptoslogic/haxm/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kryptoslogic/haxm/teams","hooks_url":"https://api.github.com/repos/kryptoslogic/haxm/hooks","issue_events_url":"https://api.github.com/repos/kryptoslogic/haxm/issues/events{/number}","events_url":"https://api.github.com/repos/kryptoslogic/haxm/events","assignees_url":"https://api.github.com/repos/kryptoslogic/haxm/assignees{/user}","branches_url":"https://api.github.com/repos/kryptoslogic/haxm/branches{/branch}","tags_url":"https://api.github.com/repos/kryptoslogic/haxm/tags","blobs_url":"https://api.github.com/repos/kryptoslogic/haxm/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kryptoslogic/haxm/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kryptoslogic/haxm/git/refs{/sha}","trees_url":"https://api.github.com/repos/kryptoslogic/haxm/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kryptoslogic/haxm/statuses/{sha}","languages_url":"https://api.github.com/repos/kryptoslogic/haxm/languages","stargazers_url":"https://api.github.com/repos/kryptoslogic/haxm/stargazers","contributors_url":"https://api.github.com/repos/kryptoslogic/haxm/contributors","subscribers_url":"https://api.github.com/repos/kryptoslogic/haxm/subscribers","subscription_url":"https://api.github.com/repos/kryptoslogic/haxm/subscription","commits_url":"https://api.github.com/repos/kryptoslogic/haxm/commits{/sha}","git_commits_url":"https://api.github.com/repos/kryptoslogic/haxm/git/commits{/sha}","comments_url":"https://api.github.com/repos/kryptoslogic/haxm/comments{/number}","issue_comment_url":"https://api.github.com/repos/kryptoslogic/haxm/issues/comments{/number}","contents_url":"https://api.github.com/repos/kryptoslogic/haxm/contents/{+path}","compare_url":"https://api.github.com/repos/kryptoslogic/haxm/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kryptoslogic/haxm/merges","archive_url":"https://api.github.com/repos/kryptoslogic/haxm/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kryptoslogic/haxm/downloads","issues_url":"https://api.github.com/repos/kryptoslogic/haxm/issues{/number}","pulls_url":"https://api.github.com/repos/kryptoslogic/haxm/pulls{/number}","milestones_url":"https://api.github.com/repos/kryptoslogic/haxm/milestones{/number}","notifications_url":"https://api.github.com/repos/kryptoslogic/haxm/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kryptoslogic/haxm/labels{/name}","releases_url":"https://api.github.com/repos/kryptoslogic/haxm/releases{/id}","deployments_url":"https://api.github.com/repos/kryptoslogic/haxm/deployments","created_at":"2018-10-08T20:17:44Z","updated_at":"2018-11-05T03:37:09Z","pushed_at":"2018-11-06T01:07:07Z","git_url":"git://github.com/kryptoslogic/haxm.git","ssh_url":"git@github.com:kryptoslogic/haxm.git","clone_url":"https://github.com/kryptoslogic/haxm.git","svn_url":"https://github.com/kryptoslogic/haxm","homepage":null,"size":747,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"bsd-3-clause","name":"BSD 3-Clause \"New\" or \"Revised\" License","spdx_id":"BSD-3-Clause","url":"https://api.github.com/licenses/bsd-3-clause","node_id":"MDc6TGljZW5zZTU="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"intel:master","ref":"master","sha":"a5da3c32beb54e15d79573dd6c425bf78292fa27","user":{"login":"intel","id":17888862,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE3ODg4ODYy","avatar_url":"https://avatars3.githubusercontent.com/u/17888862?v=4","gravatar_id":"","url":"https://api.github.com/users/intel","html_url":"https://github.com/intel","followers_url":"https://api.github.com/users/intel/followers","following_url":"https://api.github.com/users/intel/following{/other_user}","gists_url":"https://api.github.com/users/intel/gists{/gist_id}","starred_url":"https://api.github.com/users/intel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/intel/subscriptions","organizations_url":"https://api.github.com/users/intel/orgs","repos_url":"https://api.github.com/users/intel/repos","events_url":"https://api.github.com/users/intel/events{/privacy}","received_events_url":"https://api.github.com/users/intel/received_events","type":"Organization","site_admin":false},"repo":{"id":98257850,"node_id":"MDEwOlJlcG9zaXRvcnk5ODI1Nzg1MA==","name":"haxm","full_name":"intel/haxm","private":false,"owner":{"login":"intel","id":17888862,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE3ODg4ODYy","avatar_url":"https://avatars3.githubusercontent.com/u/17888862?v=4","gravatar_id":"","url":"https://api.github.com/users/intel","html_url":"https://github.com/intel","followers_url":"https://api.github.com/users/intel/followers","following_url":"https://api.github.com/users/intel/following{/other_user}","gists_url":"https://api.github.com/users/intel/gists{/gist_id}","starred_url":"https://api.github.com/users/intel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/intel/subscriptions","organizations_url":"https://api.github.com/users/intel/orgs","repos_url":"https://api.github.com/users/intel/repos","events_url":"https://api.github.com/users/intel/events{/privacy}","received_events_url":"https://api.github.com/users/intel/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/intel/haxm","description":"Intel® Hardware Accelerated Execution Manager (Intel® HAXM)","fork":false,"url":"https://api.github.com/repos/intel/haxm","forks_url":"https://api.github.com/repos/intel/haxm/forks","keys_url":"https://api.github.com/repos/intel/haxm/keys{/key_id}","collaborators_url":"https://api.github.com/repos/intel/haxm/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/intel/haxm/teams","hooks_url":"https://api.github.com/repos/intel/haxm/hooks","issue_events_url":"https://api.github.com/repos/intel/haxm/issues/events{/number}","events_url":"https://api.github.com/repos/intel/haxm/events","assignees_url":"https://api.github.com/repos/intel/haxm/assignees{/user}","branches_url":"https://api.github.com/repos/intel/haxm/branches{/branch}","tags_url":"https://api.github.com/repos/intel/haxm/tags","blobs_url":"https://api.github.com/repos/intel/haxm/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/intel/haxm/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/intel/haxm/git/refs{/sha}","trees_url":"https://api.github.com/repos/intel/haxm/git/trees{/sha}","statuses_url":"https://api.github.com/repos/intel/haxm/statuses/{sha}","languages_url":"https://api.github.com/repos/intel/haxm/languages","stargazers_url":"https://api.github.com/repos/intel/haxm/stargazers","contributors_url":"https://api.github.com/repos/intel/haxm/contributors","subscribers_url":"https://api.github.com/repos/intel/haxm/subscribers","subscription_url":"https://api.github.com/repos/intel/haxm/subscription","commits_url":"https://api.github.com/repos/intel/haxm/commits{/sha}","git_commits_url":"https://api.github.com/repos/intel/haxm/git/commits{/sha}","comments_url":"https://api.github.com/repos/intel/haxm/comments{/number}","issue_comment_url":"https://api.github.com/repos/intel/haxm/issues/comments{/number}","contents_url":"https://api.github.com/repos/intel/haxm/contents/{+path}","compare_url":"https://api.github.com/repos/intel/haxm/compare/{base}...{head}","merges_url":"https://api.github.com/repos/intel/haxm/merges","archive_url":"https://api.github.com/repos/intel/haxm/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/intel/haxm/downloads","issues_url":"https://api.github.com/repos/intel/haxm/issues{/number}","pulls_url":"https://api.github.com/repos/intel/haxm/pulls{/number}","milestones_url":"https://api.github.com/repos/intel/haxm/milestones{/number}","notifications_url":"https://api.github.com/repos/intel/haxm/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/intel/haxm/labels{/name}","releases_url":"https://api.github.com/repos/intel/haxm/releases{/id}","deployments_url":"https://api.github.com/repos/intel/haxm/deployments","created_at":"2017-07-25T03:00:01Z","updated_at":"2018-11-05T23:05:20Z","pushed_at":"2018-11-06T01:07:09Z","git_url":"git://github.com/intel/haxm.git","ssh_url":"git@github.com:intel/haxm.git","clone_url":"https://github.com/intel/haxm.git","svn_url":"https://github.com/intel/haxm","homepage":null,"size":599,"stargazers_count":684,"watchers_count":684,"language":"C","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":118,"mirror_url":null,"archived":false,"open_issues_count":29,"license":{"key":"bsd-3-clause","name":"BSD 3-Clause \"New\" or \"Revised\" License","spdx_id":"BSD-3-Clause","url":"https://api.github.com/licenses/bsd-3-clause","node_id":"MDc6TGljZW5zZTU="},"forks":118,"open_issues":29,"watchers":684,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/intel/haxm/pulls/119"},"html":{"href":"https://github.com/intel/haxm/pull/119"},"issue":{"href":"https://api.github.com/repos/intel/haxm/issues/119"},"comments":{"href":"https://api.github.com/repos/intel/haxm/issues/119/comments"},"review_comments":{"href":"https://api.github.com/repos/intel/haxm/pulls/119/comments"},"review_comment":{"href":"https://api.github.com/repos/intel/haxm/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/intel/haxm/pulls/119/commits"},"statuses":{"href":"https://api.github.com/repos/intel/haxm/statuses/24fdff5da8a15347463bfe12e35da56fbdd74cef"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"raphaelning"}}