@@ -244,6 +244,25 @@ static bool access_vm_reg(struct kvm_vcpu *vcpu,
244
244
return true;
245
245
}
246
246
247
+ static bool access_actlr (struct kvm_vcpu * vcpu ,
248
+ struct sys_reg_params * p ,
249
+ const struct sys_reg_desc * r )
250
+ {
251
+ if (p -> is_write )
252
+ return ignore_write (vcpu , p );
253
+
254
+ p -> regval = vcpu_read_sys_reg (vcpu , ACTLR_EL1 );
255
+
256
+ if (p -> is_aarch32 ) {
257
+ if (r -> Op2 & 2 )
258
+ p -> regval = upper_32_bits (p -> regval );
259
+ else
260
+ p -> regval = lower_32_bits (p -> regval );
261
+ }
262
+
263
+ return true;
264
+ }
265
+
247
266
/*
248
267
* Trap handler for the GICv3 SGI generation system register.
249
268
* Forward the request to the VGIC emulation.
@@ -617,6 +636,12 @@ static void reset_amair_el1(struct kvm_vcpu *vcpu, const struct sys_reg_desc *r)
617
636
vcpu_write_sys_reg (vcpu , amair , AMAIR_EL1 );
618
637
}
619
638
639
+ static void reset_actlr (struct kvm_vcpu * vcpu , const struct sys_reg_desc * r )
640
+ {
641
+ u64 actlr = read_sysreg (actlr_el1 );
642
+ vcpu_write_sys_reg (vcpu , actlr , ACTLR_EL1 );
643
+ }
644
+
620
645
static void reset_mpidr (struct kvm_vcpu * vcpu , const struct sys_reg_desc * r )
621
646
{
622
647
u64 mpidr ;
@@ -1520,6 +1545,7 @@ static const struct sys_reg_desc sys_reg_descs[] = {
1520
1545
ID_UNALLOCATED (7 ,7 ),
1521
1546
1522
1547
{ SYS_DESC (SYS_SCTLR_EL1 ), access_vm_reg , reset_val , SCTLR_EL1 , 0x00C50078 },
1548
+ { SYS_DESC (SYS_ACTLR_EL1 ), access_actlr , reset_actlr , ACTLR_EL1 },
1523
1549
{ SYS_DESC (SYS_CPACR_EL1 ), NULL , reset_val , CPACR_EL1 , 0 },
1524
1550
{ SYS_DESC (SYS_ZCR_EL1 ), NULL , reset_val , ZCR_EL1 , 0 , .visibility = sve_visibility },
1525
1551
{ SYS_DESC (SYS_TTBR0_EL1 ), access_vm_reg , reset_unknown , TTBR0_EL1 },
@@ -1959,6 +1985,8 @@ static const struct sys_reg_desc cp14_64_regs[] = {
1959
1985
static const struct sys_reg_desc cp15_regs [] = {
1960
1986
{ Op1 ( 0 ), CRn ( 0 ), CRm ( 0 ), Op2 ( 1 ), access_ctr },
1961
1987
{ Op1 ( 0 ), CRn ( 1 ), CRm ( 0 ), Op2 ( 0 ), access_vm_reg , NULL , c1_SCTLR },
1988
+ { Op1 ( 0 ), CRn ( 1 ), CRm ( 0 ), Op2 ( 1 ), access_actlr },
1989
+ { Op1 ( 0 ), CRn ( 1 ), CRm ( 0 ), Op2 ( 3 ), access_actlr },
1962
1990
{ Op1 ( 0 ), CRn ( 2 ), CRm ( 0 ), Op2 ( 0 ), access_vm_reg , NULL , c2_TTBR0 },
1963
1991
{ Op1 ( 0 ), CRn ( 2 ), CRm ( 0 ), Op2 ( 1 ), access_vm_reg , NULL , c2_TTBR1 },
1964
1992
{ Op1 ( 0 ), CRn ( 2 ), CRm ( 0 ), Op2 ( 2 ), access_vm_reg , NULL , c2_TTBCR },
@@ -2111,36 +2139,6 @@ static int check_sysreg_table(const struct sys_reg_desc *table, unsigned int n,
2111
2139
return 0 ;
2112
2140
}
2113
2141
2114
- /* Target specific emulation tables */
2115
- static struct kvm_sys_reg_target_table * target_tables [KVM_ARM_NUM_TARGETS ];
2116
-
2117
- void kvm_register_target_sys_reg_table (unsigned int target ,
2118
- struct kvm_sys_reg_target_table * table )
2119
- {
2120
- if (check_sysreg_table (table -> table64 .table , table -> table64 .num , false) ||
2121
- check_sysreg_table (table -> table32 .table , table -> table32 .num , true))
2122
- return ;
2123
-
2124
- target_tables [target ] = table ;
2125
- }
2126
-
2127
- /* Get specific register table for this target. */
2128
- static const struct sys_reg_desc * get_target_table (unsigned target ,
2129
- bool mode_is_64 ,
2130
- size_t * num )
2131
- {
2132
- struct kvm_sys_reg_target_table * table ;
2133
-
2134
- table = target_tables [target ];
2135
- if (mode_is_64 ) {
2136
- * num = table -> table64 .num ;
2137
- return table -> table64 .table ;
2138
- } else {
2139
- * num = table -> table32 .num ;
2140
- return table -> table32 .table ;
2141
- }
2142
- }
2143
-
2144
2142
static int match_sys_reg (const void * key , const void * elt )
2145
2143
{
2146
2144
const unsigned long pval = (unsigned long )key ;
@@ -2251,9 +2249,7 @@ static void unhandled_cp_access(struct kvm_vcpu *vcpu,
2251
2249
*/
2252
2250
static int kvm_handle_cp_64 (struct kvm_vcpu * vcpu ,
2253
2251
const struct sys_reg_desc * global ,
2254
- size_t nr_global ,
2255
- const struct sys_reg_desc * target_specific ,
2256
- size_t nr_specific )
2252
+ size_t nr_global )
2257
2253
{
2258
2254
struct sys_reg_params params ;
2259
2255
u32 hsr = kvm_vcpu_get_hsr (vcpu );
@@ -2280,14 +2276,11 @@ static int kvm_handle_cp_64(struct kvm_vcpu *vcpu,
2280
2276
}
2281
2277
2282
2278
/*
2283
- * Try to emulate the coprocessor access using the target
2284
- * specific table first, and using the global table afterwards.
2285
- * If either of the tables contains a handler, handle the
2279
+ * If the table contains a handler, handle the
2286
2280
* potential register operation in the case of a read and return
2287
2281
* with success.
2288
2282
*/
2289
- if (!emulate_cp (vcpu , & params , target_specific , nr_specific ) ||
2290
- !emulate_cp (vcpu , & params , global , nr_global )) {
2283
+ if (!emulate_cp (vcpu , & params , global , nr_global )) {
2291
2284
/* Split up the value between registers for the read side */
2292
2285
if (!params .is_write ) {
2293
2286
vcpu_set_reg (vcpu , Rt , lower_32_bits (params .regval ));
@@ -2308,9 +2301,7 @@ static int kvm_handle_cp_64(struct kvm_vcpu *vcpu,
2308
2301
*/
2309
2302
static int kvm_handle_cp_32 (struct kvm_vcpu * vcpu ,
2310
2303
const struct sys_reg_desc * global ,
2311
- size_t nr_global ,
2312
- const struct sys_reg_desc * target_specific ,
2313
- size_t nr_specific )
2304
+ size_t nr_global )
2314
2305
{
2315
2306
struct sys_reg_params params ;
2316
2307
u32 hsr = kvm_vcpu_get_hsr (vcpu );
@@ -2326,8 +2317,7 @@ static int kvm_handle_cp_32(struct kvm_vcpu *vcpu,
2326
2317
params .Op1 = (hsr >> 14 ) & 0x7 ;
2327
2318
params .Op2 = (hsr >> 17 ) & 0x7 ;
2328
2319
2329
- if (!emulate_cp (vcpu , & params , target_specific , nr_specific ) ||
2330
- !emulate_cp (vcpu , & params , global , nr_global )) {
2320
+ if (!emulate_cp (vcpu , & params , global , nr_global )) {
2331
2321
if (!params .is_write )
2332
2322
vcpu_set_reg (vcpu , Rt , params .regval );
2333
2323
return 1 ;
@@ -2339,38 +2329,22 @@ static int kvm_handle_cp_32(struct kvm_vcpu *vcpu,
2339
2329
2340
2330
int kvm_handle_cp15_64 (struct kvm_vcpu * vcpu , struct kvm_run * run )
2341
2331
{
2342
- const struct sys_reg_desc * target_specific ;
2343
- size_t num ;
2344
-
2345
- target_specific = get_target_table (vcpu -> arch .target , false, & num );
2346
- return kvm_handle_cp_64 (vcpu ,
2347
- cp15_64_regs , ARRAY_SIZE (cp15_64_regs ),
2348
- target_specific , num );
2332
+ return kvm_handle_cp_64 (vcpu , cp15_64_regs , ARRAY_SIZE (cp15_64_regs ));
2349
2333
}
2350
2334
2351
2335
int kvm_handle_cp15_32 (struct kvm_vcpu * vcpu , struct kvm_run * run )
2352
2336
{
2353
- const struct sys_reg_desc * target_specific ;
2354
- size_t num ;
2355
-
2356
- target_specific = get_target_table (vcpu -> arch .target , false, & num );
2357
- return kvm_handle_cp_32 (vcpu ,
2358
- cp15_regs , ARRAY_SIZE (cp15_regs ),
2359
- target_specific , num );
2337
+ return kvm_handle_cp_32 (vcpu , cp15_regs , ARRAY_SIZE (cp15_regs ));
2360
2338
}
2361
2339
2362
2340
int kvm_handle_cp14_64 (struct kvm_vcpu * vcpu , struct kvm_run * run )
2363
2341
{
2364
- return kvm_handle_cp_64 (vcpu ,
2365
- cp14_64_regs , ARRAY_SIZE (cp14_64_regs ),
2366
- NULL , 0 );
2342
+ return kvm_handle_cp_64 (vcpu , cp14_64_regs , ARRAY_SIZE (cp14_64_regs ));
2367
2343
}
2368
2344
2369
2345
int kvm_handle_cp14_32 (struct kvm_vcpu * vcpu , struct kvm_run * run )
2370
2346
{
2371
- return kvm_handle_cp_32 (vcpu ,
2372
- cp14_regs , ARRAY_SIZE (cp14_regs ),
2373
- NULL , 0 );
2347
+ return kvm_handle_cp_32 (vcpu , cp14_regs , ARRAY_SIZE (cp14_regs ));
2374
2348
}
2375
2349
2376
2350
static bool is_imp_def_sys_reg (struct sys_reg_params * params )
@@ -2382,15 +2356,9 @@ static bool is_imp_def_sys_reg(struct sys_reg_params *params)
2382
2356
static int emulate_sys_reg (struct kvm_vcpu * vcpu ,
2383
2357
struct sys_reg_params * params )
2384
2358
{
2385
- size_t num ;
2386
- const struct sys_reg_desc * table , * r ;
2387
-
2388
- table = get_target_table (vcpu -> arch .target , true, & num );
2359
+ const struct sys_reg_desc * r ;
2389
2360
2390
- /* Search target-specific then generic table. */
2391
- r = find_reg (params , table , num );
2392
- if (!r )
2393
- r = find_reg (params , sys_reg_descs , ARRAY_SIZE (sys_reg_descs ));
2361
+ r = find_reg (params , sys_reg_descs , ARRAY_SIZE (sys_reg_descs ));
2394
2362
2395
2363
if (likely (r )) {
2396
2364
perform_access (vcpu , params , r );
@@ -2405,14 +2373,20 @@ static int emulate_sys_reg(struct kvm_vcpu *vcpu,
2405
2373
return 1 ;
2406
2374
}
2407
2375
2408
- static void reset_sys_reg_descs (struct kvm_vcpu * vcpu ,
2409
- const struct sys_reg_desc * table , size_t num )
2376
+ /**
2377
+ * kvm_reset_sys_regs - sets system registers to reset value
2378
+ * @vcpu: The VCPU pointer
2379
+ *
2380
+ * This function finds the right table above and sets the registers on the
2381
+ * virtual CPU struct to their architecturally defined reset values.
2382
+ */
2383
+ void kvm_reset_sys_regs (struct kvm_vcpu * vcpu )
2410
2384
{
2411
2385
unsigned long i ;
2412
2386
2413
- for (i = 0 ; i < num ; i ++ )
2414
- if (table [i ].reset )
2415
- table [i ].reset (vcpu , & table [i ]);
2387
+ for (i = 0 ; i < ARRAY_SIZE ( sys_reg_descs ) ; i ++ )
2388
+ if (sys_reg_descs [i ].reset )
2389
+ sys_reg_descs [i ].reset (vcpu , & sys_reg_descs [i ]);
2416
2390
}
2417
2391
2418
2392
/**
@@ -2494,8 +2468,7 @@ const struct sys_reg_desc *find_reg_by_id(u64 id,
2494
2468
static const struct sys_reg_desc * index_to_sys_reg_desc (struct kvm_vcpu * vcpu ,
2495
2469
u64 id )
2496
2470
{
2497
- size_t num ;
2498
- const struct sys_reg_desc * table , * r ;
2471
+ const struct sys_reg_desc * r ;
2499
2472
struct sys_reg_params params ;
2500
2473
2501
2474
/* We only do sys_reg for now. */
@@ -2505,10 +2478,7 @@ static const struct sys_reg_desc *index_to_sys_reg_desc(struct kvm_vcpu *vcpu,
2505
2478
if (!index_to_params (id , & params ))
2506
2479
return NULL ;
2507
2480
2508
- table = get_target_table (vcpu -> arch .target , true, & num );
2509
- r = find_reg (& params , table , num );
2510
- if (!r )
2511
- r = find_reg (& params , sys_reg_descs , ARRAY_SIZE (sys_reg_descs ));
2481
+ r = find_reg (& params , sys_reg_descs , ARRAY_SIZE (sys_reg_descs ));
2512
2482
2513
2483
/* Not saved in the sys_reg array and not otherwise accessible? */
2514
2484
if (r && !(r -> reg || r -> get_user ))
@@ -2808,35 +2778,17 @@ static int walk_one_sys_reg(const struct kvm_vcpu *vcpu,
2808
2778
/* Assumed ordered tables, see kvm_sys_reg_table_init. */
2809
2779
static int walk_sys_regs (struct kvm_vcpu * vcpu , u64 __user * uind )
2810
2780
{
2811
- const struct sys_reg_desc * i1 , * i2 , * end1 , * end2 ;
2781
+ const struct sys_reg_desc * i2 , * end2 ;
2812
2782
unsigned int total = 0 ;
2813
- size_t num ;
2814
2783
int err ;
2815
2784
2816
- /* We check for duplicates here, to allow arch-specific overrides. */
2817
- i1 = get_target_table (vcpu -> arch .target , true, & num );
2818
- end1 = i1 + num ;
2819
2785
i2 = sys_reg_descs ;
2820
2786
end2 = sys_reg_descs + ARRAY_SIZE (sys_reg_descs );
2821
2787
2822
- BUG_ON (i1 == end1 || i2 == end2 );
2823
-
2824
- /* Walk carefully, as both tables may refer to the same register. */
2825
- while (i1 || i2 ) {
2826
- int cmp = cmp_sys_reg (i1 , i2 );
2827
- /* target-specific overrides generic entry. */
2828
- if (cmp <= 0 )
2829
- err = walk_one_sys_reg (vcpu , i1 , & uind , & total );
2830
- else
2831
- err = walk_one_sys_reg (vcpu , i2 , & uind , & total );
2832
-
2788
+ while (i2 != end2 ) {
2789
+ err = walk_one_sys_reg (vcpu , i2 ++ , & uind , & total );
2833
2790
if (err )
2834
2791
return err ;
2835
-
2836
- if (cmp <= 0 && ++ i1 == end1 )
2837
- i1 = NULL ;
2838
- if (cmp >= 0 && ++ i2 == end2 )
2839
- i2 = NULL ;
2840
2792
}
2841
2793
return total ;
2842
2794
}
@@ -2903,22 +2855,3 @@ void kvm_sys_reg_table_init(void)
2903
2855
/* Clear all higher bits. */
2904
2856
cache_levels &= (1 << (i * 3 ))- 1 ;
2905
2857
}
2906
-
2907
- /**
2908
- * kvm_reset_sys_regs - sets system registers to reset value
2909
- * @vcpu: The VCPU pointer
2910
- *
2911
- * This function finds the right table above and sets the registers on the
2912
- * virtual CPU struct to their architecturally defined reset values.
2913
- */
2914
- void kvm_reset_sys_regs (struct kvm_vcpu * vcpu )
2915
- {
2916
- size_t num ;
2917
- const struct sys_reg_desc * table ;
2918
-
2919
- /* Generic chip reset first (so target could override). */
2920
- reset_sys_reg_descs (vcpu , sys_reg_descs , ARRAY_SIZE (sys_reg_descs ));
2921
-
2922
- table = get_target_table (vcpu -> arch .target , true, & num );
2923
- reset_sys_reg_descs (vcpu , table , num );
2924
- }
0 commit comments