diff mbox

trace: Fix incorrect number of pages used for trace metadata

Message ID 1475157221-21828-1-git-send-email-igor.druzhinin@citrix.com (mailing list archive)
State New, archived
Headers show

Commit Message

Igor Druzhinin Sept. 29, 2016, 1:53 p.m. UTC
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 <igor.druzhinin@citrix.com>
---
 xen/common/trace.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox

Patch

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());