It's only a trim that cleans up the look between the edge of the glass and sheet metal. The windsheild if installed properly will not leak even without the trim in place.
Mine is also popped up, but not as much as yours though. You can try using some 3M automotive double side tape and stick down. If it's under warranty, you could see if the dealer will take care of it. If it was me, I would rip more of it out first before going to dealer so it's now a bigger issue. Don't blame me, if they won't do anything and you followed my advice ripping it some more.
The way I see it, it's Toyota's quality sliding down the hill or falling off the cliff.