Skip to content

Instantly share code, notes, and snippets.

@dantmnf
Created October 27, 2022 17:12
Show Gist options
  • Save dantmnf/bbaeb0f35ea102506af6b764a7473b53 to your computer and use it in GitHub Desktop.
Save dantmnf/bbaeb0f35ea102506af6b764a7473b53 to your computer and use it in GitHub Desktop.
Forge Processor Name String on AMD CPUs
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"https://chipsandcheese.com/2022/10/27/why-you-cant-trust-cpuid/"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import struct\n",
"def wrcpuid(s):\n",
" b = s.encode()[:47]+b'\\0'*48\n",
" b = b[:48]\n",
" vals = struct.unpack('<QQQQQQ', b)\n",
" addrs = range(0xC0010030, 0xC0010036)\n",
" print('insmod wrmsr')\n",
" for x in zip(addrs, vals):\n",
" print('wrmsr 0x%X 0x%X' % x)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"use GRUB command line or `configfile`"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"insmod wrmsr\n",
"wrmsr 0xC0010030 0x657A795220444D41\n",
"wrmsr 0xC0010031 0x353431312039206E\n",
"wrmsr 0xC0010032 0x583431\n",
"wrmsr 0xC0010033 0x0\n",
"wrmsr 0xC0010034 0x0\n",
"wrmsr 0xC0010035 0x0\n"
]
}
],
"source": [
"wrcpuid('AMD Ryzen 9 114514X')"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.10.3 64-bit",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.3"
},
"orig_nbformat": 4,
"vscode": {
"interpreter": {
"hash": "76d849ad2a318e10f5a0a2e2063decbae756492edd53ef527e19fb86cc3b916e"
}
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment