From patchwork Tue Dec 13 00:16:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 2891 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2544575wrr; Mon, 12 Dec 2022 16:18:28 -0800 (PST) X-Google-Smtp-Source: AA0mqf6v1HEwBGYJKTli1d5HPraXLICteDFgLlephzaDogxpxxbOhqN1othhW4Go61zTz4oNrKYr X-Received: by 2002:a17:902:b618:b0:189:af28:fd8d with SMTP id b24-20020a170902b61800b00189af28fd8dmr17793046pls.1.1670890708366; Mon, 12 Dec 2022 16:18:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670890708; cv=none; d=google.com; s=arc-20160816; b=hVVwckyWNTadgBQqAEwJ/goiKNdFpXCTjHICVeXgrO/ufMlOLAynMrwDlCakbpgnUW uFKiF+fqBxPtWqXRX4g/slj9qL8kvkYbTcXamXWvF9nd14eTmm9HgLuWa7iBeS0VwYxi vccmzE5p13auqAWj2O4f1ouL8XK33f/a5JJzLQiGzqqZQ90IpKoqHxxyKmHuVs8QvubD teGPam/g+MgmcI8rNcw+kGTw/I9dqx3KiFPCwLwo4yto7dqwEs5nzLjmzvAMmc9ArmfT lKkP02IRegxawVAc3l26Q4MaP98HkQC0Enwss3U8n3Y2h5QOAwqWtYPqHrrwMc2MEPlX i81Q== 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:mime-version:date :reply-to:dkim-signature; bh=rrmKIRMf4Mq2msGAMjuH9G/DlO6PhwIb4et9Vyytf0s=; b=F7lPkk1iooR3ykY6F5UPgOBAbG2cKf9cphZbQG6vPCejvZlj9iwC+I73sImJNXDifR P+S+m3LQwCH72w+jpMQqsRiTjLNXWoOfpRkAA7QyRcelLTFv2tfl/yT3+UKsHEg9opah MbKi39uYixFT9eU5yRa7/s+0sSGix51vNShifErHq0PNLJuqc2GRcAwD/wAuAo4bfl9u GO/prJtyXH2l/zYw7awMuU/VWQ7Rq5AhQxDEqnC5gO0AU0SnHhskJ+I03EYv0mBQWkHq t6BnfB0V1J/QvVa8TMNaoo44jpUHO8kIBM3Kq3t0Zwz8zAacRUmapLeejHCy4EhYwqbW InNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="Y/SoLe17"; 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 j9-20020a170903024900b001865c1ecf30si12550401plh.176.2022.12.12.16.18.15; Mon, 12 Dec 2022 16:18:28 -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="Y/SoLe17"; 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 S234063AbiLMARA (ORCPT + 99 others); Mon, 12 Dec 2022 19:17:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229975AbiLMAQ6 (ORCPT ); Mon, 12 Dec 2022 19:16:58 -0500 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 504931B1DF for ; Mon, 12 Dec 2022 16:16:57 -0800 (PST) Received: by mail-yb1-xb49.google.com with SMTP id t9-20020a5b03c9000000b006cff5077dc9so14754853ybp.3 for ; Mon, 12 Dec 2022 16:16:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:mime-version:date:reply-to:from:to:cc :subject:date:message-id:reply-to; bh=rrmKIRMf4Mq2msGAMjuH9G/DlO6PhwIb4et9Vyytf0s=; b=Y/SoLe17F+HoJZwya7YFOMVPVWxIyS8YXDXAdkZKURoZhYboc1qqDhxRYkM8qd/fyn zV4AKnvonZDIf4kBxS6BbqKkYvK++Z8SlakM9rrpZf/WnJthiD/WaPvC4mId1Hi85VXx HEnTLJKfq/AiMkE+A1lvFD7n5RUyEVn7KE12qMAkazwYdkxp/onbTYKAwGSZxx/+wvCu AkCHnFjwsiycANQDr7f8nJl13jr3Aq6KbcvSvBjixq+cK42hwQ3dC8wgvpt4LO7Wo9ul DCX6EzwtU8238LHHvhH1M16EyNBESvafX2Bsjx0/y3efzS0Lla4Z0vEPMEkwmHimVswS SmYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:mime-version:date:reply-to :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=rrmKIRMf4Mq2msGAMjuH9G/DlO6PhwIb4et9Vyytf0s=; b=iPPVa6to9mgE7ejoC+vrI+zYm5sEo4q6HjHEvhAmF/xuO7iN4vBV5E0vD55ZDYeTK/ qo48+EkP5iwCrwTlK3A+tpTYn71RhKOhyKVzKsfdhFhBeKVNrUYoxrA1yNCwulynGFFv I/l5Y1csRy/fY2FSwxI/HqY1i9fEdP3SUbcO8gZwAICtr00Po2NztG2SrfZGbD6mwqMq bQdzwwentfQo9dImXR/bV7BOV1oh3XQ1OBtR/qvx0rMCXUjbpEdZjLBvavF1eAQOXT0P VfeXkd7J3qKR7etttxZj6RZrlRXeM9mFbWDCyTphLUEBrdWZ34CI2tFqbdLi11k7233p jVgw== X-Gm-Message-State: ANoB5pkjWuBrOrLxMGi83o1d4iRO13yXaV9YvZYMZo+ZurxJpnXxYm2j Jy+Zamzygjg3EfgHJELiFGidxQvoFqk= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a25:2397:0:b0:724:2a55:aadb with SMTP id j145-20020a252397000000b007242a55aadbmr1005565ybj.576.1670890616579; Mon, 12 Dec 2022 16:16:56 -0800 (PST) Reply-To: Sean Christopherson Date: Tue, 13 Dec 2022 00:16:39 +0000 Mime-Version: 1.0 X-Mailer: git-send-email 2.39.0.rc1.256.g54fd8350bd-goog Message-ID: <20221213001653.3852042-1-seanjc@google.com> Subject: [PATCH 00/14] KVM: selftests: Clang fixes, Makefile cleanup From: Sean Christopherson To: Paolo Bonzini , Marc Zyngier , Paul Walmsley , Palmer Dabbelt , Albert Ou , Nathan Chancellor , Nick Desaulniers Cc: James Morse , Alexandru Elisei , Suzuki K Poulose , Oliver Upton , Tom Rix , kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, kvmarm@lists.cs.columbia.edu, linux-riscv@lists.infradead.org, llvm@lists.linux.dev, linux-kernel@vger.kernel.org, Ricardo Koller , Sean Christopherson , Aaron Lewis , Raghavendra Rao Ananta 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,USER_IN_DEF_DKIM_WL autolearn=ham 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?1752055895041066901?= X-GMAIL-MSGID: =?utf-8?q?1752055895041066901?= Fix a variety of KVM selftests issues exposed by clang, and rework the Makefile and .gitignore to reduce the maintenance burden of selftests. For the Makefile, programmatically generate the list of targets by looking for .c files, and opt-out via a dummy macro in the source instead of forcing architectures to opt-in. The opt-out approach is less error prone (harder to forget to add an arch), doesn't generate unnecessary conflicts if multiple tests are added simultanesouly, and makes it much easier to understand which tests aren't supported, e.g. $ git grep TEST_UNSUPPORTED | grep aarch64 hardware_disable_test.c:TEST_UNSUPPORTED(aarch64); max_guest_memory_test.c:TEST_UNSUPPORTED(aarch64); system_counter_offset_test.c:TEST_UNSUPPORTED(aarch64); This all started when trying to reproduce clang build errors reported by Raghu and Aaron that were introduced by commit 6b6f71484bf4 ("KVM: selftests: Implement memcmp(), memcpy(), and memset() for guest use"). Just getting selftests to compile with clang was a nightmare, as it took me several hours to realize that "CC=clang make" and "make CC=clang" aren't equivalent, and that the "include ../lib.mak" buried halfway through the Makefile was overriding "CC=clang make". After too many hours fighting to get clang working, my frustration with the Makefile boiled over a bit... Note, I have fixes for the RISC-V RSEQ bugs (outside of selftests/kvm) that I'll post separately. Tested on x86 and arm, build tested on s390x and RISC-V, all with both gcc and clang. Sean Christopherson (14): KVM: selftests: Define literal to asm constraint in aarch64 as unsigned long KVM: selftests: Delete dead code in x86_64/vmx_tsc_adjust_test.c KVM: selftests: Fix divide-by-zero bug in memslot_perf_test KVM: selftests: Use pattern matching in .gitignore KVM: selftests: Fix a typo in x86-64's kvm_get_cpu_address_width() KVM: selftests: Rename UNAME_M to ARCH_DIR, fill explicitly for x86 KVM: selftests: Use proper function prototypes in probing code KVM: selftests: Probe -no-pie with actual CFLAGS used to compile KVM: selftests: Explicitly disable builtins for mem*() overrides KVM: selftests: Include lib.mk before consuming $(CC) KVM: selftests: Disable "gnu-variable-sized-type-not-at-end" warning KVM: selftests: Use wildcards to find library source files KVM: selftests: Use wildcards to find targets and test source files KVM: selftests: Enable RSEQ test for RISC-V tools/testing/selftests/kvm/.gitignore | 91 +------ tools/testing/selftests/kvm/Makefile | 229 +++--------------- .../selftests/kvm/aarch64/page_fault_test.c | 2 +- .../selftests/kvm/access_tracking_perf_test.c | 3 + .../selftests/kvm/dirty_log_perf_test.c | 3 + .../selftests/kvm/hardware_disable_test.c | 4 + .../testing/selftests/kvm/include/test_util.h | 11 + .../selftests/kvm/lib/x86_64/processor.c | 2 +- .../selftests/kvm/max_guest_memory_test.c | 4 + .../kvm/memslot_modification_stress_test.c | 3 + .../testing/selftests/kvm/memslot_perf_test.c | 6 + tools/testing/selftests/kvm/steal_time.c | 3 + .../kvm/system_counter_offset_test.c | 4 + .../kvm/x86_64/vmx_tsc_adjust_test.c | 5 - 14 files changed, 80 insertions(+), 290 deletions(-) base-commit: f1a1d3aff0cc2e68a9ebbd8810d7dcd8cfe2714b