All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: Michael Kelley <mikelley@microsoft.com>
Cc: Will Deacon <will@kernel.org>, Ard Biesheuvel <ardb@kernel.org>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Marc Zyngier <maz@kernel.org>,
	Linux ARM <linux-arm-kernel@lists.infradead.org>,
	gregkh <gregkh@linuxfoundation.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	linux-hyperv@vger.kernel.org,
	linux-efi <linux-efi@vger.kernel.org>,
	linux-arch <linux-arch@vger.kernel.org>,
	olaf@aepfle.de, Andy Whitcroft <apw@canonical.com>,
	Vitaly Kuznetsov <vkuznets@redhat.com>,
	Jason Wang <jasowang@redhat.com>,
	marcelo.cerri@canonical.com,
	"K. Y. Srinivasan" <kys@microsoft.com>,
	sunilmut@microsoft.com, Boqun Feng <boqun.feng@gmail.com>
Subject: Re: [PATCH v6 04/10] arm64: hyperv: Add memory alloc/free functions for Hyper-V size pages
Date: Mon, 16 Mar 2020 09:22:43 +0100	[thread overview]
Message-ID: <CAK8P3a2Hnm74aUMNFHbjMr4HwHGZn1+xa4ERsxAJY6hMzhEOhQ@mail.gmail.com> (raw)
In-Reply-To: <1584200119-18594-5-git-send-email-mikelley@microsoft.com>

On Sat, Mar 14, 2020 at 4:36 PM Michael Kelley <mikelley@microsoft.com> 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?

       Arnd

WARNING: multiple messages have this Message-ID (diff)
From: Arnd Bergmann <arnd@arndb.de>
To: Michael Kelley <mikelley@microsoft.com>
Cc: Mark Rutland <mark.rutland@arm.com>,
	linux-arch <linux-arch@vger.kernel.org>,
	linux-hyperv@vger.kernel.org,
	linux-efi <linux-efi@vger.kernel.org>,
	Boqun Feng <boqun.feng@gmail.com>,
	gregkh <gregkh@linuxfoundation.org>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Jason Wang <jasowang@redhat.com>,
	sunilmut@microsoft.com,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	marcelo.cerri@canonical.com, olaf@aepfle.de,
	Marc Zyngier <maz@kernel.org>, Andy Whitcroft <apw@canonical.com>,
	Vitaly Kuznetsov <vkuznets@redhat.com>,
	"K. Y. Srinivasan" <kys@microsoft.com>,
	Will Deacon <will@kernel.org>, Ard Biesheuvel <ardb@kernel.org>,
	Linux ARM <linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH v6 04/10] arm64: hyperv: Add memory alloc/free functions for Hyper-V size pages
Date: Mon, 16 Mar 2020 09:22:43 +0100	[thread overview]
Message-ID: <CAK8P3a2Hnm74aUMNFHbjMr4HwHGZn1+xa4ERsxAJY6hMzhEOhQ@mail.gmail.com> (raw)
In-Reply-To: <1584200119-18594-5-git-send-email-mikelley@microsoft.com>

On Sat, Mar 14, 2020 at 4:36 PM Michael Kelley <mikelley@microsoft.com> 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?

       Arnd

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2020-03-16  8:23 UTC|newest]

Thread overview: 130+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-14 15:35 [PATCH v6 00/10] Subject: Enable Linux guests on Hyper-V on ARM64 Michael Kelley
2020-03-14 15:35 ` Michael Kelley
2020-03-14 15:35 ` Michael Kelley
2020-03-14 15:35 ` [PATCH v6 01/10] arm64: hyperv: Add core Hyper-V include files Michael Kelley
2020-03-14 15:35   ` Michael Kelley
2020-03-14 15:35   ` Michael Kelley
2020-03-15 17:31   ` Marc Zyngier
2020-03-15 17:31     ` Marc Zyngier
2020-03-18  0:10     ` Michael Kelley
2020-03-18  0:10       ` Michael Kelley
2020-03-18  0:10       ` Michael Kelley
2020-03-18  0:10       ` Michael Kelley
2020-03-16  8:47   ` Arnd Bergmann
2020-03-16  8:47     ` Arnd Bergmann
2020-03-18  0:12     ` Michael Kelley
2020-03-18  0:12       ` Michael Kelley
2020-03-18  0:12       ` Michael Kelley
2020-03-18 10:10       ` Arnd Bergmann
2020-03-18 10:10         ` Arnd Bergmann
2020-03-18 10:10         ` Arnd Bergmann
2020-03-19 21:31         ` Michael Kelley
2020-03-19 21:31           ` Michael Kelley
2020-03-19 21:31           ` Michael Kelley
2020-03-20 16:38           ` Arnd Bergmann
2020-03-20 16:38             ` Arnd Bergmann
2020-03-20 16:38             ` Arnd Bergmann
2020-03-14 15:35 ` [PATCH v6 02/10] arm/arm64: smccc-1.1: Add vendor specific owner definition Michael Kelley
2020-03-14 15:35   ` Michael Kelley
2020-03-14 15:35   ` Michael Kelley
2020-03-14 15:35 ` [PATCH v6 03/10] arm64: hyperv: Add hypercall and register access functions Michael Kelley
2020-03-14 15:35   ` Michael Kelley
2020-03-14 15:35   ` Michael Kelley
2020-03-14 15:35 ` [PATCH v6 04/10] arm64: hyperv: Add memory alloc/free functions for Hyper-V size pages Michael Kelley
2020-03-14 15:35   ` Michael Kelley
2020-03-14 15:35   ` Michael Kelley
2020-03-16  8:22   ` Arnd Bergmann [this message]
2020-03-16  8:22     ` Arnd Bergmann
2020-03-16  8:30     ` gregkh
2020-03-16  8:30       ` gregkh
2020-03-16  8:30     ` Marc Zyngier
2020-03-16  8:30       ` Marc Zyngier
2020-03-16  8:32       ` Arnd Bergmann
2020-03-16  8:32         ` Arnd Bergmann
2020-03-18  0:15         ` Michael Kelley
2020-03-18  0:15           ` Michael Kelley
2020-03-18  9:57           ` Arnd Bergmann
2020-03-18  9:57             ` Arnd Bergmann
2020-03-18  9:57             ` Arnd Bergmann
2020-03-19 21:43             ` Michael Kelley
2020-03-19 21:43               ` Michael Kelley
2020-03-19 21:43               ` Michael Kelley
2020-03-20 16:28               ` Arnd Bergmann
2020-03-20 16:28                 ` Arnd Bergmann
2020-03-20 16:28                 ` Arnd Bergmann
2020-03-20 17:22                 ` Michael Kelley
2020-03-20 17:22                   ` Michael Kelley
2020-03-20 17:22                   ` Michael Kelley
2020-03-14 15:35 ` [PATCH v6 05/10] arm64: hyperv: Add interrupt handlers for VMbus and stimer Michael Kelley
2020-03-14 15:35   ` Michael Kelley
2020-03-14 15:35   ` Michael Kelley
2020-03-16  8:25   ` Arnd Bergmann
2020-03-16  8:25     ` Arnd Bergmann
2020-03-18  0:16     ` Michael Kelley
2020-03-18  0:16       ` Michael Kelley
2020-03-18  0:16       ` Michael Kelley
2020-03-18  9:52       ` Arnd Bergmann
2020-03-18  9:52         ` Arnd Bergmann
2020-03-18  9:52         ` Arnd Bergmann
2020-03-14 15:35 ` [PATCH v6 06/10] arm64: hyperv: Add kexec and panic handlers Michael Kelley
2020-03-14 15:35   ` Michael Kelley
2020-03-14 15:35   ` Michael Kelley
2020-03-15 18:15   ` Marc Zyngier
2020-03-15 18:15     ` Marc Zyngier
2020-03-18  0:17     ` Michael Kelley
2020-03-18  0:17       ` Michael Kelley
2020-03-18  0:17       ` Michael Kelley
2020-03-18  0:17       ` Michael Kelley
2020-03-14 15:35 ` [PATCH v6 07/10] arm64: hyperv: Initialize hypervisor on boot Michael Kelley
2020-03-14 15:35   ` Michael Kelley
2020-03-14 15:35   ` Michael Kelley
2020-03-16  8:29   ` Arnd Bergmann
2020-03-16  8:29     ` Arnd Bergmann
2020-03-16  8:29     ` Arnd Bergmann
2020-03-18  0:17     ` Michael Kelley
2020-03-18  0:17       ` Michael Kelley
2020-03-18  0:17       ` Michael Kelley
2020-03-18  9:44       ` Arnd Bergmann
2020-03-18  9:44         ` Arnd Bergmann
2020-03-18  9:44         ` Arnd Bergmann
2020-03-14 15:35 ` [PATCH v6 08/10] Drivers: hv: vmbus: Add hooks for per-CPU IRQ Michael Kelley
2020-03-14 15:35   ` Michael Kelley
2020-03-14 15:35   ` Michael Kelley
2020-03-14 15:35 ` [PATCH v6 09/10] arm64: efi: Export screen_info Michael Kelley
2020-03-14 15:35   ` Michael Kelley
2020-03-14 15:35   ` Michael Kelley
2020-03-16  8:20   ` Arnd Bergmann
2020-03-16  8:20     ` Arnd Bergmann
2020-03-18  0:18     ` Michael Kelley
2020-03-18  0:18       ` Michael Kelley
2020-03-18  0:18       ` Michael Kelley
2020-03-18  9:26       ` Arnd Bergmann
2020-03-18  9:26         ` Arnd Bergmann
2020-03-18  9:26         ` Arnd Bergmann
2020-03-19 21:46         ` Michael Kelley
2020-03-19 21:46           ` Michael Kelley
2020-03-19 21:46           ` Michael Kelley
2020-05-13 14:26           ` Nikhil Mahale
2020-05-13 14:26             ` Nikhil Mahale
2020-05-13 14:26             ` Nikhil Mahale
2020-05-18  4:25             ` Nikhil Mahale
2020-05-18  4:25               ` Nikhil Mahale
2020-05-18  4:25               ` Nikhil Mahale
2020-05-18 12:51               ` Ard Biesheuvel
2020-05-18 12:51                 ` Ard Biesheuvel
2020-05-18 12:51                 ` Ard Biesheuvel
2020-05-22 11:14                 ` Nikhil Mahale
2020-05-22 11:14                   ` Nikhil Mahale
2020-05-22 11:14                   ` Nikhil Mahale
2020-05-22 11:32                   ` Ard Biesheuvel
2020-05-22 11:32                     ` Ard Biesheuvel
2020-05-22 11:32                     ` Ard Biesheuvel
2020-03-14 15:35 ` [PATCH v6 10/10] Drivers: hv: Enable Hyper-V code to be built on ARM64 Michael Kelley
2020-03-14 15:35   ` Michael Kelley
2020-03-14 15:35   ` Michael Kelley
2020-03-18  3:11 ` [PATCH v6 03/10] arm64: hyperv: Add hypercall and register access functions Hillf Danton
2020-03-18  3:11   ` Hillf Danton
2020-03-19 21:04   ` Michael Kelley
2020-03-19 21:04     ` Michael Kelley
2020-03-19 21:04     ` Michael Kelley
2020-03-19 21:04     ` Michael Kelley

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAK8P3a2Hnm74aUMNFHbjMr4HwHGZn1+xa4ERsxAJY6hMzhEOhQ@mail.gmail.com \
    --to=arnd@arndb.de \
    --cc=apw@canonical.com \
    --cc=ardb@kernel.org \
    --cc=boqun.feng@gmail.com \
    --cc=catalin.marinas@arm.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jasowang@redhat.com \
    --cc=kys@microsoft.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-efi@vger.kernel.org \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcelo.cerri@canonical.com \
    --cc=mark.rutland@arm.com \
    --cc=maz@kernel.org \
    --cc=mikelley@microsoft.com \
    --cc=olaf@aepfle.de \
    --cc=sunilmut@microsoft.com \
    --cc=vkuznets@redhat.com \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.