Efficient second harmonic generation and broad-band photoluminescence from deeply subwavelength and nontoxic nanoparticles is essential for nanophotonic applications. Here, we explore nonlinear optical response from mesoporous Si/SiO2, SiO2, and Si nanoparticles, considering various fabrication and treatment procedures. We show that thermal annealing (including femtosecond laser treatment) of mesoporous Si/SiO2 nanoparticles provides the transformation of Si phase from amorphous to crystalline, enhancing the second harmonic and nonlinear photoluminescent response. Notably, the SiO2 mesoporous frame of the considered Si/SiO2 nanoparticles plays a dual positive role for the nonlinear process: it stabilizes the Si material, and SiO2:OH− material has a second-order nonlinearity itself and impacts to the observed second harmonic signal.