From patchwork Thu Sep 15 00:43:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Wanpeng Li X-Patchwork-Id: 670176 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 ozlabs.org (Postfix) with ESMTPS id 3sZKTS58fvz9s9Y for ; Thu, 15 Sep 2016 10:45:47 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=O3TJJ1g8; dkim-atps=neutral Received: from localhost ([::1]:59357 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bkKoA-0001MR-1j for incoming@patchwork.ozlabs.org; Wed, 14 Sep 2016 20:45:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50822) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bkKnH-0000o6-Fs for qemu-devel@nongnu.org; Wed, 14 Sep 2016 20:44:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bkKnE-0002bS-G1 for qemu-devel@nongnu.org; Wed, 14 Sep 2016 20:44:47 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:35224) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bkKnE-0002bN-7g for qemu-devel@nongnu.org; Wed, 14 Sep 2016 20:44:44 -0400 Received: by mail-pf0-f195.google.com with SMTP id z84so1447079pfi.2 for ; Wed, 14 Sep 2016 17:44:44 -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=BbmLz71wxGJvlM3c9GmEYxYeerPNG8mB5zRkafN4d/4=; b=O3TJJ1g8yP6ry+aqLO7iF1Ihhh22LM0RVd2ojHBcBrZ8lt6UVnQGGJERM3hHlC3XuF TilpK3vmjt8a4/RImyRMd3rw/fcIdSx/ApB53F3zF9HKs0grv5TWvdvFz4/yHsVKHXg0 QnHwnb4eZDbhfTXzAmUbqjfq3j7ozElZ5qHtUofVadrIRrSOSdC9U3Spfy7vgldcmp1i kNQG6q9nsGkndEnss3NmC2Q7H+I/q3Y6VpwQOFdJZ85Pi7ITVS8qTd4MEzqoHsesC/v6 U9Wr8+LRJ3ueVxTXl4XsFSpVktHNMW6M3dbeNyQ7F9W6xw7v+INpGs7M+SQWaLycQ3A8 0qkQ== 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=BbmLz71wxGJvlM3c9GmEYxYeerPNG8mB5zRkafN4d/4=; b=a3WTOx8YxZJhOgb+KC09RW7mp5wMB7ZW5/XpJrNbmYUnH8jf+uKXK8HiA6SyQ6TwjT drVSgLnYkipzwQM3ZuR5ORfrehXwOhdDNhmPUz2CXGt8QdhkgD6oX7wx7SBuYy3WTxmI x+rdVjFPYtUhjViNwraKioWSmDkb+eBBHH2znECq+4+MrJl7kGVSY8RIUv0J6AjUR52k bm/tOgAZ+1VpqpKwyhlyM5A5Gtjshh7g6k4n8K9KYtrez15f9Y7UuIiSg515e4tFHD+h DqQvGJR0/TYFezld4YZZ097wQk2cbzc1sOgHYs+9FRhX3hoUXMl4Tu4buMfBJ+b8G4cK LJ0Q== X-Gm-Message-State: AE9vXwNM6yXXOIFD/Pslc35p1GhFJb0FesrU4poWLWhU5I23lx8n054RkToTRwlbCtQtRQ== X-Received: by 10.98.9.210 with SMTP id 79mr9773349pfj.33.1473900223440; Wed, 14 Sep 2016 17:43:43 -0700 (PDT) Received: from kernel.kingsoft.cn ([114.255.44.132]) by smtp.gmail.com with ESMTPSA id ps2sm521408pab.10.2016.09.14.17.43.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 Sep 2016 17:43:42 -0700 (PDT) From: Wanpeng Li X-Google-Original-From: Wanpeng Li To: kvm@vger.kernel.org, qemu-devel@nongnu.org Date: Thu, 15 Sep 2016 08:43:33 +0800 Message-Id: <1473900213-8765-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.192.195 Subject: [Qemu-devel] [PATCH] 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 Cc: Paolo Bonzini Cc: Radim Krčmář Cc: Michael S. Tsirkin Cc: Eduardo Habkost Signed-off-by: Wanpeng Li Reviewed-by: Michael S. Tsirkin --- hw/intc/apic.c | 20 ++++++++++---------- include/hw/i386/apic_internal.h | 4 ++++ 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/hw/intc/apic.c b/hw/intc/apic.c index 45887d9..577f095 100644 --- a/hw/intc/apic.c +++ b/hw/intc/apic.c @@ -163,7 +163,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 +373,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 +479,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 +493,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 +550,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 +584,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 +663,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 +766,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 +870,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 +889,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); diff --git a/include/hw/i386/apic_internal.h b/include/hw/i386/apic_internal.h index 06c4e9f..5e36016 100644 --- a/include/hw/i386/apic_internal.h +++ b/include/hw/i386/apic_internal.h @@ -131,6 +131,10 @@ typedef struct APICCommonState APICCommonState; #define APIC_COMMON_GET_CLASS(obj) \ OBJECT_GET_CLASS(APICCommonClass, (obj), TYPE_APIC_COMMON) +#define TYPE_APIC "apic" +#define APIC(obj) \ + OBJECT_CHECK(APICCommonState, (obj), TYPE_APIC) + typedef struct APICCommonClass { DeviceClass parent_class;