1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-01-12 15:52:55 +00:00

qemu: Report physical address size in domain capabilities

We already report the hosts physical address size in host capabilities,
but computing a baseline CPU definition is done from domain
capabilities.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Jiri Denemark 2023-06-09 17:17:36 +02:00
parent 078e645cc3
commit be1b7d5b18
37 changed files with 80 additions and 2 deletions

@ -187,6 +187,7 @@ CPUs <formatdomain.html#cpu-model-and-topology>`__.
<mode name='host-model' supported='yes'>
<model fallback='allow'>Broadwell</model>
<vendor>Intel</vendor>
<maxphysaddr mode="passthrough" limit="39"/>
<feature policy='disable' name='aes'/>
<feature policy='require' name='vmx'/>
</mode>
@ -218,7 +219,10 @@ more details about it:
indicated by the ``fallback`` attribute of the ``model`` sub element:
``allow`` means not all specifics were accounted for and thus the CPU a guest
will see may be different; ``forbid`` indicates that the CPU a guest will see
should match this CPU definition.
should match this CPU definition. The optional ``maxphysaddr`` element
reports physical address size of the host CPU if this value is available and
applicable for the requested domain type. This is useful for computing
baseline CPU definition which should be compatible with several hosts.
``custom``
The ``mode`` element contains a list of supported CPU models, each described
by a dedicated ``model`` element. The ``usable`` attribute specifies whether

@ -132,6 +132,9 @@
<optional>
<ref name="cpuVendor"/>
</optional>
<optional>
<ref name="cpuMaxPhysAddr"/>
</optional>
<zeroOrMore>
<ref name="cpuFeature"/>
</zeroOrMore>

@ -717,6 +717,8 @@ struct _virQEMUCapsHostCPUData {
* probe QEMU or load the cache.
*/
qemuMonitorCPUModelInfo *info;
/* Physical address size of the host CPU or 0 if unknown or not applicable. */
unsigned int physAddrSize;
/* Host CPU definition reported in domain capabilities. */
virCPUDef *reported;
/* Migratable host CPU definition used for updating guest CPU. */
@ -2236,6 +2238,7 @@ virQEMUCapsGetHostModel(virQEMUCaps *qemuCaps,
static void
virQEMUCapsSetHostModel(virQEMUCaps *qemuCaps,
virDomainVirtType type,
unsigned int physAddrSize,
virCPUDef *reported,
virCPUDef *migratable,
virCPUDef *full)
@ -2243,12 +2246,34 @@ virQEMUCapsSetHostModel(virQEMUCaps *qemuCaps,
virQEMUCapsHostCPUData *cpuData;
cpuData = &virQEMUCapsGetAccel(qemuCaps, type)->hostCPU;
cpuData->physAddrSize = physAddrSize;
cpuData->reported = reported;
cpuData->migratable = migratable;
cpuData->full = full;
}
static virCPUMaxPhysAddrDef *
virQEMUCapsGetHostPhysAddr(virQEMUCaps *qemuCaps,
virDomainVirtType type)
{
virQEMUCapsHostCPUData *cpuData;
virCPUMaxPhysAddrDef *addr = NULL;
cpuData = &virQEMUCapsGetAccel(qemuCaps, type)->hostCPU;
if (cpuData->physAddrSize != 0) {
addr = g_new0(virCPUMaxPhysAddrDef, 1);
addr->mode = VIR_CPU_MAX_PHYS_ADDR_MODE_PASSTHROUGH;
addr->limit = cpuData->physAddrSize;
addr->bits = -1;
}
return addr;
}
bool
virQEMUCapsIsArchSupported(virQEMUCaps *qemuCaps,
virArch arch)
@ -3805,6 +3830,7 @@ virQEMUCapsInitHostCPUModel(virQEMUCaps *qemuCaps,
virCPUDef *migCPU = NULL;
virCPUDef *hostCPU = NULL;
virCPUDef *fullCPU = NULL;
unsigned int physAddrSize = 0;
size_t i;
int rc;
@ -3878,7 +3904,10 @@ virQEMUCapsInitHostCPUModel(virQEMUCaps *qemuCaps,
goto error;
}
virQEMUCapsSetHostModel(qemuCaps, type, cpu, migCPU, fullCPU);
if (virQEMUCapsTypeIsAccelerated(type))
virHostCPUGetPhysAddrSize(&physAddrSize);
virQEMUCapsSetHostModel(qemuCaps, type, physAddrSize, cpu, migCPU, fullCPU);
cleanup:
virCPUDefFree(cpuExpanded);
@ -6224,6 +6253,8 @@ virQEMUCapsFillDomainCPUCaps(virQEMUCaps *qemuCaps,
virCPUDef *cpu = virQEMUCapsGetHostModel(qemuCaps, domCaps->virttype,
VIR_QEMU_CAPS_HOST_CPU_REPORTED);
domCaps->cpu.hostModel = virCPUDefCopy(cpu);
domCaps->cpu.hostModel->addr = virQEMUCapsGetHostPhysAddr(qemuCaps,
domCaps->virttype);
}
if (virQEMUCapsIsCPUModeSupported(qemuCaps, hostarch, domCaps->virttype,

@ -44,6 +44,7 @@
<mode name='host-model' supported='yes'>
<model fallback='forbid'>Skylake-Client-IBRS</model>
<vendor>Intel</vendor>
<maxphysaddr mode='passthrough' limit='64'/>
<feature policy='require' name='ss'/>
<feature policy='require' name='vmx'/>
<feature policy='require' name='hypervisor'/>

@ -38,6 +38,7 @@
</mode>
<mode name='host-model' supported='yes'>
<model fallback='allow'>POWER8</model>
<maxphysaddr mode='passthrough' limit='64'/>
</mode>
<mode name='custom' supported='yes'>
<model usable='unknown' vendor='IBM'>POWER9</model>

@ -38,6 +38,7 @@
</mode>
<mode name='host-model' supported='yes'>
<model fallback='forbid'>gen15a-base</model>
<maxphysaddr mode='passthrough' limit='64'/>
<feature policy='require' name='aen'/>
<feature policy='require' name='cmmnt'/>
<feature policy='require' name='vxpdeh'/>

@ -43,6 +43,7 @@
<mode name='host-model' supported='yes'>
<model fallback='forbid'>Skylake-Client-IBRS</model>
<vendor>Intel</vendor>
<maxphysaddr mode='passthrough' limit='64'/>
<feature policy='require' name='ss'/>
<feature policy='require' name='vmx'/>
<feature policy='require' name='hypervisor'/>

@ -44,6 +44,7 @@
<mode name='host-model' supported='yes'>
<model fallback='forbid'>Skylake-Client-IBRS</model>
<vendor>Intel</vendor>
<maxphysaddr mode='passthrough' limit='64'/>
<feature policy='require' name='ss'/>
<feature policy='require' name='vmx'/>
<feature policy='require' name='hypervisor'/>

@ -38,6 +38,7 @@
</mode>
<mode name='host-model' supported='yes'>
<model fallback='allow'>POWER8</model>
<maxphysaddr mode='passthrough' limit='64'/>
</mode>
<mode name='custom' supported='yes'>
<model usable='unknown' vendor='IBM'>POWER10</model>

@ -43,6 +43,7 @@
<mode name='host-model' supported='yes'>
<model fallback='forbid'>Skylake-Client-IBRS</model>
<vendor>Intel</vendor>
<maxphysaddr mode='passthrough' limit='64'/>
<feature policy='require' name='ss'/>
<feature policy='require' name='vmx'/>
<feature policy='require' name='hypervisor'/>

@ -44,6 +44,7 @@
<mode name='host-model' supported='yes'>
<model fallback='forbid'>EPYC-Rome</model>
<vendor>AMD</vendor>
<maxphysaddr mode='passthrough' limit='64'/>
<feature policy='require' name='x2apic'/>
<feature policy='require' name='tsc-deadline'/>
<feature policy='require' name='hypervisor'/>

@ -43,6 +43,7 @@
<mode name='host-model' supported='yes'>
<model fallback='forbid'>EPYC-Rome</model>
<vendor>AMD</vendor>
<maxphysaddr mode='passthrough' limit='64'/>
<feature policy='require' name='x2apic'/>
<feature policy='require' name='tsc-deadline'/>
<feature policy='require' name='hypervisor'/>

@ -44,6 +44,7 @@
<mode name='host-model' supported='yes'>
<model fallback='forbid'>EPYC-Rome</model>
<vendor>AMD</vendor>
<maxphysaddr mode='passthrough' limit='64'/>
<feature policy='require' name='x2apic'/>
<feature policy='require' name='tsc-deadline'/>
<feature policy='require' name='hypervisor'/>

@ -38,6 +38,7 @@
</mode>
<mode name='host-model' supported='yes'>
<model fallback='allow'>POWER8</model>
<maxphysaddr mode='passthrough' limit='64'/>
</mode>
<mode name='custom' supported='yes'>
<model usable='unknown' vendor='IBM'>POWER10</model>

@ -38,6 +38,7 @@
</mode>
<mode name='host-model' supported='yes'>
<model fallback='forbid'>gen15a-base</model>
<maxphysaddr mode='passthrough' limit='64'/>
<feature policy='require' name='aen'/>
<feature policy='require' name='cmmnt'/>
<feature policy='require' name='vxpdeh'/>

@ -43,6 +43,7 @@
<mode name='host-model' supported='yes'>
<model fallback='forbid'>EPYC-Rome</model>
<vendor>AMD</vendor>
<maxphysaddr mode='passthrough' limit='64'/>
<feature policy='require' name='x2apic'/>
<feature policy='require' name='tsc-deadline'/>
<feature policy='require' name='hypervisor'/>

@ -44,6 +44,7 @@
<mode name='host-model' supported='yes'>
<model fallback='forbid'>EPYC-Rome</model>
<vendor>AMD</vendor>
<maxphysaddr mode='passthrough' limit='64'/>
<feature policy='require' name='x2apic'/>
<feature policy='require' name='tsc-deadline'/>
<feature policy='require' name='hypervisor'/>

@ -38,6 +38,7 @@
</mode>
<mode name='host-model' supported='yes'>
<model fallback='forbid'>gen15a-base</model>
<maxphysaddr mode='passthrough' limit='64'/>
<feature policy='require' name='aen'/>
<feature policy='require' name='cmmnt'/>
<feature policy='require' name='vxpdeh'/>

@ -43,6 +43,7 @@
<mode name='host-model' supported='yes'>
<model fallback='forbid'>EPYC-Rome</model>
<vendor>AMD</vendor>
<maxphysaddr mode='passthrough' limit='64'/>
<feature policy='require' name='x2apic'/>
<feature policy='require' name='tsc-deadline'/>
<feature policy='require' name='hypervisor'/>

@ -44,6 +44,7 @@
<mode name='host-model' supported='yes'>
<model fallback='forbid'>EPYC-Rome</model>
<vendor>AMD</vendor>
<maxphysaddr mode='passthrough' limit='64'/>
<feature policy='require' name='x2apic'/>
<feature policy='require' name='tsc-deadline'/>
<feature policy='require' name='hypervisor'/>

@ -43,6 +43,7 @@
<mode name='host-model' supported='yes'>
<model fallback='forbid'>EPYC-Rome</model>
<vendor>AMD</vendor>
<maxphysaddr mode='passthrough' limit='64'/>
<feature policy='require' name='x2apic'/>
<feature policy='require' name='tsc-deadline'/>
<feature policy='require' name='hypervisor'/>

@ -44,6 +44,7 @@
<mode name='host-model' supported='yes'>
<model fallback='forbid'>EPYC-Rome</model>
<vendor>AMD</vendor>
<maxphysaddr mode='passthrough' limit='64'/>
<feature policy='require' name='x2apic'/>
<feature policy='require' name='tsc-deadline'/>
<feature policy='require' name='hypervisor'/>

@ -38,6 +38,7 @@
</mode>
<mode name='host-model' supported='yes'>
<model fallback='allow'>POWER8</model>
<maxphysaddr mode='passthrough' limit='64'/>
</mode>
<mode name='custom' supported='yes'>
<model usable='unknown' vendor='IBM'>POWER10</model>

@ -43,6 +43,7 @@
<mode name='host-model' supported='yes'>
<model fallback='forbid'>EPYC-Rome</model>
<vendor>AMD</vendor>
<maxphysaddr mode='passthrough' limit='64'/>
<feature policy='require' name='x2apic'/>
<feature policy='require' name='tsc-deadline'/>
<feature policy='require' name='hypervisor'/>

@ -44,6 +44,7 @@
<mode name='host-model' supported='yes'>
<model fallback='forbid'>EPYC-Rome</model>
<vendor>AMD</vendor>
<maxphysaddr mode='passthrough' limit='64'/>
<feature policy='require' name='x2apic'/>
<feature policy='require' name='tsc-deadline'/>
<feature policy='require' name='hypervisor'/>

@ -38,6 +38,7 @@
</mode>
<mode name='host-model' supported='yes'>
<model fallback='allow'>POWER8</model>
<maxphysaddr mode='passthrough' limit='64'/>
</mode>
<mode name='custom' supported='yes'>
<model usable='unknown' vendor='IBM'>POWER10</model>

@ -43,6 +43,7 @@
<mode name='host-model' supported='yes'>
<model fallback='forbid'>EPYC-Rome</model>
<vendor>AMD</vendor>
<maxphysaddr mode='passthrough' limit='64'/>
<feature policy='require' name='x2apic'/>
<feature policy='require' name='tsc-deadline'/>
<feature policy='require' name='hypervisor'/>

@ -44,6 +44,7 @@
<mode name='host-model' supported='yes'>
<model fallback='forbid'>EPYC-Rome</model>
<vendor>AMD</vendor>
<maxphysaddr mode='passthrough' limit='64'/>
<feature policy='require' name='x2apic'/>
<feature policy='require' name='tsc-deadline'/>
<feature policy='require' name='hypervisor'/>

@ -33,6 +33,7 @@
<mode name='maximum' supported='no'/>
<mode name='host-model' supported='yes'>
<model fallback='allow'>POWER8</model>
<maxphysaddr mode='passthrough' limit='64'/>
</mode>
<mode name='custom' supported='yes'>
<model usable='unknown' vendor='IBM'>POWER10</model>

@ -43,6 +43,7 @@
<mode name='host-model' supported='yes'>
<model fallback='forbid'>EPYC-Rome</model>
<vendor>AMD</vendor>
<maxphysaddr mode='passthrough' limit='64'/>
<feature policy='require' name='x2apic'/>
<feature policy='require' name='tsc-deadline'/>
<feature policy='require' name='hypervisor'/>

@ -44,6 +44,7 @@
<mode name='host-model' supported='yes'>
<model fallback='forbid'>EPYC-Rome</model>
<vendor>AMD</vendor>
<maxphysaddr mode='passthrough' limit='64'/>
<feature policy='require' name='x2apic'/>
<feature policy='require' name='tsc-deadline'/>
<feature policy='require' name='hypervisor'/>

@ -43,6 +43,7 @@
<mode name='host-model' supported='yes'>
<model fallback='forbid'>EPYC-Rome</model>
<vendor>AMD</vendor>
<maxphysaddr mode='passthrough' limit='64'/>
<feature policy='require' name='x2apic'/>
<feature policy='require' name='tsc-deadline'/>
<feature policy='require' name='hypervisor'/>

@ -44,6 +44,7 @@
<mode name='host-model' supported='yes'>
<model fallback='forbid'>EPYC-Rome</model>
<vendor>AMD</vendor>
<maxphysaddr mode='passthrough' limit='64'/>
<feature policy='require' name='x2apic'/>
<feature policy='require' name='tsc-deadline'/>
<feature policy='require' name='hypervisor'/>

@ -43,6 +43,7 @@
<mode name='host-model' supported='yes'>
<model fallback='forbid'>EPYC-Rome</model>
<vendor>AMD</vendor>
<maxphysaddr mode='passthrough' limit='64'/>
<feature policy='require' name='x2apic'/>
<feature policy='require' name='tsc-deadline'/>
<feature policy='require' name='hypervisor'/>

@ -44,6 +44,7 @@
<mode name='host-model' supported='yes'>
<model fallback='forbid'>EPYC-Rome</model>
<vendor>AMD</vendor>
<maxphysaddr mode='passthrough' limit='64'/>
<feature policy='require' name='x2apic'/>
<feature policy='require' name='tsc-deadline'/>
<feature policy='require' name='hypervisor'/>

@ -43,6 +43,7 @@
<mode name='host-model' supported='yes'>
<model fallback='forbid'>EPYC-Rome</model>
<vendor>AMD</vendor>
<maxphysaddr mode='passthrough' limit='64'/>
<feature policy='require' name='x2apic'/>
<feature policy='require' name='tsc-deadline'/>
<feature policy='require' name='hypervisor'/>

@ -36,6 +36,13 @@ virHostCPUGetMicrocodeVersion(virArch hostArch G_GNUC_UNUSED)
return 0;
}
int
virHostCPUGetPhysAddrSize(unsigned int *size)
{
*size = 64;
return 0;
}
#if WITH_QEMU
static bool (*real_virQEMUCapsGetKVMSupportsSecureGuest)(virQEMUCaps *qemuCaps);