summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Norvez <norvez@chromium.org>2016-08-12 12:32:42 +0100
committerchrome-bot <chrome-bot@chromium.org>2016-08-15 09:25:29 -0700
commit8e917140b7ffafebb82d32998e9f56ad215a53c6 (patch)
treeb552c49ed0cfb2cc85fff3672cdb6e4d522ffebb
parent969ce32e407f32671ab79444238b9ddf98c7d960 (diff)
downloadvboot-8e917140b7ffafebb82d32998e9f56ad215a53c6.tar.gz
crossystem: refactor VM detection to share across architectures
If there is no HWID and mainfw_type is "nonchrome", report that the host is a VM. If HWID is present, it's not a VM. Make the detection architecture-independent. BUG=chromium:632303 TEST=emerge-cyan vboot_reference and test binary on QEMU and HW TEST=emerge-veyron_minnie vboot_reference and test binary on HW BRANCH=none Change-Id: I076eb9838a3b724ded0cfded9fb8d8a5392631c8 Reviewed-on: https://chromium-review.googlesource.com/368650 Commit-Ready: Nicolas Norvez <norvez@chromium.org> Tested-by: Nicolas Norvez <norvez@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r--host/arch/arm/lib/crossystem_arch.c3
-rw-r--r--host/arch/mips/lib/crossystem_arch.c2
-rw-r--r--host/arch/x86/lib/crossystem_arch.c17
-rw-r--r--host/lib/crossystem.c15
4 files changed, 15 insertions, 22 deletions
diff --git a/host/arch/arm/lib/crossystem_arch.c b/host/arch/arm/lib/crossystem_arch.c
index ae1a0299..f1feab2c 100644
--- a/host/arch/arm/lib/crossystem_arch.c
+++ b/host/arch/arm/lib/crossystem_arch.c
@@ -404,9 +404,6 @@ int VbGetArchPropertyInt(const char* name) {
} else if (!strcasecmp(name, "recoverysw_ec_boot")) {
/* TODO: read correct value using ectool */
return 0;
- } else if (!strcasecmp(name, "inside_vm")) {
- /* No ARM VMs currently. */
- return 0;
} else {
return -1;
}
diff --git a/host/arch/mips/lib/crossystem_arch.c b/host/arch/mips/lib/crossystem_arch.c
index ed1c7ab8..28a6b806 100644
--- a/host/arch/mips/lib/crossystem_arch.c
+++ b/host/arch/mips/lib/crossystem_arch.c
@@ -42,8 +42,6 @@ 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 e1ee4f82..d7e89fe1 100644
--- a/host/arch/x86/lib/crossystem_arch.c
+++ b/host/arch/x86/lib/crossystem_arch.c
@@ -803,23 +803,6 @@ 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/host/lib/crossystem.c b/host/lib/crossystem.c
index 7c51927e..87c74169 100644
--- a/host/lib/crossystem.c
+++ b/host/lib/crossystem.c
@@ -553,6 +553,21 @@ int VbGetSystemPropertyInt(const char* name) {
value = VbGetNvStorage(VBNV_TRY_RO_SYNC);
} else if (!strcasecmp(name, "battery_cutoff_request")) {
value = VbGetNvStorage(VBNV_BATTERY_CUTOFF_REQUEST);
+ } else if (!strcasecmp(name, "inside_vm")) {
+ /* 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. */
+ char hwid[VB_MAX_STRING_PROPERTY];
+ if (!VbGetSystemPropertyString("hwid", hwid, sizeof(hwid))) {
+ char fwtype_buf[VB_MAX_STRING_PROPERTY];
+ const char *fwtype = VbGetSystemPropertyString("mainfw_type", fwtype_buf,
+ sizeof(fwtype_buf));
+ if (fwtype && !strcasecmp(fwtype, "nonchrome")) {
+ value = 1;
+ }
+ } else {
+ value = 0;
+ }
}
return value;