Skip to content

Commit dcb6105

Browse files
Gavin Shanjfvogel
authored andcommitted
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 <[email protected]> Signed-off-by: Gavin Shan <[email protected]> Cc: [email protected] Signed-off-by: Paolo Bonzini <[email protected]> (cherry picked from commit 5fcf3a5) Orabug: 30222757 Signed-off-by: Victor Erminpour <[email protected]> Reviewed-by: Somasundaram Krishnasamy <[email protected]>
1 parent f68a470 commit dcb6105

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

tools/kvm/kvm_stat/kvm_stat

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ class ArchX86(Arch):
270270
def __init__(self, exit_reasons):
271271
self.sc_perf_evt_open = 298
272272
self.ioctl_numbers = IOCTL_NUMBERS
273+
self.exit_reason_field = 'exit_reason'
273274
self.exit_reasons = exit_reasons
274275

275276
def debugfs_is_child(self, field):
@@ -289,6 +290,7 @@ class ArchPPC(Arch):
289290
# numbers depend on the wordsize.
290291
char_ptr_size = ctypes.sizeof(ctypes.c_char_p)
291292
self.ioctl_numbers['SET_FILTER'] = 0x80002406 | char_ptr_size << 16
293+
self.exit_reason_field = 'exit_nr'
292294
self.exit_reasons = {}
293295

294296
def debugfs_is_child(self, field):
@@ -300,6 +302,7 @@ class ArchA64(Arch):
300302
def __init__(self):
301303
self.sc_perf_evt_open = 241
302304
self.ioctl_numbers = IOCTL_NUMBERS
305+
self.exit_reason_field = 'esr_ec'
303306
self.exit_reasons = AARCH64_EXIT_REASONS
304307

305308
def debugfs_is_child(self, field):
@@ -311,6 +314,7 @@ class ArchS390(Arch):
311314
def __init__(self):
312315
self.sc_perf_evt_open = 331
313316
self.ioctl_numbers = IOCTL_NUMBERS
317+
self.exit_reason_field = None
314318
self.exit_reasons = None
315319

316320
def debugfs_is_child(self, field):
@@ -541,8 +545,8 @@ class TracepointProvider(Provider):
541545
"""
542546
filters = {}
543547
filters['kvm_userspace_exit'] = ('reason', USERSPACE_EXIT_REASONS)
544-
if ARCH.exit_reasons:
545-
filters['kvm_exit'] = ('exit_reason', ARCH.exit_reasons)
548+
if ARCH.exit_reason_field and ARCH.exit_reasons:
549+
filters['kvm_exit'] = (ARCH.exit_reason_field, ARCH.exit_reasons)
546550
return filters
547551

548552
def _get_available_fields(self):

0 commit comments

Comments
 (0)