crossystem: use wpsw_boot as fallback for wpsw_cur

In preparation for deprecating wpsw_boot, update wpsw_cur
to use wpsw_boot as a fallback value.

The source of wpsw_boot will still be deprecated on devices
using new firmware, but in those cases, we are absolutely
certain that wpsw_cur will work.

BUG=b:124141368, chromium:950723
TEST=make clean && make runtests
BRANCH=none

Change-Id: I77ab9c6b827ef2c033ae46b7b01b12465101c0a9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2071633
Tested-by: Joel Kitching <kitching@chromium.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
Commit-Queue: Joel Kitching <kitching@chromium.org>
diff --git a/host/arch/x86/lib/crossystem_arch.c b/host/arch/x86/lib/crossystem_arch.c
index 2fd2f53..1e51cb0 100644
--- a/host/arch/x86/lib/crossystem_arch.c
+++ b/host/arch/x86/lib/crossystem_arch.c
@@ -803,6 +803,9 @@
 		value = ReadGpio(GPIO_SIGNAL_TYPE_RECOVERY);
 	} else if (!strcasecmp(name,"wpsw_cur")) {
 		value = ReadGpio(GPIO_SIGNAL_TYPE_WP);
+		/* Use "write-protect at boot" as a fallback value. */
+		if (-1 == value)
+			value = ReadFileBit(ACPI_CHSW_PATH, CHSW_WP_BOOT);
 		if (-1 != value && FwidStartsWith("Mario."))
 			value = 1 - value;  /* Mario reports this backwards */
 	} else if (!strcasecmp(name,"recoverysw_ec_boot")) {
diff --git a/host/lib/crossystem.c b/host/lib/crossystem.c
index 33cf332..50de4cb 100644
--- a/host/lib/crossystem.c
+++ b/host/lib/crossystem.c
@@ -428,6 +428,9 @@
 		value = GetVdatInt(VDAT_INT_DEVSW_BOOT);
 	} else if (!strcasecmp(name, "recoverysw_boot")) {
 		value = GetVdatInt(VDAT_INT_RECSW_BOOT);
+	} else if (!strcasecmp(name, "wpsw_cur")) {
+		/* Use "write-protect at boot" as a fallback value. */
+		value = GetVdatInt(VDAT_INT_HW_WPSW_BOOT);
 	} else if (!strcasecmp(name, "wpsw_boot")) {
 		value = GetVdatInt(VDAT_INT_HW_WPSW_BOOT);
 	} else if (!strcasecmp(name,"vdat_flags")) {