Skip to content

Commit 2873dc2

Browse files
committed
Merge branch 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 fixes from Ingo Molnar: "Misc fixes: a pkeys fix for a bug that triggers with weird BIOS settings, and two Xen PV fixes: a paravirt interface fix, and pagetable dumping fix" * 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/mm: Fix dump_pagetables with Xen PV x86/ioperm: Add new paravirt function update_io_bitmap() x86/pkeys: Manually set X86_FEATURE_OSPKE to preserve existing changes
2 parents c105df5 + bba42af commit 2873dc2

File tree

8 files changed

+52
-9
lines changed

8 files changed

+52
-9
lines changed

arch/x86/include/asm/io_bitmap.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,14 @@ struct task_struct;
1919
void io_bitmap_share(struct task_struct *tsk);
2020
void io_bitmap_exit(void);
2121

22-
void tss_update_io_bitmap(void);
22+
void native_tss_update_io_bitmap(void);
23+
24+
#ifdef CONFIG_PARAVIRT_XXL
25+
#include <asm/paravirt.h>
26+
#else
27+
#define tss_update_io_bitmap native_tss_update_io_bitmap
28+
#endif
29+
2330
#else
2431
static inline void io_bitmap_share(struct task_struct *tsk) { }
2532
static inline void io_bitmap_exit(void) { }

arch/x86/include/asm/paravirt.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,13 @@ static inline void write_idt_entry(gate_desc *dt, int entry, const gate_desc *g)
295295
PVOP_VCALL3(cpu.write_idt_entry, dt, entry, g);
296296
}
297297

298+
#ifdef CONFIG_X86_IOPL_IOPERM
299+
static inline void tss_update_io_bitmap(void)
300+
{
301+
PVOP_VCALL0(cpu.update_io_bitmap);
302+
}
303+
#endif
304+
298305
static inline void paravirt_activate_mm(struct mm_struct *prev,
299306
struct mm_struct *next)
300307
{

arch/x86/include/asm/paravirt_types.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,10 @@ struct pv_cpu_ops {
140140

141141
void (*load_sp0)(unsigned long sp0);
142142

143+
#ifdef CONFIG_X86_IOPL_IOPERM
144+
void (*update_io_bitmap)(void);
145+
#endif
146+
143147
void (*wbinvd)(void);
144148

145149
/* cpuid emulation, mostly so that caps bits can be disabled */

arch/x86/kernel/cpu/common.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ static __always_inline void setup_pku(struct cpuinfo_x86 *c)
445445
* cpuid bit to be set. We need to ensure that we
446446
* update that bit in this CPU's "cpu_info".
447447
*/
448-
get_cpu_cap(c);
448+
set_cpu_cap(c, X86_FEATURE_OSPKE);
449449
}
450450

451451
#ifdef CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS

arch/x86/kernel/paravirt.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include <asm/timer.h>
3131
#include <asm/special_insns.h>
3232
#include <asm/tlb.h>
33+
#include <asm/io_bitmap.h>
3334

3435
/*
3536
* nop stub, which must not clobber anything *including the stack* to
@@ -341,6 +342,10 @@ struct paravirt_patch_template pv_ops = {
341342
.cpu.iret = native_iret,
342343
.cpu.swapgs = native_swapgs,
343344

345+
#ifdef CONFIG_X86_IOPL_IOPERM
346+
.cpu.update_io_bitmap = native_tss_update_io_bitmap,
347+
#endif
348+
344349
.cpu.start_context_switch = paravirt_nop,
345350
.cpu.end_context_switch = paravirt_nop,
346351

arch/x86/kernel/process.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ static void tss_copy_io_bitmap(struct tss_struct *tss, struct io_bitmap *iobm)
374374
/**
375375
* tss_update_io_bitmap - Update I/O bitmap before exiting to usermode
376376
*/
377-
void tss_update_io_bitmap(void)
377+
void native_tss_update_io_bitmap(void)
378378
{
379379
struct tss_struct *tss = this_cpu_ptr(&cpu_tss_rw);
380380
struct thread_struct *t = &current->thread;

arch/x86/mm/dump_pagetables.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -363,13 +363,8 @@ static void ptdump_walk_pgd_level_core(struct seq_file *m,
363363
{
364364
const struct ptdump_range ptdump_ranges[] = {
365365
#ifdef CONFIG_X86_64
366-
367-
#define normalize_addr_shift (64 - (__VIRTUAL_MASK_SHIFT + 1))
368-
#define normalize_addr(u) ((signed long)((u) << normalize_addr_shift) >> \
369-
normalize_addr_shift)
370-
371366
{0, PTRS_PER_PGD * PGD_LEVEL_MULT / 2},
372-
{normalize_addr(PTRS_PER_PGD * PGD_LEVEL_MULT / 2), ~0UL},
367+
{GUARD_HOLE_END_ADDR, ~0UL},
373368
#else
374369
{0, ~0UL},
375370
#endif

arch/x86/xen/enlighten_pv.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@
7272
#include <asm/mwait.h>
7373
#include <asm/pci_x86.h>
7474
#include <asm/cpu.h>
75+
#ifdef CONFIG_X86_IOPL_IOPERM
76+
#include <asm/io_bitmap.h>
77+
#endif
7578

7679
#ifdef CONFIG_ACPI
7780
#include <linux/acpi.h>
@@ -837,6 +840,25 @@ static void xen_load_sp0(unsigned long sp0)
837840
this_cpu_write(cpu_tss_rw.x86_tss.sp0, sp0);
838841
}
839842

843+
#ifdef CONFIG_X86_IOPL_IOPERM
844+
static void xen_update_io_bitmap(void)
845+
{
846+
struct physdev_set_iobitmap iobitmap;
847+
struct tss_struct *tss = this_cpu_ptr(&cpu_tss_rw);
848+
849+
native_tss_update_io_bitmap();
850+
851+
iobitmap.bitmap = (uint8_t *)(&tss->x86_tss) +
852+
tss->x86_tss.io_bitmap_base;
853+
if (tss->x86_tss.io_bitmap_base == IO_BITMAP_OFFSET_INVALID)
854+
iobitmap.nr_ports = 0;
855+
else
856+
iobitmap.nr_ports = IO_BITMAP_BITS;
857+
858+
HYPERVISOR_physdev_op(PHYSDEVOP_set_iobitmap, &iobitmap);
859+
}
860+
#endif
861+
840862
static void xen_io_delay(void)
841863
{
842864
}
@@ -1047,6 +1069,9 @@ static const struct pv_cpu_ops xen_cpu_ops __initconst = {
10471069
.write_idt_entry = xen_write_idt_entry,
10481070
.load_sp0 = xen_load_sp0,
10491071

1072+
#ifdef CONFIG_X86_IOPL_IOPERM
1073+
.update_io_bitmap = xen_update_io_bitmap,
1074+
#endif
10501075
.io_delay = xen_io_delay,
10511076

10521077
/* Xen takes care of %gs when switching to usermode for us */

0 commit comments

Comments
 (0)