Skip to content

Commit 5ceeee7

Browse files
Peter Zijlstrahansendc
authored andcommitted
x86/mm: Add a few comments
It's a shame to hide useful comments in Changelogs, add some to the code. Shamelessly stolen from commit: c40a56a ("x86/mm/init: Remove freed kernel image areas from alias mapping") Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Link: https://lkml.kernel.org/r/20221110125544.460677011%40infradead.org
1 parent 80d0969 commit 5ceeee7

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

arch/x86/mm/pat/set_memory.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,23 @@ within_inclusive(unsigned long addr, unsigned long start, unsigned long end)
219219

220220
#ifdef CONFIG_X86_64
221221

222+
/*
223+
* The kernel image is mapped into two places in the virtual address space
224+
* (addresses without KASLR, of course):
225+
*
226+
* 1. The kernel direct map (0xffff880000000000)
227+
* 2. The "high kernel map" (0xffffffff81000000)
228+
*
229+
* We actually execute out of #2. If we get the address of a kernel symbol, it
230+
* points to #2, but almost all physical-to-virtual translations point to #1.
231+
*
232+
* This is so that we can have both a directmap of all physical memory *and*
233+
* take full advantage of the the limited (s32) immediate addressing range (2G)
234+
* of x86_64.
235+
*
236+
* See Documentation/x86/x86_64/mm.rst for more detail.
237+
*/
238+
222239
static inline unsigned long highmap_start_pfn(void)
223240
{
224241
return __pa_symbol(_text) >> PAGE_SHIFT;
@@ -1626,6 +1643,9 @@ static int __change_page_attr(struct cpa_data *cpa, int primary)
16261643

16271644
static int __change_page_attr_set_clr(struct cpa_data *cpa, int checkalias);
16281645

1646+
/*
1647+
* Check the directmap and "high kernel map" 'aliases'.
1648+
*/
16291649
static int cpa_process_alias(struct cpa_data *cpa)
16301650
{
16311651
struct cpa_data alias_cpa;

0 commit comments

Comments
 (0)