Reputation: 6844
I'm reading this question about how to fix a bug in Valgrind. The only proposed solution is to apply this patch.
I never applied a patch and I found this question on the topic, but I can't understand how to apply it to my case.
Upvotes: 1
Views: 1307
Reputation: 30958
priv/guest_amd64_helpers.c
@@ -3101,7 +3101,8 @@ void amd64g_dirtyhelper_CPUID_avx2 ( VexGuestAMD64State* st )
SET_ABCD(0x0000000d, 0x756e6547, 0x6c65746e, 0x49656e69);
break;
case 0x00000001:
- SET_ABCD(0x000306c3, 0x02100800, 0x7ffafbff, 0xbfebfbff);
+ /* Don't advertise RDRAND support, bit 30 in ECX. */
+ SET_ABCD(0x000306c3, 0x02100800, 0x3ffafbff, 0xbfebfbff);
break;
case 0x00000002:
SET_ABCD(0x76036301, 0x00f0b6ff, 0x00000000, 0x00c10000);
This patch is very simple. It changes only one file priv/guest_amd64_helpers.c
. The changed lines are in the function void amd64g_dirtyhelper_CPUID_avx2 ( VexGuestAMD64State* st )
. A -
prefixed line means this line is to be deleted. A +
prefixed line means this line is to be added. The other lines without a prefixed -
or +
are the context to locate. So find the chunk, then remove and add these lines in your priv/guest_amd64_helpers.c
. This is a straightforward way by hand.
As for a generic git patch or commit, we can also apply it by git commands if your code is managed by a git repository. The last link in your question describes how to git apply a patch. The command git am
can also do the job. Here is the way to apply this commit by git cherry-pick
.
cd <your_repo>
git fetch https://github.com/svn2github/valgrind-vex master
git cherry-pick 1ab61656f71e94ce12b68de87f1e28cf3dc0c18c
If you don't want to keep the author info of 1ab6165, you could use git cherry-pick -n 1ab616;git commit
instead.
A patch is a formatted file that describes which files are changed and what lines are added or removed. You can apply it by hand or automatically by commands. There is another common method. Download priv/guest_amd64_helpers.c
into the local disk and compare it with your version, for example by Beyond Compare. Focus on the related chunk and merge it into your version.
Upvotes: 2