Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp57297pxk; Mon, 5 Oct 2020 17:39:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwM+Q83kksK9ZGSywjXCYlE1/umJZ5VqKZXtLiLLdyPeMmum+cjmHcZ2OggvhjqaPjx4V4t X-Received: by 2002:a17:906:eb01:: with SMTP id mb1mr2446103ejb.124.1601944781478; Mon, 05 Oct 2020 17:39:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601944781; cv=none; d=google.com; s=arc-20160816; b=OF7UOn10jz2yBuovkwNlKX7t3cRhjSwifIwXjK0CKprwj5aDWd+K5k6S7AX2TZ/gWw 4D/kKJU41xY4LYlQWwKAuT8z6x6pug1sA/fhvgN3xiYAYASzT/g17ThIePF9YTGy3ioW TuVO+uI9Ov+izswF3dd7iUU3DcZr20ZyqtiHHE/R9ANyAWT8Mb6HPdEsU+7ZMAK0dWLS 3ZYEfORw45mKdDawGKYhDmF30i6voDYfV5faAmcHouvrh57m2CxHOkJoP9VCTkqti6VI NwztAqnxzRgfNFhHQsRglgD7fDJLusRgUxLtxVMWrKAA05WpDUiV+B8GSOtis15Wsl5z OSxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=b/FwBA/msQzo5YJ8+2EUK3yOoOSWvQuHG5pphc3Hc8U=; b=Z2FpwR0eQLlV4Zy4DGmQLnqqriy160XGoj+jrn6DOo4Mzr79iVn8WuDDWoB2OCEMpT ihV9Ir/5jRY1n/QeaRwqFuxRY0KOQe3cXuetgm02MxodeRUre+jn4j/r654mSkWmi+CS zsSxYyn2BeU9L9CG53NY1OwnqUR3/kVfO+1o4Og32Udnpuwb67RxBEiisyV+57gr33wr VX6rufl8JVSxFvUR6o+56TjgTmW8/d+DS85V/EMS1GUyAsuUp+kxt7uv3ARpbXUxGp0b m9ysqf9tCakELVtpIXxHlAD0VnBVEW8jHg4XCChpI2Wto5AmscHuqCNLngbowvGwIpkM 2ZtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gP6hRbcX; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w17si867249ejk.629.2020.10.05.17.39.18; Mon, 05 Oct 2020 17:39:41 -0700 (PDT) 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=@kernel.org header.s=default header.b=gP6hRbcX; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726683AbgJFAfk (ORCPT + 99 others); Mon, 5 Oct 2020 20:35:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:60568 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725865AbgJFAfk (ORCPT ); Mon, 5 Oct 2020 20:35:40 -0400 Received: from devnote2 (NE2965lan1.rev.em-net.ne.jp [210.141.244.193]) (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 4F7542074A; Tue, 6 Oct 2020 00:35:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601944539; bh=z2WQFganH31foJ4iNkkZl1ET6PM+YBNa0ZXpQ29c990=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=gP6hRbcXwksMMPfdO5nHFfAIPOS215+uHEf5VJBxMftLDwB3ZDXjvm6esBt0GKZ/Y dCtB97jae3fCDhNz1wYhhfUU+F2HYEI/d5udzJs+kL2CiN5DpYFG3ypw1gdEIC9cLW +GSU4C0+YfYR32k9LfqTlQgTzXHa3/QYW5pzDKRE= Date: Tue, 6 Oct 2020 09:35:36 +0900 From: Masami Hiramatsu To: Julien Grall Cc: Stefano Stabellini , xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, Alex =?UTF-8?B?QmVubsOpZQ==?= , takahiro.akashi@linaro.org Subject: Re: [PATCH] arm/arm64: xen: Fix to convert percpu address to gfn correctly Message-Id: <20201006093536.5f7ad9e1bc3e2fea2494c229@kernel.org> In-Reply-To: References: <160190516028.40160.9733543991325671759.stgit@devnote2> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 5 Oct 2020 19:18:47 +0100 Julien Grall wrote: > 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. OK, I've confirmed that this depends on CONFIG_NUMA_BALANCING instead of CONFIG_SMP. I'll update the comment. > > [...] > > > Fixes: 250c9af3d831 ("arm/xen: Add support for 64KB page granularity") > > FWIW, I think the bug was already present before 250c9af3d831. Hm, it seems commit 9a9ab3cc00dc ("xen/arm: SMP support") has introduced the per-cpu code. Thank you, > > > Signed-off-by: Masami Hiramatsu > > --- > > 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 -- Masami Hiramatsu