[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <9a8eeb99abeb7a3f670f1701839ec5659dea33a5.camel@intel.com>
Date: Thu, 6 Mar 2025 05:38:47 +0000
From: "Huang, Kai" <kai.huang@...el.com>
To: "bp@...en8.de" <bp@...en8.de>, "arnd@...db.de" <arnd@...db.de>
CC: "arnd@...nel.org" <arnd@...nel.org>, "Edgecombe, Rick P"
<rick.p.edgecombe@...el.com>, "mingo@...nel.org" <mingo@...nel.org>,
"x86@...nel.org" <x86@...nel.org>, "dave.hansen@...ux.intel.com"
<dave.hansen@...ux.intel.com>, "Jason@...c4.com" <Jason@...c4.com>,
"hpa@...or.com" <hpa@...or.com>, "mingo@...hat.com" <mingo@...hat.com>,
"tglx@...utronix.de" <tglx@...utronix.de>, "kirill.shutemov@...ux.intel.com"
<kirill.shutemov@...ux.intel.com>,
"sathyanarayanan.kuppuswamy@...ux.intel.com"
<sathyanarayanan.kuppuswamy@...ux.intel.com>, "thomas.lendacky@....com"
<thomas.lendacky@....com>, "linux-kernel@...r.kernel.org"
<linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] x86: coco: mark cc_mask as __maybe_unused
>
> > warn about them at all unless it's explictly enabled, and then
> > it warns about both of them. Newer gcc versions have a distinct
> > -Wunused-const-variable=1 for the clang behavior and
> > -Wunused-const-variable=2 that warns for both, so we could
> > reasonably decide to enable the =1 version by default and
> > leave the =2 version for W=2.
> >
> > On the other hand, most of the users of 'static const' variables
> > in headers are rather dumb and should just be moved into the
> > file that uses them, or they can be replaced with a #define
> > or an enum.
> >
> > 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.
>
I actually tried this with CONFIG_ARCH_HAS_CC_PLATFORM off yesterday but got
below error:
$ make -j$(nproc)
mkdir -p /work/enabling/src/linux/tools/objtool && make
O=/work/enabling/src/linux subdir=tools/objtool --no-print-directory -C objtool
CALL scripts/checksyscalls.sh
INSTALL libsubcmd_headers
CC drivers/char/tpm/tpm2-cmd.o
CC drivers/char/tpm/tpmrm-dev.o
CC drivers/char/tpm/tpm2-space.o
CC drivers/char/tpm/tpm-sysfs.o
In file included from ./arch/x86/include/asm/pgtable.h:23,
from ./arch/x86/include/asm/tlbflush.h:16,
from ./arch/x86/include/asm/uaccess.h:17,
from ./include/linux/uaccess.h:12,
from ./include/linux/sched/task.h:13,
from ./include/linux/sched/signal.h:9,
from ./include/linux/rcuwait.h:6,
from ./include/linux/percpu-rwsem.h:7,
from ./include/linux/fs.h:33,
from ./include/linux/tpm.h:23,
from drivers/char/tpm/tpm.h:27,
from drivers/char/tpm/tpm2-cmd.c:14:
drivers/char/tpm/tpm2-cmd.c: In function ‘tpm2_find_cc’:
./arch/x86/include/asm/coco.h:28:17: error: expected identifier or ‘(’ before
numeric constant
28 | #define cc_mask 0
| ^
drivers/char/tpm/tpm2-cmd.c:813:13: note: in expansion of macro ‘cc_mask’
813 | u32 cc_mask;
| ^~~~~~~
drivers/char/tpm/tpm2-cmd.c:816:17: error: lvalue required as left operand of
assignment
816 | cc_mask = 1 << TPM2_CC_ATTR_VENDOR | GENMASK(15, 0);
| ^
Rename the local variable 'cc_mask' in drivers/char/tpm/tpm2-cmd.c fix the
build, but I think the real issue is the 'cc_mask' in asm/coco.h is too common
to be a global visible variable/macro.
Powered by blists - more mailing lists