From: Julien Grall <julien@xen.org>
To: Masami Hiramatsu <mhiramat@kernel.org>,
Stefano Stabellini <sstabellini@kernel.org>
Cc: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org,
"Alex Bennée" <alex.bennee@linaro.org>,
takahiro.akashi@linaro.org
Subject: Re: [PATCH] arm/arm64: xen: Fix to convert percpu address to gfn correctly
Date: Mon, 5 Oct 2020 19:18:47 +0100 [thread overview]
Message-ID: <b205ec9c-c307-2b67-c43a-cf2a67179484@xen.org> (raw)
In-Reply-To: <160190516028.40160.9733543991325671759.stgit@devnote2>
Hi Masami,
On 05/10/2020 14:39, Masami Hiramatsu wrote:
> Use per_cpu_ptr_to_phys() instead of virt_to_phys() for per-cpu
> address conversion.
>
> In xen_starting_cpu(), per-cpu xen_vcpu_info address is converted
> to gfn by virt_to_gfn() macro. However, since the virt_to_gfn(v)
> assumes the given virtual address is in contiguous kernel memory
> area, it can not convert the per-cpu memory if it is allocated on
> vmalloc area (depends on CONFIG_SMP).
Are you sure about this? I have a .config with CONFIG_SMP=y where the
per-cpu region for CPU0 is allocated outside of vmalloc area.
However, I was able to trigger the bug as soon as CONFIG_NUMA_BALANCING
was enabled.
[...]
> Fixes: 250c9af3d831 ("arm/xen: Add support for 64KB page granularity")
FWIW, I think the bug was already present before 250c9af3d831.
> Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
> ---
> arch/arm/xen/enlighten.c | 2 +-
> include/xen/arm/page.h | 3 +++
> 2 files changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c
> index e93145d72c26..a6ab3689b2f4 100644
> --- a/arch/arm/xen/enlighten.c
> +++ b/arch/arm/xen/enlighten.c
> @@ -150,7 +150,7 @@ static int xen_starting_cpu(unsigned int cpu)
> pr_info("Xen: initializing cpu%d\n", cpu);
> vcpup = per_cpu_ptr(xen_vcpu_info, cpu);
>
> - info.mfn = virt_to_gfn(vcpup);
> + info.mfn = percpu_to_gfn(vcpup);
> info.offset = xen_offset_in_page(vcpup);
>
> err = HYPERVISOR_vcpu_op(VCPUOP_register_vcpu_info, xen_vcpu_nr(cpu),
> diff --git a/include/xen/arm/page.h b/include/xen/arm/page.h
> index 39df751d0dc4..ac1b65470563 100644
> --- a/include/xen/arm/page.h
> +++ b/include/xen/arm/page.h
> @@ -83,6 +83,9 @@ static inline unsigned long bfn_to_pfn(unsigned long bfn)
> })
> #define gfn_to_virt(m) (__va(gfn_to_pfn(m) << XEN_PAGE_SHIFT))
>
> +#define percpu_to_gfn(v) \
> + (pfn_to_gfn(per_cpu_ptr_to_phys(v) >> XEN_PAGE_SHIFT))
> +
> /* Only used in PV code. But ARM guests are always HVM. */
> static inline xmaddr_t arbitrary_virt_to_machine(void *vaddr)
> {
>
Cheers,
--
Julien Grall
next prev parent reply other threads:[~2020-10-05 18:41 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-05 13:39 [PATCH] arm/arm64: xen: Fix to convert percpu address to gfn correctly Masami Hiramatsu
2020-10-05 18:18 ` Julien Grall [this message]
2020-10-06 0:35 ` Masami Hiramatsu
2020-10-06 1:13 ` Stefano Stabellini
2020-10-06 2:40 ` Masami Hiramatsu
2020-10-06 4:11 ` Masami Hiramatsu
2020-10-06 17:56 ` Stefano Stabellini
2020-10-07 5:50 ` Masami Hiramatsu
2020-10-08 8:28 ` Masami Hiramatsu
2020-10-08 17:30 ` Stefano Stabellini
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=b205ec9c-c307-2b67-c43a-cf2a67179484@xen.org \
--to=julien@xen.org \
--cc=alex.bennee@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=sstabellini@kernel.org \
--cc=takahiro.akashi@linaro.org \
--cc=xen-devel@lists.xenproject.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).