Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2695BC6379F for ; Sat, 4 Feb 2023 01:46:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233373AbjBDBqL (ORCPT ); Fri, 3 Feb 2023 20:46:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233155AbjBDBqD (ORCPT ); Fri, 3 Feb 2023 20:46:03 -0500 Received: from mail-pg1-x54a.google.com (mail-pg1-x54a.google.com [IPv6:2607:f8b0:4864:20::54a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CDE79A701A for ; Fri, 3 Feb 2023 17:46:00 -0800 (PST) Received: by mail-pg1-x54a.google.com with SMTP id 201-20020a6300d2000000b004ccf545f44fso3275313pga.12 for ; Fri, 03 Feb 2023 17:46:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=sK9fCHOjSKyHIh+9UN6lsnk5tQ2QvRukVyGEesqGDFI=; b=Ne0/c5nYli8A8YARILFynyC9hZ935JyXYB6DrRE7im9kDJtHvj3vGJoSSOGCcdIYpH 0Z879s/LyTnhsPL0ByVE8/WKKHxbY+xXrPifBZHtJgIJKMw5TdYlt6gqg9gsiMh2O1Ie gaS0QN6nDEHXZm3Lj40cxq1dHx6tmLZvxmtr60XmW0w2SRN+V75Uw1Z2z1hurE/5PI1R z9JHfqYzDh4QfFYkWA3j8KpXBkAKQcRab4rzg/XsMXqfUzZPzSbHG1/e8+DBBvj5CO7f 3Ghj3eMsnLqs3ZpCiQedw49VFBZemU0Q3t7r8f4q58jYqdKuMwu24DnlC98R382fSKf4 oEqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=sK9fCHOjSKyHIh+9UN6lsnk5tQ2QvRukVyGEesqGDFI=; b=RNqeOxlDnHKQRUvlCbej8I2hsf1vky8n8BtfHuNJRxuDCuoNj4Uo+UIPUpmULJ8UGy k2VD5LA3G7EqVaFNEvGs4l694huaiNonEBWJvtfGFD02We689XDn2RI/71z/TFX0ys4d SgbfXrJVNkcd7cPGjYrmOPyhFcMbdxyCj1OvaxzdI69ulOg/kjOz9o50YuYxjG9FQhZ1 azQbQOGJE+nWMreyv7wX95qqqXVp8sgxGeWdCN+aNKPrPPq1HPkRgTHXp/RjObEZ5vSn JNf2JysLvTxZCFYDWN/XkqTizHkFQu3tw0mb6BQTf8BxY/GLwMj9JGtNWk/6TtEXKBB0 amSg== X-Gm-Message-State: AO0yUKWY2ht/6ELCXCBSKLIu+F8UKPoLVFjFothPkyVrw7IVtJl2seli IFVM+jovT3Grx3H++16qJC8IUR6QeS3J X-Google-Smtp-Source: AK7set/DXsNXXKmR3W8P/zntCNkzjBACzoHPKLF2bCvwQAuGzTlayHGK6luIrJTqjl6Qeaay4dTCp24MGQF9 X-Received: from vipin.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:479f]) (user=vipinsh job=sendgmr) by 2002:a62:d41e:0:b0:592:4543:162c with SMTP id a30-20020a62d41e000000b005924543162cmr2771003pfh.33.1675475160132; Fri, 03 Feb 2023 17:46:00 -0800 (PST) Date: Fri, 3 Feb 2023 17:45:46 -0800 In-Reply-To: <20230204014547.583711-1-vipinsh@google.com> Mime-Version: 1.0 References: <20230204014547.583711-1-vipinsh@google.com> X-Mailer: git-send-email 2.39.1.519.gcb327c4b5f-goog Message-ID: <20230204014547.583711-4-vipinsh@google.com> Subject: [Patch v2 3/4] KVM: selftests: Add macro to generate KVM exit reason strings From: Vipin Sharma To: seanjc@google.com, pbonzini@redhat.com, maz@kernel.org, james.morse@arm.com, suzuki.poulose@arm.com, oliver.upton@linux.dev, yuzenghui@huawei.com, borntraeger@linux.ibm.com, frankja@linux.ibm.com, imbrenda@linux.ibm.com, david@redhat.com Cc: dmatlack@google.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sean Christopherson Add and use a macro to generate the KVM exit reason strings array instead of relying on developers to correctly copy+paste+edit each string. Signed-off-by: Sean Christopherson --- tools/testing/selftests/kvm/lib/kvm_util.c | 52 +++++++++++----------- 1 file changed, 27 insertions(+), 25 deletions(-) diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c b/tools/testing/selftests/kvm/lib/kvm_util.c index 56d5ea949cbb..2413ce511d20 100644 --- a/tools/testing/selftests/kvm/lib/kvm_util.c +++ b/tools/testing/selftests/kvm/lib/kvm_util.c @@ -1815,37 +1815,39 @@ void vm_dump(FILE *stream, struct kvm_vm *vm, uint8_t indent) vcpu_dump(stream, vcpu, indent + 2); } +#define KVM_EXIT_STRING(x) {KVM_EXIT_##x, #x} + /* Known KVM exit reasons */ static struct exit_reason { unsigned int reason; const char *name; } exit_reasons_known[] = { - {KVM_EXIT_UNKNOWN, "UNKNOWN"}, - {KVM_EXIT_EXCEPTION, "EXCEPTION"}, - {KVM_EXIT_IO, "IO"}, - {KVM_EXIT_HYPERCALL, "HYPERCALL"}, - {KVM_EXIT_DEBUG, "DEBUG"}, - {KVM_EXIT_HLT, "HLT"}, - {KVM_EXIT_MMIO, "MMIO"}, - {KVM_EXIT_IRQ_WINDOW_OPEN, "IRQ_WINDOW_OPEN"}, - {KVM_EXIT_SHUTDOWN, "SHUTDOWN"}, - {KVM_EXIT_FAIL_ENTRY, "FAIL_ENTRY"}, - {KVM_EXIT_INTR, "INTR"}, - {KVM_EXIT_SET_TPR, "SET_TPR"}, - {KVM_EXIT_TPR_ACCESS, "TPR_ACCESS"}, - {KVM_EXIT_S390_SIEIC, "S390_SIEIC"}, - {KVM_EXIT_S390_RESET, "S390_RESET"}, - {KVM_EXIT_DCR, "DCR"}, - {KVM_EXIT_NMI, "NMI"}, - {KVM_EXIT_INTERNAL_ERROR, "INTERNAL_ERROR"}, - {KVM_EXIT_OSI, "OSI"}, - {KVM_EXIT_PAPR_HCALL, "PAPR_HCALL"}, - {KVM_EXIT_DIRTY_RING_FULL, "DIRTY_RING_FULL"}, - {KVM_EXIT_X86_RDMSR, "RDMSR"}, - {KVM_EXIT_X86_WRMSR, "WRMSR"}, - {KVM_EXIT_XEN, "XEN"}, + KVM_EXIT_STRING(UNKNOWN), + KVM_EXIT_STRING(EXCEPTION), + KVM_EXIT_STRING(IO), + KVM_EXIT_STRING(HYPERCALL), + KVM_EXIT_STRING(DEBUG), + KVM_EXIT_STRING(HLT), + KVM_EXIT_STRING(MMIO), + KVM_EXIT_STRING(IRQ_WINDOW_OPEN), + KVM_EXIT_STRING(SHUTDOWN), + KVM_EXIT_STRING(FAIL_ENTRY), + KVM_EXIT_STRING(INTR), + KVM_EXIT_STRING(SET_TPR), + KVM_EXIT_STRING(TPR_ACCESS), + KVM_EXIT_STRING(S390_SIEIC), + KVM_EXIT_STRING(S390_RESET), + KVM_EXIT_STRING(DCR), + KVM_EXIT_STRING(NMI), + KVM_EXIT_STRING(INTERNAL_ERROR), + KVM_EXIT_STRING(OSI), + KVM_EXIT_STRING(PAPR_HCALL), + KVM_EXIT_STRING(DIRTY_RING_FULL), + KVM_EXIT_STRING(X86_RDMSR), + KVM_EXIT_STRING(X86_WRMSR), + KVM_EXIT_STRING(XEN), #ifdef KVM_EXIT_MEMORY_NOT_PRESENT - {KVM_EXIT_MEMORY_NOT_PRESENT, "MEMORY_NOT_PRESENT"}, + KVM_EXIT_STRING(MEMORY_NOT_PRESENT), #endif }; -- 2.39.1.519.gcb327c4b5f-goog