From patchwork Mon May 23 15:09:41 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 9132011 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CAAB560761 for ; Mon, 23 May 2016 15:18:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C119F28237 for ; Mon, 23 May 2016 15:18:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B5ABC2822B; Mon, 23 May 2016 15:18:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 448512822B for ; Mon, 23 May 2016 15:18:45 +0000 (UTC) Received: from localhost ([::1]:48835 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b4rcx-0000u6-VI for patchwork-qemu-devel@patchwork.kernel.org; Mon, 23 May 2016 11:18:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37516) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b4rUm-0002BM-93 for qemu-devel@nongnu.org; Mon, 23 May 2016 11:10:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b4rUg-00043D-3s for qemu-devel@nongnu.org; Mon, 23 May 2016 11:10:16 -0400 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]:36060) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b4rUf-00042b-PO for qemu-devel@nongnu.org; Mon, 23 May 2016 11:10:10 -0400 Received: by mail-wm0-x242.google.com with SMTP id q62so16004059wmg.3 for ; Mon, 23 May 2016 08:10:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=G4/PEAxO1K3fmNdkFdSAadQhDT15HyK6xtyk6EiUCxU=; b=teENCMidTBAWhytpQG8H8jbkWeqEmXU5WQ9apAdUVBYdn39gtx4Q8lu5JHZp1obCVF kCKl1znPNK+Q+bzKpE8+iCaNG254vPQPs5kAPCIMhQyIoZKzj2F/GF6eYYLD5Ca/58Ku 8jR8Zuo6w0td7bpA1w1eFwA4rUBJbsPSfODzk2xgcyKDwW39HKzVbKksxjNxmey/5Row wEhNkxKnw6nvpvtAxmJF/uY6tgUDF5OA8NaY62wIAFZYfzTNAFe+3WW8S4JV106ZZt20 O/o/QoO/Q7/IsiToLCA5g/uDzzTO3FIP+sbG7MCHvB/KWd3M/ikn/OKJRpdNxS7ceX6l sNTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=G4/PEAxO1K3fmNdkFdSAadQhDT15HyK6xtyk6EiUCxU=; b=fq11wP1OLqTt5M0gAAfeThaUAV9DE38r3gkGKbF2m1zWnhPuPUzmrULu2TUH1c+RSv Ojk2hgvWfsxo9CVKFazwynaUcqYCzHMcw6nFFj4DI200w1YHFpoBH074JHVY41sVoVlN 0pQe3wvW+bvd/6Q5JFBeta9v4TCUcnNuESJ8nn/Sa05NaNoDH6fvyDHOcYiwnTS58GVN a4gcV6HH5iiTYjb4X7YKf0Bs4/DiAZYrbCSjkv6kfSAm28rHfoL7aNfnjUb++UVksDu+ 3tqvK7iRSDW7/k9KmYePMhzruJRgPVJv8ixDe9lsEbqCq/vHDwHwy/MxyfpvbzAc2OgV iIbA== X-Gm-Message-State: AOPr4FUHGjNQD//d8uwECJIGuUNXprf0VSXqVaFZ+BzfrxL9DTNOEkvbOZ8QsyvN/dhaIw== X-Received: by 10.28.105.200 with SMTP id z69mr17893823wmh.78.1464016208871; Mon, 23 May 2016 08:10:08 -0700 (PDT) Received: from 640k.lan (dynamic-adsl-78-12-252-58.clienti.tiscali.it. [78.12.252.58]) by smtp.gmail.com with ESMTPSA id ac2sm19250359wjc.35.2016.05.23.08.10.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 May 2016 08:10:08 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 23 May 2016 17:09:41 +0200 Message-Id: <1464016199-43768-7-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1464016199-43768-1-git-send-email-pbonzini@redhat.com> References: <1464016199-43768-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::242 Subject: [Qemu-devel] [PULL 06/24] ioapic: keep RO bits for IOAPIC entry X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Xu Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Peter Xu Currently IOAPIC RO bits can be written. To be better aligned with hardware, we should let them read-only. Reviewed-by: Radim Krčmář Signed-off-by: Peter Xu Message-Id: <1462875682-1349-2-git-send-email-peterx@redhat.com> Signed-off-by: Paolo Bonzini --- 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 4f42b91..c27ee83 100644 --- a/hw/intc/ioapic.c +++ b/hw/intc/ioapic.c @@ -281,6 +281,7 @@ ioapic_mem_write(void *opaque, hwaddr addr, uint64_t val, default: index = (s->ioregsel - IOAPIC_REG_REDTBL_BASE) >> 1; if (index >= 0 && index < IOAPIC_NUM_PINS) { + uint64_t ro_bits = s->ioredtbl[index] & IOAPIC_RO_BITS; if (s->ioregsel & 1) { s->ioredtbl[index] &= 0xffffffff; s->ioredtbl[index] |= (uint64_t)val << 32; @@ -288,6 +289,9 @@ ioapic_mem_write(void *opaque, hwaddr addr, uint64_t val, s->ioredtbl[index] &= ~0xffffffffULL; s->ioredtbl[index] |= val; } + /* restore RO bits */ + s->ioredtbl[index] &= IOAPIC_RW_BITS; + s->ioredtbl[index] |= ro_bits; ioapic_service(s); } } diff --git a/include/hw/i386/ioapic_internal.h b/include/hw/i386/ioapic_internal.h index 797ed47..cab9e67 100644 --- a/include/hw/i386/ioapic_internal.h +++ b/include/hw/i386/ioapic_internal.h @@ -47,6 +47,11 @@ #define IOAPIC_LVT_DEST_MODE (1 << IOAPIC_LVT_DEST_MODE_SHIFT) #define IOAPIC_LVT_DELIV_MODE (7 << IOAPIC_LVT_DELIV_MODE_SHIFT) +/* 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