From patchwork Sat Jul 3 17:11:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 12357083 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=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 46BABC47E48 for ; Sat, 3 Jul 2021 17:12:20 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 08D0961930 for ; Sat, 3 Jul 2021 17:12:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 08D0961930 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=xen.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.149551.276641 (Exim 4.92) (envelope-from ) id 1lzjBZ-0001eJ-0U; Sat, 03 Jul 2021 17:12:09 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 149551.276641; Sat, 03 Jul 2021 17:12:08 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lzjBY-0001e6-SB; Sat, 03 Jul 2021 17:12:08 +0000 Received: by outflank-mailman (input) for mailman id 149551; Sat, 03 Jul 2021 17:12:07 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lzjBX-0001Wu-HV for xen-devel@lists.xenproject.org; Sat, 03 Jul 2021 17:12:07 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lzjBW-0007ce-5b; Sat, 03 Jul 2021 17:12:06 +0000 Received: from 54-240-197-235.amazon.com ([54.240.197.235] helo=ufe34d9ed68d054.ant.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lzjBV-0005vs-TO; Sat, 03 Jul 2021 17:12:06 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=aIWtWhcuPOkNdbKN38vfGnv+lqziWSfdZNPE+Udjlj8=; b=Vf9Vm+yQSPcRJdNGq9MMtxp0c OwQStU5yFNCZGF9m4yO8Pu6lx/vbibpnPWFR9QnVeKuAkEiUFDn6XVxdISUM3N4mXJ4NHvMMt04dy sE4oKpjcoW3XIFTKfFmtGH+k0h9mh0kWm9Zj3Ax4nVGFt6J66u2ZlfhKRuclXqXTypGnc=; From: Julien Grall To: xen-devel@lists.xenproject.org Cc: julien@xen.org, Julien Grall , Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Wei Liu , George Dunlap , Ian Jackson , Stefano Stabellini , Volodymyr Babchuk Subject: [PATCH v5 4/4] xen/mm: Provide dummy M2P-related helpers when the M2P is not supported Date: Sat, 3 Jul 2021 18:11:52 +0100 Message-Id: <20210703171152.15874-5-julien@xen.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210703171152.15874-1-julien@xen.org> References: <20210703171152.15874-1-julien@xen.org> From: Julien Grall At the moment, Arm is providing a dummy implementation for the M2P helpers used in common code. However, they are quite isolated and could be used by other architecture in the future. So move the helpers necessary for compilation in xen/mm.h and gate them with a new config !HAS_M2P. The other M2P related helpers are removed. Take the opportunity to encode that CONFIG_MEM_SHARING requires the M2P. It is done in the header rather than the Kconfig because the option is not defined in the common Kconfig. Signed-off-by: Julien Grall Reviewed-by: Jan Beulich Acked-by: Stefano Stabellini --- INVALID_M2P_ENTRY needs to be defined because it is a parameter of set_gpfn_from_mfn(). The alternative would be to not evaluate the parameter 'pfn' (e.g. leave the helper as a macro) however this is a bit risky. Changes in v5: - Check that MEM_SHARING is not enabled without the M2P. Changes in v4: - The tags were dropped as the previous version was sent a long time ago. Changes in v3: - Add Stefano's reviewed-by - Add George's acked-by Changes in v2: - Patch added --- xen/arch/x86/Kconfig | 1 + xen/include/asm-arm/mm.h | 11 ----------- xen/include/xen/mm.h | 17 +++++++++++++++++ 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/xen/arch/x86/Kconfig b/xen/arch/x86/Kconfig index 9b164db64187..a083d8194680 100644 --- a/xen/arch/x86/Kconfig +++ b/xen/arch/x86/Kconfig @@ -16,6 +16,7 @@ config X86 select HAS_FAST_MULTIPLY select HAS_IOPORTS select HAS_KEXEC + select HAS_M2P select HAS_NS16550 select HAS_PASSTHROUGH select HAS_PCI diff --git a/xen/include/asm-arm/mm.h b/xen/include/asm-arm/mm.h index 07c24654a0b6..beff43786bda 100644 --- a/xen/include/asm-arm/mm.h +++ b/xen/include/asm-arm/mm.h @@ -318,17 +318,6 @@ static inline void *page_to_virt(const struct page_info *pg) struct page_info *get_page_from_gva(struct vcpu *v, vaddr_t va, unsigned long flags); -/* - * Arm does not have an M2P, but common code expects a handful of - * M2P-related defines and functions. Provide dummy versions of these. - */ -#define INVALID_M2P_ENTRY (~0UL) -#define SHARED_M2P_ENTRY (~0UL - 1UL) -#define SHARED_M2P(_e) ((_e) == SHARED_M2P_ENTRY) - -/* We don't have a M2P on Arm */ -#define set_gpfn_from_mfn(mfn, pfn) do { (void) (mfn), (void)(pfn); } while (0) - /* Arch-specific portion of memory_op hypercall. */ long arch_memory_op(int op, XEN_GUEST_HANDLE_PARAM(void) arg); diff --git a/xen/include/xen/mm.h b/xen/include/xen/mm.h index 667f9dac83a4..b98a1a7f423f 100644 --- a/xen/include/xen/mm.h +++ b/xen/include/xen/mm.h @@ -612,4 +612,21 @@ static inline void put_page_alloc_ref(struct page_info *page) } } +/* + * Dummy implementation of M2P-related helpers for common code when + * the architecture doesn't have an M2P. + */ +#ifndef CONFIG_HAS_M2P + +#ifdef CONFIG_MEM_SHARING +# error "Memory sharing depends on the M2P" +#endif + +#define INVALID_M2P_ENTRY (~0UL) +#define SHARED_M2P(_e) ((void)(_e), false) + +static inline void set_gpfn_from_mfn(unsigned long mfn, unsigned long pfn) {} + +#endif + #endif /* __XEN_MM_H__ */