From patchwork Tue Jul 12 09:02:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Zhang X-Patchwork-Id: 9224847 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8D08F60871 for ; Tue, 12 Jul 2016 09:19:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7B34F26419 for ; Tue, 12 Jul 2016 09:19:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6F90C2787D; Tue, 12 Jul 2016 09:19:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 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.wl.linuxfoundation.org (Postfix) with ESMTPS id C11F627813 for ; Tue, 12 Jul 2016 09:19:46 +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 1bMto7-0004Gj-K9; Tue, 12 Jul 2016 09:16:47 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bMto6-0004Gc-84 for xen-devel@lists.xen.org; Tue, 12 Jul 2016 09:16:46 +0000 Received: from [85.158.139.211] by server-6.bemta-5.messagelabs.com id 74/A1-00606-D75B4875; Tue, 12 Jul 2016 09:16:45 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrLLMWRWlGSWpSXmKPExsVywNwkVrdma0u 4wdprNhZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa0bT3SvMBdPtKxqvPGRtYFxn0MXIySEkUCFx 88J6JhBbQoBX4siyGawQdoDEqiW/mbsYOYBq6iRmvy0DCbMJaEv8WP2bEcQWEZCWuPb5MpDNx cEssIRJYvKW9WwgCWGBcIk/3deZQWwWAVWJHx8usYPYvAJeEos+LILaJSdx8thksF2cAt4S7R PnMkPc4yWx6s1fpgmMvAsYGVYxahSnFpWlFukaWuglFWWmZ5TkJmbm6BoamOrlphYXJ6an5iQ mFesl5+duYgQGAwMQ7GBs2u55iFGSg0lJlLeZuSVciC8pP6UyI7E4I76oNCe1+BCjDAeHkgSv /xagnGBRanpqRVpmDjAsYdISHDxKIrx6IGne4oLE3OLMdIjUKUZFKXHe+5uBEgIgiYzSPLg2W CxcYpSVEuZlBDpEiKcgtSg3swRV/hWjOAejkjDvT5ApPJl5JXDTXwEtZgJaXOvQDLK4JBEhJd XAqHjL2MGKpavcbuFP5luVz7r+Crk+/D3vn8r56Ts/SpS0XLvj7nS+9Pi0bYf3l4lPbA94t3h 53JEo+YWsz/oSennWTLzWK5p6P65NNPfFNYenAcetpqe++nhuqVSm5zmu1x2xm2qvabnse3PH 8NV8p1ufvy/qNY5V3G+3X9XhxTXF+Jssk17xH1NiKc5INNRiLipOBAD7VvpcgAIAAA== X-Env-Sender: yu.c.zhang@linux.intel.com X-Msg-Ref: server-11.tower-206.messagelabs.com!1468315002!37439193!2 X-Originating-IP: [192.55.52.93] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTkyLjU1LjUyLjkzID0+IDMyNDY2NQ==\n X-StarScan-Received: X-StarScan-Version: 8.77; banners=-,-,- X-VirusChecked: Checked Received: (qmail 12577 invoked from network); 12 Jul 2016 09:16:44 -0000 Received: from mga11.intel.com (HELO mga11.intel.com) (192.55.52.93) by server-11.tower-206.messagelabs.com with SMTP; 12 Jul 2016 09:16:44 -0000 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga102.fm.intel.com with ESMTP; 12 Jul 2016 02:16:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.28,351,1464678000"; d="scan'208"; a="1015212896" Received: from zhangyu-xengt.bj.intel.com ([10.238.157.46]) by orsmga002.jf.intel.com with ESMTP; 12 Jul 2016 02:16:41 -0700 From: Yu Zhang To: xen-devel@lists.xen.org Date: Tue, 12 Jul 2016 17:02:06 +0800 Message-Id: <1468314129-28465-2-git-send-email-yu.c.zhang@linux.intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1468314129-28465-1-git-send-email-yu.c.zhang@linux.intel.com> References: <1468314129-28465-1-git-send-email-yu.c.zhang@linux.intel.com> Cc: Kevin Tian , Jan Beulich , George Dunlap , Andrew Cooper , Tim Deegan , Paul Durrant , zhiyuan.lv@intel.com, Jun Nakajima Subject: [Xen-devel] [PATCH v5 1/4] x86/ioreq server: Rename p2m_mmio_write_dm to p2m_ioreq_server. 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-Virus-Scanned: ClamAV using ClamSMTP Previously p2m type p2m_mmio_write_dm was introduced for write- protected memory pages whose write operations are supposed to be forwarded to and emulated by an ioreq server. Yet limitations of rangeset restrict the number of guest pages to be write-protected. This patch replaces the p2m type p2m_mmio_write_dm with a new name: p2m_ioreq_server, which means this p2m type can be claimed by one ioreq server, instead of being tracked inside the rangeset of ioreq server. And a new memory type, HVMMEM_ioreq_server, is now used in the HVMOP_set/get_mem_type interface to set/get this p2m type. Patches following up will add the related HVMOP handling code which map/unmap type p2m_ioreq_server to/from an ioreq server. Without following patches, memory type changes to HVMMEM_ioreq_server can still be allowed, and in such cases, p2m_ioreq_server pages will be treated the same as ones with previous type p2m_mmio_write_dm, and are tracked inside the ioreq server's rangeset. Signed-off-by: Paul Durrant Signed-off-by: Yu Zhang Acked-by: Tim Deegan Acked-by: Andrew Cooper Acked-by: George Dunlap --- Cc: Jan Beulich Cc: Andrew Cooper Cc: Jun Nakajima Cc: Kevin Tian Cc: George Dunlap Cc: Tim Deegan changes in v5: - Commit message changes - explained why we can allow memory type changes to HVMMEM_ioreq_server. - Add George's Acked-by. changes in v4: - According to George's comments, move the HVMMEM_unused part into a seperate patch(which has already been accepted); - Removed George's Reviewed-by because of changes after v3. - According to Wei Liu's comments, change the format of the commit message. changes in v3: - According to Jan & George's comments, keep HVMMEM_mmio_write_dm for old xen interface versions, and replace it with HVMMEM_unused for xen interfaces newer than 4.7.0; For p2m_ioreq_server, a new enum - HVMMEM_ioreq_server is introduced for the get/set mem type interfaces; - Add George's Reviewed-by and Acked-by from Tim & Andrew. changes in v2: - According to George Dunlap's comments, only rename the p2m type, with no behavior changes. --- xen/arch/x86/hvm/hvm.c | 9 ++++++--- xen/arch/x86/mm/p2m-ept.c | 2 +- xen/arch/x86/mm/p2m-pt.c | 2 +- xen/arch/x86/mm/shadow/multi.c | 2 +- xen/include/asm-x86/p2m.h | 4 ++-- xen/include/public/hvm/hvm_op.h | 5 +++-- 6 files changed, 14 insertions(+), 10 deletions(-) diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index c89ab6e..4b51c57 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -1865,7 +1865,7 @@ int hvm_hap_nested_page_fault(paddr_t gpa, unsigned long gla, */ if ( (p2mt == p2m_mmio_dm) || (npfec.write_access && - (p2m_is_discard_write(p2mt) || (p2mt == p2m_mmio_write_dm))) ) + (p2m_is_discard_write(p2mt) || (p2mt == p2m_ioreq_server))) ) { __put_gfn(p2m, gfn); if ( ap2m_active ) @@ -5565,6 +5565,8 @@ 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_ioreq_server ) + a.mem_type = HVMMEM_ioreq_server; else if ( p2m_is_readonly(t) ) a.mem_type = HVMMEM_ram_ro; else if ( p2m_is_ram(t) ) @@ -5595,7 +5597,8 @@ 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_unused] = p2m_invalid + [HVMMEM_unused] = p2m_invalid, + [HVMMEM_ioreq_server] = p2m_ioreq_server }; if ( copy_from_guest(&a, arg, 1) ) @@ -5644,7 +5647,7 @@ long do_hvm_op(unsigned long op, XEN_GUEST_HANDLE_PARAM(void) arg) } if ( !p2m_is_ram(t) && (!p2m_is_hole(t) || a.hvmmem_type != HVMMEM_mmio_dm) && - (t != p2m_mmio_write_dm || a.hvmmem_type != HVMMEM_ram_rw) ) + (t != p2m_ioreq_server || a.hvmmem_type != HVMMEM_ram_rw) ) { put_gfn(d, pfn); goto setmemtype_fail; diff --git a/xen/arch/x86/mm/p2m-ept.c b/xen/arch/x86/mm/p2m-ept.c index 7166c71..7adc77d 100644 --- a/xen/arch/x86/mm/p2m-ept.c +++ b/xen/arch/x86/mm/p2m-ept.c @@ -171,7 +171,7 @@ static void ept_p2m_type_to_flags(struct p2m_domain *p2m, ept_entry_t *entry, entry->a = entry->d = !!cpu_has_vmx_ept_ad; break; case p2m_grant_map_ro: - case p2m_mmio_write_dm: + case p2m_ioreq_server: entry->r = 1; entry->w = entry->x = 0; entry->a = !!cpu_has_vmx_ept_ad; diff --git a/xen/arch/x86/mm/p2m-pt.c b/xen/arch/x86/mm/p2m-pt.c index 4980934..05aaf8f 100644 --- a/xen/arch/x86/mm/p2m-pt.c +++ b/xen/arch/x86/mm/p2m-pt.c @@ -94,7 +94,7 @@ static unsigned long p2m_type_to_flags(p2m_type_t t, mfn_t mfn, default: return flags | _PAGE_NX_BIT; case p2m_grant_map_ro: - case p2m_mmio_write_dm: + case p2m_ioreq_server: return flags | P2M_BASE_FLAGS | _PAGE_NX_BIT; case p2m_ram_ro: case p2m_ram_logdirty: diff --git a/xen/arch/x86/mm/shadow/multi.c b/xen/arch/x86/mm/shadow/multi.c index dfe59a2..8c4b20e 100644 --- a/xen/arch/x86/mm/shadow/multi.c +++ b/xen/arch/x86/mm/shadow/multi.c @@ -3226,7 +3226,7 @@ static int sh_page_fault(struct vcpu *v, /* Need to hand off device-model MMIO to the device model */ if ( p2mt == p2m_mmio_dm - || (p2mt == p2m_mmio_write_dm && ft == ft_demand_write) ) + || (p2mt == p2m_ioreq_server && ft == ft_demand_write) ) { gpa = guest_walk_to_gpa(&gw); goto mmio; diff --git a/xen/include/asm-x86/p2m.h b/xen/include/asm-x86/p2m.h index 4ab3574..6785669 100644 --- a/xen/include/asm-x86/p2m.h +++ b/xen/include/asm-x86/p2m.h @@ -71,7 +71,7 @@ typedef enum { p2m_ram_shared = 12, /* Shared or sharable memory */ p2m_ram_broken = 13, /* Broken page, access cause domain crash */ p2m_map_foreign = 14, /* ram pages from foreign domain */ - p2m_mmio_write_dm = 15, /* Read-only; writes go to the device model */ + p2m_ioreq_server = 15, } p2m_type_t; /* Modifiers to the query */ @@ -112,7 +112,7 @@ typedef unsigned int p2m_query_t; | p2m_to_mask(p2m_ram_ro) \ | p2m_to_mask(p2m_grant_map_ro) \ | p2m_to_mask(p2m_ram_shared) \ - | p2m_to_mask(p2m_mmio_write_dm)) + | p2m_to_mask(p2m_ioreq_server)) /* Write-discard types, which should discard the write operations */ #define P2M_DISCARD_WRITE_TYPES (p2m_to_mask(p2m_ram_ro) \ diff --git a/xen/include/public/hvm/hvm_op.h b/xen/include/public/hvm/hvm_op.h index ebb907a..b3e45cf 100644 --- a/xen/include/public/hvm/hvm_op.h +++ b/xen/include/public/hvm/hvm_op.h @@ -84,11 +84,12 @@ typedef enum { 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 */ + HVMMEM_mmio_write_dm, /* Read-only; writes go to the device model */ #else - HVMMEM_unused /* Placeholder; setting memory to this type + HVMMEM_unused, /* Placeholder; setting memory to this type will fail for code after 4.7.0 */ #endif + HVMMEM_ioreq_server } hvmmem_type_t; /* Following tools-only interfaces may change in future. */