Received: by 10.213.65.68 with SMTP id h4csp1055390imn; Wed, 14 Mar 2018 08:17:33 -0700 (PDT) X-Google-Smtp-Source: AG47ELsCHscr69VLLqFHtVdSI61HQJakypW8DjI2Pqj7V5eDG+E4tE8PTm+AzSLF+ONo57uKSnBs X-Received: by 2002:a17:902:4d46:: with SMTP id o6-v6mr4433127plh.166.1521040653648; Wed, 14 Mar 2018 08:17:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521040653; cv=none; d=google.com; s=arc-20160816; b=eluF5v+9Hw7hPhaRS8TkIpqSheDuj0a5Ze9dYPDxmCuUtwFegyoBkN1t19wFK9e9f8 v4wqYfsH5vvPK88aoNBP7mD1+gnZFgQs3GCywZQr+aJax1vwlDTJkQfSmboBacmFY7Se Wm8ZEpTkdwo3raytj5RKIhUdNEUBLDvuIaYsrIpnR56OAWFsGCp76Rvdyh3Z6nPS9d1Y LvCNG5guCZszT0/8qoyzENLxJOZNrlLqioE/iIRvKZ2/YvvIw6uR8k2MW+rerUfvulMq rO3xyJSu2nzC5c2DgC9A2ns+rcaG3Sfq/PwdfaOylXY91+/CeSK/cMhDzfBKVA8vAu9h t7ig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date :arc-authentication-results; bh=VKqfdCoXc+8qZ8N7BuwDy4B4m6GtjyBdluQG/mZByhc=; b=uqVWMc85yeBzWa5x8RVc1e6FqO1HB6lyp2IiXRIKIYqLMWUFISQpDQfPhIH5b4K8gl PyS/SSVLRJNQC7kvu8IWNfvJnuHAqagDn14g+86XVdVz4wF7HTkEedw2jGJaOv02Elpd 74Y64ATlykCr2ujYjAUm4pWrnokcJaQKt/Fb3H+7wwc2SAZf5qP6B5SE4tnFZp9Tc0wz Dl8P7H7qsW02KfE/+jLNndgSgP9u+k9wXET00xSS4Esfb5FgAxSNEEpykPiBcPMnqUVy 2tdyhnH4J9wf7UhyE2nkjtLSLa90SPVaoj44zApmCom8fgMsa47DXXSFK5Y2FfxRgYMs UCgA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q22si2258931pfj.50.2018.03.14.08.17.09; Wed, 14 Mar 2018 08:17:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751695AbeCNPQG (ORCPT + 99 others); Wed, 14 Mar 2018 11:16:06 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:51506 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751348AbeCNPQD (ORCPT ); Wed, 14 Mar 2018 11:16:03 -0400 Received: from hsi-kbw-5-158-153-52.hsi19.kabel-badenwuerttemberg.de ([5.158.153.52] helo=nanos.tec.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1ew88F-0003ra-Cp; Wed, 14 Mar 2018 16:15:59 +0100 Date: Wed, 14 Mar 2018 16:15:58 +0100 (CET) From: Thomas Gleixner To: Vitaly Kuznetsov cc: kvm@vger.kernel.org, x86@kernel.org, Paolo Bonzini , =?ISO-8859-2?Q?Radim_Kr=E8m=E1=F8?= , "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , "Michael Kelley (EOSG)" , Mohammed Gamal , Cathy Avery , Bandan Das , linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 4/7] x86/hyper-v: allocate and use Virtual Processor Assist Pages In-Reply-To: <20180309140249.2840-5-vkuznets@redhat.com> Message-ID: References: <20180309140249.2840-1-vkuznets@redhat.com> <20180309140249.2840-5-vkuznets@redhat.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 9 Mar 2018, Vitaly Kuznetsov wrote: > @@ -198,6 +218,12 @@ static int hv_cpu_die(unsigned int cpu) > struct hv_reenlightenment_control re_ctrl; > unsigned int new_cpu; > > + if (hv_vp_assist_page && hv_vp_assist_page[cpu]) { > + wrmsrl(HV_X64_MSR_VP_ASSIST_PAGE, 0); > + vfree(hv_vp_assist_page[cpu]); > + hv_vp_assist_page[cpu] = NULL; So this is freed before the CPU is actually dead. And this runs in preemtible context. Is the wrmsrl(HV_X64_MSR_VP_ASSIST_PAGE, 0); enough to prevent eventual users of the assist page on the outgoing CPU from accessing it? > if (hv_reenlightenment_cb == NULL) > return 0; > > @@ -241,6 +267,13 @@ void hyperv_init(void) > if (!hv_vp_index) > return; > > + hv_vp_assist_page = kcalloc(num_possible_cpus(), > + sizeof(*hv_vp_assist_page), GFP_KERNEL); > + if (!hv_vp_assist_page) { > + ms_hyperv.hints &= ~HV_X64_ENLIGHTENED_VMCS_RECOMMENDED; > + return; > + } > + > if (cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "x86/hyperv_init:online", > hv_cpu_init, hv_cpu_die) < 0) > goto free_vp_index; Shouldn't you free hv_vp_assist_page in the error path? > +extern struct hv_vp_assist_page **hv_vp_assist_page; > + > +static inline struct hv_vp_assist_page *hv_get_vp_assist_page(unsigned int cpu) > +{ > + return hv_vp_assist_page[cpu]; Shouldn't that check hv_vp_assist_page != NULL? Thanks, tglx