public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org,
	boris.ostrovsky@oracle.com, david.vrabel@citrix.com,
	mukesh.rathor@oracle.com, jbeulich@suse.com
Subject: Re: [Xen-devel] [PATCH v11 03/12] xen/pvh: Early bootup changes in PV code.
Date: Wed, 18 Dec 2013 09:58:52 -0500	[thread overview]
Message-ID: <20131218145852.GC4934@phenom.dumpdata.com> (raw)
In-Reply-To: <alpine.DEB.2.02.1312181423380.8667@kaball.uk.xensource.com>

On Wed, Dec 18, 2013 at 02:27:08PM +0000, Stefano Stabellini wrote:
> On Tue, 17 Dec 2013, Konrad Rzeszutek Wilk wrote:
> > From: Mukesh Rathor <mukesh.rathor@oracle.com>
> > 
> > In the bootup code for PVH we can trap cpuid via vmexit, so don't
> > need to use emulated prefix call. We also check for vector callback
> > early on, as it is a required feature. PVH also runs at default kernel
> > IOPL.
> > 
> > Finally, pure PV settings are moved to a separate function that are
> > only called for pure PV, ie, pv with pvmmu. They are also #ifdef
> > with CONFIG_XEN_PVMMU.
> > 
> > Signed-off-by: Mukesh Rathor <mukesh.rathor@oracle.com>
> > Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> > ---
> >  arch/x86/xen/enlighten.c | 63 +++++++++++++++++++++++++++++++++---------------
> >  arch/x86/xen/setup.c     | 18 +++++++++-----
> >  2 files changed, 56 insertions(+), 25 deletions(-)
> > 
> > diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
> > index fa6ade7..3b21c82 100644
> > --- a/arch/x86/xen/enlighten.c
> > +++ b/arch/x86/xen/enlighten.c
> > @@ -46,6 +46,7 @@
> >  #include <xen/hvm.h>
> >  #include <xen/hvc-console.h>
> >  #include <xen/acpi.h>
> > +#include <xen/features.h>
> >  
> >  #include <asm/paravirt.h>
> >  #include <asm/apic.h>
> > @@ -262,8 +263,9 @@ static void __init xen_banner(void)
> >  	struct xen_extraversion extra;
> >  	HYPERVISOR_xen_version(XENVER_extraversion, &extra);
> >  
> > -	printk(KERN_INFO "Booting paravirtualized kernel on %s\n",
> > -	       pv_info.name);
> > +	pr_info("Booting paravirtualized kernel %son %s\n",
> > +		xen_feature(XENFEAT_auto_translated_physmap) ?
> > +			"with PVH extensions " : "", pv_info.name);
> >  	printk(KERN_INFO "Xen version: %d.%d%s%s\n",
> >  	       version >> 16, version & 0xffff, extra.extraversion,
> >  	       xen_feature(XENFEAT_mmu_pt_update_preserve_ad) ? " (preserve-AD)" : "");
> > @@ -331,12 +333,15 @@ static void xen_cpuid(unsigned int *ax, unsigned int *bx,
> >  		break;
> >  	}
> >  
> > -	asm(XEN_EMULATE_PREFIX "cpuid"
> > -		: "=a" (*ax),
> > -		  "=b" (*bx),
> > -		  "=c" (*cx),
> > -		  "=d" (*dx)
> > -		: "0" (*ax), "2" (*cx));
> > +	if (xen_pvh_domain())
> > +		native_cpuid(ax, bx, cx, dx);
> > +	else
> > +		asm(XEN_EMULATE_PREFIX "cpuid"
> > +			: "=a" (*ax),
> > +			"=b" (*bx),
> > +			"=c" (*cx),
> > +			"=d" (*dx)
> > +			: "0" (*ax), "2" (*cx));
> >  
> >  	*bx &= maskebx;
> >  	*cx &= maskecx;
> > @@ -1420,6 +1425,19 @@ static void __init xen_setup_stackprotector(void)
> >  	pv_cpu_ops.load_gdt = xen_load_gdt;
> >  }
> >  
> > +static void __init xen_pvh_early_guest_init(void)
> > +{
> > +	if (xen_feature(XENFEAT_hvm_callback_vector))
> > +		xen_have_vector_callback = 1;
> > +
> > +#ifdef CONFIG_X86_32
> > +	if (xen_feature(XENFEAT_auto_translated_physmap)) {
> > +		xen_raw_printk("ERROR: 32bit PVH guests are not supported\n");
> > +		BUG();
> > +	}
> > +#endif
> 
> Shouldn't we detect this error at build time?

You can't even set the XEN_PVH for 32-bit.
> If so, does it make sense to check for it at run time too?
> 

I think I might as well rip that out - as that code won't be ever
touched. And perhaps just stash in a BUG with /* PVH: FIXME */?


> The rest looks OK to me.

Thank you!
> 
> > +}
> > +
> >  /* First C function to be called on Xen boot */
> >  asmlinkage void __init xen_start_kernel(void)
> >  {
> > @@ -1431,13 +1449,18 @@ asmlinkage void __init xen_start_kernel(void)
> >  
> >  	xen_domain_type = XEN_PV_DOMAIN;
> >  
> > +	xen_setup_features();
> > +	xen_pvh_early_guest_init();
> >  	xen_setup_machphys_mapping();
> >  
> >  	/* Install Xen paravirt ops */
> >  	pv_info = xen_info;
> >  	pv_init_ops = xen_init_ops;
> > -	pv_cpu_ops = xen_cpu_ops;
> >  	pv_apic_ops = xen_apic_ops;
> > +	if (xen_pvh_domain())
> > +		pv_cpu_ops.cpuid = xen_cpuid;
> > +	else
> > +		pv_cpu_ops = xen_cpu_ops;
> >  
> >  	x86_init.resources.memory_setup = xen_memory_setup;
> >  	x86_init.oem.arch_setup = xen_arch_setup;
> > @@ -1469,8 +1492,6 @@ asmlinkage void __init xen_start_kernel(void)
> >  	/* Work out if we support NX */
> >  	x86_configure_nx();
> >  
> > -	xen_setup_features();
> > -
> >  	/* Get mfn list */
> >  	if (!xen_feature(XENFEAT_auto_translated_physmap))
> >  		xen_build_dynamic_phys_to_machine();
> > @@ -1548,14 +1569,18 @@ asmlinkage void __init xen_start_kernel(void)
> >  	/* set the limit of our address space */
> >  	xen_reserve_top();
> >  
> > -	/* We used to do this in xen_arch_setup, but that is too late on AMD
> > -	 * were early_cpu_init (run before ->arch_setup()) calls early_amd_init
> > -	 * which pokes 0xcf8 port.
> > -	 */
> > -	set_iopl.iopl = 1;
> > -	rc = HYPERVISOR_physdev_op(PHYSDEVOP_set_iopl, &set_iopl);
> > -	if (rc != 0)
> > -		xen_raw_printk("physdev_op failed %d\n", rc);
> > +	/* PVH: runs at default kernel iopl of 0 */
> > +	if (!xen_pvh_domain()) {
> > +		/*
> > +		 * We used to do this in xen_arch_setup, but that is too late
> > +		 * on AMD were early_cpu_init (run before ->arch_setup()) calls
> > +		 * early_amd_init which pokes 0xcf8 port.
> > +		 */
> > +		set_iopl.iopl = 1;
> > +		rc = HYPERVISOR_physdev_op(PHYSDEVOP_set_iopl, &set_iopl);
> > +		if (rc != 0)
> > +			xen_raw_printk("physdev_op failed %d\n", rc);
> > +	}
> >  
> >  #ifdef CONFIG_X86_32
> >  	/* set up basic CPUID stuff */
> > diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c
> > index 68c054f..2137c51 100644
> > --- a/arch/x86/xen/setup.c
> > +++ b/arch/x86/xen/setup.c
> > @@ -563,16 +563,13 @@ void xen_enable_nmi(void)
> >  		BUG();
> >  #endif
> >  }
> > -void __init xen_arch_setup(void)
> > +void __init xen_pvmmu_arch_setup(void)
> >  {
> > -	xen_panic_handler_init();
> > -
> >  	HYPERVISOR_vm_assist(VMASST_CMD_enable, VMASST_TYPE_4gb_segments);
> >  	HYPERVISOR_vm_assist(VMASST_CMD_enable, VMASST_TYPE_writable_pagetables);
> >  
> > -	if (!xen_feature(XENFEAT_auto_translated_physmap))
> > -		HYPERVISOR_vm_assist(VMASST_CMD_enable,
> > -				     VMASST_TYPE_pae_extended_cr3);
> > +	HYPERVISOR_vm_assist(VMASST_CMD_enable,
> > +			     VMASST_TYPE_pae_extended_cr3);
> >  
> >  	if (register_callback(CALLBACKTYPE_event, xen_hypervisor_callback) ||
> >  	    register_callback(CALLBACKTYPE_failsafe, xen_failsafe_callback))
> > @@ -581,6 +578,15 @@ void __init xen_arch_setup(void)
> >  	xen_enable_sysenter();
> >  	xen_enable_syscall();
> >  	xen_enable_nmi();
> > +}
> > +
> > +/* This function is not called for HVM domains */
> > +void __init xen_arch_setup(void)
> > +{
> > +	xen_panic_handler_init();
> > +	if (!xen_feature(XENFEAT_auto_translated_physmap))
> > +		xen_pvmmu_arch_setup();
> > +
> >  #ifdef CONFIG_ACPI
> >  	if (!(xen_start_info->flags & SIF_INITDOMAIN)) {
> >  		printk(KERN_INFO "ACPI in unprivileged domain disabled\n");
> > -- 
> > 1.8.3.1
> > 
> > 
> > _______________________________________________
> > Xen-devel mailing list
> > Xen-devel@lists.xen.org
> > http://lists.xen.org/xen-devel
> > 

  reply	other threads:[~2013-12-18 15:00 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-17 20:51 [PATCH v11] PVH support for Linux kernel Konrad Rzeszutek Wilk
2013-12-17 20:51 ` [PATCH v11 01/12] xen/p2m: Check for auto-xlat when doing mfn_to_local_pfn Konrad Rzeszutek Wilk
2013-12-18 14:10   ` [Xen-devel] " Stefano Stabellini
2013-12-17 20:51 ` [PATCH v11 02/12] xen/pvh: Define what an PVH guest is Konrad Rzeszutek Wilk
2013-12-18 14:22   ` [Xen-devel] " Stefano Stabellini
2013-12-18 14:55     ` Stefano Stabellini
2013-12-18 16:01       ` Ian Campbell
2013-12-18 16:58         ` Konrad Rzeszutek Wilk
2013-12-18 17:03           ` Ian Campbell
2013-12-18 14:57     ` Konrad Rzeszutek Wilk
2013-12-17 20:51 ` [PATCH v11 03/12] xen/pvh: Early bootup changes in PV code Konrad Rzeszutek Wilk
2013-12-18 14:27   ` [Xen-devel] " Stefano Stabellini
2013-12-18 14:58     ` Konrad Rzeszutek Wilk [this message]
2013-12-18 15:05       ` Stefano Stabellini
2013-12-17 20:51 ` [PATCH v11 04/12] xen/pvh: Don't setup P2M tree Konrad Rzeszutek Wilk
2013-12-18 14:39   ` [Xen-devel] " Stefano Stabellini
2013-12-18 15:05     ` Konrad Rzeszutek Wilk
2013-12-17 20:51 ` [PATCH v11 05/12] xen/pvh: Update E820 to work with PVH Konrad Rzeszutek Wilk
2013-12-18 18:25   ` [Xen-devel] " Stefano Stabellini
2013-12-18 20:30     ` Konrad Rzeszutek Wilk
2013-12-18 23:44     ` Mukesh Rathor
2013-12-19 11:25       ` Stefano Stabellini
2013-12-17 20:51 ` [PATCH v11 06/12] xen/pvh: Load GDT/GS in early PV bootup code for BSP Konrad Rzeszutek Wilk
2013-12-17 20:51 ` [PATCH v11 07/12] xen/pvh: Secondary VCPU bringup (non-bootup CPUs) Konrad Rzeszutek Wilk
2013-12-17 20:51 ` [PATCH v11 08/12] xen/pvh: MMU changes for PVH Konrad Rzeszutek Wilk
2013-12-18 14:48   ` [Xen-devel] " Stefano Stabellini
2013-12-18 15:10     ` Konrad Rzeszutek Wilk
2013-12-18 15:15       ` Stefano Stabellini
2013-12-17 20:51 ` [PATCH v11 09/12] xen/pvh: Piggyback on PVHVM XenBus and event channels " Konrad Rzeszutek Wilk
2013-12-18 18:31   ` [Xen-devel] " Stefano Stabellini
2013-12-18 21:17     ` Konrad Rzeszutek Wilk
2014-01-04  0:48       ` Mukesh Rathor
2014-01-05 17:18         ` Stefano Stabellini
2013-12-31 18:56     ` Konrad Rzeszutek Wilk
2014-01-03 15:04       ` Stefano Stabellini
2014-01-04  0:29         ` Mukesh Rathor
2013-12-17 20:51 ` [PATCH v11 10/12] xen/pvh: Piggyback on PVHVM for grant driver Konrad Rzeszutek Wilk
2013-12-18 18:46   ` [Xen-devel] " Stefano Stabellini
2013-12-18 21:21     ` Konrad Rzeszutek Wilk
2014-01-03 15:10       ` Stefano Stabellini
2013-12-17 20:51 ` [PATCH v11 11/12] xen/pvh: Disable PV code that does not work with PVH Konrad Rzeszutek Wilk
2013-12-18 14:19   ` [Xen-devel] " Stefano Stabellini
2013-12-18 14:56     ` Konrad Rzeszutek Wilk
2013-12-18 15:22       ` Stefano Stabellini
2013-12-17 20:51 ` [PATCH v11 12/12] xen/pvh: Support ParaVirtualized Hardware extensions Konrad Rzeszutek Wilk
2013-12-18 14:52   ` [Xen-devel] " Stefano Stabellini

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=20131218145852.GC4934@phenom.dumpdata.com \
    --to=konrad.wilk@oracle.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=david.vrabel@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mukesh.rathor@oracle.com \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=xen-devel@lists.xenproject.org \
    /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