Skip to contentSkip to conversation

hw/i386: check if nvdimm is enabled before plugging

PATCH In review Haozhong Zhang 5 participants 10 messages Jan 13, 2017 – Jan 23, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/i386: check if nvdimm is enabled before plugging

The missing of 'nvdimm' in the machine type option '-M' means NVDIMM is disabled. QEMU should refuse to plug any NVDIMM device in this case and report the misconfiguration.

Message-Id: [email protected]
Message-Id: [email protected]

---
 hw/i386/pc.c | 5 +++++
 1 file changed, 5 insertions(+)
hw/i386/pc.c +5 -0
index 25e8586..3907609 100644
@@ -1715,6 +1715,11 @@ static void pc_dimm_plug(HotplugHandler *hotplug_dev,
     }
 
     if (object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM)) {
+        if (!pcms->acpi_nvdimm_state.is_enabled) {
+            error_setg(&local_err,
+                       "nvdimm is not enabled: missing 'nvdimm' in '-M'");
+            goto out;
+        }
         nvdimm_plug(&pcms->acpi_nvdimm_state);
     }
 
Signature · 1 line
2.10.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 3 lines · Haozhong Zhang

The missing of 'nvdimm' in the machine type option '-M' means NVDIMM is disabled. QEMU should refuse to plug any NVDIMM device in this case and report the misconfiguration.

Thanks for your fix.

#2 lore raw
In reply to Haozhong Zhang
Quoted 17 lines · Haozhong Zhang

The missing of 'nvdimm' in the machine type option '-M' means NVDIMM is disabled. QEMU should refuse to plug any NVDIMM device in this case and report the misconfiguration.

Message-Id: [email protected]
Message-Id: [email protected]

---
 hw/i386/pc.c | 5 +++++
 1 file changed, 5 insertions(+)
hw/i386/pc.c +0 -0
index 25e8586..3907609 100644

hw/i386/pc.c static void pc_dimm_plug(HotplugHandler *hotplug_dev, · line 1722

Quoted 8 lines
hw/i386/pc.c +5 -0
@@ -1715,6 +1715,11 @@ static void pc_dimm_plug(HotplugHandler *hotplug_dev,
     }
 
     if (object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM)) {
+        if (!pcms->acpi_nvdimm_state.is_enabled) {
+            error_setg(&local_err,
+                       "nvdimm is not enabled: missing 'nvdimm' in '-M'");
+            goto out;
+        }

A warning is definitely useful to notify users of a possible configuration error.

I wonder what happens when you plug an NVDIMM into a motherboard where the firmware lacks support. Does it:
* Refuse to boot?
* Treat the DIMM as regular RAM?
* Boot but the DIMM will not be used by firmware and kernel?

QEMU should act the same way as real hardware.

Stefan

#3 lore raw
Quoted 20 lines · Stefan Hajnoczi
Quoted 19 lines · Haozhong Zhang

The missing of 'nvdimm' in the machine type option '-M' means NVDIMM is disabled. QEMU should refuse to plug any NVDIMM device in this case and report the misconfiguration.

Message-Id: [email protected]
Message-Id: [email protected]

---
 hw/i386/pc.c | 5 +++++
 1 file changed, 5 insertions(+)
hw/i386/pc.c +0 -0
index 25e8586..3907609 100644
@@ -1715,6 +1715,11 @@ static void pc_dimm_plug(HotplugHandler *hotplug_dev,
     }
 
Quoted 9 lines

hw/i386/pc.c static void pc_dimm_plug(HotplugHandler *hotplug_dev, · line 1722

Quoted 6 lines
hw/i386/pc.c +5 -0
     if (object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM)) {
+        if (!pcms->acpi_nvdimm_state.is_enabled) {
+            error_setg(&local_err,
+                       "nvdimm is not enabled: missing 'nvdimm' in '-M'");
+            goto out;
+        }

A warning is definitely useful to notify users of a possible configuration error.

If NVDIMM is plugged at boot time, QEMU with this patch will stop and report a message like
qemu-system-x86_64: -device nvdimm,...: nvdimm is not enabled: missing 'nvdimm' in '-M'

If NVDIMM is plugged via 'device_add' command, QEMU with this patch will report a warning message
nvdimm is not enabled: missing 'nvdimm' in '-M'
and continue to run w/o plugging this device.

Quoted 6 lines

I wonder what happens when you plug an NVDIMM into a motherboard where the firmware lacks support. Does it:
* Refuse to boot?
* Treat the DIMM as regular RAM?
* Boot but the DIMM will not be used by firmware and kernel?

Good question. Guangrong, any idea?

Thanks,
Haozhong

Quoted 4 lines

QEMU should act the same way as real hardware.

Stefan

#4 lore raw
In reply to Stefan Hajnoczi
Quoted 30 lines · Stefan Hajnoczi
Quoted 17 lines · Haozhong Zhang

The missing of 'nvdimm' in the machine type option '-M' means NVDIMM is disabled. QEMU should refuse to plug any NVDIMM device in this case and report the misconfiguration.

Message-Id: [email protected]
Message-Id: [email protected]

---
 hw/i386/pc.c | 5 +++++
 1 file changed, 5 insertions(+)
hw/i386/pc.c +0 -0
index 25e8586..3907609 100644

hw/i386/pc.c static void pc_dimm_plug(HotplugHandler *hotplug_dev, · line 1722

Quoted 8 lines
hw/i386/pc.c +5 -0
@@ -1715,6 +1715,11 @@ static void pc_dimm_plug(HotplugHandler *hotplug_dev,
     }
 
     if (object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM)) {
+        if (!pcms->acpi_nvdimm_state.is_enabled) {
+            error_setg(&local_err,
+                       "nvdimm is not enabled: missing 'nvdimm' in '-M'");
+            goto out;
+        }

A warning is definitely useful to notify users of a possible configuration error.

Quoted 7 lines

I wonder what happens when you plug an NVDIMM into a motherboard where the firmware lacks support. Does it:
* Refuse to boot?
* Treat the DIMM as regular RAM?
* Boot but the DIMM will not be used by firmware and kernel?

QEMU should act the same way as real hardware.

If real hardware behavior is not useful in any way (e.g. first and third options above), is there a good reason for QEMU to not implement an additional safety mechanism preventing NVDIMM from being connected to a machine that doesn't support it?

Signature · 1 line
Eduardo
#5 lore raw
Quoted 37 lines · Eduardo Habkost
Quoted 36 lines · Stefan Hajnoczi
Quoted 17 lines · Haozhong Zhang

The missing of 'nvdimm' in the machine type option '-M' means NVDIMM is disabled. QEMU should refuse to plug any NVDIMM device in this case and report the misconfiguration.

Message-Id: [email protected]
Message-Id: [email protected]

---
 hw/i386/pc.c | 5 +++++
 1 file changed, 5 insertions(+)
hw/i386/pc.c +0 -0
index 25e8586..3907609 100644

hw/i386/pc.c static void pc_dimm_plug(HotplugHandler *hotplug_dev, · line 1722

Quoted 8 lines
hw/i386/pc.c +5 -0
@@ -1715,6 +1715,11 @@ static void pc_dimm_plug(HotplugHandler *hotplug_dev,
     }
 
     if (object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM)) {
+        if (!pcms->acpi_nvdimm_state.is_enabled) {
+            error_setg(&local_err,
+                       "nvdimm is not enabled: missing 'nvdimm' in '-M'");
+            goto out;
+        }

A warning is definitely useful to notify users of a possible configuration error.

I wonder what happens when you plug an NVDIMM into a motherboard where the firmware lacks support. Does it:
* Refuse to boot?
* Treat the DIMM as regular RAM?
* Boot but the DIMM will not be used by firmware and kernel?

Quoted 7 lines
Quoted 1 line

QEMU should act the same way as real hardware.

If real hardware behavior is not useful in any way (e.g. first and third options above), is there a good reason for QEMU to not implement an additional safety mechanism preventing NVDIMM from being connected to a machine that doesn't support it?

Yes. i agree with Eduardo.

For the real hardware the behavior may be different between vendors, we are asking our HW people to check what will happen on Intel's hardware under this case.

Thanks!

#6 lore raw
Quoted 48 lines · Xiao Guangrong
Quoted 37 lines · Eduardo Habkost
Quoted 36 lines · Stefan Hajnoczi
Quoted 17 lines · Haozhong Zhang

The missing of 'nvdimm' in the machine type option '-M' means NVDIMM is disabled. QEMU should refuse to plug any NVDIMM device in this case and report the misconfiguration.

Message-Id: [email protected]
Message-Id: [email protected]

---
 hw/i386/pc.c | 5 +++++
 1 file changed, 5 insertions(+)
hw/i386/pc.c +0 -0
index 25e8586..3907609 100644

hw/i386/pc.c static void pc_dimm_plug(HotplugHandler *hotplug_dev, · line 1722

Quoted 8 lines
hw/i386/pc.c +5 -0
@@ -1715,6 +1715,11 @@ static void pc_dimm_plug(HotplugHandler *hotplug_dev,
     }
 
     if (object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM)) {
+        if (!pcms->acpi_nvdimm_state.is_enabled) {
+            error_setg(&local_err,
+                       "nvdimm is not enabled: missing 'nvdimm' in '-M'");
+            goto out;
+        }

A warning is definitely useful to notify users of a possible configuration error.

I wonder what happens when you plug an NVDIMM into a motherboard where the firmware lacks support. Does it:
* Refuse to boot?
* Treat the DIMM as regular RAM?
* Boot but the DIMM will not be used by firmware and kernel?

Quoted 7 lines
Quoted 1 line

QEMU should act the same way as real hardware.

If real hardware behavior is not useful in any way (e.g. first and third options above), is there a good reason for QEMU to not implement an additional safety mechanism preventing NVDIMM from being connected to a machine that doesn't support it?

Quoted 5 lines

Yes. i agree with Eduardo.

For the real hardware the behavior may be different between vendors, we are asking our HW people to check what will happen on Intel's hardware under this case.

Let's find out what real hardware/firmware does. I guess it's the Intel MRC component that handles memory initialization.

Stefan

#7 lore raw
Quoted 47 lines · Stefan Hajnoczi
Quoted 46 lines · Xiao Guangrong
Quoted 44 lines · Eduardo Habkost
Quoted 30 lines · Stefan Hajnoczi
Quoted 17 lines · Haozhong Zhang

The missing of 'nvdimm' in the machine type option '-M' means NVDIMM is disabled. QEMU should refuse to plug any NVDIMM device in this case and report the misconfiguration.

Message-Id: [email protected]
Message-Id: [email protected]

---
 hw/i386/pc.c | 5 +++++
 1 file changed, 5 insertions(+)
hw/i386/pc.c +0 -0
index 25e8586..3907609 100644

hw/i386/pc.c static void pc_dimm_plug(HotplugHandler *hotplug_dev, · line 1722

Quoted 8 lines
hw/i386/pc.c +5 -0
@@ -1715,6 +1715,11 @@ static void pc_dimm_plug(HotplugHandler *hotplug_dev,
     }
 
     if (object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM)) {
+        if (!pcms->acpi_nvdimm_state.is_enabled) {
+            error_setg(&local_err,
+                       "nvdimm is not enabled: missing 'nvdimm' in '-M'");
+            goto out;
+        }

A warning is definitely useful to notify users of a possible configuration error.

Quoted 7 lines

I wonder what happens when you plug an NVDIMM into a motherboard where the firmware lacks support. Does it:
* Refuse to boot?
* Treat the DIMM as regular RAM?
* Boot but the DIMM will not be used by firmware and kernel?

QEMU should act the same way as real hardware.

If real hardware behavior is not useful in any way (e.g. first and third options above), is there a good reason for QEMU to not implement an additional safety mechanism preventing NVDIMM from being connected to a machine that doesn't support it?

Quoted 9 lines
Quoted 5 lines

Yes. i agree with Eduardo.

For the real hardware the behavior may be different between vendors, we are asking our HW people to check what will happen on Intel's hardware under this case.

Let's find out what real hardware/firmware does. I guess it's the Intel MRC component that handles memory initialization.

The behavior of NVDIMM on unsupported platform (HW/FW) is vendor specific. For some vendors, it's undefined and the platform may do anything (e.g. the three points Stefan listed above). Thus, I think QEMU is free to choose the implementation. Aborting QEMU (i.e. refusing to boot) is the easiest one.

Haozhong

Reviewed-by
#8 lore raw
Quoted 58 lines · Haozhong Zhang
Quoted 47 lines · Stefan Hajnoczi
Quoted 46 lines · Xiao Guangrong
Quoted 44 lines · Eduardo Habkost
Quoted 30 lines · Stefan Hajnoczi
Quoted 17 lines · Haozhong Zhang

The missing of 'nvdimm' in the machine type option '-M' means NVDIMM is disabled. QEMU should refuse to plug any NVDIMM device in this case and report the misconfiguration.

Message-Id: [email protected]
Message-Id: [email protected]

---
 hw/i386/pc.c | 5 +++++
 1 file changed, 5 insertions(+)
hw/i386/pc.c +0 -0
index 25e8586..3907609 100644

hw/i386/pc.c static void pc_dimm_plug(HotplugHandler *hotplug_dev, · line 1722

Quoted 8 lines
hw/i386/pc.c +5 -0
@@ -1715,6 +1715,11 @@ static void pc_dimm_plug(HotplugHandler *hotplug_dev,
     }
 
     if (object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM)) {
+        if (!pcms->acpi_nvdimm_state.is_enabled) {
+            error_setg(&local_err,
+                       "nvdimm is not enabled: missing 'nvdimm' in '-M'");
+            goto out;
+        }

A warning is definitely useful to notify users of a possible configuration error.

Quoted 7 lines

I wonder what happens when you plug an NVDIMM into a motherboard where the firmware lacks support. Does it:
* Refuse to boot?
* Treat the DIMM as regular RAM?
* Boot but the DIMM will not be used by firmware and kernel?

QEMU should act the same way as real hardware.

If real hardware behavior is not useful in any way (e.g. first and third options above), is there a good reason for QEMU to not implement an additional safety mechanism preventing NVDIMM from being connected to a machine that doesn't support it?

Quoted 9 lines
Quoted 5 lines

Yes. i agree with Eduardo.

For the real hardware the behavior may be different between vendors, we are asking our HW people to check what will happen on Intel's hardware under this case.

Let's find out what real hardware/firmware does. I guess it's the Intel MRC component that handles memory initialization.

Quoted 5 lines

The behavior of NVDIMM on unsupported platform (HW/FW) is vendor specific. For some vendors, it's undefined and the platform may do anything (e.g. the three points Stefan listed above). Thus, I think QEMU is free to choose the implementation. Aborting QEMU (i.e. refusing to boot) is the easiest one.

I agree.

Signature · 1 line
Eduardo
Reviewed-by on v1 1/1
#9 lore raw
In reply to Haozhong Zhang
Quoted 11 lines · Haozhong Zhang

The missing of 'nvdimm' in the machine type option '-M' means NVDIMM is disabled. QEMU should refuse to plug any NVDIMM device in this case and report the misconfiguration.

Message-Id: [email protected]
Message-Id: [email protected]

---
 hw/i386/pc.c | 5 +++++
 1 file changed, 5 insertions(+)

Michael: Please add Haozhong's comment to the commit description when merging:

"The behavior of NVDIMM on unsupported platform (HW/FW) is vendor specific. For some vendors, it's undefined and the platform may do anything. Thus, I think QEMU is free to choose the implementation. Aborting QEMU (i.e. refusing to boot) is the easiest one."

This way we have a record that the behavior is okay according to the spec and why we chose this option.