]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
4.19-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 9 Aug 2021 09:21:39 +0000 (11:21 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 9 Aug 2021 09:21:39 +0000 (11:21 +0200)
added patches:
optee-clear-stale-cache-entries-during-initialization.patch
scripts-tracing-fix-the-bug-that-can-t-parse-raw_trace_func.patch
tee-add-tee_shm_alloc_kernel_buf.patch
tracing-histogram-give-calculation-hist_fields-a-size.patch
tracing-histogram-rename-cpu-to-common_cpu.patch

queue-4.19/optee-clear-stale-cache-entries-during-initialization.patch [new file with mode: 0644]
queue-4.19/scripts-tracing-fix-the-bug-that-can-t-parse-raw_trace_func.patch [new file with mode: 0644]
queue-4.19/series
queue-4.19/tee-add-tee_shm_alloc_kernel_buf.patch [new file with mode: 0644]
queue-4.19/tracing-histogram-give-calculation-hist_fields-a-size.patch [new file with mode: 0644]
queue-4.19/tracing-histogram-rename-cpu-to-common_cpu.patch [new file with mode: 0644]

diff --git a/queue-4.19/optee-clear-stale-cache-entries-during-initialization.patch b/queue-4.19/optee-clear-stale-cache-entries-during-initialization.patch
new file mode 100644 (file)
index 0000000..618e7b4
--- /dev/null
@@ -0,0 +1,121 @@
+From b5c10dd04b7418793517e3286cde5c04759a86de Mon Sep 17 00:00:00 2001
+From: Tyler Hicks <tyhicks@linux.microsoft.com>
+Date: Mon, 14 Jun 2021 17:33:13 -0500
+Subject: optee: Clear stale cache entries during initialization
+
+From: Tyler Hicks <tyhicks@linux.microsoft.com>
+
+commit b5c10dd04b7418793517e3286cde5c04759a86de upstream.
+
+The shm cache could contain invalid addresses if
+optee_disable_shm_cache() was not called from the .shutdown hook of the
+previous kernel before a kexec. These addresses could be unmapped or
+they could point to mapped but unintended locations in memory.
+
+Clear the shared memory cache, while being careful to not translate the
+addresses returned from OPTEE_SMC_DISABLE_SHM_CACHE, during driver
+initialization. Once all pre-cache shm objects are removed, proceed with
+enabling the cache so that we know that we can handle cached shm objects
+with confidence later in the .shutdown hook.
+
+Cc: stable@vger.kernel.org
+Signed-off-by: Tyler Hicks <tyhicks@linux.microsoft.com>
+Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
+Reviewed-by: Sumit Garg <sumit.garg@linaro.org>
+Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/tee/optee/call.c          |   36 +++++++++++++++++++++++++++++++++---
+ drivers/tee/optee/core.c          |    9 +++++++++
+ drivers/tee/optee/optee_private.h |    1 +
+ 3 files changed, 43 insertions(+), 3 deletions(-)
+
+--- a/drivers/tee/optee/call.c
++++ b/drivers/tee/optee/call.c
+@@ -413,11 +413,13 @@ void optee_enable_shm_cache(struct optee
+ }
+ /**
+- * optee_disable_shm_cache() - Disables caching of some shared memory allocation
+- *                          in OP-TEE
++ * __optee_disable_shm_cache() - Disables caching of some shared memory
++ *                               allocation in OP-TEE
+  * @optee:    main service struct
++ * @is_mapped:        true if the cached shared memory addresses were mapped by this
++ *            kernel, are safe to dereference, and should be freed
+  */
+-void optee_disable_shm_cache(struct optee *optee)
++static void __optee_disable_shm_cache(struct optee *optee, bool is_mapped)
+ {
+       struct optee_call_waiter w;
+@@ -436,6 +438,13 @@ void optee_disable_shm_cache(struct opte
+               if (res.result.status == OPTEE_SMC_RETURN_OK) {
+                       struct tee_shm *shm;
++                      /*
++                       * Shared memory references that were not mapped by
++                       * this kernel must be ignored to prevent a crash.
++                       */
++                      if (!is_mapped)
++                              continue;
++
+                       shm = reg_pair_to_ptr(res.result.shm_upper32,
+                                             res.result.shm_lower32);
+                       tee_shm_free(shm);
+@@ -446,6 +455,27 @@ void optee_disable_shm_cache(struct opte
+       optee_cq_wait_final(&optee->call_queue, &w);
+ }
++/**
++ * optee_disable_shm_cache() - Disables caching of mapped shared memory
++ *                             allocations in OP-TEE
++ * @optee:    main service struct
++ */
++void optee_disable_shm_cache(struct optee *optee)
++{
++      return __optee_disable_shm_cache(optee, true);
++}
++
++/**
++ * optee_disable_unmapped_shm_cache() - Disables caching of shared memory
++ *                                      allocations in OP-TEE which are not
++ *                                      currently mapped
++ * @optee:    main service struct
++ */
++void optee_disable_unmapped_shm_cache(struct optee *optee)
++{
++      return __optee_disable_shm_cache(optee, false);
++}
++
+ #define PAGELIST_ENTRIES_PER_PAGE                             \
+       ((OPTEE_MSG_NONCONTIG_PAGE_SIZE / sizeof(u64)) - 1)
+--- a/drivers/tee/optee/core.c
++++ b/drivers/tee/optee/core.c
+@@ -619,6 +619,15 @@ static struct optee *optee_probe(struct
+       optee->memremaped_shm = memremaped_shm;
+       optee->pool = pool;
++      /*
++       * Ensure that there are no pre-existing shm objects before enabling
++       * the shm cache so that there's no chance of receiving an invalid
++       * address during shutdown. This could occur, for example, if we're
++       * kexec booting from an older kernel that did not properly cleanup the
++       * shm cache.
++       */
++      optee_disable_unmapped_shm_cache(optee);
++
+       optee_enable_shm_cache(optee);
+       pr_info("initialized driver\n");
+--- a/drivers/tee/optee/optee_private.h
++++ b/drivers/tee/optee/optee_private.h
+@@ -160,6 +160,7 @@ int optee_cancel_req(struct tee_context
+ void optee_enable_shm_cache(struct optee *optee);
+ void optee_disable_shm_cache(struct optee *optee);
++void optee_disable_unmapped_shm_cache(struct optee *optee);
+ int optee_shm_register(struct tee_context *ctx, struct tee_shm *shm,
+                      struct page **pages, size_t num_pages,
diff --git a/queue-4.19/scripts-tracing-fix-the-bug-that-can-t-parse-raw_trace_func.patch b/queue-4.19/scripts-tracing-fix-the-bug-that-can-t-parse-raw_trace_func.patch
new file mode 100644 (file)
index 0000000..c82bd7a
--- /dev/null
@@ -0,0 +1,66 @@
+From 1c0cec64a7cc545eb49f374a43e9f7190a14defa Mon Sep 17 00:00:00 2001
+From: Hui Su <suhui@zeku.com>
+Date: Fri, 11 Jun 2021 10:21:07 +0800
+Subject: scripts/tracing: fix the bug that can't parse raw_trace_func
+
+From: Hui Su <suhui@zeku.com>
+
+commit 1c0cec64a7cc545eb49f374a43e9f7190a14defa upstream.
+
+Since commit 77271ce4b2c0 ("tracing: Add irq, preempt-count and need resched info
+to default trace output"), the default trace output format has been changed to:
+          <idle>-0       [009] d.h. 22420.068695: _raw_spin_lock_irqsave <-hrtimer_interrupt
+          <idle>-0       [000] ..s. 22420.068695: _nohz_idle_balance <-run_rebalance_domains
+          <idle>-0       [011] d.h. 22420.068695: account_process_tick <-update_process_times
+
+origin trace output format:(before v3.2.0)
+     # tracer: nop
+     #
+     #           TASK-PID    CPU#    TIMESTAMP  FUNCTION
+     #              | |       |          |         |
+          migration/0-6     [000]    50.025810: rcu_note_context_switch <-__schedule
+          migration/0-6     [000]    50.025812: trace_rcu_utilization <-rcu_note_context_switch
+          migration/0-6     [000]    50.025813: rcu_sched_qs <-rcu_note_context_switch
+          migration/0-6     [000]    50.025815: rcu_preempt_qs <-rcu_note_context_switch
+          migration/0-6     [000]    50.025817: trace_rcu_utilization <-rcu_note_context_switch
+          migration/0-6     [000]    50.025818: debug_lockdep_rcu_enabled <-__schedule
+          migration/0-6     [000]    50.025820: debug_lockdep_rcu_enabled <-__schedule
+
+The draw_functrace.py(introduced in v2.6.28) can't parse the new version format trace_func,
+So we need modify draw_functrace.py to adapt the new version trace output format.
+
+Link: https://lkml.kernel.org/r/20210611022107.608787-1-suhui@zeku.com
+
+Cc: stable@vger.kernel.org
+Fixes: 77271ce4b2c0 tracing: Add irq, preempt-count and need resched info to default trace output
+Signed-off-by: Hui Su <suhui@zeku.com>
+Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ scripts/tracing/draw_functrace.py |    6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+--- a/scripts/tracing/draw_functrace.py
++++ b/scripts/tracing/draw_functrace.py
+@@ -17,7 +17,7 @@ Usage:
+       $ cat /sys/kernel/debug/tracing/trace_pipe > ~/raw_trace_func
+       Wait some times but not too much, the script is a bit slow.
+       Break the pipe (Ctrl + Z)
+-      $ scripts/draw_functrace.py < raw_trace_func > draw_functrace
++      $ scripts/tracing/draw_functrace.py < ~/raw_trace_func > draw_functrace
+       Then you have your drawn trace in draw_functrace
+ """
+@@ -103,10 +103,10 @@ def parseLine(line):
+       line = line.strip()
+       if line.startswith("#"):
+               raise CommentLineException
+-      m = re.match("[^]]+?\\] +([0-9.]+): (\\w+) <-(\\w+)", line)
++      m = re.match("[^]]+?\\] +([a-z.]+) +([0-9.]+): (\\w+) <-(\\w+)", line)
+       if m is None:
+               raise BrokenLineException
+-      return (m.group(1), m.group(2), m.group(3))
++      return (m.group(2), m.group(3), m.group(4))
+ def main():
index 921167ed23220737e38efd12d799c5258728f367..e125794a411bcf970d9b69c15a42de64272b45b3 100644 (file)
@@ -29,3 +29,8 @@ usb-gadget-f_hid-added-get_idle-and-set_idle-handlers.patch
 usb-gadget-f_hid-fixed-null-pointer-dereference.patch
 usb-gadget-f_hid-idle-uses-the-highest-byte-for-duration.patch
 usb-otg-fsm-fix-hrtimer-list-corruption.patch
+scripts-tracing-fix-the-bug-that-can-t-parse-raw_trace_func.patch
+tracing-histogram-give-calculation-hist_fields-a-size.patch
+tracing-histogram-rename-cpu-to-common_cpu.patch
+optee-clear-stale-cache-entries-during-initialization.patch
+tee-add-tee_shm_alloc_kernel_buf.patch
diff --git a/queue-4.19/tee-add-tee_shm_alloc_kernel_buf.patch b/queue-4.19/tee-add-tee_shm_alloc_kernel_buf.patch
new file mode 100644 (file)
index 0000000..b92c4bb
--- /dev/null
@@ -0,0 +1,60 @@
+From dc7019b7d0e188d4093b34bd0747ed0d668c63bf Mon Sep 17 00:00:00 2001
+From: Jens Wiklander <jens.wiklander@linaro.org>
+Date: Mon, 14 Jun 2021 17:33:14 -0500
+Subject: tee: add tee_shm_alloc_kernel_buf()
+
+From: Jens Wiklander <jens.wiklander@linaro.org>
+
+commit dc7019b7d0e188d4093b34bd0747ed0d668c63bf upstream.
+
+Adds a new function tee_shm_alloc_kernel_buf() to allocate shared memory
+from a kernel driver. This function can later be made more lightweight
+by unnecessary dma-buf export.
+
+Cc: stable@vger.kernel.org
+Reviewed-by: Tyler Hicks <tyhicks@linux.microsoft.com>
+Reviewed-by: Sumit Garg <sumit.garg@linaro.org>
+Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/tee/tee_shm.c   |   18 ++++++++++++++++++
+ include/linux/tee_drv.h |    1 +
+ 2 files changed, 19 insertions(+)
+
+--- a/drivers/tee/tee_shm.c
++++ b/drivers/tee/tee_shm.c
+@@ -228,6 +228,24 @@ struct tee_shm *tee_shm_priv_alloc(struc
+ }
+ EXPORT_SYMBOL_GPL(tee_shm_priv_alloc);
++/**
++ * tee_shm_alloc_kernel_buf() - Allocate shared memory for kernel buffer
++ * @ctx:      Context that allocates the shared memory
++ * @size:     Requested size of shared memory
++ *
++ * The returned memory registered in secure world and is suitable to be
++ * passed as a memory buffer in parameter argument to
++ * tee_client_invoke_func(). The memory allocated is later freed with a
++ * call to tee_shm_free().
++ *
++ * @returns a pointer to 'struct tee_shm'
++ */
++struct tee_shm *tee_shm_alloc_kernel_buf(struct tee_context *ctx, size_t size)
++{
++      return tee_shm_alloc(ctx, size, TEE_SHM_MAPPED | TEE_SHM_DMA_BUF);
++}
++EXPORT_SYMBOL_GPL(tee_shm_alloc_kernel_buf);
++
+ struct tee_shm *tee_shm_register(struct tee_context *ctx, unsigned long addr,
+                                size_t length, u32 flags)
+ {
+--- a/include/linux/tee_drv.h
++++ b/include/linux/tee_drv.h
+@@ -317,6 +317,7 @@ void *tee_get_drvdata(struct tee_device
+  * @returns a pointer to 'struct tee_shm'
+  */
+ struct tee_shm *tee_shm_alloc(struct tee_context *ctx, size_t size, u32 flags);
++struct tee_shm *tee_shm_alloc_kernel_buf(struct tee_context *ctx, size_t size);
+ /**
+  * tee_shm_priv_alloc() - Allocate shared memory privately
diff --git a/queue-4.19/tracing-histogram-give-calculation-hist_fields-a-size.patch b/queue-4.19/tracing-histogram-give-calculation-hist_fields-a-size.patch
new file mode 100644 (file)
index 0000000..1c203ca
--- /dev/null
@@ -0,0 +1,65 @@
+From 2c05caa7ba8803209769b9e4fe02c38d77ae88d0 Mon Sep 17 00:00:00 2001
+From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
+Date: Fri, 30 Jul 2021 17:19:51 -0400
+Subject: tracing / histogram: Give calculation hist_fields a size
+
+From: Steven Rostedt (VMware) <rostedt@goodmis.org>
+
+commit 2c05caa7ba8803209769b9e4fe02c38d77ae88d0 upstream.
+
+When working on my user space applications, I found a bug in the synthetic
+event code where the automated synthetic event field was not matching the
+event field calculation it was attached to. Looking deeper into it, it was
+because the calculation hist_field was not given a size.
+
+The synthetic event fields are matched to their hist_fields either by
+having the field have an identical string type, or if that does not match,
+then the size and signed values are used to match the fields.
+
+The problem arose when I tried to match a calculation where the fields
+were "unsigned int". My tool created a synthetic event of type "u32". But
+it failed to match. The string was:
+
+  diff=field1-field2:onmatch(event).trace(synth,$diff)
+
+Adding debugging into the kernel, I found that the size of "diff" was 0.
+And since it was given "unsigned int" as a type, the histogram fallback
+code used size and signed. The signed matched, but the size of u32 (4) did
+not match zero, and the event failed to be created.
+
+This can be worse if the field you want to match is not one of the
+acceptable fields for a synthetic event. As event fields can have any type
+that is supported in Linux, this can cause an issue. For example, if a
+type is an enum. Then there's no way to use that with any calculations.
+
+Have the calculation field simply take on the size of what it is
+calculating.
+
+Link: https://lkml.kernel.org/r/20210730171951.59c7743f@oasis.local.home
+
+Cc: Tom Zanussi <zanussi@kernel.org>
+Cc: Masami Hiramatsu <mhiramat@kernel.org>
+Cc: Namhyung Kim <namhyung@kernel.org>
+Cc: Ingo Molnar <mingo@kernel.org>
+Cc: Andrew Morton <akpm@linux-foundation.org>
+Cc: stable@vger.kernel.org
+Fixes: 100719dcef447 ("tracing: Add simple expression support to hist triggers")
+Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ kernel/trace/trace_events_hist.c |    4 ++++
+ 1 file changed, 4 insertions(+)
+
+--- a/kernel/trace/trace_events_hist.c
++++ b/kernel/trace/trace_events_hist.c
+@@ -2911,6 +2911,10 @@ static struct hist_field *parse_expr(str
+       expr->operands[0] = operand1;
+       expr->operands[1] = operand2;
++
++      /* The operand sizes should be the same, so just pick one */
++      expr->size = operand1->size;
++
+       expr->operator = field_op;
+       expr->name = expr_str(expr, 0);
+       expr->type = kstrdup(operand1->type, GFP_KERNEL);
diff --git a/queue-4.19/tracing-histogram-rename-cpu-to-common_cpu.patch b/queue-4.19/tracing-histogram-rename-cpu-to-common_cpu.patch
new file mode 100644 (file)
index 0000000..d4ef28e
--- /dev/null
@@ -0,0 +1,151 @@
+From 1e3bac71c5053c99d438771fc9fa5082ae5d90aa Mon Sep 17 00:00:00 2001
+From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
+Date: Wed, 21 Jul 2021 11:00:53 -0400
+Subject: tracing/histogram: Rename "cpu" to "common_cpu"
+
+From: Steven Rostedt (VMware) <rostedt@goodmis.org>
+
+commit 1e3bac71c5053c99d438771fc9fa5082ae5d90aa upstream.
+
+Currently the histogram logic allows the user to write "cpu" in as an
+event field, and it will record the CPU that the event happened on.
+
+The problem with this is that there's a lot of events that have "cpu"
+as a real field, and using "cpu" as the CPU it ran on, makes it
+impossible to run histograms on the "cpu" field of events.
+
+For example, if I want to have a histogram on the count of the
+workqueue_queue_work event on its cpu field, running:
+
+ ># echo 'hist:keys=cpu' > events/workqueue/workqueue_queue_work/trigger
+
+Gives a misleading and wrong result.
+
+Change the command to "common_cpu" as no event should have "common_*"
+fields as that's a reserved name for fields used by all events. And
+this makes sense here as common_cpu would be a field used by all events.
+
+Now we can even do:
+
+ ># echo 'hist:keys=common_cpu,cpu if cpu < 100' > events/workqueue/workqueue_queue_work/trigger
+ ># cat events/workqueue/workqueue_queue_work/hist
+ # event histogram
+ #
+ # trigger info: hist:keys=common_cpu,cpu:vals=hitcount:sort=hitcount:size=2048 if cpu < 100 [active]
+ #
+
+ { common_cpu:          0, cpu:          2 } hitcount:          1
+ { common_cpu:          0, cpu:          4 } hitcount:          1
+ { common_cpu:          7, cpu:          7 } hitcount:          1
+ { common_cpu:          0, cpu:          7 } hitcount:          1
+ { common_cpu:          0, cpu:          1 } hitcount:          1
+ { common_cpu:          0, cpu:          6 } hitcount:          2
+ { common_cpu:          0, cpu:          5 } hitcount:          2
+ { common_cpu:          1, cpu:          1 } hitcount:          4
+ { common_cpu:          6, cpu:          6 } hitcount:          4
+ { common_cpu:          5, cpu:          5 } hitcount:         14
+ { common_cpu:          4, cpu:          4 } hitcount:         26
+ { common_cpu:          0, cpu:          0 } hitcount:         39
+ { common_cpu:          2, cpu:          2 } hitcount:        184
+
+Now for backward compatibility, I added a trick. If "cpu" is used, and
+the field is not found, it will fall back to "common_cpu" and work as
+it did before. This way, it will still work for old programs that use
+"cpu" to get the actual CPU, but if the event has a "cpu" as a field, it
+will get that event's "cpu" field, which is probably what it wants
+anyway.
+
+I updated the tracefs/README to include documentation about both the
+common_timestamp and the common_cpu. This way, if that text is present in
+the README, then an application can know that common_cpu is supported over
+just plain "cpu".
+
+Link: https://lkml.kernel.org/r/20210721110053.26b4f641@oasis.local.home
+
+Cc: Namhyung Kim <namhyung@kernel.org>
+Cc: Ingo Molnar <mingo@kernel.org>
+Cc: Andrew Morton <akpm@linux-foundation.org>
+Cc: stable@vger.kernel.org
+Fixes: 8b7622bf94a44 ("tracing: Add cpu field for hist triggers")
+Reviewed-by: Tom Zanussi <zanussi@kernel.org>
+Reviewed-by: Masami Hiramatsu <mhiramat@kernel.org>
+Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ Documentation/trace/histogram.rst |    2 +-
+ kernel/trace/trace.c              |    4 ++++
+ kernel/trace/trace_events_hist.c  |   21 +++++++++++++++------
+ 3 files changed, 20 insertions(+), 7 deletions(-)
+
+--- a/Documentation/trace/histogram.rst
++++ b/Documentation/trace/histogram.rst
+@@ -191,7 +191,7 @@ Documentation written by Tom Zanussi
+                                 with the event, in nanoseconds.  May be
+                               modified by .usecs to have timestamps
+                               interpreted as microseconds.
+-    cpu                    int  the cpu on which the event occurred.
++    common_cpu             int  the cpu on which the event occurred.
+     ====================== ==== =======================================
+ Extended error information
+--- a/kernel/trace/trace.c
++++ b/kernel/trace/trace.c
+@@ -4727,6 +4727,10 @@ static const char readme_msg[] =
+       "\t            [:pause][:continue][:clear]\n"
+       "\t            [:name=histname1]\n"
+       "\t            [if <filter>]\n\n"
++      "\t    Note, special fields can be used as well:\n"
++      "\t            common_timestamp - to record current timestamp\n"
++      "\t            common_cpu - to record the CPU the event happened on\n"
++      "\n"
+       "\t    When a matching event is hit, an entry is added to a hash\n"
+       "\t    table using the key(s) and value(s) named, and the value of a\n"
+       "\t    sum called 'hitcount' is incremented.  Keys and values\n"
+--- a/kernel/trace/trace_events_hist.c
++++ b/kernel/trace/trace_events_hist.c
+@@ -1773,7 +1773,7 @@ static const char *hist_field_name(struc
+                field->flags & HIST_FIELD_FL_ALIAS)
+               field_name = hist_field_name(field->operands[0], ++level);
+       else if (field->flags & HIST_FIELD_FL_CPU)
+-              field_name = "cpu";
++              field_name = "common_cpu";
+       else if (field->flags & HIST_FIELD_FL_EXPR ||
+                field->flags & HIST_FIELD_FL_VAR_REF) {
+               if (field->system) {
+@@ -2627,14 +2627,23 @@ parse_field(struct hist_trigger_data *hi
+               hist_data->enable_timestamps = true;
+               if (*flags & HIST_FIELD_FL_TIMESTAMP_USECS)
+                       hist_data->attrs->ts_in_usecs = true;
+-      } else if (strcmp(field_name, "cpu") == 0)
++      } else if (strcmp(field_name, "common_cpu") == 0)
+               *flags |= HIST_FIELD_FL_CPU;
+       else {
+               field = trace_find_event_field(file->event_call, field_name);
+               if (!field || !field->size) {
+-                      hist_err("Couldn't find field: ", field_name);
+-                      field = ERR_PTR(-EINVAL);
+-                      goto out;
++                      /*
++                       * For backward compatibility, if field_name
++                       * was "cpu", then we treat this the same as
++                       * common_cpu.
++                       */
++                      if (strcmp(field_name, "cpu") == 0) {
++                              *flags |= HIST_FIELD_FL_CPU;
++                      } else {
++                              hist_err("Couldn't find field: ", field_name);
++                              field = ERR_PTR(-EINVAL);
++                              goto out;
++                      }
+               }
+       }
+  out:
+@@ -5052,7 +5061,7 @@ static void hist_field_print(struct seq_
+               seq_printf(m, "%s=", hist_field->var.name);
+       if (hist_field->flags & HIST_FIELD_FL_CPU)
+-              seq_puts(m, "cpu");
++              seq_puts(m, "common_cpu");
+       else if (field_name) {
+               if (hist_field->flags & HIST_FIELD_FL_VAR_REF ||
+                   hist_field->flags & HIST_FIELD_FL_ALIAS)