Received: from eggs.gnu.org ([2001:4830:134:3::10]:48274) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ay9x4-0004lF-8T for qemu-devel@nongnu.org; Wed, 04 May 2016 23:27:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ay9ws-0008BO-I3 for qemu-devel@nongnu.org; Wed, 04 May 2016 23:27:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54789) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ay9ws-00088h-Ci for qemu-devel@nongnu.org; Wed, 04 May 2016 23:27:34 -0400 From: Peter Xu Date: Thu, 5 May 2016 11:25:52 +0800 Message-Id: <1462418761-12714-18-git-send-email-peterx@redhat.com> In-Reply-To: <1462418761-12714-1-git-send-email-peterx@redhat.com> References: <1462418761-12714-1-git-send-email-peterx@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH v6 17/26] ioapic: keep RO bits for IOAPIC entry List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: imammedo@redhat.com, rth@twiddle.net, ehabkost@redhat.com, jasowang@redhat.com, marcel@redhat.com, mst@redhat.com, pbonzini@redhat.com, jan.kiszka@web.de, rkrcmar@redhat.com, alex.williamson@redhat.com, wexu@redhat.com, davidkiarie4@gmail.com, peterx@redhat.com Currently IOAPIC RO bits can be written. To be better aligned with hardware, we should let them read-only. Reviewed-by: Radim Kr=C4=8Dm=C3=A1=C5=99 Signed-off-by: Peter Xu --- hw/intc/ioapic.c | 4 ++++ include/hw/i386/ioapic_internal.h | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/hw/intc/ioapic.c b/hw/intc/ioapic.c index b41ab89..d7ebb5c 100644 --- a/hw/intc/ioapic.c +++ b/hw/intc/ioapic.c @@ -307,6 +307,7 @@ ioapic_mem_write(void *opaque, hwaddr addr, uint64_t = val, default: index =3D (s->ioregsel - IOAPIC_REG_REDTBL_BASE) >> 1; if (index >=3D 0 && index < IOAPIC_NUM_PINS) { + uint64_t ro_bits =3D s->ioredtbl[index] & IOAPIC_RO_BITS= ; if (s->ioregsel & 1) { s->ioredtbl[index] &=3D 0xffffffff; s->ioredtbl[index] |=3D (uint64_t)val << 32; @@ -314,6 +315,9 @@ ioapic_mem_write(void *opaque, hwaddr addr, uint64_t = val, s->ioredtbl[index] &=3D ~0xffffffffULL; s->ioredtbl[index] |=3D val; } + /* restore RO bits */ + s->ioredtbl[index] &=3D IOAPIC_RW_BITS; + s->ioredtbl[index] |=3D ro_bits; ioapic_service(s); } } diff --git a/include/hw/i386/ioapic_internal.h b/include/hw/i386/ioapic_i= nternal.h index d279f2d..31dafb3 100644 --- a/include/hw/i386/ioapic_internal.h +++ b/include/hw/i386/ioapic_internal.h @@ -48,6 +48,11 @@ #define IOAPIC_LVT_DEST_MODE (1 << IOAPIC_LVT_DEST_MODE_SHIFT= ) #define IOAPIC_LVT_DELIV_MODE (7 << IOAPIC_LVT_DELIV_MODE_SHIF= T) =20 +/* Bits that are read-only for IOAPIC entry */ +#define IOAPIC_RO_BITS (IOAPIC_LVT_REMOTE_IRR | \ + IOAPIC_LVT_DELIV_STATUS) +#define IOAPIC_RW_BITS (~(uint64_t)IOAPIC_RO_BITS) + #define IOAPIC_TRIGGER_EDGE 0 #define IOAPIC_TRIGGER_LEVEL 1 =20 --=20 2.4.11