Yeah, didn't want the pillow suggested. Flat out would never do that.
Ok, now to address your question. Never put a gun under your pillow. Never.
There are a few holster choices that will strap a gun to the side of your mattress and I guess that might be an option to explore, although to some degree grabbing any weapon from a prone position, especially when sleep is involved, is always going to be somewhat awkward.
Mine stays locked up on the floor next to me, so I'm not going to be able to access it lightning fast, but given the fact that I would hope to be woken up before anyone gets to my bedroom door, I don't expect that few seconds it takes to make much of a serious difference.