mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 15:27:47 +00:00
cpu_x86: Introduce virCPUx86SignatureFromCPUID
It can be used for separating family, model, and stepping numbers from a single 32b integer as reported by CPUID. Signed-off-by: Jiri Denemark <jdenemar@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
372b2cf1ca
commit
3b474c1f8f
@ -717,6 +717,18 @@ x86MakeSignature(unsigned int family,
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
virCPUx86SignatureFromCPUID(uint32_t sig,
|
||||
unsigned int *family,
|
||||
unsigned int *model,
|
||||
unsigned int *stepping)
|
||||
{
|
||||
*family = ((sig >> 20) & 0xff) + ((sig >> 8) & 0xf);
|
||||
*model = ((sig >> 12) & 0xf0) + ((sig >> 4) & 0xf);
|
||||
*stepping = sig & 0xf;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
x86DataToSignatureFull(const virCPUx86Data *data,
|
||||
unsigned int *family,
|
||||
@ -725,17 +737,14 @@ x86DataToSignatureFull(const virCPUx86Data *data,
|
||||
{
|
||||
virCPUx86DataItem leaf1 = CPUID(.eax_in = 0x1);
|
||||
virCPUx86DataItemPtr item;
|
||||
virCPUx86CPUIDPtr cpuid;
|
||||
|
||||
*family = *model = *stepping = 0;
|
||||
|
||||
if (!(item = virCPUx86DataGet(data, &leaf1)))
|
||||
return;
|
||||
|
||||
cpuid = &item->data.cpuid;
|
||||
*family = ((cpuid->eax >> 20) & 0xff) + ((cpuid->eax >> 8) & 0xf);
|
||||
*model = ((cpuid->eax >> 12) & 0xf0) + ((cpuid->eax >> 4) & 0xf);
|
||||
*stepping = cpuid->eax & 0xf;
|
||||
virCPUx86SignatureFromCPUID(item->data.cpuid.eax,
|
||||
family, model, stepping);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user