diff options
-rw-r--r-- | host/arch/arm/lib/crossystem_arch.c | 8 | ||||
-rw-r--r-- | host/arch/mips/lib/crossystem_arch.c | 2 | ||||
-rw-r--r-- | host/arch/x86/lib/crossystem_arch.c | 17 | ||||
-rw-r--r-- | utility/crossystem.c | 1 |
4 files changed, 26 insertions, 2 deletions
diff --git a/host/arch/arm/lib/crossystem_arch.c b/host/arch/arm/lib/crossystem_arch.c index 309235dc..ae1a0299 100644 --- a/host/arch/arm/lib/crossystem_arch.c +++ b/host/arch/arm/lib/crossystem_arch.c @@ -401,11 +401,15 @@ int VbGetArchPropertyInt(const char* name) { if (value != -1) return value; return VbGetVarGpio("write-protect-switch"); - } else if (!strcasecmp(name, "recoverysw_ec_boot")) + } else if (!strcasecmp(name, "recoverysw_ec_boot")) { /* TODO: read correct value using ectool */ return 0; - else + } else if (!strcasecmp(name, "inside_vm")) { + /* No ARM VMs currently. */ + return 0; + } else { return -1; + } } const char* VbGetArchPropertyString(const char* name, char* dest, diff --git a/host/arch/mips/lib/crossystem_arch.c b/host/arch/mips/lib/crossystem_arch.c index 28a6b806..ed1c7ab8 100644 --- a/host/arch/mips/lib/crossystem_arch.c +++ b/host/arch/mips/lib/crossystem_arch.c @@ -42,6 +42,8 @@ int VbGetArchPropertyInt(const char* name) { return 0; } else if (!strcasecmp(name,"wpsw_boot")) { return 1; + } else if (!strcasecmp(name,"inside_vm")) { + return 0; } return -1; } diff --git a/host/arch/x86/lib/crossystem_arch.c b/host/arch/x86/lib/crossystem_arch.c index d7e89fe1..e1ee4f82 100644 --- a/host/arch/x86/lib/crossystem_arch.c +++ b/host/arch/x86/lib/crossystem_arch.c @@ -803,6 +803,23 @@ int VbGetArchPropertyInt(const char* name) { value = (int)fwupdate_value; } + /* Detect if the host is a VM. If there is no HWID and the firmware type + * is "nonchrome", then assume it is a VM. If HWID is present, it is a + * baremetal Chrome OS machine. Other cases are errors. */ + if (!strcasecmp(name,"inside_vm")) { + char hwid[VB_MAX_STRING_PROPERTY]; + if (!VbGetArchPropertyString("hwid", hwid, sizeof(hwid))) { + char fwtype_buf[VB_MAX_STRING_PROPERTY]; + const char *fwtype = VbGetArchPropertyString("mainfw_type", fwtype_buf, + sizeof(fwtype_buf)); + if (fwtype && !strcasecmp(fwtype,"nonchrome")) { + value = 1; + } + } else { + value = 0; + } + } + return value; } diff --git a/utility/crossystem.c b/utility/crossystem.c index c88a444d..6278e30f 100644 --- a/utility/crossystem.c +++ b/utility/crossystem.c @@ -69,6 +69,7 @@ const Param sys_param_list[] = { {"fw_prev_tried", IS_STRING, "Firmware tried on previous boot (vboot2)"}, {"fw_prev_result", IS_STRING, "Firmware result of previous boot (vboot2)"}, {"hwid", IS_STRING, "Hardware ID"}, + {"inside_vm", 0, "Running in a VM?"}, {"kern_nv", 0, "Non-volatile field for kernel use", "0x%08x"}, {"kernkey_vfy", IS_STRING, "Type of verification done on kernel key block"}, {"loc_idx", CAN_WRITE, "Localization index for firmware screens (writable)"}, |