From patchwork Wed Oct 25 09:27: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: 117041 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp628254qgn; Wed, 25 Oct 2017 02:29:25 -0700 (PDT) X-Google-Smtp-Source: ABhQp+Q6g4VO4H6zd3q1HPWbCf4O3JXSO5LxI7oBxGvy36vhBK+jovEpTuZmfXYOHv7QFTtjygMu X-Received: by 10.107.183.197 with SMTP id h188mr23221558iof.183.1508923765225; Wed, 25 Oct 2017 02:29:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508923765; cv=none; d=google.com; s=arc-20160816; b=LZevBEPQgMe7u0vPNDLmSIuTAz8Qe/lqtlaZV5XuIKy9mU8FgjTtCVAxMWmWg1iuDu nsVqEIWE7Fj6SPfJ6HS3GgXMljLExL/++kPOcE3beNISuONphl7SOe/3foedRSumvJ8F zf/HnPWEb1qXhzh46rWCEsrjSxmjTYlA6ksVymxcxGSbLZlUvtZUywPy2CqFU380dSor CCPkmwFJO4Z674mRjc9qLmsJuNDk4pvWSaFwHMfJKJj0Y4gcvje5pIj1ps6v7Sur8idg HYyaQnfM8PGfaBHNOZbfE52EJch6oUuwCiqereO9NusuZtDC/xc0jNzfLCShazGPTnOd 2zPA== 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=6eO6ybs1CeT47b+5zrVhgXDKd2S3c8FZLKrT5hgt4iY=; b=vyRVAmWfnw4loR8GQw43MxVoMYAFB6aGEVvuSYVR3WJgVK1P2rgkiG7l+hOMjwZSj1 7JaCjhxNgQJElFpdkQ7kJJZqKuVu+z8Orojv69N/sOnt1BnyIvmSjxzk86e09erMHfUl O1Dp0bxlsKfX1KpW/QPtO+Liz+8jNTawMYnDPFJab+9jJEwKwNyoFPUHIOqyyPKR6omY CODrcESA+aehxiXImUU5eP+XwMig5aBYUaScinnWCGdF7BefffL5mJjaAnpWjJBhBqfZ iwKXaVjsp0Xikh9DJD3Wkpm5PAL+64YiLpuZHlUUAgb0sAoWYm57SLjKhC+IFaM2nX0M 7e9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=FT+McP9j; 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 y141si1697316ioy.44.2017.10.25.02.29.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Oct 2017 02:29:25 -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=FT+McP9j; 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 1e7HyA-0003f8-QL; Wed, 25 Oct 2017 09:27:26 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e7Hy9-0003ew-U5 for xen-devel@lists.xenproject.org; Wed, 25 Oct 2017 09:27:26 +0000 Received: from [85.158.137.68] by server-14.bemta-3.messagelabs.com id AA/22-00431-DF850F95; Wed, 25 Oct 2017 09:27:25 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrPIsWRWlGSWpSXmKPExsVyMfTAYd0/ER8 iDZZMFLX4vmUykwOjx+EPV1gCGKNYM/OS8isSWDP+HpjHXnBJsGLD3w9sDYwP+boYuTiEBGYy Svx7vY4ZxGERmMcs0ffyBRuIIyHQzyoxceZX9i5GTiAnT+J8z2NGCDtNYvbZN2wQdrnEjQWXW UBsIQEtiaOnZrNCjG1hknjW0gjUwMHBJmAiMatDAqRGREBJ4t6qyUwgNcwC8xklmib1gg0SFk iWeDuvhQnEZhFQlWj/v4YVxOYV8Jb4PruJCWKZnMTNc53MIDangI/Ep5uTmSAWe0tc+baAcQK j4AJGhlWMGsWpRWWpRbpGJnpJRZnpGSW5iZk5uoYGxnq5qcXFiempOYlJxXrJ+bmbGIFBV8/A wLiD8dVxv0OMkhxMSqK84R4fIoX4kvJTKjMSizPii0pzUosPMcpwcChJ8EoCg1hIsCg1PbUiL TMHGP4waQkOHiURXl2QNG9xQWJucWY6ROoUoz3HhTuX/jBxHNhzC0h23LwLJJ/NfN3ALMSSl5 +XKiXOuz8cqE0ApC2jNA9uKCxeLzHKSgnzMjIwMAjxFKQW5WaWoMq/YhTnYFQS5j0IMoUnM68 EbvcroLOYgM5qUgU7qyQRISXVwLhu76wV2QcO5ubmMD3Iyp0YybKXd0NNdfuPrTu28Tm+z/bN n9X+OXnt8StXTmzhnfNyxtMmhW5/n+nTxf6eyy6bFxa/ysWGdWUS67OHmeGntp07cvnmsW3zb Jgll9XNW2/MGlo7q07bPDd/9SPjQzH6QgkhJcvC8rb4Oe5ouury3TTuQPIZmXwlluKMREMt5q LiRAByVcQo0gIAAA== X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-8.tower-31.messagelabs.com!1508923643!111936933!1 X-Originating-IP: [209.85.192.195] 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 26972 invoked from network); 25 Oct 2017 09:27:24 -0000 Received: from mail-pf0-f195.google.com (HELO mail-pf0-f195.google.com) (209.85.192.195) by server-8.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 25 Oct 2017 09:27:24 -0000 Received: by mail-pf0-f195.google.com with SMTP id n14so21783014pfh.8 for ; Wed, 25 Oct 2017 02:27:24 -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=Dr6lQC3lVVottQ+NHxC6FEsu1ICS2ANKP3R5G5Zhkgw=; b=FT+McP9jnUqLXJnom3b/fWEBpnOnjkxUwxT9PbH9l9a4Z9SFf9skhpEXFioMEQQFsR X6LtSJgzdMTDH0dkzdYcYsB/lZNgG4122jlJVW+qkey+ZvoEQqiiX4uF+3CpIHFc/j3m yKbmqAE0ay4EQcFsu/02AHjTkjLfbXhslgKI4= 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=Dr6lQC3lVVottQ+NHxC6FEsu1ICS2ANKP3R5G5Zhkgw=; b=JhiySzwhl71D/kfgKi+7KtNUtjzzffPs/MroWhQxYprAq3aUy8v8AlOc7z1rebHA69 P2Tzge8IjFXu2U9aCmj1YVxbRlkxso18yl5sw1+qjb8kFAqoA3RafUdRdNxe6DPC6KkQ 7KMu8QSdP0RQoDPdv4amRlNFDj3S6b9b2RXX2FoXvZL9V13t42ucyCHt2Pa8dtG0BNvJ cdgEnlkcgtg2mWDVU+cxzpFKGvrbzJDyy+a0xwqeNUHZtD/4gTJzV6clAJAVW+k1SZLB wnuxNn4QJ6BwBseC5VkrcFLMIcBdtxUN6q8bB9zS/a3YTVmsm23UnNDSJ9J+0KZRU+bJ x46A== X-Gm-Message-State: AMCzsaWs/4Al9iyvvhiJ5FbWoBFU86WpLGK/fgOYAux7BL+UFDHLmqm6 pqxbDs8soesHs1Cno3O7jcyyQ3JblHI= X-Received: by 10.98.75.77 with SMTP id y74mr1619875pfa.78.1508923642610; Wed, 25 Oct 2017 02:27:22 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id m17sm4022861pfh.28.2017.10.25.02.27.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 25 Oct 2017 02:27:22 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Wed, 25 Oct 2017 14:57:07 +0530 Message-Id: <1508923628-26446-4-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1508923628-26446-1-git-send-email-bhupinder.thakur@linaro.org> References: <1508923628-26446-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 4/5 v2] 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;