In power systems with grid-forming inverters (GFMs), small-signal instability issues could occur due to harmonic excitation, impedance interactions, and poor inverter control design. There mainly exist two types of stability issues based on the frequency range. One is the low-frequency resonance (0 -2f 0 Hz) and the other is the high-frequency harmonics (above 2f 0 Hz), where f 0 is the system fundamental frequency. By assuming that the low-frequency related controls are well designed, this paper addresses the high-frequency harmonic issues. The goal is to develop a system stabilization function (SSF) to eliminate any high-frequency stability issues under various grid conditions without affecting predefined low-frequency behaviors. The idea is to conduct the inverter passivation test at the system harmonic resonant frequency so that the corresponding harmonic instability can be removed. To achieve this, the resonant frequency of the harmonic instability is detected first, and then if the magnitude of the resonant component exceeds the threshold value, the proposed SSF will be enabled, thus the system would be stabilized. Both simulation and experimental tests are conducted to validate the effectiveness of the proposed approach.INDEX TERMS Grid-forming inverters, harmonic instability, online harmonic detection, passivity-based design.