Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp945303pxb; Fri, 22 Jan 2021 03:21:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJwMBSfgp7nH0217iY+nU5dMJBB404m7fW1xIOxKNvHBzGuktYRlFtIP6+KRIKpXuHrjVW52 X-Received: by 2002:aa7:d88e:: with SMTP id u14mr2747888edq.72.1611314473340; Fri, 22 Jan 2021 03:21:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611314473; cv=none; d=google.com; s=arc-20160816; b=hjMWrp2I4Zxwq/vwDqD/sScTvxeLWe9NofJPXvZyWNdeAB34RWI/ne0nSwxpHDHhCC 0WHOrJHH53x1U+FMtuBWGAHcueguVAJyjLP4Igfeah9STOCMAwSKAE9kkhUXuwspf4Lj ioeDwEw+2sLmq00y5VV1SmrXCcluz0juomDG3zY3oteMJq3G6bXTIcgtHSyNzeWxxsTW FhIQU5TFjWYh5jvkiAc8eBfedX6qxCe9hAqwr4klWFbLI1qIjDrpNdwxKIdPYs6kuHbA HIosHw+MsKpybMLIjRk2MdyxCMGGK/phd9baRvVc3ZImgj9lzTT3XX/uET69geU2/WsA 5q9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :ironport-sdr:ironport-sdr; bh=vr0S5pm0HmHmKeb8mW0mxLFZbAk99RkbEqFCL+w9IlA=; b=VAy4CXUV9jfGuk9cmGU/jVH/ba47rssyII85qQg+JMw9XRS8p86SGG56hNqniUM1zw CNsCKxx9DhhTJecsFmQj44hdUcLcVv/HO8IZOZtZ/IXiRlrASo2yNyA2cWBXXR/7oUrm xaeRwo9Sa9nnpFoc8PfdYJk5PDRmkXlH3Dh1WLteaficPUCNfGQU5ETzXTOfixFEFNed OtfBYgvGsjODYO5253vedQMBmCafhBqCjbMnyde6GOLY8NnWjKxl4OQbvNcF2B3yyNJM yGvmPDRckuyaP6gfv5tIo7zQm3+ZfRv4Rjo3slvCIk3YzDETxEF0BU9bfl3sLt6aigZP uduQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d15si787291edx.394.2021.01.22.03.20.49; Fri, 22 Jan 2021 03:21:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728094AbhAVLSf (ORCPT + 99 others); Fri, 22 Jan 2021 06:18:35 -0500 Received: from mga06.intel.com ([134.134.136.31]:25447 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727641AbhAVLCy (ORCPT ); Fri, 22 Jan 2021 06:02:54 -0500 IronPort-SDR: cUNzSB7eZumm/J5Bg2ohjyYIpLzvGrLmnSbHOTytNMKh2BCPKmB8vC+c1YYDQE44H//WXkTAAQ yzfapLUIZT1g== X-IronPort-AV: E=McAfee;i="6000,8403,9871"; a="240973081" X-IronPort-AV: E=Sophos;i="5.79,366,1602572400"; d="scan'208";a="240973081" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jan 2021 03:01:55 -0800 IronPort-SDR: wABItAB87uKzdf5S6tm7jSvLrMm5BTlo5f34yD6zsuo3yQZatlCwFTRiPZW4FAXBnR8Bi8XySh uwMoL0gqEROw== X-IronPort-AV: E=Sophos;i="5.79,366,1602572400"; d="scan'208";a="502677079" Received: from shsi6026.sh.intel.com (HELO localhost) ([10.239.147.88]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jan 2021 03:01:50 -0800 From: shuo.a.liu@intel.com To: linux-kernel@vger.kernel.org, x86@kernel.org Cc: Greg Kroah-Hartman , "H . Peter Anvin" , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Yu Wang , Reinette Chatre , Shuo Liu , Yakui Zhao , Nick Desaulniers , Borislav Petkov , Dave Hansen , Sean Christopherson , Dan Williams , Fengwei Yin , Zhi Wang , Zhenyu Wang , Arvind Sankar , Peter Zijlstra , Segher Boessenkool Subject: [PATCH v8 04/18] x86/acrn: Introduce hypercall interfaces Date: Fri, 22 Jan 2021 19:01:08 +0800 Message-Id: <20210122110122.45800-5-shuo.a.liu@intel.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20210122110122.45800-1-shuo.a.liu@intel.com> References: <20210122110122.45800-1-shuo.a.liu@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Shuo Liu The Service VM communicates with the hypervisor via conventional hypercalls. VMCALL instruction is used to make the hypercalls. ACRN hypercall ABI: * Hypercall number is in R8 register. * Up to 2 parameters are in RDI and RSI registers. * Return value is in RAX register. Introduce the ACRN hypercall interfaces. Because GCC doesn't support R8 register as direct register constraints, use supported constraint as input with a explicit MOV to R8 in beginning of asm. Originally-by: Yakui Zhao Signed-off-by: Shuo Liu Reviewed-by: Reinette Chatre Reviewed-by: Nick Desaulniers Acked-by: Borislav Petkov Cc: Dave Hansen Cc: Sean Christopherson Cc: Dan Williams Cc: Fengwei Yin Cc: Zhi Wang Cc: Zhenyu Wang Cc: Yu Wang Cc: Reinette Chatre Cc: Greg Kroah-Hartman Cc: Borislav Petkov Cc: Arvind Sankar Cc: Peter Zijlstra Cc: Nick Desaulniers Cc: Segher Boessenkool --- 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 127f20672c5d..e003a01b7c67 100644 --- a/arch/x86/include/asm/acrn.h +++ b/arch/x86/include/asm/acrn.h @@ -21,4 +21,58 @@ static inline u32 acrn_cpuid_base(void) return 0; } +/* + * Hypercalls for ACRN + * + * - VMCALL instruction is used to implement ACRN hypercalls. + * - ACRN hypercall ABI: + * - Hypercall number is passed in R8 register. + * - Up to 2 arguments are passed in RDI, RSI. + * - Return value will be placed in RAX. + * + * Because GCC doesn't support R8 register as direct register constraints, use + * supported constraint as input with a explicit MOV to R8 in beginning of asm. + */ +static inline long acrn_hypercall0(unsigned long hcall_id) +{ + long result; + + asm volatile("movl %1, %%r8d\n\t" + "vmcall\n\t" + : "=a" (result) + : "g" (hcall_id) + : "r8", "memory"); + + return result; +} + +static inline long acrn_hypercall1(unsigned long hcall_id, + unsigned long param1) +{ + long result; + + asm volatile("movl %1, %%r8d\n\t" + "vmcall\n\t" + : "=a" (result) + : "g" (hcall_id), "D" (param1) + : "r8", "memory"); + + return result; +} + +static inline long acrn_hypercall2(unsigned long hcall_id, + unsigned long param1, + unsigned long param2) +{ + long result; + + asm volatile("movl %1, %%r8d\n\t" + "vmcall\n\t" + : "=a" (result) + : "g" (hcall_id), "D" (param1), "S" (param2) + : "r8", "memory"); + + return result; +} + #endif /* _ASM_X86_ACRN_H */ -- 2.28.0