From patchwork Thu Apr 28 08:21:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Zhang X-Patchwork-Id: 8966611 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 5B2BBBF29F for ; Thu, 28 Apr 2016 08:37:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5AB4D20295 for ; Thu, 28 Apr 2016 08:37:30 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5B4EC2027D for ; Thu, 28 Apr 2016 08:37:29 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1avhOt-0006jm-6u; Thu, 28 Apr 2016 08:34:19 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1avhOr-0006jV-Qm for xen-devel@lists.xen.org; Thu, 28 Apr 2016 08:34:17 +0000 Received: from [85.158.137.68] by server-5.bemta-3.messagelabs.com id F3/98-03651-80BC1275; Thu, 28 Apr 2016 08:34:16 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrILMWRWlGSWpSXmKPExsVywNykQpfjtGK 4wZGlShZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8aLKzuYCp6KV3x6v5W9gfGnYBcjB4eQQKXE p8VsXYycHBICvBJHls1gBQlLCPhLnNyYABIWEqiT2DXjLCuIzSagLfFj9W9GEFtEQFri2ufLY DazwF1GiWvHRUFahQUiJG6fVAIJswioSvxsnAfWyivgJfH6zHIWiE1yEiePTWadwMi9gJFhFa N6cWpRWWqRroVeUlFmekZJbmJmjq6hgbFebmpxcWJ6ak5iUrFecn7uJkagVxmAYAfjhXbnQ4y SHExKorxdhxTDhfiS8lMqMxKLM+KLSnNSiw8xynBwKEnwvj8JlBMsSk1PrUjLzAGGF0xagoNH SYR3JUiat7ggMbc4Mx0idYpRUUqc9yVIQgAkkVGaB9cGC+lLjLJSwryMQIcI8RSkFuVmlqDKv 2IU52BUEuY1OgU0hSczrwRu+iugxUxAiwU2gS0uSURISTUw1v3a9jX9frd6z6mDu78Z1G5R/h p0puP0FBHL6ozZRStZnnGxH/m2tkamQ3njAhX1yeyL/6x9cCj7zRvz+cHWqsf9qoM4Zho/FOD +d778d0oAa2CVv9upEoGGG8mWMc81uqcHfqwJNir+NF13ksb5lbOUs6KiOg5mB1Vv4op9tcv8 cdJSp92TlViKMxINtZiLihMBASF0G2QCAAA= X-Env-Sender: yu.c.zhang@linux.intel.com X-Msg-Ref: server-14.tower-31.messagelabs.com!1461832455!37396063!1 X-Originating-IP: [192.55.52.120] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.34; banners=-,-,- X-VirusChecked: Checked Received: (qmail 2941 invoked from network); 28 Apr 2016 08:34:16 -0000 Received: from mga04.intel.com (HELO mga04.intel.com) (192.55.52.120) by server-14.tower-31.messagelabs.com with SMTP; 28 Apr 2016 08:34:16 -0000 Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga104.fm.intel.com with ESMTP; 28 Apr 2016 01:34:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,546,1455004800"; d="scan'208";a="693613336" Received: from zhangyu-xengt.bj.intel.com ([10.238.157.66]) by FMSMGA003.fm.intel.com with ESMTP; 28 Apr 2016 01:34:13 -0700 From: Yu Zhang To: xen-devel@lists.xen.org Date: Thu, 28 Apr 2016 16:21:23 +0800 Message-Id: <1461831683-26524-1-git-send-email-yu.c.zhang@linux.intel.com> X-Mailer: git-send-email 1.9.1 Cc: Wei Liu , George Dunlap , Andrew Cooper , Paul Durrant , zhiyuan.lv@intel.com, Jan Beulich Subject: [Xen-devel] [PATCH] Remove HVMMEM_mmio_write_dm from the public interface(patch for 4.7.0). 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" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP HVMMEM_mmio_write_dm is removed for new xen interface versions, and is replaced with type HVMMEM_unused. Attempts to set a page to this type will return -EINVAL in xen after 4.7.0. And there will be no pages with type p2m_mmio_write_dm, therefore HVMOP_get_mem_type will never get the old type - HVMMEM_mmio_write_dm. New approaches to write protect guest ram pages will be provided in future patches. Signed-off-by: Yu Zhang --- Cc: Jan Beulich Cc: Andrew Cooper Cc: George Dunlap Cc: Paul Durrant Cc: Wei Liu --- xen/arch/x86/hvm/hvm.c | 7 +++---- xen/include/public/hvm/hvm_op.h | 5 +++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index 8cb6e9e..82e2ed1 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -5497,8 +5497,6 @@ long do_hvm_op(unsigned long op, XEN_GUEST_HANDLE_PARAM(void) arg) get_gfn_query_unlocked(d, a.pfn, &t); if ( p2m_is_mmio(t) ) a.mem_type = HVMMEM_mmio_dm; - else if ( t == p2m_mmio_write_dm ) - a.mem_type = HVMMEM_mmio_write_dm; else if ( p2m_is_readonly(t) ) a.mem_type = HVMMEM_ram_ro; else if ( p2m_is_ram(t) ) @@ -5529,7 +5527,7 @@ long do_hvm_op(unsigned long op, XEN_GUEST_HANDLE_PARAM(void) arg) [HVMMEM_ram_rw] = p2m_ram_rw, [HVMMEM_ram_ro] = p2m_ram_ro, [HVMMEM_mmio_dm] = p2m_mmio_dm, - [HVMMEM_mmio_write_dm] = p2m_mmio_write_dm + [HVMMEM_unused] = p2m_invalid }; if ( copy_from_guest(&a, arg, 1) ) @@ -5553,7 +5551,8 @@ long do_hvm_op(unsigned long op, XEN_GUEST_HANDLE_PARAM(void) arg) ((a.first_pfn + a.nr - 1) > domain_get_maximum_gpfn(d)) ) goto setmemtype_fail; - if ( a.hvmmem_type >= ARRAY_SIZE(memtype) ) + if ( a.hvmmem_type >= ARRAY_SIZE(memtype) || + unlikely(a.hvmmem_type == HVMMEM_unused) ) goto setmemtype_fail; while ( a.nr > start_iter ) diff --git a/xen/include/public/hvm/hvm_op.h b/xen/include/public/hvm/hvm_op.h index 1606185..ebb907a 100644 --- a/xen/include/public/hvm/hvm_op.h +++ b/xen/include/public/hvm/hvm_op.h @@ -83,7 +83,12 @@ typedef enum { HVMMEM_ram_rw, /* Normal read/write guest RAM */ HVMMEM_ram_ro, /* Read-only; writes are discarded */ HVMMEM_mmio_dm, /* Reads and write go to the device model */ +#if __XEN_INTERFACE_VERSION__ < 0x00040700 HVMMEM_mmio_write_dm /* Read-only; writes go to the device model */ +#else + HVMMEM_unused /* Placeholder; setting memory to this type + will fail for code after 4.7.0 */ +#endif } hvmmem_type_t; /* Following tools-only interfaces may change in future. */