From patchwork Thu Apr 28 08:29:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Zhang X-Patchwork-Id: 8966711 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 3121E9F441 for ; Thu, 28 Apr 2016 08:44:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 43BDA20295 for ; Thu, 28 Apr 2016 08:44:45 +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 2AD342028D for ; Thu, 28 Apr 2016 08:44:44 +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 1avhXA-0007cx-Il; Thu, 28 Apr 2016 08:42:52 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1avhX9-0007cq-RN for xen-devel@lists.xen.org; Thu, 28 Apr 2016 08:42:51 +0000 Received: from [193.109.254.147] by server-3.bemta-14.messagelabs.com id A2/1C-03281-A0DC1275; Thu, 28 Apr 2016 08:42:50 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrCLMWRWlGSWpSXmKPExsVywNykQpfrrGK 4wcPHQhZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8aLKzuYCp6KV3x6v5W9gfGnYBcjJ4eQQIXE tglTmEBsCQFeiSPLZrBC2P4S3w78YO9i5ACqqZOYN1ELJMwmoC3xY/VvRhBbREBa4trny2A2s 8BdRolrx0VBbGGg1oufTzOD2CwCqhIdE9+xgdi8Al4Sv///ZIcYLydx8thk1gmM3AsYGVYxah SnFpWlFukaGuklFWWmZ5TkJmbm6BoamujlphYXJ6an5iQmFesl5+duYgT6lgEIdjCeneZ8iFG Sg0lJlLfrkGK4EF9SfkplRmJxRnxRaU5q8SFGGQ4OJQleqzNAOcGi1PTUirTMHGCQwaQlOHiU RHjPnAZK8xYXJOYWZ6ZDpE4xKkqJ854ESQiAJDJK8+DaYIF9iVFWSpiXEegQIZ6C1KLczBJU+ VeM4hyMSsK810Cm8GTmlcBNfwW0mAloscAmsMUliQgpqQbGprufd2T6270SroqW7j24+LHlmT vadX4lbc3e0v1f9lx2VHIT3+QTFyt1fmVPzISrv//O/zzx5xP/OVvEA3dPY6zX1/wUcXPPwWs vD0kWOz9o+HfBRPhcy4bCCzInPm+a3j//mYjOnq9z//TuXak1ScNyU+K3klMnt96drXhcQ8H7 lG3uHnmBZCWW4oxEQy3mouJEADyBP79nAgAA X-Env-Sender: yu.c.zhang@linux.intel.com X-Msg-Ref: server-11.tower-27.messagelabs.com!1461832969!29697687!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 23185 invoked from network); 28 Apr 2016 08:42:50 -0000 Received: from mga04.intel.com (HELO mga04.intel.com) (192.55.52.120) by server-11.tower-27.messagelabs.com with SMTP; 28 Apr 2016 08:42:50 -0000 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP; 28 Apr 2016 01:42:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,546,1455004800"; d="scan'208";a="941940361" Received: from zhangyu-xengt.bj.intel.com ([10.238.157.66]) by orsmga001.jf.intel.com with ESMTP; 28 Apr 2016 01:42:47 -0700 From: Yu Zhang To: xen-devel@lists.xen.org Date: Thu, 28 Apr 2016 16:29:57 +0800 Message-Id: <1461832197-26772-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 for 4.7] Remove HVMMEM_mmio_write_dm from the public interface. 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 Reviewed-by: Paul Durrant Reviewed-by: George Dunlap Reviewed-by: Wei Liu --- 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. */