Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tools/kvm_stat: Fix kvm_exit filter name

The filter name is fixed to "exit_reason" for some kvm_exit events, no
matter what architect we have. Actually, the filter name ("exit_reason")
is only applicable to x86, meaning it's broken on other architects
including aarch64.

This fixes the issue by providing various kvm_exit filter names, depending
on architect we're on. Afterwards, the variable filter name is picked and
applied through ioctl(fd, SET_FILTER).

Reported-by: Andrew Jones <drjones@redhat.com>
Signed-off-by: Gavin Shan <gshan@redhat.com>
Cc: stable@vger.kernel.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

authored by

Gavin Shan and committed by
Paolo Bonzini
5fcf3a55 56871d44

+6 -2
+6 -2
tools/kvm/kvm_stat/kvm_stat
··· 270 270 def __init__(self, exit_reasons): 271 271 self.sc_perf_evt_open = 298 272 272 self.ioctl_numbers = IOCTL_NUMBERS 273 + self.exit_reason_field = 'exit_reason' 273 274 self.exit_reasons = exit_reasons 274 275 275 276 def debugfs_is_child(self, field): ··· 290 289 # numbers depend on the wordsize. 291 290 char_ptr_size = ctypes.sizeof(ctypes.c_char_p) 292 291 self.ioctl_numbers['SET_FILTER'] = 0x80002406 | char_ptr_size << 16 292 + self.exit_reason_field = 'exit_nr' 293 293 self.exit_reasons = {} 294 294 295 295 def debugfs_is_child(self, field): ··· 302 300 def __init__(self): 303 301 self.sc_perf_evt_open = 241 304 302 self.ioctl_numbers = IOCTL_NUMBERS 303 + self.exit_reason_field = 'esr_ec' 305 304 self.exit_reasons = AARCH64_EXIT_REASONS 306 305 307 306 def debugfs_is_child(self, field): ··· 314 311 def __init__(self): 315 312 self.sc_perf_evt_open = 331 316 313 self.ioctl_numbers = IOCTL_NUMBERS 314 + self.exit_reason_field = None 317 315 self.exit_reasons = None 318 316 319 317 def debugfs_is_child(self, field): ··· 545 541 """ 546 542 filters = {} 547 543 filters['kvm_userspace_exit'] = ('reason', USERSPACE_EXIT_REASONS) 548 - if ARCH.exit_reasons: 549 - filters['kvm_exit'] = ('exit_reason', ARCH.exit_reasons) 544 + if ARCH.exit_reason_field and ARCH.exit_reasons: 545 + filters['kvm_exit'] = (ARCH.exit_reason_field, ARCH.exit_reasons) 550 546 return filters 551 547 552 548 def _get_available_fields(self):