From patchwork Mon Mar 20 00:12:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haozhong Zhang X-Patchwork-Id: 9632863 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 500DB6020B for ; Mon, 20 Mar 2017 00:15:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 448C527F8C for ; Mon, 20 Mar 2017 00:15:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3941127FBC; Mon, 20 Mar 2017 00:15:38 +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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A99CB27F9F for ; Mon, 20 Mar 2017 00:15:36 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cpkxT-0007rq-NX; Mon, 20 Mar 2017 00:13:59 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cpkxS-0007oN-BN for xen-devel@lists.xenproject.org; Mon, 20 Mar 2017 00:13:58 +0000 Received: from [193.109.254.147] by server-3.bemta-6.messagelabs.com id 8D/B9-27751-5CE1FC85; Mon, 20 Mar 2017 00:13:57 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpnkeJIrShJLcpLzFFi42Jpa+uQ0D0qdz7 CYPc9LovvWyYzOTB6HP5whSWAMYo1My8pvyKBNePf7H6mgjvSFZf2X2NsYJwm1sXIxcEicItJ YvnJ9UwgjpDAdEaJnz9WsHcxcnJICPBKHFk2gxXC9pPY1LSdEaKol1HizeKnYAk2AX2JFY8PA tkcHCICxhJtN51BapgFZjNLdH+6BzZIWCBUYlPHY0YQm0VAVWLlp/tgcV4BW4mfXxrYIBbIS1 y4eooFZA6ngJ1Ex2w3kLAQUMmPVZNZJjDyLWBkWMWoUZxaVJZapGtspJdUlJmeUZKbmJmja2h gppebWlycmJ6ak5hUrJecn7uJERgoDECwg/H0usBDjJIcTEqivJ/nHowQ4kvKT6nMSCzOiC8q zUktPsQow8GhJMHL9g0oJ1iUmp5akZaZAwxZmLQEB4+SCK82SJq3uCAxtzgzHSJ1ilGXY87s3 W+YhFjy8vNSpcR5VUGKBECKMkrz4EbA4ucSo6yUMC8j0FFCPAWpRbmZJajyrxjFORiVhCEu4c nMK4Hb9AroCCagI6bxgR1RkoiQkmpg1NgvE9PMfiaO7daPxamBu+X3v5TZdCdnZ9xZyQO8bC+ FnQ69Mnx4/0vJzCsnkjc0n7J5t61Yi+GDk9Qt5RAuTm2rmUY7JP4qM33cwq8j2iTSJr6S8e6W qQq5wR/O5X2p4J5576jVPgHuNU6S+hcyA/9tM8x0EZxn9eHA/ZkbxSMm2V1ZvF70uhJLcUaio RZzUXEiAMrq6gyaAgAA X-Env-Sender: haozhong.zhang@intel.com X-Msg-Ref: server-2.tower-27.messagelabs.com!1489968834!40097795!1 X-Originating-IP: [134.134.136.24] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTM0LjEzNC4xMzYuMjQgPT4gMzkwOTcx\n X-StarScan-Received: X-StarScan-Version: 9.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 34629 invoked from network); 20 Mar 2017 00:13:56 -0000 Received: from mga09.intel.com (HELO mga09.intel.com) (134.134.136.24) by server-2.tower-27.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 20 Mar 2017 00:13:56 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1489968836; x=1521504836; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=82LTZg/5VOT6Lr7nPZUOG/GPqCm/6q2YeB8XNrANJwU=; b=gojIizdXWV0w2DsXJmrwBnFxPLam8EL6F9idTChJ9+r645CoxLnZK/ll V3fK5Hii1wA7ARru93Aj4JfvkFMHYQ==; Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Mar 2017 17:13:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,191,1486454400"; d="scan'208";a="78799192" Received: from hz-desktop.sh.intel.com (HELO localhost) ([10.239.159.153]) by fmsmga006.fm.intel.com with ESMTP; 19 Mar 2017 17:13:12 -0700 From: Haozhong Zhang To: qemu-devel@nongnu.org, xen-devel@lists.xen.org Date: Mon, 20 Mar 2017 08:12:46 +0800 Message-Id: <20170320001249.25521-8-haozhong.zhang@intel.com> X-Mailer: git-send-email 2.10.1 In-Reply-To: <20170320001249.25521-1-haozhong.zhang@intel.com> References: <20170320001249.25521-1-haozhong.zhang@intel.com> Cc: Haozhong Zhang , Stefano Stabellini , Eduardo Habkost , "Michael S. Tsirkin" , xen-devel@lists.xenproject.org, Paolo Bonzini , Anthony Perard , Konrad Rzeszutek Wilk , Dan Williams , Richard Henderson Subject: [Xen-devel] [RFC QEMU PATCH v2 07/10] xen-hvm: initiate building DM ACPI on i386 machine X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP If QEMU is running as Xen device model and Xen needs ACPI (e.g. NFIT) from QEMU, initiate building DM ACPI. Signed-off-by: Haozhong Zhang --- Cc: "Michael S. Tsirkin" Cc: Paolo Bonzini Cc: Richard Henderson Cc: Eduardo Habkost Cc: Stefano Stabellini Cc: Anthony Perard Cc: xen-devel@lists.xenproject.org --- hw/i386/pc.c | 16 ++++++++++------ include/hw/xen/xen.h | 2 ++ xen-hvm-stub.c | 4 ++++ xen-hvm.c | 23 ++++++++++++++++++++++- 4 files changed, 38 insertions(+), 7 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index d24388e05f..6b76720c35 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1256,12 +1256,16 @@ void pc_machine_done(Notifier *notifier, void *data) } } - acpi_setup(); - if (pcms->fw_cfg) { - pc_build_smbios(pcms); - pc_build_feature_control_file(pcms); - /* update FW_CFG_NB_CPUS to account for -device added CPUs */ - fw_cfg_modify_i16(pcms->fw_cfg, FW_CFG_NB_CPUS, pcms->boot_cpus); + if (!xen_enabled()) { + acpi_setup(); + if (pcms->fw_cfg) { + pc_build_smbios(pcms); + pc_build_feature_control_file(pcms); + /* update FW_CFG_NB_CPUS to account for -device added CPUs */ + fw_cfg_modify_i16(pcms->fw_cfg, FW_CFG_NB_CPUS, pcms->boot_cpus); + } + } else { + xen_dm_acpi_setup(pcms); } if (pcms->apic_id_limit > 255) { diff --git a/include/hw/xen/xen.h b/include/hw/xen/xen.h index d67cdd8c7d..2e2f4bf60d 100644 --- a/include/hw/xen/xen.h +++ b/include/hw/xen/xen.h @@ -65,4 +65,6 @@ void xen_register_framebuffer(struct MemoryRegion *mr); int xen_acpi_copy_to_guest(const char *name, const void *blob, size_t length, int type); +void xen_dm_acpi_setup(PCMachineState *pcms); + #endif /* QEMU_HW_XEN_H */ diff --git a/xen-hvm-stub.c b/xen-hvm-stub.c index a6c018505c..1231faabda 100644 --- a/xen-hvm-stub.c +++ b/xen-hvm-stub.c @@ -67,3 +67,7 @@ int xen_acpi_copy_to_guest(const char *name, const void *blob, size_t length, { return -1; } + +void xen_dm_acpi_setup(PCMachineState *pcms) +{ +} diff --git a/xen-hvm.c b/xen-hvm.c index 4ddc47e5f1..0c36dd11da 100644 --- a/xen-hvm.c +++ b/xen-hvm.c @@ -1268,7 +1268,7 @@ static ram_addr_t dm_acpi_buf_alloc(size_t length) static int xen_dm_acpi_required(PCMachineState *pcms) { - return 0; + return pcms->acpi_nvdimm_state.is_enabled; } static int xen_dm_acpi_init(PCMachineState *pcms, XenIOState *state) @@ -1280,6 +1280,27 @@ static int xen_dm_acpi_init(PCMachineState *pcms, XenIOState *state) return dm_acpi_buf_init(state); } +static void xen_dm_acpi_nvdimm_setup(PCMachineState *pcms) +{ + GArray *table_offsets = g_array_new(false, true /* clear */, + sizeof(uint32_t)); + GArray *table_data = g_array_new(false, true /* clear */, 1); + + nvdimm_build_acpi(table_offsets, table_data, + NULL, &pcms->acpi_nvdimm_state, + MACHINE(pcms)->ram_slots); + + g_array_free(table_offsets, true); + g_array_free(table_data, true); +} + +void xen_dm_acpi_setup(PCMachineState *pcms) +{ + if (pcms->acpi_nvdimm_state.is_enabled) { + xen_dm_acpi_nvdimm_setup(pcms); + } +} + void xen_hvm_init(PCMachineState *pcms, MemoryRegion **ram_memory) { int i, rc;