linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: andre.przywara@linaro.org (Andre Przywara)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] ARM/KVM: save and restore generic timer registers
Date: Wed, 05 Jun 2013 23:11:46 +0200	[thread overview]
Message-ID: <51AFA992.4060803@linaro.org> (raw)
In-Reply-To: <20130605192316.GB9640@ubuntu>

On 06/05/2013 09:23 PM, Christoffer Dall wrote:
> On Sat, Jun 01, 2013 at 12:39:12AM +0200, Andre Przywara wrote:
>> For migration to work we need to save (and later restore) the state of
>> each cores virtual generic timer.
>> Since this is per VCPU, we can use the [gs]et_one_reg ioctl and just
>> need to add the three registers (control, counter, compare value) to
>> the list of saved registers. However we provide special accessor
>> functions to get the value of each register, since the content can
>> change anytime.
>>
>> Signed-off-by: Andre Przywara <andre.przywara@linaro.org>
>> ---
>>   arch/arm/include/asm/kvm_asm.h  |  7 ++++++-
>>   arch/arm/include/asm/kvm_host.h |  3 +++
>>   arch/arm/include/uapi/asm/kvm.h | 16 ++++++++++++++++
>>   arch/arm/kvm/arch_timer.c       | 32 ++++++++++++++++++++++++++++++++
>>   arch/arm/kvm/coproc.c           | 30 ++++++++++++++++++++++++++++++
>>   5 files changed, 87 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/arm/include/asm/kvm_asm.h b/arch/arm/include/asm/kvm_asm.h
>> index 18d5032..a732b17 100644
>> --- a/arch/arm/include/asm/kvm_asm.h
>> +++ b/arch/arm/include/asm/kvm_asm.h
>> @@ -46,7 +46,12 @@
>>   #define c13_TID_URO	24	/* Thread ID, User R/O */
>>   #define c13_TID_PRIV	25	/* Thread ID, Privileged */
>>   #define c14_CNTKCTL	26	/* Timer Control Register (PL1) */
>> -#define NR_CP15_REGS	27	/* Number of regs (incl. invalid) */
>> +#define c14_CNTV_CTL	27	/* Virtual Timer Control Register */
>> +#define c14_CNTVCT	28	/* Virtual Timer Counter Register */
>> +#define c14_CNTVCT_high	29	/* Virtual Timer Counter Register */
>> +#define c14_CNTV_CVAL	30	/* Virtual Timer Counter Register */
>> +#define c14_CNTV_CVAL_high	31	/* Virtual Timer Counter Register */
>> +#define NR_CP15_REGS	32	/* Number of regs (incl. invalid) */
>
> To avoid the extra storage overhead here I suggest you just export the
> registers using a separate number space for the ONE_REG ioctl instead of
> piggybacking on the cp15 exports.

Believe it or not, that was my first approach ;-)
I sent it out to Peter and Marc sometimes ago, they disliked it because 
the timer lives in cp15 space and they didn't see enough justification 
to create an extra coproc for this. So I went ahead and changed it...

I will forward you the thread for your reference.

However I have no issues in going back to that old version (or a 
slightly improved one).

Regards,
Andre.

> The main rationale being that the cp15 registers are optional to the
> architecture, which fits nicely with having the extra struct (which is a
> kconfig option) included in the vcpu struct.
>
> The implementation is basically going to be the same, you just need to
> add specific handling for that number space, I recommend you use
> "coprocessor number 17" for this, so your pattern would look something
> like (note added benefit of direct 64 bit support):
>
> 0x4020 0000 0013 <32 bit reg_id, indexed from 0:16>
> 0x4030 0000 0013 <64 bit reg_id, indexed from 0:16>
>
snip

  reply	other threads:[~2013-06-05 21:11 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-31 22:39 [PATCH] ARM/KVM: save and restore generic timer registers Andre Przywara
2013-06-05 19:23 ` Christoffer Dall
2013-06-05 21:11   ` Andre Przywara [this message]
2013-06-05 21:18     ` Peter Maydell
2013-06-05 22:44       ` Christoffer Dall

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=51AFA992.4060803@linaro.org \
    --to=andre.przywara@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).