From patchwork Sat Feb 4 01:45:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vipin Sharma X-Patchwork-Id: 52717 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1153769wrn; Fri, 3 Feb 2023 17:49:47 -0800 (PST) X-Google-Smtp-Source: AK7set+B0QdFihx128/AIYqfGi9pgTxSVwLxgoVYldUuOCtfTcp8zIXYD9h/QqXLTtNZDgo4vIcC X-Received: by 2002:a17:907:1607:b0:7d3:c516:6ef4 with SMTP id hb7-20020a170907160700b007d3c5166ef4mr17842786ejc.20.1675475387562; Fri, 03 Feb 2023 17:49:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675475387; cv=none; d=google.com; s=arc-20160816; b=K0p2vXc2eNdGF7+vrfJjJVKCQvh3dhx3vprYx0/N+dhMCq1V2EFcCyTZjZYyDkZnpo +9w8GQHhK/U5w6bydWq/Ao6VBD1hLnbdYfMWhNsUOvu9c02qd/euVKdmgDM6B6agUEgj eSj6nSifZlqAk7QomYXrKNa/JMJeSUH9iAF85AaTPUxsqo+kH76FysNHLsrf+45kT64d 9Vu87TcqyTZP57RmK/L5Eze8yWCy+x73RjEwuakzzUQuTwkynzDVcSEQ54Iryb7hK2dS 8cGDucpXuJPAfAGoSQl/VFwXml1JXGVLe1A7dxSmrHnUuLwrZoCqc97dIrQo/H0aOQDw g2kg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=sK9fCHOjSKyHIh+9UN6lsnk5tQ2QvRukVyGEesqGDFI=; b=usQkR3JsI6YCu5EPE95JJKC9MFOOi+9VgG1iFmLmUftHyYXkly1NQYW8kuQDi6iHOM y/f1xCUOyASbmkzlRDskSMSE2tHQ14O6wKB6DxTGRPcJk6Bbup4slfnHRK3Vlp/TSYMp 98Dqe6eoK0jaMtDot/zmGZDOKIyu/heI2Q15q39Y5KRxM/6Sx5oWl2gcBBeO3acnHrtR RjEHhj6gaEq5A8YI4umulDhxhGWzwxf4vWC5/wVzGh7QRlXJsxIWlemESMEM2A7ER8hU kbbNwQ7vOvUBIc9nzoaRfvFYjhP4LQ6whJd+fFPxAsXeYHyBh7Zp9sRe0ARFmPZtkflj iyVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="Ne0/c5nY"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e22-20020a17090658d600b0088d52f894c1si6247466ejs.861.2023.02.03.17.49.24; Fri, 03 Feb 2023 17:49:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="Ne0/c5nY"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233341AbjBDBqL (ORCPT + 99 others); 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-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 X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,UPPERCASE_50_75,USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756863279981888180?= X-GMAIL-MSGID: =?utf-8?q?1756863279981888180?= 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 };