All of lore.kernel.org
 help / color / mirror / Atom feed
From: Avi Kivity <avi@redhat.com>
To: Christoffer Dall <cdall@cs.columbia.edu>
Cc: kvm@vger.kernel.org, catalin.marinas@arm.com,
	tech@virtualopensystems.com, android-virt@lists.cs.columbia.edu
Subject: Re: [PATCH v4 04/10] ARM: KVM: Memory virtualization setup
Date: Tue, 09 Aug 2011 12:57:42 +0300	[thread overview]
Message-ID: <4E410496.7030001@redhat.com> (raw)
In-Reply-To: <20110806103926.27198.11259.stgit@localhost6.localdomain6>

On 08/06/2011 01:39 PM, Christoffer Dall wrote:
> This commit introduces the framework for guest memory management
> through the use of 2nd stage translation. Each VM has a pointer
> to a level-1 tabled (the pgd field in struct kvm_arch) which is
> used for the 2nd stage translations. Entries are added when handling
> guest faults (later patch) and the table itself can be allocated and
> freed through the following functions implemented in
> arch/arm/kvm/arm_mmu.c:
>   - kvm_alloc_stage2_pgd(struct kvm *kvm);
>   - kvm_free_stage2_pgd(struct kvm *kvm);
>
> Further, each entry in TLBs and caches are tagged with a VMID
> identifier in addition to ASIDs. The VMIDs are managed using
> a bitmap and assigned when creating the VM in kvm_arch_init_vm()
> where the 2nd stage pgd is also allocated. The table is freed in
> kvm_arch_destroy_vm(). Both functions are called from the main
> KVM code.
>
>
> +/**
> + * kvm_arch_init_vm - initializes a VM data structure
> + * @kvm:	pointer to the KVM struct
> + */
>   int kvm_arch_init_vm(struct kvm *kvm)
>   {
> -	return 0;
> +	int ret = 0;
> +	phys_addr_t pgd_phys;
> +	unsigned long vmid;
> +	unsigned long start, end;
> +
> +
> +	mutex_lock(&kvm_vmids_mutex);
> +	vmid = find_first_zero_bit(kvm_vmids, VMID_SIZE);
> +	if (vmid>= VMID_SIZE) {
> +		mutex_unlock(&kvm_vmids_mutex);
> +		return -EBUSY;
> +	}
> +	__set_bit(vmid, kvm_vmids);

VMID_SIZE seems to be a bit low for comfort.  I guess it's fine for a 
start, but later on we'll have to recycle VMIDs, like we do for SVM ASIDs.

Is there not a risk of a user starting 255 tiny guests and denying other 
users the ability to use kvm?

> +	kvm->arch.vmid = vmid;
> +	mutex_unlock(&kvm_vmids_mutex);
> +
> +	ret = kvm_alloc_stage2_pgd(kvm);
> +	if (ret)
> +		goto out_fail_alloc;
> +
> +	pgd_phys = virt_to_phys(kvm->arch.pgd);
> +	kvm->arch.vttbr = pgd_phys&  ((1LLU<<  40) - 1)&  ~((2<<  VTTBR_X) - 1);
> +	kvm->arch.vttbr |= ((u64)vmid<<  48);
> +
> +	start = (unsigned long)kvm,
> +	end = start + sizeof(struct kvm);
> +	ret = create_hyp_mappings(kvm_hyp_pgd, start, end);
> +	if (ret)
> +		goto out_fail_hyp_mappings;
> +
> +	return ret;
> +out_fail_hyp_mappings:
> +	remove_hyp_mappings(kvm_hyp_pgd, start, end);
> +out_fail_alloc:
> +	clear_bit(vmid, kvm_vmids);
> +	return ret;
>   }
>

-- 
error compiling committee.c: too many arguments to function


  reply	other threads:[~2011-08-09  9:58 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-06 10:38 [PATCH v4 00/10] KVM/ARM Implementation Christoffer Dall
2011-08-06 10:39 ` [PATCH v4 01/10] ARM: KVM: Initial skeleton to compile KVM support Christoffer Dall
2011-08-06 10:39 ` [PATCH v4 02/10] ARM: KVM: Hypervisor identity mapping Christoffer Dall
2011-08-09  9:20   ` Avi Kivity
2011-08-09  9:29     ` Catalin Marinas
2011-08-09  9:29     ` Christoffer Dall
2011-08-09 10:23       ` [Android-virt] " Alexey Smirnov
2011-08-09 11:23         ` Christoffer Dall
2011-08-06 10:39 ` [PATCH v4 03/10] ARM: KVM: Add hypervisor inititalization Christoffer Dall
2011-08-06 10:39 ` [PATCH v4 04/10] ARM: KVM: Memory virtualization setup Christoffer Dall
2011-08-09  9:57   ` Avi Kivity [this message]
2011-08-09 11:24     ` [Android-virt] " Christoffer Dall
2011-08-06 10:39 ` [PATCH v4 05/10] ARM: KVM: Inject IRQs and FIQs from userspace Christoffer Dall
2011-08-09 10:07   ` Avi Kivity
2011-08-09 11:27     ` [Android-virt] " Christoffer Dall
2011-08-09 11:37       ` Avi Kivity
2011-08-09 11:40         ` Christoffer Dall
2011-08-06 10:39 ` [PATCH v4 06/10] ARM: KVM: World-switch implementation Christoffer Dall
2011-08-09 11:09   ` Avi Kivity
2011-08-09 11:29     ` Christoffer Dall
2011-08-06 10:39 ` [PATCH v4 07/10] ARM: KVM: Emulation framework and CP15 emulation Christoffer Dall
2011-08-09 11:17   ` Avi Kivity
2011-08-09 11:34     ` Christoffer Dall
2011-08-09 11:39       ` Avi Kivity
2011-08-09 11:40         ` Christoffer Dall
2011-08-06 10:39 ` [PATCH v4 08/10] ARM: KVM: Handle guest faults in KVM Christoffer Dall
2011-08-09 11:24   ` Avi Kivity
2011-08-09 11:35     ` Christoffer Dall
2011-08-06 10:40 ` [PATCH v4 09/10] ARM: KVM: Handle I/O aborts Christoffer Dall
2011-08-09 11:34   ` Avi Kivity
2011-08-09 11:39     ` Christoffer Dall
2011-08-09 11:46       ` Avi Kivity
2011-08-06 10:40 ` [PATCH v4 10/10] ARM: KVM: Guest wait-for-interrupts (WFI) support Christoffer Dall
2011-08-09 11:43 ` [PATCH v4 00/10] KVM/ARM Implementation Avi Kivity

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=4E410496.7030001@redhat.com \
    --to=avi@redhat.com \
    --cc=android-virt@lists.cs.columbia.edu \
    --cc=catalin.marinas@arm.com \
    --cc=cdall@cs.columbia.edu \
    --cc=kvm@vger.kernel.org \
    --cc=tech@virtualopensystems.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.