Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp487471pxb; Wed, 20 Jan 2021 11:56:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJzETkdyQySv3hcic1OeWW6N/773CTdQpf5RmtssPvhmWYXuCzVbu8R8x8R0hBAKoVAg1aby X-Received: by 2002:aa7:d98a:: with SMTP id u10mr8509702eds.275.1611172576923; Wed, 20 Jan 2021 11:56:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611172576; cv=none; d=google.com; s=arc-20160816; b=TlomOPeWt7jkVRpDMh/jxBTSbnVz2sC3+FeWDVGosNdS1Fgxus5xi8LRLXjWdtArow FHoZl1vvqPj/X0AFV8jRdgupDMPCcWilA5YzI1JKLjgJM4G1uPM+fmvyMkVAgjQ6lh6h jF3msSD4cUjoX64QGpmmeYzl0B1U7cixmTeRUoeY7Pzw347BtfwdFZGwYzgrDVKp2c9I lqFt/AAVgACrTCqFk20VGNo+afvHp822tVCWte+brIUCy5bb6oCZOpMnzhbbdalAr4i3 AfeFWZOvpi9Al4yYk8QFREqP4loIJBkkIyhTeLQF3J+otffb2X3OznVZ/8bllE0Fxh9D CF8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=UqXhr6U1RGBGjv0Nmx2hKPUeAH0sokB4LM4fa/b0g0Q=; b=x/fLzsfUd+FcJ0BThDc7pys0dP/v3e+yYpbm/WeKNzeTze3r117TKv2D/yBIkbhw7L ikdhnCkTUSFx7d3VXqgOlxEDyCgGWjkikYKrKmHr6iqd8SZltgut9ScKasmqlZ5MeJca wR3IoraIXQ5geiQGc0r+oXGO4/dmMjfUUu1fBY6dvd+qPmKJ+NnBzjDVjcoIXUCujelu n95WtkMLVJQwxNxZpscGDGni6Zrz+z8BgMpetqdNDz0ADkRRZj3smMZVsqxnrgJuhdBF JXRGUxoFJCIeC6ec2fOFfX4xNJzZ3DEW/LxHlPOHaM828QF8e2cpdORJKh+jTWE6G7Rz d4qg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@soleen.com header.s=google header.b=R+IWStL2; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b7si1021241ejj.332.2021.01.20.11.55.52; Wed, 20 Jan 2021 11:56:16 -0800 (PST) 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; dkim=pass header.i=@soleen.com header.s=google header.b=R+IWStL2; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387823AbhATTxi (ORCPT + 99 others); Wed, 20 Jan 2021 14:53:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2392668AbhATTp5 (ORCPT ); Wed, 20 Jan 2021 14:45:57 -0500 Received: from mail-ed1-x536.google.com (mail-ed1-x536.google.com [IPv6:2a00:1450:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE688C0613D3 for ; Wed, 20 Jan 2021 11:45:11 -0800 (PST) Received: by mail-ed1-x536.google.com with SMTP id h16so27180898edt.7 for ; Wed, 20 Jan 2021 11:45:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=UqXhr6U1RGBGjv0Nmx2hKPUeAH0sokB4LM4fa/b0g0Q=; b=R+IWStL2+wlSzaEPF5grre/1r+Jaffw+FsSinFtR7GqGC4E2gIGppNZ48FLSAM1P7V qmOSQXfMkfMvZdsjTxKcjGptYXy54nxR82l+BpQkvK4R5NMIJd7MNHbu+ZZs3+OD+aSP A/aOYQcz6NfqfQoK/m5hgsDdS5u8yBivB/ibpaQimmRiM+LXerCEUiNaw1WxlXSfayCO RDh9CfRYuEHhLrQI7nCm9ERtXoOuf3fAdpNPmGAHBLeqsGgN+X3hX0i3Z+vflrYKvBuv 6TqFt5BK8O+lYEg936dFG4VwU4JjTpoOeDwoCeHHKrfIY47nUARkbZ6uIlK3RU07mG5K ThBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=UqXhr6U1RGBGjv0Nmx2hKPUeAH0sokB4LM4fa/b0g0Q=; b=UMbY3RsVfGSWzUhwNfERcoBj4n8uqHqEYwtWEviUW1dGbeNPcmvrOxvLDrN7o4cohT 0CmgmCrw+kArPIEV2rUS3Nic3mob6gv7NjTSiy4PA4gc2fISBNAEs0lHq9i65BLqd7Fb o7EaAsmbCEgbS0zDq9pJ8BJJcTfnuFN3Fwrf4HQiitvQCmir3F9drgIzi3a2sofHGfXa S+m51L6cg/ymmsfeOG+g6+2xQeloTZJ89MaSsv2+zwA4VhgOowEA8/LkE4aQJk+s5wSV ishfY2WCZSUWwKTpforAOhtkiFJFO2VJhCsLXzy1l9/oEyaU1s3OdDkQHyXaXemyuWVe 1PUg== X-Gm-Message-State: AOAM532y8p1zKSmHtzj91L3EzszTikFMk+0QD26Gb5WxCXLXiG0V78aI a7Xf5ssqJ+LpR9OJWpOF4avCVhXOTdXZvUBbJh5SWQ== X-Received: by 2002:a50:934a:: with SMTP id n10mr8420776eda.26.1611171910694; Wed, 20 Jan 2021 11:45:10 -0800 (PST) MIME-Version: 1.0 References: <20210120120058.29138-1-wei.liu@kernel.org> <20210120120058.29138-7-wei.liu@kernel.org> In-Reply-To: <20210120120058.29138-7-wei.liu@kernel.org> From: Pavel Tatashin Date: Wed, 20 Jan 2021 14:44:34 -0500 Message-ID: Subject: Re: [PATCH v5 06/16] x86/hyperv: allocate output arg pages if required To: Wei Liu Cc: 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" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 20, 2021 at 7:01 AM Wei Liu wrote: > > 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 Reviewed-by: Pavel Tatashin The new warnings reported by the robot are the same as for the input argument. Pasha > --- > v3: Fix hv_cpu_die to use free_pages. > v2: Address Vitaly's comments > --- > arch/x86/hyperv/hv_init.c | 35 ++++++++++++++++++++++++++++----- > arch/x86/include/asm/mshyperv.h | 1 + > 2 files changed, 31 insertions(+), 5 deletions(-) > > diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c > index e04d90af4c27..6f4cb40e53fe 100644 > --- a/arch/x86/hyperv/hv_init.c > +++ b/arch/x86/hyperv/hv_init.c > @@ -41,6 +41,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); > > @@ -73,12 +76,19 @@ static int hv_cpu_init(unsigned int cpu) > void **input_arg; > struct page *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); > + pg = alloc_pages(irqs_disabled() ? GFP_ATOMIC : GFP_KERNEL, hv_root_partition ? 1 : 0); > if (unlikely(!pg)) > return -ENOMEM; > + > + input_arg = (void **)this_cpu_ptr(hyperv_pcpu_input_arg); > *input_arg = page_address(pg); > + if (hv_root_partition) { > + void **output_arg; > + > + output_arg = (void **)this_cpu_ptr(hyperv_pcpu_output_arg); > + *output_arg = page_address(pg + 1); > + } > > hv_get_vp_index(msr_vp_index); > > @@ -205,14 +215,23 @@ static int hv_cpu_die(unsigned int cpu) > unsigned int new_cpu; > unsigned long flags; > void **input_arg; > - void *input_pg = NULL; > + void *pg; > > local_irq_save(flags); > input_arg = (void **)this_cpu_ptr(hyperv_pcpu_input_arg); > - input_pg = *input_arg; > + pg = *input_arg; > *input_arg = NULL; > + > + if (hv_root_partition) { > + void **output_arg; > + > + output_arg = (void **)this_cpu_ptr(hyperv_pcpu_output_arg); > + *output_arg = NULL; > + } > + > local_irq_restore(flags); > - free_page((unsigned long)input_pg); > + > + free_pages((unsigned long)pg, hv_root_partition ? 1 : 0); > > if (hv_vp_assist_page && hv_vp_assist_page[cpu]) > wrmsrl(HV_X64_MSR_VP_ASSIST_PAGE, 0); > @@ -346,6 +365,12 @@ void __init hyperv_init(void) > > BUG_ON(hyperv_pcpu_input_arg == NULL); > > + /* Allocate the per-CPU state for output arg for root */ > + if (hv_root_partition) { > + hyperv_pcpu_output_arg = alloc_percpu(void *); > + BUG_ON(hyperv_pcpu_output_arg == NULL); > + } > + > /* Allocate percpu VP index */ > hv_vp_index = kmalloc_array(num_possible_cpus(), sizeof(*hv_vp_index), > GFP_KERNEL); > diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h > index ac2b0d110f03..62d9390f1ddf 100644 > --- a/arch/x86/include/asm/mshyperv.h > +++ b/arch/x86/include/asm/mshyperv.h > @@ -76,6 +76,7 @@ static inline void hv_disable_stimer0_percpu_irq(int irq) {} > #if IS_ENABLED(CONFIG_HYPERV) > extern void *hv_hypercall_pg; > extern void __percpu **hyperv_pcpu_input_arg; > +extern void __percpu **hyperv_pcpu_output_arg; > > static inline u64 hv_do_hypercall(u64 control, void *input, void *output) > { > -- > 2.20.1 >