All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: kvm@vger.kernel.org
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
	"Radim Krčmář" <rkrcmar@redhat.com>,
	david@redhat.com
Subject: [PATCH v2 14/15] KVM: x86: allow setting identity map addr with no vcpus only
Date: Thu, 24 Aug 2017 20:51:36 +0200	[thread overview]
Message-ID: <20170824185137.6253-15-david@redhat.com> (raw)
In-Reply-To: <20170824185137.6253-1-david@redhat.com>

Changing it afterwards doesn't make too much sense and will only result
in inconsistencies.

Reviewed-by: Radim Krčmář <rkrcmar@redhat.com>
Signed-off-by: David Hildenbrand <david@redhat.com>
---
 Documentation/virtual/kvm/api.txt | 1 +
 arch/x86/kvm/x86.c                | 8 +++++++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/Documentation/virtual/kvm/api.txt b/Documentation/virtual/kvm/api.txt
index 22bc5a052a5d..dd2dd96927b8 100644
--- a/Documentation/virtual/kvm/api.txt
+++ b/Documentation/virtual/kvm/api.txt
@@ -1131,6 +1131,7 @@ This ioctl is required on Intel-based hosts.  This is needed on Intel hardware
 because of a quirk in the virtualization implementation (see the internals
 documentation when it pops into existence).
 
+Fails if any VCPU has already been created.
 
 4.41 KVM_SET_BOOT_CPU_ID
 
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 757e1caa05ec..ccb065608215 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -4005,10 +4005,16 @@ long kvm_arch_vm_ioctl(struct file *filp,
 	case KVM_SET_IDENTITY_MAP_ADDR: {
 		u64 ident_addr;
 
+		mutex_lock(&kvm->lock);
+		r = -EINVAL;
+		if (kvm->created_vcpus)
+			goto set_identity_unlock;
 		r = -EFAULT;
 		if (copy_from_user(&ident_addr, argp, sizeof ident_addr))
-			goto out;
+			goto set_identity_unlock;
 		r = kvm_vm_ioctl_set_identity_map_addr(kvm, ident_addr);
+set_identity_unlock:
+		mutex_unlock(&kvm->lock);
 		break;
 	}
 	case KVM_SET_NR_MMU_PAGES:
-- 
2.13.5

  parent reply	other threads:[~2017-08-24 18:52 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-24 18:51 [PATCH v2 00/15] KVM x86/VMX cleanups David Hildenbrand
2017-08-24 18:51 ` [PATCH v2 01/15] KVM: x86: mmu: returning void in a void function is strange David Hildenbrand
2017-08-24 18:51 ` [PATCH v2 02/15] KVM: x86: mmu: free_page can handle NULL David Hildenbrand
2017-08-24 18:51 ` [PATCH v2 03/15] KVM: x86: drop BUG_ON(vcpu->kvm) David Hildenbrand
2017-08-24 18:51 ` [PATCH v2 04/15] KVM: VMX: vmx_vcpu_setup() cannot fail David Hildenbrand
2017-08-24 18:51 ` [PATCH v2 05/15] KVM: x86: no need to inititalize vcpu members to 0 David Hildenbrand
2017-08-24 18:51 ` [PATCH v2 06/15] KVM: VMX: drop enable_ept check from ept_sync_context() David Hildenbrand
2017-08-24 18:51 ` [PATCH v2 07/15] KVM: VMX: call ept_sync_global() with enable_ept only David Hildenbrand
2017-08-24 18:51 ` [PATCH v2 08/15] KVM: VMX: require INVEPT GLOBAL for EPT David Hildenbrand
2017-08-24 18:51 ` [PATCH v2 09/15] KVM: VMX: drop unnecessary function declarations David Hildenbrand
2017-08-24 18:51 ` [PATCH v2 10/15] KVM: nVMX: no need to set vcpu->cpu when switching vmcs David Hildenbrand
2017-08-24 18:51 ` [PATCH v2 11/15] KVM: nVMX: no need to set ept/vpid caps to 0 David Hildenbrand
2017-08-24 18:51 ` [PATCH v2 12/15] KVM: VMX: cleanup init_rmode_identity_map() David Hildenbrand
2017-08-24 18:51 ` [PATCH v2 13/15] KVM: x86: document special identity map address value David Hildenbrand
2017-08-24 18:51 ` David Hildenbrand [this message]
2017-08-24 18:51 ` [PATCH v2 15/15] KVM: VMX: rename RDSEED and RDRAND vmx ctrls to reflect exiting David Hildenbrand
2017-08-24 20:39   ` Jim Mattson
2017-08-28 14:55     ` David Hildenbrand
2017-08-28 15:50       ` Jim Mattson
2017-09-19 12:42 ` [PATCH v2 00/15] KVM x86/VMX cleanups David Hildenbrand
2017-09-19 12:57   ` Paolo Bonzini
2017-10-06 18:11 ` Radim Krčmář

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=20170824185137.6253-15-david@redhat.com \
    --to=david@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=rkrcmar@redhat.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.