Actually, His words indicated that Mary KNEW already about His passion. In fact, she did know. Simeon the prophet told her at the Temple when Jesus was circumcised. And it wasn't an illiterate era. Jesus and other males read from the Torah in the synagogue. So, she could read from Isaiah or have read to her from Isaiah just as easily as anyone else.
His disciples didn't understand, but Mary had been told "a sword will pierce your heart, too." Luke 2: "34 Then Simeon blessed them and said to Mary, his mother: "This child is destined to cause the falling and rising of many in Israel, and to be a sign that will be spoken against, 35 so that the thoughts of many hearts will be revealed. And a sword will pierce your own soul too.""
Wonder why the 'too'? Who else would be pierced?