It’s movie where a man sits in a chair to pay for a virtual reality or dream scape. He has to choose who he wants to be. But they tell him it has to be something made up and can’t be something you already are. He says spy but the machine breaks beucase he is a spy and doesn’t know it. And the. He ends up killing everyone in the room and realizes that he is a spy and doesn’t know if he’s dreaming or not.
“Total Recall” (1990)
https://www.imdb.com/title/tt0100802/
In this original 1990 version Arnold Schwarzenegger plays the man who wants to be a spy.
Trailer:
Or its 2012 remake with the same title:
“Total Recall” (2012)
https://www.imdb.com/title/tt1386703/
In this remake version Colin Farrell plays the spy.
I am sure that this is the movie you are looking for (either the original or the remake). If you agree, then please select my answer above as Best Answer, there is an option for that.