From patchwork Thu Sep 15 07:15:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Wanpeng Li X-Patchwork-Id: 9332891 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 2CF2E6077A for ; Thu, 15 Sep 2016 07:17:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1AC662933D for ; Thu, 15 Sep 2016 07:17:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0FC1829342; Thu, 15 Sep 2016 07:17:32 +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_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable 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 9488F2933D for ; Thu, 15 Sep 2016 07:17:31 +0000 (UTC) Received: from localhost ([::1]:60646 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bkQvK-0007L6-EP for patchwork-qemu-devel@patchwork.kernel.org; Thu, 15 Sep 2016 03:17:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33247) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bkQv2-0007L0-UC for qemu-devel@nongnu.org; Thu, 15 Sep 2016 03:17:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bkQuw-0003kV-TL for qemu-devel@nongnu.org; Thu, 15 Sep 2016 03:17:11 -0400 Received: from mail-pa0-f68.google.com ([209.85.220.68]:36188) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bkQuw-0003kA-M5 for qemu-devel@nongnu.org; Thu, 15 Sep 2016 03:17:06 -0400 Received: by mail-pa0-f68.google.com with SMTP id p2so1767577pap.3 for ; Thu, 15 Sep 2016 00:17:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Nc3qP5ZvYynxEtuUhdGxeygZ0cmY/3g3OnpRrDEcDcI=; b=jethOW2EG0QMCLpoXRul6zR3kXCzcZu6OF6fQ5TM/xKhIn+3ZfHTqlVb0nNkREhVf+ lkf1I9mw9YTv4G+gBEJ3jBvuUhCqGWrkQOyBOk9877cwzgvtCvNogi/BQQUAbuIJ9ZtP /kJnY7mW92/267t2QX1NGBJVooL5F71RIDnQr+SV+FbYh9uT2A/5q+XwQQy6jg2ft5b2 e20GjJlrrJxm1mK6DTlBwEf8EKo/98EHkcv40X4YZy/ykHmTLuAfkPPEnkOO6LFoh62y YsSRcbTMyT4btMWXBIfPx/kPldD04rGIRGSEKyw+ELMwOayArGMHYDgcsSE1Rx6md8+H Rl1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Nc3qP5ZvYynxEtuUhdGxeygZ0cmY/3g3OnpRrDEcDcI=; b=AsrfqSVjqQILbxZ2nu1DdZxhE7KMmw+W1OjLiGrTBDCgWFs9QgZTW9AbL2Aee5iyow xBgsgOW48N5UjHElpth/lMignRBSkrPd4ULcHeLdLxVKgeK9BGrbga1ehZVCcuXWbXJI Y62+XLuVBIlT0/3MhiieJiBXTuApmKccjPA16Hi/7XZiOrSlPYsWGloVjAU9VsOgnH67 1okRDGclzleJTAUw1KR25PCMjsNi2GBMCISJ0+Il6++4td9o+xNBmV4kPpGn3ACt7GIF Zc1eDpG+X0y2+3iiCfR5TaQp9qlNNaXx6sm5FGLB9BE58A8Ecod4xe63zvYSPYsZd/QV UxsQ== X-Gm-Message-State: AE9vXwN+wnOzcaufHB3I9EJHvH8TKPYmSRN+B1zu1ISZfx5KzDElNOq9QjISFDSr3AuqQw== X-Received: by 10.66.25.143 with SMTP id c15mr11875110pag.90.1473923766096; Thu, 15 Sep 2016 00:16:06 -0700 (PDT) Received: from kernel.kingsoft.cn ([114.255.44.132]) by smtp.gmail.com with ESMTPSA id bm8sm2539740pac.16.2016.09.15.00.16.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 15 Sep 2016 00:16:05 -0700 (PDT) From: Wanpeng Li X-Google-Original-From: Wanpeng Li To: linux-kernel@vger.kernel.org, qemu-devel@nongnu.org Date: Thu, 15 Sep 2016 15:15:59 +0800 Message-Id: <1473923759-13912-1-git-send-email-wanpeng.li@hotmail.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.220.68 Subject: [Qemu-devel] [PATCH v2] pc: apic: introduce APIC macro 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: Paolo Bonzini , "Michael S. Tsirkin" , Eduardo Habkost , Wanpeng Li , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Wanpeng Li Introduce a new APIC macro to replace APIC_COMMON macro in hw/intc/apic.c in order to capture access LAPIC in qemu even if LAPIC is emulated in kvm. Suggested-by: Paolo Bonzini Reviewed-by: Michael S. Tsirkin Cc: Paolo Bonzini Cc: Radim Krčmář Cc: Michael S. Tsirkin Cc: Eduardo Habkost Signed-off-by: Wanpeng Li --- v1 -> v2: * move the new APIC macro to apic.c * replace the occurrence of "apic" in apic.c by TYPE_APIC hw/intc/apic.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/hw/intc/apic.c b/hw/intc/apic.c index 45887d9..7bd1d27 100644 --- a/hw/intc/apic.c +++ b/hw/intc/apic.c @@ -39,6 +39,10 @@ static APICCommonState *local_apics[MAX_APICS + 1]; +#define TYPE_APIC "apic" +#define APIC(obj) \ + OBJECT_CHECK(APICCommonState, (obj), TYPE_APIC) + static void apic_set_irq(APICCommonState *s, int vector_num, int trigger_mode); static void apic_update_irq(APICCommonState *s); static void apic_get_delivery_bitmask(uint32_t *deliver_bitmask, @@ -163,7 +167,7 @@ static void apic_local_deliver(APICCommonState *s, int vector) void apic_deliver_pic_intr(DeviceState *dev, int level) { - APICCommonState *s = APIC_COMMON(dev); + APICCommonState *s = APIC(dev); if (level) { apic_local_deliver(s, APIC_LVT_LINT0); @@ -373,7 +377,7 @@ static void apic_update_irq(APICCommonState *s) void apic_poll_irq(DeviceState *dev) { - APICCommonState *s = APIC_COMMON(dev); + APICCommonState *s = APIC(dev); apic_sync_vapic(s, SYNC_FROM_VAPIC); apic_update_irq(s); @@ -479,7 +483,7 @@ static void apic_startup(APICCommonState *s, int vector_num) void apic_sipi(DeviceState *dev) { - APICCommonState *s = APIC_COMMON(dev); + APICCommonState *s = APIC(dev); cpu_reset_interrupt(CPU(s->cpu), CPU_INTERRUPT_SIPI); @@ -493,7 +497,7 @@ static void apic_deliver(DeviceState *dev, uint8_t dest, uint8_t dest_mode, uint8_t delivery_mode, uint8_t vector_num, uint8_t trigger_mode) { - APICCommonState *s = APIC_COMMON(dev); + APICCommonState *s = APIC(dev); uint32_t deliver_bitmask[MAX_APIC_WORDS]; int dest_shorthand = (s->icr[0] >> 18) & 3; APICCommonState *apic_iter; @@ -550,7 +554,7 @@ static bool apic_check_pic(APICCommonState *s) int apic_get_interrupt(DeviceState *dev) { - APICCommonState *s = APIC_COMMON(dev); + APICCommonState *s = APIC(dev); int intno; /* if the APIC is installed or enabled, we let the 8259 handle the @@ -584,7 +588,7 @@ int apic_get_interrupt(DeviceState *dev) int apic_accept_pic_intr(DeviceState *dev) { - APICCommonState *s = APIC_COMMON(dev); + APICCommonState *s = APIC(dev); uint32_t lvt0; if (!s) @@ -663,7 +667,7 @@ static uint32_t apic_mem_readl(void *opaque, hwaddr addr) if (!dev) { return 0; } - s = APIC_COMMON(dev); + s = APIC(dev); index = (addr >> 4) & 0xff; switch(index) { @@ -766,7 +770,7 @@ static void apic_mem_writel(void *opaque, hwaddr addr, uint32_t val) if (!dev) { return; } - s = APIC_COMMON(dev); + s = APIC(dev); trace_apic_mem_writel(addr, val); @@ -870,7 +874,7 @@ static const MemoryRegionOps apic_io_ops = { static void apic_realize(DeviceState *dev, Error **errp) { - APICCommonState *s = APIC_COMMON(dev); + APICCommonState *s = APIC(dev); if (s->id >= MAX_APICS) { error_setg(errp, "%s initialization failed. APIC ID %d is invalid", @@ -889,7 +893,7 @@ static void apic_realize(DeviceState *dev, Error **errp) static void apic_unrealize(DeviceState *dev, Error **errp) { - APICCommonState *s = APIC_COMMON(dev); + APICCommonState *s = APIC(dev); timer_del(s->timer); timer_free(s->timer); @@ -912,7 +916,7 @@ static void apic_class_init(ObjectClass *klass, void *data) } static const TypeInfo apic_info = { - .name = "apic", + .name = TYPE_APIC, .instance_size = sizeof(APICCommonState), .parent = TYPE_APIC_COMMON, .class_init = apic_class_init,