public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Julien Grall <julien.grall@arm.com>
To: Marc Zyngier <marc.zyngier@arm.com>
Cc: "kvm@vger.kernel.org" <kvm@vger.kernel.org>, nd <nd@arm.com>,
	Christoffer Dall <Christoffer.Dall@arm.com>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"kvmarm@lists.cs.columbia.edu" <kvmarm@lists.cs.columbia.edu>
Subject: Re: [PATCH 06/14] KVM: arm/arm64: Factor out VMID into struct kvm_vmid
Date: Fri, 22 Feb 2019 11:42:46 +0000	[thread overview]
Message-ID: <44bd2df6-8011-c77f-a83a-95c3529287c0@arm.com> (raw)
In-Reply-To: <20190222091848.21f7f8e6@why.wild-wind.fr.eu.org>

Hi Marc,

On 22/02/2019 09:18, Marc Zyngier wrote:
> On Thu, 21 Feb 2019 11:02:56 +0000
> Julien Grall <Julien.Grall@arm.com> wrote:
> 
> Hi Julien,
> 
>> Hi Christoffer,
>>
>> On 24/01/2019 14:00, Christoffer Dall wrote:
>>> Note that to avoid mapping the kvm_vmid_bits variable into hyp, we
>>> simply forego the masking of the vmid value in kvm_get_vttbr and rely on
>>> update_vmid to always assign a valid vmid value (within the supported
>>> range).
>>
>> [...]
>>
>>> -	kvm->arch.vmid = kvm_next_vmid;
>>> +	vmid->vmid = kvm_next_vmid;
>>>    	kvm_next_vmid++;
>>> -	kvm_next_vmid &= (1 << kvm_vmid_bits) - 1;
>>> -
>>> -	/* update vttbr to be used with the new vmid */
>>> -	pgd_phys = virt_to_phys(kvm->arch.pgd);
>>> -	BUG_ON(pgd_phys & ~kvm_vttbr_baddr_mask(kvm));
>>> -	vmid = ((u64)(kvm->arch.vmid) << VTTBR_VMID_SHIFT) & VTTBR_VMID_MASK(kvm_vmid_bits);
>>> -	kvm->arch.vttbr = kvm_phys_to_vttbr(pgd_phys) | vmid | cnp;
>>> +	kvm_next_vmid &= (1 << kvm_get_vmid_bits()) - 1;
>>
>> The arm64 version of kvm_get_vmid_bits does not look cheap. Indeed it required
>> to read the sanitized value of SYS_ID_AA64MMFR1_EL1 that is implemented using
>> the function bsearch.
>>
>> So wouldn't it be better to keep kvm_vmid_bits variable for use in update_vttbr()?
> 
> How often does this happen? Can you measure this overhead at all?
> 
> My understanding is that we hit this path on rollover only, having IPIed
> all CPUs and invalidated all TLBs. I seriously doubt you can observe
> any sort of overhead at all, given that it is so incredibly rare. But
> feel free to prove me wrong!

That would happen on roll-over and the first time you allocate VMID for the VM.

I am planning to run some test with 3-bit VMIDs and provide them next week.

Cheers,

-- 
Julien Grall

  reply	other threads:[~2019-02-22 11:42 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-24 14:00 [PATCH 00/14] KVM: arm/arm64: Various rework in preparation of nested virt support Christoffer Dall
2019-01-24 14:00 ` [PATCH 01/14] arm/arm64: KVM: Introduce kvm_call_hyp_ret() Christoffer Dall
2019-01-24 14:00 ` [PATCH 02/14] arm64: KVM: Allow for direct call of HYP functions when using VHE Christoffer Dall
2019-01-24 14:00 ` [PATCH 03/14] arm64: KVM: Drop VHE-specific HYP call stub Christoffer Dall
2019-01-24 14:00 ` [PATCH 04/14] ARM: KVM: Teach some form of type-safety to kvm_call_hyp Christoffer Dall
2019-01-24 14:00 ` [PATCH 05/14] arm/arm64: KVM: Statically configure the host's view of MPIDR Christoffer Dall
2019-01-24 14:00 ` [PATCH 06/14] KVM: arm/arm64: Factor out VMID into struct kvm_vmid Christoffer Dall
2019-01-24 19:01   ` James Morse
2019-01-25 10:09     ` Marc Zyngier
2019-01-25 11:05   ` Julien Thierry
2019-01-31 13:01     ` Marc Zyngier
2019-02-21 11:02   ` Julien Grall
2019-02-22  9:18     ` Marc Zyngier
2019-02-22 11:42       ` Julien Grall [this message]
2019-02-22 12:14         ` Marc Zyngier
2019-01-24 14:00 ` [PATCH 07/14] KVM: arm/arm64: Simplify bg_timer programming Christoffer Dall
2019-01-24 14:00 ` [PATCH 08/14] KVM: arm64: Fix ICH_ELRSR_EL2 sysreg naming Christoffer Dall
2019-01-24 14:00 ` [PATCH 09/14] KVM: arm64: Reuse sys_reg() macro when searching the trap table Christoffer Dall
2019-01-30  8:57   ` André Przywara
2019-01-24 14:00 ` [PATCH 10/14] KVM: arm/arm64: consolidate arch timer trap handlers Christoffer Dall
2019-01-25 12:33   ` Julien Thierry
2019-01-30 17:38     ` Marc Zyngier
2019-01-24 14:00 ` [PATCH 11/14] KVM: arm/arm64: timer: Rework data structures for multiple timers Christoffer Dall
2019-02-18 15:10   ` André Przywara
2019-02-19 12:27     ` Christoffer Dall
2019-01-24 14:00 ` [PATCH 12/14] KVM: arm/arm64: arch_timer: Assign the phys timer on VHE systems Christoffer Dall
2019-02-18 15:10   ` André Przywara
2019-02-19 12:43     ` Christoffer Dall
2019-02-20 17:58       ` Andre Przywara
2019-02-19 11:39   ` Alexandru Elisei
2019-02-19 13:03     ` Christoffer Dall
2019-01-24 14:00 ` [PATCH 13/14] KVM: arm/arm64: Rework the timer code to use a timer_map Christoffer Dall
2019-01-24 14:00 ` [PATCH 14/14] KVM: arm/arm64: Move kvm_is_write_fault to header file 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=44bd2df6-8011-c77f-a83a-95c3529287c0@arm.com \
    --to=julien.grall@arm.com \
    --cc=Christoffer.Dall@arm.com \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=marc.zyngier@arm.com \
    --cc=nd@arm.com \
    /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