I'm asking because I read somewhere that pair production needs an energy of two photons greater than E=2mc2. I'm not sure if not only this exact energy is necessary and also sufficient to create a pair of electron and positron.
Excess energy is transformed to the kinetic energy of the particles in the pair. With energy exactly equal to rest mass, the pair cannot separate and will annigilate immediately.
The question doesn't make sense, since an equation can't be violated-an identity can turn out to be violated or an inequality can. An equation may not admit any solution-but that isn't the case here. What does make sense is the following, which is a standard exercise for the Dirac equation: If you try to find a solution of the Dirac equation, when the potential energy has the form of a step, whose height esxceeds 2 m c^2, where m is the mass in the Dirac equation, then you'll find that the reflected current is greater than the incident current, due to pair production. This isn't a ``violation'' of the Dirac equation, since a solution has been constructed-it just means that a single particle solution doesn't exist. The solution that *does* exist describes many particles.
It is true that, if you want to create a pair of particle/antiparticle of mass m each from the vacuum and these particles are electrically charged, thus interact with photons, then you can achieve this with pairs of photons of energy at least 2 m c^2 and you can describe this process using the Dirac equation (cf. any textbook on relativistic quantum mechanics or quantum field theory), assuming, therefore, that the electromagnetic energy is supplied by an external field, whose fluctuations can be neglected.