.. | .. |
---|
1 | 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ |
---|
2 | 2 | /* |
---|
3 | 3 | * |
---|
4 | | - * (C) COPYRIGHT 2012-2014, 2016-2018, 2020-2021 ARM Limited. All rights reserved. |
---|
| 4 | + * (C) COPYRIGHT 2012-2014, 2016-2018, 2020-2022 ARM Limited. All rights reserved. |
---|
5 | 5 | * |
---|
6 | 6 | * This program is free software and is provided to you under the terms of the |
---|
7 | 7 | * GNU General Public License version 2 as published by the Free Software |
---|
.. | .. |
---|
47 | 47 | #define HUGE_PAGE (1u << 0) |
---|
48 | 48 | #define HUGE_HEAD (1u << 1) |
---|
49 | 49 | #define FROM_PARTIAL (1u << 2) |
---|
| 50 | + |
---|
| 51 | +#define NUM_4K_PAGES_IN_2MB_PAGE (SZ_2M / SZ_4K) |
---|
50 | 52 | |
---|
51 | 53 | /* |
---|
52 | 54 | * Note: if macro for converting physical address to page is not defined |
---|
.. | .. |
---|
158 | 160 | return t.tagged_addr & FROM_PARTIAL; |
---|
159 | 161 | } |
---|
160 | 162 | |
---|
| 163 | +/** |
---|
| 164 | + * index_in_large_page() - Get index of a 4KB page within a 2MB page which |
---|
| 165 | + * wasn't split to be used partially. |
---|
| 166 | + * |
---|
| 167 | + * @t: Tagged physical address of the physical 4KB page that lies within |
---|
| 168 | + * the large (or 2 MB) physical page. |
---|
| 169 | + * |
---|
| 170 | + * Return: Index of the 4KB page within a 2MB page |
---|
| 171 | + */ |
---|
| 172 | +static inline unsigned int index_in_large_page(struct tagged_addr t) |
---|
| 173 | +{ |
---|
| 174 | + WARN_ON(!is_huge(t)); |
---|
| 175 | + |
---|
| 176 | + return (PFN_DOWN(as_phys_addr_t(t)) & (NUM_4K_PAGES_IN_2MB_PAGE - 1)); |
---|
| 177 | +} |
---|
| 178 | + |
---|
161 | 179 | #endif /* _KBASE_LOWLEVEL_H */ |
---|