Skip to content

Commit

Permalink
arch,pt: do not flush entire TLB upon PT change
Browse files Browse the repository at this point in the history
Use INVLPG instead.

Signed-off-by: Pawel Wieczorkiewicz <[email protected]>
  • Loading branch information
wipawel committed Oct 25, 2023
1 parent 7d6e25f commit 9f7ae9c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 4 additions & 0 deletions arch/x86/pagetables.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ void dump_pagetables(cr3_t cr3) {
static inline void *tmp_map_mfn(mfn_t mfn) {
BUG_ON(mfn_invalid(mfn));
set_pgentry(_tmp_mapping_entry, mfn, L1_PROT);
invlpg(_tmp_mapping);
return _tmp_mapping;
}

Expand Down Expand Up @@ -199,6 +200,7 @@ static void *_vmap(cr3_t *cr3_ptr, void *va, mfn_t mfn, unsigned int order,
tab = tmp_map_mfn(l3t_mfn);
entry = &tab[l3_table_index(va)];
set_pgentry(entry, mfn, l3_flags | _PAGE_PSE);
invlpg(va);
goto done;
}

Expand All @@ -208,6 +210,7 @@ static void *_vmap(cr3_t *cr3_ptr, void *va, mfn_t mfn, unsigned int order,
tab = tmp_map_mfn(l2t_mfn);
entry = &tab[l2_table_index(va)];
set_pgentry(entry, mfn, l2_flags | _PAGE_PSE);
invlpg(va);
goto done;
}

Expand All @@ -216,6 +219,7 @@ static void *_vmap(cr3_t *cr3_ptr, void *va, mfn_t mfn, unsigned int order,
tab = tmp_map_mfn(l1t_mfn);
entry = &tab[l1_table_index(va)];
set_pgentry(entry, mfn, l1_flags);
invlpg(va);

done:
spin_unlock(&lock);
Expand Down
1 change: 0 additions & 1 deletion include/arch/x86/pagetable.h
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,6 @@ static inline pdpe_t *get_pdpe(const void *va) {
static inline void set_pgentry(pgentry_t *e, mfn_t mfn, unsigned long flags) {
*e = pgentry_from_mfn(mfn, flags);
barrier();
flush_tlb();
}

/* External declarations */
Expand Down

0 comments on commit 9f7ae9c

Please sign in to comment.