From nobody Tue Apr 30 00:36:30 2024 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=1578242950; cv=none; d=zohomail.com; s=zohoarc; b=gqjwt0OXPldP3XjhVoF0PCSqlzbyPPV1kf/xj1BcvnJe+9ojIU4fyyIq2XC7RQiigg/srPfNObvQp37e2AS/UEZYbHgL42l3XWTEPZ7eN3aCSJXnaPTf6KOVH1FFCY5bBBFKouc07ur20F/hjR/q88Kf2NW0DiFO8vn84/202TA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578242950; 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=qdZbjgjuvHY8W+oILsJrPK/5lOiFI85+tjGS8v4SqfM=; b=OhXzQMuvJ9fx5UFbb2lefupI/8TAHvMEvjK1ASYaVv9CiWaAC0UoXKoEZamGIhAo+VA4qzSHmfeDJkwvIBQH73g7VFPhDHYPAAVc4XEZxoLoGG40zswkyBJHDMUtPN1Q8d4IVmQBlV3mMksJLmSdWSQzdL9a1inHVgeNX+Erlis= 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 1578242950073321.39283709607844; Sun, 5 Jan 2020 08:49:10 -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 1io94f-0003lK-AR; Sun, 05 Jan 2020 16:48:21 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1io94e-0003lE-GJ for xen-devel@lists.xenproject.org; Sun, 05 Jan 2020 16:48:20 +0000 Received: from mail-wr1-x443.google.com (unknown [2a00:1450:4864:20::443]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 2ad8ff7e-2fdb-11ea-88e7-bc764e2007e4; Sun, 05 Jan 2020 16:48:15 +0000 (UTC) Received: by mail-wr1-x443.google.com with SMTP id t2so47085503wrr.1 for ; Sun, 05 Jan 2020 08:48:15 -0800 (PST) Received: from localhost.localdomain (38.163.200.146.dyn.plus.net. [146.200.163.38]) by smtp.gmail.com with ESMTPSA id y139sm20834028wmd.24.2020.01.05.08.48.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 08:48:14 -0800 (PST) X-Inumbo-ID: 2ad8ff7e-2fdb-11ea-88e7-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=AeVdaCAPZTMCoRydrJF1kMnbXuo4DmKCUTwBKEx4Ftg=; b=r2DLRQlnqCJ7OG+Mer+waKGjvZSZCpgrzpLqRNHx1gEa4cCYhpLVd5NG0HeKiK0Sw9 voIZ1yQQxiplU5Bon+03bFsjCYg6SxNhWo8TsK4QYzyDpxYEDUHsW0HfZbRMQ5hbDgap Y0T+Yp5lW/v9wgT/7B1mkb/SKvcCS9L0fMf3s/RWTIS2EFsJYEZRWQi1B7ytAvbEiIn4 s1/ct04HglCk8qYtqVF4aqJ6TuQ0lB44tqRQy+RGHe0DH/K5eHQdQfUt1diy0hAedbaL udxhnPcaikQZASY7SLB9qhc2yJMUS8iwQBC1GJOkfoeSD1idI6+pkzIqKUXMt0cHxL61 EXMg== 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=AeVdaCAPZTMCoRydrJF1kMnbXuo4DmKCUTwBKEx4Ftg=; b=azwgb+/a6sHlm9sOszb8duBIGLyBPBP+zKzydACqSevQtO/YPsHBMdEpYGxLyEziT0 nHJzqRPUyaKhabz57+uqVYPhBbLQuo7swbFDDwsifNmxBLJTABn8iI0YwI7q+HjnLeyv cz6o48zf3LNbVoOoAM5DqZ4rooI7R9EhCsMib/uHrxr9GxALR1jWgqTkBesCvjD/GQNs WU+sdy18aZQkQ/V8Qde7Tz6zsGazoivAKK5a8jsi7rongiqrLfbWNZmiYAXPqo75J0sg anQ6wII7io2eAsZQeRDGojUJ8qSNtUGjUCv91sNFHEQP37ocSVmpDBiQLBdnJxXb+lXI 5eVw== X-Gm-Message-State: APjAAAXhABOuDn+OCEAGpUin/vPxCBMn1r6zagAf5yr934PttSJJMf5g gb2uQ4c9f8gDKsXDQKrJ+HMsmXn0tsk= X-Google-Smtp-Source: APXvYqxiumd4z+uBIL06RQRkKx6Fu8H8snAD5+UsfaXvVHj4Wp8rcpwPsWGxoTHD527Xsy9yOKTG/A== X-Received: by 2002:a05:6000:118d:: with SMTP id g13mr3845255wrx.141.1578242894685; Sun, 05 Jan 2020 08:48:14 -0800 (PST) From: Wei Liu X-Google-Original-From: Wei Liu To: Xen Development List Date: Sun, 5 Jan 2020 16:47:57 +0000 Message-Id: <20200105164801.26278-2-liuwe@microsoft.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200105164801.26278-1-liuwe@microsoft.com> References: <20200105164801.26278-1-liuwe@microsoft.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v3 1/5] x86/hyperv: setup hypercall page 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) Signed-off-by: Wei Liu --- v2: 1. Fix issue discovered by Michael 2. Use a statically allocated page as hypercall page --- xen/arch/x86/guest/hyperv/Makefile | 1 + xen/arch/x86/guest/hyperv/hypercall_page.S | 21 +++++++++++++++++ xen/arch/x86/guest/hyperv/hyperv.c | 27 +++++++++++++++++++--- 3 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 xen/arch/x86/guest/hyperv/hypercall_page.S diff --git a/xen/arch/x86/guest/hyperv/Makefile b/xen/arch/x86/guest/hyperv= /Makefile index 68170109a9..1a8887d2f4 100644 --- a/xen/arch/x86/guest/hyperv/Makefile +++ b/xen/arch/x86/guest/hyperv/Makefile @@ -1 +1,2 @@ +obj-y +=3D hypercall_page.o obj-y +=3D hyperv.o diff --git a/xen/arch/x86/guest/hyperv/hypercall_page.S b/xen/arch/x86/gues= t/hyperv/hypercall_page.S new file mode 100644 index 0000000000..6d6ab913be --- /dev/null +++ b/xen/arch/x86/guest/hyperv/hypercall_page.S @@ -0,0 +1,21 @@ +#include +#include + + .section ".text.page_aligned", "ax", @progbits + .p2align PAGE_SHIFT +GLOBAL(hv_hypercall_page) + /* Return -1 for "not yet ready" state */ + mov -1, %rax + ret +1: + /* Fill the rest with `ret` */ + .fill PAGE_SIZE - (1b - hv_hypercall_page), 1, 0xc3 + .type hv_hypercall_page, STT_OBJECT + .size hv_hypercall_page, PAGE_SIZE + +/* + * Local variables: + * tab-width: 8 + * indent-tabs-mode: nil + * End: + */ diff --git a/xen/arch/x86/guest/hyperv/hyperv.c b/xen/arch/x86/guest/hyperv= /hyperv.c index 8d38313d7a..381be2a68c 100644 --- a/xen/arch/x86/guest/hyperv/hyperv.c +++ b/xen/arch/x86/guest/hyperv/hyperv.c @@ -19,16 +19,16 @@ * Copyright (c) 2019 Microsoft. */ #include +#include =20 #include #include =20 struct ms_hyperv_info __read_mostly ms_hyperv; =20 -static const struct hypervisor_ops ops =3D { - .name =3D "Hyper-V", -}; +extern char hv_hypercall_page[]; =20 +static const struct hypervisor_ops ops; const struct hypervisor_ops *__init hyperv_probe(void) { uint32_t eax, ebx, ecx, edx; @@ -72,6 +72,27 @@ const struct hypervisor_ops *__init hyperv_probe(void) return &ops; } =20 +static void __init setup_hypercall_page(void) +{ + union hv_x64_msr_hypercall_contents hypercall_msr; + + rdmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64); + hypercall_msr.enable =3D 1; + hypercall_msr.guest_physical_address =3D + __pa(hv_hypercall_page) >> HV_HYP_PAGE_SHIFT; + wrmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64); +} + +static void __init setup(void) +{ + setup_hypercall_page(); +} + +static const struct hypervisor_ops ops =3D { + .name =3D "Hyper-V", + .setup =3D setup, +}; + /* * Local variables: * mode: C --=20 2.20.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Tue Apr 30 00:36:30 2024 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=1578242949; cv=none; d=zohomail.com; s=zohoarc; b=HoFSxssXYhU5a7ZJNW6krl/EF9jVn1kd7RSLtc9xyCOiBjsllYg5mUl1HMZghN7vWY/TV4ldohQ3Y4HOxkWZU7piH2fOAvHzgiXeRFalUO+EmEbPp+CScrivlmV4hSH/IaSAV4LvH9g5xGv/GjL0tS/rUx+Dpf1lfznkYiZUGZQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578242949; 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=fDz4D+87AvspJNQFKqueB8CgyMUnPmG5bWIzqqaYvf4=; b=ncBXXw+L+31+U5PVk9ZBUiOm6g/Hvq/jSro8stKN0TDUIAaSlIGP9i8c25k3eZu85oYNdGvb9qnZ1AIHux91yURkjNrLvEJA0DDgmSjoJNg5pPmtfTBf4ONqkpZK2nCX6H6fuxf4F1BIhE9z5vK5gTkyua43dqlYq6HPOHGXIXs= 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 1578242949933900.1633099207786; Sun, 5 Jan 2020 08:49:09 -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 1io94k-0003lp-JE; Sun, 05 Jan 2020 16:48:26 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1io94j-0003lc-GK for xen-devel@lists.xenproject.org; Sun, 05 Jan 2020 16:48:25 +0000 Received: from mail-wr1-x443.google.com (unknown [2a00:1450:4864:20::443]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 2b4e09f4-2fdb-11ea-88e7-bc764e2007e4; Sun, 05 Jan 2020 16:48:16 +0000 (UTC) Received: by mail-wr1-x443.google.com with SMTP id b6so47138754wrq.0 for ; Sun, 05 Jan 2020 08:48:16 -0800 (PST) Received: from localhost.localdomain (38.163.200.146.dyn.plus.net. [146.200.163.38]) by smtp.gmail.com with ESMTPSA id y139sm20834028wmd.24.2020.01.05.08.48.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 08:48:15 -0800 (PST) X-Inumbo-ID: 2b4e09f4-2fdb-11ea-88e7-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=UZghIdEEuygXxe0vKMiX29LXHwMAJ7Mkp6vmawf/dbA=; b=mQmEZXhB7VPIFcfgOi698RXGYpFhpBbpFa2D0mmd9VFRtWPYhRCizWsQ0UmyDTu6xZ ViFGHO5Med49c4oPX4gWvDDt3AeXRxJBuYlweslOZ4EmIz7AkL5xs+VoBAgplX+BT40g b2ubVZ8CrnyOxIQlgUGxlDDeBhcS6xHN/lPezi4tir3yHdwPMUgE3ZUG+22BnjCd/hbx v5iUhGdZ68ELJoMXR8l3nyegof4DVyMT6bohg8A8IYj49FXLWOMtupy7PgMkg74rTjpG t3kB/wXLsT+PHUAtqFMD3vRdwNboMi9j5fzJ/3V2OOuaEpC1e9XuNq/YRLMX99VCFBeJ fQMw== 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=UZghIdEEuygXxe0vKMiX29LXHwMAJ7Mkp6vmawf/dbA=; b=an6GPKQRqpX+CvMW8PdDQ7XaxPhPgr/aCBZBcfrf/JjYPd7esYwzF/skqMxUNAg8f4 iajFjzIPbKyn42sQFQvnLHKfMueNjK4fCGxFiMykjEqvO/CIUHmJ6ZhSvt3Tuhq+bVxq ocB9k5/dEeS02+AK5gqCQJK6xJJevZCS1Q8Pdk0Z1fkfsBhYIT6AkKwphRR31ekMbYXg 2x9nq1I2GOVzUzZzzMaGxgHptX8BmlzWVr2a5fK14X0Vt8RmDRmWVbJESVR8zdl5fu7t bSLRw+/rZHUWlDBOU8mcpbvxxS2XVCfJAt6NREp6JGpn6mRzn2n2TPXW+ZSCsWxhc2wI tx4Q== X-Gm-Message-State: APjAAAVVwuLYTByAg7fR0k+MwfJwhJwL1hh9YnmIyBvgzHOKZhtoFLra d5tn1u64Z9iT00ZraFrXqwm7OFEs3yE= X-Google-Smtp-Source: APXvYqxe+PMLJlbq5uHUsneNkt9zW2JDyI5rUmbq/nJE4tjK2l+RPX25Uym2WdbACXpflObTy9PHIA== X-Received: by 2002:adf:c147:: with SMTP id w7mr102064995wre.389.1578242895459; Sun, 05 Jan 2020 08:48:15 -0800 (PST) From: Wei Liu X-Google-Original-From: Wei Liu To: Xen Development List Date: Sun, 5 Jan 2020 16:47:58 +0000 Message-Id: <20200105164801.26278-3-liuwe@microsoft.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200105164801.26278-1-liuwe@microsoft.com> References: <20200105164801.26278-1-liuwe@microsoft.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v3 2/5] 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 --- v3: 1. Name the file hyperv-hcall.h v2: 1. Use direct call --- xen/include/asm-x86/guest/hyperv-hcall.h | 95 ++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 xen/include/asm-x86/guest/hyperv-hcall.h diff --git a/xen/include/asm-x86/guest/hyperv-hcall.h b/xen/include/asm-x86= /guest/hyperv-hcall.h new file mode 100644 index 0000000000..4b87dcfe64 --- /dev/null +++ b/xen/include/asm-x86/guest/hyperv-hcall.h @@ -0,0 +1,95 @@ +/*************************************************************************= ***** + * asm-x86/guest/hyperv-hcall.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_HCALL_H__ +#define __X86_HYPERV_HCALL_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_HCALL_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 From nobody Tue Apr 30 00:36:30 2024 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=1578242955; cv=none; d=zohomail.com; s=zohoarc; b=gjSeiur9GjkkEY2hGPLus35kIBX53SYlz1vFIelu26hDlc6PnyexiyrKxVi6PR+Y81zJYYsJDID9RlLthvtm+HVXvLkCjoKHRfLkEyYYyOHF0bbYPETIvJ8P+QkRDNN7lxAPez4gH4caxIL1yk76VpVCLQR5RirkHTI+ENLsgTs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578242955; 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=Z0UBfH6hEhejsNeNqfG83Scmr43nU8Q1n1unTXdTN6g=; b=T+I3+2OJHUzaspaDCtg5qFLf2jF9c2LybSDKrx1LOJSh643FXWC90a9wKthoE9hOXbtRRL19yydJBeW1vSXjv/k0pN8/xfsBw5mD4cuB/Ed71kdnBr16HVjzykGH2oAt2bgjVjHl0WO2tndv5POAAxddSva0HaR+TqmWRPqSTXE= 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 1578242955575270.58418480275645; Sun, 5 Jan 2020 08:49:15 -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 1io94p-0003ms-RQ; Sun, 05 Jan 2020 16:48:31 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1io94o-0003mZ-Fw for xen-devel@lists.xenproject.org; Sun, 05 Jan 2020 16:48:30 +0000 Received: from mail-wr1-x441.google.com (unknown [2a00:1450:4864:20::441]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 2bcd9796-2fdb-11ea-b6f1-bc764e2007e4; Sun, 05 Jan 2020 16:48:17 +0000 (UTC) Received: by mail-wr1-x441.google.com with SMTP id q6so46992760wro.9 for ; Sun, 05 Jan 2020 08:48:17 -0800 (PST) Received: from localhost.localdomain (38.163.200.146.dyn.plus.net. [146.200.163.38]) by smtp.gmail.com with ESMTPSA id y139sm20834028wmd.24.2020.01.05.08.48.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 08:48:15 -0800 (PST) X-Inumbo-ID: 2bcd9796-2fdb-11ea-b6f1-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=/ARCb3PeIG/kpr3xyc38m7PUJesXNvhlAaIIhN3mhTE=; b=qoANYLeOghT30R0fPBO4/xMRrkYbamKNWwld+OQNb+kMPWoiars7LuIh/tyE4/dDp5 GHv94/RDrmSuWE0kbbhELFEGCtI2vhXj0C4EkYzIflTb6tyhE1Dqd38v35TKLz1oH8gf jjMwJiqqwV+xXAo8z+ahiT4Zey72Gj4ozt7dO5NKE/Ccwd8R/FwYvm3NXdx0Le3FO+mC SLDVqSvgWDRycevPgar9CV4n/r5WBWW+zW0S2WGATbwrFs25qZCW0i97tOQosCP/F7mZ qna6tc1KnncSMyDTiGx8qe8SwuwkT6vfuTcDcSkRSjKxo1P27pGsIk+RCPB1rwJgoNX7 KeVw== 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=/ARCb3PeIG/kpr3xyc38m7PUJesXNvhlAaIIhN3mhTE=; b=EtT0B10KSVJTVLPoV/S5F6Dby8bZ7hMDwXztpupAW0HnWBq2I/3+HFlrmQh3rnjwXR JAz2QtCCV9m5Qtng0Xr0mvLbIgeAK1KRa3gvLjP2QcNG7K5JkK9wTcaB+g9RBt4SXtpz lcJfCNbzG0bwq7mTQPKg1cwhjG28aH8BLQs7EiMj2VKpLjrf4y2KPMJ4hEdEv+MRDqh5 2JLCOkkmsZ1DNnhjLJZ48wJGnfjQm1HTjm/m4GkXTOPQHGet+wyo6nVM2HKLrajZ2vqX ouLrgjs+srC30C/2iWixskQwzV8NSqKL6TFVIF9hmBhfHOyKUJk7d3fBu1de5BfPjAjD TaRg== X-Gm-Message-State: APjAAAUuR0Db0HpvYiYxfPtk31/PZqnD7ZzrcqK/Cqlw9bsmYCs4dFeP TPp2XfRTMi8jCwPh46V5JFShQyKUj80= X-Google-Smtp-Source: APXvYqzJDVBX0cV6hin7+5B+KYwQ+CZTxir4dQ1XVQl5rrj28zwQ/o0VAboBKwDoenJeF4HpdE7yvQ== X-Received: by 2002:adf:fc4b:: with SMTP id e11mr33096478wrs.326.1578242896305; Sun, 05 Jan 2020 08:48:16 -0800 (PST) From: Wei Liu X-Google-Original-From: Wei Liu To: Xen Development List Date: Sun, 5 Jan 2020 16:47:59 +0000 Message-Id: <20200105164801.26278-4-liuwe@microsoft.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200105164801.26278-1-liuwe@microsoft.com> References: <20200105164801.26278-1-liuwe@microsoft.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v3 3/5] x86/hyperv: provide percpu hypercall input page 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) Hyper-V's input / output argument must be 8 bytes aligned an not cross page boundary. The easiest way to satisfy those requirements is to use percpu page. For the foreseeable future we only need to provide input for TLB and APIC hypercalls, so skip setting up an output page. We will also need to provide an ap_setup hook for secondary cpus to setup its own input page. Signed-off-by: Wei Liu --- v3: 1. Use xenheap page instead 2. Drop page tracking structure 3. Drop Paul's review tag --- xen/arch/x86/guest/hyperv/hyperv.c | 20 ++++++++++++++++++++ xen/include/asm-x86/guest/hyperv.h | 4 ++++ 2 files changed, 24 insertions(+) diff --git a/xen/arch/x86/guest/hyperv/hyperv.c b/xen/arch/x86/guest/hyperv= /hyperv.c index 381be2a68c..7e046dfc04 100644 --- a/xen/arch/x86/guest/hyperv/hyperv.c +++ b/xen/arch/x86/guest/hyperv/hyperv.c @@ -27,6 +27,7 @@ struct ms_hyperv_info __read_mostly ms_hyperv; =20 extern char hv_hypercall_page[]; +DEFINE_PER_CPU_READ_MOSTLY(void *, hv_pcpu_input_arg); =20 static const struct hypervisor_ops ops; const struct hypervisor_ops *__init hyperv_probe(void) @@ -83,14 +84,33 @@ static void __init setup_hypercall_page(void) wrmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64); } =20 +static void setup_hypercall_pcpu_arg(void) +{ + void *mapping; + + mapping =3D alloc_xenheap_page(); + if ( !mapping ) + panic("Failed to allocate hypercall input page for %u\n", + smp_processor_id()); + + this_cpu(hv_pcpu_input_arg) =3D mapping; +} + static void __init setup(void) { setup_hypercall_page(); + setup_hypercall_pcpu_arg(); +} + +static void ap_setup(void) +{ + setup_hypercall_pcpu_arg(); } =20 static const struct hypervisor_ops ops =3D { .name =3D "Hyper-V", .setup =3D setup, + .ap_setup =3D ap_setup, }; =20 /* diff --git a/xen/include/asm-x86/guest/hyperv.h b/xen/include/asm-x86/guest= /hyperv.h index c7a7f32bd5..6cf2eab62f 100644 --- a/xen/include/asm-x86/guest/hyperv.h +++ b/xen/include/asm-x86/guest/hyperv.h @@ -51,6 +51,8 @@ static inline uint64_t hv_scale_tsc(uint64_t tsc, uint64_= t scale, =20 #ifdef CONFIG_HYPERV_GUEST =20 +#include + #include =20 struct ms_hyperv_info { @@ -63,6 +65,8 @@ struct ms_hyperv_info { }; extern struct ms_hyperv_info ms_hyperv; =20 +DECLARE_PER_CPU(void *, hv_pcpu_input_arg); + const struct hypervisor_ops *hyperv_probe(void); =20 #else --=20 2.20.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Tue Apr 30 00:36:30 2024 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=1578242958; cv=none; d=zohomail.com; s=zohoarc; b=D9JoSzKEksY/MGyD6JXngGq/ST3SNg3skiXkeY+9HhUfJdVv13n4SXsIbJBdmN1xJWDHkLcxdJpduZr8j+9DDiE8qifZeWLY4hnyMeg17gLCEZTC2HFA15jrzubx4PAiUCbPg7OPduGcpyEYVpkOSRTGkh3nRs0FESOijioFWm4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578242958; 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=4Z4XcnbCndBeMdogn/4TGmqrNmTcdF7+hEDKZMBrFxI=; b=nNALmm7z1RI7ejxymZBvV0IKE4oN8aATuB/79j6z8dlPV/4D+wwH2mrFfTUdk7e04h62/lczoSgICu1+96zgK/5rnuNudJfdPEJ+guImrvz3F2xpATTu2VKxxlSm18oRABs9F8d0sDeLARNiwNCU2uHraYcAEXgJYwSQvZDSPGA= 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 1578242958960982.8117921442825; Sun, 5 Jan 2020 08:49:18 -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 1io94u-0003nz-4e; Sun, 05 Jan 2020 16:48:36 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1io94t-0003nm-Hm for xen-devel@lists.xenproject.org; Sun, 05 Jan 2020 16:48:35 +0000 Received: from mail-wm1-x343.google.com (unknown [2a00:1450:4864:20::343]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 2c464d4e-2fdb-11ea-a1e1-bc764e2007e4; Sun, 05 Jan 2020 16:48:18 +0000 (UTC) Received: by mail-wm1-x343.google.com with SMTP id a5so12670468wmb.0 for ; Sun, 05 Jan 2020 08:48:18 -0800 (PST) Received: from localhost.localdomain (38.163.200.146.dyn.plus.net. [146.200.163.38]) by smtp.gmail.com with ESMTPSA id y139sm20834028wmd.24.2020.01.05.08.48.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 08:48:16 -0800 (PST) X-Inumbo-ID: 2c464d4e-2fdb-11ea-a1e1-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=WF8WbKtTBhS4BHGj5cB1aEH2QagI1ZAGsiQPgtzAOMw=; b=Pecq2HSHZroLPuNAiwy0aVovMUhQaNl5eW+t42s/BKtCEhQwadEAeik73V656FJISM XLkPanOOEV0CiZb26QWdY0+zcVgcladeC3NK+GaKxAaOxYpzmZEIvKwXtjDU5Dx4uOXy o/I5YPPMP/AM2vi8LO13kXcprpnlo8xFd1g78D0P9TB1PaNasF8k1XKihI269+OSsJd8 93EzXkIdz6hI5jeWPlRJhqpMWsSD+RJr6JxfST2rWEoG8V3skkHeFl2DNCLworzkD8UT BUJP0bG0pgtYyWwYtlFQpAJgCy/ksd+oQjOc+Vdc+alZVVIKwSOmANB5YFiCWG5+heH7 w1og== 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=WF8WbKtTBhS4BHGj5cB1aEH2QagI1ZAGsiQPgtzAOMw=; b=YCZoyflbz/kdu+vJgzfwUO84iLQJIZq9cxOlPo7yCGhURuogKp7imVtT9fXjPS1lBe 6aABKWE3U8UQkQB1cPWxwQ+qiTZe34L9Luao4tEETRIX9FwP0eun4f2Dxg3aABHVZM34 N/uQ77qEwcEEzBmV8Uf6Uuu2EaAd69VriqTJKxEA/mdYXhITDg6YIpsEGRE2EFMM0qii qM/UMdp4wFLEl08nJ5d+MutSbgIGqGFg/FQpTadHCGlIczuf4Zm+4puBtZ7EAboAS1Gi fws2b/5K2A9oEvGXK3mpbqPgqpWYIx1TX+vS4cVsM0++5L+H18ZS8nx7PCMMDT6VZKaA tElg== X-Gm-Message-State: APjAAAXTah0dU8W6egmB4eu1z6LKf0qDnKJIgexJzZuO3YA8oXOuxz2u 7Iyp9jRWs5H+w3XmFaY3t/3mYKzL2y4= X-Google-Smtp-Source: APXvYqx2DIQd26D44159xlchspxu/nXkZ5hTAc6k5+voMv2DpaDhI7uHFedu6PAXTvCWdOovCKxaqA== X-Received: by 2002:a1c:770e:: with SMTP id t14mr32371711wmi.101.1578242897110; Sun, 05 Jan 2020 08:48:17 -0800 (PST) From: Wei Liu X-Google-Original-From: Wei Liu To: Xen Development List Date: Sun, 5 Jan 2020 16:48:00 +0000 Message-Id: <20200105164801.26278-5-liuwe@microsoft.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200105164801.26278-1-liuwe@microsoft.com> References: <20200105164801.26278-1-liuwe@microsoft.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v3 4/5] x86/hyperv: retrieve vp_index from Hyper-V 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) This will be useful when invoking hypercall that targets specific vcpu(s). Signed-off-by: Wei Liu Reviewed-by: Paul Durrant --- v2: 1. Fold into setup_pcpu_arg function --- xen/arch/x86/guest/hyperv/hyperv.c | 5 +++++ xen/include/asm-x86/guest/hyperv.h | 1 + 2 files changed, 6 insertions(+) diff --git a/xen/arch/x86/guest/hyperv/hyperv.c b/xen/arch/x86/guest/hyperv= /hyperv.c index 7e046dfc04..e5f258c946 100644 --- a/xen/arch/x86/guest/hyperv/hyperv.c +++ b/xen/arch/x86/guest/hyperv/hyperv.c @@ -28,6 +28,7 @@ struct ms_hyperv_info __read_mostly ms_hyperv; =20 extern char hv_hypercall_page[]; DEFINE_PER_CPU_READ_MOSTLY(void *, hv_pcpu_input_arg); +DEFINE_PER_CPU_READ_MOSTLY(unsigned int, hv_vp_index); =20 static const struct hypervisor_ops ops; const struct hypervisor_ops *__init hyperv_probe(void) @@ -87,6 +88,7 @@ static void __init setup_hypercall_page(void) static void setup_hypercall_pcpu_arg(void) { void *mapping; + uint64_t vp_index_msr; =20 mapping =3D alloc_xenheap_page(); if ( !mapping ) @@ -94,6 +96,9 @@ static void setup_hypercall_pcpu_arg(void) smp_processor_id()); =20 this_cpu(hv_pcpu_input_arg) =3D mapping; + + rdmsrl(HV_X64_MSR_VP_INDEX, vp_index_msr); + this_cpu(hv_vp_index) =3D vp_index_msr; } =20 static void __init setup(void) diff --git a/xen/include/asm-x86/guest/hyperv.h b/xen/include/asm-x86/guest= /hyperv.h index 6cf2eab62f..bae06c8a3a 100644 --- a/xen/include/asm-x86/guest/hyperv.h +++ b/xen/include/asm-x86/guest/hyperv.h @@ -66,6 +66,7 @@ struct ms_hyperv_info { extern struct ms_hyperv_info ms_hyperv; =20 DECLARE_PER_CPU(void *, hv_pcpu_input_arg); +DECLARE_PER_CPU(unsigned int, hv_vp_index); =20 const struct hypervisor_ops *hyperv_probe(void); =20 --=20 2.20.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Tue Apr 30 00:36:30 2024 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=1578242961; cv=none; d=zohomail.com; s=zohoarc; b=AabFC1M0U0FgW2B6DurySsMBDmYHcSebCH7cN69eV5HyZxaZYF6bd6Ong0zlO/cCRnbuTG/ZxsdCSMv43awbZW6kPxW4qHgcY9vay/LRYwBzJCmbfhs8qWH4jCOwBOyQ39nrPzOj9bRB1Sdekr3NcByq6GK0E+ej4tk2x/K60wg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578242961; 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=vC3Y/c4VzUQb/IYTTvr31HSxYbjMeIkXaA13OXaXBn0=; b=R+QzUKy/VvL3tNWA8MK0zHTjGMpPcUY6oDrRPJmwORrrOFbCaQZ9fkDL45xRoNUF3DkReDJjVvSzHWyLwl3QNtA4EwXcnpR/bl5QsiEL2huSV1sDAZuvDY/UnemaZz1R3vQjMvgefJ9OdutkMff/Av9uOj9P2vvJV0FkHBjPw4g= 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 1578242961901880.9550683400759; Sun, 5 Jan 2020 08:49:21 -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 1io94z-0003qc-Ig; Sun, 05 Jan 2020 16:48:41 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1io94y-0003pz-H4 for xen-devel@lists.xenproject.org; Sun, 05 Jan 2020 16:48:40 +0000 Received: from mail-wm1-x344.google.com (unknown [2a00:1450:4864:20::344]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 2cb8ba8c-2fdb-11ea-a914-bc764e2007e4; Sun, 05 Jan 2020 16:48:18 +0000 (UTC) Received: by mail-wm1-x344.google.com with SMTP id c127so10348821wme.1 for ; Sun, 05 Jan 2020 08:48:18 -0800 (PST) Received: from localhost.localdomain (38.163.200.146.dyn.plus.net. [146.200.163.38]) by smtp.gmail.com with ESMTPSA id y139sm20834028wmd.24.2020.01.05.08.48.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 08:48:17 -0800 (PST) X-Inumbo-ID: 2cb8ba8c-2fdb-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=z0cjj/lBQl0c9w1vDyVAOKv50SGygVYLUy39Nar8kbQ=; b=qqEb8PLbYwd+C8pWU6U9Z01IXdSrrma0roIdjxBrgKgPvumCHDa1ujNwFIaKwpE9QQ wkWkDfwCI/jYddKFQuUoYOMk+VspFVzI0bznyhSELZ6J5nDkUtLzf2442f4JW7j1YJhc Ki+M9Z4ZzwJi5rcQX1jkkQQuW6zn9CsiLyRmgsZ4MmfZwb8K+QxzZOeImGZ4QOKFMPhi JoW25wbNgKa+4ppgyQP6Cb9z7sYt2doz+yS9Vwfp0HDmn7b9uC9BHX6Ft+96CxEjr08R HbgJR4osfNI1s65vyqjI9SonmiPvRGurxRZPEMPCH0YQoSOABGuyadJ4Mtfed04mcORd KhhQ== 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=z0cjj/lBQl0c9w1vDyVAOKv50SGygVYLUy39Nar8kbQ=; b=nfQhJJzMb0rjetfPggissXHuSq6AwCa1Y92rwm4cU/ggs2hvRXDi/xbd0QflyTgYB0 fT2mLAeNZ1n2fwUc6aJ0hZut0pb4rDVp+6SF9w6h9vqNtqRbcaIa36Qo//cdpo+d9F8K 6KFw2LhtN80yCbO/XkuL/TeGKpse3ozt0q2PWZSctsri5FyelfbqTJqy8Mz6E5zv4il6 b7iDvQOR9nbFZg7L5Z77aehDOEFRydNZDXC/VkufwZPchiMRVEVZAmn0fSI+8vSAUIA1 f2T+x8RioN6AQUugBwW2aFr3tSVgC6lPkJgFuGf125bwam2cg/aM6d6tsrWU/JLkvQ3B kucg== X-Gm-Message-State: APjAAAVcKW6zLWt9+ybktgsWDjezU2LUoDji4mD9LpwECjEsFRRkTt8l Djk0AcrLAs/bozJhsKBDYekkyQBqV94= X-Google-Smtp-Source: APXvYqwzJDSMmx3E/QqOTDjHNRu3BYDa6GcOcWslL6+9+unRjR45tgun0vDm11rOLWIZGvMdNYUzzw== X-Received: by 2002:a05:600c:21c5:: with SMTP id x5mr29046737wmj.72.1578242897883; Sun, 05 Jan 2020 08:48:17 -0800 (PST) From: Wei Liu X-Google-Original-From: Wei Liu To: Xen Development List Date: Sun, 5 Jan 2020 16:48:01 +0000 Message-Id: <20200105164801.26278-6-liuwe@microsoft.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200105164801.26278-1-liuwe@microsoft.com> References: <20200105164801.26278-1-liuwe@microsoft.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v3 5/5] x86/hyperv: setup VP assist page 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) VP assist page is rather important as we need to toggle some bits in it for efficient nested virtualisation. Signed-off-by: Wei Liu --- v3: 1. Use xenheap page 2. Drop set_vp_assist v2: 1. Use HV_HYP_PAGE_SHIFT instead --- xen/arch/x86/guest/hyperv/hyperv.c | 21 +++++++++++++++++++++ xen/include/asm-x86/guest/hyperv.h | 1 + 2 files changed, 22 insertions(+) diff --git a/xen/arch/x86/guest/hyperv/hyperv.c b/xen/arch/x86/guest/hyperv= /hyperv.c index e5f258c946..17488f8c40 100644 --- a/xen/arch/x86/guest/hyperv/hyperv.c +++ b/xen/arch/x86/guest/hyperv/hyperv.c @@ -29,6 +29,7 @@ struct ms_hyperv_info __read_mostly ms_hyperv; extern char hv_hypercall_page[]; DEFINE_PER_CPU_READ_MOSTLY(void *, hv_pcpu_input_arg); DEFINE_PER_CPU_READ_MOSTLY(unsigned int, hv_vp_index); +DEFINE_PER_CPU_READ_MOSTLY(void *, hv_vp_assist); =20 static const struct hypervisor_ops ops; const struct hypervisor_ops *__init hyperv_probe(void) @@ -101,15 +102,35 @@ static void setup_hypercall_pcpu_arg(void) this_cpu(hv_vp_index) =3D vp_index_msr; } =20 +static void setup_vp_assist(void) +{ + void *mapping; + uint64_t val; + + mapping =3D alloc_xenheap_page(); + if ( !mapping ) + panic("Failed to allocate vp_assist page for %u\n", + smp_processor_id()); + + clear_page(mapping); + + this_cpu(hv_vp_assist) =3D mapping; + val =3D (virt_to_mfn(mapping) << HV_HYP_PAGE_SHIFT) + | HV_X64_MSR_VP_ASSIST_PAGE_ENABLE; + wrmsrl(HV_X64_MSR_VP_ASSIST_PAGE, val); +} + static void __init setup(void) { setup_hypercall_page(); setup_hypercall_pcpu_arg(); + setup_vp_assist(); } =20 static void ap_setup(void) { setup_hypercall_pcpu_arg(); + setup_vp_assist(); } =20 static const struct hypervisor_ops ops =3D { diff --git a/xen/include/asm-x86/guest/hyperv.h b/xen/include/asm-x86/guest= /hyperv.h index bae06c8a3a..2ddfd53f8c 100644 --- a/xen/include/asm-x86/guest/hyperv.h +++ b/xen/include/asm-x86/guest/hyperv.h @@ -67,6 +67,7 @@ extern struct ms_hyperv_info ms_hyperv; =20 DECLARE_PER_CPU(void *, hv_pcpu_input_arg); DECLARE_PER_CPU(unsigned int, hv_vp_index); +DECLARE_PER_CPU(void *, hv_vp_assist); =20 const struct hypervisor_ops *hyperv_probe(void); =20 --=20 2.20.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel