init: Wait for /dev/hvc1 during ARCVM first-stage mount

This commit introduces a function to allow ARC-specific logic during
first-stage mount by checking for the existence of an indicator file
at the path "/is_arcvm".

ARC uses the virtio-console device `hvc1` to pass byte data to Android
before second-stage init. Ensure that /dev/hvc1 is initialized before
ARCVM continues booting, but allow other devices to bypass this device
initialization.

Bug: 325538592
Test: boot ARC, ensure /dev/hvc1 can be read during PropertyInit
Change-Id: Ic258b7b004b59da462f4990131a5c11fc94eca62
This commit is contained in:
Tiffany Yang 2024-05-22 21:04:38 -07:00
parent 0fb39f6e69
commit b885e4ad53
3 changed files with 12 additions and 0 deletions

View file

@ -305,6 +305,11 @@ bool FirstStageMountVBootV2::InitDevices() {
return false;
}
}
if (IsArcvm() && !block_dev_init_.InitHvcDevice("hvc1")) {
return false;
}
return true;
}

View file

@ -474,6 +474,8 @@ void SelinuxRestoreContext() {
RestoreconIfExists(SnapshotManager::GetGlobalRollbackIndicatorPath().c_str(), 0);
RestoreconIfExists("/metadata/gsi",
SELINUX_ANDROID_RESTORECON_RECURSE | SELINUX_ANDROID_RESTORECON_SKIP_SEHASH);
RestoreconIfExists("/dev/hvc1", 0);
}
int SelinuxKlogCallback(int type, const char* fmt, ...) {

View file

@ -18,6 +18,7 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/unistd.h>
#include <chrono>
#include <functional>
@ -108,6 +109,10 @@ inline constexpr bool IsMicrodroid() {
#endif
}
inline bool IsArcvm() {
return !access("/is_arcvm", F_OK);
}
bool Has32BitAbi();
std::string GetApexNameFromFileName(const std::string& path);