display: Add flag to avoid mapping memory in userspace
For secure content the MM heap should never be mapped in userspace. Add a flag to avoid doing this for rotator which does not need userspace mapping. (cherry picked from commit 8d9f2fa336564d5a021dd932f5619b5f389d5fad) Change-Id: I17d1faa40859e261518d928089f2ce86084d31fd CRs-fixed: 332402
This commit is contained in:
parent
4c082b642a
commit
694752d90d
@ -136,6 +136,9 @@ int IonController::allocate(alloc_data& data, int usage,
|
||||
if(usage & GRALLOC_USAGE_PROTECTED)
|
||||
ionFlags |= ION_SECURE;
|
||||
|
||||
if(usage & GRALLOC_USAGE_PRIVATE_DO_NOT_MAP)
|
||||
data.allocType = private_handle_t::PRIV_FLAGS_NOT_MAPPED;
|
||||
|
||||
// if no flags are set, default to
|
||||
// EBI heap, so that bypass can work
|
||||
// we can fall back to system heap if
|
||||
|
@ -74,6 +74,9 @@ enum {
|
||||
* and may need to be moved if the gralloc API changes
|
||||
*/
|
||||
GRALLOC_USAGE_PRIVATE_UNSYNCHRONIZED = 0X00040000,
|
||||
|
||||
/* Set this flag when you need to avoid mapping the memory in userspace */
|
||||
GRALLOC_USAGE_PRIVATE_DO_NOT_MAP = 0X00080000,
|
||||
};
|
||||
|
||||
enum {
|
||||
@ -317,6 +320,7 @@ struct private_handle_t {
|
||||
PRIV_FLAGS_HWC_LOCK = 0x00000200, // Set by HWC when storing the handle
|
||||
PRIV_FLAGS_SECURE_BUFFER = 0x00000400,
|
||||
PRIV_FLAGS_UNSYNCHRONIZED = 0x00000800, // For explicit synchronization
|
||||
PRIV_FLAGS_NOT_MAPPED = 0x00001000, // Not mapped in userspace
|
||||
};
|
||||
|
||||
// file-descriptors
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include <fcntl.h>
|
||||
#include <cutils/log.h>
|
||||
#include <errno.h>
|
||||
#include "gralloc_priv.h"
|
||||
#include "ionalloc.h"
|
||||
|
||||
using gralloc::IonAlloc;
|
||||
@ -116,7 +117,8 @@ int IonAlloc::alloc_buffer(alloc_data& data)
|
||||
return err;
|
||||
}
|
||||
|
||||
if(!(data.flags & ION_SECURE)) {
|
||||
if(!(data.flags & ION_SECURE) &&
|
||||
!(data.allocType & private_handle_t::PRIV_FLAGS_NOT_MAPPED)) {
|
||||
|
||||
base = mmap(0, ionAllocData.len, PROT_READ|PROT_WRITE,
|
||||
MAP_SHARED, fd_data.fd, 0);
|
||||
|
@ -1830,8 +1830,9 @@ bool OverlayDataChannel::mapRotatorMemory(int num_buffers, bool uiChannel, int r
|
||||
data.align = getpagesize();
|
||||
data.uncached = true;
|
||||
|
||||
int allocFlags = GRALLOC_USAGE_PRIVATE_MM_HEAP |
|
||||
GRALLOC_USAGE_PRIVATE_WRITEBACK_HEAP;
|
||||
int allocFlags = GRALLOC_USAGE_PRIVATE_MM_HEAP |
|
||||
GRALLOC_USAGE_PRIVATE_WRITEBACK_HEAP|
|
||||
GRALLOC_USAGE_PRIVATE_DO_NOT_MAP;
|
||||
|
||||
if(mSecure) {
|
||||
allocFlags |= GRALLOC_USAGE_PROTECTED;
|
||||
|
@ -164,7 +164,8 @@ status_t Rotator::startRotSession(msm_rotator_img_info& rotInfo,
|
||||
GRALLOC_USAGE_PRIVATE_WRITEBACK_HEAP |
|
||||
GRALLOC_USAGE_PRIVATE_ADSP_HEAP |
|
||||
GRALLOC_USAGE_PRIVATE_IOMMU_HEAP |
|
||||
GRALLOC_USAGE_PRIVATE_SMI_HEAP;
|
||||
GRALLOC_USAGE_PRIVATE_SMI_HEAP |
|
||||
GRALLOC_USAGE_PRIVATE_DO_NOT_MAP;
|
||||
|
||||
int err = mAlloc->allocate(data, allocFlags, 0);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user