Make sure you don't hit the jump button too early, or you'll Homing Attack and lose all speed. Running on the ground will take your speed back down to the normal max. You want to jump as soon as you hit the ground to keep your momentum, as M-Speed only works in the air. While Sonic is walking forwards at this speed, boost and jump a few times. The sweet spot you need to hit to pull this off is significantly smaller than in Unleashed and will take a bit of practice. To do it, you need to tilt the analog stick forwards just enough so that Sonic starts walking forwards, so that you are on the very point between standing still and walking. M-Speed is the 3D version of this glitch. PS3 and Xbox stock controllers will work fine, cheap knockoffs probably won't.
To perform these glitches you MUST be using a controller with continuous sensitivity on the analog sticks. These glitches were also present in Unleashed, when Generations was made it was supposedly patched but is still possible, albeit much harder. This is useful for speedrunning and can even be used to skip entire sections of levels. M-Speed and D-Speed are the 3D and 2D variants of the Superspeed exploit in which Sonic can attain very high speeds that are otherwise impossible.