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

RE: [PATCH] xen/arm: avoid vtimer flip-flop transition in context switch


  • To: Julien Grall <julien@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Wei Chen <Wei.Chen@xxxxxxx>
  • Date: Fri, 17 Jun 2022 10:42:49 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com])
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
  • Arc-message-signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=ZhHnLb1DtHSLpn0nYAVsoJxBk+anSGpro/6G43XRzKU=; b=AKA/gItZiMGmTEHZ6qU6pg5Wkedpxd5D1nwt+a+suKL0bD7tEYSnaFpLp2kpKQEFDl9Qbe8QLCd8yzMWnvE6Nufy0bEVU3XAKS4NXdSAwv8mWMaAapvQLszy+fo3T0ERW2xv1r5fVBjoTNQpjTRZP9MZX8c+PjnZw4e5YKbCqAKOpk8GM3t9X3QNZgiyDBsba85vXxJGL7/0Gfb48BuVoH2iDo5u1r/VvkOunF9DrY1yM3vEP22wvIwzqlWbm6nvSX+qDv3pNn6OSXRUyKihuEWrN6PFk/28dSzR6Vs0X/vT+eLePqUs3obPAlZw726U0FjueCJxwGiWedeI0PKaFw==
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=ZhHnLb1DtHSLpn0nYAVsoJxBk+anSGpro/6G43XRzKU=; b=LDGoFmYbUdXHwsopJFdqHHGfAaw/YstVODE3KIazK3YgajDfTDaCNXubOxU9Lus6PivctCFLakU8zTGuoV+QcNtSFyQ3SPmHPFRZgnSSusmvhVHz6japkHlmoHl6mVsou1jNO7SyUz4HEgY4mBMOrQ+QQc1Cj0KlhuMqzn5mwFcWyLAFflFXMl+sDUCL+5P1rbPKAdJFlTEy+Ey/jz5czleUm/3dSLNHwr9MBTy0kPsNMEgN6zhcCh/gcbgcipqyIMbJn+aV3uK1i2awSQl1gVGuSjzjIWGx6hN2s7ygJeVykeXHmrHufngTO7ltrPK2THk1W13iQlZub6pSgG1HmQ==
  • Arc-seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=C9rtyUXibJ+uqfGKlk206yW197/fpbbH82k85dS3RohKy3fCI8u+h2m1v4fHhiVo7G88DGck+ptLoCGDuXJh4t8hweB4A2ynR6ShDpucl+7b3xT7U3xPKy5eJK5pIyjP2fDueO4paFKUKeYi5n5ymcVtPxANDGtVaX7rtXuAH+5kiXzJZpHM1s6yNt4/xvaDi2iHI0DDp4/1SZwP2et6SPwG5CksOE4E9dsTAp2Vnke/matfPCI/ViCMHSNM5ENzXo8LRsKw0lXJCvX+8uik1ufUI5HqSZ4pQMtU/RkmMz+mMDrcPNZrn03NvQALrbbX45utsZebsCQbHKdJmF1aUg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WS2vsi4z1kQ9K5+XbuAwOWqXJHwrYiVbTIM2Nr9zk96cCNyI/Xl52NKeYLEmXi58iht02dw9mZ3m71NrAFx/Xcu2JBwdoutJ7GAI3xZAWPK9WQBnMQnrjolQHARCzSKAWfKCkX3/MfvZyXdkg3WQomcAOgfQyQAq1eEYhTQMYJ8X/Sixfr9t5XyVvIrp8Bw+3B33EQEgaqwSKUgYPEOul6+mV9bU9IH4JqXR08XexoMq4CK67iIWvSJKfyEzjuNxXKjARMsYxPMf4DG6a/UUt8zK2efHT+cwouXYHfMixhP6TdBkh1FNiAmAG+3j1Gz2dYV0anreW1GeVgYjB7lSqA==
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: nd <nd@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Bertrand Marquis <Bertrand.Marquis@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Fri, 17 Jun 2022 10:43:11 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Original-authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Thread-index: AQHYgFjGGQRmuhVkyUGP4eiVYzlBr61QOR4AgAABKRCAAw50AIAAI+pg
  • Thread-topic: [PATCH] xen/arm: avoid vtimer flip-flop transition in context switch

Hi Julien,

> -----Original Message-----
> From: Julien Grall <julien@xxxxxxx>
> Sent: 2022年6月17日 16:32
> To: Wei Chen <Wei.Chen@xxxxxxx>; xen-devel@xxxxxxxxxxxxxxxxxxxx
> Cc: nd <nd@xxxxxxx>; Stefano Stabellini <sstabellini@xxxxxxxxxx>; Bertrand
> Marquis <Bertrand.Marquis@xxxxxxx>; Volodymyr Babchuk
> <Volodymyr_Babchuk@xxxxxxxx>
> Subject: Re: [PATCH] xen/arm: avoid vtimer flip-flop transition in context
> switch
> 
> 
> 
> On 15/06/2022 11:36, Wei Chen wrote:
> > Hi Julien,
> 
> Hi Wei,
> 
> >> -----Original Message-----
> >> From: Julien Grall <julien@xxxxxxx>
> >> Sent: 2022年6月15日 17:47
> >> To: Wei Chen <Wei.Chen@xxxxxxx>; xen-devel@xxxxxxxxxxxxxxxxxxxx
> >> Cc: nd <nd@xxxxxxx>; Stefano Stabellini <sstabellini@xxxxxxxxxx>;
> Bertrand
> >> Marquis <Bertrand.Marquis@xxxxxxx>; Volodymyr Babchuk
> >> <Volodymyr_Babchuk@xxxxxxxx>
> >> Subject: Re: [PATCH] xen/arm: avoid vtimer flip-flop transition in
> context
> >> switch
> >>>
> >>> So in this patch, we adjust the formula to use "offset - boot_count"
> >>> first, and then use the result to plus cval. This will avoid the
> >>> uint64_t overflow.
> >>
> >> Technically, the overflow is still present because the (offset -
> >> boot_count) is a non-zero value *and* cval is a 64-bit value.
> >>
> >
> > Yes, GuestOS can issue any valid 64-bit value for their usage.
> >
> >> So I think the equation below should be reworked to...
> >>
> >>>
> >>> Signed-off-by: Wei Chen <wei.chen@xxxxxxx>
> >>> ---
> >>>    xen/arch/arm/vtimer.c | 5 +++--
> >>>    1 file changed, 3 insertions(+), 2 deletions(-)
> >>>
> >>> diff --git a/xen/arch/arm/vtimer.c b/xen/arch/arm/vtimer.c
> >>> index 5bb5970f58..86e63303c8 100644
> >>> --- a/xen/arch/arm/vtimer.c
> >>> +++ b/xen/arch/arm/vtimer.c
> >>> @@ -144,8 +144,9 @@ void virt_timer_save(struct vcpu *v)
> >>>        if ( (v->arch.virt_timer.ctl & CNTx_CTL_ENABLE) &&
> >>>             !(v->arch.virt_timer.ctl & CNTx_CTL_MASK))
> >>>        {
> >>> -        set_timer(&v->arch.virt_timer.timer, ticks_to_ns(v-
> >>> arch.virt_timer.cval +
> >>> -                  v->domain->arch.virt_timer_base.offset -
> boot_count));
> >>> +        set_timer(&v->arch.virt_timer.timer,
> >>> +                  ticks_to_ns(v->domain->arch.virt_timer_base.offset
> -
> >>> +                              boot_count + v->arch.virt_timer.cval));
> >>
> >> ... something like:
> >>
> >> ticks_to_ns(offset - boot_count) + ticks_to_ns(cval);
> >>
> >> The first part of the equation should always be the same. So it could
> be
> >> stored in struct domain.
> >>
> >
> > If you think there is still some values to continue this patch, I will
> > address this comment : )
> 
> I think there are. This can be easily triggered by a vCPU setting a
> large cval.
> 

Ok, thanks! We will address it and refine the subject and descriptions.

> Cheers,
> 
> --
> Julien Grall

 


Rackspace

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