public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <sean.j.christopherson@intel.com>
To: Joerg Roedel <joro@8bytes.org>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	Vitaly Kuznetsov <vkuznets@redhat.com>,
	Wanpeng Li <wanpengli@tencent.com>,
	Jim Mattson <jmattson@google.com>,
	Tom Lendacky <thomas.lendacky@amd.com>,
	kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
	Joerg Roedel <jroedel@suse.de>
Subject: Re: [PATCH v3 2/4] KVM: SVM: Add GHCB definitions
Date: Mon, 3 Aug 2020 11:17:31 -0700	[thread overview]
Message-ID: <20200803181731.GF3151@linux.intel.com> (raw)
In-Reply-To: <20200803122708.5942-3-joro@8bytes.org>

On Mon, Aug 03, 2020 at 02:27:06PM +0200, Joerg Roedel wrote:
> From: Tom Lendacky <thomas.lendacky@amd.com>
> 
> Extend the vmcb_safe_area with SEV-ES fields and add a new
> 'struct ghcb' which will be used for guest-hypervisor communication.
> 
> Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
> Signed-off-by: Joerg Roedel <jroedel@suse.de>
> ---
>  arch/x86/include/asm/svm.h | 45 +++++++++++++++++++++++++++++++++++++-
>  arch/x86/kvm/svm/svm.c     |  2 ++
>  2 files changed, 46 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/x86/include/asm/svm.h b/arch/x86/include/asm/svm.h
> index 8a1f5382a4ea..9a3e0b802716 100644
> --- a/arch/x86/include/asm/svm.h
> +++ b/arch/x86/include/asm/svm.h
> @@ -200,13 +200,56 @@ struct __attribute__ ((__packed__)) vmcb_save_area {
>  	u64 br_to;
>  	u64 last_excp_from;
>  	u64 last_excp_to;
> +
> +	/*
> +	 * The following part of the save area is valid only for
> +	 * SEV-ES guests when referenced through the GHCB.
> +	 */
> +	u8 reserved_7[104];
> +	u64 reserved_8;		/* rax already available at 0x01f8 */
> +	u64 rcx;
> +	u64 rdx;
> +	u64 rbx;
> +	u64 reserved_9;		/* rsp already available at 0x01d8 */
> +	u64 rbp;
> +	u64 rsi;
> +	u64 rdi;
> +	u64 r8;
> +	u64 r9;
> +	u64 r10;
> +	u64 r11;
> +	u64 r12;
> +	u64 r13;
> +	u64 r14;
> +	u64 r15;
> +	u8 reserved_10[16];
> +	u64 sw_exit_code;
> +	u64 sw_exit_info_1;
> +	u64 sw_exit_info_2;
> +	u64 sw_scratch;
> +	u8 reserved_11[56];
> +	u64 xcr0;
> +	u8 valid_bitmap[16];
> +	u64 x87_state_gpa;
> +};
> +
> +struct __attribute__ ((__packed__)) ghcb {

IMO this should use __packed straightaway, but I can also appreciate the
desire for consistency within a given snapshot in time so I'm a-ok if you
want to keep it as is.

> +	struct vmcb_save_area save;
> +	u8 reserved_save[2048 - sizeof(struct vmcb_save_area)];
> +
> +	u8 shared_buffer[2032];
> +
> +	u8 reserved_1[10];
> +	u16 protocol_version;	/* negotiated SEV-ES/GHCB protocol version */
> +	u32 ghcb_usage;
>  };
>  
>  
>  static inline void __unused_size_checks(void)
>  {
> -	BUILD_BUG_ON(sizeof(struct vmcb_save_area) != 0x298);
> +	BUILD_BUG_ON(sizeof(struct vmcb_save_area) != 1032);
>  	BUILD_BUG_ON(sizeof(struct vmcb_control_area) != 256);
> +	BUILD_BUG_ON(sizeof(struct ghcb) != 4096);
>  }
>  
>  struct __attribute__ ((__packed__)) vmcb {
> diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
> index 783330d0e7b8..953cf947f022 100644
> --- a/arch/x86/kvm/svm/svm.c
> +++ b/arch/x86/kvm/svm/svm.c
> @@ -4161,6 +4161,8 @@ static struct kvm_x86_init_ops svm_init_ops __initdata = {
>  
>  static int __init svm_init(void)
>  {
> +	__unused_size_checks();
> +
>  	return kvm_init(&svm_init_ops, sizeof(struct vcpu_svm),
>  			__alignof__(struct vcpu_svm), THIS_MODULE);
>  }
> -- 
> 2.17.1
> 

  reply	other threads:[~2020-08-03 18:17 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-03 12:27 [PATCH v3 0/4] KVM: SVM: SEV-ES groundwork Joerg Roedel
2020-08-03 12:27 ` [PATCH v3 1/4] KVM: SVM: nested: Don't allocate VMCB structures on stack Joerg Roedel
2020-08-03 18:04   ` Sean Christopherson
2020-08-03 12:27 ` [PATCH v3 2/4] KVM: SVM: Add GHCB definitions Joerg Roedel
2020-08-03 18:17   ` Sean Christopherson [this message]
2020-08-03 12:27 ` [PATCH v3 3/4] KVM: SVM: Add GHCB Accessor functions Joerg Roedel
2020-08-03 18:45   ` Sean Christopherson
2020-08-03 21:02     ` Joerg Roedel
2020-08-03 12:27 ` [PATCH v3 4/4] KVM: SVM: Use __packed shorthand Joerg Roedel

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=20200803181731.GF3151@linux.intel.com \
    --to=sean.j.christopherson@intel.com \
    --cc=jmattson@google.com \
    --cc=joro@8bytes.org \
    --cc=jroedel@suse.de \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=thomas.lendacky@amd.com \
    --cc=vkuznets@redhat.com \
    --cc=wanpengli@tencent.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