From: George Dunlap <George.Dunlap@eu.citrix.com>
To: Yang Zhang <yang.z.zhang@intel.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
Tim Deegan <tim@xen.org>, Jan Beulich <JBeulich@suse.com>,
"Zhang, Xiantao" <xiantao.zhang@intel.com>,
"xen-devel@lists.xen.org" <xen-devel@lists.xen.org>
Subject: Re: [PATCH] Don't track all memory when enabling log dirty to track vram
Date: Mon, 10 Feb 2014 16:13:50 +0000 [thread overview]
Message-ID: <CAFLBxZYrQf6w3N_uz4=6eEyKL_rU6EcDoKSD90ASSUt1jOLBkw@mail.gmail.com> (raw)
In-Reply-To: <1392012840-22555-1-git-send-email-yang.z.zhang@intel.com>
create ^
title it HAP dirty vram tracking breaks pass-through
thanks
On Mon, Feb 10, 2014 at 6:14 AM, Yang Zhang <yang.z.zhang@intel.com> wrote:
> From: Yang Zhang <yang.z.zhang@Intel.com>
>
> 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 <yang.z.zhang@Intel.com>
> ---
> 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
next prev parent reply other threads:[~2014-02-10 16:13 UTC|newest]
Thread overview: 62+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-10 6:14 [PATCH] Don't track all memory when enabling log dirty to track vram Yang Zhang
2014-02-10 8:03 ` Tim Deegan
2014-02-10 8:15 ` Zhang, Yang Z
2014-02-11 9:02 ` Tim Deegan
2014-02-11 10:59 ` George Dunlap
2014-02-11 11:55 ` Tim Deegan
2014-02-11 12:57 ` Jan Beulich
2014-02-11 15:55 ` George Dunlap
2014-02-12 0:53 ` Zhang, Yang Z
2014-02-13 15:46 ` George Dunlap
2014-02-13 15:55 ` Jan Beulich
2014-02-13 16:20 ` Tim Deegan
2014-02-13 16:25 ` George Dunlap
2014-02-13 16:45 ` Processed: " xen
2014-02-17 10:18 ` Jan Beulich
2014-02-17 12:23 ` George Dunlap
2014-02-17 12:37 ` Jan Beulich
2014-02-17 14:51 ` George Dunlap
2014-02-17 15:05 ` Jan Beulich
2014-02-18 3:14 ` Zhang, Yang Z
2014-02-18 10:26 ` George Dunlap
2014-02-19 1:28 ` Zhang, Yang Z
2014-02-19 8:55 ` Jan Beulich
2014-02-19 11:03 ` George Dunlap
2014-02-19 11:13 ` Jan Beulich
2014-02-19 11:17 ` George Dunlap
2014-02-17 15:00 ` Jan Beulich
2014-02-18 3:25 ` Zhang, Yang Z
2014-02-18 8:45 ` Jan Beulich
2014-02-18 11:46 ` Jan Beulich
2014-02-18 15:28 ` Jan Beulich
2014-02-19 6:40 ` Xu, Dongxiao
2014-02-19 1:17 ` Zhang, Yang Z
2014-02-19 8:50 ` Jan Beulich
2014-02-18 8:30 ` Jan Beulich
2014-05-19 7:48 ` Zhang, Yang Z
2014-05-19 9:03 ` Jan Beulich
2014-05-20 3:09 ` Zhang, Yang Z
2014-05-20 7:17 ` Jan Beulich
2014-05-19 13:27 ` George Dunlap
2014-05-19 13:50 ` Jan Beulich
2014-05-19 13:59 ` George Dunlap
2014-05-19 14:19 ` Jan Beulich
2014-05-20 3:13 ` Zhang, Yang Z
2014-05-20 7:20 ` Jan Beulich
2014-05-20 10:12 ` George Dunlap
2014-05-20 10:46 ` Jan Beulich
2014-05-21 1:02 ` Zhang, Yang Z
2014-05-21 7:49 ` Jan Beulich
2014-05-21 8:37 ` Zhang, Yang Z
2014-05-21 9:58 ` Jan Beulich
2014-05-23 6:42 ` Jan Beulich
2014-05-26 8:16 ` Zhang, Yang Z
2014-05-26 9:04 ` Jan Beulich
2014-05-31 1:26 ` Nakajima, Jun
2014-06-02 6:55 ` Jan Beulich
2014-06-02 14:06 ` George Dunlap
2014-06-02 14:27 ` Jan Beulich
2014-06-02 15:03 ` George Dunlap
2014-02-10 10:42 ` Andrew Cooper
2014-02-10 16:13 ` George Dunlap [this message]
2014-02-10 16:30 ` Processed: " xen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAFLBxZYrQf6w3N_uz4=6eEyKL_rU6EcDoKSD90ASSUt1jOLBkw@mail.gmail.com' \
--to=george.dunlap@eu.citrix.com \
--cc=JBeulich@suse.com \
--cc=andrew.cooper3@citrix.com \
--cc=tim@xen.org \
--cc=xen-devel@lists.xen.org \
--cc=xiantao.zhang@intel.com \
--cc=yang.z.zhang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).