519
bool kvm_supports_pmu;
520
bool kvm_supports_steal_time;
521
bool kvm_supports_sve;
522
- char max_name[8], name[8];
522
uint32_t max_vq, vq;
523
uint64_t vls;
524
QDict *resp;
572
}
573
574
if (kvm_supports_sve) {
575
+ g_autofree const char *max_name = NULL;
576
+ g_autofree const char *name = NULL;
577
+
578
g_assert(vls != 0);
579
max_vq = 64 - __builtin_clzll(vls);
578
- sprintf(max_name, "sve%u", max_vq * 128);
580
+ max_name = g_strdup_printf("sve%u", max_vq * 128);
581
582
/* Enabling a supported length is of course fine. */
583
assert_sve_vls(qts, "host", vls, "{ %s: true }", max_name);
585
/* Get the next supported length smaller than max-vq. */
586
vq = 64 - __builtin_clzll(vls & ~BIT_ULL(max_vq - 1));
587
if (vq) {
588
+ g_autofree const char *name2 =
589
+ g_strdup_printf("sve%u", vq * 128);
590
+
591
/*
592
* We have at least one length smaller than max-vq,
593
* so we can disable max-vq.
600
* unless all larger, supported vector lengths are also
601
* disabled.
602
*/
598
- sprintf(name, "sve%u", vq * 128);
599
- error = g_strdup_printf("cannot disable %s", name);
603
+ error = g_strdup_printf("cannot disable %s", name2);
604
assert_error(qts, "host", error,
605
"{ %s: true, %s: false }",
602
- max_name, name);
606
+ max_name, name2);
607
g_free(error);
608
}
609
612
* we need at least one vector length enabled.
613
*/
614
vq = __builtin_ffsll(vls);
611
- sprintf(name, "sve%u", vq * 128);
615
+ name = g_strdup_printf(name, "sve%u", vq * 128);
616
error = g_strdup_printf("cannot disable %s", name);
617
assert_error(qts, "host", error, "{ %s: false }", name);
618
g_free(error);
624
}
625
}
626
if (vq <= SVE_MAX_VQ) {
623
- sprintf(name, "sve%u", vq * 128);
624
- error = g_strdup_printf("cannot enable %s", name);
625
- assert_error(qts, "host", error, "{ %s: true }", name);
627
+ g_autofree const char *name2 =
628
+ g_strdup_printf("sve%u", vq * 128);
629
+
630
+ error = g_strdup_printf("cannot enable %s", name2);
631
+ assert_error(qts, "host", error, "{ %s: true }", name2);
632
g_free(error);
633
}
634
} else {