From: David Vrabel <david.vrabel@citrix.com>
To: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: <linux-kernel@vger.kernel.org>, <xen-devel@lists.xenproject.org>,
<boris.ostrovsky@oracle.com>, <stefano.stabellini@eu.citrix.com>,
<mukesh.rathor@oracle.com>
Subject: Re: [PATCH v12 08/18] xen/pvh: Load GDT/GS in early PV bootup code for BSP.
Date: Thu, 2 Jan 2014 11:31:12 +0000 [thread overview]
Message-ID: <52C54E00.7010508@citrix.com> (raw)
In-Reply-To: <1388550945-25499-9-git-send-email-konrad.wilk@oracle.com>
On 01/01/14 04:35, Konrad Rzeszutek Wilk wrote:
> From: Mukesh Rathor <mukesh.rathor@oracle.com>
>
> During early bootup we start life using the Xen provided
> GDT, which means that we are running with %cs segment set
> to FLAT_KERNEL_CS (FLAT_RING3_CS64 0xe033, GDT index 261).
>
> But for PVH we want to be use HVM type mechanism for
> segment operations. As such we need to switch to the HVM
> one and also reload ourselves with the __KERNEL_CS:eip
> to run in the proper GDT and segment.
>
> For HVM this is usually done in 'secondary_startup_64' in
> (head_64.S) but since we are not taking that bootup
> path (we start in PV - xen_start_kernel) we need to do
> that in the early PV bootup paths.
>
> For good measure we also zero out the %fs, %ds, and %es
> (not strictly needed as Xen has already cleared them
> for us). The %gs is loaded by 'switch_to_new_gdt'.
[...]
> --- a/arch/x86/xen/enlighten.c
> +++ b/arch/x86/xen/enlighten.c
> @@ -1414,8 +1414,43 @@ static void __init xen_boot_params_init_edd(void)
> * we do this, we have to be careful not to call any stack-protected
> * function, which is most of the kernel.
> */
> -static void __init xen_setup_stackprotector(void)
> +static void __init xen_setup_gdt(void)
> {
> + if (xen_feature(XENFEAT_auto_translated_physmap)) {
> +#ifdef CONFIG_X86_64
> + unsigned long dummy;
> +
> + switch_to_new_gdt(0); /* GDT and GS set */
> +
> + /* We are switching of the Xen provided GDT to our HVM mode
> + * GDT. The new GDT has __KERNEL_CS with CS.L = 1
> + * and we are jumping to reload it.
> + */
> + asm volatile ("pushq %0\n"
> + "leaq 1f(%%rip),%0\n"
> + "pushq %0\n"
> + "lretq\n"
> + "1:\n"
> + : "=&r" (dummy) : "0" (__KERNEL_CS));
> +
> + /*
> + * While not needed, we also set the %es, %ds, and %fs
> + * to zero. We don't care about %ss as it is NULL.
> + * Strictly speaking this is not needed as Xen zeros those
> + * out (and also MSR_FS_BASE, MSR_GS_BASE, MSR_KERNEL_GS_BASE)
> + *
> + * Linux zeros them in cpu_init() and in secondary_startup_64
> + * (for BSP).
> + */
> + loadsegment(es, 0);
> + loadsegment(ds, 0);
> + loadsegment(fs, 0);
> +#else
> + /* PVH: TODO Implement. */
> + BUG();
> +#endif
> + return;
> + }
> pv_cpu_ops.write_gdt_entry = xen_write_gdt_entry_boot;
> pv_cpu_ops.load_gdt = xen_load_gdt_boot;
If PVH uses native GDT why are these (and possibly other?) GDT ops needed?
David
next prev parent reply other threads:[~2014-01-02 11:31 UTC|newest]
Thread overview: 90+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-01 4:35 [PATCH v12] Linux Xen PVH support Konrad Rzeszutek Wilk
2014-01-01 4:35 ` [PATCH v12 01/18] xen/p2m: Check for auto-xlat when doing mfn_to_local_pfn Konrad Rzeszutek Wilk
2014-01-01 4:35 ` [PATCH v12 02/18] xen/pvh/x86: Define what an PVH guest is (v2) Konrad Rzeszutek Wilk
2014-01-02 11:13 ` David Vrabel
2014-01-03 15:33 ` Stefano Stabellini
2014-01-01 4:35 ` [PATCH v12 03/18] xen/pvh: Early bootup changes in PV code (v2) Konrad Rzeszutek Wilk
2014-01-02 15:32 ` David Vrabel
2014-01-02 18:32 ` Konrad Rzeszutek Wilk
2014-01-03 1:34 ` Mukesh Rathor
2014-01-03 11:29 ` David Vrabel
2014-01-03 15:37 ` Stefano Stabellini
2014-01-03 17:35 ` Konrad Rzeszutek Wilk
2014-01-04 1:13 ` Mukesh Rathor
2014-01-03 11:25 ` David Vrabel
2014-01-01 4:35 ` [PATCH v12 04/18] xen/pvh: Don't setup P2M tree Konrad Rzeszutek Wilk
2014-01-02 11:17 ` David Vrabel
2014-01-03 15:41 ` Stefano Stabellini
2014-01-01 4:35 ` [PATCH v12 05/18] xen/mmu/p2m: Refactor the xen_pagetable_init code Konrad Rzeszutek Wilk
2014-01-02 11:21 ` David Vrabel
2014-01-03 15:47 ` Stefano Stabellini
2014-01-03 16:02 ` Konrad Rzeszutek Wilk
2014-01-03 16:23 ` Stefano Stabellini
2014-01-01 4:35 ` [PATCH v12 06/18] xen/pvh: MMU changes for PVH (v2) Konrad Rzeszutek Wilk
2014-01-02 11:24 ` David Vrabel
2014-01-03 1:36 ` Mukesh Rathor
2014-01-03 10:14 ` David Vrabel
2014-01-03 15:50 ` Stefano Stabellini
2014-01-01 4:35 ` [PATCH v12 07/18] xen/pvh: Setup up shared_info Konrad Rzeszutek Wilk
2014-01-02 11:27 ` David Vrabel
2014-01-02 18:23 ` Konrad Rzeszutek Wilk
2014-01-03 14:39 ` Konrad Rzeszutek Wilk
2014-01-03 15:18 ` David Vrabel
2014-01-01 4:35 ` [PATCH v12 08/18] xen/pvh: Load GDT/GS in early PV bootup code for BSP Konrad Rzeszutek Wilk
2014-01-02 11:31 ` David Vrabel [this message]
2014-01-02 18:24 ` Konrad Rzeszutek Wilk
2014-01-03 11:27 ` David Vrabel
2014-01-01 4:35 ` [PATCH v12 09/18] xen/pvh: Secondary VCPU bringup (non-bootup CPUs) Konrad Rzeszutek Wilk
2014-01-02 16:07 ` David Vrabel
2014-01-01 4:35 ` [PATCH v12 10/18] xen/pvh: Update E820 to work with PVH (v2) Konrad Rzeszutek Wilk
2014-01-02 16:14 ` David Vrabel
2014-01-02 18:41 ` Konrad Rzeszutek Wilk
2014-01-04 1:23 ` Mukesh Rathor
2014-01-04 2:25 ` Konrad Rzeszutek Wilk
2014-01-03 16:30 ` Stefano Stabellini
2014-01-01 4:35 ` [PATCH v12 11/18] xen/pvh: Piggyback on PVHVM for event channels (v2) Konrad Rzeszutek Wilk
2014-01-02 15:43 ` David Vrabel
2014-01-03 16:34 ` Stefano Stabellini
2014-01-03 18:10 ` Konrad Rzeszutek Wilk
2014-01-01 4:35 ` [PATCH v12 12/18] xen/grants: Remove gnttab_max_grant_frames dependency on gnttab_init Konrad Rzeszutek Wilk
2014-01-02 11:38 ` David Vrabel
2014-01-03 16:40 ` Stefano Stabellini
2014-01-01 4:35 ` [PATCH v12 13/18] xen/grant-table: Refactor gnttab_init Konrad Rzeszutek Wilk
2014-01-02 11:39 ` David Vrabel
2014-01-03 16:43 ` Stefano Stabellini
2014-01-01 4:35 ` [PATCH v12 14/18] xen/grant: Implement an grant frame array struct Konrad Rzeszutek Wilk
2014-01-02 16:27 ` David Vrabel
2014-01-02 18:47 ` Konrad Rzeszutek Wilk
2014-01-03 12:11 ` [Xen-devel] " David Vrabel
2014-01-03 15:09 ` Konrad Rzeszutek Wilk
2014-01-03 16:53 ` Stefano Stabellini
2014-01-03 19:18 ` [Xen-devel] " Konrad Rzeszutek Wilk
2014-01-01 4:35 ` [PATCH v12 15/18] xen/pvh: Piggyback on PVHVM for grant driver (v2) Konrad Rzeszutek Wilk
2014-01-02 16:32 ` David Vrabel
2014-01-02 18:50 ` Konrad Rzeszutek Wilk
2014-01-03 11:54 ` David Vrabel
2014-01-03 14:44 ` Konrad Rzeszutek Wilk
2014-01-03 15:41 ` David Vrabel
2014-01-03 15:48 ` [Xen-devel] " Konrad Rzeszutek Wilk
2014-01-03 17:20 ` Stefano Stabellini
2014-01-03 18:14 ` Konrad Rzeszutek Wilk
2014-01-03 18:29 ` Stefano Stabellini
2014-01-03 18:39 ` Konrad Rzeszutek Wilk
2014-01-03 19:02 ` Stefano Stabellini
2014-01-03 17:26 ` Stefano Stabellini
2014-01-03 18:20 ` Konrad Rzeszutek Wilk
2014-01-01 4:35 ` [PATCH v12 16/18] xen/pvh: Piggyback on PVHVM XenBus Konrad Rzeszutek Wilk
2014-01-02 11:43 ` David Vrabel
2014-01-03 17:22 ` Stefano Stabellini
2014-01-01 4:35 ` [PATCH v12 17/18] xen/pvh/arm/arm64: Disable PV code that does not work with PVH (v2) Konrad Rzeszutek Wilk
2014-01-02 11:44 ` David Vrabel
2014-01-03 16:22 ` Stefano Stabellini
2014-01-03 17:59 ` Konrad Rzeszutek Wilk
2014-01-01 4:35 ` [PATCH v12 18/18] xen/pvh: Support ParaVirtualized Hardware extensions (v2) Konrad Rzeszutek Wilk
2014-01-02 11:48 ` David Vrabel
2014-01-02 18:27 ` Konrad Rzeszutek Wilk
2014-01-02 16:50 ` [PATCH v12] Linux Xen PVH support David Vrabel
2014-01-02 19:02 ` Konrad Rzeszutek Wilk
2014-01-03 13:37 ` David Vrabel
2014-01-02 18:39 ` H. Peter Anvin
2014-01-02 19:12 ` Konrad Rzeszutek Wilk
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=52C54E00.7010508@citrix.com \
--to=david.vrabel@citrix.com \
--cc=boris.ostrovsky@oracle.com \
--cc=konrad.wilk@oracle.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;
as well as URLs for NNTP newsgroup(s).