driverdev-devel.linuxdriverproject.org archive mirror
 help / color / mirror / Atom feed
From: yakui.zhao@intel.com (Zhao Yakui)
Subject: [RFC PATCH 03/15] x86/acrn: Add hypercall for ACRN guest
Date: Fri, 16 Aug 2019 10:25:44 +0800	[thread overview]
Message-ID: <1565922356-4488-4-git-send-email-yakui.zhao@intel.com> (raw)
In-Reply-To: <1565922356-4488-1-git-send-email-yakui.zhao@intel.com>

When ACRN hypervisor is detected, the hypercall is needed so that the
ACRN guest can query/config some settings. For example: it can be used
to query the resources in hypervisor and manage the CPU/memory/device/
interrupt for guest operating system.

On x86 it is implemented with the VMCALL instruction.

Co-developed-by: Jason Chen CJ <jason.cj.chen at intel.com>
Signed-off-by: Jason Chen CJ <jason.cj.chen at intel.com>
Signed-off-by: Zhao Yakui <yakui.zhao at intel.com>
---
 arch/x86/include/asm/acrn.h | 54 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 54 insertions(+)

diff --git a/arch/x86/include/asm/acrn.h b/arch/x86/include/asm/acrn.h
index 857e6244..ab97c3d 100644
--- a/arch/x86/include/asm/acrn.h
+++ b/arch/x86/include/asm/acrn.h
@@ -11,4 +11,58 @@ extern void acrn_hv_vector_handler(struct pt_regs *regs);
 
 extern void acrn_setup_intr_irq(void (*handler)(void));
 extern void acrn_remove_intr_irq(void);
+
+/*
+ * Hypercalls for ACRN guest
+ *
+ * Hypercall number is passed in R8 register.
+ * Up to 2 arguments are passed in RDI, RSI.
+ * Return value will be placed in RAX.
+ */
+static inline long acrn_hypercall0(unsigned long hcall_id)
+{
+	long result;
+
+	/* the hypercall is implemented with the VMCALL instruction.
+	 * volatile qualifier is added to avoid that it is dropped
+	 * because of compiler optimization.
+	 */
+	asm volatile("movq %[hcall_id], %%r8\n\t"
+		     "vmcall\n\t"
+		     : "=a" (result)
+		     : [hcall_id] "g" (hcall_id)
+		     : "r8");
+
+	return result;
+}
+
+static inline long acrn_hypercall1(unsigned long hcall_id,
+				   unsigned long param1)
+{
+	long result;
+
+	asm volatile("movq %[hcall_id], %%r8\n\t"
+		     "vmcall\n\t"
+		     : "=a" (result)
+		     : [hcall_id] "g" (hcall_id), "D" (param1)
+		     : "r8");
+
+	return result;
+}
+
+static inline long acrn_hypercall2(unsigned long hcall_id,
+				   unsigned long param1,
+				   unsigned long param2)
+{
+	long result;
+
+	asm volatile("movq %[hcall_id], %%r8\n\t"
+		     "vmcall\n\t"
+		     : "=a" (result)
+		     : [hcall_id] "g" (hcall_id), "D" (param1), "S" (param2)
+		     : "r8");
+
+	return result;
+}
+
 #endif /* _ASM_X86_ACRN_H */
-- 
2.7.4

  parent reply	other threads:[~2019-08-16  2:25 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-16  2:25 [RFC PATCH 00/15] acrn: add the ACRN driver module Zhao Yakui
2019-08-16  2:25 ` [RFC PATCH 01/15] x86/acrn: Report X2APIC for ACRN guest Zhao Yakui
2019-08-16  2:25 ` [RFC PATCH 02/15] x86/acrn: Add two APIs to add/remove driver-specific upcall ISR handler Zhao Yakui
2019-08-16  2:25 ` Zhao Yakui [this message]
2019-08-16  2:25 ` [RFC PATCH 04/15] drivers/acrn: add the basic framework of acrn char device driver Zhao Yakui
2019-08-16  7:05   ` Greg KH
2019-08-19  4:02     ` Zhao, Yakui
2019-08-19  5:26       ` Greg KH
2019-08-16 11:28   ` Dan Carpenter
2019-08-16  2:25 ` [RFC PATCH 05/15] drivers/acrn: add driver-specific hypercall for ACRN_HSM Zhao Yakui
2019-08-16  2:25 ` [RFC PATCH 06/15] drivers/acrn: add the support of querying ACRN api version Zhao Yakui
2019-08-16  2:25 ` [RFC PATCH 07/15] drivers/acrn: add acrn vm/vcpu management for ACRN_HSM char device Zhao Yakui
2019-08-16  2:25 ` [RFC PATCH 08/15] drivers/acrn: add VM memory management for ACRN " Zhao Yakui
2019-08-16 12:58   ` Dan Carpenter
2019-08-19  5:32     ` Zhao, Yakui
2019-08-19  7:39       ` Dan Carpenter
2019-08-19  7:46         ` Borislav Petkov
2019-08-20  2:25         ` Zhao, Yakui
2019-08-16  2:25 ` [RFC PATCH 09/15] drivers/acrn: add passthrough device support Zhao Yakui
2019-08-16 13:05   ` Dan Carpenter
2019-09-02  0:18     ` Zhao, Yakui
2019-08-16  2:25 ` [RFC PATCH 10/15] drivers/acrn: add interrupt injection support Zhao Yakui
2019-08-16 13:12   ` Dan Carpenter
2019-08-19  4:59     ` Zhao, Yakui
2019-08-16  2:25 ` [RFC PATCH 11/15] drivers/acrn: add the support of handling emulated ioreq Zhao Yakui
2019-08-16 13:39   ` Dan Carpenter
2019-08-19  4:54     ` Zhao, Yakui
2019-08-16  2:25 ` [RFC PATCH 12/15] drivers/acrn: add driver-specific IRQ handle to dispatch IO_REQ request Zhao Yakui
2019-08-16  2:25 ` [RFC PATCH 13/15] drivers/acrn: add service to obtain Power data transition Zhao Yakui
2019-08-16  2:25 ` [RFC PATCH 14/15] drivers/acrn: add the support of irqfd and eventfd Zhao Yakui
2019-08-16  2:25 ` [RFC PATCH 15/15] drivers/acrn: add the support of offline SOS cpu Zhao Yakui
2019-08-19 10:34   ` Dan Carpenter
2019-08-20  2:23     ` Zhao, Yakui
2019-08-16  6:39 ` [RFC PATCH 00/15] acrn: add the ACRN driver module Borislav Petkov
2019-08-16  7:03   ` Greg KH
2019-08-19  2:39     ` Zhao, Yakui
2019-08-19  5:25       ` Greg KH
2019-08-19  1:44   ` Zhao, Yakui
2019-08-19  5:25     ` Greg KH
2019-08-19  5:39       ` Zhao, Yakui
2019-08-19  6:18     ` Borislav Petkov

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=1565922356-4488-4-git-send-email-yakui.zhao@intel.com \
    --to=yakui.zhao@intel.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;
as well as URLs for NNTP newsgroup(s).