xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH 4/8]: identity map, events, and xenbus related changes
@ 2012-08-16  1:03 Mukesh Rathor
  2012-08-16 14:14 ` Konrad Rzeszutek Wilk
  2012-08-17  9:34 ` Ian Campbell
  0 siblings, 2 replies; 4+ messages in thread
From: Mukesh Rathor @ 2012-08-16  1:03 UTC (permalink / raw)
  To: Konrad Rzeszutek Wilk, Xen-devel@lists.xensource.com


---
 arch/x86/xen/setup.c               |   32 +++++++++++++++++++++++++++-----
 drivers/xen/events.c               |    7 +++++++
 drivers/xen/xenbus/xenbus_client.c |    2 +-
 drivers/xen/xenbus/xenbus_probe.c  |    5 ++++-
 4 files changed, 39 insertions(+), 7 deletions(-)

diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c
index 936f21d..1c961fc 100644
--- a/arch/x86/xen/setup.c
+++ b/arch/x86/xen/setup.c
@@ -26,6 +26,7 @@
 #include <xen/interface/memory.h>
 #include <xen/interface/physdev.h>
 #include <xen/features.h>
+#include "mmu.h"
 #include "xen-ops.h"
 #include "vdso.h"
 
@@ -222,6 +223,20 @@ static void __init xen_set_identity_and_release_chunk(
 	*identity += set_phys_range_identity(start_pfn, end_pfn);
 }
 
+/* For PVH, the pfns [0..MAX] are mapped to mfn's in the EPT/NPT. The mfns
+ * are released as part of this 1:1 mapping hypercall. We can't balloon down
+ * any time later because when p2m/EPT is updated, the mfns are already lost.
+ * Also, we map the entire IO space, ie, beyond max_pfn_mapped.
+ */
+static void noinline __init xen_pvh_identity_map_chunk(unsigned long start_pfn,
+						       unsigned long end_pfn)
+{
+	unsigned long pfn;
+
+	for (pfn = start_pfn; pfn < end_pfn; pfn++)
+		xen_set_clr_mmio_pvh_pte(pfn, pfn, 1, 1);
+}
+
 static unsigned long __init xen_set_identity_and_release(
 	const struct e820entry *list, size_t map_size, unsigned long nr_pages)
 {
@@ -251,11 +266,18 @@ static unsigned long __init xen_set_identity_and_release(
 			if (entry->type == E820_RAM)
 				end_pfn = PFN_UP(entry->addr);
 
-			if (start_pfn < end_pfn)
-				xen_set_identity_and_release_chunk(
-					start_pfn, end_pfn, nr_pages,
-					&released, &identity);
-
+			if (start_pfn < end_pfn) {
+				if (xen_pvh_domain()) {
+					xen_pvh_identity_map_chunk(start_pfn,
+								   end_pfn);
+					released += end_pfn - start_pfn;
+					identity += end_pfn - start_pfn;
+				} else {
+					xen_set_identity_and_release_chunk(
+						start_pfn, end_pfn, nr_pages,
+						&released, &identity);
+				}
+			}
 			start = end;
 		}
 	}
diff --git a/drivers/xen/events.c b/drivers/xen/events.c
index 7595581..260113e 100644
--- a/drivers/xen/events.c
+++ b/drivers/xen/events.c
@@ -1814,6 +1814,13 @@ void __init xen_init_IRQ(void)
 		if (xen_initial_domain())
 			pci_xen_initial_domain();
 
+		if (xen_pvh_domain()) {
+			xen_callback_vector();
+			return;
+		}
+
+		/* PVH: TBD/FIXME: debug and fix eio map to work with pvh */
+
 		pirq_eoi_map = (void *)__get_free_page(GFP_KERNEL|__GFP_ZERO);
 		eoi_gmfn.gmfn = virt_to_mfn(pirq_eoi_map);
 		rc = HYPERVISOR_physdev_op(PHYSDEVOP_pirq_eoi_gmfn_v2, &eoi_gmfn);
diff --git a/drivers/xen/xenbus/xenbus_client.c b/drivers/xen/xenbus/xenbus_client.c
index b3e146e..c0fcff1 100644
--- a/drivers/xen/xenbus/xenbus_client.c
+++ b/drivers/xen/xenbus/xenbus_client.c
@@ -743,7 +743,7 @@ static const struct xenbus_ring_ops ring_ops_hvm = {
 
 void __init xenbus_ring_ops_init(void)
 {
-	if (xen_pv_domain())
+	if (xen_pv_domain() && !xen_pvh_domain())
 		ring_ops = &ring_ops_pv;
 	else
 		ring_ops = &ring_ops_hvm;
diff --git a/drivers/xen/xenbus/xenbus_probe.c b/drivers/xen/xenbus/xenbus_probe.c
index b793723..735dd5c 100644
--- a/drivers/xen/xenbus/xenbus_probe.c
+++ b/drivers/xen/xenbus/xenbus_probe.c
@@ -749,7 +749,10 @@ static int __init xenbus_init(void)
 			if (err)
 				goto out_error;
 		}
-		xen_store_interface = mfn_to_virt(xen_store_mfn);
+		if (xen_pvh_domain())
+			xen_store_interface = __va(xen_store_mfn<<PAGE_SHIFT);
+		else
+			xen_store_interface = mfn_to_virt(xen_store_mfn);
 	}
 
 	/* Initialize the interface to xenstore. */
-- 
1.7.2.3

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [RFC PATCH 4/8]: identity map, events, and xenbus related changes
  2012-08-16  1:03 [RFC PATCH 4/8]: identity map, events, and xenbus related changes Mukesh Rathor
@ 2012-08-16 14:14 ` Konrad Rzeszutek Wilk
  2012-08-17  9:34 ` Ian Campbell
  1 sibling, 0 replies; 4+ messages in thread
From: Konrad Rzeszutek Wilk @ 2012-08-16 14:14 UTC (permalink / raw)
  To: Mukesh Rathor; +Cc: Xen-devel@lists.xensource.com

On Wed, Aug 15, 2012 at 06:03:56PM -0700, Mukesh Rathor wrote:
> 
> ---
>  arch/x86/xen/setup.c               |   32 +++++++++++++++++++++++++++-----
>  drivers/xen/events.c               |    7 +++++++
>  drivers/xen/xenbus/xenbus_client.c |    2 +-
>  drivers/xen/xenbus/xenbus_probe.c  |    5 ++++-
>  4 files changed, 39 insertions(+), 7 deletions(-)
> 
> diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c
> index 936f21d..1c961fc 100644
> --- a/arch/x86/xen/setup.c
> +++ b/arch/x86/xen/setup.c
> @@ -26,6 +26,7 @@
>  #include <xen/interface/memory.h>
>  #include <xen/interface/physdev.h>
>  #include <xen/features.h>
> +#include "mmu.h"
>  #include "xen-ops.h"
>  #include "vdso.h"
>  
> @@ -222,6 +223,20 @@ static void __init xen_set_identity_and_release_chunk(
>  	*identity += set_phys_range_identity(start_pfn, end_pfn);
>  }
>  
> +/* For PVH, the pfns [0..MAX] are mapped to mfn's in the EPT/NPT. The mfns
> + * are released as part of this 1:1 mapping hypercall. We can't balloon down
> + * any time later because when p2m/EPT is updated, the mfns are already lost.
> + * Also, we map the entire IO space, ie, beyond max_pfn_mapped.

> + */
> +static void noinline __init xen_pvh_identity_map_chunk(unsigned long start_pfn,
> +						       unsigned long end_pfn)
> +{
> +	unsigned long pfn;
> +
> +	for (pfn = start_pfn; pfn < end_pfn; pfn++)
> +		xen_set_clr_mmio_pvh_pte(pfn, pfn, 1, 1);

Include a comment for what the '1' and '1' are for? Like:
		xen_set..(pfn, pfn, 1 /* Enable clearing */, 1 /* Do something .. */

> +}
> +
>  static unsigned long __init xen_set_identity_and_release(
>  	const struct e820entry *list, size_t map_size, unsigned long nr_pages)
>  {
> @@ -251,11 +266,18 @@ static unsigned long __init xen_set_identity_and_release(
>  			if (entry->type == E820_RAM)
>  				end_pfn = PFN_UP(entry->addr);
>  
> -			if (start_pfn < end_pfn)
> -				xen_set_identity_and_release_chunk(
> -					start_pfn, end_pfn, nr_pages,
> -					&released, &identity);
> -
> +			if (start_pfn < end_pfn) {
> +				if (xen_pvh_domain()) {
> +					xen_pvh_identity_map_chunk(start_pfn,
> +								   end_pfn);
> +					released += end_pfn - start_pfn;
> +					identity += end_pfn - start_pfn;
> +				} else {
> +					xen_set_identity_and_release_chunk(
> +						start_pfn, end_pfn, nr_pages,
> +						&released, &identity);
> +				}
> +			}
>  			start = end;
>  		}
>  	}
> diff --git a/drivers/xen/events.c b/drivers/xen/events.c
> index 7595581..260113e 100644
> --- a/drivers/xen/events.c
> +++ b/drivers/xen/events.c
> @@ -1814,6 +1814,13 @@ void __init xen_init_IRQ(void)
>  		if (xen_initial_domain())
>  			pci_xen_initial_domain();
>  
> +		if (xen_pvh_domain()) {
> +			xen_callback_vector();
> +			return;
> +		}
> +
> +		/* PVH: TBD/FIXME: debug and fix eio map to work with pvh */
> +
>  		pirq_eoi_map = (void *)__get_free_page(GFP_KERNEL|__GFP_ZERO);
>  		eoi_gmfn.gmfn = virt_to_mfn(pirq_eoi_map);
>  		rc = HYPERVISOR_physdev_op(PHYSDEVOP_pirq_eoi_gmfn_v2, &eoi_gmfn);
> diff --git a/drivers/xen/xenbus/xenbus_client.c b/drivers/xen/xenbus/xenbus_client.c
> index b3e146e..c0fcff1 100644
> --- a/drivers/xen/xenbus/xenbus_client.c
> +++ b/drivers/xen/xenbus/xenbus_client.c
> @@ -743,7 +743,7 @@ static const struct xenbus_ring_ops ring_ops_hvm = {
>  
>  void __init xenbus_ring_ops_init(void)
>  {
> -	if (xen_pv_domain())
> +	if (xen_pv_domain() && !xen_pvh_domain())
>  		ring_ops = &ring_ops_pv;
>  	else
>  		ring_ops = &ring_ops_hvm;
> diff --git a/drivers/xen/xenbus/xenbus_probe.c b/drivers/xen/xenbus/xenbus_probe.c
> index b793723..735dd5c 100644
> --- a/drivers/xen/xenbus/xenbus_probe.c
> +++ b/drivers/xen/xenbus/xenbus_probe.c
> @@ -749,7 +749,10 @@ static int __init xenbus_init(void)
>  			if (err)
>  				goto out_error;
>  		}
> -		xen_store_interface = mfn_to_virt(xen_store_mfn);
> +		if (xen_pvh_domain())
> +			xen_store_interface = __va(xen_store_mfn<<PAGE_SHIFT);
> +		else
> +			xen_store_interface = mfn_to_virt(xen_store_mfn);
>  	}
>  
>  	/* Initialize the interface to xenstore. */
> -- 
> 1.7.2.3

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFC PATCH 4/8]: identity map, events, and xenbus related changes
  2012-08-16  1:03 [RFC PATCH 4/8]: identity map, events, and xenbus related changes Mukesh Rathor
  2012-08-16 14:14 ` Konrad Rzeszutek Wilk
@ 2012-08-17  9:34 ` Ian Campbell
  2012-08-17 23:55   ` Mukesh Rathor
  1 sibling, 1 reply; 4+ messages in thread
From: Ian Campbell @ 2012-08-17  9:34 UTC (permalink / raw)
  To: Mukesh Rathor; +Cc: Xen-devel@lists.xensource.com, Konrad Rzeszutek Wilk

On Thu, 2012-08-16 at 02:03 +0100, Mukesh Rathor wrote:
> +				if (xen_pvh_domain()) {
> +					xen_pvh_identity_map_chunk(start_pfn,
> +								   end_pfn);
> +					released += end_pfn - start_pfn;
> +					identity += end_pfn - start_pfn;

In the non pvh case this is done inside
xen_set_identity_and_release_chunk. I think the interface ought to be
the same in both halves of the if.

Not sure if it makes sense to push the if down into
xen_set_identity_and_release_chunk, I think the PVH case doesn't do the
release bit?

(what does happen to the old backing MFN in this case?)

> +				} else {
> +					xen_set_identity_and_release_chunk(
> +						start_pfn, end_pfn, nr_pages,
> +						&released, &identity);
> +				}
> +			}
>  			start = end;
>  		}
>  	}
> diff --git a/drivers/xen/events.c b/drivers/xen/events.c
> index 7595581..260113e 100644
> --- a/drivers/xen/events.c
> +++ b/drivers/xen/events.c
> @@ -1814,6 +1814,13 @@ void __init xen_init_IRQ(void)
>  		if (xen_initial_domain())
>  			pci_xen_initial_domain();
>  
> +		if (xen_pvh_domain()) {
> +			xen_callback_vector();

The definition of this function is surrounded by CONFIG_XEN_PVHVM, or
did I miss where you removed that and/or the appropriate Kconfig runes
to make it so?

Ian.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFC PATCH 4/8]: identity map, events, and xenbus related changes
  2012-08-17  9:34 ` Ian Campbell
@ 2012-08-17 23:55   ` Mukesh Rathor
  0 siblings, 0 replies; 4+ messages in thread
From: Mukesh Rathor @ 2012-08-17 23:55 UTC (permalink / raw)
  To: Ian Campbell; +Cc: Xen-devel@lists.xensource.com, Konrad Rzeszutek Wilk

> > diff --git a/drivers/xen/events.c b/drivers/xen/events.c
> > index 7595581..260113e 100644
> > --- a/drivers/xen/events.c
> > +++ b/drivers/xen/events.c
> > @@ -1814,6 +1814,13 @@ void __init xen_init_IRQ(void)
> >  		if (xen_initial_domain())
> >  			pci_xen_initial_domain();
> >  
> > +		if (xen_pvh_domain()) {
> > +			xen_callback_vector();
> 
> The definition of this function is surrounded by CONFIG_XEN_PVHVM, or
> did I miss where you removed that and/or the appropriate Kconfig runes
> to make it so?

Right. I really dislike the zillion config options. Since this is used by
PV now, we can remove the PVHVM restriction on it.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-08-17 23:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-16  1:03 [RFC PATCH 4/8]: identity map, events, and xenbus related changes Mukesh Rathor
2012-08-16 14:14 ` Konrad Rzeszutek Wilk
2012-08-17  9:34 ` Ian Campbell
2012-08-17 23:55   ` Mukesh Rathor

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).