[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] x86/viridian: use hv_timer_message_payload struct


  • To: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Fri, 14 Nov 2025 10:10:46 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Hr7DTJIufm0p25oj4sCrlf1nLSZaUAmrYro1EM9XGcY=; b=kXhpKH4t+M8V4a41ucJDVJVK+Pv7dw3DcHcQCXZ5a8CPAKACZSLJm/1V2jtv85cSVDF+xjUEYoeXx0nANKtwh+3Qs7sqS3BjEWopVPOcbTG63NKuIT+XsfkdQevUQtQasRccNZeza8JIj7zVMBZWWUzB8ylUshpH2A3ux9x1odfAusbIps2rUQbDQ2V07SEUohF4DKNeuf5L8g7pRFRFME8pEPt2S9GV66APAr+LswW0YqUbgXFIU6iaABqCE9M+Ba+fCUfwLxHtaJY93a3jCjBzAT3cYdLHBncZb5MZ8iXlmo4KqeTgeIN4yTzwkFmOPqlR1K7/37TOORL7Nlszsg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=VnEWTS8U6vkarGGwFzdu2rmCqxEvvISIfqC07oEA5ye0/+fMQ6EtCmipXKMrC4srCvFUFpLz/ZIbbwTXsxkBD4CCoBk2vOT0wIaSXeSJJH5XIhGWERVJrqYsWMCm85iIoqTVcNljSfQasZK4f6FvZQAtfAx9xR3XyuZD+G27aqhM+a7dXpi0d4/CyDt0gKaupkB2I34qDxWAVCBSGzF8kfDGihzlYMxnyahFWORfPGD36cczOL7cdFl4IfoiTSN5GrIxnfRutJDro1g1h8DA91adN4bK4ZPPbcQzwLEGLI7hZiTmYRFJlLGvpUjyt2GkIeP5g/p/YdEOj+29AaFtmg==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: xen-devel@xxxxxxxxxxxxxxxxxxxx, Paul Durrant <paul@xxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>
  • Delivery-date: Fri, 14 Nov 2025 09:11:09 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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@xxxxxxxxxx>

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.



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.