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: 10026195 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 4387F603D7 for ; Wed, 25 Oct 2017 09:29:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 254E026E3D for ; Wed, 25 Oct 2017 09:29:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 19CA9251F9; Wed, 25 Oct 2017 09:29:44 +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=-0.7 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_BL_SPAMCOP_NET, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM, RCVD_IN_SORBS_WEB, T_DKIM_INVALID autolearn=no 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 8F7FC251F9 for ; Wed, 25 Oct 2017 09:29:43 +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 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-Google-Smtp-Source: ABhQp+SJmIiVS7IZURnhuQQg/bsL2/XwevGTOUG15M9zPf1VX9bikw9MJ0B9teCurTgTUPxil8q7ew== 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" X-Virus-Scanned: ClamAV using ClamSMTP 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;