aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Chiu <jasoncschiu@google.com>2023-11-30 22:25:57 +0800
committerJason Chiu <jasoncschiu@google.com>2023-12-05 09:14:48 +0800
commitec2a9a0c7ac5d981862093b47be2d24c36518ecd (patch)
treebca888978ae28032140d12e112497cbbd8df861f
parent2a201a74c221ed6bf4adf597d7437b3a724a3898 (diff)
downloadgs-common-ec2a9a0c7ac5d981862093b47be2d24c36518ecd.tar.gz
gs-common: bootctrl: integrate blowAR() for gs101 & zuma
Common bootcontrol use zuma version for the base, and blowAR() can't be used by gs101. So we need to port ag/18743149 into common bootcontrol. Bug: 313615120 Change-Id: I25febde96a56279e6592a6d7740be9a2e385543b Signed-off-by: Jason Chiu <jasoncschiu@google.com>
-rw-r--r--bootctrl/1.2/BootControl.cpp23
-rw-r--r--bootctrl/aidl/BootControl.cpp22
2 files changed, 43 insertions, 2 deletions
diff --git a/bootctrl/1.2/BootControl.cpp b/bootctrl/1.2/BootControl.cpp
index 4e72805..ff02013 100644
--- a/bootctrl/1.2/BootControl.cpp
+++ b/bootctrl/1.2/BootControl.cpp
@@ -50,6 +50,8 @@ namespace {
#define BOOT_B_PATH "/dev/block/by-name/boot_b"
#define DEVINFO_PATH "/dev/block/by-name/devinfo"
+#define BLOW_AR_PATH "/sys/kernel/boot_control/blow_ar"
+
// slot flags
#define AB_ATTR_PRIORITY_SHIFT 52
#define AB_ATTR_PRIORITY_MASK (3UL << AB_ATTR_PRIORITY_SHIFT)
@@ -230,7 +232,7 @@ static int blow_otp_AR(bool secure) {
return 0;
}
-static bool blowAR() {
+static bool blowAR_zuma() {
int ret = blow_otp_AR(true);
if (ret) {
ALOGI("Blow secure anti-rollback OTP failed");
@@ -245,6 +247,25 @@ static bool blowAR() {
return true;
}
+
+static bool blowAR_gs101() {
+ android::base::unique_fd fd(open(BLOW_AR_PATH, O_WRONLY | O_DSYNC));
+ return android::base::WriteStringToFd("1", fd);
+}
+
+static bool blowAR() {
+ char platform[PROPERTY_VALUE_MAX];
+ property_get("ro.boot.hardware.platform", platform, "");
+
+ if (std::string(platform) == "gs101") {
+ return blowAR_gs101();
+ } else if (std::string(platform) == "gs201" || std::string(platform) == "zuma") {
+ return blowAR_zuma();
+ }
+
+ return true;
+}
+
} // namespace
// Methods from ::android::hardware::boot::V1_0::IBootControl follow.
diff --git a/bootctrl/aidl/BootControl.cpp b/bootctrl/aidl/BootControl.cpp
index 0221514..e771845 100644
--- a/bootctrl/aidl/BootControl.cpp
+++ b/bootctrl/aidl/BootControl.cpp
@@ -47,6 +47,8 @@ namespace {
#define BOOT_B_PATH "/dev/block/by-name/boot_b"
#define DEVINFO_PATH "/dev/block/by-name/devinfo"
+#define BLOW_AR_PATH "/sys/kernel/boot_control/blow_ar"
+
// slot flags
#define AB_ATTR_PRIORITY_SHIFT 52
#define AB_ATTR_PRIORITY_MASK (3UL << AB_ATTR_PRIORITY_SHIFT)
@@ -227,7 +229,7 @@ static int blow_otp_AR(bool secure) {
return 0;
}
-static bool blowAR() {
+static bool blowAR_zuma() {
int ret = blow_otp_AR(true);
if (ret) {
ALOGI("Blow secure anti-rollback OTP failed");
@@ -243,6 +245,24 @@ static bool blowAR() {
return true;
}
+static bool blowAR_gs101() {
+ ::android::base::unique_fd fd(open(BLOW_AR_PATH, O_WRONLY | O_DSYNC));
+ return ::android::base::WriteStringToFd("1", fd);
+}
+
+static bool blowAR() {
+ char platform[PROPERTY_VALUE_MAX];
+ property_get("ro.boot.hardware.platform", platform, "");
+
+ if (std::string(platform) == "gs101") {
+ return blowAR_gs101();
+ } else if (std::string(platform) == "gs201" || std::string(platform) == "zuma") {
+ return blowAR_zuma();
+ }
+
+ return true;
+}
+
static constexpr MergeStatus ToAIDLMergeStatus(HIDLMergeStatus status) {
switch (status) {
case HIDLMergeStatus::NONE: