From nobody Mon Feb 9 08:10:29 2026 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1578067805; cv=none; d=zohomail.com; s=zohoarc; b=HnU6INUhCOx3KCRgLrakSLJ7x9qvzYRyETiVXetG/E8z4FLDhsaU0PrcjD/cpjJnIh+I9+xvYNoFlscafp4tEDSj3xmTuxCPpM+MYJFXbbuTJ8/c4tbf25ZzRU6agLFBq0ocywQ1HUPYTnbXQhhlF6jMJ6i5mwbCygF+zS+ePZw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578067805; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=8bWfZYm26NJgdZnCGavGpNfHTJUHVi3I3O4VWmPI+RU=; b=G2wobXrA6Xt8eDBOzjqgec+myPFf3cvDKeYEZT2SD/9iFaMrM2O0v90JaljZ437FNTOhnDsChhlK9TX8V3mSAor6RlThQ5hn8UkxppdcTNnjOKNKnulbPz/PEFYGQWJeGmin8zjK4GYhDcDPzWHPjU2bMECFrwlLxhdKcwSeupg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1578067805072885.0073062770612; Fri, 3 Jan 2020 08:10:05 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1inPVr-0005Wl-OM; Fri, 03 Jan 2020 16:09:23 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1inPVq-0005WC-LG for xen-devel@lists.xenproject.org; Fri, 03 Jan 2020 16:09:22 +0000 Received: from mail-wm1-x343.google.com (unknown [2a00:1450:4864:20::343]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 5b7ce030-2e43-11ea-a914-bc764e2007e4; Fri, 03 Jan 2020 16:09:02 +0000 (UTC) Received: by mail-wm1-x343.google.com with SMTP id p17so9045937wma.1 for ; Fri, 03 Jan 2020 08:09:02 -0800 (PST) Received: from localhost.localdomain (38.163.200.146.dyn.plus.net. [146.200.163.38]) by smtp.gmail.com with ESMTPSA id z11sm61000235wrt.82.2020.01.03.08.09.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Jan 2020 08:09:01 -0800 (PST) X-Inumbo-ID: 5b7ce030-2e43-11ea-a914-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RUfnlZlwFuHWpde6sRvjxDfadwPtw2oJdC3k1kQv/fc=; b=tUbHi0DpRaYWZ3lxVGLFpcaSMEAc4PBWX+py0GYk/V1mca4StnwqTGD2Z8bGwK0gHF TP0q8tHZ1laPI1bmR1NaekYETPtGvI/oDtHmd9u0I/nTOFwudnzDUBjQ2rSAuQyfEH0X EbD4j5U0WdVJ1bOFO1IUN0bYFvMBgO0yWjWyFtadcVgF06PxsXKCxX4FrDmsmm35YuOT c/jT/Ups37cbNsCJNfZaBFqzPK5Y2tzG08cGxkiqLb1wQXLrJTF4eZ07XEhlIEou0ziz Rgu9RM3A8Ran/Goz8ne0+v3qZ1I4AmDZRM5qLX3qlx9e3RJhxNRyYS8+FktP4OMVES2t ASzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=RUfnlZlwFuHWpde6sRvjxDfadwPtw2oJdC3k1kQv/fc=; b=YLXS77vRzpJfoJ39+ceA06ITZhwkFdpk0lh+8JxadXFNy7gF5kqnQFtzqOyaolWsH+ Fp7eZtRcIz4cfnhXD02E58G4Ixun5rC8cQ2iwSO29XNCwR30jJ/2xO+BZKMAwkAssLCR jhuVk65fo2v/HPj/PUGKcVyp4cqnGUsf5YUuZ7aomUEvdW05D7CNMUtKMuoAJNAPGMSy 4ZIaDgXjqSPgcoonY7Fvr9Og5hYo5d16nWfpn81qTNT6wfKB5k0MsDKNS53p02oab+XD OlM/rEDMau2jBAaP9xaxMo0qlR4yAx4LWCj87kdgLgS2Dt/P8tME7Q2K7/O/qKVMVw+X dwEg== X-Gm-Message-State: APjAAAW5YAST86MrsxCxHquqR8BPf88pH8eicJp7KX8zYGsCs29GjPgR 7ANcS13juMadq697VC0vYbqLLOKrMg7YWA== X-Google-Smtp-Source: APXvYqxOVtQLjKCVbZacFTlx6nzgZtiAYBluSMVrihTmit9tKrvWHb/2hHm9MhvYZCCKCRH5ezfz1A== X-Received: by 2002:a7b:cf12:: with SMTP id l18mr21771776wmg.66.1578067741581; Fri, 03 Jan 2020 08:09:01 -0800 (PST) From: Wei Liu X-Google-Original-From: Wei Liu To: Xen Development List Date: Fri, 3 Jan 2020 16:08:22 +0000 Message-Id: <20200103160825.19377-6-liuwe@microsoft.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200103160825.19377-1-liuwe@microsoft.com> References: <20200103160825.19377-1-liuwe@microsoft.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v2 5/8] x86/hyperv: provide Hyper-V hypercall functions X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Wei Liu , Wei Liu , Paul Durrant , Andrew Cooper , Michael Kelley , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) These functions will be used later to make hypercalls to Hyper-V. I couldn't find reference in TLFS that Hyper-V clobbers flags and r9-r11, but Linux's commit message says it does. Err on the safe side. Signed-off-by: Wei Liu --- v2: 1. Use direct call --- xen/include/asm-x86/guest/hyperv-hypercall.h | 95 ++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 xen/include/asm-x86/guest/hyperv-hypercall.h diff --git a/xen/include/asm-x86/guest/hyperv-hypercall.h b/xen/include/asm= -x86/guest/hyperv-hypercall.h new file mode 100644 index 0000000000..928d85ae7e --- /dev/null +++ b/xen/include/asm-x86/guest/hyperv-hypercall.h @@ -0,0 +1,95 @@ +/*************************************************************************= ***** + * asm-x86/guest/hyperv-hypercall.h + * + * This program is free software; you can redistribute it and/or + * modify it under the terms and conditions of the GNU General Public + * License, version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; If not, see . + * + * Copyright (c) 2019 Microsoft. + */ + +#ifndef __X86_HYPERV_HYPERCALL_H__ +#define __X86_HYPERV_HYPERCALL_H__ + +#include + +#include +#include +#include + +static inline uint64_t hv_do_hypercall(uint64_t control, paddr_t input, pa= ddr_t output) +{ + uint64_t status; + + asm volatile ("mov %[output], %%r8\n" + "call hv_hypercall_page" + : "=3Da" (status), "+c" (control), + "+d" (input) ASM_CALL_CONSTRAINT + : [output] "rm" (output) + : "cc", "memory", "r8", "r9", "r10", "r11"); + + return status; +} + +static inline uint64_t hv_do_fast_hypercall(uint16_t code, + uint64_t input1, uint64_t inpu= t2) +{ + uint64_t status; + uint64_t control =3D (uint64_t)code | HV_HYPERCALL_FAST_BIT; + + asm volatile ("mov %[input2], %%r8\n" + "call hv_hypercall_page" + : "=3Da" (status), "+c" (control), + "+d" (input1) ASM_CALL_CONSTRAINT + : [input2] "rm" (input2) + : "cc", "r8", "r9", "r10", "r11"); + + return status; +} + +static inline uint64_t hv_do_rep_hypercall(uint16_t code, uint16_t rep_cou= nt, + uint16_t varhead_size, + paddr_t input, paddr_t output) +{ + uint64_t control =3D code; + uint64_t status; + uint16_t rep_comp; + + control |=3D (uint64_t)varhead_size << HV_HYPERCALL_VARHEAD_OFFSET; + control |=3D (uint64_t)rep_count << HV_HYPERCALL_REP_COMP_OFFSET; + + do { + status =3D hv_do_hypercall(control, input, output); + if ( (status & HV_HYPERCALL_RESULT_MASK) !=3D HV_STATUS_SUCCESS ) + break; + + rep_comp =3D (status & HV_HYPERCALL_REP_COMP_MASK) >> + HV_HYPERCALL_REP_COMP_OFFSET; + + control &=3D ~HV_HYPERCALL_REP_START_MASK; + control |=3D (uint64_t)rep_comp << HV_HYPERCALL_REP_COMP_OFFSET; + + } while ( rep_comp < rep_count ); + + return status; +} + +#endif /* __X86_HYPERV_HYPERCALL_H__ */ + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ --=20 2.20.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel