From nobody Mon Feb 9 08:11:40 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1580830705266783.6263948537269; Tue, 4 Feb 2020 07:38:25 -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 1iz0Gt-0001eB-EM; Tue, 04 Feb 2020 15:37:51 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iz0Gs-0001dO-AH for xen-devel@lists.xenproject.org; Tue, 04 Feb 2020 15:37:50 +0000 Received: from mail-wr1-x442.google.com (unknown [2a00:1450:4864:20::442]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 3a4cb3c4-4764-11ea-8396-bc764e2007e4; Tue, 04 Feb 2020 15:37:19 +0000 (UTC) Received: by mail-wr1-x442.google.com with SMTP id z7so23550777wrl.13 for ; Tue, 04 Feb 2020 07:37:19 -0800 (PST) Received: from localhost.localdomain (41.142.6.51.dyn.plus.net. [51.6.142.41]) by smtp.gmail.com with ESMTPSA id p26sm4067143wmc.24.2020.02.04.07.37.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Feb 2020 07:37:17 -0800 (PST) X-Inumbo-ID: 3a4cb3c4-4764-11ea-8396-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=rHW797PnSnAKQGPtPpxfNCtXqooWzhK9wvrkDonruZY=; b=mVqLMm9VDCdYFpGHPyTKdGykWzEkUQqpZa9ht5jTLuo+aalA3pZhVUyE7M2FQSlF8g d3+2BlOGdEpikghRAX6uDphm0Pcui2Q4cDuZ+U5Arfsxo0TknMF8+tRYMdjCjr51uOyx KkLE64WXwpnBsNljG1HFjZPc0rbPbo0ptz1hXuhyw96K2/H2z7us5QBerlNxUN9NY9vd xdqFCAjDLEwfsnq8oQms/bYHslFGVO3NAJKs4ltqQJeBBXM9d/P0PwmxVto+KumwEm34 rFnZ8B+IFbjUdvxnCwaKGEiCWLYyS03dX8/JVzTBYWBk8M8LogvST46WX+m+XTfVPGcp F5VQ== 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=rHW797PnSnAKQGPtPpxfNCtXqooWzhK9wvrkDonruZY=; b=FB4qJr9dkCDWGrlctIPtuMO9vCbiFMnKIY0MR1pvJfiPmzf9Y6oFSdlLxymoT5UtYY 8qGE0p6q4EJUeIj3ptTPTjKerew4sPQNke16yMjakt+rLXMHPar1mq/xnJx3MqEHGmYE fPOyJsx/Vy+XakeWItLC6y3PvXANeOk74cvVZojKFTTmUBd08Y1I5zv1bsvPRGSMZ3OS QXA/uUxWK97ulcKJ3Rak4k5dwk43+DdItVVNUL+1YjdehrjnqfkfkbQ7rHqsbspRYI61 eTasIfXZANb5DjxfENGdjwgRJaUrD3MAp/wGi52w03EkfB5owADx3zrqHwg5kIr0w88U zKcw== X-Gm-Message-State: APjAAAV8Q+n8Qgsc2LRDL17wBBuZjStuDiJq6nVqXB0tvdyv45/WDudx BULdy3PykmyjbXl/bOvXyAvhMQo3cnY= X-Google-Smtp-Source: APXvYqw74B6LPmIVyxElrEIagcvKTsXOsSenaCZop0exi2LVFFcDApz813LIvle+0RtlozLYgqzx9w== X-Received: by 2002:adf:b64b:: with SMTP id i11mr24453079wre.58.1580830638351; Tue, 04 Feb 2020 07:37:18 -0800 (PST) From: Wei Liu X-Google-Original-From: Wei Liu To: Xen Development List Date: Tue, 4 Feb 2020 15:37:02 +0000 Message-Id: <20200204153704.15934-9-liuwe@microsoft.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200204153704.15934-1-liuwe@microsoft.com> References: <20200204153704.15934-1-liuwe@microsoft.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v7 08/10] 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 , Andrew Cooper , Paul Durrant , 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. 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 Reviewed-by: Paul Durrant Reviewed-by: Roger Pau Monn=C3=A9 --- v6: 1. Make code shorter 2. Change variable name 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 address comments --- xen/arch/x86/guest/hyperv/hyperv.c | 28 ++++++++++++++++++++++++++++ xen/arch/x86/guest/hyperv/private.h | 29 +++++++++++++++++++++++++++++ 2 files changed, 57 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 2a2afcb363..6b58065c78 100644 --- a/xen/arch/x86/guest/hyperv/hyperv.c +++ b/xen/arch/x86/guest/hyperv/hyperv.c @@ -27,7 +27,10 @@ #include #include =20 +#include "private.h" + struct ms_hyperv_info __read_mostly ms_hyperv; +DEFINE_PER_CPU_READ_MOSTLY(void *, hv_input_page); =20 static uint64_t generate_guest_id(void) { @@ -130,11 +133,35 @@ static void __init setup_hypercall_page(void) } } =20 +static int setup_hypercall_pcpu_arg(void) +{ + if ( this_cpu(hv_input_page) ) + return 0; + + this_cpu(hv_input_page) =3D alloc_xenheap_page(); + if ( !this_cpu(hv_input_page) ) + { + printk("CPU%u: Failed to allocate hypercall input page\n", + smp_processor_id()); + return -ENOMEM; + } + + return 0; +} + static void __init setup(void) { ASM_CONSTANT(HV_HCALL_PAGE, __fix_x_to_virt(FIX_X_HYPERV_HCALL)); =20 setup_hypercall_page(); + + if ( setup_hypercall_pcpu_arg() ) + panic("Hyper-V hypercall percpu arg setup failed\n"); +} + +static int ap_setup(void) +{ + return setup_hypercall_pcpu_arg(); } =20 static void __init e820_fixup(struct e820map *e820) @@ -148,6 +175,7 @@ static void __init e820_fixup(struct e820map *e820) static const struct hypervisor_ops ops =3D { .name =3D "Hyper-V", .setup =3D setup, + .ap_setup =3D ap_setup, .e820_fixup =3D e820_fixup, }; =20 diff --git a/xen/arch/x86/guest/hyperv/private.h b/xen/arch/x86/guest/hyper= v/private.h new file mode 100644 index 0000000000..093985a94b --- /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 . + * + * Copyright (c) 2020 Microsoft. + */ + +#ifndef __XEN_HYPERV_PRIVIATE_H__ +#define __XEN_HYPERV_PRIVIATE_H__ + +#include + +DECLARE_PER_CPU(void *, hv_input_page); + +#endif /* __XEN_HYPERV_PRIVIATE_H__ */ --=20 2.20.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel