From patchwork Tue Oct 17 16:46:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 116147 Delivered-To: patch@linaro.org Received: by 10.80.163.170 with SMTP id s39csp1438432edb; Tue, 17 Oct 2017 09:48:39 -0700 (PDT) X-Received: by 10.36.68.13 with SMTP id o13mr5869738ita.56.1508258919492; Tue, 17 Oct 2017 09:48:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508258919; cv=none; d=google.com; s=arc-20160816; b=L3jH/h/vMotZQ68btJldmEaRH7eBypZtq/i1AXyFoybcmIuh3F69Y67femgT8uz/n9 Z1/WPixp6Lap1+rTuWxAht1w5h4PzzfdIJ/UjtdoIErmox58p3t22J1E6W7Sx+56fxJU Me9XtkzG3EBCAJJWvwWfMpSyXPnQBJVIDYFXHPv+S8ZK/Nn/Ohhx51S7n+VS68sn87Ee 0xwvH2c9NU3L69W6ry08aZrXoBBgQ1TW0P7hHo7IXoNJ9SITkWVKkIFdWFF6RYMjWPCk fGEmGH7jCbR6NQjazspWuOcPZr2hIG9ZUK96/+vJMTcF5yXsuCY3VkRaLeuZp4fWp8+C Do/Q== 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=78RLIGrDyIeq4MpzImwgVdZACG6TW33WHKOsxktHMec=; b=glqZ6MAVYMLQabxGTQbm3TbvdwbWIqHSrhRK6dTdnYLzcFC0yyRUp3NzUHAjLixYt7 6Xrx6Sv2astKs0YH/fEVN08uDx/2Dr7/yHQ+NRjKVM3J129TRvpGZP7yEOD6aobp/FlW GPb+q4fzqywmyLM7O+ZkILlHtSHsKTb/syN7rBZNo4k6MyjJvyroDzyJzozjQYfwJARb e+UqGRuKJIrV/un6NmTkBV/ezE852BPa1XZ/bKQkU8+5KmND75HHPLUpHZfpMTjoiFUB BCR5PnoYdvsrXr2V+brsVCj3uf9R+V2vQV2/E9XGdB4KdXS4Q63S5tQN2z6iVKjo03Ry 4sYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=VVBkqCdw; 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 x13si7472834iti.139.2017.10.17.09.48.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Oct 2017 09:48:39 -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=VVBkqCdw; 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 1e4V11-0001m6-Cd; Tue, 17 Oct 2017 16:46:51 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e4V10-0001lV-EQ for xen-devel@lists.xenproject.org; Tue, 17 Oct 2017 16:46:50 +0000 Received: from [85.158.137.68] by server-13.bemta-3.messagelabs.com id 72/C9-07262-9F336E95; Tue, 17 Oct 2017 16:46:49 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrOIsWRWlGSWpSXmKPExsVyMfTAat0fxs8 iDRovsFh83zKZyYHR4/CHKywBjFGsmXlJ+RUJrBnHL0xnLLglUPFg63zGBsZmvi5GLg4hgRmM EmcWHGIHcVgE5jFLTPt2Dcjh5JAQ6GeVaJyrDmHnSWx7dpARwk6TOLx1HZRdIXHm4goWEFtIQ Evi6KnZrBBTW5gkJuw9DjSIg4NNwERiVocESI2IgJLEvVWTmUBqmAXmM0o0TeplA0kIC4RIPJ v6lhnEZhFQlTi95z3YEbwCXhK/l29nglgmJ3HzXCdYDaeAt8TzN5OYQOYLAdXM2q03gVFwASP DKkaN4tSistQiXUMTvaSizPSMktzEzBxdQwNjvdzU4uLE9NScxKRiveT83E2MwIBjAIIdjCu2 ex5ilORgUhLldTZ8EinEl5SfUpmRWJwRX1Sak1p8iFGGg0NJgpcTGMBCgkWp6akVaZk5wNCHS Utw8CiJ8C4zAkrzFhck5hZnpkOkTjFacly4c+kPE8eBPbeAZMfNu3+YhFjy8vNSpcR5GUHmCY A0ZJTmwY2DxeclRlkpYV5GoAOFeApSi3IzS1DlXzGKczAqCfM+BVnLk5lXArf1FdBBTEAHrXN 6AnJQSSJCSqqBkSF6kcyh2bOrH805wp3g+47/h8Ym0b7gyI9rt61f2vJesSf9+oplTXHqyZrv I9ZWPmcMuXV7aeLmWXfvGS+4VVQppK3c0Ld8ZWvwk/DWFyEM6byx/1vra9gnLf/MJzD5zoT+z Yvuf3N2blZKesB75Szby7XJ6xwmJP9lU/zXzHfj0g0+v6u/XiuxFGckGmoxFxUnAgBxAG4/yg IAAA== X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-14.tower-31.messagelabs.com!1508258806!110536040!1 X-Originating-IP: [209.85.192.171] 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 5461 invoked from network); 17 Oct 2017 16:46:47 -0000 Received: from mail-pf0-f171.google.com (HELO mail-pf0-f171.google.com) (209.85.192.171) by server-14.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 17 Oct 2017 16:46:47 -0000 Received: by mail-pf0-f171.google.com with SMTP id p87so1755556pfj.3 for ; Tue, 17 Oct 2017 09:46:47 -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=vtLnrQvI2QkwPJWNRuKMPFUHjK3UVpPxiw8esbGM3/I=; b=VVBkqCdwCp3uKcD6jt8oLpvOYHUb14n/8vgsoxbj0hpP58/SPTO5zbWxXl07jYtq8+ wG7oG/IG4N+7vEm70HpMEvlkj7cUxEVoE/Ct78OoeLxm1mrMWHbQrOEQL9o1R5ymoMC8 iB1h93a+ier9aPVuIILo7RUltWnXONP/IKX5k= 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=vtLnrQvI2QkwPJWNRuKMPFUHjK3UVpPxiw8esbGM3/I=; b=heNiQ+MPwAfcLqIT3SMYuJNVnN3BYw/EsTl4ppviaL9CbiJ7X20kqSPE5BzofPaCk+ 0t63w6YYnzFgql6uy3QiNDLAntsFPEfN89FlD/RYNOQPO45n8dDhzT3bYRVbIPbrHjTk mOQPRjoQc/I4vG4wPmdB9nF2+GI+bVEv8XoVuUAsS/bQS5BpIeMvZDPJ7isneWY4ggCk 8usYFWhF4ES3uOZL8bWiCGmKdX8J98Kg0N8/E3+OFW5Akig2/Peg3Ne2oyWu7XqwzjJI hVypj5UyktkpAKILThJ58YqllUogwazPh4KNNeQqDTrtKn/b6PvEMgMWK0um377VIn/m FZ7A== X-Gm-Message-State: AMCzsaWXuiyI6XdxBjXlHDGckY/FwDjr4mOgT53H9NsPu8LAUkcsilYA L4G1KFXM36OSa5CydLS80fBHBuejGW8= X-Google-Smtp-Source: AOwi7QDPwssEf0jLhyMsvKWYON02bLm3NYwOxVYa+O6uSEsxCNuVPN6rVkXAiZPISJ9S0XWyEQRiiQ== X-Received: by 10.84.235.72 with SMTP id g8mr12078495plt.86.1508258806342; Tue, 17 Oct 2017 09:46:46 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id b3sm17926225pgr.81.2017.10.17.09.46.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 17 Oct 2017 09:46:45 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Tue, 17 Oct 2017 22:16:31 +0530 Message-Id: <1508258793-5690-3-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1508258793-5690-1-git-send-email-bhupinder.thakur@linaro.org> References: <1508258793-5690-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] 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 --- CC: Ian Jackson CC: Wei Liu CC: Stefano Stabellini CC: Julien Grall 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;