From nobody Mon Feb 9 06:00:18 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=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