Cosmic rays and magnetic fields in the core and halo of the starburst M82: implications for galactic wind physics