From patchwork Sun Jan 5 16:47:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Liu X-Patchwork-Id: 11318507 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7EB78138C for ; Sun, 5 Jan 2020 16:49:32 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5B5352077B for ; Sun, 5 Jan 2020 16:49:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="qoANYLeO" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5B5352077B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=xen.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org 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 X-Inumbo-ID: 2bcd9796-2fdb-11ea-b6f1-bc764e2007e4 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) 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) 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) 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_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" 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; extern char hv_hypercall_page[]; +DEFINE_PER_CPU_READ_MOSTLY(void *, hv_pcpu_input_arg); 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); } +static void setup_hypercall_pcpu_arg(void) +{ + void *mapping; + + mapping = alloc_xenheap_page(); + if ( !mapping ) + panic("Failed to allocate hypercall input page for %u\n", + smp_processor_id()); + + this_cpu(hv_pcpu_input_arg) = mapping; +} + static void __init setup(void) { setup_hypercall_page(); + setup_hypercall_pcpu_arg(); +} + +static void ap_setup(void) +{ + setup_hypercall_pcpu_arg(); } static const struct hypervisor_ops ops = { .name = "Hyper-V", .setup = setup, + .ap_setup = ap_setup, }; /* 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, #ifdef CONFIG_HYPERV_GUEST +#include + #include struct ms_hyperv_info { @@ -63,6 +65,8 @@ struct ms_hyperv_info { }; extern struct ms_hyperv_info ms_hyperv; +DECLARE_PER_CPU(void *, hv_pcpu_input_arg); + const struct hypervisor_ops *hyperv_probe(void); #else