lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <7012583a-90be-4156-a151-2fc56fa18d51@app.fastmail.com>
Date: Mon, 10 Mar 2025 14:10:23 +0100
From: "Arnd Bergmann" <arnd@...db.de>
To: "Borislav Petkov" <bp@...en8.de>
Cc: "Ingo Molnar" <mingo@...nel.org>, "Arnd Bergmann" <arnd@...nel.org>,
 "Thomas Gleixner" <tglx@...utronix.de>, "Ingo Molnar" <mingo@...hat.com>,
 "Dave Hansen" <dave.hansen@...ux.intel.com>, x86@...nel.org,
 "Kuppuswamy Sathyanarayanan" <sathyanarayanan.kuppuswamy@...ux.intel.com>,
 "Rick Edgecombe" <rick.p.edgecombe@...el.com>,
 "Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>,
 "Tom Lendacky" <thomas.lendacky@....com>, "H. Peter Anvin" <hpa@...or.com>,
 "Jason A . Donenfeld" <Jason@...c4.com>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] x86: coco: mark cc_mask as __maybe_unused

On Wed, Mar 5, 2025, at 23:50, Borislav Petkov wrote:
> On Wed, Mar 05, 2025 at 11:45:11PM +0100, Arnd Bergmann wrote:
>> There is a twist here: clang by default warns about unused const
>> variables in .c files but not in headers, while gcc doesn't
>
> What is the point of this warning, do you know?
>
> Someone defines a const, forgets to use it and? Oh big deal. This should be
> a -Wunused anyway, no?
>
> I must be missing something here...

We turned on -Wunused a while ago for default builds after all the
-Wunused-variable warnings got addressed, but instead turned off
-Wunused-const-variable and -Wunused-but-set-variable
unless W=1 is set while there are still existing warnings.

In my opinion, there is little difference between unused const and
non-const variables, the reason that gcc treats them differently
seems to be from common c++ coding style advocating for them to be
used in place of macros. This is the case here, but most of the
warnings it actually shows are for mistakes where some variable
is in the wrong #ifdef block or the only user got removed.

>> In this case, the only user is a macro:
>> #define _PAGE_CC               (_AT(pteval_t, cc_mask))
>> 
>> so maybe '#define cc_mask 0' would be appropriate.
>
> Sounds a lot better to me.

Too bad that did not work. This version is also a bit ugly:

diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h
index c90e9c51edb7..f31c1a31742d 100644
--- a/arch/x86/include/asm/pgtable_types.h
+++ b/arch/x86/include/asm/pgtable_types.h
@@ -179,7 +179,11 @@ enum page_cache_mode {
 };
 #endif
 
+#ifdef CONFIG_ARCH_HAS_CC_PLATFORM
 #define _PAGE_CC               (_AT(pteval_t, cc_mask))
+#else
+#define _PAGE_CC               (_AT(pteval_t, 0))
+#endif
 #define _PAGE_ENC              (_AT(pteval_t, sme_me_mask))
 
 #define _PAGE_CACHE_MASK       (_PAGE_PWT | _PAGE_PCD | _PAGE_PAT)

so I'll just follow Ingo's earlier suggestion for the v2 patch.

       Arnd

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ