android_kernel_samsung_a7y1.../arch
Thomas Richter 826871f96e s390/cpum_sf: Check for SDBT and SDB consistency
[ Upstream commit 247f265fa502e7b17a0cb0cc330e055a36aafce4 ]

Each SBDT is located at a 4KB page and contains 512 entries.
Each entry of a SDBT points to a SDB, a 4KB page containing
sampled data. The last entry is a link to another SDBT page.

When an event is created the function sequence executed is:

  __hw_perf_event_init()
  +--> allocate_buffers()
       +--> realloc_sampling_buffers()
	    +---> alloc_sample_data_block()

Both functions realloc_sampling_buffers() and
alloc_sample_data_block() allocate pages and the allocation
can fail. This is handled correctly and all allocated
pages are freed and error -ENOMEM is returned to the
top calling function. Finally the event is not created.

Once the event has been created, the amount of initially
allocated SDBT and SDB can be too low. This is detected
during measurement interrupt handling, where the amount
of lost samples is calculated. If the number of lost samples
is too high considering sampling frequency and already allocated
SBDs, the number of SDBs is enlarged during the next execution
of cpumsf_pmu_enable().

If more SBDs need to be allocated, functions

       realloc_sampling_buffers()
       +---> alloc-sample_data_block()

are called to allocate more pages. Page allocation may fail
and the returned error is ignored. A SDBT and SDB setup
already exists.

However the modified SDBTs and SDBs might end up in a situation
where the first entry of an SDBT does not point to an SDB,
but another SDBT, basicly an SBDT without payload.
This can not be handled by the interrupt handler, where an SDBT
must have at least one entry pointing to an SBD.

Add a check to avoid SDBTs with out payload (SDBs) when enlarging
the buffer setup.

Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2020-04-07 13:23:41 +02:00
..
alpha
arc ARC: perf: Accommodate big-endian CPU 2020-04-07 12:37:04 +02:00
arm libfdt: define INT32_MAX and UINT32_MAX in libfdt_env.h 2020-04-07 13:23:39 +02:00
arm64 arm64: psci: Reduce the waiting time for cpu_psci_cpu_kill() 2020-04-07 13:20:51 +02:00
avr32
blackfin
c6x
cris
frv
h8300 h8300: use cc-cross-prefix instead of hardcoding h8300-unknown-linux- 2020-04-06 14:21:05 +02:00
hexagon
ia64 ia64:unwind: fix double free for mod->arch.init_unw_table 2020-04-07 07:38:19 +02:00
m32r
m68k bug.h: work around GCC PR82365 in BUG() 2020-04-06 19:20:52 +02:00
metag
microblaze microblaze: move "... is ready" messages to arch/microblaze/Makefile 2020-04-07 12:41:36 +02:00
mips MIPS: OCTEON: cvmx_pko_mem_debug8: use oldest forward compatible definition 2020-04-07 12:45:27 +02:00
mn10300
nios2
openrisc openrisc: Fix broken paths to arch/or32 2020-04-07 12:42:07 +02:00
parisc parisc: Fix vmap memory leak in ioremap()/iounmap() 2020-04-07 09:26:56 +02:00
powerpc libfdt: define INT32_MAX and UINT32_MAX in libfdt_env.h 2020-04-07 13:23:39 +02:00
s390 s390/cpum_sf: Check for SDBT and SDB consistency 2020-04-07 13:23:41 +02:00
score
sh pinctrl: sh-pfc: sh7734: Fix duplicate TCLK1_B 2020-04-07 13:20:55 +02:00
sparc sparc64: Rework xchg() definition to avoid warnings. 2020-04-07 12:35:33 +02:00
tile
um um: Make GCOV depend on !KCOV 2020-04-07 12:42:32 +02:00
unicore32
x86 x86/crash: Add a forward declaration of struct kimage 2020-04-07 13:21:37 +02:00
xtensa xtensa: fix TLB sanity checker 2020-04-07 13:12:45 +02:00
Kconfig