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

Re: [PATCH 4/5] x86/time: gtsc_to_gtime() is HVM-only


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Wed, 14 Jan 2026 10:52:07 +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=LQXsGox0J2nDQ7zGjOnmuQKu+/3lCfMKMolkWae8U/M=; b=G8svYoVxvAnJcl8ODA7MK3e1q1FL+LQ5Zc2SEQlZULGdHC7uIRqsxE8KCr0CFJ/gAAUH4vW/9gPmdiI3yZq9isr0tCCaIgpy92DaPxNJLo7juX5/mVgjSgMPdSGSZYjSYrNQpVUoHb+5ei6IrAWgG2MH2XqmxyOKd9QQKkZloJn94Ow0vXER5mj7Vxt0QP29qVxXCMxjfLx6/CHHaZPInICFKRKE4wyxmO88SohwPmkA8E7BZcrF+dyQ9QsAUCiFG+/e2ilvl2Rezp6qt8O06XZubQOvI8YSJrGnCZ9EKGRAIO3Z5gVzi0i/SA2ECoxjtBIC2/fbEOEkW9JUufpI9A==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=eL8sfaoc7JCFAXcdY5LJMmL3uG8oQv7YjrdPR9PvRHJDKTfL7EyO4qimgsm1Tcn+VnLJJ6NUrM8MviD12dWhxYlUBTot2W1U5uA5yMYHkK15n/ZtpOmjN8oKOtN3gyq5itkWJKSnp6M47f6U5l5Jl4AJL3xEL1Dt2F4qroSiwKu7p3uEsnpz6AQWojTjPUCo5RgrDRc9wfS6Shntp57cRQ0k5oU7f0eZRwH0GX5t/s9lfWAt+fWsY2bphOnzNr7wMLZlIfCbvffIQnpbAo27CIII0KXl2MiDbTWsXTJmT8JqQia/V6h6eb/Lnk3wRAhWiIHS3/tRwDmw3DfAR9/9zg==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Delivery-date: Wed, 14 Jan 2026 09:53:06 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Wed, Jan 14, 2026 at 10:43:38AM +0100, Roger Pau Monné wrote:
> On Tue, Jan 06, 2026 at 02:59:43PM +0100, Jan Beulich wrote:
> > Omit the function when HVM=n. With that the !HVM logic can also go away;
> > leave an assertion.
> > 
> > Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
> > 
> > --- a/xen/arch/x86/time.c
> > +++ b/xen/arch/x86/time.c
> > @@ -2840,14 +2840,13 @@ uint64_t gtime_to_gtsc(const struct doma
> >      return scale_delta(time, &d->arch.ns_to_vtsc);
> >  }
> >  
> > +#ifdef CONFIG_HVM
> >  uint64_t gtsc_to_gtime(const struct domain *d, uint64_t tsc)
> >  {
> > -    u64 time = scale_delta(tsc, &d->arch.vtsc_to_ns);
> > -
> > -    if ( !is_hvm_domain(d) )
> > -        time += d->arch.vtsc_offset;
> > -    return time;
> > +    ASSERT(is_hvm_domain(d));
> > +    return scale_delta(tsc, &d->arch.vtsc_to_ns);
> >  }
> > +#endif /* CONFIG_HVM */
> 
> Seeing this is solely used by the vlapic code, did you consider
> keeping scale_delta() non-static, and then moving gtsc_to_gtime() into
> vlapic.c?
> 
> It would result in less ifdefery overall.

I see now this might not be appropriate, gtsc_to_gtime() is the pair
to gtime_to_gtsc(), which is used in other places.  It looks like
gtsc_to_gtime() could also gain users in order parts of the code, and
hence making static to vlapic might not be the best approach.

I'm not overly happy with adding more ifdefary to time.c, and the
asymmetry this creates with PV guest not having a gtsc_to_gtime(), but
it's otherwise dead code, so:

Acked-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>

Thanks, Roger.



 


Rackspace

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