From: Brijesh Singh <brijesh.singh@amd.com>
To: Sean Christopherson <sean.j.christopherson@intel.com>
Cc: brijesh.singh@amd.com, x86@kernel.org,
linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
"Tom Lendacky" <thomas.lendacky@amd.com>,
"Thomas Gleixner" <tglx@linutronix.de>,
"Borislav Petkov" <bp@suse.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 13:50:21 -0500 [thread overview]
Message-ID: <9b7ba5a6-5b2d-206d-46f0-32e0dbd2af70@amd.com> (raw)
In-Reply-To: <20180906140738.GA370@linux.intel.com>
On 09/06/2018 09:07 AM, Sean Christopherson wrote:
...
>> +
>> +/* This should cover upto 512 VCPUS (first 64 are covered by hv_clock_boot[]). */
>> +#define HVC_DECRYPTED_ARRAY_SIZE \
>> + ((PAGE_SIZE * 7) / sizeof(struct pvclock_vsyscall_time_info))
>
> I think we can define the size relative to NR_CPUS rather than picking
> an arbitrary number of pages, maybe with a BUILD_BUG_ON to make sure
> the total size won't require a second 2mb page for __decrpyted.
>
> #define HVC_DECRYPTED_ARRAY_SIZE \
> PAGE_ALIGN((NR_CPUS - HVC_BOOT_ARRAY_SIZE) * \
> sizeof(struct pvclock_vsyscall_time_info))
>
Sure works for me.
>> +static struct pvclock_vsyscall_time_info
>> + hv_clock_dec[HVC_DECRYPTED_ARRAY_SIZE] __decrypted_hvclock;
>> +
>> static inline struct pvclock_vcpu_time_info *this_cpu_pvti(void)
>> {
>> return &this_cpu_read(hv_clock_per_cpu)->pvti;
>> @@ -267,10 +274,19 @@ static int kvmclock_setup_percpu(unsigned int cpu)
>> return 0;
>>
>> /* Use the static page for the first CPUs, allocate otherwise */
>> - if (cpu < HVC_BOOT_ARRAY_SIZE)
>> + if (cpu < HVC_BOOT_ARRAY_SIZE) {
>> p = &hv_clock_boot[cpu];
>> - else
>> - p = kzalloc(sizeof(*p), GFP_KERNEL);
>> + } else {
>> + /*
>> + * When SEV is active, use the static pages from
>> + * .data..decrypted_hvclock section. The pages are already
>> + * mapped with C=0.
>> + */
>> + if (sev_active())
>> + p = &hv_clock_dec[cpu - HVC_BOOT_ARRAY_SIZE];
>> + else
>> + p = kzalloc(sizeof(*p), GFP_KERNEL);
>> + }
>
> Personal preference, but I think an if-elif-else with a single block
> comment would be easier to read.
I can do with that. thanks for your feedback.
>
> /*
> * Blah blah blah
> */
> if (cpu < HVC_BOOT_ARRAY_SIZE)
> p = &hv_clock_boot[cpu];
> else if (sev_active())
> p = &hv_clock_dec[cpu - HVC_BOOT_ARRAY_SIZE];
> else
> p = kzalloc(sizeof(*p), GFP_KERNEL);
>
next prev parent reply other threads:[~2018-09-06 18:50 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
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 [this message]
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=9b7ba5a6-5b2d-206d-46f0-32e0dbd2af70@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
Powered by JetHome