Cross-Layer Design Of Reliable And Secure Cyber-Physical Systems