From patchwork Tue Oct 31 06:55:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 10033645 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 EB82A603B5 for ; Tue, 31 Oct 2017 06:57:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DD7EB284F6 for ; Tue, 31 Oct 2017 06:57:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D26482895D; Tue, 31 Oct 2017 06:57:49 +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=-3.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RCVD_IN_SORBS_SPAM,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 705642870D for ; Tue, 31 Oct 2017 06:57:47 +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 1e9QSG-0002yD-CD; Tue, 31 Oct 2017 06:55:20 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e9QSF-0002y7-Nc for xen-devel@lists.xenproject.org; Tue, 31 Oct 2017 06:55:19 +0000 Received: from [85.158.139.211] by server-7.bemta-5.messagelabs.com id C9/85-01785-65E18F95; Tue, 31 Oct 2017 06:55:18 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrNIsWRWlGSWpSXmKPExsXiVRvsqBsm9yP S4MJUfovvWyYzOTB6HP5whSWAMYo1My8pvyKBNePb2WWMBT+cK943+jcwTjTuYuTiEBKYyShx fOYSJhCHRWAes0TftvWsII6EQD+rxNnnfUAOJ5CTJ/Fn1kV2CDtNYtu6J0AdHEB2hcSGk6YgY SEBLYmjp2azQkzdwSRx+89DZpAaNgETiVkdEiA1IgJKEvdWTQZbxiwwn1GiaVIvG0hCWMBLor FnFhOIzSKgKvGx5yQrSC+vgLfE+1+OEGvlJG6e62QGsTkFfCS6m/sYIfZ6S/S9msIygVFwASP DKkb14tSistQiXWO9pKLM9IyS3MTMHF1DA1O93NTi4sT01JzEpGK95PzcTYzAYGMAgh2Me/85 HWKU5GBSEuXd6fg9UogvKT+lMiOxOCO+qDQntfgQowwHh5IEr5Xsj0ghwaLU9NSKtMwcYNjDp CU4eJREeHVlgNK8xQWJucWZ6RCpU4z2HMc2Xf7DxLFvzy0g2XHzLpB8NvN1A7MQS15+XqqUOK 8zyFQBkLaM0jy4obA4vcQoKyXMywh0phBPQWpRbmYJqvwrRnEORiVh3n0gU3gy80rgdr8COos J6CwvCbCzShIRUlINjFbO0kvcg1J36+RN9fvJ1zql7o3k3Z/vD85IunWwLXv/p2fFeaHsr5vX HFz7RiJrOde0D3rzQ+ZIzLq26b9XYnrnNNu+4tbC6LOxf1v0XdjmLGc8uH+Hl1W33oGPk79yd Ee26hWwT1n8sdX98apgNdePhn4Rp1m4mm4bun/5crBH/aHK5Czjf0osxRmJhlrMRcWJAJLimh jOAgAA X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-11.tower-206.messagelabs.com!1509432917!89607455!1 X-Originating-IP: [74.125.83.65] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 18530 invoked from network); 31 Oct 2017 06:55:17 -0000 Received: from mail-pg0-f65.google.com (HELO mail-pg0-f65.google.com) (74.125.83.65) by server-11.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 31 Oct 2017 06:55:17 -0000 Received: by mail-pg0-f65.google.com with SMTP id l24so13846379pgu.11 for ; Mon, 30 Oct 2017 23:55:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=R5hNAH30cZfYDouNEHa7dp2B5+pAu8phJUwXkMy6jtQ=; b=JHZFeZQS4D3HDtmSblka5OJrRozY5uUH8P08yThMPuPPhdu/aUJtC6120MPlTBmsZv MpPpegCxIltosj32iWMZElwclqzdLc59YScAow8Gd/Nfu2YPi4Irr5VxJ0vK1iPx5pt5 UxSlCzBwCcOpON3C1lsVByXHwGOJk/ZQbpfOU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=R5hNAH30cZfYDouNEHa7dp2B5+pAu8phJUwXkMy6jtQ=; b=TsXWvwiMnRmw37i5tqLl4dxTnuDIe+Psdty2gT0LnhydCHy/KFbI9lZwZJ1woJH4a7 4eMhNybNU+ZSINm0fDOp6+CLSoV3N04pExnuB6uPuV0HAfcyfvk6Xzt1NYZBj/YaC0Lw zfsQmsNIo8DwJOGL3oczJQND1wj2Bg8Hk061swBXyo7rTgGLVa2S1OhyC5Q5mxI4i8lk LiMp8QhAnHgnxJo8H9oHEYP0zmPO6ukcl+jwmZhMUnJuNEMNs239l0XgGQ/tgxI8SHXz 0p1Rvb0JrRzLBupmwMwLs9JgAuz6cFDc9T7jEm9SPrXBQylVYJoYk6X73GK6Eyv69B7P NJNg== X-Gm-Message-State: AMCzsaV+94tPhEyoDtb/YZKJMnzBC3BW2UF9ua1tmdysn1M0prHB3HmD avHO/0KLnLQN6gkU8Yg3nFIWzzQ56IA= X-Google-Smtp-Source: ABhQp+S9VyDc2PJFgiu1xwAX5Y3EL2SpI/I9TEAYuuxye9CMqjaV4Ei/eU1AElO4S838Z3JmVEwklg== X-Received: by 10.84.168.69 with SMTP id e63mr989916plb.340.1509432916319; Mon, 30 Oct 2017 23:55:16 -0700 (PDT) Received: from blr-ubuntu-linaro.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com. [103.229.18.19]) by smtp.gmail.com with ESMTPSA id g16sm1517127pfd.87.2017.10.30.23.55.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 30 Oct 2017 23:55:15 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Tue, 31 Oct 2017 12:25:06 +0530 Message-Id: <1509432908-17449-2-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1509432908-17449-1-git-send-email-bhupinder.thakur@linaro.org> References: <1509432908-17449-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 2/4 v3] libxl: Change the type of console_mfn to xen_pfn_t 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 Currently the type of console mfn is unsigned long in libxl. This may be an issue for 32-bit toolstack running on 64-bit Xen, where the pfn are 64 bit. To ensure that console_mfn can hold any valid 64-bit pfn, the type of console_mfn is changed to xen_pfn_t. Also the name console_mfn is misleading as it is actually a gfn. This patch also modifies the name to console_gfn. Signed-off-by: Bhupinder Thakur Acked-by: Wei Liu --- CC: Ian Jackson CC: Wei Liu CC: Stefano Stabellini CC: Julien Grall This patch is as per the review of commit fa1f157 libxl: Fix the bug introduced in commit "libxl: use correct type tools/libxc/include/xenctrl_compat.h | 2 +- tools/libxc/xc_foreign_memory.c | 4 ++-- tools/libxl/libxl_console.c | 2 +- tools/libxl/libxl_create.c | 10 +++++----- tools/libxl/libxl_dom.c | 12 ++++++------ tools/libxl/libxl_internal.h | 2 +- tools/libxl/libxl_save_helper.c | 6 +++--- 7 files changed, 19 insertions(+), 19 deletions(-) diff --git a/tools/libxc/include/xenctrl_compat.h b/tools/libxc/include/xenctrl_compat.h index a655e47..5ee72bf 100644 --- a/tools/libxc/include/xenctrl_compat.h +++ b/tools/libxc/include/xenctrl_compat.h @@ -26,7 +26,7 @@ */ void *xc_map_foreign_range(xc_interface *xch, uint32_t dom, int size, int prot, - unsigned long mfn ); + xen_pfn_t pfn); void *xc_map_foreign_pages(xc_interface *xch, uint32_t dom, int prot, const xen_pfn_t *arr, int num ); diff --git a/tools/libxc/xc_foreign_memory.c b/tools/libxc/xc_foreign_memory.c index 4053d26..c1f114a 100644 --- a/tools/libxc/xc_foreign_memory.c +++ b/tools/libxc/xc_foreign_memory.c @@ -33,7 +33,7 @@ void *xc_map_foreign_pages(xc_interface *xch, uint32_t dom, int prot, void *xc_map_foreign_range(xc_interface *xch, uint32_t dom, int size, int prot, - unsigned long mfn) + xen_pfn_t pfn) { xen_pfn_t *arr; int num; @@ -46,7 +46,7 @@ void *xc_map_foreign_range(xc_interface *xch, return NULL; for ( i = 0; i < num; i++ ) - arr[i] = mfn + i; + arr[i] = pfn + i; ret = xc_map_foreign_pages(xch, dom, prot, arr, num); free(arr); diff --git a/tools/libxl/libxl_console.c b/tools/libxl/libxl_console.c index 6bfc0e5..f2ca689 100644 --- a/tools/libxl/libxl_console.c +++ b/tools/libxl/libxl_console.c @@ -329,7 +329,7 @@ int libxl__device_console_add(libxl__gc *gc, uint32_t domid, flexarray_append(ro_front, "port"); flexarray_append(ro_front, GCSPRINTF("%"PRIu32, state->console_port)); flexarray_append(ro_front, "ring-ref"); - flexarray_append(ro_front, GCSPRINTF("%lu", state->console_mfn)); + flexarray_append(ro_front, GCSPRINTF("%"PRIu_xen_pfn, state->console_mfn)); } else { flexarray_append(front, "state"); flexarray_append(front, GCSPRINTF("%d", XenbusStateInitialising)); diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index f15fb21..26870ca 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -1134,7 +1134,7 @@ static void domcreate_bootloader_done(libxl__egc *egc, } void libxl__srm_callout_callback_restore_results(xen_pfn_t store_mfn, - xen_pfn_t console_mfn, void *user) + xen_pfn_t console_gfn, void *user) { libxl__save_helper_state *shs = user; libxl__domain_create_state *dcs = shs->caller_state; @@ -1142,7 +1142,7 @@ void libxl__srm_callout_callback_restore_results(xen_pfn_t store_mfn, libxl__domain_build_state *const state = &dcs->build_state; state->store_mfn = store_mfn; - state->console_mfn = console_mfn; + state->console_gfn = console_gfn; shs->need_results = 0; } @@ -1740,7 +1740,7 @@ static int do_domain_soft_reset(libxl_ctx *ctx, libxl__domain_create_state *dcs; libxl__domain_build_state *state; libxl__domain_save_state *dss; - const char *console_tty, *xs_store_mfn, *xs_console_mfn; + const char *console_tty, *xs_store_mfn, *xs_console_gfn; char *dom_path; uint32_t domid_out; int rc; @@ -1781,12 +1781,12 @@ static int do_domain_soft_reset(libxl_ctx *ctx, rc = libxl__xs_read_checked(gc, XBT_NULL, GCSPRINTF("%s/console/ring-ref", dom_path), - &xs_console_mfn); + &xs_console_gfn); if (rc) { LOGD(ERROR, domid_soft_reset, "failed to read console/ring-ref."); goto out; } - state->console_mfn = xs_console_mfn ? atol(xs_console_mfn): 0; + state->console_gfn = xs_console_gfn ? atol(xs_console_gfn): 0; rc = libxl__xs_read_mandatory(gc, XBT_NULL, GCSPRINTF("%s/console/tty", dom_path), diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c index ef834e6..647dbf7 100644 --- a/tools/libxl/libxl_dom.c +++ b/tools/libxl/libxl_dom.c @@ -852,11 +852,11 @@ int libxl__build_pv(libxl__gc *gc, uint32_t domid, goto out; if (xc_dom_translated(dom)) { - state->console_mfn = dom->console_pfn; + state->console_gfn = dom->console_pfn; state->store_mfn = dom->xenstore_pfn; state->vuart_gfn = dom->vuart_gfn; } else { - state->console_mfn = xc_dom_p2m(dom, dom->console_pfn); + state->console_gfn = xc_dom_p2m(dom, dom->console_pfn); state->store_mfn = xc_dom_p2m(dom, dom->xenstore_pfn); } @@ -869,7 +869,7 @@ out: static int hvm_build_set_params(xc_interface *handle, uint32_t domid, libxl_domain_build_info *info, int store_evtchn, unsigned long *store_mfn, - int console_evtchn, unsigned long *console_mfn, + int console_evtchn, xen_pfn_t *console_gfn, domid_t store_domid, domid_t console_domid) { struct hvm_info_table *va_hvm; @@ -901,9 +901,9 @@ static int hvm_build_set_params(xc_interface *handle, uint32_t domid, xc_hvm_param_set(handle, domid, HVM_PARAM_CONSOLE_EVTCHN, console_evtchn); *store_mfn = str_mfn; - *console_mfn = cons_mfn; + *console_gfn = cons_mfn; - xc_dom_gnttab_hvm_seed(handle, domid, *console_mfn, *store_mfn, console_domid, store_domid); + xc_dom_gnttab_hvm_seed(handle, domid, *console_gfn, *store_mfn, console_domid, store_domid); return 0; } @@ -1270,7 +1270,7 @@ int libxl__build_hvm(libxl__gc *gc, uint32_t domid, rc = hvm_build_set_params(ctx->xch, domid, info, state->store_port, &state->store_mfn, state->console_port, - &state->console_mfn, state->store_domid, + &state->console_gfn, state->store_domid, state->console_domid); if (rc != 0) { LOG(ERROR, "hvm build set params failed"); diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index bfa95d8..49f7966 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -1129,7 +1129,7 @@ typedef struct { uint32_t console_port; uint32_t console_domid; - unsigned long console_mfn; + xen_pfn_t console_gfn; char *console_tty; char *saved_state; diff --git a/tools/libxl/libxl_save_helper.c b/tools/libxl/libxl_save_helper.c index 38089a0..bf50ec8 100644 --- a/tools/libxl/libxl_save_helper.c +++ b/tools/libxl/libxl_save_helper.c @@ -284,17 +284,17 @@ int main(int argc, char **argv) helper_setcallbacks_restore(&helper_restore_callbacks, cbflags); unsigned long store_mfn = 0; - unsigned long console_mfn = 0; + unsigned long console_gfn = 0; startup("restore"); setup_signals(SIG_DFL); r = xc_domain_restore(xch, io_fd, dom, store_evtchn, &store_mfn, - store_domid, console_evtchn, &console_mfn, + store_domid, console_evtchn, &console_gfn, console_domid, hvm, pae, stream_type, &helper_restore_callbacks, send_back_fd); - helper_stub_restore_results(store_mfn,console_mfn,0); + helper_stub_restore_results(store_mfn,console_gfn,0); complete(r); } else {