All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Huang, Kai" <kai.huang@intel.com>
To: "bp@alien8.de" <bp@alien8.de>, "arnd@arndb.de" <arnd@arndb.de>
Cc: "arnd@kernel.org" <arnd@kernel.org>,
	"Edgecombe, Rick P" <rick.p.edgecombe@intel.com>,
	"mingo@kernel.org" <mingo@kernel.org>,
	"x86@kernel.org" <x86@kernel.org>,
	"dave.hansen@linux.intel.com" <dave.hansen@linux.intel.com>,
	"Jason@zx2c4.com" <Jason@zx2c4.com>,
	"hpa@zytor.com" <hpa@zytor.com>,
	"mingo@redhat.com" <mingo@redhat.com>,
	"tglx@linutronix.de" <tglx@linutronix.de>,
	"kirill.shutemov@linux.intel.com"
	<kirill.shutemov@linux.intel.com>,
	"sathyanarayanan.kuppuswamy@linux.intel.com"
	<sathyanarayanan.kuppuswamy@linux.intel.com>,
	"thomas.lendacky@amd.com" <thomas.lendacky@amd.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] x86: coco: mark cc_mask as __maybe_unused
Date: Thu, 6 Mar 2025 05:38:47 +0000	[thread overview]
Message-ID: <9a8eeb99abeb7a3f670f1701839ec5659dea33a5.camel@intel.com> (raw)
In-Reply-To: <20250305225057.GBZ8jVUXJmIJBZwdgT@fat_crate.local>


> 
> > 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.


  reply	other threads:[~2025-03-06  5:38 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-04 14:33 [PATCH] x86: coco: mark cc_mask as __maybe_unused Arnd Bergmann
2025-03-04 19:55 ` Sathyanarayanan Kuppuswamy
2025-03-05  9:02 ` Kirill A. Shutemov
2025-03-05 10:44 ` Ingo Molnar
2025-03-05 22:17   ` Borislav Petkov
2025-03-05 22:20     ` Borislav Petkov
2025-03-05 22:45       ` Arnd Bergmann
2025-03-05 22:50         ` Borislav Petkov
2025-03-06  5:38           ` Huang, Kai [this message]
2025-03-10 13:10           ` Arnd Bergmann
2025-03-10 13:50   ` Arnd Bergmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9a8eeb99abeb7a3f670f1701839ec5659dea33a5.camel@intel.com \
    --to=kai.huang@intel.com \
    --cc=Jason@zx2c4.com \
    --cc=arnd@arndb.de \
    --cc=arnd@kernel.org \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=mingo@redhat.com \
    --cc=rick.p.edgecombe@intel.com \
    --cc=sathyanarayanan.kuppuswamy@linux.intel.com \
    --cc=tglx@linutronix.de \
    --cc=thomas.lendacky@amd.com \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.