From: Wei Liu <wl@xen.org>
To: Xen Development List <xen-devel@lists.xenproject.org>
Cc: "Wei Liu" <liuwe@microsoft.com>, "Wei Liu" <wl@xen.org>,
"Andrew Cooper" <andrew.cooper3@citrix.com>,
"Paul Durrant" <pdurrant@amazon.com>,
"Michael Kelley" <mikelley@microsoft.com>,
"Roger Pau Monné" <roger.pau@citrix.com>
Subject: [Xen-devel] [PATCH v5 10/12] x86/hyperv: provide percpu hypercall input page
Date: Wed, 29 Jan 2020 20:20:32 +0000 [thread overview]
Message-ID: <20200129202034.15052-11-liuwe@microsoft.com> (raw)
In-Reply-To: <20200129202034.15052-1-liuwe@microsoft.com>
Hyper-V's input / output argument must be 8 bytes aligned an not cross
page boundary. One 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 <liuwe@microsoft.com>
---
v5:
1. Adjust to new ap_setup
2. Change variable name to hv_pcpu_input_page
v4:
1. Change wording in commit message
2. Prevent leak
3. Introduce a private header
v3:
1. Use xenheap page instead
2. Drop page tracking structure
3. Drop Paul's review tag
---
xen/arch/x86/guest/hyperv/hyperv.c | 31 +++++++++++++++++++++++++++++
xen/arch/x86/guest/hyperv/private.h | 29 +++++++++++++++++++++++++++
2 files changed, 60 insertions(+)
create mode 100644 xen/arch/x86/guest/hyperv/private.h
diff --git a/xen/arch/x86/guest/hyperv/hyperv.c b/xen/arch/x86/guest/hyperv/hyperv.c
index 4387b6541e..f0facccbad 100644
--- a/xen/arch/x86/guest/hyperv/hyperv.c
+++ b/xen/arch/x86/guest/hyperv/hyperv.c
@@ -27,7 +27,10 @@
#include <asm/guest/hyperv-tlfs.h>
#include <asm/processor.h>
+#include "private.h"
+
struct ms_hyperv_info __read_mostly ms_hyperv;
+DEFINE_PER_CPU_READ_MOSTLY(void *, hv_pcpu_input_page);
static uint64_t generate_guest_id(void)
{
@@ -127,14 +130,42 @@ static void __init setup_hypercall_page(void)
}
}
+static int setup_hypercall_pcpu_arg(void)
+{
+ void *mapping;
+
+ if ( this_cpu(hv_pcpu_input_page) )
+ return 0;
+
+ mapping = alloc_xenheap_page();
+ if ( !mapping )
+ {
+ printk("Failed to allocate hypercall input page for CPU%u\n",
+ smp_processor_id());
+ return -ENOMEM;
+ }
+
+ this_cpu(hv_pcpu_input_page) = mapping;
+
+ return 0;
+}
+
static void __init setup(void)
{
setup_hypercall_page();
+ if ( setup_hypercall_pcpu_arg() )
+ panic("Hypercall percpu arg setup failed\n");
+}
+
+static int ap_setup(void)
+{
+ return setup_hypercall_pcpu_arg();
}
static const struct hypervisor_ops ops = {
.name = "Hyper-V",
.setup = setup,
+ .ap_setup = ap_setup,
};
static void __maybe_unused build_assertions(void)
diff --git a/xen/arch/x86/guest/hyperv/private.h b/xen/arch/x86/guest/hyperv/private.h
new file mode 100644
index 0000000000..a339274985
--- /dev/null
+++ b/xen/arch/x86/guest/hyperv/private.h
@@ -0,0 +1,29 @@
+/******************************************************************************
+ * arch/x86/guest/hyperv/private.h
+ *
+ * Definitions / declarations only useful to Hyper-V code.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ *
+ * Copyright (c) 2020 Microsoft.
+ */
+
+#ifndef __XEN_HYPERV_PRIVIATE_H__
+#define __XEN_HYPERV_PRIVIATE_H__
+
+#include <xen/percpu.h>
+
+DECLARE_PER_CPU(void *, hv_pcpu_input_page);
+
+#endif /* __XEN_HYPERV_PRIVIATE_H__ */
--
2.20.1
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2020-01-29 20:21 UTC|newest]
Thread overview: 65+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-29 20:20 [Xen-devel] [PATCH v5 00/12] More Hyper-V infrastructures Wei Liu
2020-01-29 20:20 ` [Xen-devel] [PATCH v5 01/12] MAINTAINERS: put Hyper-V code under Viridian maintainership Wei Liu
2020-01-30 9:34 ` Durrant, Paul
2020-01-29 20:20 ` [Xen-devel] [PATCH v5 02/12] x86/hypervisor: make hypervisor_ap_setup return an error code Wei Liu
2020-01-30 10:01 ` Roger Pau Monné
2020-01-30 13:25 ` Wei Liu
2020-01-29 20:20 ` [Xen-devel] [PATCH v5 03/12] x86/smp: don't online cpu if hypervisor_ap_setup fails Wei Liu
2020-01-30 10:10 ` Roger Pau Monné
2020-01-31 13:53 ` Jan Beulich
2020-01-31 14:10 ` Wei Liu
2020-01-31 14:34 ` Jan Beulich
2020-01-29 20:20 ` [Xen-devel] [PATCH v5 04/12] x86: make paddr_bits available earlier Wei Liu
2020-01-30 10:17 ` Roger Pau Monné
2020-01-30 12:00 ` Wei Liu
2020-01-31 13:57 ` Jan Beulich
2020-01-29 20:20 ` [Xen-devel] [PATCH v5 05/12] x86: provide executable fixmap facility Wei Liu
2020-01-30 0:30 ` Wei Liu
2020-01-31 13:12 ` Wei Liu
2020-01-31 13:19 ` Jan Beulich
2020-01-31 13:20 ` Wei Liu
2020-01-29 20:20 ` [Xen-devel] [PATCH v5 06/12] x86/hypervisor: provide hypervisor_reserve_top_pages Wei Liu
2020-01-30 10:32 ` Roger Pau Monné
2020-01-29 20:20 ` [Xen-devel] [PATCH v5 07/12] x86/hyperv: setup hypercall page Wei Liu
2020-01-30 9:57 ` Durrant, Paul
2020-01-30 11:19 ` Wei Liu
2020-01-30 10:41 ` Roger Pau Monné
2020-01-30 11:18 ` Wei Liu
2020-01-30 11:39 ` Roger Pau Monné
2020-01-30 11:47 ` Wei Liu
2020-01-30 12:11 ` Roger Pau Monné
2020-01-31 12:49 ` Wei Liu
2020-01-31 14:05 ` Jan Beulich
2020-01-29 20:20 ` [Xen-devel] [PATCH v5 08/12] x86/hyperv: provide Hyper-V hypercall functions Wei Liu
2020-01-30 10:06 ` Durrant, Paul
2020-01-30 12:08 ` Roger Pau Monné
2020-01-30 12:28 ` Wei Liu
2020-01-30 12:32 ` Roger Pau Monné
2020-01-30 12:39 ` Wei Liu
2020-01-30 14:22 ` Roger Pau Monné
2020-01-30 14:25 ` Wei Liu
2020-01-30 14:47 ` Roger Pau Monné
2020-01-30 15:03 ` Wei Liu
2020-01-30 15:25 ` Roger Pau Monné
2020-01-30 16:02 ` Wei Liu
2020-01-31 14:12 ` Jan Beulich
2020-01-31 14:20 ` Wei Liu
2020-01-31 14:36 ` Jan Beulich
2020-01-31 14:24 ` Jan Beulich
2020-01-31 14:37 ` Wei Liu
2020-01-31 15:35 ` Jan Beulich
2020-01-31 16:15 ` Wei Liu
2020-01-31 16:18 ` Jan Beulich
2020-01-31 16:49 ` Wei Liu
2020-01-29 20:20 ` [Xen-devel] [PATCH v5 09/12] DO NOT APPLY: x86/hyperv: issue an hypercall Wei Liu
2020-01-29 20:20 ` Wei Liu [this message]
2020-01-30 10:14 ` [Xen-devel] [PATCH v5 10/12] x86/hyperv: provide percpu hypercall input page Durrant, Paul
2020-01-30 12:26 ` Roger Pau Monné
2020-01-30 14:09 ` Wei Liu
2020-01-29 20:20 ` [Xen-devel] [PATCH v5 11/12] x86/hyperv: retrieve vp_index from Hyper-V Wei Liu
2020-01-31 14:27 ` Jan Beulich
2020-01-29 20:20 ` [Xen-devel] [PATCH v5 12/12] x86/hyperv: setup VP assist page Wei Liu
2020-01-30 10:34 ` Durrant, Paul
2020-01-30 14:00 ` Wei Liu
2020-01-30 12:42 ` Roger Pau Monné
2020-01-30 14:03 ` Wei Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200129202034.15052-11-liuwe@microsoft.com \
--to=wl@xen.org \
--cc=andrew.cooper3@citrix.com \
--cc=liuwe@microsoft.com \
--cc=mikelley@microsoft.com \
--cc=pdurrant@amazon.com \
--cc=roger.pau@citrix.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.