From: Tom Lendacky <thomas.lendacky@amd.com>
To: David Woodhouse <dwmw2@infradead.org>,
Usama Arif <usama.arif@bytedance.com>,
tglx@linutronix.de, kim.phillips@amd.com, brgerst@gmail.com
Cc: piotrgorski@cachyos.org, oleksandr@natalenko.name,
arjan@linux.intel.com, mingo@redhat.com, bp@alien8.de,
dave.hansen@linux.intel.com, hpa@zytor.com, x86@kernel.org,
pbonzini@redhat.com, paulmck@kernel.org,
linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
rcu@vger.kernel.org, mimoja@mimoja.de, hewenliang4@huawei.com,
seanjc@google.com, pmenzel@molgen.mpg.de,
fam.zheng@bytedance.com, punit.agrawal@bytedance.com,
simon.evans@bytedance.com, liangma@liangbit.com
Subject: Re: [PATCH v13 00/11] Parallel CPU bringup for x86_64
Date: Tue, 7 Mar 2023 10:45:59 -0600 [thread overview]
Message-ID: <effbb6e2-c5a1-af7f-830d-8d7088f57477@amd.com> (raw)
In-Reply-To: <faa0eb3bb8ba0326d501516a057ab46eaf1f3c05.camel@infradead.org>
On 3/7/23 08:42, David Woodhouse wrote:
> On Thu, 2023-03-02 at 11:12 +0000, Usama Arif wrote:
>> The main code change over v12 is to fix the build error when
>> CONFIG_FORCE_NR_CPUS is present.
>>
>> The commit message for removing initial stack has also been improved, typos
>> have been fixed and extra comments have been added to make code clearer.
>
> Might something like this make it work in parallel with SEV-SNP? If so,
> I can clean it up and adjust the C code to actually invoke it...
This should be ok for both SEV-ES and SEV-SNP.
>
> diff --git a/arch/x86/include/asm/sev-common.h b/arch/x86/include/asm/sev-common.h
> index b8357d6ecd47..f25df4bd318e 100644
> --- a/arch/x86/include/asm/sev-common.h
> +++ b/arch/x86/include/asm/sev-common.h
> @@ -70,6 +70,7 @@
> /* GHCBData[63:12] */ \
> (((u64)(v) & GENMASK_ULL(63, 12)) >> 12)
>
> +#ifndef __ASSEMBLY__
> /*
> * SNP Page State Change Operation
> *
> @@ -160,6 +161,8 @@ struct snp_psc_desc {
>
> #define GHCB_RESP_CODE(v) ((v) & GHCB_MSR_INFO_MASK)
>
> +#endif /* __ASSEMBLY__ */
> +
> /*
> * Error codes related to GHCB input that can be communicated back to the guest
> * by setting the lower 32-bits of the GHCB SW_EXITINFO1 field to 2.
> diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
> index defe76ee9e64..0c26f80f488c 100644
> --- a/arch/x86/include/asm/smp.h
> +++ b/arch/x86/include/asm/smp.h
> @@ -204,6 +204,7 @@ extern unsigned int smpboot_control;
> /* Control bits for startup_64 */
> #define STARTUP_APICID_CPUID_0B 0x80000000
> #define STARTUP_APICID_CPUID_01 0x40000000
> +#define STARTUP_APICID_SEV_SNP 0x20000000
>
> #define STARTUP_PARALLEL_MASK (STARTUP_APICID_CPUID_01 | STARTUP_APICID_CPUID_0B)
>
> diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
> index c35f7c173832..b2571034562c 100644
> --- a/arch/x86/kernel/head_64.S
> +++ b/arch/x86/kernel/head_64.S
> @@ -26,7 +26,7 @@
> #include <asm/nospec-branch.h>
> #include <asm/fixmap.h>
> #include <asm/smp.h>
> -
> +#include <asm/sev-common.h>
> /*
> * We are not able to switch in one step to the final KERNEL ADDRESS SPACE
> * because we need identity-mapped pages.
> @@ -242,6 +242,7 @@ SYM_INNER_LABEL(secondary_startup_64_no_verify, SYM_L_GLOBAL)
> *
> * Bit 31 STARTUP_APICID_CPUID_0B flag (use CPUID 0x0b)
> * Bit 30 STARTUP_APICID_CPUID_01 flag (use CPUID 0x01)
> + * Bit 29 STARTUP_APICID_SEV_SNP flag (CPUID 0x0v via GHCB MSR)
> * Bit 0-24 CPU# if STARTUP_APICID_CPUID_xx flags are not set
> */
> movl smpboot_control(%rip), %ecx
> @@ -249,6 +250,8 @@ SYM_INNER_LABEL(secondary_startup_64_no_verify, SYM_L_GLOBAL)
> jnz .Luse_cpuid_0b
> testl $STARTUP_APICID_CPUID_01, %ecx
> jnz .Luse_cpuid_01
> + testl $STARTUP_APICID_SEV_SNP, %ecx
> + jnz .Luse_sev_cpuid_0b
> andl $0x0FFFFFFF, %ecx
> jmp .Lsetup_cpu
>
> @@ -259,6 +262,18 @@ SYM_INNER_LABEL(secondary_startup_64_no_verify, SYM_L_GLOBAL)
> shr $24, %edx
> jmp .Lsetup_AP
>
> +.Luse_sev_cpuid_0b:
> + movl $MSR_AMD64_SEV_ES_GHCB, %ecx
> + # GHCB_CPUID_REQ(0x0b, GHCB_CPUID_REQ_EDX)
> + movq $0xc00000040000000b, %rax
> + xorl %edx, %edx
> + vmgexit
According to the GHCB spec, the GHCB MSR protocol is triggered when the
GHCB value is non-zero in bits 11:0. For the CPUID function, bits 63:32
hold the CPUID function, bits 31:30 hold the requested register and bits
11:0 == 0x4. So this should be:
/* Set the GHCB MSR to request CPUID 0xB_EDX */
movl $MSR_AMD64_SEV_ES_GHCB, %ecx
movl $0xc0000004, %eax
movl $0xb, %edx
wrmsr
/* Perform GHCB MSR protocol */
vmgexit
/*
* Get the result. After the RDMSR:
* EAX should be 0xc0000005
* EDX should have the CPUID register value and since EDX
* is the target register, no need to move the result.
*/
> + rdmsr
> + andl $GHCB_MSR_INFO_MASK, %eax
> + cmpl $GHCB_MSR_CPUID_RESP, %eax
> + jne 1f
> + jmp .Lsetup_AP
> +
> .Luse_cpuid_0b:
> mov $0x0B, %eax
> xorl %ecx, %ecx
>
Thanks,
Tom
>
next prev parent reply other threads:[~2023-03-07 16:50 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-02 11:12 [PATCH v13 00/11] Parallel CPU bringup for x86_64 Usama Arif
2023-03-02 11:12 ` [PATCH v13 01/11] x86/apic/x2apic: Allow CPU cluster_mask to be populated in parallel Usama Arif
2023-03-02 11:12 ` [PATCH v13 02/11] cpu/hotplug: Move idle_thread_get() to <linux/smpboot.h> Usama Arif
2023-03-02 11:12 ` [PATCH v13 03/11] cpu/hotplug: Add dynamic parallel bringup states before CPUHP_BRINGUP_CPU Usama Arif
2023-03-02 11:12 ` [PATCH v13 04/11] x86/smpboot: Reference count on smpboot_setup_warm_reset_vector() Usama Arif
2023-03-02 11:12 ` [PATCH v13 05/11] x86/smpboot: Split up native_cpu_up into separate phases and document them Usama Arif
2023-03-02 11:12 ` [PATCH v13 06/11] x86/smpboot: Remove initial_stack on 64-bit Usama Arif
2023-03-02 11:12 ` [PATCH v13 07/11] x86/smpboot: Remove early_gdt_descr " Usama Arif
2023-03-02 11:12 ` [PATCH v13 08/11] x86/smpboot: Remove initial_gs Usama Arif
2023-03-02 11:12 ` [PATCH v13 09/11] x86/smpboot: Support parallel startup of secondary CPUs Usama Arif
2023-03-02 11:12 ` [PATCH v13 10/11] x86/smpboot: Send INIT/SIPI/SIPI to secondary CPUs in parallel Usama Arif
2023-03-02 11:12 ` [PATCH v13 11/11] x86/smpboot: Serialize topology updates for secondary bringup Usama Arif
2023-03-07 14:42 ` [PATCH v13 00/11] Parallel CPU bringup for x86_64 David Woodhouse
2023-03-07 16:45 ` Tom Lendacky [this message]
2023-03-07 19:18 ` David Woodhouse
2023-03-07 20:06 ` Tom Lendacky
2023-03-07 22:22 ` Tom Lendacky
2023-03-07 22:27 ` David Woodhouse
2023-03-07 22:55 ` Tom Lendacky
2023-03-08 9:04 ` David Woodhouse
2023-03-08 11:27 ` [External] " Usama Arif
2023-03-08 12:15 ` David Laight
2023-03-08 12:19 ` David Woodhouse
2023-03-08 14:10 ` [External] " Usama Arif
2023-03-08 14:40 ` Tom Lendacky
2023-03-07 23:35 ` Sean Christopherson
2023-03-08 7:38 ` David Woodhouse
2023-03-07 21:00 ` [External] " Usama Arif
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=effbb6e2-c5a1-af7f-830d-8d7088f57477@amd.com \
--to=thomas.lendacky@amd.com \
--cc=arjan@linux.intel.com \
--cc=bp@alien8.de \
--cc=brgerst@gmail.com \
--cc=dave.hansen@linux.intel.com \
--cc=dwmw2@infradead.org \
--cc=fam.zheng@bytedance.com \
--cc=hewenliang4@huawei.com \
--cc=hpa@zytor.com \
--cc=kim.phillips@amd.com \
--cc=kvm@vger.kernel.org \
--cc=liangma@liangbit.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mimoja@mimoja.de \
--cc=mingo@redhat.com \
--cc=oleksandr@natalenko.name \
--cc=paulmck@kernel.org \
--cc=pbonzini@redhat.com \
--cc=piotrgorski@cachyos.org \
--cc=pmenzel@molgen.mpg.de \
--cc=punit.agrawal@bytedance.com \
--cc=rcu@vger.kernel.org \
--cc=seanjc@google.com \
--cc=simon.evans@bytedance.com \
--cc=tglx@linutronix.de \
--cc=usama.arif@bytedance.com \
--cc=x86@kernel.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