Re: [PATCH] KVM: SVM: Replace kmap_atomic() with kmap_local_page()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 9/2/22 08:15, Sean Christopherson wrote:
>>  	for (i = 0; i < npages; i++) {
>> -		page_virtual = kmap_atomic(pages[i]);
>> +		page_virtual = kmap_local_page(pages[i]);
>>  		clflush_cache_range(page_virtual, PAGE_SIZE);
> SEV is 64-bit only, any reason not to go straight to page_address()?

Yes.  page_address() is a hack.  People get away with using it, but they
really shouldn't, especially when it is used on pages you didn't
allocate yourself.

IOW:

	page = alloc_page(GFP_KERNEL);
	ptr = page_address(page);

is fine.  But:

	page = alloc_page(GFP_HIGHUSER);
	ptr = page_address(page);

even on something that's Kconfig'd 64-bit only is a no-no in my book.
The same goes for a generic-looking function like sev_clflush_pages()
where the pages come from who-knows-where.

It's incredibly useful for kernel accesses to random pages to be bounded
explicitly.  Keeping the kmap() *API* in place means it can be used for
things other than highmem mappings (like protection keys).  The kmap*()
family is a pretty thin wrapper around page_address() on 64-bit most of
the time anyway.




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux