From: Brijesh Singh <brijesh.singh@amd.com>
To: Sean Christopherson <sean.j.christopherson@intel.com>
Cc: brijesh.singh@amd.com, "Borislav Petkov" <bp@suse.de>,
x86@kernel.org, linux-kernel@vger.kernel.org,
kvm@vger.kernel.org, "Tom Lendacky" <thomas.lendacky@amd.com>,
"Thomas Gleixner" <tglx@linutronix.de>,
"H. Peter Anvin" <hpa@zytor.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Radim Krčmář" <rkrcmar@redhat.com>
Subject: Re: [PATCH v5 5/5] x86/kvm: Avoid dynamic allocation of pvclock data when SEV is active
Date: Thu, 6 Sep 2018 16:56:06 -0500 [thread overview]
Message-ID: <4c6df918-0b47-e823-1141-82baa068828d@amd.com> (raw)
In-Reply-To: <20180906203926.GA5717@linux.intel.com>
On 09/06/2018 03:39 PM, Sean Christopherson wrote:
> On Thu, Sep 06, 2018 at 03:20:46PM -0500, Brijesh Singh wrote:
>>
>>
>> On 09/06/2018 02:47 PM, Sean Christopherson wrote:
>> ...
>>
>>>>
>>>> Yes, the auxiliary array will dumped into the regular .bss when
>>>> CONFIG_AMD_MEM_ENCRYPT=n. Typically it will be few k, I am not
>>>> sure if its worth complicating the code to save those extra memory.
>>>> Most of the distro's have CONFIG_AMD_MEM_ENCRYPT=y anyways.
>>>
>>> I just realized that we'll try to create a bogus array if 'NR_CPUS <=
>>> HVC_BOOT_ARRAY_SIZE'. A bit ugly, but we could #ifdef away both that
>>> and CONFIG_AMD_MEM_ENCRYPT=n in a single shot, e.g.:
>>>
>>> #if defined(CONFIG_AMD_MEM_ENCRYPT) && NR_CPUS > HVC_BOOT_ARRAY_SIZE
>>> #define HVC_AUX_ARRAY_SIZE \
>>> PAGE_ALIGN((NR_CPUS - HVC_BOOT_ARRAY_SIZE) * \
>>> sizeof(struct pvclock_vsyscall_time_info))
>>> static struct pvclock_vsyscall_time_info
>>> hv_clock_aux[HVC_AUX_ARRAY_SIZE] __decrypted __aligned(PAGE_SIZE);
>>> #endif
>>>
>>
>> The HVC_BOOT_ARRAY_SIZE macro uses sizeof(..) and to my understanding
>> the sizeof operators are not allowed in '#if'. Anyway, I will try to see
>> if it can be used, if not then I will stick to CONFIG_AMD_MEM_ENCRYPT
>> check.
>
> Hmm, we'll need something otherwise 'NR_CPUS - HVC_BOOT_ARRAY_SIZE'
> will wrap and cause build errors.
>
Right.
One option is we can hard-code the check for > 64, something like this:
#if defined(CONFIG_AMD_MEM_ENCRYPT) && NR_CPUS > 64
...
...
#endif
But this assumption will break if we ever add a new field in
struct pvclock_vsyscall_time_info. Hence I am not in favor of this.
Second option is, use KVM_MAX_VCPUS or NR_CPUS, something like this:
#ifdef CONFIG_AMD_MEM_ENCRYPT
#define HVC_AUX_ARRAY_SIZE \
PAGE_ALIGN(NR_CPUS * sizeof(struct pvclock_vsyscall_time_info))
...
#endif
In this case we will allocate few extra bytes which will get freed for
the non-SEV case anyways.
next prev parent reply other threads:[~2018-09-06 21:56 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-06 11:42 [PATCH v5 0/5] x86: Fix SEV guest regression Brijesh Singh
2018-09-06 11:42 ` [PATCH v5 1/5] x86/mm: Restructure sme_encrypt_kernel() Brijesh Singh
2018-09-06 11:42 ` [PATCH v5 2/5] x86/mm: fix sme_populate_pgd() to update page flags Brijesh Singh
2018-09-06 11:43 ` [PATCH v5 3/5] x86/mm: add .data..decrypted section to hold shared variables Brijesh Singh
2018-09-06 11:43 ` [PATCH v5 4/5] x86/kvm: use __decrypted attribute in " Brijesh Singh
2018-09-06 11:43 ` [PATCH v5 5/5] x86/kvm: Avoid dynamic allocation of pvclock data when SEV is active Brijesh Singh
2018-09-06 12:24 ` Borislav Petkov
2018-09-06 13:50 ` Sean Christopherson
2018-09-06 14:18 ` Sean Christopherson
2018-09-06 14:44 ` Borislav Petkov
2018-09-06 18:37 ` Brijesh Singh
2018-09-06 18:47 ` Sean Christopherson
2018-09-06 19:24 ` Brijesh Singh
2018-09-06 19:46 ` Brijesh Singh
2018-09-06 19:47 ` Sean Christopherson
2018-09-06 20:20 ` Brijesh Singh
2018-09-06 20:39 ` Sean Christopherson
2018-09-06 21:56 ` Brijesh Singh [this message]
2018-09-06 14:43 ` Borislav Petkov
2018-09-06 14:56 ` Sean Christopherson
2018-09-06 15:19 ` Borislav Petkov
2018-09-06 15:54 ` Sean Christopherson
2018-09-06 18:33 ` Borislav Petkov
2018-09-06 18:43 ` Brijesh Singh
2018-09-06 18:45 ` Sean Christopherson
2018-09-06 19:03 ` Borislav Petkov
2018-09-06 17:50 ` Brijesh Singh
2018-09-06 14:07 ` Sean Christopherson
2018-09-06 18:50 ` Brijesh Singh
2018-09-07 3:57 ` Brijesh Singh
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=4c6df918-0b47-e823-1141-82baa068828d@amd.com \
--to=brijesh.singh@amd.com \
--cc=bp@suse.de \
--cc=hpa@zytor.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=rkrcmar@redhat.com \
--cc=sean.j.christopherson@intel.com \
--cc=tglx@linutronix.de \
--cc=thomas.lendacky@amd.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
all inboxes | Powered by JetHome®