Skip to content

Commit 665750f

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]> [jf: rebase onto v5.17] Signed-off-by: Jerome Forissier <[email protected]>
1 parent 688e135 commit 665750f

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
@@ -237,7 +237,6 @@ int optee_pool_op_alloc_helper(struct tee_shm_pool_mgr *poolm,
237237
size_t num_pages,
238238
unsigned long start));
239239

240-
241240
void optee_remove_common(struct optee *optee);
242241
int optee_open(struct tee_context *ctx, bool cap_memref_null);
243242
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
@@ -269,13 +269,11 @@ static void optee_enable_shm_cache(struct optee *optee)
269269
}
270270

271271
/**
272-
* __optee_disable_shm_cache() - Disables caching of some shared memory
273-
* allocation in OP-TEE
272+
* optee_disable_shm_cache() - Disables caching of some shared memory allocation
273+
* in OP-TEE
274274
* @optee: main service struct
275-
* @is_mapped: true if the cached shared memory addresses were mapped by this
276-
* kernel, are safe to dereference, and should be freed
277275
*/
278-
static void __optee_disable_shm_cache(struct optee *optee, bool is_mapped)
276+
void optee_disable_shm_cache(struct optee *optee)
279277
{
280278
struct optee_call_waiter w;
281279

@@ -294,13 +292,6 @@ static void __optee_disable_shm_cache(struct optee *optee, bool is_mapped)
294292
if (res.result.status == OPTEE_SMC_RETURN_OK) {
295293
struct tee_shm *shm;
296294

297-
/*
298-
* Shared memory references that were not mapped by
299-
* this kernel must be ignored to prevent a crash.
300-
*/
301-
if (!is_mapped)
302-
continue;
303-
304295
shm = reg_pair_to_ptr(res.result.shm_upper32,
305296
res.result.shm_lower32);
306297
tee_shm_free(shm);
@@ -311,27 +302,6 @@ static void __optee_disable_shm_cache(struct optee *optee, bool is_mapped)
311302
optee_cq_wait_final(&optee->call_queue, &w);
312303
}
313304

314-
/**
315-
* optee_disable_shm_cache() - Disables caching of mapped shared memory
316-
* allocations in OP-TEE
317-
* @optee: main service struct
318-
*/
319-
static void optee_disable_shm_cache(struct optee *optee)
320-
{
321-
return __optee_disable_shm_cache(optee, true);
322-
}
323-
324-
/**
325-
* optee_disable_unmapped_shm_cache() - Disables caching of shared memory
326-
* allocations in OP-TEE which are not
327-
* currently mapped
328-
* @optee: main service struct
329-
*/
330-
static void optee_disable_unmapped_shm_cache(struct optee *optee)
331-
{
332-
return __optee_disable_shm_cache(optee, false);
333-
}
334-
335305
#define PAGELIST_ENTRIES_PER_PAGE \
336306
((OPTEE_MSG_NONCONTIG_PAGE_SIZE / sizeof(u64)) - 1)
337307

@@ -1445,15 +1415,6 @@ static int optee_probe(struct platform_device *pdev)
14451415
pr_info("Asynchronous notifications enabled\n");
14461416
}
14471417

1448-
/*
1449-
* Ensure that there are no pre-existing shm objects before enabling
1450-
* the shm cache so that there's no chance of receiving an invalid
1451-
* address during shutdown. This could occur, for example, if we're
1452-
* kexec booting from an older kernel that did not properly cleanup the
1453-
* shm cache.
1454-
*/
1455-
optee_disable_unmapped_shm_cache(optee);
1456-
14571418
optee_enable_shm_cache(optee);
14581419

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

0 commit comments

Comments
 (0)