From xen-devel-bounces@lists.xen.org Mon Feb 10 16:19:07 2014 Received: (at maildrop) by bugs.xenproject.org; 10 Feb 2014 16:19:07 +0000 Received: from lists.xen.org ([50.57.142.19]) by bugs.xenproject.org with esmtp (Exim 4.80) (envelope-from ) id 1WCtZb-0008UA-NK for xen-devel-maildrop-Eithu9ie@bugs.xenproject.org; Mon, 10 Feb 2014 16:19:07 +0000 Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WCtUY-0004aa-63; Mon, 10 Feb 2014 16:13:54 +0000 Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WCtUW-0004aR-Is for xen-devel@lists.xen.org; Mon, 10 Feb 2014 16:13:52 +0000 Received: from [85.158.143.35:10848] by server-3.bemta-4.messagelabs.com id CC/49-11539-FBAF8F25; Mon, 10 Feb 2014 16:13:51 +0000 X-Env-Sender: dunlapg@gmail.com X-Msg-Ref: server-16.tower-21.messagelabs.com!1392048830!4583207!1 X-Originating-IP: [209.85.212.174] X-SpamReason: No, hits=0.3 required=7.0 tests=RCVD_BY_IP X-StarScan-Received: X-StarScan-Version: 6.9.16; banners=-,-,- X-VirusChecked: Checked Received: (qmail 27614 invoked from network); 10 Feb 2014 16:13:50 -0000 Received: from mail-wi0-f174.google.com (HELO mail-wi0-f174.google.com) (209.85.212.174) by server-16.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 10 Feb 2014 16:13:50 -0000 Received: by mail-wi0-f174.google.com with SMTP id f8so2984337wiw.7 for ; Mon, 10 Feb 2014 08:13:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=h59J3fNYxHzJ1kyshaUw0P8cmzKFgd8c0A34nDotSaY=; b=avSuHwpNaVuI+Q1pCAQ/ehNRFPyonIUZRMOtE8QcsHAGFPF/g2wTpVUfSfzIYdhsHV Fe/nj8bgI5TtUgYhYo0g9l2Hh2tRmbakGBThJQ5hP0WjHBNg5X3ZNyJkGbXUmwL7+/JQ nKBw3+2HoI/bU+ejC+TPzfPoLEGapw4WJgteiFPHn6xlnJMD51oGXwMFfxn4+5B/kra5 bE00TQ+/Gw1XNJ921V3r7UYqfaKznfe7JW4e0/MBoYuBB0pmSE/hJ8SHv6g3wWTtH8aP m06hu1JLncqQJ7kobsbJoApyGfv9PzGEcoE5XjJl6NGTFntTw7ibPk9VBRI8slSv41/1 CSOw== MIME-Version: 1.0 X-Received: by 10.180.185.197 with SMTP id fe5mr11014321wic.56.1392048830622; Mon, 10 Feb 2014 08:13:50 -0800 (PST) Received: by 10.194.75.163 with HTTP; Mon, 10 Feb 2014 08:13:50 -0800 (PST) In-Reply-To: <1392012840-22555-1-git-send-email-yang.z.zhang@intel.com> References: <1392012840-22555-1-git-send-email-yang.z.zhang@intel.com> Date: Mon, 10 Feb 2014 16:13:50 +0000 X-Google-Sender-Auth: x9f5VOQzyWbAE9XSbbb1UaOYWRo Message-ID: From: George Dunlap To: Yang Zhang Cc: Andrew Cooper , Tim Deegan , Jan Beulich , "Zhang, Xiantao" , "xen-devel@lists.xen.org" Subject: Re: [Xen-devel] [PATCH] Don't track all memory when enabling log dirty to track vram X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org create ^ title it HAP dirty vram tracking breaks pass-through thanks On Mon, Feb 10, 2014 at 6:14 AM, Yang Zhang wrote: > From: Yang Zhang > > When enabling log dirty mode, it sets all guest's memory to readonly. > And in HAP enabled domain, it modifies all EPT entries to clear write bit > to make sure it is readonly. This will cause problem if VT-d shares page > table with EPT: the device may issue a DMA write request, then VT-d engine > tells it the target memory is readonly and result in VT-d fault. > > Currnetly, there are two places will enable log dirty mode: migration and vram > tracking. Migration with device assigned is not allowed, so it is ok. For vram, > it doesn't need to set all memory to readonly. Only track the vram range is enough. > > Signed-off-by: Yang Zhang > --- > xen/arch/x86/mm/hap/hap.c | 20 ++++++++++++++------ > xen/arch/x86/mm/paging.c | 9 +++++---- > xen/arch/x86/mm/shadow/common.c | 2 +- > xen/include/asm-x86/domain.h | 2 +- > xen/include/asm-x86/paging.h | 5 +++-- > xen/include/asm-x86/shadow.h | 2 +- > 6 files changed, 25 insertions(+), 15 deletions(-) > > diff --git a/xen/arch/x86/mm/hap/hap.c b/xen/arch/x86/mm/hap/hap.c > index d3f64bd..5f75636 100644 > --- a/xen/arch/x86/mm/hap/hap.c > +++ b/xen/arch/x86/mm/hap/hap.c > @@ -82,7 +82,7 @@ int hap_track_dirty_vram(struct domain *d, > if ( !paging_mode_log_dirty(d) ) > { > hap_logdirty_init(d); > - rc = paging_log_dirty_enable(d); > + rc = paging_log_dirty_enable(d, 0); > if ( rc ) > goto out; > } > @@ -167,17 +167,25 @@ out: > /* HAP LOG DIRTY SUPPORT */ > /************************************************/ > > -/* hap code to call when log_dirty is enable. return 0 if no problem found. */ > -static int hap_enable_log_dirty(struct domain *d) > +/* > + * hap code to call when log_dirty is enable. return 0 if no problem found. > + * > + * NB: Domain that having device assigned should not set log_global. Because > + * there is no way to track the memory updating from device. > + */ > +static int hap_enable_log_dirty(struct domain *d, bool_t log_global) > { > /* turn on PG_log_dirty bit in paging mode */ > paging_lock(d); > d->arch.paging.mode |= PG_log_dirty; > paging_unlock(d); > > - /* set l1e entries of P2M table to be read-only. */ > - p2m_change_entry_type_global(d, p2m_ram_rw, p2m_ram_logdirty); > - flush_tlb_mask(d->domain_dirty_cpumask); > + if ( log_global ) > + { > + /* set l1e entries of P2M table to be read-only. */ > + p2m_change_entry_type_global(d, p2m_ram_rw, p2m_ram_logdirty); > + flush_tlb_mask(d->domain_dirty_cpumask); > + } > return 0; > } > > diff --git a/xen/arch/x86/mm/paging.c b/xen/arch/x86/mm/paging.c > index 21344e5..ab5eacb 100644 > --- a/xen/arch/x86/mm/paging.c > +++ b/xen/arch/x86/mm/paging.c > @@ -164,7 +164,7 @@ void paging_free_log_dirty_bitmap(struct domain *d) > paging_unlock(d); > } > > -int paging_log_dirty_enable(struct domain *d) > +int paging_log_dirty_enable(struct domain *d, bool_t log_global) > { > int ret; > > @@ -172,7 +172,7 @@ int paging_log_dirty_enable(struct domain *d) > return -EINVAL; > > domain_pause(d); > - ret = d->arch.paging.log_dirty.enable_log_dirty(d); > + ret = d->arch.paging.log_dirty.enable_log_dirty(d, log_global); > domain_unpause(d); > > return ret; > @@ -489,7 +489,8 @@ void paging_log_dirty_range(struct domain *d, > * These function pointers must not be followed with the log-dirty lock held. > */ > void paging_log_dirty_init(struct domain *d, > - int (*enable_log_dirty)(struct domain *d), > + int (*enable_log_dirty)(struct domain *d, > + bool_t log_global), > int (*disable_log_dirty)(struct domain *d), > void (*clean_dirty_bitmap)(struct domain *d)) > { > @@ -590,7 +591,7 @@ int paging_domctl(struct domain *d, xen_domctl_shadow_op_t *sc, > case XEN_DOMCTL_SHADOW_OP_ENABLE_LOGDIRTY: > if ( hap_enabled(d) ) > hap_logdirty_init(d); > - return paging_log_dirty_enable(d); > + return paging_log_dirty_enable(d, 1); > > case XEN_DOMCTL_SHADOW_OP_OFF: > if ( paging_mode_log_dirty(d) ) > diff --git a/xen/arch/x86/mm/shadow/common.c b/xen/arch/x86/mm/shadow/common.c > index 0bfa595..11c6b62 100644 > --- a/xen/arch/x86/mm/shadow/common.c > +++ b/xen/arch/x86/mm/shadow/common.c > @@ -3418,7 +3418,7 @@ shadow_write_p2m_entry(struct vcpu *v, unsigned long gfn, > /* Shadow specific code which is called in paging_log_dirty_enable(). > * Return 0 if no problem found. > */ > -int shadow_enable_log_dirty(struct domain *d) > +int shadow_enable_log_dirty(struct domain *d, bool_t log_global) > { > int ret; > > diff --git a/xen/include/asm-x86/domain.h b/xen/include/asm-x86/domain.h > index ea72db2..4ff89f0 100644 > --- a/xen/include/asm-x86/domain.h > +++ b/xen/include/asm-x86/domain.h > @@ -169,7 +169,7 @@ struct log_dirty_domain { > unsigned int dirty_count; > > /* functions which are paging mode specific */ > - int (*enable_log_dirty )(struct domain *d); > + int (*enable_log_dirty )(struct domain *d, bool_t log_global); > int (*disable_log_dirty )(struct domain *d); > void (*clean_dirty_bitmap )(struct domain *d); > }; > diff --git a/xen/include/asm-x86/paging.h b/xen/include/asm-x86/paging.h > index cd7ee3b..8dd2a61 100644 > --- a/xen/include/asm-x86/paging.h > +++ b/xen/include/asm-x86/paging.h > @@ -143,14 +143,15 @@ void paging_log_dirty_range(struct domain *d, > uint8_t *dirty_bitmap); > > /* enable log dirty */ > -int paging_log_dirty_enable(struct domain *d); > +int paging_log_dirty_enable(struct domain *d, bool_t log_global); > > /* disable log dirty */ > int paging_log_dirty_disable(struct domain *d); > > /* log dirty initialization */ > void paging_log_dirty_init(struct domain *d, > - int (*enable_log_dirty)(struct domain *d), > + int (*enable_log_dirty)(struct domain *d, > + bool_t log_global), > int (*disable_log_dirty)(struct domain *d), > void (*clean_dirty_bitmap)(struct domain *d)); > > diff --git a/xen/include/asm-x86/shadow.h b/xen/include/asm-x86/shadow.h > index 852023d..348915e 100644 > --- a/xen/include/asm-x86/shadow.h > +++ b/xen/include/asm-x86/shadow.h > @@ -82,7 +82,7 @@ void shadow_teardown(struct domain *d); > void shadow_final_teardown(struct domain *d); > > /* shadow code to call when log dirty is enabled */ > -int shadow_enable_log_dirty(struct domain *d); > +int shadow_enable_log_dirty(struct domain *d, bool_t log_global); > > /* shadow code to call when log dirty is disabled */ > int shadow_disable_log_dirty(struct domain *d); > -- > 1.7.1 > > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xen.org > http://lists.xen.org/xen-devel _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel