@@ -176,7 +176,7 @@ static bool check_supported_feat_reg(struct kvm_vcpu *vcpu, __u64 reg)
176
176
#define CORE_SPSR_XX_NR_WORDS 2
177
177
#define CORE_FPREGS_XX_NR_WORDS 4
178
178
179
- static const char * core_id_to_str (struct vcpu_config * c , __u64 id )
179
+ static const char * core_id_to_str (const char * prefix , __u64 id )
180
180
{
181
181
__u64 core_off = id & ~REG_MASK , idx ;
182
182
@@ -187,7 +187,7 @@ static const char *core_id_to_str(struct vcpu_config *c, __u64 id)
187
187
case KVM_REG_ARM_CORE_REG (regs .regs [0 ]) ...
188
188
KVM_REG_ARM_CORE_REG (regs .regs [30 ]):
189
189
idx = (core_off - KVM_REG_ARM_CORE_REG (regs .regs [0 ])) / CORE_REGS_XX_NR_WORDS ;
190
- TEST_ASSERT (idx < 31 , "%s: Unexpected regs.regs index: %lld" , config_name ( c ) , idx );
190
+ TEST_ASSERT (idx < 31 , "%s: Unexpected regs.regs index: %lld" , prefix , idx );
191
191
return strdup_printf ("KVM_REG_ARM_CORE_REG(regs.regs[%lld])" , idx );
192
192
case KVM_REG_ARM_CORE_REG (regs .sp ):
193
193
return "KVM_REG_ARM_CORE_REG(regs.sp)" ;
@@ -202,24 +202,24 @@ static const char *core_id_to_str(struct vcpu_config *c, __u64 id)
202
202
case KVM_REG_ARM_CORE_REG (spsr [0 ]) ...
203
203
KVM_REG_ARM_CORE_REG (spsr [KVM_NR_SPSR - 1 ]):
204
204
idx = (core_off - KVM_REG_ARM_CORE_REG (spsr [0 ])) / CORE_SPSR_XX_NR_WORDS ;
205
- TEST_ASSERT (idx < KVM_NR_SPSR , "%s: Unexpected spsr index: %lld" , config_name ( c ) , idx );
205
+ TEST_ASSERT (idx < KVM_NR_SPSR , "%s: Unexpected spsr index: %lld" , prefix , idx );
206
206
return strdup_printf ("KVM_REG_ARM_CORE_REG(spsr[%lld])" , idx );
207
207
case KVM_REG_ARM_CORE_REG (fp_regs .vregs [0 ]) ...
208
208
KVM_REG_ARM_CORE_REG (fp_regs .vregs [31 ]):
209
209
idx = (core_off - KVM_REG_ARM_CORE_REG (fp_regs .vregs [0 ])) / CORE_FPREGS_XX_NR_WORDS ;
210
- TEST_ASSERT (idx < 32 , "%s: Unexpected fp_regs.vregs index: %lld" , config_name ( c ) , idx );
210
+ TEST_ASSERT (idx < 32 , "%s: Unexpected fp_regs.vregs index: %lld" , prefix , idx );
211
211
return strdup_printf ("KVM_REG_ARM_CORE_REG(fp_regs.vregs[%lld])" , idx );
212
212
case KVM_REG_ARM_CORE_REG (fp_regs .fpsr ):
213
213
return "KVM_REG_ARM_CORE_REG(fp_regs.fpsr)" ;
214
214
case KVM_REG_ARM_CORE_REG (fp_regs .fpcr ):
215
215
return "KVM_REG_ARM_CORE_REG(fp_regs.fpcr)" ;
216
216
}
217
217
218
- TEST_FAIL ("%s: Unknown core reg id: 0x%llx" , config_name ( c ) , id );
218
+ TEST_FAIL ("%s: Unknown core reg id: 0x%llx" , prefix , id );
219
219
return NULL ;
220
220
}
221
221
222
- static const char * sve_id_to_str (struct vcpu_config * c , __u64 id )
222
+ static const char * sve_id_to_str (const char * prefix , __u64 id )
223
223
{
224
224
__u64 sve_off , n , i ;
225
225
@@ -229,37 +229,37 @@ static const char *sve_id_to_str(struct vcpu_config *c, __u64 id)
229
229
sve_off = id & ~(REG_MASK | ((1ULL << 5 ) - 1 ));
230
230
i = id & (KVM_ARM64_SVE_MAX_SLICES - 1 );
231
231
232
- TEST_ASSERT (i == 0 , "%s: Currently we don't expect slice > 0, reg id 0x%llx" , config_name ( c ) , id );
232
+ TEST_ASSERT (i == 0 , "%s: Currently we don't expect slice > 0, reg id 0x%llx" , prefix , id );
233
233
234
234
switch (sve_off ) {
235
235
case KVM_REG_ARM64_SVE_ZREG_BASE ...
236
236
KVM_REG_ARM64_SVE_ZREG_BASE + (1ULL << 5 ) * KVM_ARM64_SVE_NUM_ZREGS - 1 :
237
237
n = (id >> 5 ) & (KVM_ARM64_SVE_NUM_ZREGS - 1 );
238
238
TEST_ASSERT (id == KVM_REG_ARM64_SVE_ZREG (n , 0 ),
239
- "%s: Unexpected bits set in SVE ZREG id: 0x%llx" , config_name ( c ) , id );
239
+ "%s: Unexpected bits set in SVE ZREG id: 0x%llx" , prefix , id );
240
240
return strdup_printf ("KVM_REG_ARM64_SVE_ZREG(%lld, 0)" , n );
241
241
case KVM_REG_ARM64_SVE_PREG_BASE ...
242
242
KVM_REG_ARM64_SVE_PREG_BASE + (1ULL << 5 ) * KVM_ARM64_SVE_NUM_PREGS - 1 :
243
243
n = (id >> 5 ) & (KVM_ARM64_SVE_NUM_PREGS - 1 );
244
244
TEST_ASSERT (id == KVM_REG_ARM64_SVE_PREG (n , 0 ),
245
- "%s: Unexpected bits set in SVE PREG id: 0x%llx" , config_name ( c ) , id );
245
+ "%s: Unexpected bits set in SVE PREG id: 0x%llx" , prefix , id );
246
246
return strdup_printf ("KVM_REG_ARM64_SVE_PREG(%lld, 0)" , n );
247
247
case KVM_REG_ARM64_SVE_FFR_BASE :
248
248
TEST_ASSERT (id == KVM_REG_ARM64_SVE_FFR (0 ),
249
- "%s: Unexpected bits set in SVE FFR id: 0x%llx" , config_name ( c ) , id );
249
+ "%s: Unexpected bits set in SVE FFR id: 0x%llx" , prefix , id );
250
250
return "KVM_REG_ARM64_SVE_FFR(0)" ;
251
251
}
252
252
253
253
return NULL ;
254
254
}
255
255
256
- static void print_reg (struct vcpu_config * c , __u64 id )
256
+ static void print_reg (const char * prefix , __u64 id )
257
257
{
258
258
unsigned op0 , op1 , crn , crm , op2 ;
259
259
const char * reg_size = NULL ;
260
260
261
261
TEST_ASSERT ((id & KVM_REG_ARCH_MASK ) == KVM_REG_ARM64 ,
262
- "%s: KVM_REG_ARM64 missing in reg id: 0x%llx" , config_name ( c ) , id );
262
+ "%s: KVM_REG_ARM64 missing in reg id: 0x%llx" , prefix , id );
263
263
264
264
switch (id & KVM_REG_SIZE_MASK ) {
265
265
case KVM_REG_SIZE_U8 :
@@ -291,16 +291,16 @@ static void print_reg(struct vcpu_config *c, __u64 id)
291
291
break ;
292
292
default :
293
293
TEST_FAIL ("%s: Unexpected reg size: 0x%llx in reg id: 0x%llx" ,
294
- config_name ( c ) , (id & KVM_REG_SIZE_MASK ) >> KVM_REG_SIZE_SHIFT , id );
294
+ prefix , (id & KVM_REG_SIZE_MASK ) >> KVM_REG_SIZE_SHIFT , id );
295
295
}
296
296
297
297
switch (id & KVM_REG_ARM_COPROC_MASK ) {
298
298
case KVM_REG_ARM_CORE :
299
- printf ("\tKVM_REG_ARM64 | %s | KVM_REG_ARM_CORE | %s,\n" , reg_size , core_id_to_str (c , id ));
299
+ printf ("\tKVM_REG_ARM64 | %s | KVM_REG_ARM_CORE | %s,\n" , reg_size , core_id_to_str (prefix , id ));
300
300
break ;
301
301
case KVM_REG_ARM_DEMUX :
302
302
TEST_ASSERT (!(id & ~(REG_MASK | KVM_REG_ARM_DEMUX_ID_MASK | KVM_REG_ARM_DEMUX_VAL_MASK )),
303
- "%s: Unexpected bits set in DEMUX reg id: 0x%llx" , config_name ( c ) , id );
303
+ "%s: Unexpected bits set in DEMUX reg id: 0x%llx" , prefix , id );
304
304
printf ("\tKVM_REG_ARM64 | %s | KVM_REG_ARM_DEMUX | KVM_REG_ARM_DEMUX_ID_CCSIDR | %lld,\n" ,
305
305
reg_size , id & KVM_REG_ARM_DEMUX_VAL_MASK );
306
306
break ;
@@ -311,25 +311,25 @@ static void print_reg(struct vcpu_config *c, __u64 id)
311
311
crm = (id & KVM_REG_ARM64_SYSREG_CRM_MASK ) >> KVM_REG_ARM64_SYSREG_CRM_SHIFT ;
312
312
op2 = (id & KVM_REG_ARM64_SYSREG_OP2_MASK ) >> KVM_REG_ARM64_SYSREG_OP2_SHIFT ;
313
313
TEST_ASSERT (id == ARM64_SYS_REG (op0 , op1 , crn , crm , op2 ),
314
- "%s: Unexpected bits set in SYSREG reg id: 0x%llx" , config_name ( c ) , id );
314
+ "%s: Unexpected bits set in SYSREG reg id: 0x%llx" , prefix , id );
315
315
printf ("\tARM64_SYS_REG(%d, %d, %d, %d, %d),\n" , op0 , op1 , crn , crm , op2 );
316
316
break ;
317
317
case KVM_REG_ARM_FW :
318
318
TEST_ASSERT (id == KVM_REG_ARM_FW_REG (id & 0xffff ),
319
- "%s: Unexpected bits set in FW reg id: 0x%llx" , config_name ( c ) , id );
319
+ "%s: Unexpected bits set in FW reg id: 0x%llx" , prefix , id );
320
320
printf ("\tKVM_REG_ARM_FW_REG(%lld),\n" , id & 0xffff );
321
321
break ;
322
322
case KVM_REG_ARM_FW_FEAT_BMAP :
323
323
TEST_ASSERT (id == KVM_REG_ARM_FW_FEAT_BMAP_REG (id & 0xffff ),
324
- "%s: Unexpected bits set in the bitmap feature FW reg id: 0x%llx" , config_name ( c ) , id );
324
+ "%s: Unexpected bits set in the bitmap feature FW reg id: 0x%llx" , prefix , id );
325
325
printf ("\tKVM_REG_ARM_FW_FEAT_BMAP_REG(%lld),\n" , id & 0xffff );
326
326
break ;
327
327
case KVM_REG_ARM64_SVE :
328
- printf ("\t%s,\n" , sve_id_to_str (c , id ));
328
+ printf ("\t%s,\n" , sve_id_to_str (prefix , id ));
329
329
break ;
330
330
default :
331
331
TEST_FAIL ("%s: Unexpected coproc type: 0x%llx in reg id: 0x%llx" ,
332
- config_name ( c ) , (id & KVM_REG_ARM_COPROC_MASK ) >> KVM_REG_ARM_COPROC_SHIFT , id );
332
+ prefix , (id & KVM_REG_ARM_COPROC_MASK ) >> KVM_REG_ARM_COPROC_SHIFT , id );
333
333
}
334
334
}
335
335
@@ -458,7 +458,7 @@ static void run_test(struct vcpu_config *c)
458
458
__u64 id = reg_list -> reg [i ];
459
459
if ((print_list && !filter_reg (id )) ||
460
460
(print_filtered && filter_reg (id )))
461
- print_reg (c , id );
461
+ print_reg (config_name ( c ) , id );
462
462
}
463
463
putchar ('\n' );
464
464
return ;
@@ -486,7 +486,7 @@ static void run_test(struct vcpu_config *c)
486
486
ret = __vcpu_get_reg (vcpu , reg_list -> reg [i ], & addr );
487
487
if (ret ) {
488
488
printf ("%s: Failed to get " , config_name (c ));
489
- print_reg (c , reg .id );
489
+ print_reg (config_name ( c ) , reg .id );
490
490
putchar ('\n' );
491
491
++ failed_get ;
492
492
}
@@ -498,7 +498,7 @@ static void run_test(struct vcpu_config *c)
498
498
ret = __vcpu_ioctl (vcpu , KVM_SET_ONE_REG , & reg );
499
499
if (ret != -1 || errno != EPERM ) {
500
500
printf ("%s: Failed to reject (ret=%d, errno=%d) " , config_name (c ), ret , errno );
501
- print_reg (c , reg .id );
501
+ print_reg (config_name ( c ) , reg .id );
502
502
putchar ('\n' );
503
503
++ failed_reject ;
504
504
}
@@ -510,7 +510,7 @@ static void run_test(struct vcpu_config *c)
510
510
ret = __vcpu_ioctl (vcpu , KVM_SET_ONE_REG , & reg );
511
511
if (ret ) {
512
512
printf ("%s: Failed to set " , config_name (c ));
513
- print_reg (c , reg .id );
513
+ print_reg (config_name ( c ) , reg .id );
514
514
putchar ('\n' );
515
515
++ failed_set ;
516
516
}
@@ -548,15 +548,15 @@ static void run_test(struct vcpu_config *c)
548
548
"Consider adding them to the blessed reg "
549
549
"list with the following lines:\n\n" , config_name (c ), new_regs );
550
550
for_each_new_reg (i )
551
- print_reg (c , reg_list -> reg [i ]);
551
+ print_reg (config_name ( c ) , reg_list -> reg [i ]);
552
552
putchar ('\n' );
553
553
}
554
554
555
555
if (missing_regs ) {
556
556
printf ("\n%s: There are %d missing registers.\n"
557
557
"The following lines are missing registers:\n\n" , config_name (c ), missing_regs );
558
558
for_each_missing_reg (i )
559
- print_reg (c , blessed_reg [i ]);
559
+ print_reg (config_name ( c ) , blessed_reg [i ]);
560
560
putchar ('\n' );
561
561
}
562
562
0 commit comments