From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7F666C0044D for ; Mon, 16 Mar 2020 08:30:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 553AF20737 for ; Mon, 16 Mar 2020 08:30:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1584347432; bh=GJ8GsEypd+i+4W9htj3qLpzQtn+OsOQ9mGSyV2/R7dA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:List-ID:From; b=oxzDzOezlFFGXu+cg/FAWEScwpyfuNZV4vvfuXKqynQ0vsc9IZ3fbWiA3qHb5vrqP VMgCnkqiY8LxRyFUEY3bN9hNTE/XZApTJPkqd9zU1JjU5DF1scwi64+HFDiC5o963W GRVbxiK1keYBNz+aXUF17npiNpxHN7GoLoUWUJrw= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730166AbgCPIa2 (ORCPT ); Mon, 16 Mar 2020 04:30:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:53400 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730016AbgCPIa2 (ORCPT ); Mon, 16 Mar 2020 04:30:28 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C03CF20658; Mon, 16 Mar 2020 08:30:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1584347426; bh=GJ8GsEypd+i+4W9htj3qLpzQtn+OsOQ9mGSyV2/R7dA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=aO/QdzZIFo1XvwNhvNiWRREapqKvMl1JtbC2hByDGtwxxWiPLc8FMNy1H3SN2m+Lv HrJyKp++eqtMyv7/6pUJ4mP2NYJy9OfRPytBOLRGsbhN+9dElVQQ92E7u4rwZ03INc K2y4pim3uAIqEEP/OBj07CjTShjFfqgLzx2t7lM4= Date: Mon, 16 Mar 2020 09:30:24 +0100 From: gregkh To: Arnd Bergmann Cc: Michael Kelley , Will Deacon , Ard Biesheuvel , Catalin Marinas , Mark Rutland , Marc Zyngier , Linux ARM , "linux-kernel@vger.kernel.org" , linux-hyperv@vger.kernel.org, linux-efi , linux-arch , olaf@aepfle.de, Andy Whitcroft , Vitaly Kuznetsov , Jason Wang , marcelo.cerri@canonical.com, "K. Y. Srinivasan" , sunilmut@microsoft.com, Boqun Feng Subject: Re: [PATCH v6 04/10] arm64: hyperv: Add memory alloc/free functions for Hyper-V size pages Message-ID: <20200316083024.GA3204377@kroah.com> References: <1584200119-18594-1-git-send-email-mikelley@microsoft.com> <1584200119-18594-5-git-send-email-mikelley@microsoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-hyperv-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hyperv@vger.kernel.org On Mon, Mar 16, 2020 at 09:22:43AM +0100, Arnd Bergmann wrote: > On Sat, Mar 14, 2020 at 4:36 PM Michael Kelley wrote: > > /* > > + * 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. > > + * > > + * These functions are used by arm64 specific code as well as > > + * arch independent Hyper-V drivers. > > + */ > > + > > +void *hv_alloc_hyperv_page(void) > > +{ > > + BUILD_BUG_ON(PAGE_SIZE < HV_HYP_PAGE_SIZE); > > + return kmalloc(HV_HYP_PAGE_SIZE, GFP_KERNEL); > > +} > > +EXPORT_SYMBOL_GPL(hv_alloc_hyperv_page); > > I don't think there is any guarantee that kmalloc() returns page-aligned > allocations in general. How about using get_free_pages() > to implement this? Even if it was guaranteed, a pointless wrapper like this is not needed or ok, and shouldn't be created, just use kmalloc. thanks, greg k-h