From patchwork Fri Jun 4 06:02:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?SsO8cmdlbiBHcm/Dnw==?= X-Patchwork-Id: 12298749 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,URIBL_BLOCKED, 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 EE0B8C47083 for ; Fri, 4 Jun 2021 06:02:41 +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 9EAAC61402 for ; Fri, 4 Jun 2021 06:02:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9EAAC61402 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com 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.136693.253379 (Exim 4.92) (envelope-from ) id 1lp2ug-000452-M5; Fri, 04 Jun 2021 06:02:34 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 136693.253379; Fri, 04 Jun 2021 06:02:34 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lp2ug-00044r-Ig; Fri, 04 Jun 2021 06:02:34 +0000 Received: by outflank-mailman (input) for mailman id 136693; Fri, 04 Jun 2021 06:02:33 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lp2uf-00029d-L9 for xen-devel@lists.xenproject.org; Fri, 04 Jun 2021 06:02:33 +0000 Received: from smtp-out2.suse.de (unknown [195.135.220.29]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 9d3de1b3-3223-44a0-aaa8-1c7101803c80; Fri, 04 Jun 2021 06:02:18 +0000 (UTC) Received: from imap.suse.de (imap-alt.suse-dmz.suse.de [192.168.254.47]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id CDB1A1FD4A; Fri, 4 Jun 2021 06:02:17 +0000 (UTC) Received: from imap3-int (imap-alt.suse-dmz.suse.de [192.168.254.47]) by imap.suse.de (Postfix) with ESMTP id 9BE5B118DD; Fri, 4 Jun 2021 06:02:17 +0000 (UTC) Received: from director2.suse.de ([192.168.254.72]) by imap3-int with ESMTPSA id QEfCJOnBuWCyGwAALh3uQQ (envelope-from ); Fri, 04 Jun 2021 06:02:17 +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" X-Inumbo-ID: 9d3de1b3-3223-44a0-aaa8-1c7101803c80 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1622786537; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8dbnJVTwfYU2q9IE6Ab5h4nWrKb9atrgQLfiOOr8PBc=; b=ODhxW/t+SwuqmSbFWx4OwmnrItQONZiqU56yh+iFlKM0V3PVS6fKnSOFL/79EThVBfUvnY ijBB65YG1ryNhGGzI2/4D17mMsG0WYq5UFHaDoZgrV1cKHWLsJApw/xR2M89iLZn7BDucM MHfWONi29pi3L5KPexMkppxLkhdxRJU= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1622786537; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8dbnJVTwfYU2q9IE6Ab5h4nWrKb9atrgQLfiOOr8PBc=; b=ODhxW/t+SwuqmSbFWx4OwmnrItQONZiqU56yh+iFlKM0V3PVS6fKnSOFL/79EThVBfUvnY ijBB65YG1ryNhGGzI2/4D17mMsG0WYq5UFHaDoZgrV1cKHWLsJApw/xR2M89iLZn7BDucM MHfWONi29pi3L5KPexMkppxLkhdxRJU= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: julien@xen.org, Juergen Gross , Ian Jackson , Wei Liu Subject: [PATCH v2 6/6] tools/libs/guest: make some definitions private to libxenguest Date: Fri, 4 Jun 2021 08:02:14 +0200 Message-Id: <20210604060214.14924-7-jgross@suse.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210604060214.14924-1-jgross@suse.com> References: <20210604060214.14924-1-jgross@suse.com> MIME-Version: 1.0 There are some definitions which are used in libxenguest only now. Move them from libxenctrl over to libxenguest. Remove an unused macro. Signed-off-by: Juergen Gross Acked-by: Wei Liu --- tools/libs/ctrl/xc_private.h | 32 -------------------------------- tools/libs/guest/xg_core.h | 2 +- tools/libs/guest/xg_core_x86.c | 16 +++++++++++++++- tools/libs/guest/xg_private.h | 16 +++++++++++++++- tools/libs/guest/xg_resume.c | 2 +- 5 files changed, 32 insertions(+), 36 deletions(-) diff --git a/tools/libs/ctrl/xc_private.h b/tools/libs/ctrl/xc_private.h index dff0f0289b..3e299b943f 100644 --- a/tools/libs/ctrl/xc_private.h +++ b/tools/libs/ctrl/xc_private.h @@ -65,38 +65,6 @@ struct iovec { #define ROUNDUP(_x,_w) (((unsigned long)(_x)+(1UL<<(_w))-1) & ~((1UL<<(_w))-1)) -#define GET_FIELD(_p, _f, _w) (((_w) == 8) ? ((_p)->x64._f) : ((_p)->x32._f)) - -#define SET_FIELD(_p, _f, _v, _w) do { \ - if ((_w) == 8) \ - (_p)->x64._f = (_v); \ - else \ - (_p)->x32._f = (_v); \ -} while (0) - -/* XXX SMH: following skanky macros rely on variable p2m_size being set */ -/* XXX TJD: also, "guest_width" should be the guest's sizeof(unsigned long) */ - -struct domain_info_context { - unsigned int guest_width; - unsigned int p2m_frames; - unsigned long p2m_size; -}; - -/* Number of xen_pfn_t in a page */ -#define FPP (PAGE_SIZE/(dinfo->guest_width)) - -/* Number of entries in the pfn_to_mfn_frame_list_list */ -#define P2M_FLL_ENTRIES (((dinfo->p2m_size)+(FPP*FPP)-1)/(FPP*FPP)) - -/* Number of entries in the pfn_to_mfn_frame_list */ -#define P2M_FL_ENTRIES (((dinfo->p2m_size)+FPP-1)/FPP) - -/* Size in bytes of the pfn_to_mfn_frame_list */ -#define P2M_GUEST_FL_SIZE ((P2M_FL_ENTRIES) * (dinfo->guest_width)) -#define P2M_TOOLS_FL_SIZE ((P2M_FL_ENTRIES) * \ - max_t(size_t, sizeof(xen_pfn_t), dinfo->guest_width)) - #define DECLARE_DOMCTL struct xen_domctl domctl #define DECLARE_SYSCTL struct xen_sysctl sysctl #define DECLARE_PHYSDEV_OP struct physdev_op physdev_op diff --git a/tools/libs/guest/xg_core.h b/tools/libs/guest/xg_core.h index f07584aaa6..aaca9e0a8b 100644 --- a/tools/libs/guest/xg_core.h +++ b/tools/libs/guest/xg_core.h @@ -21,7 +21,7 @@ #define XC_CORE_H #include "xen/version.h" -#include "xc_private.h" +#include "xg_private.h" #include "xen/libelf/elfstructs.h" /* section names */ diff --git a/tools/libs/guest/xg_core_x86.c b/tools/libs/guest/xg_core_x86.c index 09f5d696ce..61106b98b8 100644 --- a/tools/libs/guest/xg_core_x86.c +++ b/tools/libs/guest/xg_core_x86.c @@ -18,10 +18,24 @@ */ #include -#include "xc_private.h" +#include "xg_private.h" #include "xg_core.h" #include +/* Number of xen_pfn_t in a page */ +#define FPP (PAGE_SIZE/(dinfo->guest_width)) + +/* Number of entries in the pfn_to_mfn_frame_list_list */ +#define P2M_FLL_ENTRIES (((dinfo->p2m_size)+(FPP*FPP)-1)/(FPP*FPP)) + +/* Number of entries in the pfn_to_mfn_frame_list */ +#define P2M_FL_ENTRIES (((dinfo->p2m_size)+FPP-1)/FPP) + +/* Size in bytes of the pfn_to_mfn_frame_list */ +#define P2M_GUEST_FL_SIZE ((P2M_FL_ENTRIES) * (dinfo->guest_width)) +#define P2M_TOOLS_FL_SIZE ((P2M_FL_ENTRIES) * \ + max_t(size_t, sizeof(xen_pfn_t), dinfo->guest_width)) + int xc_core_arch_gpfn_may_present(struct xc_core_arch_context *arch_ctxt, unsigned long pfn) diff --git a/tools/libs/guest/xg_private.h b/tools/libs/guest/xg_private.h index 25e46d7ce1..03d765da21 100644 --- a/tools/libs/guest/xg_private.h +++ b/tools/libs/guest/xg_private.h @@ -42,6 +42,21 @@ #endif #endif +#define GET_FIELD(_p, _f, _w) (((_w) == 8) ? ((_p)->x64._f) : ((_p)->x32._f)) + +#define SET_FIELD(_p, _f, _v, _w) do { \ + if ((_w) == 8) \ + (_p)->x64._f = (_v); \ + else \ + (_p)->x32._f = (_v); \ +} while (0) + +struct domain_info_context { + unsigned int guest_width; + unsigned int p2m_frames; + unsigned long p2m_size; +}; + struct xc_dom_loader { const char *name; /* Sadly the error returns from these functions are not consistent: */ @@ -139,7 +154,6 @@ static inline xen_pfn_t xc_pfn_to_mfn(xen_pfn_t pfn, xen_pfn_t *p2m, /* Masks for PTE<->PFN conversions */ #define MADDR_BITS_X86 ((dinfo->guest_width == 8) ? 52 : 44) #define MFN_MASK_X86 ((1ULL << (MADDR_BITS_X86 - PAGE_SHIFT_X86)) - 1) -#define MADDR_MASK_X86 (MFN_MASK_X86 << PAGE_SHIFT_X86) int pin_table(xc_interface *xch, unsigned int type, unsigned long mfn, uint32_t dom); diff --git a/tools/libs/guest/xg_resume.c b/tools/libs/guest/xg_resume.c index d201c1488d..77e2451a3c 100644 --- a/tools/libs/guest/xg_resume.c +++ b/tools/libs/guest/xg_resume.c @@ -13,7 +13,7 @@ * License along with this library; If not, see . */ -#include "xc_private.h" +#include "xg_private.h" #include "xenguest.h" #if defined(__i386__) || defined(__x86_64__)