From patchwork Thu Sep 29 13:53:41 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Druzhinin X-Patchwork-Id: 9356459 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 B10E7600C8 for ; Thu, 29 Sep 2016 13:56:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A276829A92 for ; Thu, 29 Sep 2016 13:56:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 96E6829A96; Thu, 29 Sep 2016 13:56:56 +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.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED 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 9CCBD29AB8 for ; Thu, 29 Sep 2016 13:56:55 +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 1bpbnB-0003qZ-09; Thu, 29 Sep 2016 13:54:28 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bpbnA-0003qT-BL for xen-devel@lists.xen.org; Thu, 29 Sep 2016 13:54:28 +0000 Received: from [85.158.143.35] by server-4.bemta-6.messagelabs.com id 0B/79-29421-31D1DE75; Thu, 29 Sep 2016 13:54:27 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrJLMWRWlGSWpSXmKPExsXitHSDva6w7Nt wgxOn+CyWfFzM4sDocXT3b6YAxijWzLyk/IoE1oz18x+yFczlqDgw6QNjA+MLti5GTg4JAX+J b9NmMIPYbAIGEqc2LWIBsUUEZCVWd81hB7GZBXwlJr/6ARYXBrL/3P4M1ssioCrxatF9sDivg KfEn+cQ9RICihLdzyaA1QgJqEkc7doFVSMocXLmExaImRISB1+8YIao55a4fXoq8wRGnllIym YhKVvAyLSKUaM4tagstUjX0EIvqSgzPaMkNzEzR9fQwEwvN7W4ODE9NScxqVgvOT93EyMwSBi AYAfjzY0BhxglOZiURHmvznsTLsSXlJ9SmZFYnBFfVJqTWnyIUYaDQ0mC95H023AhwaLU9NSK tMwcYLjCpCU4eJREeL+CpHmLCxJzizPTIVKnGBWlxHm7QRICIImM0jy4NliMXGKUlRLmZQQ6R IinILUoN7MEVf4VozgHo5IwL7sM0BSezLwSuOmvgBYzAS3OP/oGZHFJIkJKqoFxQd69K/dKZH fwZMdZyQQ9/Mgpfnaht+/zJe0KBX2HZ908ZmHz46zMjfzcbgt2zVXycXEK25r+JUyZFnJt+Xt ZucqtecdebncQT5Kvjfx5ekG+ul7GC2FW042Boc81921yO385vmvpjWXSWjy8d6LevgzhPnE0 sDBgYeLS1Z9WmHI+/tauvvaCEktxRqKhFnNRcSIADoIXLYwCAAA= X-Env-Sender: prvs=07309a4f8=igor.druzhinin@citrix.com X-Msg-Ref: server-14.tower-21.messagelabs.com!1475157265!30306164!1 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 8.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 9511 invoked from network); 29 Sep 2016 13:54:26 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-14.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 29 Sep 2016 13:54:26 -0000 X-IronPort-AV: E=Sophos;i="5.30,415,1470700800"; d="scan'208";a="389689997" From: Igor Druzhinin To: Date: Thu, 29 Sep 2016 13:53:41 +0000 Message-ID: <1475157221-21828-1-git-send-email-igor.druzhinin@citrix.com> X-Mailer: git-send-email 1.7.10.4 MIME-Version: 1.0 X-DLP: MIA2 Cc: george.dunlap@eu.citrix.com, Igor Druzhinin Subject: [Xen-devel] [PATCH] trace: Fix incorrect number of pages used for trace metadata 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: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP As long as t_info_first_offset is calculated in uint32_t offsets we need to multiply it by sizeof(uint32_t) in order to get the right number of pages for trace metadata. Not doing that makes it impossible to read the trace buffer correctly from userspace for some corner cases. Signed-off-by: Igor Druzhinin --- xen/common/trace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/common/trace.c b/xen/common/trace.c index f651cf3..a9563cc 100644 --- a/xen/common/trace.c +++ b/xen/common/trace.c @@ -149,7 +149,7 @@ static int calculate_tbuf_size(unsigned int pages, uint16_t t_info_first_offset) } t_info_words = num_online_cpus() * pages * sizeof(uint32_t); - t_info_pages = PFN_UP(t_info_first_offset + t_info_words); + t_info_pages = PFN_UP(t_info_first_offset * sizeof(uint32_t) + t_info_words); printk(XENLOG_INFO "xentrace: requesting %u t_info pages " "for %u trace pages on %u cpus\n", t_info_pages, pages, num_online_cpus());