Seriously worth repeating. HR is NOT your friend. I learnt this the hard way.
HR's core function is to protect the company from litigation by employees. The HR management is highly unlikely to side with you against upper management no matter how much you are in the right.