Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753444AbbG2L0x (ORCPT ); Wed, 29 Jul 2015 07:26:53 -0400 Received: from smtp02.citrix.com ([66.165.176.63]:62274 "EHLO SMTP02.CITRIX.COM" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752153AbbG2L0v (ORCPT ); Wed, 29 Jul 2015 07:26:51 -0400 X-IronPort-AV: E=Sophos;i="5.15,570,1432598400"; d="scan'208";a="288806464" Message-ID: <55B8B846.2060103@citrix.com> Date: Wed, 29 Jul 2015 12:25:58 +0100 From: Julien Grall User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.7.0 MIME-Version: 1.0 To: Boris Ostrovsky , CC: , "H. Peter Anvin" , "Jiri Slaby" , , Russell King , , , Tomi Valkeinen , , Jean-Christophe Plagniol-Villard , , Konrad Rzeszutek Wilk , "James E.J. Bottomley" , Thomas Gleixner , Ingo Molnar , , Juergen Gross , "Wei Liu" , Greg Kroah-Hartman , Dmitry Torokhov , , David Vrabel , , , =?windows-1252?Q?Roger_Pau_Monn=E9?= Subject: Re: [PATCH 4/8] xen: Use the correctly the Xen memory terminologies References: <1438095769-2560-1-git-send-email-julien.grall@citrix.com> <1438095769-2560-5-git-send-email-julien.grall@citrix.com> <55B7D40B.5080903@oracle.com> In-Reply-To: <55B7D40B.5080903@oracle.com> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-DLP: MIA2 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2522 Lines: 80 Hi Boris, On 28/07/15 20:12, Boris Ostrovsky wrote: > On 07/28/2015 11:02 AM, Julien Grall wrote: >> Based on include/xen/mm.h [1], Linux is mistakenly using MFN when GFN >> is meant, I suspect this is because the first support for Xen was for >> PV. This brough some misimplementation of helpers on ARM and make the >> developper confused the expected behavior. >> >> For instance, with pfn_to_mfn, we expect to get an MFN based on the name. >> Although, if we look at the implementation on x86, it's returning a GFN. >> >> For clarity and avoid new confusion, replace any reference of mfn into >> gnf in any helpers used by PV drivers. > > > > >> @@ -730,7 +730,7 @@ static void xen_do_pin(unsigned level, unsigned >> long pfn) >> struct mmuext_op op; >> >> op.cmd = level; >> - op.arg1.mfn = pfn_to_mfn(pfn); >> + op.arg1.mfn = pfn_to_gfn(pfn); > > > This looks slightly odd. It is correct but given that purpose of this > series is to make things more clear perhaps we can add another union > member (gfn) to mmuext_op.arg1? > > (Of course, the hypervisor will continue referring to mfn which could > still be confusing) This operation is only used for PV guests, right? IHMO re-introducing pfn_to_mfn for PV-guests only (i.e with a BUG_ON to ensure no usage for auto-translated guest) would be the best solution. It would avoid to have different name than the hypersivor one in the hypercall interface. It will also make clear that virt_to_machine & co is only PV specific. I though doing this but I preferred to defer it to x86 expert as my knowledge for x86 Xen is very limited. I don't know where it's more suitable to use MFN or GFN. I guess this file (mmu.c) is mostly PV specific? Would something like below fine for you? static inline unsigned long pfn_to_mfn(unsigned long pfn) { unsigned long mfn; BUG_ON(xen_feature(XENFEAT_auto_translated_physmap)); mfn = __pfn_to_mfn(pfn); if (mfn != INVALID_P2M_ENTRY) mfn &= ~(FOREIGN_FRAME_BIT | IDENTITY_FRAME_BIT); return mfn; } static inline unsigned long pfn_to_gfn(unsigned long pfn) { if (xen_feature(XENFEAT_autotranslated_physmap)) return pfn; else return pfn_to_mfn(pfn); } Similar splitting would be done for gfn_to_pfn and mfn_to_pfn. Regards, -- Julien Grall -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/