Skip to contentSkip to conversation

audio/hda: fix guest triggerable assert

PATCH Superseded Gerd Hoffmann 3 participants 4 messages Nov 22, 2018 – Nov 23, 2018

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 audio/hda: fix guest triggerable assert

Guest writes to a readonly register trigger the assert in intel_hda_reg_write(). Add a check and just ignore them.

---
 hw/audio/intel-hda.c | 4 ++++
 1 file changed, 4 insertions(+)
hw/audio/intel-hda.c +4 -0
index 23a2cf6484..066532713c 100644
@@ -929,6 +929,10 @@ static void intel_hda_reg_write(IntelHDAState *d, const IntelHDAReg *reg, uint32
     if (!reg) {
         return;
     }
+    if (!reg->wmask) {
+        /* read-only register */
+        return;
+    }
 
     if (d->debug) {
         time_t now = time(NULL);
Signature · 1 line
2.9.3
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · * Gerd Hoffmann ([email protected]) wrote:

Guest writes to a readonly register trigger the assert in intel_hda_reg_write(). Add a check and just ignore them.

Does make you wonder:
a) Why the guest was writing to a read-only register
b) Wth it only did it in the weird combination of devices tested.

Quoted 23 lines
---
 hw/audio/intel-hda.c | 4 ++++
 1 file changed, 4 insertions(+)
hw/audio/intel-hda.c +4 -0
index 23a2cf6484..066532713c 100644
@@ -929,6 +929,10 @@ static void intel_hda_reg_write(IntelHDAState *d, const IntelHDAReg *reg, uint32
     if (!reg) {
         return;
     }
+    if (!reg->wmask) {
+        /* read-only register */
+        return;
+    }
 
     if (d->debug) {
         time_t now = time(NULL);
Signature · 1 line
2.9.3

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

#2 lore raw
Quoted 11 lines · Dr. David Alan Gilbert
Quoted 5 lines · * Gerd Hoffmann ([email protected]) wrote:

Guest writes to a readonly register trigger the assert in intel_hda_reg_write(). Add a check and just ignore them.

Does make you wonder:
a) Why the guest was writing to a read-only register
b) Wth it only did it in the weird combination of devices tested.

Note that we also have pci hotplug involved. Probably a bug in the guest, maybe due to a register access landing at the wrong device while reshuffling the bars or something like that.

cheers,
Gerd

Reviewed-by on v1 1/1
#3 lore raw
In reply to Gerd Hoffmann

Hi Gerd,

Quoted 2 lines · Gerd Hoffmann

Guest writes to a readonly register trigger the assert in intel_hda_reg_write(). Add a check and just ignore them.

Is this 3.1 material? It seems to apply.

Quoted 12 lines
---
 hw/audio/intel-hda.c | 4 ++++
 1 file changed, 4 insertions(+)
hw/audio/intel-hda.c +0 -0
index 23a2cf6484..066532713c 100644

hw/audio/intel-hda.c static void intel_hda_reg_write(IntelHDAState *d, const IntelHDAReg *reg, uint32 · line 933

Quoted 5 lines
hw/audio/intel-hda.c +2 -0
@@ -929,6 +929,10 @@ static void intel_hda_reg_write(IntelHDAState *d, const IntelHDAReg *reg, uint32
     if (!reg) {
         return;
     }
+    if (!reg->wmask) {
+        /* read-only register */

Can you add:

qemu_log_mask(LOG_GUEST_ERROR,
"intel-hda: Register %s is read-only\n", reg->name);

Regardless:

Quoted 6 lines
hw/audio/intel-hda.c +2 -0
+        return;
+    }
 
     if (d->debug) {
         time_t now = time(NULL);