Skip to content

Commit ea26c1a

Browse files
committed
Revert "optee: Clear stale cache entries during initialization"
This reverts commit b5c10dd which breaks OP-TEE virtualization support [1]. The bug is in fact in the Xen mediator [2] so the proper fix is to upgrade Xen when a new maintenance release is available, at which point this revert should be discarded. Link: [1] OP-TEE/build#523 Link: [2] https://xenbits.xen.org/gitweb/?p=xen.git;a=commit;h=1c3ed9c908732d19660fbe83580674d585464d4c Signed-off-by: Jerome Forissier <[email protected]> [jf: rebase onto v5.16] Signed-off-by: Jerome Forissier <[email protected]>
1 parent 5f137b5 commit ea26c1a

File tree

2 files changed

+3
-43
lines changed

2 files changed

+3
-43
lines changed

drivers/tee/optee/optee_private.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,6 @@ int optee_pool_op_alloc_helper(struct tee_shm_pool_mgr *poolm,
224224
size_t num_pages,
225225
unsigned long start));
226226

227-
228227
void optee_remove_common(struct optee *optee);
229228
int optee_open(struct tee_context *ctx, bool cap_memref_null);
230229
void optee_release(struct tee_context *ctx);

drivers/tee/optee/smc_abi.c

Lines changed: 3 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -275,13 +275,11 @@ static void optee_enable_shm_cache(struct optee *optee)
275275
}
276276

277277
/**
278-
* __optee_disable_shm_cache() - Disables caching of some shared memory
279-
* allocation in OP-TEE
278+
* optee_disable_shm_cache() - Disables caching of some shared memory allocation
279+
* in OP-TEE
280280
* @optee: main service struct
281-
* @is_mapped: true if the cached shared memory addresses were mapped by this
282-
* kernel, are safe to dereference, and should be freed
283281
*/
284-
static void __optee_disable_shm_cache(struct optee *optee, bool is_mapped)
282+
void optee_disable_shm_cache(struct optee *optee)
285283
{
286284
struct optee_call_waiter w;
287285

@@ -300,13 +298,6 @@ static void __optee_disable_shm_cache(struct optee *optee, bool is_mapped)
300298
if (res.result.status == OPTEE_SMC_RETURN_OK) {
301299
struct tee_shm *shm;
302300

303-
/*
304-
* Shared memory references that were not mapped by
305-
* this kernel must be ignored to prevent a crash.
306-
*/
307-
if (!is_mapped)
308-
continue;
309-
310301
shm = reg_pair_to_ptr(res.result.shm_upper32,
311302
res.result.shm_lower32);
312303
tee_shm_free(shm);
@@ -317,27 +308,6 @@ static void __optee_disable_shm_cache(struct optee *optee, bool is_mapped)
317308
optee_cq_wait_final(&optee->call_queue, &w);
318309
}
319310

320-
/**
321-
* optee_disable_shm_cache() - Disables caching of mapped shared memory
322-
* allocations in OP-TEE
323-
* @optee: main service struct
324-
*/
325-
static void optee_disable_shm_cache(struct optee *optee)
326-
{
327-
return __optee_disable_shm_cache(optee, true);
328-
}
329-
330-
/**
331-
* optee_disable_unmapped_shm_cache() - Disables caching of shared memory
332-
* allocations in OP-TEE which are not
333-
* currently mapped
334-
* @optee: main service struct
335-
*/
336-
static void optee_disable_unmapped_shm_cache(struct optee *optee)
337-
{
338-
return __optee_disable_shm_cache(optee, false);
339-
}
340-
341311
#define PAGELIST_ENTRIES_PER_PAGE \
342312
((OPTEE_MSG_NONCONTIG_PAGE_SIZE / sizeof(u64)) - 1)
343313

@@ -1295,15 +1265,6 @@ static int optee_probe(struct platform_device *pdev)
12951265
optee->smc.memremaped_shm = memremaped_shm;
12961266
optee->pool = pool;
12971267

1298-
/*
1299-
* Ensure that there are no pre-existing shm objects before enabling
1300-
* the shm cache so that there's no chance of receiving an invalid
1301-
* address during shutdown. This could occur, for example, if we're
1302-
* kexec booting from an older kernel that did not properly cleanup the
1303-
* shm cache.
1304-
*/
1305-
optee_disable_unmapped_shm_cache(optee);
1306-
13071268
optee_enable_shm_cache(optee);
13081269

13091270
if (optee->smc.sec_caps & OPTEE_SMC_SEC_CAP_DYNAMIC_SHM)

0 commit comments

Comments
 (0)