qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

target/ppc: Clarify compat mode max_threads value

We recently had some discussions that were sidetracked for a while, because
nearly everyone misapprehended the purpose of the 'max_threads' field in
the compatiblity modes table. It's all about guest expectations, not host
expectations or support (that's handled elsewhere).

In an attempt to avoid a repeat of that confusion, rename the field to
'max_vthreads' and add an explanatory comment.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Laurent Vivier <lvivier@redhat.com>
Reviewed-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Jose Ricardo Ziviani <joserz@linux.vnet.ibm.com>

+20 -11
+2 -2
hw/ppc/spapr.c
··· 345 345 PowerPCCPU *cpu = POWERPC_CPU(cs); 346 346 DeviceClass *dc = DEVICE_GET_CLASS(cs); 347 347 int index = spapr_vcpu_id(cpu); 348 - int compat_smt = MIN(smp_threads, ppc_compat_max_threads(cpu)); 348 + int compat_smt = MIN(smp_threads, ppc_compat_max_vthreads(cpu)); 349 349 350 350 if ((index % smt) != 0) { 351 351 continue; ··· 503 503 size_t page_sizes_prop_size; 504 504 uint32_t vcpus_per_socket = smp_threads * smp_cores; 505 505 uint32_t pft_size_prop[] = {0, cpu_to_be32(spapr->htab_shift)}; 506 - int compat_smt = MIN(smp_threads, ppc_compat_max_threads(cpu)); 506 + int compat_smt = MIN(smp_threads, ppc_compat_max_vthreads(cpu)); 507 507 sPAPRDRConnector *drc; 508 508 int drc_index; 509 509 uint32_t radix_AP_encodings[PPC_PAGE_SIZES_MAX_SZ];
+17 -8
target/ppc/compat.c
··· 32 32 uint32_t pvr; 33 33 uint64_t pcr; 34 34 uint64_t pcr_level; 35 - int max_threads; 35 + 36 + /* 37 + * Maximum allowed virtual threads per virtual core 38 + * 39 + * This is to stop older guests getting confused by seeing more 40 + * threads than they think the cpu can support. Usually it's 41 + * equal to the number of threads supported on bare metal 42 + * hardware, but not always (see POWER9). 43 + */ 44 + int max_vthreads; 36 45 } CompatInfo; 37 46 38 47 static const CompatInfo compat_table[] = { ··· 45 54 .pcr = PCR_COMPAT_3_00 | PCR_COMPAT_2_07 | PCR_COMPAT_2_06 | 46 55 PCR_COMPAT_2_05 | PCR_TM_DIS | PCR_VSX_DIS, 47 56 .pcr_level = PCR_COMPAT_2_05, 48 - .max_threads = 2, 57 + .max_vthreads = 2, 49 58 }, 50 59 { /* POWER7, ISA2.06 */ 51 60 .name = "power7", 52 61 .pvr = CPU_POWERPC_LOGICAL_2_06, 53 62 .pcr = PCR_COMPAT_3_00 | PCR_COMPAT_2_07 | PCR_COMPAT_2_06 | PCR_TM_DIS, 54 63 .pcr_level = PCR_COMPAT_2_06, 55 - .max_threads = 4, 64 + .max_vthreads = 4, 56 65 }, 57 66 { 58 67 .name = "power7+", 59 68 .pvr = CPU_POWERPC_LOGICAL_2_06_PLUS, 60 69 .pcr = PCR_COMPAT_3_00 | PCR_COMPAT_2_07 | PCR_COMPAT_2_06 | PCR_TM_DIS, 61 70 .pcr_level = PCR_COMPAT_2_06, 62 - .max_threads = 4, 71 + .max_vthreads = 4, 63 72 }, 64 73 { /* POWER8, ISA2.07 */ 65 74 .name = "power8", 66 75 .pvr = CPU_POWERPC_LOGICAL_2_07, 67 76 .pcr = PCR_COMPAT_3_00 | PCR_COMPAT_2_07, 68 77 .pcr_level = PCR_COMPAT_2_07, 69 - .max_threads = 8, 78 + .max_vthreads = 8, 70 79 }, 71 80 { /* POWER9, ISA3.00 */ 72 81 .name = "power9", ··· 80 89 * confusing if half of the threads disappear from the guest 81 90 * if it announces it's POWER9 aware at CAS time. 82 91 */ 83 - .max_threads = 8, 92 + .max_vthreads = 8, 84 93 }, 85 94 }; 86 95 ··· 192 201 } 193 202 } 194 203 195 - int ppc_compat_max_threads(PowerPCCPU *cpu) 204 + int ppc_compat_max_vthreads(PowerPCCPU *cpu) 196 205 { 197 206 const CompatInfo *compat = compat_by_pvr(cpu->compat_pvr); 198 207 int n_threads = CPU(cpu)->nr_threads; 199 208 200 209 if (cpu->compat_pvr) { 201 210 g_assert(compat); 202 - n_threads = MIN(n_threads, compat->max_threads); 211 + n_threads = MIN(n_threads, compat->max_vthreads); 203 212 } 204 213 205 214 return n_threads;
+1 -1
target/ppc/cpu.h
··· 1395 1395 #if !defined(CONFIG_USER_ONLY) 1396 1396 void ppc_set_compat_all(uint32_t compat_pvr, Error **errp); 1397 1397 #endif 1398 - int ppc_compat_max_threads(PowerPCCPU *cpu); 1398 + int ppc_compat_max_vthreads(PowerPCCPU *cpu); 1399 1399 void ppc_compat_add_property(Object *obj, const char *name, 1400 1400 uint32_t *compat_pvr, const char *basedesc, 1401 1401 Error **errp);