@@ -41,16 +41,12 @@ enum legacy_insn_status {
41
41
INSN_OBSOLETE ,
42
42
};
43
43
44
- struct insn_emulation_ops {
45
- const char * name ;
46
- enum legacy_insn_status status ;
47
- struct undef_hook * hooks ;
48
- int (* set_hw_mode )(bool enable );
49
- };
50
-
51
44
struct insn_emulation {
52
- struct list_head node ;
53
- struct insn_emulation_ops * ops ;
45
+ const char * name ;
46
+ struct list_head node ;
47
+ enum legacy_insn_status status ;
48
+ struct undef_hook * hooks ;
49
+ int (* set_hw_mode )(bool enable );
54
50
int current_mode ;
55
51
int min ;
56
52
int max ;
@@ -61,48 +57,48 @@ static int nr_insn_emulated __initdata;
61
57
static DEFINE_RAW_SPINLOCK (insn_emulation_lock );
62
58
static DEFINE_MUTEX (insn_emulation_mutex );
63
59
64
- static void register_emulation_hooks (struct insn_emulation_ops * ops )
60
+ static void register_emulation_hooks (struct insn_emulation * insn )
65
61
{
66
62
struct undef_hook * hook ;
67
63
68
- BUG_ON (!ops -> hooks );
64
+ BUG_ON (!insn -> hooks );
69
65
70
- for (hook = ops -> hooks ; hook -> instr_mask ; hook ++ )
66
+ for (hook = insn -> hooks ; hook -> instr_mask ; hook ++ )
71
67
register_undef_hook (hook );
72
68
73
- pr_notice ("Registered %s emulation handler\n" , ops -> name );
69
+ pr_notice ("Registered %s emulation handler\n" , insn -> name );
74
70
}
75
71
76
- static void remove_emulation_hooks (struct insn_emulation_ops * ops )
72
+ static void remove_emulation_hooks (struct insn_emulation * insn )
77
73
{
78
74
struct undef_hook * hook ;
79
75
80
- BUG_ON (!ops -> hooks );
76
+ BUG_ON (!insn -> hooks );
81
77
82
- for (hook = ops -> hooks ; hook -> instr_mask ; hook ++ )
78
+ for (hook = insn -> hooks ; hook -> instr_mask ; hook ++ )
83
79
unregister_undef_hook (hook );
84
80
85
- pr_notice ("Removed %s emulation handler\n" , ops -> name );
81
+ pr_notice ("Removed %s emulation handler\n" , insn -> name );
86
82
}
87
83
88
84
static void enable_insn_hw_mode (void * data )
89
85
{
90
86
struct insn_emulation * insn = (struct insn_emulation * )data ;
91
- if (insn -> ops -> set_hw_mode )
92
- insn -> ops -> set_hw_mode (true);
87
+ if (insn -> set_hw_mode )
88
+ insn -> set_hw_mode (true);
93
89
}
94
90
95
91
static void disable_insn_hw_mode (void * data )
96
92
{
97
93
struct insn_emulation * insn = (struct insn_emulation * )data ;
98
- if (insn -> ops -> set_hw_mode )
99
- insn -> ops -> set_hw_mode (false);
94
+ if (insn -> set_hw_mode )
95
+ insn -> set_hw_mode (false);
100
96
}
101
97
102
98
/* Run set_hw_mode(mode) on all active CPUs */
103
99
static int run_all_cpu_set_hw_mode (struct insn_emulation * insn , bool enable )
104
100
{
105
- if (!insn -> ops -> set_hw_mode )
101
+ if (!insn -> set_hw_mode )
106
102
return - EINVAL ;
107
103
if (enable )
108
104
on_each_cpu (enable_insn_hw_mode , (void * )insn , true);
@@ -126,9 +122,9 @@ static int run_all_insn_set_hw_mode(unsigned int cpu)
126
122
raw_spin_lock_irqsave (& insn_emulation_lock , flags );
127
123
list_for_each_entry (insn , & insn_emulation , node ) {
128
124
bool enable = (insn -> current_mode == INSN_HW );
129
- if (insn -> ops -> set_hw_mode && insn -> ops -> set_hw_mode (enable )) {
125
+ if (insn -> set_hw_mode && insn -> set_hw_mode (enable )) {
130
126
pr_warn ("CPU[%u] cannot support the emulation of %s" ,
131
- cpu , insn -> ops -> name );
127
+ cpu , insn -> name );
132
128
rc = - EINVAL ;
133
129
}
134
130
}
@@ -145,43 +141,37 @@ static int update_insn_emulation_mode(struct insn_emulation *insn,
145
141
case INSN_UNDEF : /* Nothing to be done */
146
142
break ;
147
143
case INSN_EMULATE :
148
- remove_emulation_hooks (insn -> ops );
144
+ remove_emulation_hooks (insn );
149
145
break ;
150
146
case INSN_HW :
151
147
if (!run_all_cpu_set_hw_mode (insn , false))
152
- pr_notice ("Disabled %s support\n" , insn -> ops -> name );
148
+ pr_notice ("Disabled %s support\n" , insn -> name );
153
149
break ;
154
150
}
155
151
156
152
switch (insn -> current_mode ) {
157
153
case INSN_UNDEF :
158
154
break ;
159
155
case INSN_EMULATE :
160
- register_emulation_hooks (insn -> ops );
156
+ register_emulation_hooks (insn );
161
157
break ;
162
158
case INSN_HW :
163
159
ret = run_all_cpu_set_hw_mode (insn , true);
164
160
if (!ret )
165
- pr_notice ("Enabled %s support\n" , insn -> ops -> name );
161
+ pr_notice ("Enabled %s support\n" , insn -> name );
166
162
break ;
167
163
}
168
164
169
165
return ret ;
170
166
}
171
167
172
- static void __init register_insn_emulation (struct insn_emulation_ops * ops )
168
+ static void __init register_insn_emulation (struct insn_emulation * insn )
173
169
{
174
170
unsigned long flags ;
175
- struct insn_emulation * insn ;
176
-
177
- insn = kzalloc (sizeof (* insn ), GFP_KERNEL );
178
- if (!insn )
179
- return ;
180
171
181
- insn -> ops = ops ;
182
172
insn -> min = INSN_UNDEF ;
183
173
184
- switch (ops -> status ) {
174
+ switch (insn -> status ) {
185
175
case INSN_DEPRECATED :
186
176
insn -> current_mode = INSN_EMULATE ;
187
177
/* Disable the HW mode if it was turned on at early boot time */
@@ -247,7 +237,7 @@ static void __init register_insn_emulation_sysctl(void)
247
237
sysctl -> mode = 0644 ;
248
238
sysctl -> maxlen = sizeof (int );
249
239
250
- sysctl -> procname = insn -> ops -> name ;
240
+ sysctl -> procname = insn -> name ;
251
241
sysctl -> data = & insn -> current_mode ;
252
242
sysctl -> extra1 = & insn -> min ;
253
243
sysctl -> extra2 = & insn -> max ;
@@ -445,7 +435,7 @@ static struct undef_hook swp_hooks[] = {
445
435
{ }
446
436
};
447
437
448
- static struct insn_emulation_ops swp_ops = {
438
+ static struct insn_emulation insn_swp = {
449
439
.name = "swp" ,
450
440
.status = INSN_OBSOLETE ,
451
441
.hooks = swp_hooks ,
@@ -532,7 +522,7 @@ static struct undef_hook cp15_barrier_hooks[] = {
532
522
{ }
533
523
};
534
524
535
- static struct insn_emulation_ops cp15_barrier_ops = {
525
+ static struct insn_emulation insn_cp15_barrier = {
536
526
.name = "cp15_barrier" ,
537
527
.status = INSN_DEPRECATED ,
538
528
.hooks = cp15_barrier_hooks ,
@@ -605,7 +595,7 @@ static struct undef_hook setend_hooks[] = {
605
595
{}
606
596
};
607
597
608
- static struct insn_emulation_ops setend_ops = {
598
+ static struct insn_emulation insn_setend = {
609
599
.name = "setend" ,
610
600
.status = INSN_DEPRECATED ,
611
601
.hooks = setend_hooks ,
@@ -619,14 +609,14 @@ static struct insn_emulation_ops setend_ops = {
619
609
static int __init armv8_deprecated_init (void )
620
610
{
621
611
if (IS_ENABLED (CONFIG_SWP_EMULATION ))
622
- register_insn_emulation (& swp_ops );
612
+ register_insn_emulation (& insn_swp );
623
613
624
614
if (IS_ENABLED (CONFIG_CP15_BARRIER_EMULATION ))
625
- register_insn_emulation (& cp15_barrier_ops );
615
+ register_insn_emulation (& insn_cp15_barrier );
626
616
627
617
if (IS_ENABLED (CONFIG_SETEND_EMULATION )) {
628
618
if (system_supports_mixed_endian_el0 ())
629
- register_insn_emulation (& setend_ops );
619
+ register_insn_emulation (& insn_setend );
630
620
else
631
621
pr_info ("setend instruction emulation is not supported on this system\n" );
632
622
}
0 commit comments