Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp486734pxk; Wed, 16 Sep 2020 09:00:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzRddvIdavUr166wjBayFigJRvIO5RieRaNGoQxf6k3Cw1VzJGMXku0IVvbUBuH/faau9lT X-Received: by 2002:a17:906:368c:: with SMTP id a12mr19701733ejc.423.1600272011360; Wed, 16 Sep 2020 09:00:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600272011; cv=none; d=google.com; s=arc-20160816; b=s4k9veAVqe3W8pfvZ9OPZx92dTKQRAUfVtnJuLwbFuE8jrZtuM981H1qKKndyywI9f 8RX0FW0qHcITzv3R+fLaetNr6Io/ipmyz3nLcML0XSqeGUwSJ0Dbs3Z7GzomBKeSB/98 BpJ+nG/xcS55Ruo3xbCC1PHfmlTb4ZXGIU4JUzheghEHHzFKqssgt3bqhJAJxyEnuU2P M/k2wK0VgD6ZrX8gI52aJ0V2OcipA3FUSsGvkz0xrL8lo7RnL8pwvH7eOqZ5dehi3DoN WoSkGJhMMAJybCJXMXkqFLM7LFINjU0fjuhozhZ29IB5ipvciDF8bmfecFWv9CrVgvFa meYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=G2L3TW2WxV4GsWXWBBVjTC9AR//at+StzHS5DH3Oqf0=; b=op8iG/W2PPq+BFX2QPYUAhhK/tr4sKt3PZJXH3AZZ24NqhwTl5YnWQ/DW44X5tQ1Kx 2rUEHnUQY3BgYbBHhV3gYSVRBa4mDfpoQjh5qKepeoKqdHbEG0nnDJfR20DD60rR/SuN Z5+WlXobR0na+cKatdD4p5/1BL8K20tesfcRDqGGpP6GkIOanwzOF3L06macR9eN2ipM Zho/JzbQLfrTbWaal+oper8QPO0XNxY7jUan62y1YcpNc4f9DW8D1dxCjKE5Ppa2C0Tt LuGLqwfHQk2yBK2XLsOq7FdVmf+PK+GpdWQ097f23sareKPZ58sDQpH8INVxzq3NtZ7o BKzQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u12si12231584ejj.566.2020.09.16.08.59.48; Wed, 16 Sep 2020 09:00:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726316AbgIPP6i (ORCPT + 99 others); Wed, 16 Sep 2020 11:58:38 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:38782 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726312AbgIPPzb (ORCPT ); Wed, 16 Sep 2020 11:55:31 -0400 Received: by mail-wm1-f66.google.com with SMTP id l9so3575148wme.3; Wed, 16 Sep 2020 08:54:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=G2L3TW2WxV4GsWXWBBVjTC9AR//at+StzHS5DH3Oqf0=; b=qrw8Ba/B+s/J7oSklTMNE3a9uHuAanOV8+WQoQXByMQXcUpvMWSrGrT/xxdTaYjCYk FJzn1I/AKIZ1nDIWlnDE2EvdLCCB0yq1L4Y63CZyguE54kTH019MjRzFw/TcgMH9Sdrn vtLNYCNlHSY0+lQgcMY17h/BV9NV0g55WThHVXWhuZn2PuRvuAdQwwLJjzLW5krq3T3M EC66/uv6aHNiN2Zk+JkwBKn94HaIMmzUOHqMnuVnbOAF9raOPfptH8W4YkpH26vtq4XM 3vuwJHaMI1G3uAZ4ISXygX3vwsW02ifU6EGhV399y+0uGWvDmrGDbl62pm5ugeuoxhIo N6vQ== X-Gm-Message-State: AOAM530qcBSLVmvKsRYIUhJN+JbR4RvuiC8JLatg93+/dki4z6YhB21T rLANbY3DFmeoTRbVR9dQI7g0Hk9LWME= X-Received: by 2002:a05:600c:410e:: with SMTP id j14mr5699106wmi.13.1600270923209; Wed, 16 Sep 2020 08:42:03 -0700 (PDT) Received: from liuwe-devbox-debian-v2 ([51.145.34.42]) by smtp.gmail.com with ESMTPSA id t22sm7228468wmt.1.2020.09.16.08.42.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Sep 2020 08:42:02 -0700 (PDT) Date: Wed, 16 Sep 2020 15:42:00 +0000 From: Wei Liu To: Vitaly Kuznetsov Cc: Wei Liu , Linux on Hyper-V List , virtualization@lists.linux-foundation.org, Linux Kernel List , Michael Kelley , Vineeth Pillai , Sunil Muthuswamy , Nuno Das Neves , Lillian Grassin-Drake , "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , "H. Peter Anvin" Subject: Re: [PATCH RFC v1 06/18] x86/hyperv: allocate output arg pages if required Message-ID: <20200916154200.7nf74vjmqu3f6sfq@liuwe-devbox-debian-v2> References: <20200914112802.80611-1-wei.liu@kernel.org> <20200914112802.80611-7-wei.liu@kernel.org> <871rj3l4yt.fsf@vitty.brq.redhat.com> <20200915124318.z6tisek5y4d7e254@liuwe-devbox-debian-v2> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200915124318.z6tisek5y4d7e254@liuwe-devbox-debian-v2> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 15, 2020 at 12:43:18PM +0000, Wei Liu wrote: > On Tue, Sep 15, 2020 at 12:16:58PM +0200, Vitaly Kuznetsov wrote: > > Wei Liu writes: > > > > > When Linux runs as the root partition, it will need to make hypercalls > > > which return data from the hypervisor. > > > > > > Allocate pages for storing results when Linux runs as the root > > > partition. > > > > > > Signed-off-by: Lillian Grassin-Drake > > > Co-Developed-by: Lillian Grassin-Drake > > > Signed-off-by: Wei Liu > > > --- > > > arch/x86/hyperv/hv_init.c | 45 +++++++++++++++++++++++++++++---- > > > arch/x86/include/asm/mshyperv.h | 1 + > > > 2 files changed, 41 insertions(+), 5 deletions(-) > > > > > > diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c > > > index cac8e4c56261..ebba4be4185d 100644 > > > --- a/arch/x86/hyperv/hv_init.c > > > +++ b/arch/x86/hyperv/hv_init.c > > > @@ -45,6 +45,9 @@ EXPORT_SYMBOL_GPL(hv_vp_assist_page); > > > void __percpu **hyperv_pcpu_input_arg; > > > EXPORT_SYMBOL_GPL(hyperv_pcpu_input_arg); > > > > > > +void __percpu **hyperv_pcpu_output_arg; > > > +EXPORT_SYMBOL_GPL(hyperv_pcpu_output_arg); > > > + > > > u32 hv_max_vp_index; > > > EXPORT_SYMBOL_GPL(hv_max_vp_index); > > > > > > @@ -75,14 +78,29 @@ static int hv_cpu_init(unsigned int cpu) > > > u64 msr_vp_index; > > > struct hv_vp_assist_page **hvp = &hv_vp_assist_page[smp_processor_id()]; > > > void **input_arg; > > > - struct page *pg; > > > + struct page *input_pg; > > > > > > input_arg = (void **)this_cpu_ptr(hyperv_pcpu_input_arg); > > > /* hv_cpu_init() can be called with IRQs disabled from hv_resume() */ > > > - pg = alloc_page(irqs_disabled() ? GFP_ATOMIC : GFP_KERNEL); > > > - if (unlikely(!pg)) > > > + input_pg = alloc_page(irqs_disabled() ? GFP_ATOMIC : GFP_KERNEL); > > > + if (unlikely(!input_pg)) > > > return -ENOMEM; > > > - *input_arg = page_address(pg); > > > + *input_arg = page_address(input_pg); > > > + > > > + if (hv_root_partition) { > > > + struct page *output_pg; > > > + void **output_arg; > > > + > > > + output_pg = alloc_page(irqs_disabled() ? GFP_ATOMIC : > > > GFP_KERNEL); > > > > To simplify the code, can we just rename 'input_arg' to 'hypercall_args' > > and do alloc_pages(rqs_disabled() ? GFP_ATOMIC : GFP_KERNEL, 1) to > > allocate two pages above? > > It should be doable, but I need to code it up and test it to be 100% > sure. > I switch to alloc_pages to allocate an order of 2 page if necessary, but I keep input_arg and output_arg separate because I want to avoid code churn in other places. Wei. > > > > > > [...] > > > + /* Allocate the per-CPU state for output arg for root */ > > > + if (hv_root_partition) { > > > + hyperv_pcpu_output_arg = alloc_percpu(void *); > > redundant space ^^^^^ > > Fixed. Thanks. This is in fact copied from the input_arg code, so there > is a similar issue there to be fixed. But that's going to wait till > another day. > > Wei.