  We prove a higher weight general Gross--Zagier formula for CM cycles on
Kuga--Sato varieties over modular curves of arbitrary levels. To formulate and
prove this result, we prove several results on the modularity of CM cycles, in
the sense that the Hecke modules they generate are semisimple modules whose
irreducible components are associated to higher weight holomorphic cuspidal
automorphic representations. These two types of results provide evidence toward
two conjectures of Beilinson--Bloch. The higher weight general Gross--Zagier
formula is proved using arithmetic relative trace formulas. The proof of the
modularity of CM cycles is inspired by arithmetic theta lifting.
