From patchwork Thu Oct 5 17:42:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 114960 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp848342qgn; Thu, 5 Oct 2017 10:44:45 -0700 (PDT) X-Received: by 10.36.111.148 with SMTP id x142mr33475388itb.72.1507225485590; Thu, 05 Oct 2017 10:44:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507225485; cv=none; d=google.com; s=arc-20160816; b=BSUo3Qsi7CTlCmwiXO5AetVAKI1CEKOUHKH7V4AgvHxrXFyNIxKAIPY6mg0UDCXmEc 7ov8z5kaxw8jQAmlAKyPmj4aC7kmrnr0PPSu2OUp86g8x+4EONT1eoyD9rkH7sE9jLKV r7TSMj6i3oxNbB7ZEFod8cDMswiyp32D3hC6sixbJSTkY8q6C5nS17p/TvmdXgMeg0Wi qGjWxj+tXQQayQMG0TJyz/0iJVy2IWDfDwO5JYpEqfwNe5hBtn+Q7fqxhEJsciQqPjdD 3b7xA/EnNT/wN7v9pJOyFL8nYlQ7bQHV921u31nSvgSEAHsK1vJO0zOdxwphcGYbokf4 UwuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=9BCAMH0aQtNCA+wDAnLWT0sS8gFt0qQJrxyRG4kkmg8=; b=U+y0crdozqA6eKzNcCqHRKI6AVbg7bTnSI/jVtGg8S2jxzVOaDOWz+6r4ex2z4oVw8 G9TV5iLvnr+ViGG+cRpGUC+ymQApWj3yf8lx6Dv70YAizadyfzp59hQqq6x9WWuD5bZc m0dVudRU/Uq3GXFAlD4u8TWr+7W3HfQnve4HRKthSd0MZ3fkKQm+Yy4GZN8QINxtBn+q WZYFDVmwiJMvBZiqWKxOgYv3MYiTlPQ757xk9+MUPCKlvzxofasTigZapBl7hj+Ysjgh +IAC4maS9eBsuzH73M2tXD5X6UX6Bl9G+aHr8ITKZ5b0s0ljobkGWARB92RgsTT++3Bp yCMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=QOQtK6Wa; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id p10si200553itp.143.2017.10.05.10.44.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Oct 2017 10:44:45 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=QOQtK6Wa; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e0AAU-000132-QS; Thu, 05 Oct 2017 17:42:42 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e0AAT-000122-Vw for xen-devel@lists.xen.org; Thu, 05 Oct 2017 17:42:42 +0000 Received: from [193.109.254.147] by server-11.bemta-6.messagelabs.com id 62/FE-03638-11F66D95; Thu, 05 Oct 2017 17:42:41 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrKIsWRWlGSWpSXmKPExsVyMfTOJl3+/Gu RBl8fG1os+biYxYHR4+ju30wBjFGsmXlJ+RUJrBmt3e/YC9olKi5ff8LUwPhJqIuRi0NIYBKj xI9pDewgDovAPGaJ6+vWs3UxcnJICPSzSiycow1h50lcX/yYqYuRA8hOk3g7wxfCrJa48DoGx BQSUJNY8yYKYmQfk0Tv7ptg1WwCOhLrZtSCDBERkJa49vkyI0gNs8ArJonW5wvYQRLCAl4Sj9 9+BLNZBFQl3h1dD2bzCthIPJv1lR3iAnmJXW0XWUFsTgFbifU9d8DiQkA1y1ecZZ7AKLiAkWE Vo0ZxalFZapGusZFeUlFmekZJbmJmjq6hgZlebmpxcWJ6ak5iUrFecn7uJkZgsDEAwQ7G0+sC DzFKcjApifJ6ZV2LFOJLyk+pzEgszogvKs1JLT7EKMPBoSTBy58HlBMsSk1PrUjLzAGGPUxag oNHSYRXHiTNW1yQmFucmQ6ROsVoyXHhzqU/TBwH9twCkh037/5hEmLJy89LlRLn3ZML1CAA0p BRmgc3DhablxhlpYR5GYEOFOIpSC3KzSxBlX/FKM7BqCTMawWyliczrwRu6yugg5iADprTdAX koJJEhJRUA6PNXMO3ifwhHudWrtzOtOaeUP/kPsa5eTyfGVu+iOrfefuW5ZaCRwuXqavSm398 W+bM3yj4PGO/bmdvoKf17y6Vo1f/t12rW7Dsvb7R5XMFMx5Hx32Qu5Gxnfd7aUC/SRH3HZGDh nolK37dat7wa73oj6tT2fOmSW2/1CbLL3gix1rh+33mt4eUWIozEg21mIuKEwEjL+ajyAIAAA == X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-12.tower-27.messagelabs.com!1507225358!108850717!1 X-Originating-IP: [209.85.220.178] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 8343 invoked from network); 5 Oct 2017 17:42:39 -0000 Received: from mail-qk0-f178.google.com (HELO mail-qk0-f178.google.com) (209.85.220.178) by server-12.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 5 Oct 2017 17:42:39 -0000 Received: by mail-qk0-f178.google.com with SMTP id n5so13263815qke.11 for ; Thu, 05 Oct 2017 10:42:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=mWQLWwILqk9oSTywGUlMW6L5946TJfO99va/8bLjfzQ=; b=QOQtK6Wam0f0JAV/Qit8jqrS/99WmzFQamdedeB1qJTqBYVzE1mUgKft59pmnCVsOS f4I7HENoaH2c66GB86oX1vBBeHLg7I98JM0MlrTnQM23U0HhBAgDPcAcbj470uan30I/ Jc0dlGLZfs4CbbefEM67F8qm17q1CBfTHikQE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=mWQLWwILqk9oSTywGUlMW6L5946TJfO99va/8bLjfzQ=; b=ENsqOeIWFvWzz+ktjsSAJELhPAvZI5owStL/04uVPOTaWkT3AylenF/LpTUucd61k0 71VRz6Xr/v2udEumPTvn7VtVTlxG2FDz+2Cj++XShGdqUTTor9TEJwuHhpRMqMRTx6Md 0JtRS+7XJQ3MUGvZfXI0Ut6aFR1C0R5wyGrPj9+Aj/wR0DlksL9gzQBvRu+0q+b4rgEO 76VG8Vw7Z4tHMuaQTK+2tH67vGZ4u9ysn+xakWRbLqV5OFGlYavcvAiJ8n7LyUWDOwgA znTXlJ5KkENxiiL/ATs2v9cpbnMppavQSssAPR7w4nefaVgdsAJKxjlWlkkS5zVv8dZ1 M3CQ== X-Gm-Message-State: AMCzsaUJCnXTWxmPyQQrRethRlFG/TWHnWutRax0j94f0SFR72MIfGfN SF0B7MqIG1UGYAGmV4qn6SNF26nKqtM= X-Google-Smtp-Source: AOwi7QBOS4WCEo43cicq/faitrieOxJyofzeZwi5VktsKIvCuZxyv6rRS7vgwMevI+uGAQydTDIkoA== X-Received: by 10.55.204.157 with SMTP id n29mr28754391qkl.243.1507225358464; Thu, 05 Oct 2017 10:42:38 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com ([2001:41d0:1:6c23::1]) by smtp.gmail.com with ESMTPSA id y63sm11815084qky.75.2017.10.05.10.42.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Oct 2017 10:42:38 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Thu, 5 Oct 2017 18:42:20 +0100 Message-Id: <20171005174222.29161-8-julien.grall@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171005174222.29161-1-julien.grall@linaro.org> References: <20171005174222.29161-1-julien.grall@linaro.org> Cc: Stefano Stabellini , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Julien Grall , Ian Jackson , Tim Deegan , Jan Beulich Subject: [Xen-devel] [PATCH v2 7/9] xen/xenoprof: Convert the file to use typesafe MFN X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" The file common/xenoprof.c is now converted to use typesafe. This is requiring to override the macros virt_to_mfn and mfn_to_page to make them work with mfn_t. Also, add a couple of missing newlines in the code modified. Signed-off-by: Julien Grall Reviewed-by: Andrew Cooper --- Cc: Andrew Cooper Cc: George Dunlap Cc: Ian Jackson Cc: Jan Beulich Cc: Konrad Rzeszutek Wilk Cc: Stefano Stabellini Cc: Tim Deegan Cc: Wei Liu Changes in v2: - Add missing newlines - Add Andrew's reviewed-by --- xen/common/xenoprof.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/xen/common/xenoprof.c b/xen/common/xenoprof.c index a5fe6204a5..5acdde5691 100644 --- a/xen/common/xenoprof.c +++ b/xen/common/xenoprof.c @@ -19,6 +19,12 @@ #include #include +/* Override macros from asm/page.h to make them work with mfn_t */ +#undef virt_to_mfn +#define virt_to_mfn(va) _mfn(__virt_to_mfn(va)) +#undef mfn_to_page +#define mfn_to_page(mfn) __mfn_to_page(mfn_x(mfn)) + /* Limit amount of pages used for shared buffer (per domain) */ #define MAX_OPROF_SHARED_PAGES 32 @@ -134,25 +140,27 @@ static void xenoprof_reset_buf(struct domain *d) } static int -share_xenoprof_page_with_guest(struct domain *d, unsigned long mfn, int npages) +share_xenoprof_page_with_guest(struct domain *d, mfn_t mfn, int npages) { int i; /* Check if previous page owner has released the page. */ for ( i = 0; i < npages; i++ ) { - struct page_info *page = mfn_to_page(mfn + i); + struct page_info *page = mfn_to_page(mfn_add(mfn, i)); + if ( (page->count_info & (PGC_allocated|PGC_count_mask)) != 0 ) { printk(XENLOG_G_INFO "dom%d mfn %#lx page->count_info %#lx\n", - d->domain_id, mfn + i, page->count_info); + d->domain_id, mfn_x(mfn_add(mfn, i)), page->count_info); return -EBUSY; } page_set_owner(page, NULL); } for ( i = 0; i < npages; i++ ) - share_xen_page_with_guest(mfn_to_page(mfn + i), d, XENSHARE_writable); + share_xen_page_with_guest(mfn_to_page(mfn_add(mfn, i)), + d, XENSHARE_writable); return 0; } @@ -161,11 +169,12 @@ static void unshare_xenoprof_page_with_guest(struct xenoprof *x) { int i, npages = x->npages; - unsigned long mfn = virt_to_mfn(x->rawbuf); + mfn_t mfn = virt_to_mfn(x->rawbuf); for ( i = 0; i < npages; i++ ) { - struct page_info *page = mfn_to_page(mfn + i); + struct page_info *page = mfn_to_page(mfn_add(mfn, i)); + BUG_ON(page_get_owner(page) != current->domain); if ( test_and_clear_bit(_PGC_allocated, &page->count_info) ) put_page(page);