Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp955348pxb; Wed, 3 Mar 2021 22:24:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJyMOhgUrDHVYSsnNCUJ59eXqJAEipeihqxtB9TyXgywzWTkKmzlOkmxlWWLiZV8O470/RwF X-Received: by 2002:a17:906:a0d3:: with SMTP id bh19mr2586108ejb.199.1614839098894; Wed, 03 Mar 2021 22:24:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614839098; cv=none; d=google.com; s=arc-20160816; b=OjxqSYwpMiywu+iDmeOQMc4V8ClUIc7lVb4i0tNpmlOoGqWvFH5eGQmE2rnuTvTZj0 EoNDJ61OFQYcEt0KKtW6xkyardlS3HWvsAa+3JJ57WmexKneu8HCk9a1e8o+P3wtoxV+ 3yUmmDYjvuRcD4s2dvyIxrXc5i+Z7QDQSWfyrOo6VY8dqrPV+YMTDMBGlsakUUDCvTo3 q1ILYV5MmXXVw3rarcDVJyfUhLHqjPs9t3sDpCoZW9XJQbamRdOUMSNDw56mEPVBPKwQ gJ+w2MMPV9QWgOac6yQku8i1Y7hVhu8nJzY5oCjXishDw8UhZkWi/Ylj0xKT6S2c+2q4 /cHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:dkim-signature; bh=OEF+iB48cTNiKP+ZNMz7BjR6LuPsBJJOqmuhL+aZPXo=; b=Y08moNVK9QHKZNX5vcHNSx3OspWxOC81ks1OL2fgjzwvXrKSkAOrgZNTeJfH2RteFS gupmj1VXk3mow3tLsNoSCbqYPD1CCHGCZKG87/yCbxuEHnYSELKGWl5NeXEA4I8u1+By YZaa9SGeD+bKnj7w/G6RBJQCWFKnIe6zZoi5Hp66aoOpR4faPjsEXxJkLRDpsr8V9YZ1 9oeWbYdALPkOLKcAwUhe+GZaNGS0Akyb7x7++TbBjnWzQOXzlw6l7gQ04imwkACK4Uwr K6CF0RBBf2vCzl+x0wdl/dkfOugaCmSBWn0+buwLzW5/lxkjYgFSkQIwE4jPnYhs6nEP HdAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="JxeY/sU0"; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a14si12819380ejk.698.2021.03.03.22.24.36; Wed, 03 Mar 2021 22:24:58 -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=@redhat.com header.s=mimecast20190719 header.b="JxeY/sU0"; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1575766AbhCBPoG (ORCPT + 99 others); Tue, 2 Mar 2021 10:44:06 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:28213 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350827AbhCBM7H (ORCPT ); Tue, 2 Mar 2021 07:59:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614689824; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=OEF+iB48cTNiKP+ZNMz7BjR6LuPsBJJOqmuhL+aZPXo=; b=JxeY/sU0JVUw0XQWQGMgGV68V3ogYqPOHH3nouxBfmTjmXGdOhkFqTzyA1Z6eXPytSI5// XTe20PwLRmig02sl5/2lUXhTv59pGtj4DrV21bLGR455JWbzo4pdekQ6a14t2Fnsrs26BE WCsNmbiRaEj4PLFREw7mLOkovQLu6xY= Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-571-9Tu1nK9WPpOBxG_JyyrqcQ-1; Tue, 02 Mar 2021 07:57:03 -0500 X-MC-Unique: 9Tu1nK9WPpOBxG_JyyrqcQ-1 Received: by mail-ej1-f72.google.com with SMTP id ml13so8416045ejb.2 for ; Tue, 02 Mar 2021 04:57:02 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=OEF+iB48cTNiKP+ZNMz7BjR6LuPsBJJOqmuhL+aZPXo=; b=beYjl1ELl1GqGLyaWLULiSr3j/oIC+l6hjj1wIiTZOrrplzfIQSFfc6EmRmVWv2Y5P 2uxEsEGo/ab+DT4IClU9B905Tp1QPiw5c8OXk5sWObnTzvtBpnwZi6ghCqj2t7Q227Jw tJGa0EGapO7GaNL4K7JAtrgq2JGLU82EWMeoKfdrbVWAsBK5YY8+Eu7W3s7dDMX1wJWP fVjDBa/kRDZhXA6aVkPR4eqJmi01FQHYOa97yHOW88sAAW8/omA4/zhXHWQlBSBFUdcH zph6NwJs5q55206/tDv/la4N8fmoYUDKi+KQEYY3V6UOQoAXIC8ILkif3SnKqOpBxVfW BDKQ== X-Gm-Message-State: AOAM531rvC12QOXEp5L68M/CebDAiFA6fB7idRP5aC/EyEhmRSf3rpiX FxuBfyx0opGk7mCIXXWkO4dZnud5bpJf53zsSk2gjpDr034UEJEJb8bN8O2SKgYhT1NxnJCFcOK 3ijBnQT4fWqaZ+cfcc4oWFoVZ X-Received: by 2002:aa7:c403:: with SMTP id j3mr20422766edq.137.1614689821920; Tue, 02 Mar 2021 04:57:01 -0800 (PST) X-Received: by 2002:aa7:c403:: with SMTP id j3mr20422757edq.137.1614689821763; Tue, 02 Mar 2021 04:57:01 -0800 (PST) Received: from vitty.brq.redhat.com (g-server-2.ign.cz. [91.219.240.2]) by smtp.gmail.com with ESMTPSA id k27sm18623879eje.67.2021.03.02.04.57.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Mar 2021 04:57:01 -0800 (PST) From: Vitaly Kuznetsov To: Michael Kelley Cc: mikelley@microsoft.com, linux-kernel@vger.kernel.org, x86@kernel.org, linux-arch@vger.kernel.org, sthemmin@microsoft.com, kys@microsoft.com, wei.liu@kernel.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, hpa@zytor.com, daniel.lezcano@linaro.org, arnd@arndb.de, linux-hyperv@vger.kernel.org Subject: Re: ** POTENTIAL FRAUD ALERT - RED HAT ** [PATCH v2 01/10] Drivers: hv: vmbus: Move Hyper-V page allocator to arch neutral code In-Reply-To: <1614561332-2523-2-git-send-email-mikelley@microsoft.com> References: <1614561332-2523-1-git-send-email-mikelley@microsoft.com> <1614561332-2523-2-git-send-email-mikelley@microsoft.com> Date: Tue, 02 Mar 2021 13:57:00 +0100 Message-ID: <87r1kxemsj.fsf@vitty.brq.redhat.com> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Michael Kelley writes: > The Hyper-V page allocator functions are implemented in an architecture > neutral way. Move them into the architecture neutral VMbus module so > a separate implementation for ARM64 is not needed. > > No functional change. > > Signed-off-by: Michael Kelley > Reviewed-by: Boqun Feng > --- > arch/x86/hyperv/hv_init.c | 22 ---------------------- > arch/x86/include/asm/mshyperv.h | 5 ----- > drivers/hv/hv.c | 36 ++++++++++++++++++++++++++++++++++++ > include/asm-generic/mshyperv.h | 4 ++++ > 4 files changed, 40 insertions(+), 27 deletions(-) > > diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c > index b81047d..4bdb344 100644 > --- a/arch/x86/hyperv/hv_init.c > +++ b/arch/x86/hyperv/hv_init.c > @@ -54,28 +54,6 @@ > u32 hv_max_vp_index; > EXPORT_SYMBOL_GPL(hv_max_vp_index); > > -void *hv_alloc_hyperv_page(void) > -{ > - BUILD_BUG_ON(PAGE_SIZE != HV_HYP_PAGE_SIZE); > - > - return (void *)__get_free_page(GFP_KERNEL); > -} > -EXPORT_SYMBOL_GPL(hv_alloc_hyperv_page); > - > -void *hv_alloc_hyperv_zeroed_page(void) > -{ > - BUILD_BUG_ON(PAGE_SIZE != HV_HYP_PAGE_SIZE); > - > - return (void *)__get_free_page(GFP_KERNEL | __GFP_ZERO); > -} > -EXPORT_SYMBOL_GPL(hv_alloc_hyperv_zeroed_page); > - > -void hv_free_hyperv_page(unsigned long addr) > -{ > - free_page(addr); > -} > -EXPORT_SYMBOL_GPL(hv_free_hyperv_page); > - > static int hv_cpu_init(unsigned int cpu) > { > u64 msr_vp_index; > diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h > index ccf60a8..ef6e968 100644 > --- a/arch/x86/include/asm/mshyperv.h > +++ b/arch/x86/include/asm/mshyperv.h > @@ -233,9 +233,6 @@ static inline struct hv_vp_assist_page *hv_get_vp_assist_page(unsigned int cpu) > > void __init hyperv_init(void); > void hyperv_setup_mmu_ops(void); > -void *hv_alloc_hyperv_page(void); > -void *hv_alloc_hyperv_zeroed_page(void); > -void hv_free_hyperv_page(unsigned long addr); > void set_hv_tscchange_cb(void (*cb)(void)); > void clear_hv_tscchange_cb(void); > void hyperv_stop_tsc_emulation(void); > @@ -272,8 +269,6 @@ int hv_map_ioapic_interrupt(int ioapic_id, bool level, int vcpu, int vector, > #else /* CONFIG_HYPERV */ > static inline void hyperv_init(void) {} > static inline void hyperv_setup_mmu_ops(void) {} > -static inline void *hv_alloc_hyperv_page(void) { return NULL; } > -static inline void hv_free_hyperv_page(unsigned long addr) {} > static inline void set_hv_tscchange_cb(void (*cb)(void)) {} > static inline void clear_hv_tscchange_cb(void) {} > static inline void hyperv_stop_tsc_emulation(void) {}; > diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c > index f202ac7..cca8d5e 100644 > --- a/drivers/hv/hv.c > +++ b/drivers/hv/hv.c > @@ -37,6 +37,42 @@ int hv_init(void) > } > > /* > + * Functions for allocating and freeing memory with size and > + * alignment HV_HYP_PAGE_SIZE. These functions are needed because > + * the guest page size may not be the same as the Hyper-V page > + * size. We depend upon kmalloc() aligning power-of-two size > + * allocations to the allocation size boundary, so that the > + * allocated memory appears to Hyper-V as a page of the size > + * it expects. > + */ > + > +void *hv_alloc_hyperv_page(void) > +{ > + BUILD_BUG_ON(PAGE_SIZE < HV_HYP_PAGE_SIZE); > + > + if (PAGE_SIZE == HV_HYP_PAGE_SIZE) > + return (void *)__get_free_page(GFP_KERNEL); > + else > + return kmalloc(HV_HYP_PAGE_SIZE, GFP_KERNEL); PAGE_SIZE and HV_HYP_PAGE_SIZE are known compile-time and in case this won't change in the future we can probably write this as #if PAGE_SIZE == HV_HYP_PAGE_SIZE return (void *)__get_free_page(GFP_KERNEL); #else return kmalloc(HV_HYP_PAGE_SIZE, GFP_KERNEL); #endif (not sure if the output is going to be any different with e.g. gcc's '-O2') > +} > + > +void *hv_alloc_hyperv_zeroed_page(void) > +{ > + if (PAGE_SIZE == HV_HYP_PAGE_SIZE) > + return (void *)__get_free_page(GFP_KERNEL | __GFP_ZERO); > + else > + return kzalloc(HV_HYP_PAGE_SIZE, GFP_KERNEL); > +} > + > +void hv_free_hyperv_page(unsigned long addr) > +{ > + if (PAGE_SIZE == HV_HYP_PAGE_SIZE) > + free_page(addr); > + else > + kfree((void *)addr); > +} > + > +/* > * hv_post_message - Post a message using the hypervisor message IPC. > * > * This involves a hypercall. > diff --git a/include/asm-generic/mshyperv.h b/include/asm-generic/mshyperv.h > index dff58a3..694b5bc 100644 > --- a/include/asm-generic/mshyperv.h > +++ b/include/asm-generic/mshyperv.h > @@ -117,6 +117,10 @@ static inline void vmbus_signal_eom(struct hv_message *msg, u32 old_msg_type) > /* Sentinel value for an uninitialized entry in hv_vp_index array */ > #define VP_INVAL U32_MAX > > +void *hv_alloc_hyperv_page(void); > +void *hv_alloc_hyperv_zeroed_page(void); > +void hv_free_hyperv_page(unsigned long addr); > + > /** > * hv_cpu_number_to_vp_number() - Map CPU to VP. > * @cpu_number: CPU number in Linux terms -- Vitaly