KVM Archive on lore.kernel.org
 help / color / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org
Cc: Liran Alon <liran.alon@oracle.com>,
	Sean Christopherson <sean.j.christopherson@intel.com>,
	Jim Mattson <jmattson@google.com>
Subject: [PATCH] KVM: improve definition of KVM_GET/SET_NESTED_STATE structs
Date: Sat, 15 Jun 2019 02:13:24 +0200
Message-ID: <20190615001324.4776-1-pbonzini@redhat.com> (raw)

Liran sent me a patch with a large overhaul of the
KVM_GET/SET_NESTED_STATE structs.  However, I am wary of changing the
userspace ABI in backwards-incompatible ways, so here is the bare minimum
that is needed to achieve the same functionality.

Namely, the format of VMX nested state is detailed in a struct, and is
accessible through struct kvm_vmx_nested_state.  Unfortunately, to avoid
changing the size of the structs it has to be accessed as "vmx.data[0]"
rather than just "vmx.data".

Also, the values of the "format" field are defined as macros, which is
easy and not controversial.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
 arch/x86/include/uapi/asm/kvm.h | 11 +++++++++++
 arch/x86/kvm/vmx/nested.c       |  3 +++
 2 files changed, 14 insertions(+)

diff --git a/arch/x86/include/uapi/asm/kvm.h b/arch/x86/include/uapi/asm/kvm.h
index 7a0e64ccd6ff..06b8727a3b58 100644
--- a/arch/x86/include/uapi/asm/kvm.h
+++ b/arch/x86/include/uapi/asm/kvm.h
@@ -383,6 +383,9 @@ struct kvm_sync_regs {
 #define KVM_X86_QUIRK_LAPIC_MMIO_HOLE	(1 << 2)
 #define KVM_X86_QUIRK_OUT_7E_INC_RIP	(1 << 3)
 #define KVM_STATE_NESTED_GUEST_MODE	0x00000001
 #define KVM_STATE_NESTED_RUN_PENDING	0x00000002
 #define KVM_STATE_NESTED_EVMCS		0x00000004
@@ -390,6 +393,11 @@ struct kvm_sync_regs {
 #define KVM_STATE_NESTED_SMM_VMXON	0x00000002
+struct kvm_vmx_nested_state_data {
+	__u8 vmcs12[0x1000];
+	__u8 shadow_vmcs12[0x1000];
 struct kvm_vmx_nested_state {
 	__u64 vmxon_pa;
 	__u64 vmcs_pa;
@@ -397,6 +405,9 @@ struct kvm_vmx_nested_state {
 	struct {
 		__u16 flags;
 	} smm;
+	__u8 pad[120 - 18];
+	struct kvm_vmx_nested_state_data data[0];
diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c
index 0c601d079cd2..d97b87ef209b 100644
--- a/arch/x86/kvm/vmx/nested.c
+++ b/arch/x86/kvm/vmx/nested.c
@@ -5269,6 +5269,9 @@ static int vmx_get_nested_state(struct kvm_vcpu *vcpu,
 		.vmx.vmcs_pa = -1ull,
+	BUILD_BUG_ON(sizeof(struct kvm_vmx_nested_state)
+		     != sizeof_field(struct kvm_nested_state, pad));
 	if (!vcpu)
 		return kvm_state.size + 2 * VMCS12_SIZE;

                 reply index

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publically 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:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190615001324.4776-1-pbonzini@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=jmattson@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liran.alon@oracle.com \
    --cc=sean.j.christopherson@intel.com \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

KVM Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/kvm/0 kvm/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 kvm kvm/ https://lore.kernel.org/kvm \
		kvm@vger.kernel.org kvm@archiver.kernel.org
	public-inbox-index kvm

Newsgroup available over NNTP:

AGPL code for this site: git clone https://public-inbox.org/ public-inbox