From: "Roger Pau Monné" <roger.pau@citrix.com>
To: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: xen-devel@lists.xenproject.org, Paul Durrant <paul@xen.org>,
Jan Beulich <jbeulich@suse.com>
Subject: Re: [PATCH] x86/viridian: use hv_timer_message_payload struct
Date: Fri, 14 Nov 2025 10:10:46 +0100 [thread overview]
Message-ID: <aRbyFugnEJojSH01@Mac.lan> (raw)
In-Reply-To: <353236f2-2864-48c2-ae9c-e3d4a2aa5537@citrix.com>
On Thu, Nov 13, 2025 at 05:52:47PM +0000, Andrew Cooper wrote:
> On 13/11/2025 5:24 pm, Roger Pau Monne wrote:
> > diff --git a/xen/arch/x86/hvm/viridian/synic.c b/xen/arch/x86/hvm/viridian/synic.c
> > index e6cba7548f1b..6d7b6bd0eda2 100644
> > --- a/xen/arch/x86/hvm/viridian/synic.c
> > +++ b/xen/arch/x86/hvm/viridian/synic.c
> > @@ -327,15 +327,10 @@ bool viridian_synic_deliver_timer_msg(struct vcpu *v, unsigned int sintx,
> > struct viridian_vcpu *vv = v->arch.hvm.viridian;
> > const union hv_synic_sint *vs = &vv->sint[sintx];
> > struct hv_message *msg = vv->simp.ptr;
> > - struct {
> > - uint32_t TimerIndex;
> > - uint32_t Reserved;
> > - uint64_t ExpirationTime;
> > - uint64_t DeliveryTime;
> > - } payload = {
> > - .TimerIndex = index,
> > - .ExpirationTime = expiration,
> > - .DeliveryTime = delivery,
> > + const struct hv_timer_message_payload payload = {
> > + .timer_index = index,
> > + .expiration_time = expiration,
> > + .delivery_time = delivery,
>
> Align these = for readability?
Sure, can do.
> > };
> >
> > /* Don't assume SIM page to be mapped. */
> > @@ -359,8 +354,8 @@ bool viridian_synic_deliver_timer_msg(struct vcpu *v, unsigned int sintx,
> > msg->header.message_flags.msg_pending = 0;
> > msg->header.payload_size = sizeof(payload);
> >
> > - BUILD_BUG_ON(sizeof(payload) > sizeof(msg->u.payload));
> > - memcpy(msg->u.payload, &payload, sizeof(payload));
> > + BUILD_BUG_ON(sizeof(msg->payload.timer) > sizeof(msg->payload.raw));
>
> This BUILD_BUG_ON() was only needed because of the memcpy() between
> different types. With structure assignment, the compiler will tell you
> if the type mismatches.
I've keep it to ensure the size of the hv_timer_message_payload
doesn't exceed the maximum payload size (240 bytes), as
msg->payload.raw is the maximum payload size defined by the standard.
> Therefore, it's safe to drop.
>
> Otherwise, Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Let me know if you are fine with keeping the BUILD_BUG_ON() given the
justification above, as that would be my preference.
Thanks, Roger.
prev parent reply other threads:[~2025-11-14 9:11 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-13 17:24 [PATCH] x86/viridian: use hv_timer_message_payload struct Roger Pau Monne
2025-11-13 17:52 ` Andrew Cooper
2025-11-14 9:10 ` Roger Pau Monné [this message]
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=aRbyFugnEJojSH01@Mac.lan \
--to=roger.pau@citrix.com \
--cc=andrew.cooper3@citrix.com \
--cc=jbeulich@suse.com \
--cc=paul@xen.org \
--cc=xen-devel@lists.xenproject.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.