Preheat the oven to 425 degrees F. Pull back the husks from the corn to expose about 3 inches of the cob. Place the corn on a sheet pan. Quarter the onion and add it to the sheet pan. Roast until the husks start to brown and the corn is just cooked, about 20 minutes.
Remove the husks and silks from the corn. Stand each cob on its end in another sheet pan and, holding the top, slice downward along the cob to remove the kernels. (Doing this over a sheet pan catches the kernels for you.) Set the kernels aside.
Place the cobs, roasted onion, thyme sprigs, garlic, bay leaves and peppercorns in a pot and cover with water. (If you need to, snap the cobs in half to fit into the pot.) Bring to a boil, then reduce to a gentle simmer for 45 minutes to make a stock.
Place half of the corn kernels in a blender with one ladle of the developing stock and puree until smooth. Transfer the remaining kernels to a cutting board and roughly chop.
Coat a large saute pan with some olive oil and set over medium-high heat. Add the chopped corn mixture to the pan and cook just to sweat and soften it, 3 to 5 minutes. Scoop up some of the roasted onion pieces from the stock and add to the corn mixture. Pour in the corn from the blender and 1 cup of the corn stock. Cook until the grits thicken to a porridge-like consistency, another 5 minutes or so. If they are too thick, add more stock; if too think, cook them a bit longer. Season with salt.