Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp770651pxy; Wed, 28 Apr 2021 13:56:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwgfH7K2YgGu3GjEkJm3w+dFMVjPM0xpTpRAlETxeI+Rj2izpXtp5BKYsmyS/X1Z8shaB47 X-Received: by 2002:a17:906:478c:: with SMTP id cw12mr31559078ejc.5.1619643415309; Wed, 28 Apr 2021 13:56:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619643415; cv=none; d=google.com; s=arc-20160816; b=SPZrkrzX+0Adgc2wUGs1+JIYJ9k4Mm+HkcWq3+Y+zSnLJOy6Mox50sMC0u8r7d1AYj qOGBEdmyCeov6KuUOFTYe2eJKNz0QDH4UgRrlxcGRLCecwMFvy10CBO6pWj/sqSZqGL2 zbi5cppSvZbBuxGjkJ5TWgMjlROO4ZJTggeUf8yH3zzAwRE8vB59jqKub2HO6hJysY7N 4G2l7yjh/VOnew4v6MAWbnLpFMrTq6ABIK7lPhaaf93hP7grzOroRzL95Qj4PA0DelvE 4Oe7bjs22fF1xpBUR0SgdROtUFfi4++HMvZ9wCv7KKxWjcaC5CRz27CAgV1YDq+yiktN WMyg== 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:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=3EmL6xt5jVjqc/fFRGG9Bp/HY5j+2f9o1zD7J8DnnPw=; b=cU3tkFyzB0AzNw1iQ0mxTrA3EFAsE43XK120O5uYLZesbdmHwc/Ls5rGTd69cq5ztI 9vWd6IqLfZ5ftVJSpRfGPQK1i79p6+t4l3sWeZXcj7ifHi7Mhq1hIVNNEf1PeI1qkfp5 qgmuhOh2HG8sx16OJNgzeMyRbBHofpggqmMikqyI7eRwjCwQDqDicTGJlJd7F/S+N3cV H6yqyAsf7OAi7G82kRpd8yqyYbobXEG1TEbGeW6WR3HjJyvuhq/iWeyKhlpXJjto0lNl 3/eR1gv/Xj193dg/syAcrndsUg8DGMtO8WkWBQ490I7jk1rxpPM/dYT4uRnyeXYdLgt+ uu6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=qojwyUnM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u16si792132edo.422.2021.04.28.13.56.31; Wed, 28 Apr 2021 13:56:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=qojwyUnM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S241880AbhD1TjB (ORCPT + 99 others); Wed, 28 Apr 2021 15:39:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241819AbhD1Ti6 (ORCPT ); Wed, 28 Apr 2021 15:38:58 -0400 Received: from mail-pl1-x649.google.com (mail-pl1-x649.google.com [IPv6:2607:f8b0:4864:20::649]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8ED06C06138A for ; Wed, 28 Apr 2021 12:38:05 -0700 (PDT) Received: by mail-pl1-x649.google.com with SMTP id m10-20020a170902f20ab02900ed7e32ff42so854327plc.19 for ; Wed, 28 Apr 2021 12:38:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=3EmL6xt5jVjqc/fFRGG9Bp/HY5j+2f9o1zD7J8DnnPw=; b=qojwyUnMOEKFrRAcoKNQv8n9HI0z+aYcwAplArllOvARz6euC5nXNvMP3+XTjqrcuq 27iyRNgjq7qlyk8BgfqzP+q/bPr4jr7bPbIFOboYm2DK2DViCz9IgZO02YQcBAjmgel7 LfkZytiSEZgfQZE2lG/0d3YqOKenqkidls0+i+KeEhqqrAkiHzY1FGQib/wb6bMGhpLC ggG0+bb0D3uy/d/sAGEhmuM6kW/F/n5phGtR6VG9kFmXv+RTV8Z/lXrev6QZXNEaeuuF FSyn+4mmB/ug/UJXVXOt2t+AUXRjC8OQmqDiBEC30XkjkcsO+gdvbaD1+CHgH+8vqOGS vn2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=3EmL6xt5jVjqc/fFRGG9Bp/HY5j+2f9o1zD7J8DnnPw=; b=GSp1Su49djGmm0yPhr1GQmxG7lrxAUHg7wlUudh7cycIYGhNmzqHa+bVWWjWl13mVA yJNYK+wquHYIU7PPfCPNF2ZjaUYINoTqkKBXdsYzqq5mOFK2NOaWpkia/0HxctmBwejE l7SmyqkBlih6QEUk57RERNyXeaJ98DEVCuvMqB/iInnfC9tqGuULWXxKUReD9jNcacwp u6UXEFj8JEVPq5zm9IMDfA2vRFtmihyXmYXfN2Wh1WDROYwvSxpCWUbnSkZH2kvMmmiF KpJ4b02dKgBu1TFUTqo26rNDQHJmjZ2B3IqLGWN6U/q4SVO4OGO5EiJxCrIihoTVymSK SA0w== X-Gm-Message-State: AOAM530THFR9VS5rdSP+JFtbpyGH2r/HoSbI3/LtHAwHx8lApDDLL6u7 vn8Rd9NIFZBBJszj/HzCwBMwF9p3YTrsJg== X-Received: from ricarkol2.c.googlers.com ([fda3:e722:ac3:10:24:72f4:c0a8:62fe]) (user=ricarkol job=sendgmr) by 2002:a17:902:8d8b:b029:ed:64bb:db81 with SMTP id v11-20020a1709028d8bb02900ed64bbdb81mr8252681plo.53.1619638684396; Wed, 28 Apr 2021 12:38:04 -0700 (PDT) Date: Wed, 28 Apr 2021 12:37:51 -0700 In-Reply-To: <20210428193756.2110517-1-ricarkol@google.com> Message-Id: <20210428193756.2110517-2-ricarkol@google.com> Mime-Version: 1.0 References: <20210428193756.2110517-1-ricarkol@google.com> X-Mailer: git-send-email 2.31.1.498.g6c1eba8ee3d-goog Subject: [PATCH v2 1/6] KVM: selftests: Add kernel headers sync check From: Ricardo Koller To: Paolo Bonzini Cc: kvm@vger.kernel.org, Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , "H. Peter Anvin" , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Nathan Chancellor , Nick Desaulniers , linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com, Ricardo Koller Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a script that checks if header files under /tools match their original version in the kernel. Perform the check at the end of the make, so warnings are shown after all tests are built. Note that the build is _not_ aborted if any diff check fails. The list of header files to check was obtained from the union of the output of these (at tools/testing/selftests/kvm): CFLAGS="-H" make ARCH=x86_64 2>&1 | grep '.h$' | grep 'tools' CFLAGS="-H" make ARCH=arm64 CC=aarch64-linux-gnu-gcc-10 2>&1 | grep '.h$' | grep 'tools' and then by manually removing the header files that were updated on the tools/ side but not on the kernel side. There is no point in checking for these as their changes will not be synced back to the kernel. Here are the removed headers and the first commit that made them drift apart from their original copies: tools/include/linux/kernel.h d0761e37fe3 perf tools: Uninline scnprintf() and vscnprint() tools/include/linux/list.h 5602ea09c19 tools include: Add compiler.h to list.h tools/include/linux/poison.h 6ae8eefc6c8 tools include: Do not use poison with C++ tools/include/linux/types.h 70ba6b8f975 tools include: add __aligned_u64 to types.h tools/include/asm-generic/bitsperlong.h 2a00f026a15 tools: Fix up BITS_PER_LONG setting Based on tools/perf/check-headers.sh. Signed-off-by: Ricardo Koller --- tools/testing/selftests/kvm/Makefile | 2 + tools/testing/selftests/kvm/check-headers.sh | 55 ++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100755 tools/testing/selftests/kvm/check-headers.sh diff --git a/tools/testing/selftests/kvm/Makefile b/tools/testing/selftests/kvm/Makefile index ea5c42841307..69dc4f5e9ee3 100644 --- a/tools/testing/selftests/kvm/Makefile +++ b/tools/testing/selftests/kvm/Makefile @@ -147,6 +147,8 @@ $(OUTPUT)/libkvm.a: $(LIBKVM_OBJS) x := $(shell mkdir -p $(sort $(dir $(TEST_GEN_PROGS)))) all: $(STATIC_LIBS) + @./check-headers.sh + $(TEST_GEN_PROGS): $(STATIC_LIBS) cscope: include_paths = $(LINUX_TOOL_INCLUDE) $(LINUX_HDR_PATH) include lib .. diff --git a/tools/testing/selftests/kvm/check-headers.sh b/tools/testing/selftests/kvm/check-headers.sh new file mode 100755 index 000000000000..c21a69b52bcd --- /dev/null +++ b/tools/testing/selftests/kvm/check-headers.sh @@ -0,0 +1,55 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# +# Adapted from tools/perf/check-headers.sh + +FILES=' +arch/x86/include/asm/msr-index.h +include/linux/bits.h +include/linux/const.h +include/uapi/asm-generic/bitsperlong.h +include/uapi/linux/const.h +include/vdso/bits.h +include/vdso/const.h +' + +check_2 () { + file1=$1 + file2=$2 + + shift + shift + + cmd="diff $* $file1 $file2 > /dev/null" + + test -f $file2 && { + eval $cmd || { + echo "Warning: Kernel header at '$file1' differs from latest version at '$file2'" >&2 + echo diff -u $file1 $file2 + } + } +} + +check () { + file=$1 + + shift + + check_2 tools/$file $file $* +} + +# Check if we are at the right place (we have the kernel headers) +# (tools/testing/selftests/kvm/../../../../include) +test -d ../../../../include || exit 0 + +cd ../../../.. + +# simple diff check +for i in $FILES; do + check $i -B +done + +# diff with extra ignore lines +check include/linux/build_bug.h '-I "^#\(ifndef\|endif\)\( \/\/\)* static_assert$"' + +cd tools/testing/selftests/kvm -- 2.31.1.498.g6c1eba8ee3d-goog