From patchwork Mon Mar 20 00:12:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haozhong Zhang X-Patchwork-Id: 9632857 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 026DD6020B for ; Mon, 20 Mar 2017 00:13:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EA4E227F8C for ; Mon, 20 Mar 2017 00:13:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DF33B27FBC; Mon, 20 Mar 2017 00:13:48 +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 50FD227F8C for ; Mon, 20 Mar 2017 00:13:48 +0000 (UTC) Received: from localhost ([::1]:58637 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cpkxH-0005HG-9m for patchwork-qemu-devel@patchwork.kernel.org; Sun, 19 Mar 2017 20:13:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58151) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cpkwc-00051N-Ae for qemu-devel@nongnu.org; Sun, 19 Mar 2017 20:13:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cpkwZ-0004ub-QA for qemu-devel@nongnu.org; Sun, 19 Mar 2017 20:13:06 -0400 Received: from mga03.intel.com ([134.134.136.65]:51743) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cpkwZ-0004uJ-Hg for qemu-devel@nongnu.org; Sun, 19 Mar 2017 20:13:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1489968783; x=1521504783; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=44VOTdO1rDAoBeYEFIdcstehS/SeMO3BLKTpSrIQG+Y=; b=C8FjJkbIxHn72qIHkU5bf8Od2V9bmWy8YEXJscvyTqDfO43wi+oXEYR9 yEqLXNxjfTNUkUna9slmzXz3SxUWEA==; Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Mar 2017 17:13:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,191,1486454400"; d="scan'208";a="78799142" 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:01 -0700 From: Haozhong Zhang To: qemu-devel@nongnu.org, xen-devel@lists.xen.org Date: Mon, 20 Mar 2017 08:12:41 +0800 Message-Id: <20170320001249.25521-3-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> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 134.134.136.65 Subject: [Qemu-devel] [RFC QEMU PATCH v2 02/10] xen-hvm: initialize DM ACPI 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: Haozhong Zhang , Stefano Stabellini , xen-devel@lists.xenproject.org, Anthony Perard , Konrad Rzeszutek Wilk , Dan Williams Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Probe the base address and the length of guest ACPI buffer reserved for copying ACPI from QEMU. Signed-off-by: Haozhong Zhang --- Cc: Stefano Stabellini Cc: Anthony Perard Cc: xen-devel@lists.xenproject.org --- xen-hvm.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/xen-hvm.c b/xen-hvm.c index 5043beb98f..c42c958a0a 100644 --- a/xen-hvm.c +++ b/xen-hvm.c @@ -19,6 +19,7 @@ #include "qmp-commands.h" #include "sysemu/char.h" +#include "qemu/cutils.h" #include "qemu/error-report.h" #include "qemu/range.h" #include "sysemu/xen-mapcache.h" @@ -87,6 +88,18 @@ typedef struct XenPhysmap { QLIST_ENTRY(XenPhysmap) list; } XenPhysmap; +#define HVM_XS_DM_ACPI_ROOT "/hvmloader/dm-acpi" +#define HVM_XS_DM_ACPI_ADDRESS HVM_XS_DM_ACPI_ROOT"/address" +#define HVM_XS_DM_ACPI_LENGTH HVM_XS_DM_ACPI_ROOT"/length" + +typedef struct XenAcpiBuf { + ram_addr_t base; + ram_addr_t length; + ram_addr_t used; +} XenAcpiBuf; + +static XenAcpiBuf *dm_acpi_buf; + typedef struct XenIOState { ioservid_t ioservid; shared_iopage_t *shared_page; @@ -111,6 +124,8 @@ typedef struct XenIOState { hwaddr free_phys_offset; const XenPhysmap *log_for_dirtybit; + XenAcpiBuf dm_acpi_buf; + Notifier exit; Notifier suspend; Notifier wakeup; @@ -1205,6 +1220,52 @@ static void xen_wakeup_notifier(Notifier *notifier, void *data) xc_set_hvm_param(xen_xc, xen_domid, HVM_PARAM_ACPI_S_STATE, 0); } +static int dm_acpi_buf_init(XenIOState *state) +{ + char path[80], *value; + unsigned int len; + + dm_acpi_buf = &state->dm_acpi_buf; + + snprintf(path, sizeof(path), + "/local/domain/%d"HVM_XS_DM_ACPI_ADDRESS, xen_domid); + value = xs_read(state->xenstore, 0, path, &len); + if (!value) { + return -EINVAL; + } + if (qemu_strtoul(value, NULL, 16, &dm_acpi_buf->base)) { + return -EINVAL; + } + + snprintf(path, sizeof(path), + "/local/domain/%d"HVM_XS_DM_ACPI_LENGTH, xen_domid); + value = xs_read(state->xenstore, 0, path, &len); + if (!value) { + return -EINVAL; + } + if (qemu_strtoul(value, NULL, 16, &dm_acpi_buf->length)) { + return -EINVAL; + } + + dm_acpi_buf->used = 0; + + return 0; +} + +static int xen_dm_acpi_required(PCMachineState *pcms) +{ + return 0; +} + +static int xen_dm_acpi_init(PCMachineState *pcms, XenIOState *state) +{ + if (!xen_dm_acpi_required(pcms)) { + return 0; + } + + return dm_acpi_buf_init(state); +} + void xen_hvm_init(PCMachineState *pcms, MemoryRegion **ram_memory) { int i, rc; @@ -1344,6 +1405,11 @@ void xen_hvm_init(PCMachineState *pcms, MemoryRegion **ram_memory) /* Disable ACPI build because Xen handles it */ pcms->acpi_build_enabled = false; + if (xen_dm_acpi_init(pcms, state)) { + error_report("failed to initialize xen ACPI"); + goto err; + } + return; err: