If Semenya is male, then Semenya shouldn't be competing against women. Same for all DSD males. Sport is segregated into male and female for a reason.
Indeed, but there is scope for nuance here. Male and female are reproductive categories, and sport is not reproduction.
Being a member of the reproductive category very very very very closely correlates to the physical body type, but it's the physical body type that really matters for sport.
The IAAF ruling tried to be clear on this - stressing that they were interested in "sporting sex", which was not necessarily aligned with legal, genetic, social or other male/female classifications of an individual.
It's possible that someone with male genetics could have a female body type, or close enough to qualify for female sport.
CAIS is such a condition, and CAIS males are not currently restricted in female athletics. Although there is evidence that they're overrepresented among female athletes, someone with the condition does not seem to have anything like the standard male advantage. It's possibly an advantage of the order of "height" that can be accommodated as if it were a variation of a female body type. Or maybe it shouldn't be. More research would be required.
Semenya's condition 5-ARD, by contrast, is not one that interferes with male body development as a whole, so Semenya basically has a largely standard male body, but with problems in the male reproductive system. Nevertheless, internal testes mean standard male testosterone levels virilising the standard male body. Such a male-bodied individual cannot be accommodated in women's sport without defeating the entire purpose of the category.
There could in principle be individuals with female genetics whose body type was too male to be placed in female sport. However I don't believe there are any such known DSDs. Having a DSD is not an advantage. A genetic female may have elevated natural testosterone, eg PCOS, but the condition is not a net performance benefit, so there are no limits placed on natural testosterone levels for XX females.