Path: blob/master/tools/testing/selftests/kvm/include/s390/debug_print.h
49000 views
/* SPDX-License-Identifier: GPL-2.0-only */1/*2* Definition for kernel virtual machines on s390x3*4* Copyright IBM Corp. 20245*6* Authors:7* Christoph Schlameuss <[email protected]>8*/910#ifndef SELFTEST_KVM_DEBUG_PRINT_H11#define SELFTEST_KVM_DEBUG_PRINT_H1213#include "asm/ptrace.h"14#include "kvm_util.h"15#include "sie.h"1617static inline void print_hex_bytes(const char *name, u64 addr, size_t len)18{19u64 pos;2021pr_debug("%s (%p)\n", name, (void *)addr);22pr_debug(" 0/0x00---------|");23if (len > 8)24pr_debug(" 8/0x08---------|");25if (len > 16)26pr_debug(" 16/0x10--------|");27if (len > 24)28pr_debug(" 24/0x18--------|");29for (pos = 0; pos < len; pos += 8) {30if ((pos % 32) == 0)31pr_debug("\n %3lu 0x%.3lx ", pos, pos);32pr_debug(" %16lx", *((u64 *)(addr + pos)));33}34pr_debug("\n");35}3637static inline void print_hex(const char *name, u64 addr)38{39print_hex_bytes(name, addr, 512);40}4142static inline void print_psw(struct kvm_run *run, struct kvm_s390_sie_block *sie_block)43{44pr_debug("flags:0x%x psw:0x%.16llx:0x%.16llx exit:%u %s\n",45run->flags,46run->psw_mask, run->psw_addr,47run->exit_reason, exit_reason_str(run->exit_reason));48pr_debug("sie_block psw:0x%.16llx:0x%.16llx\n",49sie_block->psw_mask, sie_block->psw_addr);50}5152static inline void print_run(struct kvm_run *run, struct kvm_s390_sie_block *sie_block)53{54print_hex_bytes("run", (u64)run, 0x150);55print_hex("sie_block", (u64)sie_block);56print_psw(run, sie_block);57}5859static inline void print_regs(struct kvm_run *run)60{61struct kvm_sync_regs *sync_regs = &run->s.regs;6263print_hex_bytes("GPRS", (u64)sync_regs->gprs, 8 * NUM_GPRS);64print_hex_bytes("ACRS", (u64)sync_regs->acrs, 4 * NUM_ACRS);65print_hex_bytes("CRS", (u64)sync_regs->crs, 8 * NUM_CRS);66}6768#endif /* SELFTEST_KVM_DEBUG_PRINT_H */697071