lkml.org 
[lkml]   [2021]   [Feb]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v14 11/11] selftests: kvm/x86: add test for pmu msr MSR_IA32_PERF_CAPABILITIES
From
Date
On 01/02/21 07:01, Like Xu wrote:
>
> +uint64_t rdmsr_on_cpu(uint32_t reg)
> +{
> + uint64_t data;
> + int fd;
> + char msr_file[64];
> +
> + sprintf(msr_file, "/dev/cpu/%d/msr", 0);
> + fd = open(msr_file, O_RDONLY);
> + if (fd < 0)
> + exit(KSFT_SKIP);
> +
> + if (pread(fd, &data, sizeof(data), reg) != sizeof(data))
> + exit(KSFT_SKIP);
> +
> + close(fd);
> + return data;
> +}

In order to allow running as non-root, it's better to use the
KVM_GET_MSRS ioctl on the /dev/kvm file descriptor.

The tests pass, but please take a look at the kvm/queue branch to see if
everything is ok.

Paolo

\
 
 \ /
  Last update: 2021-02-02 15:57    [W:0.117 / U:0.056 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site