I am having a similar issue with Maximus XII Hero(WiFi). Most recent BIOS. I have G.SKILL Trident Z Royal 64GB (4 x 16GB) DDR4 4000 which is on the QVL. I enable XMP and save/Reboot. It always opens in Safe Mode then I have to F1 to setup and save it again. Then proceeds to boot into Windows. BIOS shows XMP enabled and the RAM as DDR4-4000 CL17-18-18-38 1.40V but always stays at 2133Mhz.
Windows runs fine but I want the 4000 I paid for, not 2133.
Any ideas???