LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Tianyu Lan <ltykernel@gmail.com>
To: Borislav Petkov <bp@alien8.de>
Cc: Tom Lendacky <thomas.lendacky@amd.com>,
	linux-arch@vger.kernel.org, linux-hyperv@vger.kernel.org,
	linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
	vkuznets@redhat.com, konrad.wilk@oracle.com, hch@lst.de,
	robin.murphy@arm.com, joro@8bytes.org, parri.andrea@gmail.com,
	dave.hansen@intel.com, Hikys@microsoft.com,
	haiyangz@microsoft.com, sthemmin@microsoft.com,
	wei.liu@kernel.org, decui@microsoft.com, tglx@linutronix.de,
	mingo@redhat.com, x86@kernel.org, hpa@zytor.com,
	dave.hansen@linux.intel.com, luto@kernel.org,
	peterz@infradead.org, davem@davemloft.net, kuba@kernel.org,
	gregkh@linuxfoundation.org, arnd@arndb.de, jroedel@suse.de,
	brijesh.singh@amd.com, Tianyu.Lan@microsoft.com,
	pgonda@google.com, akpm@linux-foundation.org,
	kirill.shutemov@linux.intel.com, rppt@kernel.org, tj@kernel.org,
	aneesh.kumar@linux.ibm.com, saravanand@fb.com,
	hannes@cmpxchg.org, rientjes@google.com,
	michael.h.kelley@microsoft.com
Subject: Re: [PATCH V7 5/9] x86/sev-es: Expose __sev_es_ghcb_hv_call() to call ghcb hv call out of sev code
Date: Wed, 13 Oct 2021 22:24:30 +0800	[thread overview]
Message-ID: <5a0b9de8-e133-c17b-bc0d-93bfb593c48f@gmail.com> (raw)
In-Reply-To: <YWRyvD413h+PwU9B@zn.tnic>

On 10/12/2021 1:22 AM, Borislav Petkov wrote:
> On Mon, Oct 11, 2021 at 10:42:18PM +0800, Tianyu Lan wrote:
>> Hi @Tom and Borislav:
>>       Please have a look at this patch. If it's ok, could you give your ack.
> 
> I needed to do some cleanups in that area first:
> 
> https://lore.kernel.org/r/YWRwxImd9Qcls/Yy@zn.tnic
> 
> Can you redo yours ontop so that you can show what exactly you need
> exported for HyperV?
> 
> Thx.

Hi Borislav :
	Please check whether the following change based on you patch is
ok for you.
---
x86/sev-es: Expose __sev_es_ghcb_hv_call() to call ghcb hv call out of 
sev code

     Hyper-V also needs to call ghcb hv call to write/read MSR in 
Isolation VM.
     So expose __sev_es_ghcb_hv_call() to call it in the Hyper-V code.

     Signed-off-by: Tianyu Lan <Tianyu.Lan@microsoft.com>

diff --git a/arch/x86/include/asm/sev.h b/arch/x86/include/asm/sev.h
index fa5cd05d3b5b..295c847c3cd4 100644
--- a/arch/x86/include/asm/sev.h
+++ b/arch/x86/include/asm/sev.h
@@ -81,12 +81,23 @@ static __always_inline void sev_es_nmi_complete(void)
                 __sev_es_nmi_complete();
  }
  extern int __init sev_es_efi_map_ghcbs(pgd_t *pgd);
+extern enum es_result __sev_es_ghcb_hv_call(struct ghcb *ghcb,
+                                           struct es_em_ctxt *ctxt,
+                                           u64 exit_code, u64 exit_info_1,
+                                           u64 exit_info_2);
  #else
  static inline void sev_es_ist_enter(struct pt_regs *regs) { }
  static inline void sev_es_ist_exit(void) { }
  static inline int sev_es_setup_ap_jump_table(struct real_mode_header 
*rmh) { return 0; }
  static inline void sev_es_nmi_complete(void) { }
  static inline int sev_es_efi_map_ghcbs(pgd_t *pgd) { return 0; }
+static inline enum es_result
+__sev_es_ghcb_hv_call(struct ghcb *ghcb,
+                     u64 exit_code, u64 exit_info_1,
+                     u64 exit_info_2)
+{
+       return ES_VMM_ERROR;
+}
  #endif

  #endif
diff --git a/arch/x86/kernel/sev-shared.c b/arch/x86/kernel/sev-shared.c
index ea9abd69237e..08c97cb057fa 100644
--- a/arch/x86/kernel/sev-shared.c
+++ b/arch/x86/kernel/sev-shared.c
@@ -124,10 +124,14 @@ static enum es_result verify_exception_info(struct 
ghcb *ghcb, struct es_em_ctxt
         return ES_VMM_ERROR;
  }

-static enum es_result sev_es_ghcb_hv_call(struct ghcb *ghcb,
-                                         struct es_em_ctxt *ctxt,
-                                         u64 exit_code, u64 exit_info_1,
-                                         u64 exit_info_2)
+/*
+ * __sev_es_ghcb_hv_call() is also used in the other platform code(e.g
+ * Hyper-V).
+ */
+enum es_result __sev_es_ghcb_hv_call(struct ghcb *ghcb,
+                                    struct es_em_ctxt *ctxt,
+                                    u64 exit_code, u64 exit_info_1,
+                                    u64 exit_info_2)
  {
         /* Fill in protocol and format specifiers */
         ghcb->protocol_version = GHCB_PROTOCOL_MAX;
@@ -137,12 +141,22 @@ static enum es_result sev_es_ghcb_hv_call(struct 
ghcb *ghcb,
         ghcb_set_sw_exit_info_1(ghcb, exit_info_1);
         ghcb_set_sw_exit_info_2(ghcb, exit_info_2);

-       sev_es_wr_ghcb_msr(__pa(ghcb));
         VMGEXIT();

         return verify_exception_info(ghcb, ctxt);
  }

+static enum es_result sev_es_ghcb_hv_call(struct ghcb *ghcb,
+                                         struct es_em_ctxt *ctxt,
+                                         u64 exit_code, u64 exit_info_1,
+                                         u64 exit_info_2)
+{
+       sev_es_wr_ghcb_msr(__pa(ghcb));
+
+       return __sev_es_ghcb_hv_call(ghcb, ctxt, exit_code, exit_info_1,
+                                    exit_info_2);
+}
+
  /*
   * Boot VC Handler - This is the first VC handler during boot, there 
is no GHCB
   * page yet, so it only supports the MSR based communication with the
(END)


Thanks.



  parent reply	other threads:[~2021-10-13 14:24 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-06  6:36 [PATCH V7 0/9] x86/Hyper-V: Add Hyper-V Isolation VM support(First part) Tianyu Lan
2021-10-06  6:36 ` [PATCH V7 1/9] x86/hyperv: Initialize GHCB page in Isolation VM Tianyu Lan
2021-10-06  6:36 ` [PATCH V7 2/9] x86/hyperv: Initialize shared memory boundary in the " Tianyu Lan
2021-10-06  6:36 ` [PATCH V7 3/9] x86/hyperv: Add new hvcall guest address host visibility support Tianyu Lan
2021-10-06  6:36 ` [PATCH V7 4/9] Drivers: hv: vmbus: Mark vmbus ring buffer visible to host in Isolation VM Tianyu Lan
2021-10-06  6:36 ` [PATCH V7 5/9] x86/sev-es: Expose __sev_es_ghcb_hv_call() to call ghcb hv call out of sev code Tianyu Lan
2021-10-11 14:42   ` Tianyu Lan
2021-10-11 17:22     ` Borislav Petkov
2021-10-12 14:13       ` Tianyu Lan
2021-10-13 14:24       ` Tianyu Lan [this message]
2021-10-18 12:19         ` Tianyu Lan
2021-10-19 13:57           ` Borislav Petkov
2021-10-20  6:23           ` [PATCH] " Tianyu Lan
2021-10-20  9:59             ` Borislav Petkov
2021-10-20 12:39               ` Tianyu Lan
2021-10-20 13:39                 ` Borislav Petkov
2021-10-20 13:56                   ` Tom Lendacky
2021-10-20 14:23                     ` Tianyu Lan
2021-10-20 14:39                       ` Borislav Petkov
2021-10-20 15:09                         ` Tianyu Lan
2021-10-20 16:24                           ` Borislav Petkov
2021-10-21 15:42                             ` Tianyu Lan
2021-10-06  6:36 ` [PATCH V7 6/9] x86/hyperv: Add Write/Read MSR registers via ghcb page Tianyu Lan
2021-10-06  6:36 ` [PATCH V7 7/9] x86/hyperv: Add ghcb hvcall support for SNP VM Tianyu Lan
2021-10-06  6:36 ` [PATCH V7 8/9] Drivers: hv: vmbus: Add SNP support for VMbus channel initiate message Tianyu Lan
2021-10-06  6:36 ` [PATCH V7 9/9] Drivers: hv : vmbus: Initialize VMbus ring buffer for Isolation VM Tianyu Lan

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=5a0b9de8-e133-c17b-bc0d-93bfb593c48f@gmail.com \
    --to=ltykernel@gmail.com \
    --cc=Hikys@microsoft.com \
    --cc=Tianyu.Lan@microsoft.com \
    --cc=akpm@linux-foundation.org \
    --cc=aneesh.kumar@linux.ibm.com \
    --cc=arnd@arndb.de \
    --cc=bp@alien8.de \
    --cc=brijesh.singh@amd.com \
    --cc=dave.hansen@intel.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=davem@davemloft.net \
    --cc=decui@microsoft.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=haiyangz@microsoft.com \
    --cc=hannes@cmpxchg.org \
    --cc=hch@lst.de \
    --cc=hpa@zytor.com \
    --cc=joro@8bytes.org \
    --cc=jroedel@suse.de \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=konrad.wilk@oracle.com \
    --cc=kuba@kernel.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=michael.h.kelley@microsoft.com \
    --cc=mingo@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=parri.andrea@gmail.com \
    --cc=peterz@infradead.org \
    --cc=pgonda@google.com \
    --cc=rientjes@google.com \
    --cc=robin.murphy@arm.com \
    --cc=rppt@kernel.org \
    --cc=saravanand@fb.com \
    --cc=sthemmin@microsoft.com \
    --cc=tglx@linutronix.de \
    --cc=thomas.lendacky@amd.com \
    --cc=tj@kernel.org \
    --cc=vkuznets@redhat.com \
    --cc=wei.liu@kernel.org \
    --cc=x86@kernel.org \
    --subject='Re: [PATCH V7 5/9] x86/sev-es: Expose __sev_es_ghcb_hv_call() to call ghcb hv call out of sev code' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).