@@ -61,8 +61,7 @@ static bool bad_trap(struct kvm_vcpu *vcpu,
61
61
{
62
62
WARN_ONCE (1 , "Unexpected %s\n" , msg );
63
63
print_sys_reg_instr (params );
64
- kvm_inject_undefined (vcpu );
65
- return false;
64
+ return undef_access (vcpu , params , r );
66
65
}
67
66
68
67
static bool read_from_write_only (struct kvm_vcpu * vcpu ,
@@ -353,10 +352,8 @@ static bool access_dcgsw(struct kvm_vcpu *vcpu,
353
352
struct sys_reg_params * p ,
354
353
const struct sys_reg_desc * r )
355
354
{
356
- if (!kvm_has_mte (vcpu -> kvm )) {
357
- kvm_inject_undefined (vcpu );
358
- return false;
359
- }
355
+ if (!kvm_has_mte (vcpu -> kvm ))
356
+ return undef_access (vcpu , p , r );
360
357
361
358
/* Treat MTE S/W ops as we treat the classic ones: with contempt */
362
359
return access_dcsw (vcpu , p , r );
@@ -393,10 +390,8 @@ static bool access_vm_reg(struct kvm_vcpu *vcpu,
393
390
u64 val , mask , shift ;
394
391
395
392
if (reg_to_encoding (r ) == SYS_TCR2_EL1 &&
396
- !kvm_has_feat (vcpu -> kvm , ID_AA64MMFR3_EL1 , TCRX , IMP )) {
397
- kvm_inject_undefined (vcpu );
398
- return false;
399
- }
393
+ !kvm_has_feat (vcpu -> kvm , ID_AA64MMFR3_EL1 , TCRX , IMP ))
394
+ return undef_access (vcpu , p , r );
400
395
401
396
BUG_ON (!p -> is_write );
402
397
@@ -443,10 +438,8 @@ static bool access_gic_sgi(struct kvm_vcpu *vcpu,
443
438
{
444
439
bool g1 ;
445
440
446
- if (!kvm_has_gicv3 (vcpu -> kvm )) {
447
- kvm_inject_undefined (vcpu );
448
- return false;
449
- }
441
+ if (!kvm_has_gicv3 (vcpu -> kvm ))
442
+ return undef_access (vcpu , p , r );
450
443
451
444
if (!p -> is_write )
452
445
return read_from_write_only (vcpu , p , r );
@@ -511,14 +504,6 @@ static bool trap_raz_wi(struct kvm_vcpu *vcpu,
511
504
return read_zero (vcpu , p );
512
505
}
513
506
514
- static bool trap_undef (struct kvm_vcpu * vcpu ,
515
- struct sys_reg_params * p ,
516
- const struct sys_reg_desc * r )
517
- {
518
- kvm_inject_undefined (vcpu );
519
- return false;
520
- }
521
-
522
507
/*
523
508
* ARMv8.1 mandates at least a trivial LORegion implementation, where all the
524
509
* RW registers are RES0 (which we can implement as RAZ/WI). On an ARMv8.0
@@ -531,10 +516,8 @@ static bool trap_loregion(struct kvm_vcpu *vcpu,
531
516
{
532
517
u32 sr = reg_to_encoding (r );
533
518
534
- if (!kvm_has_feat (vcpu -> kvm , ID_AA64MMFR1_EL1 , LO , IMP )) {
535
- kvm_inject_undefined (vcpu );
536
- return false;
537
- }
519
+ if (!kvm_has_feat (vcpu -> kvm , ID_AA64MMFR1_EL1 , LO , IMP ))
520
+ return undef_access (vcpu , p , r );
538
521
539
522
if (p -> is_write && sr == SYS_LORID_EL1 )
540
523
return write_to_read_only (vcpu , p , r );
@@ -1267,10 +1250,8 @@ static bool access_pmuserenr(struct kvm_vcpu *vcpu, struct sys_reg_params *p,
1267
1250
const struct sys_reg_desc * r )
1268
1251
{
1269
1252
if (p -> is_write ) {
1270
- if (!vcpu_mode_priv (vcpu )) {
1271
- kvm_inject_undefined (vcpu );
1272
- return false;
1273
- }
1253
+ if (!vcpu_mode_priv (vcpu ))
1254
+ return undef_access (vcpu , p , r );
1274
1255
1275
1256
__vcpu_sys_reg (vcpu , PMUSERENR_EL0 ) =
1276
1257
p -> regval & ARMV8_PMU_USERENR_MASK ;
@@ -1412,8 +1393,7 @@ static bool access_arch_timer(struct kvm_vcpu *vcpu,
1412
1393
break ;
1413
1394
default :
1414
1395
print_sys_reg_msg (p , "%s" , "Unhandled trapped timer register" );
1415
- kvm_inject_undefined (vcpu );
1416
- return false;
1396
+ return undef_access (vcpu , p , r );
1417
1397
}
1418
1398
1419
1399
if (p -> is_write )
@@ -2309,7 +2289,7 @@ static const struct sys_reg_desc sys_reg_descs[] = {
2309
2289
// DBGDTR[TR]X_EL0 share the same encoding
2310
2290
{ SYS_DESC (SYS_DBGDTRTX_EL0 ), trap_raz_wi },
2311
2291
2312
- { SYS_DESC (SYS_DBGVCR32_EL2 ), trap_undef , reset_val , DBGVCR32_EL2 , 0 },
2292
+ { SYS_DESC (SYS_DBGVCR32_EL2 ), undef_access , reset_val , DBGVCR32_EL2 , 0 },
2313
2293
2314
2294
{ SYS_DESC (SYS_MPIDR_EL1 ), NULL , reset_mpidr , MPIDR_EL1 },
2315
2295
@@ -2780,7 +2760,7 @@ static const struct sys_reg_desc sys_reg_descs[] = {
2780
2760
EL2_REG_VNCR (VTTBR_EL2 , reset_val , 0 ),
2781
2761
EL2_REG_VNCR (VTCR_EL2 , reset_val , 0 ),
2782
2762
2783
- { SYS_DESC (SYS_DACR32_EL2 ), trap_undef , reset_unknown , DACR32_EL2 },
2763
+ { SYS_DESC (SYS_DACR32_EL2 ), undef_access , reset_unknown , DACR32_EL2 },
2784
2764
EL2_REG_VNCR (HDFGRTR_EL2 , reset_val , 0 ),
2785
2765
EL2_REG_VNCR (HDFGWTR_EL2 , reset_val , 0 ),
2786
2766
EL2_REG_VNCR (HAFGRTR_EL2 , reset_val , 0 ),
@@ -2798,11 +2778,11 @@ static const struct sys_reg_desc sys_reg_descs[] = {
2798
2778
{ SYS_DESC (SYS_SPSR_fiq ), .access = trap_raz_wi ,
2799
2779
.visibility = hidden_user_visibility },
2800
2780
2801
- { SYS_DESC (SYS_IFSR32_EL2 ), trap_undef , reset_unknown , IFSR32_EL2 },
2781
+ { SYS_DESC (SYS_IFSR32_EL2 ), undef_access , reset_unknown , IFSR32_EL2 },
2802
2782
EL2_REG (AFSR0_EL2 , access_rw , reset_val , 0 ),
2803
2783
EL2_REG (AFSR1_EL2 , access_rw , reset_val , 0 ),
2804
2784
EL2_REG_REDIR (ESR_EL2 , reset_val , 0 ),
2805
- { SYS_DESC (SYS_FPEXC32_EL2 ), trap_undef , reset_val , FPEXC32_EL2 , 0x700 },
2785
+ { SYS_DESC (SYS_FPEXC32_EL2 ), undef_access , reset_val , FPEXC32_EL2 , 0x700 },
2806
2786
2807
2787
EL2_REG_REDIR (FAR_EL2 , reset_val , 0 ),
2808
2788
EL2_REG (HPFAR_EL2 , access_rw , reset_val , 0 ),
@@ -2812,7 +2792,7 @@ static const struct sys_reg_desc sys_reg_descs[] = {
2812
2792
2813
2793
EL2_REG (VBAR_EL2 , access_rw , reset_val , 0 ),
2814
2794
EL2_REG (RVBAR_EL2 , access_rw , reset_val , 0 ),
2815
- { SYS_DESC (SYS_RMR_EL2 ), trap_undef },
2795
+ { SYS_DESC (SYS_RMR_EL2 ), undef_access },
2816
2796
2817
2797
EL2_REG_VNCR (ICH_HCR_EL2 , reset_val , 0 ),
2818
2798
@@ -2848,10 +2828,8 @@ static bool handle_alle1is(struct kvm_vcpu *vcpu, struct sys_reg_params *p,
2848
2828
{
2849
2829
u32 sys_encoding = sys_insn (p -> Op0 , p -> Op1 , p -> CRn , p -> CRm , p -> Op2 );
2850
2830
2851
- if (!kvm_supported_tlbi_s12_op (vcpu , sys_encoding )) {
2852
- kvm_inject_undefined (vcpu );
2853
- return false;
2854
- }
2831
+ if (!kvm_supported_tlbi_s12_op (vcpu , sys_encoding ))
2832
+ return undef_access (vcpu , p , r );
2855
2833
2856
2834
write_lock (& vcpu -> kvm -> mmu_lock );
2857
2835
@@ -2920,10 +2898,8 @@ static bool handle_vmalls12e1is(struct kvm_vcpu *vcpu, struct sys_reg_params *p,
2920
2898
u32 sys_encoding = sys_insn (p -> Op0 , p -> Op1 , p -> CRn , p -> CRm , p -> Op2 );
2921
2899
u64 limit , vttbr ;
2922
2900
2923
- if (!kvm_supported_tlbi_s12_op (vcpu , sys_encoding )) {
2924
- kvm_inject_undefined (vcpu );
2925
- return false;
2926
- }
2901
+ if (!kvm_supported_tlbi_s12_op (vcpu , sys_encoding ))
2902
+ return undef_access (vcpu , p , r );
2927
2903
2928
2904
vttbr = vcpu_read_sys_reg (vcpu , VTTBR_EL2 );
2929
2905
limit = BIT_ULL (kvm_get_pa_bits (vcpu -> kvm ));
@@ -2948,10 +2924,8 @@ static bool handle_ripas2e1is(struct kvm_vcpu *vcpu, struct sys_reg_params *p,
2948
2924
u64 base , range , tg , num , scale ;
2949
2925
int shift ;
2950
2926
2951
- if (!kvm_supported_tlbi_ipas2_op (vcpu , sys_encoding )) {
2952
- kvm_inject_undefined (vcpu );
2953
- return false;
2954
- }
2927
+ if (!kvm_supported_tlbi_ipas2_op (vcpu , sys_encoding ))
2928
+ return undef_access (vcpu , p , r );
2955
2929
2956
2930
/*
2957
2931
* Because the shadow S2 structure doesn't necessarily reflect that
@@ -3019,10 +2993,8 @@ static bool handle_ipas2e1is(struct kvm_vcpu *vcpu, struct sys_reg_params *p,
3019
2993
u32 sys_encoding = sys_insn (p -> Op0 , p -> Op1 , p -> CRn , p -> CRm , p -> Op2 );
3020
2994
u64 vttbr = vcpu_read_sys_reg (vcpu , VTTBR_EL2 );
3021
2995
3022
- if (!kvm_supported_tlbi_ipas2_op (vcpu , sys_encoding )) {
3023
- kvm_inject_undefined (vcpu );
3024
- return false;
3025
- }
2996
+ if (!kvm_supported_tlbi_ipas2_op (vcpu , sys_encoding ))
2997
+ return undef_access (vcpu , p , r );
3026
2998
3027
2999
kvm_s2_mmu_iterate_by_vmid (vcpu -> kvm , get_vmid (vttbr ),
3028
3000
& (union tlbi_info ) {
@@ -3062,10 +3034,8 @@ static bool handle_tlbi_el1(struct kvm_vcpu *vcpu, struct sys_reg_params *p,
3062
3034
3063
3035
WARN_ON (!vcpu_is_el2 (vcpu ));
3064
3036
3065
- if (!kvm_supported_tlbi_s1e1_op (vcpu , sys_encoding )) {
3066
- kvm_inject_undefined (vcpu );
3067
- return false;
3068
- }
3037
+ if (!kvm_supported_tlbi_s1e1_op (vcpu , sys_encoding ))
3038
+ return undef_access (vcpu , p , r );
3069
3039
3070
3040
kvm_s2_mmu_iterate_by_vmid (vcpu -> kvm , get_vmid (vttbr ),
3071
3041
& (union tlbi_info ) {
@@ -3173,14 +3143,14 @@ static struct sys_reg_desc sys_insn_descs[] = {
3173
3143
SYS_INSN (TLBI_IPAS2LE1IS , handle_ipas2e1is ),
3174
3144
SYS_INSN (TLBI_RIPAS2LE1IS , handle_ripas2e1is ),
3175
3145
3176
- SYS_INSN (TLBI_ALLE2OS , trap_undef ),
3177
- SYS_INSN (TLBI_VAE2OS , trap_undef ),
3146
+ SYS_INSN (TLBI_ALLE2OS , undef_access ),
3147
+ SYS_INSN (TLBI_VAE2OS , undef_access ),
3178
3148
SYS_INSN (TLBI_ALLE1OS , handle_alle1is ),
3179
- SYS_INSN (TLBI_VALE2OS , trap_undef ),
3149
+ SYS_INSN (TLBI_VALE2OS , undef_access ),
3180
3150
SYS_INSN (TLBI_VMALLS12E1OS , handle_vmalls12e1is ),
3181
3151
3182
- SYS_INSN (TLBI_RVAE2IS , trap_undef ),
3183
- SYS_INSN (TLBI_RVALE2IS , trap_undef ),
3152
+ SYS_INSN (TLBI_RVAE2IS , undef_access ),
3153
+ SYS_INSN (TLBI_RVALE2IS , undef_access ),
3184
3154
3185
3155
SYS_INSN (TLBI_ALLE1IS , handle_alle1is ),
3186
3156
SYS_INSN (TLBI_VMALLS12E1IS , handle_vmalls12e1is ),
@@ -3192,10 +3162,10 @@ static struct sys_reg_desc sys_insn_descs[] = {
3192
3162
SYS_INSN (TLBI_IPAS2LE1 , handle_ipas2e1is ),
3193
3163
SYS_INSN (TLBI_RIPAS2LE1 , handle_ripas2e1is ),
3194
3164
SYS_INSN (TLBI_RIPAS2LE1OS , handle_ripas2e1is ),
3195
- SYS_INSN (TLBI_RVAE2OS , trap_undef ),
3196
- SYS_INSN (TLBI_RVALE2OS , trap_undef ),
3197
- SYS_INSN (TLBI_RVAE2 , trap_undef ),
3198
- SYS_INSN (TLBI_RVALE2 , trap_undef ),
3165
+ SYS_INSN (TLBI_RVAE2OS , undef_access ),
3166
+ SYS_INSN (TLBI_RVALE2OS , undef_access ),
3167
+ SYS_INSN (TLBI_RVAE2 , undef_access ),
3168
+ SYS_INSN (TLBI_RVALE2 , undef_access ),
3199
3169
SYS_INSN (TLBI_ALLE1 , handle_alle1is ),
3200
3170
SYS_INSN (TLBI_VMALLS12E1 , handle_vmalls12e1is ),
3201
3171
@@ -3204,19 +3174,19 @@ static struct sys_reg_desc sys_insn_descs[] = {
3204
3174
SYS_INSN (TLBI_IPAS2LE1ISNXS , handle_ipas2e1is ),
3205
3175
SYS_INSN (TLBI_RIPAS2LE1ISNXS , handle_ripas2e1is ),
3206
3176
3207
- SYS_INSN (TLBI_ALLE2OSNXS , trap_undef ),
3208
- SYS_INSN (TLBI_VAE2OSNXS , trap_undef ),
3177
+ SYS_INSN (TLBI_ALLE2OSNXS , undef_access ),
3178
+ SYS_INSN (TLBI_VAE2OSNXS , undef_access ),
3209
3179
SYS_INSN (TLBI_ALLE1OSNXS , handle_alle1is ),
3210
- SYS_INSN (TLBI_VALE2OSNXS , trap_undef ),
3180
+ SYS_INSN (TLBI_VALE2OSNXS , undef_access ),
3211
3181
SYS_INSN (TLBI_VMALLS12E1OSNXS , handle_vmalls12e1is ),
3212
3182
3213
- SYS_INSN (TLBI_RVAE2ISNXS , trap_undef ),
3214
- SYS_INSN (TLBI_RVALE2ISNXS , trap_undef ),
3215
- SYS_INSN (TLBI_ALLE2ISNXS , trap_undef ),
3216
- SYS_INSN (TLBI_VAE2ISNXS , trap_undef ),
3183
+ SYS_INSN (TLBI_RVAE2ISNXS , undef_access ),
3184
+ SYS_INSN (TLBI_RVALE2ISNXS , undef_access ),
3185
+ SYS_INSN (TLBI_ALLE2ISNXS , undef_access ),
3186
+ SYS_INSN (TLBI_VAE2ISNXS , undef_access ),
3217
3187
3218
3188
SYS_INSN (TLBI_ALLE1ISNXS , handle_alle1is ),
3219
- SYS_INSN (TLBI_VALE2ISNXS , trap_undef ),
3189
+ SYS_INSN (TLBI_VALE2ISNXS , undef_access ),
3220
3190
SYS_INSN (TLBI_VMALLS12E1ISNXS , handle_vmalls12e1is ),
3221
3191
SYS_INSN (TLBI_IPAS2E1OSNXS , handle_ipas2e1is ),
3222
3192
SYS_INSN (TLBI_IPAS2E1NXS , handle_ipas2e1is ),
@@ -3226,14 +3196,14 @@ static struct sys_reg_desc sys_insn_descs[] = {
3226
3196
SYS_INSN (TLBI_IPAS2LE1NXS , handle_ipas2e1is ),
3227
3197
SYS_INSN (TLBI_RIPAS2LE1NXS , handle_ripas2e1is ),
3228
3198
SYS_INSN (TLBI_RIPAS2LE1OSNXS , handle_ripas2e1is ),
3229
- SYS_INSN (TLBI_RVAE2OSNXS , trap_undef ),
3230
- SYS_INSN (TLBI_RVALE2OSNXS , trap_undef ),
3231
- SYS_INSN (TLBI_RVAE2NXS , trap_undef ),
3232
- SYS_INSN (TLBI_RVALE2NXS , trap_undef ),
3233
- SYS_INSN (TLBI_ALLE2NXS , trap_undef ),
3234
- SYS_INSN (TLBI_VAE2NXS , trap_undef ),
3199
+ SYS_INSN (TLBI_RVAE2OSNXS , undef_access ),
3200
+ SYS_INSN (TLBI_RVALE2OSNXS , undef_access ),
3201
+ SYS_INSN (TLBI_RVAE2NXS , undef_access ),
3202
+ SYS_INSN (TLBI_RVALE2NXS , undef_access ),
3203
+ SYS_INSN (TLBI_ALLE2NXS , undef_access ),
3204
+ SYS_INSN (TLBI_VAE2NXS , undef_access ),
3235
3205
SYS_INSN (TLBI_ALLE1NXS , handle_alle1is ),
3236
- SYS_INSN (TLBI_VALE2NXS , trap_undef ),
3206
+ SYS_INSN (TLBI_VALE2NXS , undef_access ),
3237
3207
SYS_INSN (TLBI_VMALLS12E1NXS , handle_vmalls12e1is ),
3238
3208
};
3239
3209
0 commit comments