[libvirt] [PATCH 35/36] cpu_x86: Read CPU features from IA32_ARCH_CAPABILITIES MSR
Ján Tomko
jtomko at redhat.com
Tue Apr 9 14:00:48 UTC 2019
On Mon, Apr 08, 2019 at 10:42:39AM +0200, Jiri Denemark wrote:
>This is used by the host capabilities code to construct host CPU
>definition.
>
>Signed-off-by: Jiri Denemark <jdenemar at redhat.com>
>---
> src/cpu/cpu_x86.c | 24 ++++++++++++++++++++++++
> 1 file changed, 24 insertions(+)
>
>diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
>index 1fe6770d57..74385f7992 100644
>--- a/src/cpu/cpu_x86.c
>+++ b/src/cpu/cpu_x86.c
>@@ -2759,6 +2759,30 @@ virCPUx86GetHost(virCPUDefPtr cpu,
> cpuidSet(CPUX86_EXTENDED, cpuData) < 0)
> goto cleanup;
>
>+ /* Read the IA32_ARCH_CAPABILITIES MSR (0x10a) if supported.
>+ * This is best effort since there might be no way to read the MSR. */
>+ if (virCPUx86DataCheckFeature(cpuData, "arch-capabilities") == 1) {
>+ uint64_t msr;
>+ unsigned long index = 0x10a;
>+ int rc = virHostCPUGetMSR(index, &msr);
>+
>+ if (rc < 0) {
>+ virResetLastError();
Using virResetLastError in a place other than starting a public API
seems fishy.
If we're ignoring the error, we should not have logged it in the first
place.
>+ } else if (rc == 0) {
>+ virCPUx86DataItem item = {
>+ .type = VIR_CPU_X86_DATA_MSR,
>+ .data.msr = {
>+ .index = index,
>+ .eax = msr & 0xffffffff,
>+ .edx = msr >> 32,
>+ },
>+ };
>+
>+ if (virCPUx86DataAdd(cpuData, &item) < 0)
>+ return -1;
>+ }
>+ }
>+
> ret = x86DecodeCPUData(cpu, cpuData, models);
> cpu->microcodeVersion = virHostCPUGetMicrocodeVersion();
Reviewed-by: Ján Tomko <jtomko at redhat.com>
Jano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20190409/e1000987/attachment-0001.sig>
More information about the libvir-list
mailing list