How to set up stage-2 translation table


I am trying to enable stage-2 translation for Armv8 aarch32, cortex-a53. If I set HCR.VM=1(enable stage-2 translation) it will crash. I suspect it does not set up stage-2 translation table. But when I read the Arm Architecture Reference Manual, I cannot find the pseudo-code for creating such table(only find pictures).

So could anyone provide some code or pseudo-code for creating stage-2 translation table?