The invention provides compounds having the general formula I:and pharmaceutically acceptable salts thereof, wherein the variables RAA, n, ring A, X1, L, m, X2, R2, R3, R4, R5, X, and R6 have the meaning as described herein, and compositions containing such compounds and methods for using such compounds and compositions.