From: Sean Christopherson <seanjc@google.com>
To: Vasant Karasulli <vkarasulli@suse.de>
Cc: Thomas.Lendacky@amd.com, bp@alien8.de, drjones@redhat.com,
erdemaktas@google.com, jroedel@suse.de, kvm@vger.kernel.org,
marcorr@google.com, pbonzini@redhat.com, rientjes@google.com,
zxwang42@gmail.com
Subject: Re: [kvm-unit-tests PATCH v4 08/13] x86: efi: Provide percpu storage
Date: Mon, 22 Aug 2022 17:30:00 +0000 [thread overview]
Message-ID: <YwO9GM/SV3amfIA1@google.com> (raw)
In-Reply-To: <20220822152123.18983-1-vkarasulli@suse.de>
Please send a standalone patch (with a SOB), this series has already been merged.
On Mon, Aug 22, 2022, Vasant Karasulli wrote:
> Writing to MSR_IA32_APICBASE in reset_apic() is an
> intercepted operation
Is _typically_ an intercepted operation, architecturally there's nothing that
requires APICBASE to emulated.
> and causes #VC exception when the test is launched as
> an SEV-ES guest.
>
> So calling reset_apic() before IDT is set up in setup_idt() and
> load_idt() might cause problems.
> Similarly if accessing _percpu_data array element in setup_segments64() results
> in a page fault, this will lead to a double fault.
Well, yeah, but loading the IDT isn't going to magically fix the #PF. I suspect
you're actually referring to the emulated MMIO #NPF=>#VC when accessing the xAPIC
through MMIO?
> Hence move reset_apic() call and percpu data setup after
> setup_idt() and load_idt().
> ---
> lib/x86/setup.c | 11 +++++------
> 1 file changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/lib/x86/setup.c b/lib/x86/setup.c
> index 7df0256..b14e692 100644
> --- a/lib/x86/setup.c
> +++ b/lib/x86/setup.c
> @@ -192,8 +192,6 @@ static void setup_segments64(void)
> write_gs(KERNEL_DS);
> write_ss(KERNEL_DS);
>
> - /* Setup percpu base */
> - wrmsr(MSR_GS_BASE, (u64)&__percpu_data[pre_boot_apic_id()]);
>
> /*
> * Update the code segment by putting it on the stack before the return
> @@ -322,7 +320,7 @@ efi_status_t setup_efi(efi_bootinfo_t *efi_bootinfo)
> }
> return status;
> }
> -
> +
> status = setup_rsdp(efi_bootinfo);
> if (status != EFI_SUCCESS) {
> printf("Cannot find RSDP in EFI system table\n");
> @@ -344,14 +342,15 @@ efi_status_t setup_efi(efi_bootinfo_t *efi_bootinfo)
> }
>
> setup_gdt_tss();
> + setup_segments64();
> + setup_idt();
> + load_idt();
> /*
> * GS.base, which points at the per-vCPU data, must be configured prior
> * to resetting the APIC, which sets the per-vCPU APIC ops.
> */
> - setup_segments64();
> + wrmsr(MSR_GS_BASE, (u64)&__percpu_data[pre_boot_apic_id()]);
This absolutely needs a comment, otherwise someone will wonder why on earth GS.base
isn't configured during setup_segments64(). Easist thing is probalby to split and
reword the above comment, e.g.
/*
* Load GS.base with the per-vCPU data. This must be done after loading
* the IDT as reading the APIC ID may #VC when running as an SEV-ES guest.
*/
wrmsr(MSR_GS_BASE, (u64)&__percpu_data[pre_boot_apic_id()]);
/*
* Resetting the APIC sets the per-vCPU APIC ops and so must be done
* after loading GS.base with the per-vCPU data.
*/
reset_apic();
> reset_apic();
> - setup_idt();
> - load_idt();
> mask_pic_interrupts();
> setup_page_table();
> enable_apic();
> --
> 2.34.1
>
next prev parent reply other threads:[~2022-08-22 17:30 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-15 23:29 [kvm-unit-tests PATCH v4 00/13] x86: SMP Support for x86 UEFI Tests Sean Christopherson
2022-06-15 23:29 ` [kvm-unit-tests PATCH v4 01/13] x86: Use an explicit magic string to detect that dummy.efi passes Sean Christopherson
2022-06-15 23:29 ` [kvm-unit-tests PATCH v4 02/13] x86: Share realmode trampoline between i386 and x86_64 Sean Christopherson
2022-06-15 23:29 ` [kvm-unit-tests PATCH v4 03/13] x86: Move ap_init() to smp.c Sean Christopherson
2022-06-15 23:29 ` [kvm-unit-tests PATCH v4 04/13] x86: Move load_idt() to desc.c Sean Christopherson
2022-06-15 23:29 ` [kvm-unit-tests PATCH v4 05/13] x86: desc: Split IDT entry setup into a generic helper Sean Christopherson
2022-06-15 23:29 ` [kvm-unit-tests PATCH v4 06/13] x86: Move load_gdt_tss() to desc.c Sean Christopherson
2022-06-15 23:29 ` [kvm-unit-tests PATCH v4 07/13] x86: efi: Provide a stack within testcase memory Sean Christopherson
2022-06-15 23:29 ` [kvm-unit-tests PATCH v4 08/13] x86: efi: Provide percpu storage Sean Christopherson
2022-08-22 15:21 ` Vasant Karasulli
2022-08-22 17:30 ` Sean Christopherson [this message]
2022-08-22 18:07 ` Vasant Karasulli
2022-06-15 23:29 ` [kvm-unit-tests PATCH v4 09/13] x86: Move 32-bit => 64-bit transition code to trampolines.S Sean Christopherson
2022-06-15 23:29 ` [kvm-unit-tests PATCH v4 10/13] x86: efi, smp: Transition APs from 16-bit to 32-bit mode Sean Christopherson
2022-06-15 23:29 ` [kvm-unit-tests PATCH v4 11/13] x86: Provide a common 64-bit AP entrypoint for EFI and non-EFI Sean Christopherson
2022-06-15 23:29 ` [kvm-unit-tests PATCH v4 12/13] x86: Rename ap_init() to bringup_aps() Sean Christopherson
2022-06-15 23:29 ` [kvm-unit-tests PATCH v4 13/13] x86: Add ap_online() to consolidate final "AP is alive!" code Sean Christopherson
2022-07-25 15:53 ` [kvm-unit-tests PATCH v4 00/13] x86: SMP Support for x86 UEFI Tests Vasant Karasulli
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=YwO9GM/SV3amfIA1@google.com \
--to=seanjc@google.com \
--cc=Thomas.Lendacky@amd.com \
--cc=bp@alien8.de \
--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=vkarasulli@suse.de \
--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.