From: Dan Williams <dan.j.williams@intel.com>
To: Stephen Rothwell <sfr@canb.auug.org.au>,
Dan Williams <dan.j.williams@intel.com>,
<sathyanarayanan.kuppuswamy@linux.intel.com>,
<yilun.xu@intel.com>, <sameo@rivosinc.com>, <aik@amd.com>,
<suzuki.poulose@arm.com>, <steven.price@arm.com>,
<lukas@wunner.de>, Greg KH <greg@kroah.com>
Cc: "Cedric Xing" <cedric.xing@intel.com>,
"Thomas Weißschuh" <linux@weissschuh.net>,
"Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>,
"Linux Next Mailing List" <linux-next@vger.kernel.org>
Subject: Re: linux-next: build failure after merge of the devsec-tsm tree
Date: Thu, 8 May 2025 17:37:41 -0700 [thread overview]
Message-ID: <681d4e5584d46_1229d6294d6@dwillia2-xfh.jf.intel.com.notmuch> (raw)
In-Reply-To: <20250508181032.58fc7e5b@canb.auug.org.au>
Stephen Rothwell wrote:
> Hi all,
>
> After merging the devsec-tsm tree, today's linux-next build (x86_64
> allmodconfig) failed like this:
>
> drivers/virt/coco/guest/tsm-mr.c: In function 'tsm_mr_create_attribute_group':
> drivers/virt/coco/guest/tsm-mr.c:228:29: error: assignment to 'const struct bin_attribute * const*' from incompatible pointer type 'struct bin_attribute **' [-Wincompatible-pointer-types]
> 228 | ctx->agrp.bin_attrs = no_free_ptr(bas);
> | ^
>
> Caused by commit
>
> 29b07a7b8f41 ("tsm-mr: Add TVM Measurement Register support")
>
> interacting with commit
>
> 9bec944506fa ("sysfs: constify attribute_group::bin_attrs")
>
> from the driver-core tree.
>
> I have applied the following merge resolution for today (there must be
> a better solution).
Indeed.
So it looks like while there are plenty of dynamic binary attribute
creation users (see sysfs_bin_attr_init() callers). There are zero that
attempt to assign dynamically allocated attributes to be registered by a
static @groups.
The @groups publishing model is preferable because the lifetime rules
are all handled by the driver core at device add/del time.
So, while there is still casting involved, I think a better solution is
to make the allocation const and then cast for init ala incremental
patch below. Cedric, if this looks ok to you I'll send out another
partial-reroll to get this fixed up so the build breakage stays out of
bisection runs.
-- 8< --
diff --git a/drivers/virt/coco/tsm-mr.c b/drivers/virt/coco/tsm-mr.c
index d75b08548292..7fe90fae2738 100644
--- a/drivers/virt/coco/tsm-mr.c
+++ b/drivers/virt/coco/tsm-mr.c
@@ -169,24 +169,27 @@ tsm_mr_create_attribute_group(const struct tsm_measurements *tm)
}
/*
- * @bas and the MR name strings are combined into a single allocation
+ * @attrs and the MR name strings are combined into a single allocation
* so that we don't have to free MR names one-by-one in
* tsm_mr_free_attribute_group()
*/
- struct bin_attribute **bas __free(kfree) =
- kzalloc(sizeof(*bas) * (tm->nr_mrs + 1) + nlen, GFP_KERNEL);
+ const struct bin_attribute * const *attrs __free(kfree) =
+ kzalloc(sizeof(*attrs) * (tm->nr_mrs + 1) + nlen, GFP_KERNEL);
struct tm_context *ctx __free(kfree) =
kzalloc(struct_size(ctx, mrs, tm->nr_mrs), GFP_KERNEL);
char *name, *end;
- if (!ctx || !bas)
+ if (!ctx || !attrs)
return ERR_PTR(-ENOMEM);
- /* @bas is followed immediately by MR name strings */
- name = (char *)&bas[tm->nr_mrs + 1];
+ /* @attrs is followed immediately by MR name strings */
+ name = (char *)&attrs[tm->nr_mrs + 1];
end = name + nlen;
for (size_t i = 0; i < tm->nr_mrs; ++i) {
+ /* break const for init */
+ struct bin_attribute **bas = (struct bin_attribute **)attrs;
+
bas[i] = &ctx->mrs[i];
sysfs_bin_attr_init(bas[i]);
@@ -225,7 +228,7 @@ tsm_mr_create_attribute_group(const struct tsm_measurements *tm)
init_rwsem(&ctx->rwsem);
ctx->agrp.name = "measurements";
- ctx->agrp.bin_attrs = no_free_ptr(bas);
+ ctx->agrp.bin_attrs = no_free_ptr(attrs);
ctx->tm = tm;
return &no_free_ptr(ctx)->agrp;
}
next prev parent reply other threads:[~2025-05-09 0:38 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-08 8:10 linux-next: build failure after merge of the devsec-tsm tree Stephen Rothwell
2025-05-09 0:37 ` Dan Williams [this message]
2025-05-09 7:12 ` Greg KH
2025-05-12 17:40 ` Xing, Cedric
2025-05-12 18:45 ` Dan Williams
2025-05-10 7:05 ` Thomas Weißschuh
2025-05-13 4:56 ` Dan Williams
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=681d4e5584d46_1229d6294d6@dwillia2-xfh.jf.intel.com.notmuch \
--to=dan.j.williams@intel.com \
--cc=aik@amd.com \
--cc=cedric.xing@intel.com \
--cc=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-next@vger.kernel.org \
--cc=linux@weissschuh.net \
--cc=lukas@wunner.de \
--cc=sameo@rivosinc.com \
--cc=sathyanarayanan.kuppuswamy@linux.intel.com \
--cc=sfr@canb.auug.org.au \
--cc=steven.price@arm.com \
--cc=suzuki.poulose@arm.com \
--cc=yilun.xu@intel.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox