From patchwork Tue Oct 31 06:55:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 117519 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp3524141qgn; Mon, 30 Oct 2017 23:57:28 -0700 (PDT) X-Google-Smtp-Source: ABhQp+Qiz13Ah3p5kyin/KnwinVlwAUdCULP71pkIcuZ3qQOak7G8pV9r+KPzyG1OJpMi0tPuqD5 X-Received: by 10.107.46.8 with SMTP id i8mr1188513ioo.298.1509433048252; Mon, 30 Oct 2017 23:57:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509433048; cv=none; d=google.com; s=arc-20160816; b=SCqchoqmyEPBBmhb9QZ3r1Mfkr9kvLZPXwdYLALTh9av50IKqcbJOVr2oKQJbe+zFx t/41AzPDVGBgUdEM0HHYIQ9iaC271bb+/yzx93uqNViRlI8cbvJREiuFvXsv1HQ1rDDE Y46dvk3e4VckS3xo9nuEy7CMST2g2s22KdzU3KtE5zSkI3rzciZ0MCrw1HHIcxLSDjcN DUpSeqRM9vBffJEuEOv3WQM1mFLzWBnGAWEOrrzvjkoE02XFr6R5ZMYHsGuWpHKa6puu Gvj0XI/r/6n9JI0GTdkAqjTdnAUB7t8vqWEWjZLInyfCN3tn9zZC57DPXX05rx/XIu6l oD6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=R+MdG78Jdu6jssvP98KJ9sNPvunp6JeChv+D38CvJwg=; b=WV9eQlLeH53UmhyU2z3Wzhr/lJYEv0sNgaiL7p9FnEQ/tfExY5BDROxbpB4BMUchom t20Y3E+ZB5+GFH2LjbYdMjfhlswqP4T+sgI9oU6TuKW2MQxvD7UCjbsYFvOq7qbHrbv6 r+aiAxMCksbE7JCMXp02l16jBtV80nwzqkDh4yxzisGN9C2FonNpuLZuqiO6OpkRlB1y pQS+SFpf0DEsV9KBD56lt4Gf5Acse5xXDTiziZNl/wnuXRF1v//rygdEv9WxeUyGvq4J PxeP7MxB0CJOqHLOLdkvZ849cD4aalzrxOXNaFYpPv0+tYsiCBwBtAN9n0pMUaZdA7gZ 98cQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=XnpYia5G; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id t15si1199889iti.159.2017.10.30.23.57.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Oct 2017 23:57:28 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=XnpYia5G; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e9QSJ-0002yv-Nt; Tue, 31 Oct 2017 06:55:23 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e9QSI-0002yh-Dg for xen-devel@lists.xenproject.org; Tue, 31 Oct 2017 06:55:22 +0000 Received: from [85.158.139.211] by server-2.bemta-5.messagelabs.com id 7D/52-23269-95E18F95; Tue, 31 Oct 2017 06:55:21 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrNIsWRWlGSWpSXmKPExsVyMfTAQd1IuR+ RBseesFh83zKZyYHR4/CHKywBjFGsmXlJ+RUJrBnn2t+yF/wSrOib3crSwNjK38XIxSEkMJNR YsWMVUwgDovAPGaJfbdeAjmcHBIC/awS/5YGQ9h5Eu/uTmLtYuQAstMkru3RgTArJfqmR4JUC AloSRw9NZsVwt7BJPH8lyJICZuAicSsDgmQsIiAksS9VZPBNjELzGeUaJrUywaSEBZIlph/qp cZxGYRUJXY8vs8I4jNK+AtMfnEDqhr5CRunusEq+EU8JHobu5jhNjlLdH3agrLBEbBBYwMqxg 1ilOLylKLdI1M9ZKKMtMzSnITM3N0DQ1M9XJTi4sT01NzEpOK9ZLzczcxAoOtnoGBcQfjrna/ Q4ySHExKorw7Hb9HCvEl5adUZiQWZ8QXleakFh9ilOHgUJLg/S3zI1JIsCg1PbUiLTMHGPYwa QkOHiURXl2QNG9xQWJucWY6ROoUoz3HhTuX/jBxHNhzC0h23LwLJJ/NfN3ALMSSl5+XKiXO6y wL1CYA0pZRmgc3FBanlxhlpYR5GRkYGIR4ClKLcjNLUOVfMYpzMCoJ83KCTOHJzCuB2/0K6Cw moLO8JMDOKklESEk1MM7jEDsYtGh6TcbJG7/uF4UqLHn4Zu8Bh9maxaaNtQkfPoXb/eJZX7DL a9N2sS+nqq67RffU739/Vuq1v57vQdsnBf79Jydyu1wr/XlDsuBcW+JUrTNiP3xn7vh8u8lo5 gnZomWTE4yWi25+EaCSEvzbgWn2Rd9r6c91NrUuyrrdUhyY+XArzzYlluKMREMt5qLiRAAw8j AGzgIAAA== X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-13.tower-206.messagelabs.com!1509432920!93894547!1 X-Originating-IP: [209.85.192.193] 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 29275 invoked from network); 31 Oct 2017 06:55:20 -0000 Received: from mail-pf0-f193.google.com (HELO mail-pf0-f193.google.com) (209.85.192.193) by server-13.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 31 Oct 2017 06:55:20 -0000 Received: by mail-pf0-f193.google.com with SMTP id p87so13035986pfj.3 for ; Mon, 30 Oct 2017 23:55:20 -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=ZIrhgrb9ZENT2mHVadcLYu6cjupeJkWyILO8AFM17h0=; b=XnpYia5G10e1eA0Yy0FkMQSqmrwObL9mV1Yv/ywhppSYe6RXUC6uWsAcPBfB+YbQAq C5ySj0KUcbseAAxnj+K7QOZGn2cEtm5Q34bSOrwsR30WYHIppAs4dxedn/ywRoAZd5xt OQg5nuXPD3mjBMcCkUGXHqFntmmNwOr7gBfCM= 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=ZIrhgrb9ZENT2mHVadcLYu6cjupeJkWyILO8AFM17h0=; b=sX3L2tKz66inOmBHxZkSsHpsjB+OrRYYG9HSuO1HUsPkxjjVYnnVjteFHorN00OLvK rkQgyyWddMjbUwV6NAMCYFx4dvw6kQnoSPgj7GfKnMcGxCF5rfQ4E7brZ6RSraTCqCja kKLNnSin37VHTEdPJkxpjVAajrp0lsEVJgAS5z7bWd0CPISGeKNoObrPs0z9RIfozPvd Xnuru8KmhRw1iFw0n8qqvDWOVVCi+tVw7/M2MGrMOtp9Bn3K27FX46nDvnz6v5moHZ9R ikAdjrCAOzxUTxlZPzOhryMG40CLcq2Ov+y/JaL3LQPVIK12VS06m2tX4J6G0Beamb5m MLvg== X-Gm-Message-State: AMCzsaVsm9V3llNu0XKbq0QVesFrpMISXjf8JcUYLuCXyQfs/zQr2tJI 896cRIRCAKP37hzlUOtc7iDoc87pv+o= X-Received: by 10.98.93.148 with SMTP id n20mr1030454pfj.247.1509432918821; Mon, 30 Oct 2017 23:55:18 -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.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 30 Oct 2017 23:55:18 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Tue, 31 Oct 2017 12:25:07 +0530 Message-Id: <1509432908-17449-3-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 3/4 v3] xenconsole: Change the type of ring_ref to xen_pfn_t in console_create_ring 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" Currently, ring_ref is read as an integer in console_create_ring which could lead to truncation of the value as it is reading a 64-bit value. The fix is to modify the type of ring_ref to xen_pfn_t and use the correct format specifier to read the value correctly for all architectures. 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/console/daemon/io.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c index e22009a..1839973 100644 --- a/tools/console/daemon/io.c +++ b/tools/console/daemon/io.c @@ -19,6 +19,7 @@ #define _GNU_SOURCE +#include #include "utils.h" #include "io.h" #include @@ -81,6 +82,12 @@ static unsigned int nr_fds; #define ROUNDUP(_x,_w) (((unsigned long)(_x)+(1UL<<(_w))-1) & ~((1UL<<(_w))-1)) +#if defined(CONFIG_ARM) +# define SCNi_xen_pfn SCNi64 +#else +# define SCNi_xen_pfn "li" +#endif + struct buffer { char *data; size_t consumed; @@ -98,7 +105,7 @@ struct console { struct buffer buffer; char *xspath; char *log_suffix; - int ring_ref; + xen_pfn_t ring_ref; xenevtchn_handle *xce_handle; int xce_pollfd_idx; int event_count; @@ -661,12 +668,13 @@ static void console_unmap_interface(struct console *con) static int console_create_ring(struct console *con) { - int err, remote_port, ring_ref, rc; + int err, remote_port, rc; + xen_pfn_t ring_ref; char *type, path[PATH_MAX]; struct domain *dom = con->d; err = xs_gather(xs, con->xspath, - "ring-ref", "%u", &ring_ref, + "ring-ref", "%"SCNi_xen_pfn, &ring_ref, "port", "%i", &remote_port, NULL); @@ -705,7 +713,7 @@ static int console_create_ring(struct console *con) con->interface = xc_map_foreign_range( xc, dom->domid, XC_PAGE_SIZE, PROT_READ|PROT_WRITE, - (unsigned long)ring_ref); + ring_ref); if (con->interface == NULL) { err = EINVAL; goto out;