xref: /aosp_15_r20/trusty/kernel/lib/sm/trusty_sched_share.c (revision 344aa361028b423587d4ef3fa52a23d194628137)
1*344aa361SAndroid Build Coastguard Worker /*
2*344aa361SAndroid Build Coastguard Worker  * Copyright (c) 2022, Google, Inc. All rights reserved
3*344aa361SAndroid Build Coastguard Worker  *
4*344aa361SAndroid Build Coastguard Worker  * Permission is hereby granted, free of charge, to any person obtaining
5*344aa361SAndroid Build Coastguard Worker  * a copy of this software and associated documentation files
6*344aa361SAndroid Build Coastguard Worker  * (the "Software"), to deal in the Software without restriction,
7*344aa361SAndroid Build Coastguard Worker  * including without limitation the rights to use, copy, modify, merge,
8*344aa361SAndroid Build Coastguard Worker  * publish, distribute, sublicense, and/or sell copies of the Software,
9*344aa361SAndroid Build Coastguard Worker  * and to permit persons to whom the Software is furnished to do so,
10*344aa361SAndroid Build Coastguard Worker  * subject to the following conditions:
11*344aa361SAndroid Build Coastguard Worker  *
12*344aa361SAndroid Build Coastguard Worker  * The above copyright notice and this permission notice shall be
13*344aa361SAndroid Build Coastguard Worker  * included in all copies or substantial portions of the Software.
14*344aa361SAndroid Build Coastguard Worker  *
15*344aa361SAndroid Build Coastguard Worker  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16*344aa361SAndroid Build Coastguard Worker  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17*344aa361SAndroid Build Coastguard Worker  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18*344aa361SAndroid Build Coastguard Worker  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19*344aa361SAndroid Build Coastguard Worker  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20*344aa361SAndroid Build Coastguard Worker  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21*344aa361SAndroid Build Coastguard Worker  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22*344aa361SAndroid Build Coastguard Worker  */
23*344aa361SAndroid Build Coastguard Worker 
24*344aa361SAndroid Build Coastguard Worker /*
25*344aa361SAndroid Build Coastguard Worker  * This trusty library module contains the SMC API for communication with
26*344aa361SAndroid Build Coastguard Worker  * the Linux trusty-driver for shared memory registration/unregistration.
27*344aa361SAndroid Build Coastguard Worker  * After a register request (SMC-Call) is received from the trusty-driver,
28*344aa361SAndroid Build Coastguard Worker  * access to the shared-memory block, created by the trusty-driver, is
29*344aa361SAndroid Build Coastguard Worker  * established. Likewise, when an unregister request is received, the
30*344aa361SAndroid Build Coastguard Worker  * associated resources are release and the access is removed.
31*344aa361SAndroid Build Coastguard Worker  *
32*344aa361SAndroid Build Coastguard Worker  * This library module also provides the APIs to the trusty kernel for
33*344aa361SAndroid Build Coastguard Worker  * exchanging various information in both directions. One such information
34*344aa361SAndroid Build Coastguard Worker  * exchanged is the per-cpu trusty shadow-priorities.
35*344aa361SAndroid Build Coastguard Worker  */
36*344aa361SAndroid Build Coastguard Worker 
37*344aa361SAndroid Build Coastguard Worker #include <err.h>
38*344aa361SAndroid Build Coastguard Worker #include <kernel/spinlock.h>
39*344aa361SAndroid Build Coastguard Worker #include <kernel/thread.h>
40*344aa361SAndroid Build Coastguard Worker #include <kernel/vm.h>
41*344aa361SAndroid Build Coastguard Worker #include <lib/extmem/extmem.h>
42*344aa361SAndroid Build Coastguard Worker #include <lib/sm.h>
43*344aa361SAndroid Build Coastguard Worker #include <lib/sm/sm_err.h>
44*344aa361SAndroid Build Coastguard Worker #include <lib/sm/trusty_sched_share.h>
45*344aa361SAndroid Build Coastguard Worker #include <platform.h>
46*344aa361SAndroid Build Coastguard Worker #include <string.h>
47*344aa361SAndroid Build Coastguard Worker #include <trace.h>
48*344aa361SAndroid Build Coastguard Worker 
49*344aa361SAndroid Build Coastguard Worker #define LOCAL_TRACE (0)
50*344aa361SAndroid Build Coastguard Worker 
51*344aa361SAndroid Build Coastguard Worker /* Trusty Shared Resources Info */
52*344aa361SAndroid Build Coastguard Worker struct share_info {
53*344aa361SAndroid Build Coastguard Worker     ext_mem_client_id_t client_id;
54*344aa361SAndroid Build Coastguard Worker     ext_mem_obj_id_t buf_id;
55*344aa361SAndroid Build Coastguard Worker     uint32_t cpu_count;
56*344aa361SAndroid Build Coastguard Worker     uint32_t header_size;
57*344aa361SAndroid Build Coastguard Worker     uint32_t percpu_data_size;
58*344aa361SAndroid Build Coastguard Worker };
59*344aa361SAndroid Build Coastguard Worker 
60*344aa361SAndroid Build Coastguard Worker static struct share_info shareinfo = {0};
61*344aa361SAndroid Build Coastguard Worker 
62*344aa361SAndroid Build Coastguard Worker struct trusty_sched_shared_mem* sched_shared_mem = NULL;
63*344aa361SAndroid Build Coastguard Worker static spin_lock_t sched_shared_datalock = SPIN_LOCK_INITIAL_VALUE;
64*344aa361SAndroid Build Coastguard Worker 
args_get_id(struct smc32_args * args)65*344aa361SAndroid Build Coastguard Worker static ext_mem_obj_id_t args_get_id(struct smc32_args* args) {
66*344aa361SAndroid Build Coastguard Worker     return (((uint64_t)args->params[1] << 32) | args->params[0]);
67*344aa361SAndroid Build Coastguard Worker }
68*344aa361SAndroid Build Coastguard Worker 
args_get_sz(struct smc32_args * args)69*344aa361SAndroid Build Coastguard Worker static size_t args_get_sz(struct smc32_args* args) {
70*344aa361SAndroid Build Coastguard Worker     return (size_t)args->params[2];
71*344aa361SAndroid Build Coastguard Worker }
72*344aa361SAndroid Build Coastguard Worker 
trusty_share_register(ext_mem_client_id_t client_id,ext_mem_obj_id_t buf_id,uint32_t buf_size)73*344aa361SAndroid Build Coastguard Worker static long trusty_share_register(ext_mem_client_id_t client_id,
74*344aa361SAndroid Build Coastguard Worker                                   ext_mem_obj_id_t buf_id,
75*344aa361SAndroid Build Coastguard Worker                                   uint32_t buf_size) {
76*344aa361SAndroid Build Coastguard Worker     struct trusty_sched_shared_mem* share_ptr;
77*344aa361SAndroid Build Coastguard Worker     spin_lock_saved_state_t state;
78*344aa361SAndroid Build Coastguard Worker     uint32_t needed_buf_sz;
79*344aa361SAndroid Build Coastguard Worker     uint32_t nr_cpu;
80*344aa361SAndroid Build Coastguard Worker     uint32_t hdr_sz;
81*344aa361SAndroid Build Coastguard Worker     uint32_t percpu_data_sz;
82*344aa361SAndroid Build Coastguard Worker     uint32_t struct_sz;
83*344aa361SAndroid Build Coastguard Worker     void* va;
84*344aa361SAndroid Build Coastguard Worker     status_t status;
85*344aa361SAndroid Build Coastguard Worker     int retval = SM_ERR_INVALID_PARAMETERS;
86*344aa361SAndroid Build Coastguard Worker 
87*344aa361SAndroid Build Coastguard Worker     LTRACEF_LEVEL(5, "client_id=%llx,  buf_id= %llx,  buf_size=%d\n",
88*344aa361SAndroid Build Coastguard Worker                   (unsigned long long)client_id, (unsigned long long)buf_id,
89*344aa361SAndroid Build Coastguard Worker                   buf_size);
90*344aa361SAndroid Build Coastguard Worker 
91*344aa361SAndroid Build Coastguard Worker     status = ext_mem_map_obj_id(vmm_get_kernel_aspace(),
92*344aa361SAndroid Build Coastguard Worker                                 "trusty_sched_shared_mem", client_id, buf_id, 0,
93*344aa361SAndroid Build Coastguard Worker                                 0, buf_size, &va, PAGE_SIZE_SHIFT, 0,
94*344aa361SAndroid Build Coastguard Worker                                 ARCH_MMU_FLAG_PERM_NO_EXECUTE);
95*344aa361SAndroid Build Coastguard Worker     if (status) {
96*344aa361SAndroid Build Coastguard Worker         TRACEF("Error: ext_mem_map_obj_id() failed.\n");
97*344aa361SAndroid Build Coastguard Worker         return SM_ERR_INTERNAL_FAILURE;
98*344aa361SAndroid Build Coastguard Worker     }
99*344aa361SAndroid Build Coastguard Worker     share_ptr = va;
100*344aa361SAndroid Build Coastguard Worker 
101*344aa361SAndroid Build Coastguard Worker     nr_cpu = READ_ONCE(share_ptr->cpu_count);
102*344aa361SAndroid Build Coastguard Worker     hdr_sz = READ_ONCE(share_ptr->hdr_size);
103*344aa361SAndroid Build Coastguard Worker     percpu_data_sz = READ_ONCE(share_ptr->percpu_data_size);
104*344aa361SAndroid Build Coastguard Worker 
105*344aa361SAndroid Build Coastguard Worker     struct_sz = sizeof(struct trusty_sched_shared_mem);
106*344aa361SAndroid Build Coastguard Worker     if (hdr_sz < struct_sz) {
107*344aa361SAndroid Build Coastguard Worker         TRACEF("Error: mismatched header-size=%d, struct-size=%d\n", hdr_sz,
108*344aa361SAndroid Build Coastguard Worker                struct_sz);
109*344aa361SAndroid Build Coastguard Worker         goto err_invalid_params;
110*344aa361SAndroid Build Coastguard Worker     }
111*344aa361SAndroid Build Coastguard Worker     LTRACEF_LEVEL(45, "header-size=%d, struct-size=%d\n", hdr_sz, struct_sz);
112*344aa361SAndroid Build Coastguard Worker 
113*344aa361SAndroid Build Coastguard Worker     struct_sz = sizeof(struct trusty_percpu_shared_data);
114*344aa361SAndroid Build Coastguard Worker     if (percpu_data_sz < struct_sz) {
115*344aa361SAndroid Build Coastguard Worker         TRACEF("Error: mismatched percpu-data-size=%d, struct-size=%d\n",
116*344aa361SAndroid Build Coastguard Worker                percpu_data_sz, struct_sz);
117*344aa361SAndroid Build Coastguard Worker         goto err_invalid_params;
118*344aa361SAndroid Build Coastguard Worker     }
119*344aa361SAndroid Build Coastguard Worker     LTRACEF_LEVEL(45, "percpu-data-size=%d, struct-size=%d\n", percpu_data_sz,
120*344aa361SAndroid Build Coastguard Worker                   struct_sz);
121*344aa361SAndroid Build Coastguard Worker 
122*344aa361SAndroid Build Coastguard Worker     if (__builtin_mul_overflow(nr_cpu, percpu_data_sz, &needed_buf_sz)) {
123*344aa361SAndroid Build Coastguard Worker         TRACEF("Error: multiply overflow while computing (nr_cpu * percpu_data_sz).\n");
124*344aa361SAndroid Build Coastguard Worker         goto err_invalid_params;
125*344aa361SAndroid Build Coastguard Worker     }
126*344aa361SAndroid Build Coastguard Worker     if (__builtin_add_overflow(needed_buf_sz, hdr_sz, &needed_buf_sz)) {
127*344aa361SAndroid Build Coastguard Worker         TRACEF("Error: Add overflow while adding header_size.\n");
128*344aa361SAndroid Build Coastguard Worker         goto err_invalid_params;
129*344aa361SAndroid Build Coastguard Worker     }
130*344aa361SAndroid Build Coastguard Worker 
131*344aa361SAndroid Build Coastguard Worker     if (needed_buf_sz > buf_size) {
132*344aa361SAndroid Build Coastguard Worker         TRACEF("Error: Buffer size is not adequate.\n");
133*344aa361SAndroid Build Coastguard Worker         goto err_invalid_params;
134*344aa361SAndroid Build Coastguard Worker     }
135*344aa361SAndroid Build Coastguard Worker 
136*344aa361SAndroid Build Coastguard Worker     spin_lock_irqsave(&sched_shared_datalock, state);
137*344aa361SAndroid Build Coastguard Worker 
138*344aa361SAndroid Build Coastguard Worker     if (sched_shared_mem) {
139*344aa361SAndroid Build Coastguard Worker         spin_unlock_irqrestore(&sched_shared_datalock, state);
140*344aa361SAndroid Build Coastguard Worker         TRACEF("Error: Shared-Memory is already present from a previous call.\n");
141*344aa361SAndroid Build Coastguard Worker         goto err_shared_mem_busy;
142*344aa361SAndroid Build Coastguard Worker     }
143*344aa361SAndroid Build Coastguard Worker 
144*344aa361SAndroid Build Coastguard Worker     shareinfo.cpu_count = nr_cpu;
145*344aa361SAndroid Build Coastguard Worker     shareinfo.header_size = hdr_sz;
146*344aa361SAndroid Build Coastguard Worker     shareinfo.percpu_data_size = percpu_data_sz;
147*344aa361SAndroid Build Coastguard Worker     shareinfo.client_id = client_id;
148*344aa361SAndroid Build Coastguard Worker     shareinfo.buf_id = buf_id;
149*344aa361SAndroid Build Coastguard Worker     sched_shared_mem = share_ptr;
150*344aa361SAndroid Build Coastguard Worker 
151*344aa361SAndroid Build Coastguard Worker     spin_unlock_irqrestore(&sched_shared_datalock, state);
152*344aa361SAndroid Build Coastguard Worker     return 0;
153*344aa361SAndroid Build Coastguard Worker 
154*344aa361SAndroid Build Coastguard Worker err_shared_mem_busy:
155*344aa361SAndroid Build Coastguard Worker err_invalid_params:
156*344aa361SAndroid Build Coastguard Worker     status = vmm_free_region(vmm_get_kernel_aspace(), (vaddr_t)share_ptr);
157*344aa361SAndroid Build Coastguard Worker     if (status) {
158*344aa361SAndroid Build Coastguard Worker         TRACEF("Error: failed to free the allocated virtual-memory.\n");
159*344aa361SAndroid Build Coastguard Worker         retval = SM_ERR_INTERNAL_FAILURE;
160*344aa361SAndroid Build Coastguard Worker     }
161*344aa361SAndroid Build Coastguard Worker     return retval;
162*344aa361SAndroid Build Coastguard Worker }
163*344aa361SAndroid Build Coastguard Worker 
trusty_share_unregister(ext_mem_client_id_t client_id,ext_mem_obj_id_t buf_id)164*344aa361SAndroid Build Coastguard Worker static long trusty_share_unregister(ext_mem_client_id_t client_id,
165*344aa361SAndroid Build Coastguard Worker                                     ext_mem_obj_id_t buf_id) {
166*344aa361SAndroid Build Coastguard Worker     struct trusty_sched_shared_mem* share_ptr;
167*344aa361SAndroid Build Coastguard Worker     spin_lock_saved_state_t state;
168*344aa361SAndroid Build Coastguard Worker     status_t status;
169*344aa361SAndroid Build Coastguard Worker     int retval = SM_ERR_INVALID_PARAMETERS;
170*344aa361SAndroid Build Coastguard Worker 
171*344aa361SAndroid Build Coastguard Worker     spin_lock_irqsave(&sched_shared_datalock, state);
172*344aa361SAndroid Build Coastguard Worker 
173*344aa361SAndroid Build Coastguard Worker     share_ptr = sched_shared_mem;
174*344aa361SAndroid Build Coastguard Worker     if (!share_ptr) {
175*344aa361SAndroid Build Coastguard Worker         spin_unlock_irqrestore(&sched_shared_datalock, state);
176*344aa361SAndroid Build Coastguard Worker         TRACEF("Error: Trusty ShareInfo not setup by register call.\n");
177*344aa361SAndroid Build Coastguard Worker         return retval;
178*344aa361SAndroid Build Coastguard Worker     }
179*344aa361SAndroid Build Coastguard Worker 
180*344aa361SAndroid Build Coastguard Worker     if ((client_id != shareinfo.client_id) || (buf_id != shareinfo.buf_id)) {
181*344aa361SAndroid Build Coastguard Worker         spin_unlock_irqrestore(&sched_shared_datalock, state);
182*344aa361SAndroid Build Coastguard Worker         TRACEF("Error: invalid arguments.\n");
183*344aa361SAndroid Build Coastguard Worker         return retval;
184*344aa361SAndroid Build Coastguard Worker     }
185*344aa361SAndroid Build Coastguard Worker 
186*344aa361SAndroid Build Coastguard Worker     sched_shared_mem = NULL;
187*344aa361SAndroid Build Coastguard Worker     memset(&shareinfo, 0, sizeof(struct share_info));
188*344aa361SAndroid Build Coastguard Worker 
189*344aa361SAndroid Build Coastguard Worker     spin_unlock_irqrestore(&sched_shared_datalock, state);
190*344aa361SAndroid Build Coastguard Worker     retval = 0;
191*344aa361SAndroid Build Coastguard Worker 
192*344aa361SAndroid Build Coastguard Worker     status = vmm_free_region(vmm_get_kernel_aspace(), (vaddr_t)share_ptr);
193*344aa361SAndroid Build Coastguard Worker     if (status) {
194*344aa361SAndroid Build Coastguard Worker         TRACEF("Error: failed to free the allocated virtual-memory.\n");
195*344aa361SAndroid Build Coastguard Worker         retval = SM_ERR_INTERNAL_FAILURE;
196*344aa361SAndroid Build Coastguard Worker     }
197*344aa361SAndroid Build Coastguard Worker     return retval;
198*344aa361SAndroid Build Coastguard Worker }
199*344aa361SAndroid Build Coastguard Worker 
smc_trusty_sched_share_register(struct smc32_args * args)200*344aa361SAndroid Build Coastguard Worker long smc_trusty_sched_share_register(struct smc32_args* args) {
201*344aa361SAndroid Build Coastguard Worker     ext_mem_client_id_t client_id = args->client_id;
202*344aa361SAndroid Build Coastguard Worker     ext_mem_obj_id_t buf_id = args_get_id(args);
203*344aa361SAndroid Build Coastguard Worker     uint32_t buf_size = args_get_sz(args);
204*344aa361SAndroid Build Coastguard Worker 
205*344aa361SAndroid Build Coastguard Worker     if (!IS_PAGE_ALIGNED(buf_size)) {
206*344aa361SAndroid Build Coastguard Worker         TRACEF("Error: argument buffer-size is not page-aligned.\n");
207*344aa361SAndroid Build Coastguard Worker         return SM_ERR_INVALID_PARAMETERS;
208*344aa361SAndroid Build Coastguard Worker     }
209*344aa361SAndroid Build Coastguard Worker 
210*344aa361SAndroid Build Coastguard Worker     return trusty_share_register(client_id, buf_id, buf_size);
211*344aa361SAndroid Build Coastguard Worker }
212*344aa361SAndroid Build Coastguard Worker 
smc_trusty_sched_share_unregister(struct smc32_args * args)213*344aa361SAndroid Build Coastguard Worker long smc_trusty_sched_share_unregister(struct smc32_args* args) {
214*344aa361SAndroid Build Coastguard Worker     ext_mem_client_id_t client_id = args->client_id;
215*344aa361SAndroid Build Coastguard Worker     ext_mem_obj_id_t buf_id = args_get_id(args);
216*344aa361SAndroid Build Coastguard Worker 
217*344aa361SAndroid Build Coastguard Worker     return trusty_share_unregister(client_id, buf_id);
218*344aa361SAndroid Build Coastguard Worker }
219*344aa361SAndroid Build Coastguard Worker 
get_percpu_share_ptr(uint32_t cpu_nr)220*344aa361SAndroid Build Coastguard Worker static struct trusty_percpu_shared_data* get_percpu_share_ptr(uint32_t cpu_nr) {
221*344aa361SAndroid Build Coastguard Worker     struct trusty_percpu_shared_data* percpu_data_ptr;
222*344aa361SAndroid Build Coastguard Worker     unsigned char* tmp;
223*344aa361SAndroid Build Coastguard Worker 
224*344aa361SAndroid Build Coastguard Worker     DEBUG_ASSERT(cpu_nr < shareinfo.cpu_count);
225*344aa361SAndroid Build Coastguard Worker 
226*344aa361SAndroid Build Coastguard Worker     tmp = (unsigned char*)sched_shared_mem;
227*344aa361SAndroid Build Coastguard Worker     tmp += shareinfo.header_size;
228*344aa361SAndroid Build Coastguard Worker     tmp += cpu_nr * shareinfo.percpu_data_size;
229*344aa361SAndroid Build Coastguard Worker 
230*344aa361SAndroid Build Coastguard Worker     percpu_data_ptr = (struct trusty_percpu_shared_data*)tmp;
231*344aa361SAndroid Build Coastguard Worker     return percpu_data_ptr;
232*344aa361SAndroid Build Coastguard Worker }
233*344aa361SAndroid Build Coastguard Worker 
234*344aa361SAndroid Build Coastguard Worker /*
235*344aa361SAndroid Build Coastguard Worker  * Following function is called from trusty kernel thread.c
236*344aa361SAndroid Build Coastguard Worker  */
platform_cpu_priority_set(uint32_t cpu_nr,uint32_t priority)237*344aa361SAndroid Build Coastguard Worker void platform_cpu_priority_set(uint32_t cpu_nr, uint32_t priority) {
238*344aa361SAndroid Build Coastguard Worker     spin_lock_saved_state_t state;
239*344aa361SAndroid Build Coastguard Worker     struct trusty_percpu_shared_data* percpu_data_ptr;
240*344aa361SAndroid Build Coastguard Worker     uint32_t requested_priority;
241*344aa361SAndroid Build Coastguard Worker 
242*344aa361SAndroid Build Coastguard Worker     /* Ignore the set request by irq-ns-switch-* threads, which exclusively
243*344aa361SAndroid Build Coastguard Worker      * run at the HIGHEST_PRIORITY. The problem is that the irq-ns-switch-*
244*344aa361SAndroid Build Coastguard Worker      * threads run on behalf of linux (or any other normal world client os)
245*344aa361SAndroid Build Coastguard Worker      * and are always the threads that return to linux (client os) while
246*344aa361SAndroid Build Coastguard Worker      * trusty is busy,  but those are not the threads whose priority, the
247*344aa361SAndroid Build Coastguard Worker      * linux side wants to know.
248*344aa361SAndroid Build Coastguard Worker      */
249*344aa361SAndroid Build Coastguard Worker     if (priority >= HIGHEST_PRIORITY) {
250*344aa361SAndroid Build Coastguard Worker         return;
251*344aa361SAndroid Build Coastguard Worker     }
252*344aa361SAndroid Build Coastguard Worker 
253*344aa361SAndroid Build Coastguard Worker     if (priority >= HIGH_PRIORITY) {
254*344aa361SAndroid Build Coastguard Worker         requested_priority = TRUSTY_SHADOW_PRIORITY_HIGH;
255*344aa361SAndroid Build Coastguard Worker     } else if (priority <= LOW_PRIORITY) {
256*344aa361SAndroid Build Coastguard Worker         requested_priority = TRUSTY_SHADOW_PRIORITY_LOW;
257*344aa361SAndroid Build Coastguard Worker     } else {
258*344aa361SAndroid Build Coastguard Worker         requested_priority = TRUSTY_SHADOW_PRIORITY_NORMAL;
259*344aa361SAndroid Build Coastguard Worker     }
260*344aa361SAndroid Build Coastguard Worker 
261*344aa361SAndroid Build Coastguard Worker     /*
262*344aa361SAndroid Build Coastguard Worker      * if the shared-memory is established and the reuesting
263*344aa361SAndroid Build Coastguard Worker      * cpu_nr is less than the max number of CPUs supported by
264*344aa361SAndroid Build Coastguard Worker      * the Linux side, proceed with the value change.
265*344aa361SAndroid Build Coastguard Worker      */
266*344aa361SAndroid Build Coastguard Worker     spin_lock_irqsave(&sched_shared_datalock, state);
267*344aa361SAndroid Build Coastguard Worker     if ((sched_shared_mem) && (cpu_nr < shareinfo.cpu_count)) {
268*344aa361SAndroid Build Coastguard Worker         percpu_data_ptr = get_percpu_share_ptr(cpu_nr);
269*344aa361SAndroid Build Coastguard Worker         percpu_data_ptr->ask_shadow_priority = requested_priority;
270*344aa361SAndroid Build Coastguard Worker     }
271*344aa361SAndroid Build Coastguard Worker     spin_unlock_irqrestore(&sched_shared_datalock, state);
272*344aa361SAndroid Build Coastguard Worker }
273