SOCP reformulation for the generalized trust region subproblem via a canonical form of two symmetric matrices