[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <9c075b36-e450-831b-0ae2-3b680686beb4@amd.com>
Date: Fri, 4 Mar 2022 07:17:33 -0600
From: Brijesh Singh <brijesh.singh@....com>
To: Dave Hansen <dave.hansen@...el.com>, x86@...nel.org,
linux-kernel@...r.kernel.org, kvm@...r.kernel.org,
linux-efi@...r.kernel.org, platform-driver-x86@...r.kernel.org,
linux-coco@...ts.linux.dev, linux-mm@...ck.org
Cc: brijesh.singh@....com, Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, Joerg Roedel <jroedel@...e.de>,
Tom Lendacky <thomas.lendacky@....com>,
"H. Peter Anvin" <hpa@...or.com>, Ard Biesheuvel <ardb@...nel.org>,
Paolo Bonzini <pbonzini@...hat.com>,
Sean Christopherson <seanjc@...gle.com>,
Vitaly Kuznetsov <vkuznets@...hat.com>,
Jim Mattson <jmattson@...gle.com>,
Andy Lutomirski <luto@...nel.org>,
Dave Hansen <dave.hansen@...ux.intel.com>,
Sergio Lopez <slp@...hat.com>, Peter Gonda <pgonda@...gle.com>,
Peter Zijlstra <peterz@...radead.org>,
Srinivas Pandruvada <srinivas.pandruvada@...ux.intel.com>,
David Rientjes <rientjes@...gle.com>,
Dov Murik <dovmurik@...ux.ibm.com>,
Tobin Feldman-Fitzthum <tobin@....com>,
Borislav Petkov <bp@...en8.de>,
Michael Roth <michael.roth@....com>,
Vlastimil Babka <vbabka@...e.cz>,
"Kirill A . Shutemov" <kirill.shutemov@...ux.intel.com>,
Andi Kleen <ak@...ux.intel.com>,
"Dr . David Alan Gilbert" <dgilbert@...hat.com>,
brijesh.ksingh@...il.com, tony.luck@...el.com, marcorr@...gle.com,
sathyanarayanan.kuppuswamy@...ux.intel.com
Subject: Re: [PATCH v11 42/45] virt: Add SEV-SNP guest driver
On 3/3/22 11:33 AM, Dave Hansen wrote:
...
>> + */
>> + if (count >= UINT_MAX) {
>> + pr_err_ratelimited("request message sequence counter overflow\n");
>> + return 0;
>> + }
>> +
>> + return count;
>> +}
> I didn't see a pr_fmt defined anywhere. But, for a "driver", should
> this be a dev_err()?
Okay, I can switch to dev_err() and will define pr_fmt.
> ...
>> +static void free_shared_pages(void *buf, size_t sz)
>> +{
>> + unsigned int npages = PAGE_ALIGN(sz) >> PAGE_SHIFT;
>> +
>> + if (!buf)
>> + return;
>> +
>> + if (WARN_ONCE(set_memory_encrypted((unsigned long)buf, npages),
>> + "failed to restore encryption mask (leak it)\n"))
>> + return;
>> +
>> + __free_pages(virt_to_page(buf), get_order(sz));
>> +}
> Nit: It's a bad practice to do important things inside a WARN_ON() _or_
> and if(). This should be:
>
> int ret;
>
> ...
>
> ret = set_memory_encrypted((unsigned long)buf, npages));
>
> if (ret) {
> WARN_ONCE(...);
> return;
> }
>
> BTW, this look like a generic allocator thingy. But it's only ever used
> to allocate a 'struct snp_guest_msg'. Why all the trouble to allocate
> and free one fixed-size structure? The changelog and comments don't
> shed any light.
The GHCB specification says that a guest must use shared memory for
request, response, and certificate blob. In this patch, you are seeing
that {alloc,free}_shared_pages() used only to alloc/free the request and
response page. In the last patch, we used the same generic function to
allocate the certificate blob with a different size (~16K) than 'struct
snp_guest_msg.'
thanks
Powered by blists - more mailing lists