How can I solve this

My solution at Generalizing "trace_inv" for matrix quadratic forms does what you need.

Note: @trump_mink’s solution is not consistent with CVX’s rules.