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: 10033641 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 78E3D600C5 for ; Tue, 31 Oct 2017 06:57:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6874D284F6 for ; Tue, 31 Oct 2017 06:57:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5ADBF2899B; Tue, 31 Oct 2017 06:57:48 +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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,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 01B8B284F6 for ; Tue, 31 Oct 2017 06:57:46 +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 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-Google-Smtp-Source: ABhQp+Qlx/u8D8PVncL9f/oQsguwRqCdfxEthovVT/YS86O4f5VnFttKZ852JBm8q00PxxZyHvdqtA== 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" 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;