summaryrefslogtreecommitdiff
path: root/gralloc
diff options
context:
space:
mode:
authorTharaga Balachandran <tbalacha@codeaurora.org>2020-01-23 18:41:10 -0500
committerBaldev Sahu <bsahu@codeaurora.org>2020-05-12 09:41:37 +0530
commit576571c110b70af015b5e192de6fa148ee6b0a12 (patch)
tree87eaafc96fc257880c5fd8e4e06e0a5e918335fd /gralloc
parent95175bb5f9858fbc611f2bb333317ab27b61db09 (diff)
gralloc: Read debug properties in allocator process
This change resolves selinux denials caused by system processes reading vendor debug properties via gralloc. The debug properties are read and parsed in the allocator process, then propagated through the BufferManager CRs-Fixed: 2619084 Change-Id: I5175a7848cdcd2671bd16ee11721066a921f3d79
Diffstat (limited to 'gralloc')
-rw-r--r--gralloc/QtiAllocator.cpp26
-rw-r--r--gralloc/gr_adreno_info.cpp22
-rw-r--r--gralloc/gr_adreno_info.h6
-rw-r--r--gralloc/gr_allocator.cpp11
-rw-r--r--gralloc/gr_allocator.h3
-rw-r--r--gralloc/gr_buf_mgr.cpp8
-rw-r--r--gralloc/gr_buf_mgr.h3
-rw-r--r--gralloc/gr_utils.h8
8 files changed, 59 insertions, 28 deletions
diff --git a/gralloc/QtiAllocator.cpp b/gralloc/QtiAllocator.cpp
index 529889f6..1a042377 100644
--- a/gralloc/QtiAllocator.cpp
+++ b/gralloc/QtiAllocator.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2019 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2018-2020 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -30,6 +30,7 @@
#define DEBUG 0
#include "QtiAllocator.h"
+#include <cutils/properties.h>
#include <log/log.h>
#include <vendor/qti/hardware/display/mapper/3.0/IQtiMapper.h>
#include <vendor/qti/hardware/display/mapper/4.0/IQtiMapper.h>
@@ -40,6 +41,26 @@
#include "QtiMapper4.h"
#include "gr_utils.h"
+static void get_properties(gralloc::GrallocProperties *props) {
+ char property[PROPERTY_VALUE_MAX];
+ property_get("vendor.gralloc.use_system_heap_for_sensors", property, "1");
+ if (!(strncmp(property, "0", PROPERTY_VALUE_MAX))) {
+ props->use_system_heap_for_sensors = false;
+ }
+
+ property_get("vendor.gralloc.disable_ubwc", property, "0");
+ if (!(strncmp(property, "1", PROPERTY_VALUE_MAX)) ||
+ !(strncmp(property, "true", PROPERTY_VALUE_MAX))) {
+ props->ubwc_disable = true;
+ }
+
+ property_get("vendor.gralloc.disable_ahardware_buffer", property, "0");
+ if (!(strncmp(property, "1", PROPERTY_VALUE_MAX)) ||
+ !(strncmp(property, "true", PROPERTY_VALUE_MAX))) {
+ props->ahardware_buffer_disable = true;
+ }
+}
+
namespace vendor {
namespace qti {
namespace hardware {
@@ -54,7 +75,10 @@ using IMapper_3_0_Error = android::hardware::graphics::mapper::V3_0::Error;
using gralloc::Error;
QtiAllocator::QtiAllocator() {
+ gralloc::GrallocProperties properties;
+ get_properties(&properties);
buf_mgr_ = BufferManager::GetInstance();
+ buf_mgr_->SetGrallocDebugProperties(properties);
}
// Methods from ::android::hardware::graphics::allocator::V2_0::IAllocator follow.
diff --git a/gralloc/gr_adreno_info.cpp b/gralloc/gr_adreno_info.cpp
index d33f7db6..924020ae 100644
--- a/gralloc/gr_adreno_info.cpp
+++ b/gralloc/gr_adreno_info.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011-2018, 2020 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2011-2020, The Linux Foundation. All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -77,21 +77,6 @@ AdrenoMemInfo::AdrenoMemInfo() {
} else {
ALOGE(" Failed to load libadreno_utils.so");
}
-
- // Check if the overriding property debug.gralloc.gfx_ubwc_disable
- // that disables UBWC allocations for the graphics stack is set
- char property[PROPERTY_VALUE_MAX];
- property_get(DISABLE_UBWC_PROP, property, "0");
- if (!(strncmp(property, "1", PROPERTY_VALUE_MAX)) ||
- !(strncmp(property, "true", PROPERTY_VALUE_MAX))) {
- gfx_ubwc_disable_ = true;
- }
-
- property_get(DISABLE_AHARDWAREBUFFER_PROP, property, "0");
- if (!(strncmp(property, "1", PROPERTY_VALUE_MAX)) ||
- !(strncmp(property, "true", PROPERTY_VALUE_MAX))) {
- gfx_ahardware_buffer_disable_ = true;
- }
}
AdrenoMemInfo::~AdrenoMemInfo() {
@@ -100,6 +85,11 @@ AdrenoMemInfo::~AdrenoMemInfo() {
}
}
+void AdrenoMemInfo::AdrenoSetProperties(gralloc::GrallocProperties props) {
+ gfx_ubwc_disable_ = props.ubwc_disable;
+ gfx_ahardware_buffer_disable_ = props.ahardware_buffer_disable;
+}
+
void AdrenoMemInfo::AlignUnCompressedRGB(int width, int height, int format, int tile_enabled,
unsigned int *aligned_w, unsigned int *aligned_h) {
*aligned_w = (unsigned int)ALIGN(width, 32);
diff --git a/gralloc/gr_adreno_info.h b/gralloc/gr_adreno_info.h
index 436e0c03..6c9c3e31 100644
--- a/gralloc/gr_adreno_info.h
+++ b/gralloc/gr_adreno_info.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011-2018, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2011-2020, The Linux Foundation. All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -32,6 +32,8 @@
#include <media/msm_media_info.h>
+#include "gr_utils.h"
+
namespace gralloc {
// Adreno Pixel Formats
@@ -190,6 +192,8 @@ class AdrenoMemInfo {
*/
bool AdrenoSizeAPIAvaliable();
+ void AdrenoSetProperties(gralloc::GrallocProperties props);
+
static AdrenoMemInfo *GetInstance();
private:
diff --git a/gralloc/gr_allocator.cpp b/gralloc/gr_allocator.cpp
index 64211572..a8073195 100644
--- a/gralloc/gr_allocator.cpp
+++ b/gralloc/gr_allocator.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011-2018, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2011-2020, The Linux Foundation. All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -92,11 +92,6 @@ Allocator::Allocator() : ion_allocator_(nullptr) {}
bool Allocator::Init() {
ion_allocator_ = new IonAlloc();
- char property[PROPERTY_VALUE_MAX];
- property_get(USE_SYSTEM_HEAP_FOR_SENSORS, property, "1");
- if (!(strncmp(property, "0", PROPERTY_VALUE_MAX))) {
- use_system_heap_for_sensors_ = false;
- }
if (!ion_allocator_->Init()) {
return false;
@@ -111,6 +106,10 @@ Allocator::~Allocator() {
}
}
+void Allocator::SetProperties(gralloc::GrallocProperties props) {
+ use_system_heap_for_sensors_ = props.use_system_heap_for_sensors;
+}
+
int Allocator::AllocateMem(AllocData *alloc_data, uint64_t usage, int format) {
int ret;
alloc_data->uncached = UseUncached(format, usage);
diff --git a/gralloc/gr_allocator.h b/gralloc/gr_allocator.h
index 630151ac..8a9ba64f 100644
--- a/gralloc/gr_allocator.h
+++ b/gralloc/gr_allocator.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011-2018, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2011-2018, 2020, The Linux Foundation. All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -44,6 +44,7 @@ class Allocator {
Allocator();
~Allocator();
bool Init();
+ void SetProperties(gralloc::GrallocProperties props);
int MapBuffer(void **base, unsigned int size, unsigned int offset, int fd);
int ImportBuffer(int fd);
int FreeBuffer(void *base, unsigned int size, unsigned int offset, int fd, int handle);
diff --git a/gralloc/gr_buf_mgr.cpp b/gralloc/gr_buf_mgr.cpp
index 65b38649..b7554b0f 100644
--- a/gralloc/gr_buf_mgr.cpp
+++ b/gralloc/gr_buf_mgr.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011-2018 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2011-2018, 2020 The Linux Foundation. All rights reserved.
* Not a Contribution
*
* Copyright (C) 2010 The Android Open Source Project
@@ -32,6 +32,7 @@
#include <utility>
#include <vector>
+#include "gr_adreno_info.h"
#include "gr_buf_descriptor.h"
#include "gr_priv_handle.h"
#include "gr_utils.h"
@@ -381,6 +382,11 @@ BufferManager::~BufferManager() {
}
}
+void BufferManager::SetGrallocDebugProperties(gralloc::GrallocProperties props) {
+ allocator_->SetProperties(props);
+ AdrenoMemInfo::GetInstance()->AdrenoSetProperties(props);
+}
+
Error BufferManager::FreeBuffer(std::shared_ptr<Buffer> buf) {
auto hnd = buf->handle;
ALOGD_IF(DEBUG, "FreeBuffer handle:%p", hnd);
diff --git a/gralloc/gr_buf_mgr.h b/gralloc/gr_buf_mgr.h
index e2daa120..9c5794c9 100644
--- a/gralloc/gr_buf_mgr.h
+++ b/gralloc/gr_buf_mgr.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011-2018, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2011-2018, 2020 The Linux Foundation. All rights reserved.
* Not a Contribution
*
* Copyright (C) 2008 The Android Open Source Project
@@ -56,6 +56,7 @@ class BufferManager {
Error FlushBuffer(const private_handle_t *handle);
Error RereadBuffer(const private_handle_t *handle);
Error GetAllHandles(std::vector<const private_handle_t *> *out_handle_list);
+ void SetGrallocDebugProperties(gralloc::GrallocProperties props);
private:
BufferManager();
diff --git a/gralloc/gr_utils.h b/gralloc/gr_utils.h
index f2efddaf..e21f92b8 100644
--- a/gralloc/gr_utils.h
+++ b/gralloc/gr_utils.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011-2016,2018-2019, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2011-2016,2018-2020, The Linux Foundation. All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -63,6 +63,12 @@ struct BufferInfo {
uint64_t usage;
};
+struct GrallocProperties {
+ bool use_system_heap_for_sensors = true;
+ bool ubwc_disable = false;
+ bool ahardware_buffer_disable = false;
+};
+
template <class Type1, class Type2>
inline Type1 ALIGN(Type1 x, Type2 align) {
return (Type1)((x + (Type1)align - 1) & ~((Type1)align - 1));