You must return all legendary permanent cards to the battlefield, even if the “legend rule” will put some right back into your graveyard. If any abilities triggered from the legendary permanents entering the battlefield, those abilities will be put onto the stack after applying the “legend rule.”