qemu: Implement the SBBC pSeries feature

This patch adds the implementation of the SBBC pSeries feature,
using the QEMU_CAPS_MACHINE_PSERIES_CAP_SBBC capability added
in the previous patch.

Like the previously added CFPC feature, SBBC can have the values
"broken", "workaround" or "fixed". Extra code is required to handle
it since it's not a regular tristate capability.

This is the XML format for the cap:

<features>
  <sbbc value='workaround'/>
</features>

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Daniel Henrique Barboza 2020-04-27 09:14:29 -03:00 committed by Michal Privoznik
parent 249a5c789e
commit 104dadcff6
12 changed files with 124 additions and 4 deletions

View File

@ -2079,6 +2079,7 @@
&lt;ccf-assist state='on'/&gt;
&lt;msrs unknown='ignore'/&gt;
&lt;cfpc value='workaround'/&gt;
&lt;sbbc value='workaround'/&gt;
&lt;/features&gt;
...</pre>
@ -2417,6 +2418,16 @@
default will be used.
<span class="since">Since 6.3.0</span> (QEMU/KVM only)
</dd>
<dt><code>sbbc</code></dt>
<dd>Configure sbbc (Speculation Barrier Bounds Checking) availability for
pSeries guests.
Possible values for the <code>value</code> attribute
are <code>broken</code> (no protection), <code>workaround</code>
(software workaround available) and <code>fixed</code> (fixed in
hardware). If the attribute is not defined, the hypervisor
default will be used.
<span class="since">Since 6.3.0</span> (QEMU/KVM only)
</dd>
</dl>
<h3><a id="elementsTime">Time keeping</a></h3>

View File

@ -5437,6 +5437,9 @@
<optional>
<ref name="cfpc"/>
</optional>
<optional>
<ref name="sbbc"/>
</optional>
</interleave>
</element>
</optional>
@ -5708,6 +5711,18 @@
</element>
</define>
<define name="sbbc">
<element name="sbbc">
<attribute name="value">
<choice>
<value>broken</value>
<value>workaround</value>
<value>fixed</value>
</choice>
</attribute>
</element>
</define>
<define name="address">
<element name="address">
<choice>

View File

@ -175,6 +175,7 @@ VIR_ENUM_IMPL(virDomainFeature,
"ccf-assist",
"xen",
"cfpc",
"sbbc",
);
VIR_ENUM_IMPL(virDomainCapabilitiesPolicy,
@ -1275,6 +1276,14 @@ VIR_ENUM_IMPL(virDomainCFPC,
"fixed",
);
VIR_ENUM_IMPL(virDomainSBBC,
VIR_DOMAIN_SBBC_LAST,
"none",
"broken",
"workaround",
"fixed",
);
/* Internal mapping: subset of block job types that can be present in
* <mirror> XML (remaining types are not two-phase). */
VIR_ENUM_DECL(virDomainBlockJob);
@ -19350,6 +19359,21 @@ virDomainFeaturesDefParse(virDomainDefPtr def,
}
break;
case VIR_DOMAIN_FEATURE_SBBC:
tmp = virXMLPropString(nodes[i], "value");
if (tmp) {
int value = virDomainSBBCTypeFromString(tmp);
if (value < 0 || value == VIR_DOMAIN_SBBC_NONE) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Unknown value: %s"),
tmp);
goto error;
}
def->features[val] = value;
VIR_FREE(tmp);
}
break;
case VIR_DOMAIN_FEATURE_HTM:
case VIR_DOMAIN_FEATURE_NESTED_HV:
case VIR_DOMAIN_FEATURE_CCF_ASSIST:
@ -23413,6 +23437,18 @@ virDomainDefFeaturesCheckABIStability(virDomainDefPtr src,
}
break;
case VIR_DOMAIN_FEATURE_SBBC:
if (src->features[i] != dst->features[i]) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("State of feature '%s' differs: "
"source: '%s=%s', destination: '%s=%s'"),
featureName,
"value", virDomainSBBCTypeToString(src->features[i]),
"value", virDomainSBBCTypeToString(dst->features[i]));
return false;
}
break;
case VIR_DOMAIN_FEATURE_MSRS:
break;
@ -29255,6 +29291,14 @@ virDomainDefFormatFeatures(virBufferPtr buf,
virDomainCFPCTypeToString(def->features[i]));
break;
case VIR_DOMAIN_FEATURE_SBBC:
if (def->features[i] == VIR_DOMAIN_SBBC_NONE)
break;
virBufferAsprintf(&childBuf, "<sbbc value='%s'/>\n",
virDomainSBBCTypeToString(def->features[i]));
break;
/* coverity[dead_error_begin] */
case VIR_DOMAIN_FEATURE_LAST:
break;

View File

@ -1817,6 +1817,7 @@ typedef enum {
VIR_DOMAIN_FEATURE_CCF_ASSIST,
VIR_DOMAIN_FEATURE_XEN,
VIR_DOMAIN_FEATURE_CFPC,
VIR_DOMAIN_FEATURE_SBBC,
VIR_DOMAIN_FEATURE_LAST
} virDomainFeature;
@ -1999,6 +2000,17 @@ typedef enum {
VIR_ENUM_DECL(virDomainCFPC);
typedef enum {
VIR_DOMAIN_SBBC_NONE = 0,
VIR_DOMAIN_SBBC_BROKEN,
VIR_DOMAIN_SBBC_WORKAROUND,
VIR_DOMAIN_SBBC_FIXED,
VIR_DOMAIN_SBBC_LAST
} virDomainSBBC;
VIR_ENUM_DECL(virDomainSBBC);
/* Operating system configuration data & machine / arch */
struct _virDomainOSEnv {
char *name;

View File

@ -583,6 +583,8 @@ virDomainRNGModelTypeToString;
virDomainRNGRemove;
virDomainRunningReasonTypeFromString;
virDomainRunningReasonTypeToString;
virDomainSBBCTypeFromString;
virDomainSBBCTypeToString;
virDomainSCSIDriveAddressIsUsed;
virDomainSeclabelTypeFromString;
virDomainSeclabelTypeToString;

View File

@ -7176,6 +7176,11 @@ qemuBuildMachineCommandLine(virCommandPtr cmd,
virBufferAsprintf(&buf, ",cap-cfpc=%s", str);
}
if (def->features[VIR_DOMAIN_FEATURE_SBBC] != VIR_DOMAIN_SBBC_NONE) {
const char *str = virDomainSBBCTypeToString(def->features[VIR_DOMAIN_FEATURE_SBBC]);
virBufferAsprintf(&buf, ",cap-sbbc=%s", str);
}
if (cpu && cpu->model &&
cpu->mode == VIR_CPU_MODE_HOST_MODEL &&
qemuDomainIsPSeries(def) &&

View File

@ -146,6 +146,16 @@ qemuValidateDomainDefPSeriesFeature(const virDomainDef *def,
return -1;
}
break;
case VIR_DOMAIN_FEATURE_SBBC:
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_MACHINE_PSERIES_CAP_SBBC)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("sbbc configuration is not supported by "
"this QEMU binary"));
return -1;
}
break;
}
@ -205,6 +215,7 @@ qemuValidateDomainDefFeatures(const virDomainDef *def,
case VIR_DOMAIN_FEATURE_NESTED_HV:
case VIR_DOMAIN_FEATURE_CCF_ASSIST:
case VIR_DOMAIN_FEATURE_CFPC:
case VIR_DOMAIN_FEATURE_SBBC:
if (qemuValidateDomainDefPSeriesFeature(def, qemuCaps, i) < 0)
return -1;
break;

View File

@ -12,7 +12,7 @@ QEMU_AUDIO_DRV=none \
-S \
-machine pseries,accel=tcg,usb=off,dump-guest-core=off,resize-hpt=required,\
cap-hpt-max-page-size=1048576k,cap-htm=on,cap-nested-hv=off,cap-ccf-assist=on,\
cap-cfpc=fixed \
cap-cfpc=fixed,cap-sbbc=broken \
-m 512 \
-realtime mlock=off \
-smp 1,sockets=1,cores=1,threads=1 \

View File

@ -14,6 +14,7 @@
<nested-hv state='off'/>
<ccf-assist state='on'/>
<cfpc value='fixed'/>
<sbbc value='broken'/>
</features>
<devices>
<emulator>/usr/bin/qemu-system-ppc64</emulator>

View File

@ -1965,6 +1965,7 @@ mymain(void)
QEMU_CAPS_MACHINE_PSERIES_CAP_NESTED_HV,
QEMU_CAPS_MACHINE_PSERIES_CAP_CCF_ASSIST,
QEMU_CAPS_MACHINE_PSERIES_CAP_CFPC,
QEMU_CAPS_MACHINE_PSERIES_CAP_SBBC,
QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT);
/* parse error: no QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT */
@ -1974,7 +1975,8 @@ mymain(void)
QEMU_CAPS_MACHINE_PSERIES_CAP_HTM,
QEMU_CAPS_MACHINE_PSERIES_CAP_NESTED_HV,
QEMU_CAPS_MACHINE_PSERIES_CAP_CCF_ASSIST,
QEMU_CAPS_MACHINE_PSERIES_CAP_CFPC);
QEMU_CAPS_MACHINE_PSERIES_CAP_CFPC,
QEMU_CAPS_MACHINE_PSERIES_CAP_SBBC);
/* parse error: no QEMU_CAPS_MACHINE_PSERIES_CAP_HPT_MAX_PAGE_SIZE */
DO_TEST_PARSE_ERROR("pseries-features",
@ -1983,6 +1985,7 @@ mymain(void)
QEMU_CAPS_MACHINE_PSERIES_CAP_NESTED_HV,
QEMU_CAPS_MACHINE_PSERIES_CAP_CCF_ASSIST,
QEMU_CAPS_MACHINE_PSERIES_CAP_CFPC,
QEMU_CAPS_MACHINE_PSERIES_CAP_SBBC,
QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT);
/* parse error: no QEMU_CAPS_MACHINE_PSERIES_CAP_HTM */
@ -1992,6 +1995,7 @@ mymain(void)
QEMU_CAPS_MACHINE_PSERIES_CAP_NESTED_HV,
QEMU_CAPS_MACHINE_PSERIES_CAP_CCF_ASSIST,
QEMU_CAPS_MACHINE_PSERIES_CAP_CFPC,
QEMU_CAPS_MACHINE_PSERIES_CAP_SBBC,
QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT);
/* parse error: no QEMU_CAPS_MACHINE_PSERIES_CAP_NESTED_HV */
@ -2001,6 +2005,7 @@ mymain(void)
QEMU_CAPS_MACHINE_PSERIES_CAP_HTM,
QEMU_CAPS_MACHINE_PSERIES_CAP_CCF_ASSIST,
QEMU_CAPS_MACHINE_PSERIES_CAP_CFPC,
QEMU_CAPS_MACHINE_PSERIES_CAP_SBBC,
QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT);
/* parse error: no QEMU_CAPS_MACHINE_PSERIES_CAP_CCF_ASSIST */
@ -2010,6 +2015,7 @@ mymain(void)
QEMU_CAPS_MACHINE_PSERIES_CAP_HTM,
QEMU_CAPS_MACHINE_PSERIES_CAP_NESTED_HV,
QEMU_CAPS_MACHINE_PSERIES_CAP_CFPC,
QEMU_CAPS_MACHINE_PSERIES_CAP_SBBC,
QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT);
/* parse error: no QEMU_CAPS_MACHINE_PSERIES_CFPC */
@ -2019,7 +2025,18 @@ mymain(void)
QEMU_CAPS_MACHINE_PSERIES_CAP_HPT_MAX_PAGE_SIZE,
QEMU_CAPS_MACHINE_PSERIES_CAP_HTM,
QEMU_CAPS_MACHINE_PSERIES_CAP_NESTED_HV,
QEMU_CAPS_MACHINE_PSERIES_CAP_CCF_ASSIST);
QEMU_CAPS_MACHINE_PSERIES_CAP_CCF_ASSIST,
QEMU_CAPS_MACHINE_PSERIES_CAP_SBBC);
/* parse error: no QEMU_CAPS_MACHINE_PSERIES_SBBC */
DO_TEST_PARSE_ERROR("pseries-features",
QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT,
QEMU_CAPS_MACHINE_PSERIES_CAP_HPT_MAX_PAGE_SIZE,
QEMU_CAPS_MACHINE_PSERIES_CAP_HTM,
QEMU_CAPS_MACHINE_PSERIES_CAP_NESTED_HV,
QEMU_CAPS_MACHINE_PSERIES_CAP_CCF_ASSIST,
QEMU_CAPS_MACHINE_PSERIES_CAP_CFPC);
DO_TEST_PARSE_ERROR("pseries-features-invalid-machine", NONE);

View File

@ -16,6 +16,7 @@
<nested-hv state='off'/>
<ccf-assist state='on'/>
<cfpc value='fixed'/>
<sbbc value='broken'/>
</features>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>

View File

@ -696,7 +696,8 @@ mymain(void)
QEMU_CAPS_MACHINE_PSERIES_CAP_NESTED_HV,
QEMU_CAPS_MACHINE_PSERIES_CAP_CCF_ASSIST,
QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT,
QEMU_CAPS_MACHINE_PSERIES_CAP_CFPC);
QEMU_CAPS_MACHINE_PSERIES_CAP_CFPC,
QEMU_CAPS_MACHINE_PSERIES_CAP_SBBC);
DO_TEST("pseries-serial-native",
QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,