libnvmm: Fix mmap() failure with 'permission denied'
The mmap() in nvmm_vcpu_create() was always failing with the EACCES
(permission denied) error code. It was because mmap() was requesting
prot = PROT_READ|PROT_WRITE and flags = MAP_SHARED, but the fd was
opened with O_RDONLY (or O_WRONLY in nvmm_root_init()) and thus
disallowed such a mmap request.
Fix this issue by opening the nvmm fd with O_RDWR flag. This also
requires to change the mode of '/dev/nvmm' from 0640 to 0660.
However, this makes root owner distinguishing in nvmm kernel module
useless. So change to identify root owner by checking whether the
caller has root privilege.
In addition, refactor nvmm_root_init() to also check for root privilege
first and then call nvmm_init().