Prologue

It’s 2019. AMD is more than ready to take its place in the GPU market share. Right after the release of RX 5600 XT, AMD and manufacturers partners released an update for the VBIOS (yes, GPUs also have BIOS) changing the clocks of processors making the card even more powerful.

The selection of graphics drivers for AMD hardware is comparibly very good. AMD is contributing to upstream projects like the mainline kernel code base and Mesa. And even maintaining their own projects like amdvlk or Compressonator.

There are 3 different Vulkan implementation available for Linux, which all use the amdgpu kernel module.

AMDGPU Pro, the proprietary userspace AMD Vulkan implementation.

amdvlk, an new open source Vulkan implementation by AMD.

radv, the free Vulkan implementation for AMD maintained by the Mesa project.

In addition you also can use a OpenGL 4.5 conformant GL implementation RadeonSI from Mesa, implemented on the Gallium framework.

radv also recently gained a new shader compiler ACO , which was sponsored by Valve. It is delivering considarable performance improvements compared to the old one.

Let’s do it

So here I’m, just one more GNU/Linux user with my GPU properly installed and running just fine. Oh wait, it seems that I can upgrade its VBIOS in order to improve performance, it shouldn’t be that hard, right? Right?

:)

Since this is the first time I do such operation, I started with some DuckDuckGoing to check the required steps. Each manufacturer (e.g. Gigabyte, ASRock, etc) is responsible to providing the update software for theirs users. Some lucky people managed to get an updated board from factory, while some versions won’t get support for the new version at all.

Since I’m not lucky, I need to flash my card. My model is the “Radeon RX 5600 XT Challenger D 6G OC”, also know as “RX5600XT CLD 6GO”. If you open the model page and click in the support tab, there’s one button named “vBIOS”. Clicking it reveals this text box:

The detailed description “Enhance performance.” quickly gets my attention and I know that I’m where I need to be. But calm down, let’s read all the information.

Please read the information below before downloading or updating your vBIOS

Sure, safety first.

We do not recommend users to update the vBIOS if their graphics card is already running normally.

Wait. So it seems that ASRock released a software to enhance performance of the card, but asks you not to do so and tells you that actually this is not a good idea.

ASRock assumes no responsibility for any damages caused by improper operations of downloading or updating the vBIOS.

And if something went wrong, good luck dealing with that.

Before you download or update the vBIOS, please read “(How to Update)” below carefully.

In the column “Update vBIOS Under/ How to Update” there’s only one entry where is possible to read Windows. These are bad news for me, since I have no Windows around to use. I click anyway in search for more knowledge and (as suggested) I carefully read the four steps instructions on how to extract a compressed file and how to double-click in a batch file, but they are all for Windows, so wasn’t so useful for me. Anyway, I click and download the “Global” option just in case I need it in the future.

The zip contains two files: Update.cmd and h566GCLDO_L07_X64Gop_2_09.exe . The first one is basically a batch script that call the second one with update as argument. The second one seems to be a C++ application to flash the card. It is important to notice that this binary is a Windows application with a VBIOS image embedded. To get only the image, TechPowerUp hosts a collection of VBIOS images. If an appropriated flashing tool. My first attempt failed, now it’s time to search again.

amdmeminfo

Looking for some kind of software to hack my AMD GPU that run in Linux, I discovered that there is one called amdmeminfo . Mysteriously, there was no entry at ArchLinux User Repository.I moved forward and decided to give a try. For that, I choose the first GitHub result in DDG, hoping for the best and that should be the most relevant one. From the README, we can read that “Get GDDR5 memory information and other information from AMD Radeon GPUs.” Not bad, huh?

After following the build instructions, I managed to get my binary. This was the result of the first run:

AMDMemInfo by Zuikkis <zuikkis@gmail.com> Updated by Yann St.Arnaud <ystarnaud@gmail.com> 03:00.0: Unable to unlock vbios “./amdmeminfo” terminated by signal SIGSEGV (Address boundary error)

After reading the code, I realized that this segfault had occurred because this version of the tool doesn’t support my card and no one checked if (gpu == NULL) . I need a more recent version of amdmeminfo for my card. The “original” repo, the one ystarnaud has chosen to fork from Zuikkis isn’t modified since 2014, so I think it will not help me. Back to the repo I’m using, there is a Pull Request. Maybe it’s to add to support RX 5600 XT, who knows?

add files via upload No description provided. Files changed 1: BIN +385 KB xmrig-proxy-master.zip

Well, you don’t need to be a git expert to see that’s something going strange here. I download the file and opened, and it’s an entire different repo download as zip, to deal with alt-coins proxy: xmrig-proxy.

Not sure what were VIP21’s intentions with this move, but it doesn’t seem it was succeeded. I moved to check the forks, and found that there are 50 ones, mostly from cryptomining people. After checking one by one, minershive’s (also a cryptocoin enthusiastic account) one seems to be the most reasonable one, with support to RX 5600 XT! It stills segfault, but at least was able to output the current version of my vBIOS:

113-EXT900162-L05

When I discovered this software, there were 50 forks. Now we have 51 forks!

Standars, by xkcd

I had renamed the tool to amdgpuinfo , since we get more general information about a GPU, not only about memory (at least for my card, I can’t get any memory information for now). You can find my repo at my GitLab. I also solved the problem with AUR package, and created one: amdgpuinfo-git. This tool was useful only to get my VBIOS version, since it can’t flash the card (at least for now).

atiflash / amdvbflash

As I continued my seek for Linux tools that could flash AMD cards, I found a lot of tutorials on how to do it in Windows. One popular tool among those guides is called atiflash , a tool to manipulate AMD GPUs and their VBIOSs. ATI was a company acquired by AMD and become part of the GPU development sector, but since 2010, the name ATI name isn’t used in any products released by them. So even with this outdated name, this tool shows some potential.

FreeDOS

I first heard of it in this guide in TechPowerUp’s forum, teaching how to use atiflash to flash your VBIOS. Wait, FreeDOS?

It seems like a lot of Windows users don’t trust it to perform such critical actions as flashing your VBIOS GPU. An unexpected interruption, reboot, a spiked CPU load or blue screen could corrupt the image and brick the card. Windows Update, Windows Defender, Cortana, antivirus, virus, all those softwares could work together to do that for you.

So how do you use your flashing tool, a Windows binary, in a safe environment? The answer got me by surprise, but if you are familiar with this kind of procedures, you probably already know FreeDOS. This is a GPL DOS-compatible operating system that allows you to run Windows software in an isolated condition. No updates, no voice assistance. Hopefully, no internet either. Just you and a command prompt, waiting for your order. Fortunately, Windows has a good retro compatible ABI, meaning that you can run some simple software in any release between from DOS to Windows 10.

Supported OS: Linux

The version of atiflash that is used in this guide, v4.17, is able to work on DOS as I tested in FreeDOS. But won’t be even nicer just using this in GNU/Linux? I could only find one version of this software for my OS, in a shady repository from konqueror1 , one more cryptominer: https://github.com/konqueror1/atiflash. This tool, as version 4.25, could not detect my flash card, so I needed a more updated one. Just to be sure, I tried in FreeDOS. It worked fine, but it couldn’t detect my card as well.

Hopefully, the same TechPowerUp website hosts atiflash versions, along with VBIOS images, so maybe it was just a matter of finding the right version, with the right image. So I grab the 2.93 version for download, but it only has Windows versions. Changelog says that in August 15th, 2019, support for flashing Navi Radeon RX 5700 Series BIOS was added. Two important things to notice here: even that this release is newer, it’s version has a lower number than the one that we found before (4.15). Also, the name of binary is actualy “AMDVbFlash”, without “ATI” anymore. Probably they reset the version counter when changing the name, but kept the old name in pages to enhance the Google visibility. Once again I fire my FreeDOS USB, but this time all I get from the tool is “This Program Can not Be Run in DOS Mode”. It turns that this message is bultin in the software, and it seems that it just print this and then exits, if it is running in a DOS environment. Maybe some developer in AMD changed the compiler or build system, breaking the DOS compatibility on the way.

We had already tested Linux and DOS versions out there, but TPU doesn’t provide any of then. In the hope that another tech forum has some binaries for me, I found more two websites: Guru3D and Geeks3D. I have no idea if they same some kind of relation or just use similar names by chance. By just a few days of difference, both pages posted the 3.04 release of the tool:

Geeks3D post comes with a promise that I was waiting for:

Supported OS: - Microsoft Windows (32bit/64bit) - UEFI - Linux - DOS

My hope quickly ended, when clicking for download I was presented to AMDVbFlash_v3.04.exe file. Extracting the .exe , there is an EndUserLicenseAgreement(use).doc by AMD and a readme.txt . Once again, the README states that Linux, UEFI and DOS are all supported, along with a nice AMD Copyright.

Screwed Drivers

Those tools should be coming from somewhere, hopefully from AMD itself, since they are both developer and copyright owner of the tool. However, the only mention that I could find about the tool in AMD website is in their security page.

Screwed Drivers 8/11/19 At AMD, security is a top priority. We were made aware of the public disclosure of potential industry-wide, driver-related vulnerabilities on August 11, 2019 and, after gaining new information from the researcher, AMD now believes this is related to a disclosure communicated to us earlier this year regarding the AMDVBFlash graphics driver tool that was temporarily made available on our website so early adopters of older AMD graphics products could perform a needed Video BIOS refresh and has since been removed. AMD is continuing to investigate the issue to determine if any other of our drivers may be affected.

To learn more about how this was being exploited, you can read the post by the researchers at Eclypsium’s blog:

Drivers that provide access to system BIOS or system components for the purposes of updating firmware, running diagnostics, or customizing options on the component can allow attackers to turn the very tools used to manage a system into powerful threats that can escalate privileges and persist invisibly on the host.

In summary, attackers could flash vulnerable firmware and driver to escalate privilege to read/write in kernel space. The article talks only about Windows, so it doesn’t seem to affect Linux. Also, it’s not clear about the role of “AMDVBFlash” in that attack, the article only says that “[…] the very drivers and tools that would be used to update the firmware are themselves vulnerable and provide a potential avenue for attack.”. To prevent users exploiting this attack, they removed the tool from their website, although they can’t delete it from the internet. It would be nice to have a fixed version for users, or even the source code, so they could fix it themselves. I just hope that they didn’t take down the tool with the argument that “it could be used to flash malicious images”. Similarly, this would be like removing the web browser, since it could be used to download malware.

Geeks, Gurus and miners

As you may have noticed, this statement was announced in August 8th, but the TechPowerUp and Geeks3D/Guru3D released versions after that date, in January 24th. It would make sense that this tool continues under development for AMD and their manufacturers partners, and there might have someone inside AMD leaking this software for those forums. The first line of the changelog is “AMDVBFLASH EXTERNAL – WINDOWS”, that once again brings more questions than answers. Is there an internal version? Is there a non-Windows binary? How did {Geek,Guru}3D managed to get access to this release, even after AMD saying that the tool was removed from their website?

I also found a Linux version of this tool in “ethOS Mining OS”, a paid distro for mining coins that offers atiflash as a cool feature and in “minerstat” distro as well. However, after reading their documentation, I strongly believe that this version is the old ATIflash v4.25 that I tried before.

Given all that, I couldn’t find a single tool to flash my card without a running Windows machine. The poor user amd762 even posted in AMD community forum, asking for a Linux version for the tool, but got only the silence.

That day when I tried to flash my AMD VBIOS in Linux Windows

AMDVBFlash in graphical mode, running in Windows 10

Eventually, I gave up, took the road and after 100 kilometers I reached the house of a friend of mine that have a Windows machine. We opened the cabinet, replaced the GPU, opened Windows 10 and fired up those tools described during the article. First, I did a backup of the current VBIOS image with AMDVbFlash and then used the ASRock solution to install the new one. Fortunately, all worked fine and my card now has a faster clock.

In more recent news

Luckily, now the situation is slight better in Linux side. After I did all those steps to get my VBIOS updated, I found the following resources:

Overclocking in Linux

There is a post in Reddit that teaches you how to change the voltage and frequency of your AMD card. This is basically an overclocking, but as far as I know, the performance result should be the same as flashing the VBIOS. Read the comments, since there are some useful tips and information there.

AMDVBFlash, UEFI version

TechPowerUp surprises me again, and release an UEFI shell version of AMDVBFlash 2.93 out of nowhere. Technically, this should be the best way to flash you card, since it doesn’t depend on your OS, just requires that you have a motherboard that supports UEFI. Just copy the files in a pen drive formated as FAT32 and boot it.

This release wasn’t made by AMD itself, but by “W1zzard”, an administrator from TechPowerUp. I’m not sure if it’s a reverse engineer of the original tool, or it’s the UEFI version released by AMD but with the Copyright modified. I couldn’t find more information about this developer, since their Twitter account has just one tweet with “6.5 million LinkedIn passwords” in a pastebin.

I tested following commands and everything worked as expected:

Listing devices/adapters: amdvbflash -i

Write the VBIOS of adapter 0 at file: amdvbflash -s 0 <file>

Check VBIOS info in a given file: amdvbflash -biosfileinfo <file>

Note: after I published this post, W1zzard commented in Reddit clarifying the situation: W1zzard from tpu here, the uefi flasher itself is amd original, i packaged it into a simple download with uefi shell and wrote the uefi Scripts We’re not hosting the newer vbflash because it requires that driver which has security issues as you mentioned. The current 2.93 can flash all amd cards so no reason to use the newer version and jump through the driver hoops Also, the UEFI version tool can be found with some vendors images, as is the case of MSI image.

Conclusion

AMD, in contrast with others GPU vendors, does a great job supporting Linux drivers in upstream. However, it lacks support for a VBIOS flashing tool in Linux (despite their confusing README stating the opposite), so RX 5600 XT users need to do wild things to get their card updated, including using Windows. If the tool was open source, I’m very confident that the community would support a Linux release. Thanks for reading, and if you know something about what is going on, I would love to hear.

Check my next post to see the final outcome of this history.

Thanks Lubosz for joining me in this adventure, digging in the web, looking for software, inspiring and reviewing this text.