Re: [PATCH Part1 RFC v4 20/36] x86/sev: Use SEV-SNP AP creation to start secondary CPUs

Tom Lendacky
2021-08-17T22:14:03Z

On 8/17/21 3:04 PM, Borislav Petkov wrote:
> On Wed, Jul 07, 2021 at 01:14:50PM -0500, Brijesh Singh wrote:
>> @@ -854,6 +858,207 @@ void snp_set_memory_private(unsigned long vaddr, unsigned int npages)
>> pvalidate_pages(vaddr, npages, 1);
>> }
>>
>> +static int vmsa_rmpadjust(void *va, bool vmsa)
>
> I know, I know it gets a bool vmsa param but you can still call it
> simply rmpadjust() because this is what it does - it is a wrapper around
> the insn. Just like pvalidate() and so on.

Well, yes and no. It really is just setting or clearing the VMSA page
attribute. It isn't trying to update permissions for the lower VMPLs, so I
didn't want to mislabel it as a general rmpadjust function. But it's a
simple enough thing to change and if multiple VMPL levels are ever
supported it can be evaluated at that time.

>
> ...
>
>> +static int wakeup_cpu_via_vmgexit(int apic_id, unsigned long start_ip)
>> +{
>> + struct sev_es_save_area *cur_vmsa, *vmsa;
>> + struct ghcb_state state;
>> + unsigned long flags;
>> + struct ghcb *ghcb;
>> + int cpu, err, ret;
>> + u8 sipi_vector;
>> + u64 cr4;
>> +
>> + if ((sev_hv_features & GHCB_HV_FT_SNP_AP_CREATION) != GHCB_HV_FT_SNP_AP_CREATION)
>> + return -EOPNOTSUPP;
>> +
>> + /*
>> + * Verify the desired start IP against the known trampoline start IP
>> + * to catch any future new trampolines that may be introduced that
>> + * would require a new protected guest entry point.
>> + */
>> + if (WARN_ONCE(start_ip != real_mode_header->trampoline_start,
>> + "unsupported SEV-SNP start_ip: %lx\n", start_ip))
>
> "Unsupported... " - with a capital letter

Will do.

Thanks,
Tom

>
>> + return -EINVAL;
>> +
>> + /* Override start_ip with known protected guest start IP */
>> + start_ip = real_mode_header->sev_es_trampoline_start;
>> +
>
> ...
>