Skip to content

Commit 59c80f0

Browse files
committed
Merge tag 'x86_urgent_for_v5.19_rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 fixes from Borislav Petkov: - Improve the check whether the kernel supports WP mappings so that it can accomodate a XenPV guest due to how the latter is setting up the PAT machinery - Now that the retbleed nightmare is public, here's the first round of fallout fixes: * Fix a build failure on 32-bit due to missing include * Remove an untraining point in espfix64 return path * other small cleanups * tag 'x86_urgent_for_v5.19_rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/bugs: Remove apostrophe typo um: Add missing apply_returns() x86/entry: Remove UNTRAIN_RET from native_irq_return_ldt x86/bugs: Mark retbleed_strings static x86/pat: Fix x86_has_pat_wp() x86/asm/32: Fix ANNOTATE_UNRET_SAFE use on 32-bit
2 parents 2eccaca + bcf1631 commit 59c80f0

File tree

5 files changed

+19
-5
lines changed

5 files changed

+19
-5
lines changed

arch/um/kernel/um_arch.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,10 @@ void apply_retpolines(s32 *start, s32 *end)
432432
{
433433
}
434434

435+
void apply_returns(s32 *start, s32 *end)
436+
{
437+
}
438+
435439
void apply_alternatives(struct alt_instr *start, struct alt_instr *end)
436440
{
437441
}

arch/x86/entry/entry_64.S

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,6 @@ native_irq_return_ldt:
727727
pushq %rdi /* Stash user RDI */
728728
swapgs /* to kernel GS */
729729
SWITCH_TO_KERNEL_CR3 scratch_reg=%rdi /* to kernel CR3 */
730-
UNTRAIN_RET
731730

732731
movq PER_CPU_VAR(espfix_waddr), %rdi
733732
movq %rax, (0*8)(%rdi) /* user RAX */

arch/x86/kernel/cpu/bugs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,7 @@ enum retbleed_mitigation_cmd {
793793
RETBLEED_CMD_IBPB,
794794
};
795795

796-
const char * const retbleed_strings[] = {
796+
static const char * const retbleed_strings[] = {
797797
[RETBLEED_MITIGATION_NONE] = "Vulnerable",
798798
[RETBLEED_MITIGATION_UNRET] = "Mitigation: untrained return thunk",
799799
[RETBLEED_MITIGATION_IBPB] = "Mitigation: IBPB",
@@ -1181,7 +1181,7 @@ spectre_v2_user_select_mitigation(void)
11811181
if (retbleed_mitigation == RETBLEED_MITIGATION_UNRET) {
11821182
if (mode != SPECTRE_V2_USER_STRICT &&
11831183
mode != SPECTRE_V2_USER_STRICT_PREFERRED)
1184-
pr_info("Selecting STIBP always-on mode to complement retbleed mitigation'\n");
1184+
pr_info("Selecting STIBP always-on mode to complement retbleed mitigation\n");
11851185
mode = SPECTRE_V2_USER_STRICT_PREFERRED;
11861186
}
11871187

arch/x86/kernel/head_32.S

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <asm/cpufeatures.h>
2424
#include <asm/percpu.h>
2525
#include <asm/nops.h>
26+
#include <asm/nospec-branch.h>
2627
#include <asm/bootparam.h>
2728
#include <asm/export.h>
2829
#include <asm/pgtable_32.h>

arch/x86/mm/init.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,20 @@ static uint8_t __pte2cachemode_tbl[8] = {
7777
[__pte2cm_idx(_PAGE_PWT | _PAGE_PCD | _PAGE_PAT)] = _PAGE_CACHE_MODE_UC,
7878
};
7979

80-
/* Check that the write-protect PAT entry is set for write-protect */
80+
/*
81+
* Check that the write-protect PAT entry is set for write-protect.
82+
* To do this without making assumptions how PAT has been set up (Xen has
83+
* another layout than the kernel), translate the _PAGE_CACHE_MODE_WP cache
84+
* mode via the __cachemode2pte_tbl[] into protection bits (those protection
85+
* bits will select a cache mode of WP or better), and then translate the
86+
* protection bits back into the cache mode using __pte2cm_idx() and the
87+
* __pte2cachemode_tbl[] array. This will return the really used cache mode.
88+
*/
8189
bool x86_has_pat_wp(void)
8290
{
83-
return __pte2cachemode_tbl[_PAGE_CACHE_MODE_WP] == _PAGE_CACHE_MODE_WP;
91+
uint16_t prot = __cachemode2pte_tbl[_PAGE_CACHE_MODE_WP];
92+
93+
return __pte2cachemode_tbl[__pte2cm_idx(prot)] == _PAGE_CACHE_MODE_WP;
8494
}
8595

8696
enum page_cache_mode pgprot2cachemode(pgprot_t pgprot)

0 commit comments

Comments
 (0)