Re: [PATCH bpf-next v2 0/5] execmem_alloc for BPF programs

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

 




Le 08/11/2022 à 19:47, Song Liu a écrit :
> On Tue, Nov 8, 2022 at 3:44 AM Christophe Leroy
> <christophe.leroy@xxxxxxxxxx> wrote:
>>
> [...]
>>>
>>> execmem_alloc() manages a set of PMD_SIZE RO+X memory, and allocates these
>>> memory to its users. execmem_alloc() is used to free memory allocated by
>>> execmem_alloc(). execmem_fill() is used to update memory allocated by
>>> execmem_alloc().
>>>
>>> Memory allocated by execmem_alloc() is RO+X, so this doesnot violate W^X.
>>> The caller has to update the content with text_poke like mechanism.
>>> Specifically, execmem_fill() is provided to update memory allocated by
>>> execmem_alloc(). execmem_fill() also makes sure the update stays in the
>>> boundary of one chunk allocated by execmem_alloc(). Please refer to patch
>>> 1/5 for more details of
>>>
>>> Patch 3/5 uses these new APIs in bpf program and bpf dispatcher.
>>>
>>> Patch 4/5 and 5/5 allows static kernel text (_stext to _etext) to share
>>> PMD_SIZE pages with dynamic kernel text on x86_64. This is achieved by
>>> allocating PMD_SIZE pages to roundup(_etext, PMD_SIZE), and then use
>>> _etext to roundup(_etext, PMD_SIZE) for dynamic kernel text.
>>
>> Would it be possible to have something more generic than being stuck to
>> PMD_SIZE ?
>>
>> On powerpc 8xx, PMD_SIZE is 4MB and hugepages are 512kB and 8MB.
> 
> Currently, __vmalloc_node_range() tries to allocate huge pages when
> size_per_node >= PMD_SIZE

Ah right, that reminds me that for powerpc 8xx, 8MB vmalloc mapping is 
not implemented yet and arch_vmap_pmd_supported() returns false. 
However, 512kB mapping is implemented, through 
arch_vmap_pte_supported_shift().

In __vmalloc_node_range() that's the part below:

	if (arch_vmap_pmd_supported(prot) && size_per_node >= PMD_SIZE)
		shift = PMD_SHIFT;
	else
		shift = arch_vmap_pte_supported_shift(size_per_node);


> 
> How do we handle this in powerpc 8xx? I guess we can use the same logic
> here?

arch/powerpc/include/asm/nohash/32/mmu-8xx.h has :

static inline int arch_vmap_pte_supported_shift(unsigned long size)
{
	if (size >= SZ_512K)
		return 19;
	else if (size >= SZ_16K)
		return 14;
	else
		return PAGE_SHIFT;
}


Christophe




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux