$x^2+(m-1)x-m-2=0\\\text{Ta có: }\Delta=(m+1)^2-4(-m-2)=m^2+6m+9=(m+3)^2\ge0\,\,\forall m\\\to \text{Phương trình luôn có nghiệm }\forall m\\\text{Theo Viet: }\begin{cases}x_1+x_2=-\dfrac{b}{a}=1-m\\x_1x_2=\dfrac{c}{a}=-m-2\end{cases}\\\text{Theo đề bài: }x_1^2+x_2^2=9\\\to (x_1+x_2)^2-2x_1x_2=9\\\to (1-m)^2-2.(-m-2)=9\\\to m^2-2m+1-2m+4=9\\\to m^2-4=0\\\to m=\pm 2\\\to D$