ValveSoftware / csgo-osx-linux

Counter-Strike: Global Offensive
http://counter-strike.net
784 stars 69 forks source link

Illegal instruction on Phenom`s processors #3394

Open blogdron opened 1 year ago

blogdron commented 1 year ago

Your system information

Please describe your issue in as much detail as possible:

After update csgo to cs2 game not startup

Steps for reproducing this issue:

  1. Run from steam, game not running %command% 2> log there's nothing interesting here
    pid 762826 != 762825, skipping destruction (fork without exec?)
    pid 762827 != 762825, skipping destruction (fork without exec?)
    /home/user/.steam/debian-installation/steamapps/common/Counter-Strike Global Offensive/game/cs2.sh: line 115: 762829 Illegal instruction     ${STEAM_RUNTIME_PREFIX} ${GAME_DEBUGGER} "${GAMEROOT}"/${GAMEEXE} "$@"
    ed.
    ERROR: ld.so: object '/home/user/.steam/debian-installation/ubuntu12_32/gameoverlayrenderer.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored.
    ERROR: ld.so: object '/home/user/.steam/debian-installation/ubuntu12_32/gameoverlayrenderer.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored.
    x86_64-linux-gnu-capsule-capture-libs: warning: we are assuming "_el_fn_sh_complete" to be private, but it's just a guess
    i386-linux-gnu-capsule-capture-libs: warning: we are assuming "_el_fn_sh_complete" to be private, but it's just a guess
  2. Run from terminal
    user@gnu:~/.steam/debian-installation/steamapps/common/Counter-Strike Global Offensive/game/bin/linuxsteamrt64$ ./cs2 
    Illegal instruction
    user@gnu:~/.steam/debian-installation/steamapps/common/Counter-Strike Global Offensive/game/bin/linuxsteamrt64$ 

Maybe create 2 exacutables for cs2 with instructions and without and select exacuteable in cs2.sh 👉 👈 (¬‿¬ )

Steam thread about it

Or is this equipment now without support forever ? ( . •́ ʖ •̀ .)
And it the end ? (⊙
⊙) .

PedriNH4x commented 1 year ago

Cs2 now needs to have SSE4.2 to work, and this ended up affecting me and you. #3320

blogdron commented 1 year ago

Cs2 now needs to have SSE4.2 to work, and this ended up affecting me and you. #3320

But issue not closed permanently with answer "Sorry hardware it not supported now. Close issue" (¬‿¬ ) Maybe they will decide that in theory it is possible to return support for this hardware =) Of course maaaaaaaayyyyybeeeee :D

Spacefish commented 1 year ago

Phenom does not even support x86-64-v2 ... You might be able to emulate the missing instructions with modules like: https://github.com/mirh/opemu-linux

Edit: forked it and made it buildable for modern kernels: https://github.com/Spacefish/opemu-linux/tree/master at least it loads:

[ 4955.420602] op_emu: module verification failed: signature and/or required key missing - tainting kernel
[ 4955.423064] OPEMU: Planted krpobe for symbol kallsyms_lookup_name at 00000000d374a98e
[ 4955.423185] OPEMU: Planted krpobe for symbol kallsyms_lookup_name at 00000000d374a98e
[ 4955.465426] OPEMU: kallsyms_lookup_name address = 0xffffffff992114d0
[ 4955.467320] OPEMU: module loaded
blogdron commented 1 year ago

@Spacefish interesting, thanks ^.^

blogdron commented 1 year ago

Game not startup dmesg log

🤔 What happens if you take this library libtier0.so from cs:go? Probably replacing the library will lead to a VAC

[1382931.592097] OPEMU: Planted krpobe for symbol kallsyms_lookup_name at 000000008e367ba2
[1382931.631359] OPEMU: kallsyms_lookup_name address = 0xffffffffb6bad0d4
[1382931.633855] OPEMU: module loaded
[1382950.770293] OPEMU:  pmaxud xmm0, xmm1
[1382950.770301] traps: cs2[913536] trap invalid opcode ip:7f3f73838c4e sp:7fffc493b630 error:0 in libtier0.so[7f3f736bf000+2f3000]

Need add support pmaxud SSE4.1 opcode in op_emu... ohhh, maybe i try

I'll try when I have time with the option %command% -insecure But.... If I decide, I don't want to get VAC BAN for experiments 😳

sylveonsylvia commented 1 year ago

even if you got the game to launch it wouldn't run well at all (maybe 3 frames per second)

blogdron commented 1 year ago

@Spacefish Iam add pmaxud and pminud emulation support. Now im no have kernel traps erorors from libtier0.so but game just no startup. No logs. No erros. no info :(

But! As I found out these are useless optimizations no need use pmaxud/pminud SSE4.x becouse in debuggin 128 bit value for SIMD compare and sort have just single 32 bit value for compares.

[1525657.992157] OPEMU: module unloaded
[1525690.268266] OPEMU: Planted krpobe for symbol kallsyms_lookup_name at 000000008e367ba2
[1525690.268593] OPEMU: Planted krpobe for symbol kallsyms_lookup_name at 000000008e367ba2
[1525690.320136] OPEMU: kallsyms_lookup_name address = 0xffffffffb6bad0d4
[1525690.322717] OPEMU: module loaded
[1525700.264708] PMAXUD DETECTED HELLO WORLD!
[1525700.264714] A0=6  B0=21 | MAX=21
[1525700.264716] A1=0  B1=0 | MAX=0
[1525700.264717] A2=0  B2=0 | MAX=0
[1525700.264718] A3=0  B3=0 | MAX=0
[1525700.264729] PMAXUD DETECTED HELLO WORLD!
[1525700.264730] A0=6  B0=15 | MAX=15
[1525700.264731] A1=0  B1=0 | MAX=0
[1525700.264732] A2=0  B2=0 | MAX=0
[1525700.264733] A3=0  B3=0 | MAX=0
[1525700.264735] PMAXUD DETECTED HELLO WORLD!
[1525700.264736] A0=36  B0=41 | MAX=41
[1525700.264737] A1=0  B1=0 | MAX=0
[1525700.264738] A2=0  B2=0 | MAX=0
[1525700.264739] A3=0  B3=0 | MAX=0
...
[1525910.896729] PMINUD DETECTED HELLO WORLD!
[1525910.896730] A0=200  B0=200 | MIN=200
[1525910.896731] A1=0  B1=0 | MIN=0
[1525910.896732] A2=0  B2=0 | MIN=0
[1525910.896733] A3=0  B3=0 | MIN=0
[1525910.896734] PMINUD DETECTED HELLO WORLD!
[1525910.896735] A0=64  B0=200 | MIN=64
[1525910.896736] A1=0  B1=0 | MIN=0
[1525910.896737] A2=0  B2=0 | MIN=0
[1525910.896738] A3=0  B3=0 | MIN=0
[1525910.896741] PMINUD DETECTED HELLO WORLD!
[1525910.896742] A0=200  B0=200 | MIN=200
[1525910.896743] A1=0  B1=0 | MIN=0
[1525910.896744] A2=0  B2=0 | MIN=0
[1525910.896745] A3=0  B3=0 | MIN=0
[1525910.896746] PMINUD DETECTED HELLO WORLD!
[1525910.896747] A0=8  B0=200 | MIN=8  
[1525910.896748] A1=0  B1=0 | MIN=0
[1525910.896749] A2=0  B2=0 | MIN=0
[1525910.896750] A3=0  B3=0 | MIN=0

This is simply a useless optimization for the library code, which blocks its operation on old CPUs, but does not optimize anything on new ones; moreover, it seems to me that it even slows down sorting on new processors since filling a 128-bit register and comparison will be slower than just direct comparing a 32-bit register with another. Maybe I'm wrong, of course, but I see what I see.

If anyone wants to check it out

-AHTUNG! NOTICE! ВНИМАНИЕ! maybe it make VAC BAN for you!!!!!!!!
-Iam NO HAVE INFO ABOOUT IIIIIIIIIIIT :) 
-DO NOT EXPERIMENT THIS IF YOU NO SURE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!11

git clone https://github.com/blogdron/opemu-linux
cd opemu-linux
Uncomment debugging printk in sse41.c in functions pmaxud/pminud
make
sudo dmesg -w
sudo insmod op_emu.ko run cs2 and see dmesg out

Since I no longer know where to try to fix/emulate the problem, that’s all. Maybe it will be useful to someone. :(


UPDATE: Oh nooooo :) IM HAVE NEW LOG ERROR %command% 2> log ( see log in game directory)

Launcher Error: A CPU that supports the SSE4.2 instruction set is required.

Game detect my CPU name and just stop running :( Game blocked idea for emulate instructions :( Oh noooo. the end

im can skip launcher?

phillipsjk commented 1 year ago

I also have this problem. Saw this in kern.log while trying to launch CS2: Oct 20 20:53:57 cathy kernel: [33826.665716] traps: cs2[29144] trap invalid opcode ip:7fbea277238e sp:7ffe42f52a50 error:0 in libtier0.so[7fbea25fa000+2f1000]

As far as I can tell my AMD Phenom(tm) II X6 1035T Processor meets the minimum system requirements listed on the steam page.

Edit: instructions my CPU DOES support: flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm 3dnowext 3dnow constant_tsc rep_good nopl nonstop_tsc cpuid extd_apicid aperfmperf pni monitor cx16 popcnt lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs skinit wdt cpb hw_pstate vmmcall npt lbrv svm_lock nrip_save pausefilter

Spacefish commented 1 year ago

Game detect my CPU name and just stop running :( Game blocked idea for emulate instructions :( Oh noooo. the end

I no :( guess they detect the CPU features via the "cpuid" instruction like this library: https://github.com/google/cpu_features

Amazing that you got it working though (emulating the instructions). But even if you would be able to make the game run that way, it will probably be way way to slow to play, as every invalid instruction leads to a ISR being called in the kernel, the emulation code executing and then going back to the userland process.. The overhead is extreme.. :(

Guess they will mainly use the DPPS and DPPD instructions in the engine itself. They probably use some sort of vector math library which will use these under the hood..

Unfortunately more and more software will probably need support for SSE4.2 as it´s part of the x86-64-v2 featureset. Guess Microsoft even targets x86-64-v3 with their limited CPU support in Windows 11... Even some Linux distros are starting to required x86-64-v2 (Tumbleweed).

Send you a small tip on boosty.io b.t.w. hope you still have your account / it still works to do USD -> RUB.

blogdron commented 1 year ago

@Spacefish Thank you very much, yes the profile is active, I’m just lazy and rarely write anything there, mostly I just post the code on the forums :3 Thanks again. Regarding the instructions, well, I ran the game under strace and as far as I understand, the processor is determined in several ways, and the instructions are determined based on the name.

It’s also funny that in order to find out that you don’t have 4.2 instructions, you need 4.2 instructions to work hehehe, only then you get a message that you don’t have them lol.

Yes, in order to continue adding new missing ones, you need to receive an illegal instruction, but for this you need to assure the program that my processor can do everything it needs. I was advised on the forums to replace cpuid, I have not done this yet, but I am getting ready =) As soon as I can do this, I will receive a trap invalid opcode and will be able to quietly implement the missing instructions step by step. I’m not a professional programmer, but an amateur, so it won’t be fast (maybe I’ll give up altogether since it’s not always possible)

But yes, most likely it will be unbearably slow, but it depends on where exactly these instructions will be in the executable code.

But I like the idea of emulating instructions. This is interesting. And getting a game to work on Linux is also a kind of game =)


P.S. > x86-64-v3 >> v3 >>> **v3** 😱 [![O_0]( https://i.ytimg.com/vi/HcfHBgUTn7I/maxresdefault.jpg )](https://www.youtube.com/watch?v=HcfHBgUTn7I)
phillipsjk commented 1 year ago

There are simple ways to test which instructions the CPU supports directly. The game should use them instead of crashing without an error message. Even IF the CPU is unsupported: executing illegal instructions is still a bug.

Because I got [no] error messages, and checked guides on common things to check, I thought maybe it was failing to open because my screen resolution was less than 1920x1080: the suggested "safe" resolution that almost all monitors made in the last 10 years will support.

baaannnaaannn commented 9 months ago

Replying to https://github.com/ValveSoftware/csgo-osx-linux/issues/3394#issuecomment-1773935893

This is due to the game engine? But there are dota2 on source 2 without that requirements Can they do the same with Dota?