From patchwork Mon Mar 20 00:09:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haozhong Zhang X-Patchwork-Id: 9632899 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 4A51C6020B for ; Mon, 20 Mar 2017 00:16:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3EEF527F60 for ; Mon, 20 Mar 2017 00:16:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 339CA27F9F; Mon, 20 Mar 2017 00:16:02 +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 C6CF527F60 for ; Mon, 20 Mar 2017 00:16:01 +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 1cpkws-0006bB-9x; Mon, 20 Mar 2017 00:13:22 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cpkwr-0006ZM-7g for xen-devel@lists.xen.org; Mon, 20 Mar 2017 00:13:21 +0000 Received: from [85.158.143.35] by server-5.bemta-6.messagelabs.com id 50/B1-27545-0AE1FC85; Mon, 20 Mar 2017 00:13:20 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrDLMWRWlGSWpSXmKPExsVywNykWHeB3Pk Ig89nGS2WfFzM4sDocXT3b6YAxijWzLyk/IoE1ozGyweZC7ZIV9w9tY6xgfGJWBcjFweLwC0m ieOHvjKBOEIC0xklrq1qYe9i5OSQEOCVOLJsBiuE7Sfx5eVUNoiiXkaJ/weawRJsAvoSKx4fB LNFBKQlrn2+zAhiMwvMZpK43xgCYgsLFEm8mP6MCcRmEVCVmLPoB1g9r4CtxLKvj6CWyUtcuH qKBcTmFLCTWHPpNlhcCKhm/61pbBMY+RYwMqxi1ChOLSpLLdI1MtVLKspMzyjJTczM0TU0MNP LTS0uTkxPzUlMKtZLzs/dxAgMFQYg2MG4akHgIUZJDiYlUV4VwRMRQnxJ+SmVGYnFGfFFpTmp xYcYZTg4lCR4Z+8GygkWpaanVqRl5gCDFiYtwcGjJMIrBZLmLS5IzC3OTIdInWJUlBLnnQOSE ABJZJTmwbXBIuUSo6yUMC8j0CFCPAWpRbmZJajyrxjFORiVhHnfgkzhycwrgZv+CmgxE9DixJ 9HQBaXJCKkpBoYVwRUZxjnxy7yWr2h2OvaxU0JR3g2tE527274oXBBNa1Addd33t+MpzWz0rc m+khUXKt5t6NvXd6ilAmNUy49L3r2f/Gfe+q8s/ruBh62WcJ2TWNv9Nwzh27sEV7J28wbkHFx /62vUnM64o5ZTgk+f+Tx++pAx39f3Bj29YhPTBWTdznxp+gCuxJLcUaioRZzUXEiAErrrgaPA gAA X-Env-Sender: haozhong.zhang@intel.com X-Msg-Ref: server-2.tower-21.messagelabs.com!1489968794!49178196!3 X-Originating-IP: [192.55.52.115] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 51866 invoked from network); 20 Mar 2017 00:13:19 -0000 Received: from mga14.intel.com (HELO mga14.intel.com) (192.55.52.115) by server-2.tower-21.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 20 Mar 2017 00:13:19 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1489968799; x=1521504799; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=zUcsmNlizuqSm1wWnb6kRuSFYfS2B1Tj/vKDZv85RzM=; b=fKlXUBdBSql2In5ltf0itbiWFDHhLKcq9cyDb8RA7dud2SUnF7RI4dym O3pqW5VmT6Jnn3i5IW6naArMUigNQQ==; Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Mar 2017 17:13:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,191,1486454400"; d="scan'208";a="78799203" 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:17 -0700 From: Haozhong Zhang To: xen-devel@lists.xen.org Date: Mon, 20 Mar 2017 08:09:42 +0800 Message-Id: <20170320000949.24675-9-haozhong.zhang@intel.com> X-Mailer: git-send-email 2.10.1 In-Reply-To: <20170320000949.24675-1-haozhong.zhang@intel.com> References: <20170320000949.24675-1-haozhong.zhang@intel.com> Cc: Haozhong Zhang , Wei Liu , Andrew Cooper , Ian Jackson , Jan Beulich , Konrad Rzeszutek Wilk , Dan Williams Subject: [Xen-devel] [RFC XEN PATCH v2 08/15] tools/libacpi: add callback acpi_ctxt.p2v to get a pointer from physical address 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 The address of ACPI blobs passed from device model is provided via XenStore as the physical address. libacpi needs this callback to access them. Signed-off-by: Haozhong Zhang --- Cc: Jan Beulich Cc: Andrew Cooper Cc: Ian Jackson Cc: Wei Liu --- tools/firmware/hvmloader/util.c | 6 ++++++ tools/firmware/hvmloader/util.h | 1 + tools/libacpi/libacpi.h | 1 + tools/libxl/libxl_x86_acpi.c | 10 ++++++++++ 4 files changed, 18 insertions(+) diff --git a/tools/firmware/hvmloader/util.c b/tools/firmware/hvmloader/util.c index d289361317..b2372a75be 100644 --- a/tools/firmware/hvmloader/util.c +++ b/tools/firmware/hvmloader/util.c @@ -871,6 +871,11 @@ static unsigned long acpi_v2p(struct acpi_ctxt *ctxt, void *v) return virt_to_phys(v); } +static void *acpi_p2v(struct acpi_ctxt *ctxt, unsigned long p) +{ + return phys_to_virt(p); +} + static void *acpi_mem_alloc(struct acpi_ctxt *ctxt, uint32_t size, uint32_t align) { @@ -970,6 +975,7 @@ void hvmloader_acpi_build_tables(struct acpi_config *config, ctxt.mem_ops.alloc = acpi_mem_alloc; ctxt.mem_ops.free = acpi_mem_free; ctxt.mem_ops.v2p = acpi_v2p; + ctxt.mem_ops.p2v = acpi_p2v; ctxt.min_alloc_byte_align = 16; diff --git a/tools/firmware/hvmloader/util.h b/tools/firmware/hvmloader/util.h index 6062f0b8cf..6a50dae1eb 100644 --- a/tools/firmware/hvmloader/util.h +++ b/tools/firmware/hvmloader/util.h @@ -200,6 +200,7 @@ xen_pfn_t mem_hole_alloc(uint32_t nr_mfns); /* Allocate memory in a reserved region below 4GB. */ void *mem_alloc(uint32_t size, uint32_t align); #define virt_to_phys(v) ((unsigned long)(v)) +#define phys_to_virt(p) ((void *)(p)) /* Allocate memory in a scratch region */ void *scratch_alloc(uint32_t size, uint32_t align); diff --git a/tools/libacpi/libacpi.h b/tools/libacpi/libacpi.h index 2049a1b032..48acf9583c 100644 --- a/tools/libacpi/libacpi.h +++ b/tools/libacpi/libacpi.h @@ -50,6 +50,7 @@ struct acpi_ctxt { void *(*alloc)(struct acpi_ctxt *ctxt, uint32_t size, uint32_t align); void (*free)(struct acpi_ctxt *ctxt, void *v, uint32_t size); unsigned long (*v2p)(struct acpi_ctxt *ctxt, void *v); + void *(*p2v)(struct acpi_ctxt *ctxt, unsigned long p); } mem_ops; uint32_t min_alloc_byte_align; /* minimum alignment used by mem_ops.alloc */ diff --git a/tools/libxl/libxl_x86_acpi.c b/tools/libxl/libxl_x86_acpi.c index f242450166..2622e03ce6 100644 --- a/tools/libxl/libxl_x86_acpi.c +++ b/tools/libxl/libxl_x86_acpi.c @@ -52,6 +52,15 @@ static unsigned long virt_to_phys(struct acpi_ctxt *ctxt, void *v) libxl_ctxt->alloc_base_paddr); } +static void *phys_to_virt(struct acpi_ctxt *ctxt, unsigned long p) +{ + struct libxl_acpi_ctxt *libxl_ctxt = + CONTAINER_OF(ctxt, struct libxl_acpi_ctxt, c); + + return (void *)((p - libxl_ctxt->alloc_base_paddr) + + libxl_ctxt->alloc_base_vaddr); +} + static void *mem_alloc(struct acpi_ctxt *ctxt, uint32_t size, uint32_t align) { @@ -181,6 +190,7 @@ int libxl__dom_load_acpi(libxl__gc *gc, libxl_ctxt.c.mem_ops.alloc = mem_alloc; libxl_ctxt.c.mem_ops.v2p = virt_to_phys; + libxl_ctxt.c.mem_ops.p2v = phys_to_virt; libxl_ctxt.c.mem_ops.free = acpi_mem_free; libxl_ctxt.c.min_alloc_byte_align = 16;