Because PMP is optional, but mandatorily enabled by default if present, this means all “portable” system software that switches mode from M to S or U mode, must have code to configure PMP. Note also the code linked above sets and restores the trap vector in case the PMP CSRs are not implemented and cause an illegal instruction exception. Technically the PMP CSRs should be hard-wired to zero if not implemented and they are WARL (Write Any Read Legal) so one should read back the value to check if PMP is actually present.
Because PMP is optional, but mandatorily enabled by default if present, this means all “portable” system software that switches mode from M to S or U mode, must have code to configure PMP. Note also the code linked above sets and restores the trap vector in case the PMP CSRs are not implemented and cause an illegal instruction exception. Technically the PMP CSRs should be hard-wired to zero if not implemented and they are WARL (Write Any Read Legal) so one should read back the value to check if PMP is actually present.
For a discussion of this, see: https://groups.google.com/a/groups.riscv.org/forum/#!topic/isa-dev/OFa8TSc_PNI