Split virtual-mem-related code into its own files.
Revert "Fix libpfm linkage."

This reverts commit 9555f95bbfd30f5118a5ed40425d2543644c89a5.
Rename restore_mem to AutoRestoreMem.
Convert remote-syscall code into an RAII helper, AutoRemoteSyscalls.
Address review comments.