The band diagram of a p-n and metal semiconductor junctions

I am trying to understand the band diagram of a the metal semiconductor junctions and the p-n junction. More precisely I don't understand how exactly the flow of carriers is limited on the boundary. Conceder first the p-n junction.

Clearly, there is a potential barrier and electrons going from the n side are opposed by the potential barrier $q\phi_i$ when trying to go to the conduction band of the p side. What happens however to holes on the p side when trying to move to the valence band of the n side. Due to the gradient of $E_{\nu}$ it looks as if this would be energy favourable? This however contradicts the explanation, that the field of the gap will stop them from doing so. I can't reconcile this with the confusion I have from the band diagram picture. The explanation I came up with, is that the holes have too high energy and would have to lower it, to fit in the n-type valance band.

I have the same sort of confusion due to the metal semiconductor junction. It again looks energy favourable to have electrons moving from the metal to both the p and n type semiconductors. I assume this, since both the n and p type semiconductor valance band energies $E_{v,S}$ is lower than the metal Fermi energy. Not to mention that in the metal p-type junction case the boundary is somehow between the Fermi energy $E_{F,S}$ and the valance band upper bound $E_{v,S}$, which curves downwards. I don't see how an energy barrier can be formed there. To me it looks, as if the barrier should be preventing electrons form the metal to go to the valance band.

• Hmmm... Remember that holes have the opposite charge from an electron. Electrons have a hard time going 'up' in the diagrams, while holes have a hard time going 'down'. – Jon Custer Oct 18 '16 at 18:54
• @JonCuster Is it actually possible to move electrons from the metal to the valance band of p-type SC and holes from the metal to the n-type semiconductor? – Alexander Cska Oct 19 '16 at 15:13

• Thank you for your answer. It turns out $qV(x)$ is causing the difference in behaviour. For completeness I would like to ask the following. Is it actually possible to move electrons from the metal to the valance band of p-type SC and holes from the metal to the n-type semiconductor? – Alexander Cska Oct 18 '16 at 21:21