Re: [PATCH v2 4/7] cpu_x86: Read CPU features from IA32_ARCH_CAPABILITIES MSR

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 6/19/19 6:53 PM, Jiri Denemark wrote:
> This is used by the host capabilities code to construct host CPU
> definition.
> 
> Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx>
> Reviewed-by: Ján Tomko <jtomko@xxxxxxxxxx>
> ---
>  src/cpu/cpu_x86.c | 22 ++++++++++++++++++++++
>  1 file changed, 22 insertions(+)
> 
> diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
> index a7ec0f7095..5f051950de 100644
> --- a/src/cpu/cpu_x86.c
> +++ b/src/cpu/cpu_x86.c
> @@ -2773,6 +2773,28 @@ 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
> +     * when we are not running as root. */
> +    if (virCPUx86DataCheckFeature(cpuData, "arch-capabilities") == 1) {
> +        uint64_t msr;
> +        unsigned long index = 0x10a;
> +
> +        if (virHostCPUGetMSR(index, &msr) == 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;

Coverity notes that @cpuData will be leaked in this case.

John

> +        }
> +    }
> +
>      ret = x86DecodeCPUData(cpu, cpuData, models);
>      cpu->microcodeVersion = virHostCPUGetMicrocodeVersion();
>  
> 

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux