Germany's main requirement is that you have insufficient open positions in the company (not just same roles - no open positions at all, the company is obligated to train), and that you follow "social selection", taking into account "tenure, age, family responsibilities, severe disability". High performance can be justification to keep someone despite meeting the social selection criteria for termination, but low performance cannot generally be a reason for inclusion in the list of terminations.
If you are legitimately downsizing it is pretty easy. If you are trying to use "layoffs" as cover to cut the bottom x% of performers, you'll hit trouble.