[07/14] acpi/method: add tests for NVDIMM control methods for ACPI 6.3

Message ID 20190208032314.15215-8-alex.hung@canonical.com
State Superseded
Headers show
Series
  • Updates for ACPI 6.2b and 6.3
Related show

Commit Message

Alex Hung Feb. 8, 2019, 3:23 a.m.
Including _NBS, _NCH (mantis 1893), _NIC, _NIH and _NIC (mantis 1913)

Signed-off-by: Alex Hung <alex.hung@canonical.com>
---
 src/acpi/method/method.c | 286 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 286 insertions(+)

Comments

Colin Ian King Feb. 8, 2019, 12:12 p.m. | #1
On 08/02/2019 03:23, Alex Hung wrote:
> Including _NBS, _NCH (mantis 1893), _NIC, _NIH and _NIC (mantis 1913)
> 
> Signed-off-by: Alex Hung <alex.hung@canonical.com>
> ---
>  src/acpi/method/method.c | 286 +++++++++++++++++++++++++++++++++++++++
>  1 file changed, 286 insertions(+)
> 
> diff --git a/src/acpi/method/method.c b/src/acpi/method/method.c
> index 654112d9..f117d91d 100644
> --- a/src/acpi/method/method.c
> +++ b/src/acpi/method/method.c
> @@ -138,6 +138,11 @@
>   * _MSG 	 Y
>   * _MSM 	 N
>   * _MTL 	 Y
> + * _NBS 	 Y
> + * _NCH 	 Y
> + * _NIC 	 Y
> + * _NIH 	 Y
> + * _NIG 	 Y
>   * _NTT 	 Y
>   * _OFF 	 Y
>   * _ON_ 	 Y
> @@ -3574,6 +3579,280 @@ static int method_test_TIV(fwts_framework *fw)
>  		"_TIV", arg, 1, fwts_method_test_integer_return, NULL);
>  }
>  
> +/*
> + * Section 9.20 NVDIMM Devices
> + */
> +static void check_nvdimm_status(
> +	fwts_framework *fw,
> +	char *name,
> +	uint16_t status,
> +	bool *failed)
> +{
> +	if (status > 6) {
> +		*failed = true;
> +		fwts_failed(fw, LOG_LEVEL_MEDIUM,
> +			"MethodBadStatus",
> +			"%s: Expected Status to be 0..6, got %" PRIx16,
> +			name, status);
> +	}
> +}
> +
> +static void check_nvdimm_extended_status(
> +	fwts_framework *fw,
> +	char *name,
> +	uint16_t ext_status,
> +	uint16_t expected,
> +	bool *failed)
> +{
> +	if (ext_status != expected) {
> +		*failed = true;
> +		fwts_failed(fw, LOG_LEVEL_MEDIUM,
> +			"MethodBadExtendedStatus",
> +			"%s: Expected Extended Status to be %" PRIx16
> +			", got %" PRIx16, name, expected, ext_status);
> +	}
> +}
> +
> +static void method_test_NBS_return(
> +	fwts_framework *fw,
> +	char *name,
> +	ACPI_BUFFER *buf,
> +	ACPI_OBJECT *obj,
> +	void *private)
> +{
> +	bool failed = false;
> +	uint8_t *data;
> +
> +	FWTS_UNUSED(private);
> +
> +	if (fwts_method_check_type(fw, name, buf, ACPI_TYPE_BUFFER) != FWTS_OK)
> +		return;
> +
> +	if (obj->Buffer.Length != 64) {
> +		failed = true;
> +		fwts_failed(fw, LOG_LEVEL_CRITICAL,
> +			"Method_NBSBadBufferSize",
> +			"%s should return a buffer of 64 bytes, but "
> +			"instead just returned %" PRIu32,
> +			name, obj->Buffer.Length);
> +	}
> +
> +	data = (uint8_t*)obj->Buffer.Pointer;
> +	check_nvdimm_status(fw, name, (uint16_t) data[0], &failed);

Casting (uint16_t)data[0] of data[0] into a 16 bit unsigned int just
uses the 8 bit value in data[0] and not the 16 bit value from data[0]
with data[1]. A better way would be to defined a structure for this buffer

typedef struct {
	uint16_t	status;
	uint16_t	extended_status;
	uint16_t	validation_flags;
	uint32_t	data_loss_count;
	uint8_t		reserved[54];
}  __attribute__ ((packed))nts_return_t;

..and cast this onto data

	struct nts_return_t *nts_ret = (struct nts_return_t *)data;

and use the nts_return fields instead.

Same for all the return type in the tests you added.


> +	check_nvdimm_extended_status(fw, name, (uint16_t) data[2], 0, &failed);
> +	fwts_acpi_reserved_bits_check(fw, "_NBS", "Validation Flags", (uint16_t) data[4], sizeof(uint16_t), 1, 15, &failed);
> +
> +	if (!failed)
> +		fwts_method_passed_sane(fw, name, "buffer");
> +}
> +
> +static int method_test_NBS(fwts_framework *fw)
> +{
> +	return method_evaluate_method(fw, METHOD_OPTIONAL,
> +		"_NBS", NULL, 0, method_test_NBS_return, NULL);
> +}
> +
> +static void method_test_NCH_return(
> +	fwts_framework *fw,
> +	char *name,
> +	ACPI_BUFFER *buf,
> +	ACPI_OBJECT *obj,
> +	void *private)
> +{
> +	bool failed = false;
> +	uint8_t *data;
> +
> +	FWTS_UNUSED(private);
> +
> +	if (fwts_method_check_type(fw, name, buf, ACPI_TYPE_BUFFER) != FWTS_OK)
> +		return;
> +
> +	if (obj->Buffer.Length != 64) {
> +		failed = true;
> +		fwts_failed(fw, LOG_LEVEL_CRITICAL,
> +			"Method_NCHBadBufferSize",
> +			"%s should return a buffer of 64 bytes, but "
> +			"instead just returned %" PRIu32,
> +			name, obj->Buffer.Length);
> +	}
> +
> +	data = (uint8_t*)obj->Buffer.Pointer;
> +	check_nvdimm_status(fw, name, (uint16_t) data[0], &failed);
> +	check_nvdimm_extended_status(fw, name, (uint16_t) data[2], 0, &failed);
> +	fwts_acpi_reserved_bits_check(fw, "_NCH", "Validation Flags", (uint16_t) data[4], sizeof(uint16_t), 2, 15, &failed);
> +
> +	/* Health Status Flags [2..7], [11.15], [19..31] are reserved */
> +	fwts_acpi_reserved_bits_check(fw, "_NCH", "Health Status Flags", (uint32_t) data[6], sizeof(uint32_t), 2, 7, &failed);
> +	fwts_acpi_reserved_bits_check(fw, "_NCH", "Health Status Flags", (uint32_t) data[6], sizeof(uint32_t), 11, 15, &failed);
> +	fwts_acpi_reserved_bits_check(fw, "_NCH", "Health Status Flags", (uint32_t) data[6], sizeof(uint32_t), 19, 31, &failed);
> +
> +	fwts_acpi_reserved_bits_check(fw, "_NCH", "Health Status Attributes", (uint32_t) data[10], sizeof(uint32_t), 1, 31, &failed);
> +
> +	if (!failed)
> +		fwts_method_passed_sane(fw, name, "buffer");
> +}
> +
> +static int method_test_NCH(fwts_framework *fw)
> +{
> +	return method_evaluate_method(fw, METHOD_OPTIONAL,
> +		"_NCH", NULL, 0, method_test_NCH_return, NULL);
> +}
> +
> +static void method_test_NIC_return(
> +	fwts_framework *fw,
> +	char *name,
> +	ACPI_BUFFER *buf,
> +	ACPI_OBJECT *obj,
> +	void *private)
> +{
> +	bool failed = false;
> +	uint8_t *data;
> +
> +	FWTS_UNUSED(private);
> +
> +	if (fwts_method_check_type(fw, name, buf, ACPI_TYPE_BUFFER) != FWTS_OK)
> +		return;
> +
> +	if (obj->Buffer.Length != 64) {
> +		failed = true;
> +		fwts_failed(fw, LOG_LEVEL_CRITICAL,
> +			"Method_NICBadBufferSize",
> +			"%s should return a buffer of 64 bytes, but "
> +			"instead just returned %" PRIu32,
> +			name, obj->Buffer.Length);
> +	}
> +
> +	data = (uint8_t*)obj->Buffer.Pointer;
> +	check_nvdimm_status(fw, name, (uint16_t)data[0], &failed);
> +	check_nvdimm_extended_status(fw, name, (uint16_t)data[2], 0, &failed);
> +
> +	/* Health Error Injection Capabilities [2..7], [11.15], [19..31] are reserved */
> +	fwts_acpi_reserved_bits_check(fw, "_NIC", "Health Error Injection Capabilities", (uint32_t) data[4], sizeof(uint32_t), 2, 7, &failed);
> +	fwts_acpi_reserved_bits_check(fw, "_NIC", "Health Error Injection Capabilities", (uint32_t) data[4], sizeof(uint32_t), 11, 15, &failed);
> +	fwts_acpi_reserved_bits_check(fw, "_NIC", "Health Error Injection Capabilities", (uint32_t) data[4], sizeof(uint32_t), 19, 31, &failed);
> +
> +	fwts_acpi_reserved_bits_check(fw, "_NIC", "Health Status Attributes Capabilities", (uint32_t) data[8], sizeof(uint32_t), 1, 31, &failed);
> +
> +	if (!failed)
> +		fwts_method_passed_sane(fw, name, "buffer");
> +}
> +
> +static int method_test_NIC(fwts_framework *fw)
> +{
> +	return method_evaluate_method(fw, METHOD_OPTIONAL,
> +		"_NIC", NULL, 0, method_test_NIC_return, NULL);
> +}
> +
> +static void method_test_NIH_return(
> +	fwts_framework *fw,
> +	char *name,
> +	ACPI_BUFFER *buf,
> +	ACPI_OBJECT *obj,
> +	void *private)
> +{
> +	bool failed = false;
> +	uint8_t *data;
> +
> +	FWTS_UNUSED(private);
> +
> +	if (fwts_method_check_type(fw, name, buf, ACPI_TYPE_BUFFER) != FWTS_OK)
> +		return;
> +
> +	if (obj->Buffer.Length != 64) {
> +		failed = true;
> +		fwts_failed(fw, LOG_LEVEL_CRITICAL,
> +			"Method_NIHBadBufferSize",
> +			"%s should return a buffer of 64 bytes, but "
> +			"instead just returned %" PRIu32,
> +			name, obj->Buffer.Length);
> +	}
> +
> +	data = (uint8_t*)obj->Buffer.Pointer;
> +	check_nvdimm_status(fw, name, (uint16_t) data[0], &failed);
> +	check_nvdimm_extended_status(fw, name, (uint16_t) data[2], 1, &failed);
> +
> +	if (!failed)
> +		fwts_method_passed_sane(fw, name, "buffer");
> +}
> +
> +static int method_test_NIH(fwts_framework *fw)
> +{
> +	ACPI_OBJECT arg0;
> +	char data[64];
> +	int result;
> +	int i, j;
> +
> +	memset(data, 0, sizeof(data));
> +	arg0.Type = ACPI_TYPE_BUFFER;
> +	arg0.Buffer.Length = 64;
> +	arg0.Buffer.Pointer = (void *)data;
> +
> +	/* not permanent (j = 0) and permanent (j = 1) errors  */
> +	for (j = 0; j <= 1; j++) {
> +		/* inject (i = 1) and clear (i = 2) errors */
> +		for (i = 1; i <= 2; i++) {
> +			data[0] = i;
> +			data[4] = 3;
> +			data[5] = 7;
> +			data[6] = 7;
> +			data[8] = j;
> +
> +			result = method_evaluate_method(fw, METHOD_OPTIONAL,
> +				"_NIH", &arg0, 1, method_test_NIH_return, NULL);
> +
> +			if (result != FWTS_OK)
> +				return result;
> +		}
> +	}
> +
> +	return FWTS_OK;
> +}
> +
> +static void method_test_NIG_return(
> +	fwts_framework *fw,
> +	char *name,
> +	ACPI_BUFFER *buf,
> +	ACPI_OBJECT *obj,
> +	void *private)
> +{
> +	bool failed = false;
> +	uint8_t *data;
> +
> +	FWTS_UNUSED(private);
> +
> +	if (fwts_method_check_type(fw, name, buf, ACPI_TYPE_BUFFER) != FWTS_OK)
> +		return;
> +
> +	if (obj->Buffer.Length != 64) {
> +		failed = true;
> +		fwts_failed(fw, LOG_LEVEL_CRITICAL,
> +			"Method_NIGBadBufferSize",
> +			"%s should return a buffer of 64 bytes, but "
> +			"instead just returned %" PRIu32,
> +			name, obj->Buffer.Length);
> +	}
> +
> +	data = (uint8_t*)obj->Buffer.Pointer;
> +	check_nvdimm_status(fw, name, (uint16_t)data[0], &failed);
> +	check_nvdimm_extended_status(fw, name, (uint16_t)data[2], 0, &failed);
> +	fwts_acpi_reserved_bits_check(fw, "_NIG", "Validation Flags", (uint16_t) data[4], sizeof(uint16_t), 2, 15, &failed);
> +
> +	/* Injected Health Status Errors [2..7], [11.15], [19..31] are reserved */
> +	fwts_acpi_reserved_bits_check(fw, "_NIG", "Injected Health Status Errors", (uint32_t) data[6], sizeof(uint32_t), 2, 7, &failed);
> +	fwts_acpi_reserved_bits_check(fw, "_NIG", "Injected Health Status Errors", (uint32_t) data[6], sizeof(uint32_t), 11, 15, &failed);
> +	fwts_acpi_reserved_bits_check(fw, "_NIG", "Injected Health Status Errors", (uint32_t) data[6], sizeof(uint32_t), 19, 31, &failed);
> +
> +	fwts_acpi_reserved_bits_check(fw, "_NIG", "Health Status Attributes of Injected Errors", (uint32_t) data[8], sizeof(uint32_t), 1, 31, &failed);
> +
> +	if (!failed)
> +		fwts_method_passed_sane(fw, name, "buffer");
> +}
> +
> +static int method_test_NIG(fwts_framework *fw)
> +{
> +	return method_evaluate_method(fw, METHOD_OPTIONAL,
> +		"_NIG", NULL, 0, method_test_NIG_return, NULL);
> +}
>  
>  /*
>   * Section 10.1 Smart Battery
> @@ -5896,6 +6175,13 @@ static fwts_framework_minor_test method_tests[] = {
>  	{ method_test_TIP, "Test _TIP (Expired Timer Wake Policy)." },
>  	{ method_test_TIV, "Test _TIV (Timer Values)." },
>  
> +	/* Section 9.20 NVDIMM Devices */
> +	{ method_test_NBS, "Test _NBS (NVDIMM Boot Status)." },
> +	{ method_test_NCH, "Test _NCH (NVDIMM Current Health Information)." },
> +	{ method_test_NIC, "Test _NIC (NVDIMM Health Error Injection Capabilities)." },
> +	{ method_test_NIH, "Test _NIH (NVDIMM Inject/Clear Health Errors)." },
> +	{ method_test_NIG, "Test _NIG (NVDIMM Inject Health Error Status)." },
> +
>  	/* Section 10.1 Smart Battery */
>  
>  	{ method_test_SBS, "Test _SBS (Smart Battery Subsystem)." },
>

Patch

diff --git a/src/acpi/method/method.c b/src/acpi/method/method.c
index 654112d9..f117d91d 100644
--- a/src/acpi/method/method.c
+++ b/src/acpi/method/method.c
@@ -138,6 +138,11 @@ 
  * _MSG 	 Y
  * _MSM 	 N
  * _MTL 	 Y
+ * _NBS 	 Y
+ * _NCH 	 Y
+ * _NIC 	 Y
+ * _NIH 	 Y
+ * _NIG 	 Y
  * _NTT 	 Y
  * _OFF 	 Y
  * _ON_ 	 Y
@@ -3574,6 +3579,280 @@  static int method_test_TIV(fwts_framework *fw)
 		"_TIV", arg, 1, fwts_method_test_integer_return, NULL);
 }
 
+/*
+ * Section 9.20 NVDIMM Devices
+ */
+static void check_nvdimm_status(
+	fwts_framework *fw,
+	char *name,
+	uint16_t status,
+	bool *failed)
+{
+	if (status > 6) {
+		*failed = true;
+		fwts_failed(fw, LOG_LEVEL_MEDIUM,
+			"MethodBadStatus",
+			"%s: Expected Status to be 0..6, got %" PRIx16,
+			name, status);
+	}
+}
+
+static void check_nvdimm_extended_status(
+	fwts_framework *fw,
+	char *name,
+	uint16_t ext_status,
+	uint16_t expected,
+	bool *failed)
+{
+	if (ext_status != expected) {
+		*failed = true;
+		fwts_failed(fw, LOG_LEVEL_MEDIUM,
+			"MethodBadExtendedStatus",
+			"%s: Expected Extended Status to be %" PRIx16
+			", got %" PRIx16, name, expected, ext_status);
+	}
+}
+
+static void method_test_NBS_return(
+	fwts_framework *fw,
+	char *name,
+	ACPI_BUFFER *buf,
+	ACPI_OBJECT *obj,
+	void *private)
+{
+	bool failed = false;
+	uint8_t *data;
+
+	FWTS_UNUSED(private);
+
+	if (fwts_method_check_type(fw, name, buf, ACPI_TYPE_BUFFER) != FWTS_OK)
+		return;
+
+	if (obj->Buffer.Length != 64) {
+		failed = true;
+		fwts_failed(fw, LOG_LEVEL_CRITICAL,
+			"Method_NBSBadBufferSize",
+			"%s should return a buffer of 64 bytes, but "
+			"instead just returned %" PRIu32,
+			name, obj->Buffer.Length);
+	}
+
+	data = (uint8_t*)obj->Buffer.Pointer;
+	check_nvdimm_status(fw, name, (uint16_t) data[0], &failed);
+	check_nvdimm_extended_status(fw, name, (uint16_t) data[2], 0, &failed);
+	fwts_acpi_reserved_bits_check(fw, "_NBS", "Validation Flags", (uint16_t) data[4], sizeof(uint16_t), 1, 15, &failed);
+
+	if (!failed)
+		fwts_method_passed_sane(fw, name, "buffer");
+}
+
+static int method_test_NBS(fwts_framework *fw)
+{
+	return method_evaluate_method(fw, METHOD_OPTIONAL,
+		"_NBS", NULL, 0, method_test_NBS_return, NULL);
+}
+
+static void method_test_NCH_return(
+	fwts_framework *fw,
+	char *name,
+	ACPI_BUFFER *buf,
+	ACPI_OBJECT *obj,
+	void *private)
+{
+	bool failed = false;
+	uint8_t *data;
+
+	FWTS_UNUSED(private);
+
+	if (fwts_method_check_type(fw, name, buf, ACPI_TYPE_BUFFER) != FWTS_OK)
+		return;
+
+	if (obj->Buffer.Length != 64) {
+		failed = true;
+		fwts_failed(fw, LOG_LEVEL_CRITICAL,
+			"Method_NCHBadBufferSize",
+			"%s should return a buffer of 64 bytes, but "
+			"instead just returned %" PRIu32,
+			name, obj->Buffer.Length);
+	}
+
+	data = (uint8_t*)obj->Buffer.Pointer;
+	check_nvdimm_status(fw, name, (uint16_t) data[0], &failed);
+	check_nvdimm_extended_status(fw, name, (uint16_t) data[2], 0, &failed);
+	fwts_acpi_reserved_bits_check(fw, "_NCH", "Validation Flags", (uint16_t) data[4], sizeof(uint16_t), 2, 15, &failed);
+
+	/* Health Status Flags [2..7], [11.15], [19..31] are reserved */
+	fwts_acpi_reserved_bits_check(fw, "_NCH", "Health Status Flags", (uint32_t) data[6], sizeof(uint32_t), 2, 7, &failed);
+	fwts_acpi_reserved_bits_check(fw, "_NCH", "Health Status Flags", (uint32_t) data[6], sizeof(uint32_t), 11, 15, &failed);
+	fwts_acpi_reserved_bits_check(fw, "_NCH", "Health Status Flags", (uint32_t) data[6], sizeof(uint32_t), 19, 31, &failed);
+
+	fwts_acpi_reserved_bits_check(fw, "_NCH", "Health Status Attributes", (uint32_t) data[10], sizeof(uint32_t), 1, 31, &failed);
+
+	if (!failed)
+		fwts_method_passed_sane(fw, name, "buffer");
+}
+
+static int method_test_NCH(fwts_framework *fw)
+{
+	return method_evaluate_method(fw, METHOD_OPTIONAL,
+		"_NCH", NULL, 0, method_test_NCH_return, NULL);
+}
+
+static void method_test_NIC_return(
+	fwts_framework *fw,
+	char *name,
+	ACPI_BUFFER *buf,
+	ACPI_OBJECT *obj,
+	void *private)
+{
+	bool failed = false;
+	uint8_t *data;
+
+	FWTS_UNUSED(private);
+
+	if (fwts_method_check_type(fw, name, buf, ACPI_TYPE_BUFFER) != FWTS_OK)
+		return;
+
+	if (obj->Buffer.Length != 64) {
+		failed = true;
+		fwts_failed(fw, LOG_LEVEL_CRITICAL,
+			"Method_NICBadBufferSize",
+			"%s should return a buffer of 64 bytes, but "
+			"instead just returned %" PRIu32,
+			name, obj->Buffer.Length);
+	}
+
+	data = (uint8_t*)obj->Buffer.Pointer;
+	check_nvdimm_status(fw, name, (uint16_t)data[0], &failed);
+	check_nvdimm_extended_status(fw, name, (uint16_t)data[2], 0, &failed);
+
+	/* Health Error Injection Capabilities [2..7], [11.15], [19..31] are reserved */
+	fwts_acpi_reserved_bits_check(fw, "_NIC", "Health Error Injection Capabilities", (uint32_t) data[4], sizeof(uint32_t), 2, 7, &failed);
+	fwts_acpi_reserved_bits_check(fw, "_NIC", "Health Error Injection Capabilities", (uint32_t) data[4], sizeof(uint32_t), 11, 15, &failed);
+	fwts_acpi_reserved_bits_check(fw, "_NIC", "Health Error Injection Capabilities", (uint32_t) data[4], sizeof(uint32_t), 19, 31, &failed);
+
+	fwts_acpi_reserved_bits_check(fw, "_NIC", "Health Status Attributes Capabilities", (uint32_t) data[8], sizeof(uint32_t), 1, 31, &failed);
+
+	if (!failed)
+		fwts_method_passed_sane(fw, name, "buffer");
+}
+
+static int method_test_NIC(fwts_framework *fw)
+{
+	return method_evaluate_method(fw, METHOD_OPTIONAL,
+		"_NIC", NULL, 0, method_test_NIC_return, NULL);
+}
+
+static void method_test_NIH_return(
+	fwts_framework *fw,
+	char *name,
+	ACPI_BUFFER *buf,
+	ACPI_OBJECT *obj,
+	void *private)
+{
+	bool failed = false;
+	uint8_t *data;
+
+	FWTS_UNUSED(private);
+
+	if (fwts_method_check_type(fw, name, buf, ACPI_TYPE_BUFFER) != FWTS_OK)
+		return;
+
+	if (obj->Buffer.Length != 64) {
+		failed = true;
+		fwts_failed(fw, LOG_LEVEL_CRITICAL,
+			"Method_NIHBadBufferSize",
+			"%s should return a buffer of 64 bytes, but "
+			"instead just returned %" PRIu32,
+			name, obj->Buffer.Length);
+	}
+
+	data = (uint8_t*)obj->Buffer.Pointer;
+	check_nvdimm_status(fw, name, (uint16_t) data[0], &failed);
+	check_nvdimm_extended_status(fw, name, (uint16_t) data[2], 1, &failed);
+
+	if (!failed)
+		fwts_method_passed_sane(fw, name, "buffer");
+}
+
+static int method_test_NIH(fwts_framework *fw)
+{
+	ACPI_OBJECT arg0;
+	char data[64];
+	int result;
+	int i, j;
+
+	memset(data, 0, sizeof(data));
+	arg0.Type = ACPI_TYPE_BUFFER;
+	arg0.Buffer.Length = 64;
+	arg0.Buffer.Pointer = (void *)data;
+
+	/* not permanent (j = 0) and permanent (j = 1) errors  */
+	for (j = 0; j <= 1; j++) {
+		/* inject (i = 1) and clear (i = 2) errors */
+		for (i = 1; i <= 2; i++) {
+			data[0] = i;
+			data[4] = 3;
+			data[5] = 7;
+			data[6] = 7;
+			data[8] = j;
+
+			result = method_evaluate_method(fw, METHOD_OPTIONAL,
+				"_NIH", &arg0, 1, method_test_NIH_return, NULL);
+
+			if (result != FWTS_OK)
+				return result;
+		}
+	}
+
+	return FWTS_OK;
+}
+
+static void method_test_NIG_return(
+	fwts_framework *fw,
+	char *name,
+	ACPI_BUFFER *buf,
+	ACPI_OBJECT *obj,
+	void *private)
+{
+	bool failed = false;
+	uint8_t *data;
+
+	FWTS_UNUSED(private);
+
+	if (fwts_method_check_type(fw, name, buf, ACPI_TYPE_BUFFER) != FWTS_OK)
+		return;
+
+	if (obj->Buffer.Length != 64) {
+		failed = true;
+		fwts_failed(fw, LOG_LEVEL_CRITICAL,
+			"Method_NIGBadBufferSize",
+			"%s should return a buffer of 64 bytes, but "
+			"instead just returned %" PRIu32,
+			name, obj->Buffer.Length);
+	}
+
+	data = (uint8_t*)obj->Buffer.Pointer;
+	check_nvdimm_status(fw, name, (uint16_t)data[0], &failed);
+	check_nvdimm_extended_status(fw, name, (uint16_t)data[2], 0, &failed);
+	fwts_acpi_reserved_bits_check(fw, "_NIG", "Validation Flags", (uint16_t) data[4], sizeof(uint16_t), 2, 15, &failed);
+
+	/* Injected Health Status Errors [2..7], [11.15], [19..31] are reserved */
+	fwts_acpi_reserved_bits_check(fw, "_NIG", "Injected Health Status Errors", (uint32_t) data[6], sizeof(uint32_t), 2, 7, &failed);
+	fwts_acpi_reserved_bits_check(fw, "_NIG", "Injected Health Status Errors", (uint32_t) data[6], sizeof(uint32_t), 11, 15, &failed);
+	fwts_acpi_reserved_bits_check(fw, "_NIG", "Injected Health Status Errors", (uint32_t) data[6], sizeof(uint32_t), 19, 31, &failed);
+
+	fwts_acpi_reserved_bits_check(fw, "_NIG", "Health Status Attributes of Injected Errors", (uint32_t) data[8], sizeof(uint32_t), 1, 31, &failed);
+
+	if (!failed)
+		fwts_method_passed_sane(fw, name, "buffer");
+}
+
+static int method_test_NIG(fwts_framework *fw)
+{
+	return method_evaluate_method(fw, METHOD_OPTIONAL,
+		"_NIG", NULL, 0, method_test_NIG_return, NULL);
+}
 
 /*
  * Section 10.1 Smart Battery
@@ -5896,6 +6175,13 @@  static fwts_framework_minor_test method_tests[] = {
 	{ method_test_TIP, "Test _TIP (Expired Timer Wake Policy)." },
 	{ method_test_TIV, "Test _TIV (Timer Values)." },
 
+	/* Section 9.20 NVDIMM Devices */
+	{ method_test_NBS, "Test _NBS (NVDIMM Boot Status)." },
+	{ method_test_NCH, "Test _NCH (NVDIMM Current Health Information)." },
+	{ method_test_NIC, "Test _NIC (NVDIMM Health Error Injection Capabilities)." },
+	{ method_test_NIH, "Test _NIH (NVDIMM Inject/Clear Health Errors)." },
+	{ method_test_NIG, "Test _NIG (NVDIMM Inject Health Error Status)." },
+
 	/* Section 10.1 Smart Battery */
 
 	{ method_test_SBS, "Test _SBS (Smart Battery Subsystem)." },