All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Varad Gautam <varad.gautam@suse.com>
Cc: kvm@vger.kernel.org, pbonzini@redhat.com, drjones@redhat.com,
	marcorr@google.com, zxwang42@gmail.com, erdemaktas@google.com,
	rientjes@google.com, brijesh.singh@amd.com,
	Thomas.Lendacky@amd.com, jroedel@suse.de, bp@suse.de
Subject: Re: [kvm-unit-tests PATCH v2 08/10] x86: Move 32-bit bringup routines to start32.S
Date: Wed, 13 Apr 2022 19:33:18 +0000	[thread overview]
Message-ID: <YlclfjU6BMN72hUm@google.com> (raw)
In-Reply-To: <20220412173407.13637-9-varad.gautam@suse.com>

On Tue, Apr 12, 2022, Varad Gautam wrote:
> These can be shared across EFI and non-EFI builds.
> 
> Signed-off-by: Varad Gautam <varad.gautam@suse.com>
> ---
> diff --git a/x86/start32.S b/x86/start32.S
> new file mode 100644
> index 0000000..9e00474
> --- /dev/null
> +++ b/x86/start32.S
> @@ -0,0 +1,62 @@
> +/* Common 32-bit code between EFI and non-EFI bootstrapping. */
> +
> +.code32
> +
> +MSR_GS_BASE = 0xc0000101
> +
> +.macro setup_percpu_area
> +	lea -4096(%esp), %eax
> +	mov $0, %edx
> +	mov $MSR_GS_BASE, %ecx
> +	wrmsr
> +.endm
> +
> +.macro setup_segments
> +	mov $MSR_GS_BASE, %ecx
> +	rdmsr
> +
> +	mov $0x10, %bx
> +	mov %bx, %ds
> +	mov %bx, %es
> +	mov %bx, %fs
> +	mov %bx, %gs
> +	mov %bx, %ss
> +
> +	/* restore MSR_GS_BASE */
> +	wrmsr
> +.endm
> +
> +prepare_64:
> +	lgdt gdt_descr
> +	setup_segments
> +
> +	xor %eax, %eax
> +	mov %eax, %cr4
> +
> +enter_long_mode:
> +	mov %cr4, %eax
> +	bts $5, %eax  // pae
> +	mov %eax, %cr4
> +
> +	mov pt_root, %eax
> +	mov %eax, %cr3
> +
> +efer = 0xc0000080
> +	mov $efer, %ecx
> +	rdmsr
> +	bts $8, %eax
> +	wrmsr
> +
> +	mov %cr0, %eax
> +	bts $0, %eax
> +	bts $31, %eax
> +	mov %eax, %cr0
> +	ret
> +
> +ap_start32:
> +	setup_segments
> +	mov $-4096, %esp
> +	lock xaddl %esp, smp_stacktop
> +	setup_percpu_area
> +	call prepare_64

I suspect this will conflict with my idea of using a dedicated percpu area.  But
can't that be remedied by adding a prep patch to drop setup_percpu_area and add a
C helper to the setup (using the dedicated area), called from ap_start64()?  I don't
see any instances of gs: being used before reset_apic().

Then the funky save/restore of MSR_GS_BASE also disappears.

> +	ljmpl $8, $ap_start64
> -- 
> 2.32.0
> 

  reply	other threads:[~2022-04-13 19:33 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-12 17:33 [kvm-unit-tests PATCH v2 00/10] SMP Support for x86 UEFI Tests Varad Gautam
2022-04-12 17:33 ` [kvm-unit-tests PATCH v2 01/10] x86: Move ap_init() to smp.c Varad Gautam
2022-04-13 15:16   ` Sean Christopherson
2022-04-13 18:44   ` Sean Christopherson
2022-04-13 18:55     ` Sean Christopherson
2022-04-13 18:59       ` Sean Christopherson
2022-04-13 19:01         ` Sean Christopherson
2022-04-13 19:04           ` Sean Christopherson
2022-04-12 17:33 ` [kvm-unit-tests PATCH v2 02/10] x86: Move load_idt() to desc.c Varad Gautam
2022-04-13 15:19   ` Sean Christopherson
2022-04-12 17:34 ` [kvm-unit-tests PATCH v2 03/10] x86: desc: Split IDT entry setup into a generic helper Varad Gautam
2022-04-13 16:35   ` Sean Christopherson
2022-04-12 17:34 ` [kvm-unit-tests PATCH v2 04/10] x86: Move load_gdt_tss() to desc.c Varad Gautam
2022-04-13 15:58   ` Sean Christopherson
2022-04-12 17:34 ` [kvm-unit-tests PATCH v2 05/10] x86: efi: Stop using UEFI-provided stack Varad Gautam
2022-04-13 16:20   ` Sean Christopherson
2022-04-12 17:34 ` [kvm-unit-tests PATCH v2 06/10] x86: efi: Stop using UEFI-provided %gs for percpu storage Varad Gautam
2022-04-13 16:23   ` Sean Christopherson
2022-04-12 17:34 ` [kvm-unit-tests PATCH v2 07/10] x86: efi, smp: Transition APs from 16-bit to 32-bit mode Varad Gautam
2022-04-13 19:17   ` Sean Christopherson
2022-04-12 17:34 ` [kvm-unit-tests PATCH v2 08/10] x86: Move 32-bit bringup routines to start32.S Varad Gautam
2022-04-13 19:33   ` Sean Christopherson [this message]
2022-04-12 17:34 ` [kvm-unit-tests PATCH v2 09/10] x86: efi, smp: Transition APs from 32-bit to 64-bit mode Varad Gautam
2022-04-12 17:34 ` [kvm-unit-tests PATCH v2 10/10] x86: Provide a common 64-bit AP entrypoint for EFI and non-EFI Varad Gautam
2022-04-13 19:55   ` Sean Christopherson
2022-04-13 19:57 ` [kvm-unit-tests PATCH v2 00/10] SMP Support for x86 UEFI Tests Sean Christopherson
2022-04-26 11:51   ` Varad Gautam

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=YlclfjU6BMN72hUm@google.com \
    --to=seanjc@google.com \
    --cc=Thomas.Lendacky@amd.com \
    --cc=bp@suse.de \
    --cc=brijesh.singh@amd.com \
    --cc=drjones@redhat.com \
    --cc=erdemaktas@google.com \
    --cc=jroedel@suse.de \
    --cc=kvm@vger.kernel.org \
    --cc=marcorr@google.com \
    --cc=pbonzini@redhat.com \
    --cc=rientjes@google.com \
    --cc=varad.gautam@suse.com \
    --cc=zxwang42@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.