Thread (13 messages) 13 messages, 4 authors, 2021-07-28

Re: [PATCH v3 5/6] platform/x86: intel_tdx_attest: Add TDX Guest attestation interface driver

From: Dave Hansen <hidden>
Date: 2021-07-20 21:24:17
Also in: bpf, lkml, platform-driver-x86

On 7/20/21 2:16 PM, Andi Kleen wrote:
On 7/20/2021 10:59 AM, Dave Hansen wrote:
quoted
On 7/20/21 10:52 AM, Kuppuswamy, Sathyanarayanan wrote:
quoted
quoted
Why does this need to use the page allocator directly?
^^ You didn't address this question.
The address needs to be naturally aligned, and I'm not sure all slab
allocators guarantee 64 byte alignment. So using the page allocator
seems to be safer. I guess a comment would be good.
The documentation
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/core-api/memory-allocation.rst#n146
claims:
The address of a chunk allocated with `kmalloc` is aligned to at least
ARCH_KMALLOC_MINALIGN bytes.  For sizes which are a power of two, the
alignment is also guaranteed to be at least the respective size.
This is another case where care in coding these things up, writing good
changelogs and expressing assumptions in comments can save
back-and-forth from a reviewer.

Imagine if this had been:

	/*
	 * tdreport_data needs to be 64-byte aligned.
	 * Full page alignment is more than enough.
	 */
	tdreport_data = (void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, 0);
	if (!tdreport_data) {
		ret = -ENOMEM;
		goto failed;
	}
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help