Message ID | 20221213001653.3852042-12-seanjc@google.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2544845wrr; Mon, 12 Dec 2022 16:19:07 -0800 (PST) X-Google-Smtp-Source: AA0mqf5feVKviBeKZ7JkyCr7EnjL56ZkTWcK3+zA5JPFbIIxIOUNW9WkAqedJYpAKbtJAv117nGi X-Received: by 2002:a17:902:8347:b0:189:4bf4:2cfc with SMTP id z7-20020a170902834700b001894bf42cfcmr18447686pln.31.1670890746986; Mon, 12 Dec 2022 16:19:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670890746; cv=none; d=google.com; s=arc-20160816; b=ZIdXjoWG6mf0HK4/+nhOxF8HjyreeY2zdLv6vHru5e/qdHicZDBMsRGBBoL00N9nz1 VXgD4J1OQ+nvmLgM2xBVt9bsDKmptFj0GSNKblEB0ppwbW1ONnEeF3kjg+i6Ab8ZhNFc xsErb49OiJ/8/dX5Q4i5CDk+60h8WwIsNpyCDc8Ww/D32sk0DCqaIArENfqmi4WJSti0 KHGfpJH+ypuGZPDaQeO0ZFeB8M8z9pcAPaRdDbIukJchFCnsDXwE0fZcU/LkvF19H6Dh V18yuaeCjxsEvE1g5eBnGsWvKd0oc4LY1huZdrpQ7eshmCPoom7pMbdennmpv3TG8zYt cNQQ== 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:reply-to:dkim-signature; bh=nM41DSVBAJr+S3W93Zis4JAYC8eUvXamzXgPZLD06L8=; b=DyF997o8kTpYvXwzMMj7Rv/jAAS0u7bDssd3V6BQ9xFKKZLCjmO7QIiNAfzvHBporW g7z9PSeE4N854PYhHKCzK0mDrraSR/HQ0x+OcGL0FH67NIrGOnmutpqmySrio//xLNRs tSfVXpwFTjuOZPVaGIqk8TqIZLadxuwul9288te2ZqDgNwWYDQ3n0mAqGiSDXVaChN9t 5EW/lPHOTBcgSrG8/Ti3O2fVUv/snxXhMb3bb6+LB57xsaDEorizqcJpbSQPjqA4ljRk 8QhkUcGpzLiDm+1eLrGm0fyn5qgvYo8/iy2OFW711suPwXLDaLaZqRZkeobTzdDhzJL6 DFNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=nYe6ZWOH; 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 b9-20020a170902d40900b0018867e3182esi10162114ple.335.2022.12.12.16.18.53; Mon, 12 Dec 2022 16:19:06 -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=nYe6ZWOH; 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 S234128AbiLMASE (ORCPT <rfc822;jeantsuru.cumc.mandola@gmail.com> + 99 others); Mon, 12 Dec 2022 19:18:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234122AbiLMARY (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 12 Dec 2022 19:17:24 -0500 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 E26841CB1D for <linux-kernel@vger.kernel.org>; Mon, 12 Dec 2022 16:17:15 -0800 (PST) Received: by mail-pl1-x649.google.com with SMTP id f8-20020a170902ce8800b00190c6518e21so123177plg.1 for <linux-kernel@vger.kernel.org>; Mon, 12 Dec 2022 16:17:15 -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:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=nM41DSVBAJr+S3W93Zis4JAYC8eUvXamzXgPZLD06L8=; b=nYe6ZWOHPMJgTGksZPiEisBf6HPHtTh7LwnzxBJxPqoYHxDIXfUXIa80Wv8FT5deaA UzHNYFP0DWaotAozDYEqkVOhGC3cJzSjZIrX35uJMvKk0qzEdjbF5qj55iPpjtEz3ipO bm8VP2buvMYoUm5bBSsgzK0AvSdBMq0gU3WwNjXiGhrTir7XSUZ3UlUPkv2SzjZJXHyV BW7oqPIg9/2WzHp2xjLzs82Y3ewdbcwG+wxaYmUKR44YKrwYEmcWRcUYbv914+1ep3vj XM381ihLSB7s6K13WjVWXGmod93EwbDCFi3RC00C/qqJJxPj4hbmeVdBA7F4fDCsvIiB q4Jg== 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:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=nM41DSVBAJr+S3W93Zis4JAYC8eUvXamzXgPZLD06L8=; b=ay3HNxBwmI++ZVdy/j9jDwhxSrmCaovz8nmxQCaiFIPhpxE+KfA2h/c6jy9/j2OL14 hVDAt21Bes2OMMBpBK/wnzs589KwfGM1xMcKjHY32CxOYXioXLo+930wXihMB0c+qG4T Vs8H/bUwm8QdHMVRoL3Uf9w8T6fC+VHMoEKK7BParbXFtt5OF2TDTfAf1htcEN8mwAK5 41DjWU2+kptOhINu/UDZedgukLBkZLGsb50uZB2zaTZGNKZMSZAHrXFrEFKEcI4lQJsE FZJT6avwMKJSE0aZxCzmod7e1/kKlGwYOywF3YEP1CHNagYUFMpeysKRGkRJSzW6yC23 TLZA== X-Gm-Message-State: ANoB5pn4++5nzCl4D3ZlyWeC6N7UP9Y0z1C7ap4Znr0nKBGuLVQO28ZX aQ1QNEPH6uEJIG/i+jH6xZ/HIPHVOyA= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a17:902:c406:b0:189:6df9:4f85 with SMTP id k6-20020a170902c40600b001896df94f85mr62591897plk.27.1670890635443; Mon, 12 Dec 2022 16:17:15 -0800 (PST) Reply-To: Sean Christopherson <seanjc@google.com> Date: Tue, 13 Dec 2022 00:16:50 +0000 In-Reply-To: <20221213001653.3852042-1-seanjc@google.com> Mime-Version: 1.0 References: <20221213001653.3852042-1-seanjc@google.com> X-Mailer: git-send-email 2.39.0.rc1.256.g54fd8350bd-goog Message-ID: <20221213001653.3852042-12-seanjc@google.com> Subject: [PATCH 11/14] KVM: selftests: Disable "gnu-variable-sized-type-not-at-end" warning From: Sean Christopherson <seanjc@google.com> To: Paolo Bonzini <pbonzini@redhat.com>, Marc Zyngier <maz@kernel.org>, Paul Walmsley <paul.walmsley@sifive.com>, Palmer Dabbelt <palmer@dabbelt.com>, Albert Ou <aou@eecs.berkeley.edu>, Nathan Chancellor <nathan@kernel.org>, Nick Desaulniers <ndesaulniers@google.com> Cc: James Morse <james.morse@arm.com>, Alexandru Elisei <alexandru.elisei@arm.com>, Suzuki K Poulose <suzuki.poulose@arm.com>, Oliver Upton <oliver.upton@linux.dev>, Tom Rix <trix@redhat.com>, 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 <ricarkol@google.com>, Sean Christopherson <seanjc@google.com>, Aaron Lewis <aaronlewis@google.com>, Raghavendra Rao Ananta <rananta@google.com> Content-Type: text/plain; charset="UTF-8" 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=unavailable 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752055936189481526?= X-GMAIL-MSGID: =?utf-8?q?1752055936189481526?= |
Series |
KVM: selftests: Clang fixes, Makefile cleanup
|
|
Commit Message
Sean Christopherson
Dec. 13, 2022, 12:16 a.m. UTC
Disable gnu-variable-sized-type-not-at-end so that tests and libraries
can create overlays of variable sized arrays at the end of structs when
using a fixed number of entries, e.g. to get/set a single MSR.
It's possible to fudge around the warning, e.g. by defining a custom
struct that hardcodes the number of entries, but that is a burden for
both developers and readers of the code.
lib/x86_64/processor.c:664:19: warning: field 'header' with variable sized type 'struct kvm_msrs'
not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end]
struct kvm_msrs header;
^
lib/x86_64/processor.c:772:19: warning: field 'header' with variable sized type 'struct kvm_msrs'
not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end]
struct kvm_msrs header;
^
lib/x86_64/processor.c:787:19: warning: field 'header' with variable sized type 'struct kvm_msrs'
not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end]
struct kvm_msrs header;
^
3 warnings generated.
x86_64/hyperv_tlb_flush.c:54:18: warning: field 'hv_vp_set' with variable sized type 'struct hv_vpset'
not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end]
struct hv_vpset hv_vp_set;
^
1 warning generated.
x86_64/xen_shinfo_test.c:137:25: warning: field 'info' with variable sized type 'struct kvm_irq_routing'
not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end]
struct kvm_irq_routing info;
^
1 warning generated.
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
tools/testing/selftests/kvm/Makefile | 1 +
1 file changed, 1 insertion(+)
Comments
On Mon, Dec 12, 2022 at 4:17 PM Sean Christopherson <seanjc@google.com> wrote: > > Disable gnu-variable-sized-type-not-at-end so that tests and libraries > can create overlays of variable sized arrays at the end of structs when > using a fixed number of entries, e.g. to get/set a single MSR. > > It's possible to fudge around the warning, e.g. by defining a custom > struct that hardcodes the number of entries, but that is a burden for > both developers and readers of the code. > > lib/x86_64/processor.c:664:19: warning: field 'header' with variable sized type 'struct kvm_msrs' > not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end] > struct kvm_msrs header; > ^ > lib/x86_64/processor.c:772:19: warning: field 'header' with variable sized type 'struct kvm_msrs' > not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end] > struct kvm_msrs header; > ^ > lib/x86_64/processor.c:787:19: warning: field 'header' with variable sized type 'struct kvm_msrs' > not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end] > struct kvm_msrs header; > ^ > 3 warnings generated. > > x86_64/hyperv_tlb_flush.c:54:18: warning: field 'hv_vp_set' with variable sized type 'struct hv_vpset' > not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end] > struct hv_vpset hv_vp_set; > ^ > 1 warning generated. > > x86_64/xen_shinfo_test.c:137:25: warning: field 'info' with variable sized type 'struct kvm_irq_routing' > not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end] > struct kvm_irq_routing info; > ^ > 1 warning generated. > > Signed-off-by: Sean Christopherson <seanjc@google.com> > --- > tools/testing/selftests/kvm/Makefile | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/tools/testing/selftests/kvm/Makefile b/tools/testing/selftests/kvm/Makefile > index 2487db21b177..9cff99a1cb2e 100644 > --- a/tools/testing/selftests/kvm/Makefile > +++ b/tools/testing/selftests/kvm/Makefile > @@ -196,6 +196,7 @@ else > LINUX_TOOL_ARCH_INCLUDE = $(top_srcdir)/tools/arch/$(ARCH)/include > endif > CFLAGS += -Wall -Wstrict-prototypes -Wuninitialized -O2 -g -std=gnu99 \ > + -Wno-gnu-variable-sized-type-not-at-end \ This is a clang-specific warning. This will need to be wrapped in a cc-option check. tools/build/Build.include seems to redefine that make macro, so be sure to test it first. > -fno-builtin-memcmp -fno-builtin-memcpy -fno-builtin-memset \ > -fno-stack-protector -fno-PIE -I$(LINUX_TOOL_INCLUDE) \ > -I$(LINUX_TOOL_ARCH_INCLUDE) -I$(LINUX_HDR_PATH) -Iinclude \ > -- > 2.39.0.rc1.256.g54fd8350bd-goog > >
On Mon, Dec 12, 2022, Nick Desaulniers wrote: > > diff --git a/tools/testing/selftests/kvm/Makefile b/tools/testing/selftests/kvm/Makefile > > index 2487db21b177..9cff99a1cb2e 100644 > > --- a/tools/testing/selftests/kvm/Makefile > > +++ b/tools/testing/selftests/kvm/Makefile > > @@ -196,6 +196,7 @@ else > > LINUX_TOOL_ARCH_INCLUDE = $(top_srcdir)/tools/arch/$(ARCH)/include > > endif > > CFLAGS += -Wall -Wstrict-prototypes -Wuninitialized -O2 -g -std=gnu99 \ > > + -Wno-gnu-variable-sized-type-not-at-end \ > > This is a clang-specific warning. This will need to be wrapped in a > cc-option check. Not that I'm against guarding this code, but I don't think cc-option() will do anything in this case. AFAICT, gcc stopped treating unknown "-Wno" flags as unconditional errors starting with gcc-4.4, and the kernel's min supported version is 5.1. gcc-4.4 through gcc-9.5 all print a mild warning if there's a different error, but otherwise silently ignore the uknown "-Wno". cc1: warning: unrecognized command line option '-Wno-gnu-variable-sized-type-not-at-end' gcc-10.1 is even friendlier and notes that the unknown flag may have been related to the error. cc1: note: unrecognized command-line option '-Wno-gnu-variable-sized-type-not-at-end' may have been intended to silence earlier diagnostics Because cc-option() doesn't have errors in its probing code, it will return "true" on gcc for literally any "-Wno-*" input that gcc deems syntacially valid, e.g. gcc barfs on depends on $(cc-option,-Wno-) depends on $(cc-option,-Wno) but happily succeeds with depends on $(cc-option,-Wno-lol-gcc) Various man pages suggest -Wunknown-warnings is a thing, but no gcc version supported by godbolt recognizes it. So unless I'm missing something, trying to detect lack of support will be non-trivial, and the worst case scenario is that users of older gcc version will see a potentially confusing warning when the build fails.
On 12/13/22 03:13, Sean Christopherson wrote: > AFAICT, gcc stopped treating unknown "-Wno" flags as unconditional errors starting > with gcc-4.4, and the kernel's min supported version is 5.1. gcc-4.4 through > gcc-9.5 all print a mild warning if there's a different error, but otherwise > silently ignore the uknown "-Wno". > > cc1: warning: unrecognized command line option '-Wno-gnu-variable-sized-type-not-at-end' scripts/Makefile.compiler has cc-disable-warning for this, we can copy it to tools/. Paolo
diff --git a/tools/testing/selftests/kvm/Makefile b/tools/testing/selftests/kvm/Makefile index 2487db21b177..9cff99a1cb2e 100644 --- a/tools/testing/selftests/kvm/Makefile +++ b/tools/testing/selftests/kvm/Makefile @@ -196,6 +196,7 @@ else LINUX_TOOL_ARCH_INCLUDE = $(top_srcdir)/tools/arch/$(ARCH)/include endif CFLAGS += -Wall -Wstrict-prototypes -Wuninitialized -O2 -g -std=gnu99 \ + -Wno-gnu-variable-sized-type-not-at-end \ -fno-builtin-memcmp -fno-builtin-memcpy -fno-builtin-memset \ -fno-stack-protector -fno-PIE -I$(LINUX_TOOL_INCLUDE) \ -I$(LINUX_TOOL_ARCH_INCLUDE) -I$(LINUX_HDR_PATH) -Iinclude \