Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3073228pxb; Sat, 6 Feb 2021 19:16:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJygjFywd61fuY8stdjG4Kuw0xHUJAXci2u6FsXiZzb1oQnhkrg3I8YNPFc19UK/T+2E2Iog X-Received: by 2002:a17:906:f195:: with SMTP id gs21mr11049210ejb.225.1612667782322; Sat, 06 Feb 2021 19:16:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612667782; cv=none; d=google.com; s=arc-20160816; b=t79UQx60kIl6Ap0dFYtp7Zmf1qxuj/wdPY3wFUpfR9QCeBlxvuls2QtqYJ76pt/nYO eDoFs/ftkh7DdSHEh60QfhuFoWG0re2k+Bogdt0yiG+v517hwJr/mzx/yL72G5PpFd2z PkXueRUD4FSIbhOTp4oq1dYM9W/Fu+jvP0DzkGfjqfquKYyvDuwBaoERiE2IeddWIMyc m8Ckr3zvgLrM+JI1nXIl4Lj3jpFXPTjsSyklw5qIXQ2BNJhpVg3EKQKYnU89/qck6gOw 4bO7FRlaHim+/9GWMIIEoM4XdXoXuCEy66OwVrM5IN69aNg2Yw+3vBsB/5ZMx6ecfsGy B1tw== 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=TupC0CRvE0E7g/bG2fB0gNU+tgFE1dtajJeG5IfGbmVoJzTrLnZqCSQxFhvwKyhHdU lumTJYBLWXozooPDqp5BzkSDaeX0ExE5OATlXqv59BNCUTjd14Wty40kg6YeUf2KxF/a YR/DM9xS3AO/oygdgOJEfV/GPoPAEmvuf0+lEly270f+Qm778A+L1To5XzNDgwL3oZz+ IqveMd5Zg1wnVcKAcABTWE/1t8E+aznnj/eSfhbOtf8oCtYZH4GkICv7OmOs41HdcKeU Qxz423QdktskRt9BF/HUKmT01ARpuXbp6kOjQNUSxyr+BOaHPaQUyrgFQdIXy3fGnuw2 UvIg== 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 22si7502002ejc.181.2021.02.06.19.15.59; Sat, 06 Feb 2021 19:16:22 -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 S229771AbhBGDMP (ORCPT + 99 others); Sat, 6 Feb 2021 22:12:15 -0500 Received: from mga17.intel.com ([192.55.52.151]:9985 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229636AbhBGDL4 (ORCPT ); Sat, 6 Feb 2021 22:11:56 -0500 IronPort-SDR: pVmOP7opvmo4cavU+HmVQKlF25tlDeGN+0OeNIxIZzZQxFHuvwv0oORHg572D+Ad/D83N0FBp4 ESIkHhfGWvgA== X-IronPort-AV: E=McAfee;i="6000,8403,9887"; a="161331940" X-IronPort-AV: E=Sophos;i="5.81,158,1610438400"; d="scan'208";a="161331940" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Feb 2021 19:11:16 -0800 IronPort-SDR: tOeBzsBYo3XBvF5jJdFbV4b+Dt8UloADWqom242vdVgv2I6LYB16UbzLxyQnYvc5rzBOXEXxDs qJjxb2tey3Gg== X-IronPort-AV: E=Sophos;i="5.81,158,1610438400"; d="scan'208";a="584618099" Received: from shsi6026.sh.intel.com (HELO localhost) ([10.239.147.88]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Feb 2021 19:11:11 -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 v9 04/18] x86/acrn: Introduce hypercall interfaces Date: Sun, 7 Feb 2021 11:10:26 +0800 Message-Id: <20210207031040.49576-5-shuo.a.liu@intel.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20210207031040.49576-1-shuo.a.liu@intel.com> References: <20210207031040.49576-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