mecen@lemmy.ca to Piracy: ꜱᴀɪʟ ᴛʜᴇ ʜɪɢʜ ꜱᴇᴀꜱ@lemmy.dbzer0.comEnglish · 3 days agoDenuvOwO is coming to Linuxlemmy.caimagemessage-square37linkfedilinkarrow-up144arrow-down11file-textcross-posted to: [email protected]
arrow-up143arrow-down1imageDenuvOwO is coming to Linuxlemmy.camecen@lemmy.ca to Piracy: ꜱᴀɪʟ ᴛʜᴇ ʜɪɢʜ ꜱᴇᴀꜱ@lemmy.dbzer0.comEnglish · 3 days agomessage-square37linkfedilinkfile-textcross-posted to: [email protected]
minus-squareMttw_@lemmy.dbzer0.comlinkfedilinkEnglisharrow-up1·2 days agoNo, 5800x3d is zen3 sadly. But you can actually test it with a small python script: # docs: https://man.archlinux.org/man/arch_prctl.2 import ctypes import errno import mmap import os import signal import subprocess import sys SYS_arch_prctl = 158 ARCH_SET_CPUID = 0x1012 libc = ctypes.CDLL(None, use_errno=True) libc.syscall.restype = ctypes.c_long def arch_set_cpuid(enabled: bool) -> None: rc = libc.syscall(SYS_arch_prctl, ARCH_SET_CPUID, 1 if enabled else 0) if rc != 0: e = ctypes.get_errno() raise OSError(e, os.strerror(e)) def make_cpuid_stub(): # push rbx # xor eax, eax # cpuid # pop rbx # ret code = b"\x53\x31\xc0\x0f\xa2\x5b\xc3" mm = mmap.mmap( -1, len(code), flags=mmap.MAP_PRIVATE | mmap.MAP_ANONYMOUS, prot=mmap.PROT_READ | mmap.PROT_WRITE | mmap.PROT_EXEC, ) mm.write(code) addr = ctypes.addressof(ctypes.c_char.from_buffer(mm)) func = ctypes.CFUNCTYPE(None)(addr) func._mm = mm return func def child(): cpuid = make_cpuid_stub() print("Trying normal CPUID...") cpuid() print("Normal CPUID worked.") try: arch_set_cpuid(False) except OSError as e: if e.errno == errno.ENODEV: print("CPU does not support CPUID faulting.") return 2 raise print("CPUID disabled for this thread. Calling CPUID again...") cpuid() # should SIGSEGV -11 if faulting is supported print("Unexpected: CPUID did not fault.") return 0 if __name__ == "__main__": if len(sys.argv) > 1 and sys.argv[1] == "child": raise SystemExit(child()) p = subprocess.run([sys.executable, __file__, "child"], text=True) print(f"child exit code: {p.returncode}") if p.returncode == -signal.SIGSEGV: print("Result: CPUID faulting is supported and worked.") elif p.returncode == 2: print("Result: CPUID faulting is not supported by the hardware.") else: print("Result: test did not complete cleanly.")
No, 5800x3d is zen3 sadly.
But you can actually test it with a small python script:
# docs: https://man.archlinux.org/man/arch_prctl.2 import ctypes import errno import mmap import os import signal import subprocess import sys SYS_arch_prctl = 158 ARCH_SET_CPUID = 0x1012 libc = ctypes.CDLL(None, use_errno=True) libc.syscall.restype = ctypes.c_long def arch_set_cpuid(enabled: bool) -> None: rc = libc.syscall(SYS_arch_prctl, ARCH_SET_CPUID, 1 if enabled else 0) if rc != 0: e = ctypes.get_errno() raise OSError(e, os.strerror(e)) def make_cpuid_stub(): # push rbx # xor eax, eax # cpuid # pop rbx # ret code = b"\x53\x31\xc0\x0f\xa2\x5b\xc3" mm = mmap.mmap( -1, len(code), flags=mmap.MAP_PRIVATE | mmap.MAP_ANONYMOUS, prot=mmap.PROT_READ | mmap.PROT_WRITE | mmap.PROT_EXEC, ) mm.write(code) addr = ctypes.addressof(ctypes.c_char.from_buffer(mm)) func = ctypes.CFUNCTYPE(None)(addr) func._mm = mm return func def child(): cpuid = make_cpuid_stub() print("Trying normal CPUID...") cpuid() print("Normal CPUID worked.") try: arch_set_cpuid(False) except OSError as e: if e.errno == errno.ENODEV: print("CPU does not support CPUID faulting.") return 2 raise print("CPUID disabled for this thread. Calling CPUID again...") cpuid() # should SIGSEGV -11 if faulting is supported print("Unexpected: CPUID did not fault.") return 0 if __name__ == "__main__": if len(sys.argv) > 1 and sys.argv[1] == "child": raise SystemExit(child()) p = subprocess.run([sys.executable, __file__, "child"], text=True) print(f"child exit code: {p.returncode}") if p.returncode == -signal.SIGSEGV: print("Result: CPUID faulting is supported and worked.") elif p.returncode == 2: print("Result: CPUID faulting is not supported by the hardware.") else: print("Result: test did not complete cleanly.")