Efficient and secure context switching and migrations for heterogeneous multiprocessors