Skip to contentSkip to conversation

pc: restrict port92 register value to 2 bits

PATCH In review P J P 3 participants 3 messages Nov 2, 2017

lore
Share & tools
lore

P J P

author
#0 lore raw

PATCH 1/1 pc: restrict port92 register value to 2 bits

From: Prasad J Pandit <[email protected]>

Port 92 configuration register holds an 8-bit value. Of 8-bits, bits 0-1 are used and 2-7 are reserved. Restrict the supplied value to 2 bits.

---
 hw/i386/pc.c | 1 +
 1 file changed, 1 insertion(+)
hw/i386/pc.c +1 -0
index 05985d4927..883384a599 100644
@@ -515,6 +515,7 @@ static void port92_write(void *opaque, hwaddr addr, uint64_t val,
     Port92State *s = opaque;
     int oldval = s->outport;
 
+    val &= 0x03;
     DPRINTF("port92: write 0x%02" PRIx64 "\n", val);
     s->outport = val;
     qemu_set_irq(s->a20_out, (val >> 1) & 1);
Signature · 1 line
2.13.6
#1 lore raw
Quoted 5 lines · P J P

From: Prasad J Pandit <[email protected]>

Port 92 configuration register holds an 8-bit value. Of 8-bits, bits 0-1 are used and 2-7 are reserved. Restrict the supplied value to 2 bits.

This patch is not necessary. "Do nothing and just report back the value that was written" is an okay implementation of reserved bits.

Paolo

Quoted 19 lines
---
 hw/i386/pc.c | 1 +
 1 file changed, 1 insertion(+)
hw/i386/pc.c +1 -0
index 05985d4927..883384a599 100644
@@ -515,6 +515,7 @@ static void port92_write(void *opaque, hwaddr addr, uint64_t val,
     Port92State *s = opaque;
     int oldval = s->outport;
 
+    val &= 0x03;
     DPRINTF("port92: write 0x%02" PRIx64 "\n", val);
     s->outport = val;
     qemu_set_irq(s->a20_out, (val >> 1) & 1);
#2 lore raw

Hi Prasad,

Quoted 27 lines · Paolo Bonzini
Quoted 5 lines · P J P

From: Prasad J Pandit <[email protected]>

Port 92 configuration register holds an 8-bit value. Of 8-bits, bits 0-1 are used and 2-7 are reserved. Restrict the supplied value to 2 bits.

This patch is not necessary. "Do nothing and just report back the value that was written" is an okay implementation of reserved bits.

Paolo

Quoted 14 lines
---
 hw/i386/pc.c | 1 +
 1 file changed, 1 insertion(+)
hw/i386/pc.c +0 -0
index 05985d4927..883384a599 100644
@@ -515,6 +515,7 @@ static void port92_write(void *opaque, hwaddr addr, uint64_t val,
     Port92State *s = opaque;
     int oldval = s->outport;
 
Quoted 2 lines

hw/i386/pc.c static void port92_write(void *opaque, hwaddr addr, uint64_t val, · line 519

Quoted 2 lines
hw/i386/pc.c +1 -0
+    val &= 0x03;
     DPRINTF("port92: write 0x%02" PRIx64 "\n", val);

You might want to report a guest error instead:

        if (val & ~3) {
            qemu_log_mask(LOG_GUEST_ERROR,
                "port92: bits 2-7 are reserved "
                "(wrote 0x%02" PRIx64 ")\n", val);
        }
Quoted 2 lines
Quoted 2 lines
hw/i386/pc.c +0 -0
     s->outport = val;
     qemu_set_irq(s->a20_out, (val >> 1) & 1);