Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1738957yba; Thu, 25 Apr 2019 05:05:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqxclQSoYxAZaqTQKiILeC0yL3dCeYxMDVXs+IH87BWOSNQ343xnd8bX6/5D4Xp8jh1JyacX X-Received: by 2002:a17:902:a582:: with SMTP id az2mr39470968plb.315.1556193900224; Thu, 25 Apr 2019 05:05:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556193900; cv=none; d=google.com; s=arc-20160816; b=GAqMeHDZ8VUn268Bb3Hih4uil0smTxZXkE5gzNKjKyRysbcsNA/ECl0YkKJCUfhT7r 5fZzk4Fsh2OS/0l7m+niCKSnUVtb7Zn94TXXTbLOSDro6bSMWJMp/RIOivbpQugmUKow i0fdkWobVxeKjgdF5aNuFSQU80Gdn2dQxBZjE4sKe0xt8ZIQ8Wae4+eoOyybZNcyxdWa TbZKCu5QLPFl+YBWfdechPDcCRuozk5GLdr8T8sQpXhWYt0vwsoS29tphm/FdbUnSulG IvuDlvkDg7kiIFYzOYKJ95lcQUzYpb04+uGW7TYFncEMI3XuqFiN0CMnBbj6K2KO00E+ RTsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Zlv0/XFgcNR3wgBaFoDB30QJMdFwjhVp47g/tZDSg5M=; b=pKxzDSJ4iCsDnK5ZANb5b4xSK7xZ8GDuf/p5Z/TvrftxJdXBJqas9Yn2MxZaizCbWH 1aiBnpYkvTUNjKYpcKv7Qqg4U854lC69LLkVzSz6DoD/5InxPMraBsyhaE3LnE7mZCoG //Cf9nUajaYGpjSaH5Z3YE7urzQ0EYpx1ITU9LX/uIcJzCvAYIEO+IU/YYcpifv5NSzQ DHywJq1napetxff3fCrKg+hWUxsiKvRfsEcoWyoycgtyLLSmPgYdSgeFDMXEK4gzDDQf XdwwuCp1RIRg/0CTd+2O/9gyvTP7MUDc64ejOGcWim1ZNikTadjEseQ1oL6kizVy8pMI onIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=G3J5Y0gk; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d69si20337899pgc.451.2019.04.25.05.04.41; Thu, 25 Apr 2019 05:05:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=G3J5Y0gk; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388925AbfDYHHS (ORCPT + 99 others); Thu, 25 Apr 2019 03:07:18 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:36170 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388847AbfDYHHR (ORCPT ); Thu, 25 Apr 2019 03:07:17 -0400 Received: by mail-wr1-f66.google.com with SMTP id b1so17379003wru.3 for ; Thu, 25 Apr 2019 00:07:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=Zlv0/XFgcNR3wgBaFoDB30QJMdFwjhVp47g/tZDSg5M=; b=G3J5Y0gk5MmdRKkrmXoZK3Konx19l+YRESEhqmJXnSpz9sG2kM6PsI/WsurVsizWSF 7MaMj8iSl4sOmoPdwB6oNVsf2fe39y8GGH6HiWiXbuEVWg7q+eK6mchKhHfCBkdOQ94i 9veMNbVBXa+35MkR18nTL99QAOtEwgTmBxcJAuM/rfJ/ga0vHjwOKVc2u4f4L1E43pRc ncHsSRRWmu5PWpRvF6Jz3iuqoDOLE//D/9/chFOCymCc41NEwyxNBSc4ps9o920KJeSm gX4vVKO/ylY0rFYPcQS2N/i1hCVFg8KlG5R4AGFWr5Ef0PQbTPsnovAXxcZmXqKfkaqp lHJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=Zlv0/XFgcNR3wgBaFoDB30QJMdFwjhVp47g/tZDSg5M=; b=Ouy+JN+P5ck+wKp9VhFNnHXTTHK8BE6McuT2NGUpPIe2IdE9+/YQebXx3o02bNQL2W PGYlZ/xgqEWTGOtfWKw8hUpS2Sj504VamYwju2DdZuwIoDgHYizPla5JjkHxspmKpWiX 5b7U3dUiVvfcQgxUNcdIO/IjH+1QAjLKQS9kDHUApRdxAGxaP6mCJ/Kn4MaqM28z3o/w 80+LN7KjRNIkEzY2z4SK/EMiqoK/KKTJxQyCkZtZMDlQjgh4YdMF5poFRref/DJr4G3D M2ac3frBB96bv2ewkk7X/xRhKZKd/hi2QYk0iHHekfZQQRk4dKfEmau8/Lu2xu5Y2qzx llAw== X-Gm-Message-State: APjAAAWcIENQmxaiOD6FgDM+DIkTtHHsGy5T5pFw429d0D5NTnDO3V63 wZdrey9k/ylw5yZ+tKVhInc= X-Received: by 2002:a5d:4acc:: with SMTP id y12mr3940992wrs.234.1556176035985; Thu, 25 Apr 2019 00:07:15 -0700 (PDT) Received: from gmail.com (2E8B0CD5.catv.pool.telekom.hu. [46.139.12.213]) by smtp.gmail.com with ESMTPSA id c63sm4316836wma.29.2019.04.25.00.07.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 25 Apr 2019 00:07:15 -0700 (PDT) Date: Thu, 25 Apr 2019 09:07:13 +0200 From: Ingo Molnar To: Zhao Yakui Cc: linux-kernel@vger.kernel.org, x86@kernel.org, tglx@linutronix.de, bp@alien8.de, Jason Chen CJ Subject: Re: [RFC PATCH v5 4/4] x86/acrn: Add hypercall for ACRN guest Message-ID: <20190425070712.GA57256@gmail.com> References: <1556067260-9128-1-git-send-email-yakui.zhao@intel.com> <1556067260-9128-5-git-send-email-yakui.zhao@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1556067260-9128-5-git-send-email-yakui.zhao@intel.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Zhao Yakui wrote: > 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 the guest operating system. > > So add the hypercall so that ACRN guest can communicate with the > low-level ACRN hypervisor. It is implemented with the VMCALL instruction. > > Co-developed-by: Jason Chen CJ > Signed-off-by: Jason Chen CJ > Signed-off-by: Zhao Yakui > --- > V1->V2: Refine the comments for the function of acrn_hypercall0/1/2 > v2->v3: Use the "vmcall" mnemonic to replace hard-code byte definition > v4->v5: Use _ASM_X86_ACRN_HYPERCALL_H instead of _ASM_X86_ACRNHYPERCALL_H to > align the header file of acrn_hypercall.h > Use the "VMCALL" mnemonic in comment/commit log. > Uppercase r8/rdi/rsi/rax for hypercall parameter registers in comment. > --- > arch/x86/include/asm/acrn_hypercall.h | 82 +++++++++++++++++++++++++++++++++++ > 1 file changed, 82 insertions(+) > create mode 100644 arch/x86/include/asm/acrn_hypercall.h > > diff --git a/arch/x86/include/asm/acrn_hypercall.h b/arch/x86/include/asm/acrn_hypercall.h > new file mode 100644 > index 0000000..3594436 > --- /dev/null > +++ b/arch/x86/include/asm/acrn_hypercall.h > @@ -0,0 +1,82 @@ > +/* SPDX-License-Identifier: GPL-2.0 */ > + > +#ifndef _ASM_X86_ACRN_HYPERCALL_H > +#define _ASM_X86_ACRN_HYPERCALL_H > + > +#include > + > +#ifdef CONFIG_ACRN_GUEST > + > +/* > + * 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) > +{ > + register unsigned long r8 asm("r8") = hcall_id; > + register long result asm("rax"); > + > + /* the hypercall is implemented with the VMCALL instruction. > + * asm indicates that inline assembler instruction is used. > + * volatile qualifier is added to avoid that it is dropped > + * because of compiler optimization. > + */ Non-standard comment style. asm statements are volatile by default I believe. I.e. the second and third sentences are partly obvious, superfluous and bogus. > + asm volatile("vmcall" > + : "=r"(result) > + : "r"(r8)); > + > + return result; > +} > + > +static inline long acrn_hypercall1(unsigned long hcall_id, > + unsigned long param1) > +{ > + register unsigned long r8 asm("r8") = hcall_id; > + register long result asm("rax"); > + > + asm volatile("vmcall" > + : "=r"(result) > + : "D"(param1), "r"(r8)); Why are register variables used? Doesn't GCC figure it out correctly by default? > +static inline long acrn_hypercall2(unsigned long hcall_id, > + unsigned long param1, > + unsigned long param2) > +{ > + register unsigned long r8 asm("r8") = hcall_id; > + register long result asm("rax"); > + > + asm volatile("vmcall" > + : "=r"(result) > + : "D"(param1), "S"(param2), "r"(r8)); Ditto. Thanks, Ingo