mirror of
https://github.com/libvirt/libvirt.git
synced 2026-09-03 20:53:04 -05:00
util: Publish and mock virHostCPUGetMSRFromKVM
The function will later be called when probing QEMU capabilities. Signed-off-by: Jiri Denemark <jdenemar@redhat.com> Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
@@ -2621,6 +2621,7 @@ virHostCPUGetKVMMaxVCPUs;
|
||||
virHostCPUGetMap;
|
||||
virHostCPUGetMicrocodeVersion;
|
||||
virHostCPUGetMSR;
|
||||
virHostCPUGetMSRFromKVM;
|
||||
virHostCPUGetOnline;
|
||||
virHostCPUGetOnlineBitmap;
|
||||
virHostCPUGetPhysAddrSize;
|
||||
|
||||
+21
-1
@@ -1376,7 +1376,18 @@ virHostCPUGetMicrocodeVersion(virArch hostArch G_GNUC_UNUSED)
|
||||
|
||||
#if WITH_LINUX_KVM_H && defined(KVM_GET_MSRS) && \
|
||||
(defined(__i386__) || defined(__x86_64__))
|
||||
static int
|
||||
/**
|
||||
* virHostCPUGetMSRFromKVM:
|
||||
* @index: MSR to read
|
||||
* @result: where to store the content of the @index register
|
||||
*
|
||||
* Reads the 64b content of the specified register via KVM_GET_MSRS ioctl.
|
||||
*
|
||||
* Returns 0 on success,
|
||||
* 1 when the MSR is not supported by the host CPU,
|
||||
* -1 on error.
|
||||
*/
|
||||
int
|
||||
virHostCPUGetMSRFromKVM(unsigned long index,
|
||||
uint64_t *result)
|
||||
{
|
||||
@@ -1613,6 +1624,15 @@ virHostCPUGetCPUID(void)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
virHostCPUGetMSRFromKVM(unsigned long index G_GNUC_UNUSED,
|
||||
uint64_t *result G_GNUC_UNUSED)
|
||||
{
|
||||
virReportSystemError(ENOSYS, "%s",
|
||||
_("Reading MSRs is not supported on this platform"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
int
|
||||
virHostCPUGetMSR(unsigned long index G_GNUC_UNUSED,
|
||||
uint64_t *msr G_GNUC_UNUSED)
|
||||
|
||||
@@ -78,6 +78,9 @@ int virHostCPUGetOnline(unsigned int cpu, bool *online);
|
||||
unsigned int
|
||||
virHostCPUGetMicrocodeVersion(virArch hostArch) ATTRIBUTE_MOCKABLE;
|
||||
|
||||
int virHostCPUGetMSRFromKVM(unsigned long index,
|
||||
uint64_t *result) ATTRIBUTE_MOCKABLE;
|
||||
|
||||
int virHostCPUGetMSR(unsigned long index,
|
||||
uint64_t *msr);
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "qemu/qemu_capspriv.h"
|
||||
#include "testutilshostcpus.h"
|
||||
#include "virarch.h"
|
||||
#include "util/virhostcpu.h"
|
||||
|
||||
|
||||
virCPUDef *
|
||||
@@ -33,3 +34,24 @@ virQEMUCapsProbeHostCPU(virArch hostArch G_GNUC_UNUSED,
|
||||
|
||||
return testUtilsHostCpusGetDefForModel(model);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
virHostCPUGetMSRFromKVM(unsigned long index,
|
||||
uint64_t *result)
|
||||
{
|
||||
if (index == 0x10a) {
|
||||
/* Return some arbitrary bits in arch-capabilities MSR */
|
||||
*result =
|
||||
0x00000001 | /* rdctl-no */
|
||||
0x00000008 | /* skip-l1dfl-vmentry */
|
||||
0x00000020 | /* mds-no */
|
||||
0x00000040 | /* pschange-mc-no */
|
||||
0x04000000 | /* gds-no */
|
||||
0x08000000; /* rfds-no */
|
||||
return 0;
|
||||
}
|
||||
|
||||
errno = ENOTSUP;
|
||||
return -1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user