diff options
| author | Ingo Molnar <mingo@kernel.org> | 2018-10-09 02:50:10 -0400 |
|---|---|---|
| committer | Ingo Molnar <mingo@kernel.org> | 2018-10-09 02:50:10 -0400 |
| commit | fc8eaa85681fa72dc6a4e46f01c92e4fba83d0ab (patch) | |
| tree | b044fab426f2167ceeb37ed6fe58f7f11b10cebd /arch | |
| parent | 2cc81c6992248ea37d0241bc325977bab310bc3b (diff) | |
| parent | 49e00eee00612b1357596fed8a88b621a7648c14 (diff) | |
Merge branch 'x86/urgent' into x86/cache, to pick up dependent fix
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'arch')
36 files changed, 385 insertions, 165 deletions
diff --git a/arch/arm/boot/dts/at91-sama5d2_ptc_ek.dts b/arch/arm/boot/dts/at91-sama5d2_ptc_ek.dts index b10dccd0958f..3b1baa8605a7 100644 --- a/arch/arm/boot/dts/at91-sama5d2_ptc_ek.dts +++ b/arch/arm/boot/dts/at91-sama5d2_ptc_ek.dts | |||
| @@ -11,6 +11,7 @@ | |||
| 11 | #include "sama5d2-pinfunc.h" | 11 | #include "sama5d2-pinfunc.h" |
| 12 | #include <dt-bindings/mfd/atmel-flexcom.h> | 12 | #include <dt-bindings/mfd/atmel-flexcom.h> |
| 13 | #include <dt-bindings/gpio/gpio.h> | 13 | #include <dt-bindings/gpio/gpio.h> |
| 14 | #include <dt-bindings/pinctrl/at91.h> | ||
| 14 | 15 | ||
| 15 | / { | 16 | / { |
| 16 | model = "Atmel SAMA5D2 PTC EK"; | 17 | model = "Atmel SAMA5D2 PTC EK"; |
| @@ -299,6 +300,7 @@ | |||
| 299 | <PIN_PA30__NWE_NANDWE>, | 300 | <PIN_PA30__NWE_NANDWE>, |
| 300 | <PIN_PB2__NRD_NANDOE>; | 301 | <PIN_PB2__NRD_NANDOE>; |
| 301 | bias-pull-up; | 302 | bias-pull-up; |
| 303 | atmel,drive-strength = <ATMEL_PIO_DRVSTR_ME>; | ||
| 302 | }; | 304 | }; |
| 303 | 305 | ||
| 304 | ale_cle_rdy_cs { | 306 | ale_cle_rdy_cs { |
diff --git a/arch/arm/boot/dts/bcm63138.dtsi b/arch/arm/boot/dts/bcm63138.dtsi index 43ee992ccdcf..6df61518776f 100644 --- a/arch/arm/boot/dts/bcm63138.dtsi +++ b/arch/arm/boot/dts/bcm63138.dtsi | |||
| @@ -106,21 +106,23 @@ | |||
| 106 | global_timer: timer@1e200 { | 106 | global_timer: timer@1e200 { |
| 107 | compatible = "arm,cortex-a9-global-timer"; | 107 | compatible = "arm,cortex-a9-global-timer"; |
| 108 | reg = <0x1e200 0x20>; | 108 | reg = <0x1e200 0x20>; |
| 109 | interrupts = <GIC_PPI 11 IRQ_TYPE_LEVEL_HIGH>; | 109 | interrupts = <GIC_PPI 11 IRQ_TYPE_EDGE_RISING>; |
| 110 | clocks = <&axi_clk>; | 110 | clocks = <&axi_clk>; |
| 111 | }; | 111 | }; |
| 112 | 112 | ||
| 113 | local_timer: local-timer@1e600 { | 113 | local_timer: local-timer@1e600 { |
| 114 | compatible = "arm,cortex-a9-twd-timer"; | 114 | compatible = "arm,cortex-a9-twd-timer"; |
| 115 | reg = <0x1e600 0x20>; | 115 | reg = <0x1e600 0x20>; |
| 116 | interrupts = <GIC_PPI 13 IRQ_TYPE_LEVEL_HIGH>; | 116 | interrupts = <GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(2) | |
| 117 | IRQ_TYPE_EDGE_RISING)>; | ||
| 117 | clocks = <&axi_clk>; | 118 | clocks = <&axi_clk>; |
| 118 | }; | 119 | }; |
| 119 | 120 | ||
| 120 | twd_watchdog: watchdog@1e620 { | 121 | twd_watchdog: watchdog@1e620 { |
| 121 | compatible = "arm,cortex-a9-twd-wdt"; | 122 | compatible = "arm,cortex-a9-twd-wdt"; |
| 122 | reg = <0x1e620 0x20>; | 123 | reg = <0x1e620 0x20>; |
| 123 | interrupts = <GIC_PPI 14 IRQ_TYPE_LEVEL_HIGH>; | 124 | interrupts = <GIC_PPI 14 (GIC_CPU_MASK_SIMPLE(2) | |
| 125 | IRQ_TYPE_LEVEL_HIGH)>; | ||
| 124 | }; | 126 | }; |
| 125 | 127 | ||
| 126 | armpll: armpll { | 128 | armpll: armpll { |
| @@ -158,7 +160,7 @@ | |||
| 158 | serial0: serial@600 { | 160 | serial0: serial@600 { |
| 159 | compatible = "brcm,bcm6345-uart"; | 161 | compatible = "brcm,bcm6345-uart"; |
| 160 | reg = <0x600 0x1b>; | 162 | reg = <0x600 0x1b>; |
| 161 | interrupts = <GIC_SPI 32 0>; | 163 | interrupts = <GIC_SPI 32 IRQ_TYPE_LEVEL_HIGH>; |
| 162 | clocks = <&periph_clk>; | 164 | clocks = <&periph_clk>; |
| 163 | clock-names = "periph"; | 165 | clock-names = "periph"; |
| 164 | status = "disabled"; | 166 | status = "disabled"; |
| @@ -167,7 +169,7 @@ | |||
| 167 | serial1: serial@620 { | 169 | serial1: serial@620 { |
| 168 | compatible = "brcm,bcm6345-uart"; | 170 | compatible = "brcm,bcm6345-uart"; |
| 169 | reg = <0x620 0x1b>; | 171 | reg = <0x620 0x1b>; |
| 170 | interrupts = <GIC_SPI 33 0>; | 172 | interrupts = <GIC_SPI 33 IRQ_TYPE_LEVEL_HIGH>; |
| 171 | clocks = <&periph_clk>; | 173 | clocks = <&periph_clk>; |
| 172 | clock-names = "periph"; | 174 | clock-names = "periph"; |
| 173 | status = "disabled"; | 175 | status = "disabled"; |
| @@ -180,7 +182,7 @@ | |||
| 180 | reg = <0x2000 0x600>, <0xf0 0x10>; | 182 | reg = <0x2000 0x600>, <0xf0 0x10>; |
| 181 | reg-names = "nand", "nand-int-base"; | 183 | reg-names = "nand", "nand-int-base"; |
| 182 | status = "disabled"; | 184 | status = "disabled"; |
| 183 | interrupts = <GIC_SPI 38 0>; | 185 | interrupts = <GIC_SPI 38 IRQ_TYPE_LEVEL_HIGH>; |
| 184 | interrupt-names = "nand"; | 186 | interrupt-names = "nand"; |
| 185 | }; | 187 | }; |
| 186 | 188 | ||
diff --git a/arch/arm/boot/dts/stm32mp157c.dtsi b/arch/arm/boot/dts/stm32mp157c.dtsi index 661be948ab74..185541a5b69f 100644 --- a/arch/arm/boot/dts/stm32mp157c.dtsi +++ b/arch/arm/boot/dts/stm32mp157c.dtsi | |||
| @@ -1078,8 +1078,8 @@ | |||
| 1078 | interrupts = <GIC_SPI 86 IRQ_TYPE_LEVEL_HIGH>; | 1078 | interrupts = <GIC_SPI 86 IRQ_TYPE_LEVEL_HIGH>; |
| 1079 | clocks = <&rcc SPI6_K>; | 1079 | clocks = <&rcc SPI6_K>; |
| 1080 | resets = <&rcc SPI6_R>; | 1080 | resets = <&rcc SPI6_R>; |
| 1081 | dmas = <&mdma1 34 0x0 0x40008 0x0 0x0 0>, | 1081 | dmas = <&mdma1 34 0x0 0x40008 0x0 0x0>, |
| 1082 | <&mdma1 35 0x0 0x40002 0x0 0x0 0>; | 1082 | <&mdma1 35 0x0 0x40002 0x0 0x0>; |
| 1083 | dma-names = "rx", "tx"; | 1083 | dma-names = "rx", "tx"; |
| 1084 | status = "disabled"; | 1084 | status = "disabled"; |
| 1085 | }; | 1085 | }; |
diff --git a/arch/arm/boot/dts/sun8i-r40.dtsi b/arch/arm/boot/dts/sun8i-r40.dtsi index ffd9f00f74a4..5f547c161baf 100644 --- a/arch/arm/boot/dts/sun8i-r40.dtsi +++ b/arch/arm/boot/dts/sun8i-r40.dtsi | |||
| @@ -800,8 +800,7 @@ | |||
| 800 | }; | 800 | }; |
| 801 | 801 | ||
| 802 | hdmi_phy: hdmi-phy@1ef0000 { | 802 | hdmi_phy: hdmi-phy@1ef0000 { |
| 803 | compatible = "allwinner,sun8i-r40-hdmi-phy", | 803 | compatible = "allwinner,sun8i-r40-hdmi-phy"; |
| 804 | "allwinner,sun50i-a64-hdmi-phy"; | ||
| 805 | reg = <0x01ef0000 0x10000>; | 804 | reg = <0x01ef0000 0x10000>; |
| 806 | clocks = <&ccu CLK_BUS_HDMI1>, <&ccu CLK_HDMI_SLOW>, | 805 | clocks = <&ccu CLK_BUS_HDMI1>, <&ccu CLK_HDMI_SLOW>, |
| 807 | <&ccu 7>, <&ccu 16>; | 806 | <&ccu 7>, <&ccu 16>; |
diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c index fc91205ff46c..5bf9443cfbaa 100644 --- a/arch/arm/mm/ioremap.c +++ b/arch/arm/mm/ioremap.c | |||
| @@ -473,7 +473,7 @@ void pci_ioremap_set_mem_type(int mem_type) | |||
| 473 | 473 | ||
| 474 | int pci_ioremap_io(unsigned int offset, phys_addr_t phys_addr) | 474 | int pci_ioremap_io(unsigned int offset, phys_addr_t phys_addr) |
| 475 | { | 475 | { |
| 476 | BUG_ON(offset + SZ_64K > IO_SPACE_LIMIT); | 476 | BUG_ON(offset + SZ_64K - 1 > IO_SPACE_LIMIT); |
| 477 | 477 | ||
| 478 | return ioremap_page_range(PCI_IO_VIRT_BASE + offset, | 478 | return ioremap_page_range(PCI_IO_VIRT_BASE + offset, |
| 479 | PCI_IO_VIRT_BASE + offset + SZ_64K, | 479 | PCI_IO_VIRT_BASE + offset + SZ_64K, |
diff --git a/arch/arm/tools/syscall.tbl b/arch/arm/tools/syscall.tbl index fbc74b5fa3ed..8edf93b4490f 100644 --- a/arch/arm/tools/syscall.tbl +++ b/arch/arm/tools/syscall.tbl | |||
| @@ -413,3 +413,4 @@ | |||
| 413 | 396 common pkey_free sys_pkey_free | 413 | 396 common pkey_free sys_pkey_free |
| 414 | 397 common statx sys_statx | 414 | 397 common statx sys_statx |
| 415 | 398 common rseq sys_rseq | 415 | 398 common rseq sys_rseq |
| 416 | 399 common io_pgetevents sys_io_pgetevents | ||
diff --git a/arch/arm64/kvm/guest.c b/arch/arm64/kvm/guest.c index 07256b08226c..a6c9fbaeaefc 100644 --- a/arch/arm64/kvm/guest.c +++ b/arch/arm64/kvm/guest.c | |||
| @@ -57,6 +57,45 @@ static u64 core_reg_offset_from_id(u64 id) | |||
| 57 | return id & ~(KVM_REG_ARCH_MASK | KVM_REG_SIZE_MASK | KVM_REG_ARM_CORE); | 57 | return id & ~(KVM_REG_ARCH_MASK | KVM_REG_SIZE_MASK | KVM_REG_ARM_CORE); |
| 58 | } | 58 | } |
| 59 | 59 | ||
| 60 | static int validate_core_offset(const struct kvm_one_reg *reg) | ||
| 61 | { | ||
| 62 | u64 off = core_reg_offset_from_id(reg->id); | ||
| 63 | int size; | ||
| 64 | |||
| 65 | switch (off) { | ||
| 66 | case KVM_REG_ARM_CORE_REG(regs.regs[0]) ... | ||
| 67 | KVM_REG_ARM_CORE_REG(regs.regs[30]): | ||
| 68 | case KVM_REG_ARM_CORE_REG(regs.sp): | ||
| 69 | case KVM_REG_ARM_CORE_REG(regs.pc): | ||
| 70 | case KVM_REG_ARM_CORE_REG(regs.pstate): | ||
| 71 | case KVM_REG_ARM_CORE_REG(sp_el1): | ||
| 72 | case KVM_REG_ARM_CORE_REG(elr_el1): | ||
| 73 | case KVM_REG_ARM_CORE_REG(spsr[0]) ... | ||
| 74 | KVM_REG_ARM_CORE_REG(spsr[KVM_NR_SPSR - 1]): | ||
| 75 | size = sizeof(__u64); | ||
| 76 | break; | ||
| 77 | |||
| 78 | case KVM_REG_ARM_CORE_REG(fp_regs.vregs[0]) ... | ||
| 79 | KVM_REG_ARM_CORE_REG(fp_regs.vregs[31]): | ||
| 80 | size = sizeof(__uint128_t); | ||
| 81 | break; | ||
| 82 | |||
| 83 | case KVM_REG_ARM_CORE_REG(fp_regs.fpsr): | ||
| 84 | case KVM_REG_ARM_CORE_REG(fp_regs.fpcr): | ||
| 85 | size = sizeof(__u32); | ||
| 86 | break; | ||
| 87 | |||
| 88 | default: | ||
| 89 | return -EINVAL; | ||
| 90 | } | ||
| 91 | |||
| 92 | if (KVM_REG_SIZE(reg->id) == size && | ||
| 93 | IS_ALIGNED(off, size / sizeof(__u32))) | ||
| 94 | return 0; | ||
| 95 | |||
| 96 | return -EINVAL; | ||
| 97 | } | ||
| 98 | |||
| 60 | static int get_core_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg) | 99 | static int get_core_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg) |
| 61 | { | 100 | { |
| 62 | /* | 101 | /* |
| @@ -76,6 +115,9 @@ static int get_core_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg) | |||
| 76 | (off + (KVM_REG_SIZE(reg->id) / sizeof(__u32))) >= nr_regs) | 115 | (off + (KVM_REG_SIZE(reg->id) / sizeof(__u32))) >= nr_regs) |
| 77 | return -ENOENT; | 116 | return -ENOENT; |
| 78 | 117 | ||
| 118 | if (validate_core_offset(reg)) | ||
| 119 | return -EINVAL; | ||
| 120 | |||
| 79 | if (copy_to_user(uaddr, ((u32 *)regs) + off, KVM_REG_SIZE(reg->id))) | 121 | if (copy_to_user(uaddr, ((u32 *)regs) + off, KVM_REG_SIZE(reg->id))) |
| 80 | return -EFAULT; | 122 | return -EFAULT; |
| 81 | 123 | ||
| @@ -98,6 +140,9 @@ static int set_core_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg) | |||
| 98 | (off + (KVM_REG_SIZE(reg->id) / sizeof(__u32))) >= nr_regs) | 140 | (off + (KVM_REG_SIZE(reg->id) / sizeof(__u32))) >= nr_regs) |
| 99 | return -ENOENT; | 141 | return -ENOENT; |
| 100 | 142 | ||
| 143 | if (validate_core_offset(reg)) | ||
| 144 | return -EINVAL; | ||
| 145 | |||
| 101 | if (KVM_REG_SIZE(reg->id) > sizeof(tmp)) | 146 | if (KVM_REG_SIZE(reg->id) > sizeof(tmp)) |
| 102 | return -EINVAL; | 147 | return -EINVAL; |
| 103 | 148 | ||
| @@ -107,17 +152,25 @@ static int set_core_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg) | |||
| 107 | } | 152 | } |
| 108 | 153 | ||
| 109 | if (off == KVM_REG_ARM_CORE_REG(regs.pstate)) { | 154 | if (off == KVM_REG_ARM_CORE_REG(regs.pstate)) { |
| 110 | u32 mode = (*(u32 *)valp) & PSR_AA32_MODE_MASK; | 155 | u64 mode = (*(u64 *)valp) & PSR_AA32_MODE_MASK; |
| 111 | switch (mode) { | 156 | switch (mode) { |
| 112 | case PSR_AA32_MODE_USR: | 157 | case PSR_AA32_MODE_USR: |
| 158 | if (!system_supports_32bit_el0()) | ||
| 159 | return -EINVAL; | ||
| 160 | break; | ||
| 113 | case PSR_AA32_MODE_FIQ: | 161 | case PSR_AA32_MODE_FIQ: |
| 114 | case PSR_AA32_MODE_IRQ: | 162 | case PSR_AA32_MODE_IRQ: |
| 115 | case PSR_AA32_MODE_SVC: | 163 | case PSR_AA32_MODE_SVC: |
| 116 | case PSR_AA32_MODE_ABT: | 164 | case PSR_AA32_MODE_ABT: |
| 117 | case PSR_AA32_MODE_UND: | 165 | case PSR_AA32_MODE_UND: |
| 166 | if (!vcpu_el1_is_32bit(vcpu)) | ||
| 167 | return -EINVAL; | ||
| 168 | break; | ||
| 118 | case PSR_MODE_EL0t: | 169 | case PSR_MODE_EL0t: |
| 119 | case PSR_MODE_EL1t: | 170 | case PSR_MODE_EL1t: |
| 120 | case PSR_MODE_EL1h: | 171 | case PSR_MODE_EL1h: |
| 172 | if (vcpu_el1_is_32bit(vcpu)) | ||
| 173 | return -EINVAL; | ||
| 121 | break; | 174 | break; |
| 122 | default: | 175 | default: |
| 123 | err = -EINVAL; | 176 | err = -EINVAL; |
diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c index 192b3ba07075..f58ea503ad01 100644 --- a/arch/arm64/mm/hugetlbpage.c +++ b/arch/arm64/mm/hugetlbpage.c | |||
| @@ -117,11 +117,14 @@ static pte_t get_clear_flush(struct mm_struct *mm, | |||
| 117 | 117 | ||
| 118 | /* | 118 | /* |
| 119 | * If HW_AFDBM is enabled, then the HW could turn on | 119 | * If HW_AFDBM is enabled, then the HW could turn on |
| 120 | * the dirty bit for any page in the set, so check | 120 | * the dirty or accessed bit for any page in the set, |
| 121 | * them all. All hugetlb entries are already young. | 121 | * so check them all. |
| 122 | */ | 122 | */ |
| 123 | if (pte_dirty(pte)) | 123 | if (pte_dirty(pte)) |
| 124 | orig_pte = pte_mkdirty(orig_pte); | 124 | orig_pte = pte_mkdirty(orig_pte); |
| 125 | |||
| 126 | if (pte_young(pte)) | ||
| 127 | orig_pte = pte_mkyoung(orig_pte); | ||
| 125 | } | 128 | } |
| 126 | 129 | ||
| 127 | if (valid) { | 130 | if (valid) { |
| @@ -320,11 +323,40 @@ pte_t huge_ptep_get_and_clear(struct mm_struct *mm, | |||
| 320 | return get_clear_flush(mm, addr, ptep, pgsize, ncontig); | 323 | return get_clear_flush(mm, addr, ptep, pgsize, ncontig); |
| 321 | } | 324 | } |
| 322 | 325 | ||
| 326 | /* | ||
| 327 | * huge_ptep_set_access_flags will update access flags (dirty, accesssed) | ||
| 328 | * and write permission. | ||
| 329 | * | ||
| 330 | * For a contiguous huge pte range we need to check whether or not write | ||
| 331 | * permission has to change only on the first pte in the set. Then for | ||
| 332 | * all the contiguous ptes we need to check whether or not there is a | ||
| 333 | * discrepancy between dirty or young. | ||
| 334 | */ | ||
| 335 | static int __cont_access_flags_changed(pte_t *ptep, pte_t pte, int ncontig) | ||
| 336 | { | ||
| 337 | int i; | ||
| 338 | |||
| 339 | if (pte_write(pte) != pte_write(huge_ptep_get(ptep))) | ||
| 340 | return 1; | ||
| 341 | |||
| 342 | for (i = 0; i < ncontig; i++) { | ||
| 343 | pte_t orig_pte = huge_ptep_get(ptep + i); | ||
| 344 | |||
| 345 | if (pte_dirty(pte) != pte_dirty(orig_pte)) | ||
| 346 | return 1; | ||
| 347 | |||
| 348 | if (pte_young(pte) != pte_young(orig_pte)) | ||
| 349 | return 1; | ||
| 350 | } | ||
| 351 | |||
| 352 | return 0; | ||
| 353 | } | ||
| 354 | |||
| 323 | int huge_ptep_set_access_flags(struct vm_area_struct *vma, | 355 | int huge_ptep_set_access_flags(struct vm_area_struct *vma, |
| 324 | unsigned long addr, pte_t *ptep, | 356 | unsigned long addr, pte_t *ptep, |
| 325 | pte_t pte, int dirty) | 357 | pte_t pte, int dirty) |
| 326 | { | 358 | { |
| 327 | int ncontig, i, changed = 0; | 359 | int ncontig, i; |
| 328 | size_t pgsize = 0; | 360 | size_t pgsize = 0; |
| 329 | unsigned long pfn = pte_pfn(pte), dpfn; | 361 | unsigned long pfn = pte_pfn(pte), dpfn; |
| 330 | pgprot_t hugeprot; | 362 | pgprot_t hugeprot; |
| @@ -336,19 +368,23 @@ int huge_ptep_set_access_flags(struct vm_area_struct *vma, | |||
| 336 | ncontig = find_num_contig(vma->vm_mm, addr, ptep, &pgsize); | 368 | ncontig = find_num_contig(vma->vm_mm, addr, ptep, &pgsize); |
| 337 | dpfn = pgsize >> PAGE_SHIFT; | 369 | dpfn = pgsize >> PAGE_SHIFT; |
| 338 | 370 | ||
| 371 | if (!__cont_access_flags_changed(ptep, pte, ncontig)) | ||
| 372 | return 0; | ||
| 373 | |||
| 339 | orig_pte = get_clear_flush(vma->vm_mm, addr, ptep, pgsize, ncontig); | 374 | orig_pte = get_clear_flush(vma->vm_mm, addr, ptep, pgsize, ncontig); |
| 340 | if (!pte_same(orig_pte, pte)) | ||
| 341 | changed = 1; | ||
| 342 | 375 | ||
| 343 | /* Make sure we don't lose the dirty state */ | 376 | /* Make sure we don't lose the dirty or young state */ |
| 344 | if (pte_dirty(orig_pte)) | 377 | if (pte_dirty(orig_pte)) |
| 345 | pte = pte_mkdirty(pte); | 378 | pte = pte_mkdirty(pte); |
| 346 | 379 | ||
| 380 | if (pte_young(orig_pte)) | ||
| 381 | pte = pte_mkyoung(pte); | ||
| 382 | |||
| 347 | hugeprot = pte_pgprot(pte); | 383 | hugeprot = pte_pgprot(pte); |
| 348 | for (i = 0; i < ncontig; i++, ptep++, addr += pgsize, pfn += dpfn) | 384 | for (i = 0; i < ncontig; i++, ptep++, addr += pgsize, pfn += dpfn) |
| 349 | set_pte_at(vma->vm_mm, addr, ptep, pfn_pte(pfn, hugeprot)); | 385 | set_pte_at(vma->vm_mm, addr, ptep, pfn_pte(pfn, hugeprot)); |
| 350 | 386 | ||
| 351 | return changed; | 387 | return 1; |
| 352 | } | 388 | } |
| 353 | 389 | ||
| 354 | void huge_ptep_set_wrprotect(struct mm_struct *mm, | 390 | void huge_ptep_set_wrprotect(struct mm_struct *mm, |
diff --git a/arch/powerpc/include/asm/setup.h b/arch/powerpc/include/asm/setup.h index 1a951b00465d..1fffbba8d6a5 100644 --- a/arch/powerpc/include/asm/setup.h +++ b/arch/powerpc/include/asm/setup.h | |||
| @@ -9,6 +9,7 @@ extern void ppc_printk_progress(char *s, unsigned short hex); | |||
| 9 | 9 | ||
| 10 | extern unsigned int rtas_data; | 10 | extern unsigned int rtas_data; |
| 11 | extern unsigned long long memory_limit; | 11 | extern unsigned long long memory_limit; |
| 12 | extern bool init_mem_is_free; | ||
| 12 | extern unsigned long klimit; | 13 | extern unsigned long klimit; |
| 13 | extern void *zalloc_maybe_bootmem(size_t size, gfp_t mask); | 14 | extern void *zalloc_maybe_bootmem(size_t size, gfp_t mask); |
| 14 | 15 | ||
diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S index ea04dfb8c092..2d8fc8c9da7a 100644 --- a/arch/powerpc/kernel/exceptions-64s.S +++ b/arch/powerpc/kernel/exceptions-64s.S | |||
| @@ -1314,9 +1314,7 @@ EXC_REAL_BEGIN(denorm_exception_hv, 0x1500, 0x100) | |||
| 1314 | 1314 | ||
| 1315 | #ifdef CONFIG_PPC_DENORMALISATION | 1315 | #ifdef CONFIG_PPC_DENORMALISATION |
| 1316 | mfspr r10,SPRN_HSRR1 | 1316 | mfspr r10,SPRN_HSRR1 |
| 1317 | mfspr r11,SPRN_HSRR0 /* save HSRR0 */ | ||
| 1318 | andis. r10,r10,(HSRR1_DENORM)@h /* denorm? */ | 1317 | andis. r10,r10,(HSRR1_DENORM)@h /* denorm? */ |
| 1319 | addi r11,r11,-4 /* HSRR0 is next instruction */ | ||
| 1320 | bne+ denorm_assist | 1318 | bne+ denorm_assist |
| 1321 | #endif | 1319 | #endif |
| 1322 | 1320 | ||
| @@ -1382,6 +1380,8 @@ END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_207S) | |||
| 1382 | */ | 1380 | */ |
| 1383 | XVCPSGNDP32(32) | 1381 | XVCPSGNDP32(32) |
| 1384 | denorm_done: | 1382 | denorm_done: |
| 1383 | mfspr r11,SPRN_HSRR0 | ||
| 1384 | subi r11,r11,4 | ||
| 1385 | mtspr SPRN_HSRR0,r11 | 1385 | mtspr SPRN_HSRR0,r11 |
| 1386 | mtcrf 0x80,r9 | 1386 | mtcrf 0x80,r9 |
| 1387 | ld r9,PACA_EXGEN+EX_R9(r13) | 1387 | ld r9,PACA_EXGEN+EX_R9(r13) |
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c index 913c5725cdb2..bb6ac471a784 100644 --- a/arch/powerpc/kernel/process.c +++ b/arch/powerpc/kernel/process.c | |||
| @@ -1306,6 +1306,16 @@ void show_user_instructions(struct pt_regs *regs) | |||
| 1306 | 1306 | ||
| 1307 | pc = regs->nip - (instructions_to_print * 3 / 4 * sizeof(int)); | 1307 | pc = regs->nip - (instructions_to_print * 3 / 4 * sizeof(int)); |
| 1308 | 1308 | ||
| 1309 | /* | ||
| 1310 | * Make sure the NIP points at userspace, not kernel text/data or | ||
| 1311 | * elsewhere. | ||
| 1312 | */ | ||
| 1313 | if (!__access_ok(pc, instructions_to_print * sizeof(int), USER_DS)) { | ||
| 1314 | pr_info("%s[%d]: Bad NIP, not dumping instructions.\n", | ||
| 1315 | current->comm, current->pid); | ||
| 1316 | return; | ||
| 1317 | } | ||
| 1318 | |||
| 1309 | pr_info("%s[%d]: code: ", current->comm, current->pid); | 1319 | pr_info("%s[%d]: code: ", current->comm, current->pid); |
| 1310 | 1320 | ||
| 1311 | for (i = 0; i < instructions_to_print; i++) { | 1321 | for (i = 0; i < instructions_to_print; i++) { |
diff --git a/arch/powerpc/kernel/tm.S b/arch/powerpc/kernel/tm.S index 6bffbc5affe7..7716374786bd 100644 --- a/arch/powerpc/kernel/tm.S +++ b/arch/powerpc/kernel/tm.S | |||
| @@ -176,13 +176,27 @@ _GLOBAL(tm_reclaim) | |||
| 176 | std r1, PACATMSCRATCH(r13) | 176 | std r1, PACATMSCRATCH(r13) |
| 177 | ld r1, PACAR1(r13) | 177 | ld r1, PACAR1(r13) |
| 178 | 178 | ||
| 179 | /* Store the PPR in r11 and reset to decent value */ | ||
| 180 | std r11, GPR11(r1) /* Temporary stash */ | 179 | std r11, GPR11(r1) /* Temporary stash */ |
| 181 | 180 | ||
| 181 | /* | ||
| 182 | * Move the saved user r1 to the kernel stack in case PACATMSCRATCH is | ||
| 183 | * clobbered by an exception once we turn on MSR_RI below. | ||
| 184 | */ | ||
| 185 | ld r11, PACATMSCRATCH(r13) | ||
| 186 | std r11, GPR1(r1) | ||
| 187 | |||
| 188 | /* | ||
| 189 | * Store r13 away so we can free up the scratch SPR for the SLB fault | ||
| 190 | * handler (needed once we start accessing the thread_struct). | ||
| 191 | */ | ||
| 192 | GET_SCRATCH0(r11) | ||
| 193 | std r11, GPR13(r1) | ||
| 194 | |||
| 182 | /* Reset MSR RI so we can take SLB faults again */ | 195 | /* Reset MSR RI so we can take SLB faults again */ |
| 183 | li r11, MSR_RI | 196 | li r11, MSR_RI |
| 184 | mtmsrd r11, 1 | 197 | mtmsrd r11, 1 |
| 185 | 198 | ||
| 199 | /* Store the PPR in r11 and reset to decent value */ | ||
| 186 | mfspr r11, SPRN_PPR | 200 | mfspr r11, SPRN_PPR |
| 187 | HMT_MEDIUM | 201 | HMT_MEDIUM |
| 188 | 202 | ||
| @@ -207,11 +221,11 @@ _GLOBAL(tm_reclaim) | |||
| 207 | SAVE_GPR(8, r7) /* user r8 */ | 221 | SAVE_GPR(8, r7) /* user r8 */ |
| 208 | SAVE_GPR(9, r7) /* user r9 */ | 222 | SAVE_GPR(9, r7) /* user r9 */ |
| 209 | SAVE_GPR(10, r7) /* user r10 */ | 223 | SAVE_GPR(10, r7) /* user r10 */ |
| 210 | ld r3, PACATMSCRATCH(r13) /* user r1 */ | 224 | ld r3, GPR1(r1) /* user r1 */ |
| 211 | ld r4, GPR7(r1) /* user r7 */ | 225 | ld r4, GPR7(r1) /* user r7 */ |
| 212 | ld r5, GPR11(r1) /* user r11 */ | 226 | ld r5, GPR11(r1) /* user r11 */ |
| 213 | ld r6, GPR12(r1) /* user r12 */ | 227 | ld r6, GPR12(r1) /* user r12 */ |
| 214 | GET_SCRATCH0(8) /* user r13 */ | 228 | ld r8, GPR13(r1) /* user r13 */ |
| 215 | std r3, GPR1(r7) | 229 | std r3, GPR1(r7) |
| 216 | std r4, GPR7(r7) | 230 | std r4, GPR7(r7) |
| 217 | std r5, GPR11(r7) | 231 | std r5, GPR11(r7) |
diff --git a/arch/powerpc/kvm/book3s_64_mmu_radix.c b/arch/powerpc/kvm/book3s_64_mmu_radix.c index 933c574e1cf7..998f8d089ac7 100644 --- a/arch/powerpc/kvm/book3s_64_mmu_radix.c +++ b/arch/powerpc/kvm/book3s_64_mmu_radix.c | |||
| @@ -646,6 +646,16 @@ int kvmppc_book3s_radix_page_fault(struct kvm_run *run, struct kvm_vcpu *vcpu, | |||
| 646 | */ | 646 | */ |
| 647 | local_irq_disable(); | 647 | local_irq_disable(); |
| 648 | ptep = __find_linux_pte(vcpu->arch.pgdir, hva, NULL, &shift); | 648 | ptep = __find_linux_pte(vcpu->arch.pgdir, hva, NULL, &shift); |
| 649 | /* | ||
| 650 | * If the PTE disappeared temporarily due to a THP | ||
| 651 | * collapse, just return and let the guest try again. | ||
| 652 | */ | ||
| 653 | if (!ptep) { | ||
| 654 | local_irq_enable(); | ||
| 655 | if (page) | ||
| 656 | put_page(page); | ||
| 657 | return RESUME_GUEST; | ||
| 658 | } | ||
| 649 | pte = *ptep; | 659 | pte = *ptep; |
| 650 | local_irq_enable(); | 660 | local_irq_enable(); |
| 651 | 661 | ||
diff --git a/arch/powerpc/lib/checksum_64.S b/arch/powerpc/lib/checksum_64.S index 886ed94b9c13..d05c8af4ac51 100644 --- a/arch/powerpc/lib/checksum_64.S +++ b/arch/powerpc/lib/checksum_64.S | |||
| @@ -443,6 +443,9 @@ _GLOBAL(csum_ipv6_magic) | |||
| 443 | addc r0, r8, r9 | 443 | addc r0, r8, r9 |
| 444 | ld r10, 0(r4) | 444 | ld r10, 0(r4) |
| 445 | ld r11, 8(r4) | 445 | ld r11, 8(r4) |
| 446 | #ifdef CONFIG_CPU_LITTLE_ENDIAN | ||
| 447 | rotldi r5, r5, 8 | ||
| 448 | #endif | ||
| 446 | adde r0, r0, r10 | 449 | adde r0, r0, r10 |
| 447 | add r5, r5, r7 | 450 | add r5, r5, r7 |
| 448 | adde r0, r0, r11 | 451 | adde r0, r0, r11 |
diff --git a/arch/powerpc/lib/code-patching.c b/arch/powerpc/lib/code-patching.c index 850f3b8f4da5..5ffee298745f 100644 --- a/arch/powerpc/lib/code-patching.c +++ b/arch/powerpc/lib/code-patching.c | |||
| @@ -142,7 +142,7 @@ static inline int unmap_patch_area(unsigned long addr) | |||
| 142 | return 0; | 142 | return 0; |
| 143 | } | 143 | } |
| 144 | 144 | ||
| 145 | int patch_instruction(unsigned int *addr, unsigned int instr) | 145 | static int do_patch_instruction(unsigned int *addr, unsigned int instr) |
| 146 | { | 146 | { |
| 147 | int err; | 147 | int err; |
| 148 | unsigned int *patch_addr = NULL; | 148 | unsigned int *patch_addr = NULL; |
| @@ -182,12 +182,22 @@ out: | |||
| 182 | } | 182 | } |
| 183 | #else /* !CONFIG_STRICT_KERNEL_RWX */ | 183 | #else /* !CONFIG_STRICT_KERNEL_RWX */ |
| 184 | 184 | ||
| 185 | int patch_instruction(unsigned int *addr, unsigned int instr) | 185 | static int do_patch_instruction(unsigned int *addr, unsigned int instr) |
| 186 | { | 186 | { |
| 187 | return raw_patch_instruction(addr, instr); | 187 | return raw_patch_instruction(addr, instr); |
| 188 | } | 188 | } |
| 189 | 189 | ||
| 190 | #endif /* CONFIG_STRICT_KERNEL_RWX */ | 190 | #endif /* CONFIG_STRICT_KERNEL_RWX */ |
| 191 | |||
| 192 | int patch_instruction(unsigned int *addr, unsigned int instr) | ||
| 193 | { | ||
| 194 | /* Make sure we aren't patching a freed init section */ | ||
| 195 | if (init_mem_is_free && init_section_contains(addr, 4)) { | ||
| 196 | pr_debug("Skipping init section patching addr: 0x%px\n", addr); | ||
| 197 | return 0; | ||
| 198 | } | ||
| 199 | return do_patch_instruction(addr, instr); | ||
| 200 | } | ||
| 191 | NOKPROBE_SYMBOL(patch_instruction); | 201 | NOKPROBE_SYMBOL(patch_instruction); |
| 192 | 202 | ||
| 193 | int patch_branch(unsigned int *addr, unsigned long target, int flags) | 203 | int patch_branch(unsigned int *addr, unsigned long target, int flags) |
diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c index 5c8530d0c611..04ccb274a620 100644 --- a/arch/powerpc/mm/mem.c +++ b/arch/powerpc/mm/mem.c | |||
| @@ -63,6 +63,7 @@ | |||
| 63 | #endif | 63 | #endif |
| 64 | 64 | ||
| 65 | unsigned long long memory_limit; | 65 | unsigned long long memory_limit; |
| 66 | bool init_mem_is_free; | ||
| 66 | 67 | ||
| 67 | #ifdef CONFIG_HIGHMEM | 68 | #ifdef CONFIG_HIGHMEM |
| 68 | pte_t *kmap_pte; | 69 | pte_t *kmap_pte; |
| @@ -396,6 +397,7 @@ void free_initmem(void) | |||
| 396 | { | 397 | { |
| 397 | ppc_md.progress = ppc_printk_progress; | 398 | ppc_md.progress = ppc_printk_progress; |
| 398 | mark_initmem_nx(); | 399 | mark_initmem_nx(); |
| 400 | init_mem_is_free = true; | ||
| 399 | free_initmem_default(POISON_FREE_INITMEM); | 401 | free_initmem_default(POISON_FREE_INITMEM); |
| 400 | } | 402 | } |
| 401 | 403 | ||
diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c index 35ac5422903a..055b211b7126 100644 --- a/arch/powerpc/mm/numa.c +++ b/arch/powerpc/mm/numa.c | |||
| @@ -1204,7 +1204,9 @@ int find_and_online_cpu_nid(int cpu) | |||
| 1204 | int new_nid; | 1204 | int new_nid; |
| 1205 | 1205 | ||
| 1206 | /* Use associativity from first thread for all siblings */ | 1206 | /* Use associativity from first thread for all siblings */ |
| 1207 | vphn_get_associativity(cpu, associativity); | 1207 | if (vphn_get_associativity(cpu, associativity)) |
| 1208 | return cpu_to_node(cpu); | ||
| 1209 | |||
| 1208 | new_nid = associativity_to_nid(associativity); | 1210 | new_nid = associativity_to_nid(associativity); |
| 1209 | if (new_nid < 0 || !node_possible(new_nid)) | 1211 | if (new_nid < 0 || !node_possible(new_nid)) |
| 1210 | new_nid = first_online_node; | 1212 | new_nid = first_online_node; |
| @@ -1215,9 +1217,10 @@ int find_and_online_cpu_nid(int cpu) | |||
| 1215 | * Need to ensure that NODE_DATA is initialized for a node from | 1217 | * Need to ensure that NODE_DATA is initialized for a node from |
| 1216 | * available memory (see memblock_alloc_try_nid). If unable to | 1218 | * available memory (see memblock_alloc_try_nid). If unable to |
| 1217 | * init the node, then default to nearest node that has memory | 1219 | * init the node, then default to nearest node that has memory |
| 1218 | * installed. | 1220 | * installed. Skip onlining a node if the subsystems are not |
| 1221 | * yet initialized. | ||
| 1219 | */ | 1222 | */ |
| 1220 | if (try_online_node(new_nid)) | 1223 | if (!topology_inited || try_online_node(new_nid)) |
| 1221 | new_nid = first_online_node; | 1224 | new_nid = first_online_node; |
| 1222 | #else | 1225 | #else |
| 1223 | /* | 1226 | /* |
| @@ -1452,7 +1455,8 @@ static struct timer_list topology_timer; | |||
| 1452 | 1455 | ||
| 1453 | static void reset_topology_timer(void) | 1456 | static void reset_topology_timer(void) |
| 1454 | { | 1457 | { |
| 1455 | mod_timer(&topology_timer, jiffies + topology_timer_secs * HZ); | 1458 | if (vphn_enabled) |
| 1459 | mod_timer(&topology_timer, jiffies + topology_timer_secs * HZ); | ||
| 1456 | } | 1460 | } |
| 1457 | 1461 | ||
| 1458 | #ifdef CONFIG_SMP | 1462 | #ifdef CONFIG_SMP |
diff --git a/arch/powerpc/mm/pkeys.c b/arch/powerpc/mm/pkeys.c index 333b1f80c435..b271b283c785 100644 --- a/arch/powerpc/mm/pkeys.c +++ b/arch/powerpc/mm/pkeys.c | |||
| @@ -45,7 +45,7 @@ static void scan_pkey_feature(void) | |||
| 45 | * Since any pkey can be used for data or execute, we will just treat | 45 | * Since any pkey can be used for data or execute, we will just treat |
| 46 | * all keys as equal and track them as one entity. | 46 | * all keys as equal and track them as one entity. |
| 47 | */ | 47 | */ |
| 48 | pkeys_total = be32_to_cpu(vals[0]); | 48 | pkeys_total = vals[0]; |
| 49 | pkeys_devtree_defined = true; | 49 | pkeys_devtree_defined = true; |
| 50 | } | 50 | } |
| 51 | 51 | ||
diff --git a/arch/powerpc/platforms/powernv/pci-ioda-tce.c b/arch/powerpc/platforms/powernv/pci-ioda-tce.c index 6c5db1acbe8d..fe9691040f54 100644 --- a/arch/powerpc/platforms/powernv/pci-ioda-tce.c +++ b/arch/powerpc/platforms/powernv/pci-ioda-tce.c | |||
| @@ -276,7 +276,7 @@ long pnv_pci_ioda2_table_alloc_pages(int nid, __u64 bus_offset, | |||
| 276 | level_shift = entries_shift + 3; | 276 | level_shift = entries_shift + 3; |
| 277 | level_shift = max_t(unsigned int, level_shift, PAGE_SHIFT); | 277 | level_shift = max_t(unsigned int, level_shift, PAGE_SHIFT); |
| 278 | 278 | ||
| 279 | if ((level_shift - 3) * levels + page_shift >= 60) | 279 | if ((level_shift - 3) * levels + page_shift >= 55) |
| 280 | return -EINVAL; | 280 | return -EINVAL; |
| 281 | 281 | ||
| 282 | /* Allocate TCE table */ | 282 | /* Allocate TCE table */ |
diff --git a/arch/riscv/include/asm/asm-prototypes.h b/arch/riscv/include/asm/asm-prototypes.h new file mode 100644 index 000000000000..c9fecd120d18 --- /dev/null +++ b/arch/riscv/include/asm/asm-prototypes.h | |||
| @@ -0,0 +1,7 @@ | |||
| 1 | /* SPDX-License-Identifier: GPL-2.0 */ | ||
| 2 | #ifndef _ASM_RISCV_PROTOTYPES_H | ||
| 3 | |||
| 4 | #include <linux/ftrace.h> | ||
| 5 | #include <asm-generic/asm-prototypes.h> | ||
| 6 | |||
| 7 | #endif /* _ASM_RISCV_PROTOTYPES_H */ | ||
diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c index aee603123030..b2d26d9d8489 100644 --- a/arch/riscv/kernel/setup.c +++ b/arch/riscv/kernel/setup.c | |||
| @@ -186,7 +186,7 @@ static void __init setup_bootmem(void) | |||
| 186 | BUG_ON(mem_size == 0); | 186 | BUG_ON(mem_size == 0); |
| 187 | 187 | ||
| 188 | set_max_mapnr(PFN_DOWN(mem_size)); | 188 | set_max_mapnr(PFN_DOWN(mem_size)); |
| 189 | max_low_pfn = pfn_base + PFN_DOWN(mem_size); | 189 | max_low_pfn = memblock_end_of_DRAM(); |
| 190 | 190 | ||
| 191 | #ifdef CONFIG_BLK_DEV_INITRD | 191 | #ifdef CONFIG_BLK_DEV_INITRD |
| 192 | setup_initrd(); | 192 | setup_initrd(); |
diff --git a/arch/x86/boot/compressed/mem_encrypt.S b/arch/x86/boot/compressed/mem_encrypt.S index eaa843a52907..a480356e0ed8 100644 --- a/arch/x86/boot/compressed/mem_encrypt.S +++ b/arch/x86/boot/compressed/mem_encrypt.S | |||
| @@ -25,20 +25,6 @@ ENTRY(get_sev_encryption_bit) | |||
| 25 | push %ebx | 25 | push %ebx |
| 26 | push %ecx | 26 | push %ecx |
| 27 | push %edx | 27 | push %edx |
| 28 | push %edi | ||
| 29 | |||
| 30 | /* | ||
| 31 | * RIP-relative addressing is needed to access the encryption bit | ||
| 32 | * variable. Since we are running in 32-bit mode we need this call/pop | ||
| 33 | * sequence to get the proper relative addressing. | ||
| 34 | */ | ||
| 35 | call 1f | ||
| 36 | 1: popl %edi | ||
| 37 | subl $1b, %edi | ||
| 38 | |||
| 39 | movl enc_bit(%edi), %eax | ||
| 40 | cmpl $0, %eax | ||
| 41 | jge .Lsev_exit | ||
| 42 | 28 | ||
| 43 | /* Check if running under a hypervisor */ | 29 | /* Check if running under a hypervisor */ |
| 44 | movl $1, %eax | 30 | movl $1, %eax |
| @@ -69,15 +55,12 @@ ENTRY(get_sev_encryption_bit) | |||
| 69 | 55 | ||
| 70 | movl %ebx, %eax | 56 | movl %ebx, %eax |
| 71 | andl $0x3f, %eax /* Return the encryption bit location */ | 57 | andl $0x3f, %eax /* Return the encryption bit location */ |
| 72 | movl %eax, enc_bit(%edi) | ||
| 73 | jmp .Lsev_exit | 58 | jmp .Lsev_exit |
| 74 | 59 | ||
| 75 | .Lno_sev: | 60 | .Lno_sev: |
| 76 | xor %eax, %eax | 61 | xor %eax, %eax |
| 77 | movl %eax, enc_bit(%edi) | ||
| 78 | 62 | ||
| 79 | .Lsev_exit: | 63 | .Lsev_exit: |
| 80 | pop %edi | ||
| 81 | pop %edx | 64 | pop %edx |
| 82 | pop %ecx | 65 | pop %ecx |
| 83 | pop %ebx | 66 | pop %ebx |
| @@ -113,8 +96,6 @@ ENTRY(set_sev_encryption_mask) | |||
| 113 | ENDPROC(set_sev_encryption_mask) | 96 | ENDPROC(set_sev_encryption_mask) |
| 114 | 97 | ||
| 115 | .data | 98 | .data |
| 116 | enc_bit: | ||
| 117 | .int 0xffffffff | ||
| 118 | 99 | ||
| 119 | #ifdef CONFIG_AMD_MEM_ENCRYPT | 100 | #ifdef CONFIG_AMD_MEM_ENCRYPT |
| 120 | .balign 8 | 101 | .balign 8 |
diff --git a/arch/x86/entry/vdso/Makefile b/arch/x86/entry/vdso/Makefile index fa3f439f0a92..141d415a8c80 100644 --- a/arch/x86/entry/vdso/Makefile +++ b/arch/x86/entry/vdso/Makefile | |||
| @@ -68,7 +68,13 @@ $(obj)/vdso-image-%.c: $(obj)/vdso%.so.dbg $(obj)/vdso%.so $(obj)/vdso2c FORCE | |||
| 68 | CFL := $(PROFILING) -mcmodel=small -fPIC -O2 -fasynchronous-unwind-tables -m64 \ | 68 | CFL := $(PROFILING) -mcmodel=small -fPIC -O2 -fasynchronous-unwind-tables -m64 \ |
| 69 | $(filter -g%,$(KBUILD_CFLAGS)) $(call cc-option, -fno-stack-protector) \ | 69 | $(filter -g%,$(KBUILD_CFLAGS)) $(call cc-option, -fno-stack-protector) \ |
| 70 | -fno-omit-frame-pointer -foptimize-sibling-calls \ | 70 | -fno-omit-frame-pointer -foptimize-sibling-calls \ |
| 71 | -DDISABLE_BRANCH_PROFILING -DBUILD_VDSO $(RETPOLINE_VDSO_CFLAGS) | 71 | -DDISABLE_BRANCH_PROFILING -DBUILD_VDSO |
| 72 | |||
| 73 | ifdef CONFIG_RETPOLINE | ||
| 74 | ifneq ($(RETPOLINE_VDSO_CFLAGS),) | ||
| 75 | CFL += $(RETPOLINE_VDSO_CFLAGS) | ||
| 76 | endif | ||
| 77 | endif | ||
| 72 | 78 | ||
| 73 | $(vobjs): KBUILD_CFLAGS := $(filter-out $(GCC_PLUGINS_CFLAGS) $(RETPOLINE_CFLAGS),$(KBUILD_CFLAGS)) $(CFL) | 79 | $(vobjs): KBUILD_CFLAGS := $(filter-out $(GCC_PLUGINS_CFLAGS) $(RETPOLINE_CFLAGS),$(KBUILD_CFLAGS)) $(CFL) |
| 74 | 80 | ||
| @@ -138,7 +144,13 @@ KBUILD_CFLAGS_32 += $(call cc-option, -fno-stack-protector) | |||
| 138 | KBUILD_CFLAGS_32 += $(call cc-option, -foptimize-sibling-calls) | 144 | KBUILD_CFLAGS_32 += $(call cc-option, -foptimize-sibling-calls) |
| 139 | KBUILD_CFLAGS_32 += -fno-omit-frame-pointer | 145 | KBUILD_CFLAGS_32 += -fno-omit-frame-pointer |
| 140 | KBUILD_CFLAGS_32 += -DDISABLE_BRANCH_PROFILING | 146 | KBUILD_CFLAGS_32 += -DDISABLE_BRANCH_PROFILING |
| 141 | KBUILD_CFLAGS_32 += $(RETPOLINE_VDSO_CFLAGS) | 147 | |
| 148 | ifdef CONFIG_RETPOLINE | ||
| 149 | ifneq ($(RETPOLINE_VDSO_CFLAGS),) | ||
| 150 | KBUILD_CFLAGS_32 += $(RETPOLINE_VDSO_CFLAGS) | ||
| 151 | endif | ||
| 152 | endif | ||
| 153 | |||
| 142 | $(obj)/vdso32.so.dbg: KBUILD_CFLAGS = $(KBUILD_CFLAGS_32) | 154 | $(obj)/vdso32.so.dbg: KBUILD_CFLAGS = $(KBUILD_CFLAGS_32) |
| 143 | 155 | ||
| 144 | $(obj)/vdso32.so.dbg: FORCE \ | 156 | $(obj)/vdso32.so.dbg: FORCE \ |
diff --git a/arch/x86/entry/vdso/vclock_gettime.c b/arch/x86/entry/vdso/vclock_gettime.c index f19856d95c60..e48ca3afa091 100644 --- a/arch/x86/entry/vdso/vclock_gettime.c +++ b/arch/x86/entry/vdso/vclock_gettime.c | |||
| @@ -43,8 +43,9 @@ extern u8 hvclock_page | |||
| 43 | notrace static long vdso_fallback_gettime(long clock, struct timespec *ts) | 43 | notrace static long vdso_fallback_gettime(long clock, struct timespec *ts) |
| 44 | { | 44 | { |
| 45 | long ret; | 45 | long ret; |
| 46 | asm("syscall" : "=a" (ret) : | 46 | asm ("syscall" : "=a" (ret), "=m" (*ts) : |
| 47 | "0" (__NR_clock_gettime), "D" (clock), "S" (ts) : "memory"); | 47 | "0" (__NR_clock_gettime), "D" (clock), "S" (ts) : |
| 48 | "memory", "rcx", "r11"); | ||
| 48 | return ret; | 49 | return ret; |
| 49 | } | 50 | } |
| 50 | 51 | ||
| @@ -52,8 +53,9 @@ notrace static long vdso_fallback_gtod(struct timeval *tv, struct timezone *tz) | |||
| 52 | { | 53 | { |
| 53 | long ret; | 54 | long ret; |
| 54 | 55 | ||
| 55 | asm("syscall" : "=a" (ret) : | 56 | asm ("syscall" : "=a" (ret), "=m" (*tv), "=m" (*tz) : |
| 56 | "0" (__NR_gettimeofday), "D" (tv), "S" (tz) : "memory"); | 57 | "0" (__NR_gettimeofday), "D" (tv), "S" (tz) : |
| 58 | "memory", "rcx", "r11"); | ||
| 57 | return ret; | 59 | return ret; |
| 58 | } | 60 | } |
| 59 | 61 | ||
| @@ -64,13 +66,13 @@ notrace static long vdso_fallback_gettime(long clock, struct timespec *ts) | |||
| 64 | { | 66 | { |
| 65 | long ret; | 67 | long ret; |
| 66 | 68 | ||
| 67 | asm( | 69 | asm ( |
| 68 | "mov %%ebx, %%edx \n" | 70 | "mov %%ebx, %%edx \n" |
| 69 | "mov %2, %%ebx \n" | 71 | "mov %[clock], %%ebx \n" |
| 70 | "call __kernel_vsyscall \n" | 72 | "call __kernel_vsyscall \n" |
| 71 | "mov %%edx, %%ebx \n" | 73 | "mov %%edx, %%ebx \n" |
| 72 | : "=a" (ret) | 74 | : "=a" (ret), "=m" (*ts) |
| 73 | : "0" (__NR_clock_gettime), "g" (clock), "c" (ts) | 75 | : "0" (__NR_clock_gettime), [clock] "g" (clock), "c" (ts) |
| 74 | : "memory", "edx"); | 76 | : "memory", "edx"); |
| 75 | return ret; | 77 | return ret; |
| 76 | } | 78 | } |
| @@ -79,13 +81,13 @@ notrace static long vdso_fallback_gtod(struct timeval *tv, struct timezone *tz) | |||
| 79 | { | 81 | { |
| 80 | long ret; | 82 | long ret; |
| 81 | 83 | ||
| 82 | asm( | 84 | asm ( |
| 83 | "mov %%ebx, %%edx \n" | 85 | "mov %%ebx, %%edx \n" |
| 84 | "mov %2, %%ebx \n" | 86 | "mov %[tv], %%ebx \n" |
| 85 | "call __kernel_vsyscall \n" | 87 | "call __kernel_vsyscall \n" |
| 86 | "mov %%edx, %%ebx \n" | 88 | "mov %%edx, %%ebx \n" |
| 87 | : "=a" (ret) | 89 | : "=a" (ret), "=m" (*tv), "=m" (*tz) |
| 88 | : "0" (__NR_gettimeofday), "g" (tv), "c" (tz) | 90 | : "0" (__NR_gettimeofday), [tv] "g" (tv), "c" (tz) |
| 89 | : "memory", "edx"); | 91 | : "memory", "edx"); |
| 90 | return ret; | 92 | return ret; |
| 91 | } | 93 | } |
diff --git a/arch/x86/events/amd/uncore.c b/arch/x86/events/amd/uncore.c index 981ba5e8241b..8671de126eac 100644 --- a/arch/x86/events/amd/uncore.c +++ b/arch/x86/events/amd/uncore.c | |||
| @@ -36,6 +36,7 @@ | |||
| 36 | 36 | ||
| 37 | static int num_counters_llc; | 37 | static int num_counters_llc; |
| 38 | static int num_counters_nb; | 38 | static int num_counters_nb; |
| 39 | static bool l3_mask; | ||
| 39 | 40 | ||
| 40 | static HLIST_HEAD(uncore_unused_list); | 41 | static HLIST_HEAD(uncore_unused_list); |
| 41 | 42 | ||
| @@ -209,6 +210,13 @@ static int amd_uncore_event_init(struct perf_event *event) | |||
| 209 | hwc->config = event->attr.config & AMD64_RAW_EVENT_MASK_NB; | 210 | hwc->config = event->attr.config & AMD64_RAW_EVENT_MASK_NB; |
| 210 | hwc->idx = -1; | 211 | hwc->idx = -1; |
| 211 | 212 | ||
| 213 | /* | ||
| 214 | * SliceMask and ThreadMask need to be set for certain L3 events in | ||
| 215 | * Family 17h. For other events, the two fields do not affect the count. | ||
| 216 | */ | ||
| 217 | if (l3_mask) | ||
| 218 | hwc->config |= (AMD64_L3_SLICE_MASK | AMD64_L3_THREAD_MASK); | ||
| 219 | |||
| 212 | if (event->cpu < 0) | 220 | if (event->cpu < 0) |
| 213 | return -EINVAL; | 221 | return -EINVAL; |
| 214 | 222 | ||
| @@ -525,6 +533,7 @@ static int __init amd_uncore_init(void) | |||
| 525 | amd_llc_pmu.name = "amd_l3"; | 533 | amd_llc_pmu.name = "amd_l3"; |
| 526 | format_attr_event_df.show = &event_show_df; | 534 | format_attr_event_df.show = &event_show_df; |
| 527 | format_attr_event_l3.show = &event_show_l3; | 535 | format_attr_event_l3.show = &event_show_l3; |
| 536 | l3_mask = true; | ||
| 528 | } else { | 537 | } else { |
| 529 | num_counters_nb = NUM_COUNTERS_NB; | 538 | num_counters_nb = NUM_COUNTERS_NB; |
| 530 | num_counters_llc = NUM_COUNTERS_L2; | 539 | num_counters_llc = NUM_COUNTERS_L2; |
| @@ -532,6 +541,7 @@ static int __init amd_uncore_init(void) | |||
| 532 | amd_llc_pmu.name = "amd_l2"; | 541 | amd_llc_pmu.name = "amd_l2"; |
| 533 | format_attr_event_df = format_attr_event; | 542 | format_attr_event_df = format_attr_event; |
| 534 | format_attr_event_l3 = format_attr_event; | 543 | format_attr_event_l3 = format_attr_event; |
| 544 | l3_mask = false; | ||
| 535 | } | 545 | } |
| 536 | 546 | ||
| 537 | amd_nb_pmu.attr_groups = amd_uncore_attr_groups_df; | 547 | amd_nb_pmu.attr_groups = amd_uncore_attr_groups_df; |
diff --git a/arch/x86/events/intel/uncore_snbep.c b/arch/x86/events/intel/uncore_snbep.c index 51d7c117e3c7..c07bee31abe8 100644 --- a/arch/x86/events/intel/uncore_snbep.c +++ b/arch/x86/events/intel/uncore_snbep.c | |||
| @@ -3061,7 +3061,7 @@ static struct event_constraint bdx_uncore_pcu_constraints[] = { | |||
| 3061 | 3061 | ||
| 3062 | void bdx_uncore_cpu_init(void) | 3062 | void bdx_uncore_cpu_init(void) |
| 3063 | { | 3063 | { |
| 3064 | int pkg = topology_phys_to_logical_pkg(0); | 3064 | int pkg = topology_phys_to_logical_pkg(boot_cpu_data.phys_proc_id); |
| 3065 | 3065 | ||
| 3066 | if (bdx_uncore_cbox.num_boxes > boot_cpu_data.x86_max_cores) | 3066 | if (bdx_uncore_cbox.num_boxes > boot_cpu_data.x86_max_cores) |
| 3067 | bdx_uncore_cbox.num_boxes = boot_cpu_data.x86_max_cores; | 3067 | bdx_uncore_cbox.num_boxes = boot_cpu_data.x86_max_cores; |
| @@ -3931,16 +3931,16 @@ static const struct pci_device_id skx_uncore_pci_ids[] = { | |||
| 3931 | .driver_data = UNCORE_PCI_DEV_FULL_DATA(21, 5, SKX_PCI_UNCORE_M2PCIE, 3), | 3931 | .driver_data = UNCORE_PCI_DEV_FULL_DATA(21, 5, SKX_PCI_UNCORE_M2PCIE, 3), |
| 3932 | }, | 3932 | }, |
| 3933 | { /* M3UPI0 Link 0 */ | 3933 | { /* M3UPI0 Link 0 */ |
| 3934 | PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x204C), | 3934 | PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x204D), |
| 3935 | .driver_data = UNCORE_PCI_DEV_FULL_DATA(18, 0, SKX_PCI_UNCORE_M3UPI, 0), | 3935 | .driver_data = UNCORE_PCI_DEV_FULL_DATA(18, 1, SKX_PCI_UNCORE_M3UPI, 0), |
| 3936 | }, | 3936 | }, |
| 3937 | { /* M3UPI0 Link 1 */ | 3937 | { /* M3UPI0 Link 1 */ |
| 3938 | PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x204D), | 3938 | PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x204E), |
| 3939 | .driver_data = UNCORE_PCI_DEV_FULL_DATA(18, 1, SKX_PCI_UNCORE_M3UPI, 1), | 3939 | .driver_data = UNCORE_PCI_DEV_FULL_DATA(18, 2, SKX_PCI_UNCORE_M3UPI, 1), |
| 3940 | }, | 3940 | }, |
| 3941 | { /* M3UPI1 Link 2 */ | 3941 | { /* M3UPI1 Link 2 */ |
| 3942 | PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x204C), | 3942 | PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x204D), |
| 3943 | .driver_data = UNCORE_PCI_DEV_FULL_DATA(18, 4, SKX_PCI_UNCORE_M3UPI, 2), | 3943 | .driver_data = UNCORE_PCI_DEV_FULL_DATA(18, 5, SKX_PCI_UNCORE_M3UPI, 2), |
| 3944 | }, | 3944 | }, |
| 3945 | { /* end: all zeroes */ } | 3945 | { /* end: all zeroes */ } |
| 3946 | }; | 3946 | }; |
diff --git a/arch/x86/include/asm/perf_event.h b/arch/x86/include/asm/perf_event.h index b2cf84c35a6d..8bdf74902293 100644 --- a/arch/x86/include/asm/perf_event.h +++ b/arch/x86/include/asm/perf_event.h | |||
| @@ -46,6 +46,14 @@ | |||
| 46 | #define INTEL_ARCH_EVENT_MASK \ | 46 | #define INTEL_ARCH_EVENT_MASK \ |
| 47 | (ARCH_PERFMON_EVENTSEL_UMASK | ARCH_PERFMON_EVENTSEL_EVENT) | 47 | (ARCH_PERFMON_EVENTSEL_UMASK | ARCH_PERFMON_EVENTSEL_EVENT) |
| 48 | 48 | ||
| 49 | #define AMD64_L3_SLICE_SHIFT 48 | ||
| 50 | #define AMD64_L3_SLICE_MASK \ | ||
| 51 | ((0xFULL) << AMD64_L3_SLICE_SHIFT) | ||
| 52 | |||
| 53 | #define AMD64_L3_THREAD_SHIFT 56 | ||
| 54 | #define AMD64_L3_THREAD_MASK \ | ||
| 55 | ((0xFFULL) << AMD64_L3_THREAD_SHIFT) | ||
| 56 | |||
| 49 | #define X86_RAW_EVENT_MASK \ | 57 | #define X86_RAW_EVENT_MASK \ |
| 50 | (ARCH_PERFMON_EVENTSEL_EVENT | \ | 58 | (ARCH_PERFMON_EVENTSEL_EVENT | \ |
| 51 | ARCH_PERFMON_EVENTSEL_UMASK | \ | 59 | ARCH_PERFMON_EVENTSEL_UMASK | \ |
diff --git a/arch/x86/include/asm/uv/uv.h b/arch/x86/include/asm/uv/uv.h index a80c0673798f..e60c45fd3679 100644 --- a/arch/x86/include/asm/uv/uv.h +++ b/arch/x86/include/asm/uv/uv.h | |||
| @@ -10,8 +10,13 @@ struct cpumask; | |||
| 10 | struct mm_struct; | 10 | struct mm_struct; |
| 11 | 11 | ||
| 12 | #ifdef CONFIG_X86_UV | 12 | #ifdef CONFIG_X86_UV |
| 13 | #include <linux/efi.h> | ||
| 13 | 14 | ||
| 14 | extern enum uv_system_type get_uv_system_type(void); | 15 | extern enum uv_system_type get_uv_system_type(void); |
| 16 | static inline bool is_early_uv_system(void) | ||
| 17 | { | ||
| 18 | return !((efi.uv_systab == EFI_INVALID_TABLE_ADDR) || !efi.uv_systab); | ||
| 19 | } | ||
| 15 | extern int is_uv_system(void); | 20 | extern int is_uv_system(void); |
| 16 | extern int is_uv_hubless(void); | 21 | extern int is_uv_hubless(void); |
| 17 | extern void uv_cpu_init(void); | 22 | extern void uv_cpu_init(void); |
| @@ -23,6 +28,7 @@ extern const struct cpumask *uv_flush_tlb_others(const struct cpumask *cpumask, | |||
| 23 | #else /* X86_UV */ | 28 | #else /* X86_UV */ |
| 24 | 29 | ||
| 25 | static inline enum uv_system_type get_uv_system_type(void) { return UV_NONE; } | 30 | static inline enum uv_system_type get_uv_system_type(void) { return UV_NONE; } |
| 31 | static inline bool is_early_uv_system(void) { return 0; } | ||
| 26 | static inline int is_uv_system(void) { return 0; } | 32 | static inline int is_uv_system(void) { return 0; } |
| 27 | static inline int is_uv_hubless(void) { return 0; } | 33 | static inline int is_uv_hubless(void) { return 0; } |
| 28 | static inline void uv_cpu_init(void) { } | 34 | static inline void uv_cpu_init(void) { } |
diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c index 22ab408177b2..eeea634bee0a 100644 --- a/arch/x86/kernel/cpu/amd.c +++ b/arch/x86/kernel/cpu/amd.c | |||
| @@ -922,7 +922,7 @@ static void init_amd(struct cpuinfo_x86 *c) | |||
| 922 | static unsigned int amd_size_cache(struct cpuinfo_x86 *c, unsigned int size) | 922 | static unsigned int amd_size_cache(struct cpuinfo_x86 *c, unsigned int size) |
| 923 | { | 923 | { |
| 924 | /* AMD errata T13 (order #21922) */ | 924 | /* AMD errata T13 (order #21922) */ |
| 925 | if ((c->x86 == 6)) { | 925 | if (c->x86 == 6) { |
| 926 | /* Duron Rev A0 */ | 926 | /* Duron Rev A0 */ |
| 927 | if (c->x86_model == 3 && c->x86_stepping == 0) | 927 | if (c->x86_model == 3 && c->x86_stepping == 0) |
| 928 | size = 64; | 928 | size = 64; |
diff --git a/arch/x86/kernel/cpu/intel_rdt.h b/arch/x86/kernel/cpu/intel_rdt.h index 285eb3ec4200..3736f6dc9545 100644 --- a/arch/x86/kernel/cpu/intel_rdt.h +++ b/arch/x86/kernel/cpu/intel_rdt.h | |||
| @@ -529,14 +529,14 @@ ssize_t rdtgroup_schemata_write(struct kernfs_open_file *of, | |||
| 529 | int rdtgroup_schemata_show(struct kernfs_open_file *of, | 529 | int rdtgroup_schemata_show(struct kernfs_open_file *of, |
| 530 | struct seq_file *s, void *v); | 530 | struct seq_file *s, void *v); |
| 531 | bool rdtgroup_cbm_overlaps(struct rdt_resource *r, struct rdt_domain *d, | 531 | bool rdtgroup_cbm_overlaps(struct rdt_resource *r, struct rdt_domain *d, |
| 532 | u32 _cbm, int closid, bool exclusive); | 532 | unsigned long cbm, int closid, bool exclusive); |
| 533 | unsigned int rdtgroup_cbm_to_size(struct rdt_resource *r, struct rdt_domain *d, | 533 | unsigned int rdtgroup_cbm_to_size(struct rdt_resource *r, struct rdt_domain *d, |
| 534 | u32 cbm); | 534 | unsigned long cbm); |
| 535 | enum rdtgrp_mode rdtgroup_mode_by_closid(int closid); | 535 | enum rdtgrp_mode rdtgroup_mode_by_closid(int closid); |
| 536 | int rdtgroup_tasks_assigned(struct rdtgroup *r); | 536 | int rdtgroup_tasks_assigned(struct rdtgroup *r); |
| 537 | int rdtgroup_locksetup_enter(struct rdtgroup *rdtgrp); | 537 | int rdtgroup_locksetup_enter(struct rdtgroup *rdtgrp); |
| 538 | int rdtgroup_locksetup_exit(struct rdtgroup *rdtgrp); | 538 | int rdtgroup_locksetup_exit(struct rdtgroup *rdtgrp); |
| 539 | bool rdtgroup_cbm_overlaps_pseudo_locked(struct rdt_domain *d, u32 _cbm); | 539 | bool rdtgroup_cbm_overlaps_pseudo_locked(struct rdt_domain *d, unsigned long cbm); |
| 540 | bool rdtgroup_pseudo_locked_in_hierarchy(struct rdt_domain *d); | 540 | bool rdtgroup_pseudo_locked_in_hierarchy(struct rdt_domain *d); |
| 541 | int rdt_pseudo_lock_init(void); | 541 | int rdt_pseudo_lock_init(void); |
| 542 | void rdt_pseudo_lock_release(void); | 542 | void rdt_pseudo_lock_release(void); |
diff --git a/arch/x86/kernel/cpu/intel_rdt_pseudo_lock.c b/arch/x86/kernel/cpu/intel_rdt_pseudo_lock.c index 30e6c9f5a0ad..41aeb431e834 100644 --- a/arch/x86/kernel/cpu/intel_rdt_pseudo_lock.c +++ b/arch/x86/kernel/cpu/intel_rdt_pseudo_lock.c | |||
| @@ -789,25 +789,27 @@ int rdtgroup_locksetup_exit(struct rdtgroup *rdtgrp) | |||
| 789 | /** | 789 | /** |
| 790 | * rdtgroup_cbm_overlaps_pseudo_locked - Test if CBM or portion is pseudo-locked | 790 | * rdtgroup_cbm_overlaps_pseudo_locked - Test if CBM or portion is pseudo-locked |
| 791 | * @d: RDT domain | 791 | * @d: RDT domain |
| 792 | * @_cbm: CBM to test | 792 | * @cbm: CBM to test |
| 793 | * | 793 | * |
| 794 | * @d represents a cache instance and @_cbm a capacity bitmask that is | 794 | * @d represents a cache instance and @cbm a capacity bitmask that is |
| 795 | * considered for it. Determine if @_cbm overlaps with any existing | 795 | * considered for it. Determine if @cbm overlaps with any existing |
| 796 | * pseudo-locked region on @d. | 796 | * pseudo-locked region on @d. |
| 797 | * | 797 | * |
| 798 | * Return: true if @_cbm overlaps with pseudo-locked region on @d, false | 798 | * @cbm is unsigned long, even if only 32 bits are used, to make the |
| 799 | * bitmap functions work correctly. | ||
| 800 | * | ||
| 801 | * Return: true if @cbm overlaps with pseudo-locked region on @d, false | ||
| 799 | * otherwise. | 802 | * otherwise. |
| 800 | */ | 803 | */ |
| 801 | bool rdtgroup_cbm_overlaps_pseudo_locked(struct rdt_domain *d, u32 _cbm) | 804 | bool rdtgroup_cbm_overlaps_pseudo_locked(struct rdt_domain *d, unsigned long cbm) |
| 802 | { | 805 | { |
| 803 | unsigned long *cbm = (unsigned long *)&_cbm; | ||
| 804 | unsigned long *cbm_b; | ||
| 805 | unsigned int cbm_len; | 806 | unsigned int cbm_len; |
| 807 | unsigned long cbm_b; | ||
| 806 | 808 | ||
| 807 | if (d->plr) { | 809 | if (d->plr) { |
| 808 | cbm_len = d->plr->r->cache.cbm_len; | 810 | cbm_len = d->plr->r->cache.cbm_len; |
| 809 | cbm_b = (unsigned long *)&d->plr->cbm; | 811 | cbm_b = d->plr->cbm; |
| 810 | if (bitmap_intersects(cbm, cbm_b, cbm_len)) | 812 | if (bitmap_intersects(&cbm, &cbm_b, cbm_len)) |
| 811 | return true; | 813 | return true; |
| 812 | } | 814 | } |
| 813 | return false; | 815 | return false; |
diff --git a/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c b/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c index 82a487840eb2..643670fb8943 100644 --- a/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c +++ b/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c | |||
| @@ -975,33 +975,34 @@ static int rdtgroup_mode_show(struct kernfs_open_file *of, | |||
| 975 | * is false then overlaps with any resource group or hardware entities | 975 | * is false then overlaps with any resource group or hardware entities |
| 976 | * will be considered. | 976 | * will be considered. |
| 977 | * | 977 | * |
| 978 | * @cbm is unsigned long, even if only 32 bits are used, to make the | ||
| 979 | * bitmap functions work correctly. | ||
| 980 | * | ||
| 978 | * Return: false if CBM does not overlap, true if it does. | 981 | * Return: false if CBM does not overlap, true if it does. |
| 979 | */ | 982 | */ |
| 980 | bool rdtgroup_cbm_overlaps(struct rdt_resource *r, struct rdt_domain *d, | 983 | bool rdtgroup_cbm_overlaps(struct rdt_resource *r, struct rdt_domain *d, |
| 981 | u32 _cbm, int closid, bool exclusive) | 984 | unsigned long cbm, int closid, bool exclusive) |
| 982 | { | 985 | { |
| 983 | unsigned long *cbm = (unsigned long *)&_cbm; | ||
| 984 | unsigned long *ctrl_b; | ||
| 985 | enum rdtgrp_mode mode; | 986 | enum rdtgrp_mode mode; |
| 987 | unsigned long ctrl_b; | ||
| 986 | u32 *ctrl; | 988 | u32 *ctrl; |
| 987 | int i; | 989 | int i; |
| 988 | 990 | ||
| 989 | /* Check for any overlap with regions used by hardware directly */ | 991 | /* Check for any overlap with regions used by hardware directly */ |
| 990 | if (!exclusive) { | 992 | if (!exclusive) { |
| 991 | if (bitmap_intersects(cbm, | 993 | ctrl_b = r->cache.shareable_bits; |
| 992 | (unsigned long *)&r->cache.shareable_bits, | 994 | if (bitmap_intersects(&cbm, &ctrl_b, r->cache.cbm_len)) |
| 993 | r->cache.cbm_len)) | ||
| 994 | return true; | 995 | return true; |
| 995 | } | 996 | } |
| 996 | 997 | ||
| 997 | /* Check for overlap with other resource groups */ | 998 | /* Check for overlap with other resource groups */ |
| 998 | ctrl = d->ctrl_val; | 999 | ctrl = d->ctrl_val; |
| 999 | for (i = 0; i < closids_supported(); i++, ctrl++) { | 1000 | for (i = 0; i < closids_supported(); i++, ctrl++) { |
| 1000 | ctrl_b = (unsigned long *)ctrl; | 1001 | ctrl_b = *ctrl; |
| 1001 | mode = rdtgroup_mode_by_closid(i); | 1002 | mode = rdtgroup_mode_by_closid(i); |
| 1002 | if (closid_allocated(i) && i != closid && | 1003 | if (closid_allocated(i) && i != closid && |
| 1003 | mode != RDT_MODE_PSEUDO_LOCKSETUP) { | 1004 | mode != RDT_MODE_PSEUDO_LOCKSETUP) { |
| 1004 | if (bitmap_intersects(cbm, ctrl_b, r->cache.cbm_len)) { | 1005 | if (bitmap_intersects(&cbm, &ctrl_b, r->cache.cbm_len)) { |
| 1005 | if (exclusive) { | 1006 | if (exclusive) { |
| 1006 | if (mode == RDT_MODE_EXCLUSIVE) | 1007 | if (mode == RDT_MODE_EXCLUSIVE) |
| 1007 | return true; | 1008 | return true; |
| @@ -1138,15 +1139,18 @@ out: | |||
| 1138 | * computed by first dividing the total cache size by the CBM length to | 1139 | * computed by first dividing the total cache size by the CBM length to |
| 1139 | * determine how many bytes each bit in the bitmask represents. The result | 1140 | * determine how many bytes each bit in the bitmask represents. The result |
| 1140 | * is multiplied with the number of bits set in the bitmask. | 1141 | * is multiplied with the number of bits set in the bitmask. |
| 1142 | * | ||
| 1143 | * @cbm is unsigned long, even if only 32 bits are used to make the | ||
| 1144 | * bitmap functions work correctly. | ||
| 1141 | */ | 1145 | */ |
| 1142 | unsigned int rdtgroup_cbm_to_size(struct rdt_resource *r, | 1146 | unsigned int rdtgroup_cbm_to_size(struct rdt_resource *r, |
| 1143 | struct rdt_domain *d, u32 cbm) | 1147 | struct rdt_domain *d, unsigned long cbm) |
| 1144 | { | 1148 | { |
| 1145 | struct cpu_cacheinfo *ci; | 1149 | struct cpu_cacheinfo *ci; |
| 1146 | unsigned int size = 0; | 1150 | unsigned int size = 0; |
| 1147 | int num_b, i; | 1151 | int num_b, i; |
| 1148 | 1152 | ||
| 1149 | num_b = bitmap_weight((unsigned long *)&cbm, r->cache.cbm_len); | 1153 | num_b = bitmap_weight(&cbm, r->cache.cbm_len); |
| 1150 | ci = get_cpu_cacheinfo(cpumask_any(&d->cpu_mask)); | 1154 | ci = get_cpu_cacheinfo(cpumask_any(&d->cpu_mask)); |
| 1151 | for (i = 0; i < ci->num_leaves; i++) { | 1155 | for (i = 0; i < ci->num_leaves; i++) { |
| 1152 | if (ci->info_list[i].level == r->cache_level) { | 1156 | if (ci->info_list[i].level == r->cache_level) { |
| @@ -2353,6 +2357,7 @@ static int rdtgroup_init_alloc(struct rdtgroup *rdtgrp) | |||
| 2353 | u32 used_b = 0, unused_b = 0; | 2357 | u32 used_b = 0, unused_b = 0; |
| 2354 | u32 closid = rdtgrp->closid; | 2358 | u32 closid = rdtgrp->closid; |
| 2355 | struct rdt_resource *r; | 2359 | struct rdt_resource *r; |
| 2360 | unsigned long tmp_cbm; | ||
| 2356 | enum rdtgrp_mode mode; | 2361 | enum rdtgrp_mode mode; |
| 2357 | struct rdt_domain *d; | 2362 | struct rdt_domain *d; |
| 2358 | int i, ret; | 2363 | int i, ret; |
| @@ -2390,9 +2395,14 @@ static int rdtgroup_init_alloc(struct rdtgroup *rdtgrp) | |||
| 2390 | * modify the CBM based on system availability. | 2395 | * modify the CBM based on system availability. |
| 2391 | */ | 2396 | */ |
| 2392 | cbm_ensure_valid(&d->new_ctrl, r); | 2397 | cbm_ensure_valid(&d->new_ctrl, r); |
| 2393 | if (bitmap_weight((unsigned long *) &d->new_ctrl, | 2398 | /* |
| 2394 | r->cache.cbm_len) < | 2399 | * Assign the u32 CBM to an unsigned long to ensure |
| 2395 | r->cache.min_cbm_bits) { | 2400 | * that bitmap_weight() does not access out-of-bound |
| 2401 | * memory. | ||
| 2402 | */ | ||
| 2403 | tmp_cbm = d->new_ctrl; | ||
| 2404 | if (bitmap_weight(&tmp_cbm, r->cache.cbm_len) < | ||
| 2405 | r->cache.min_cbm_bits) { | ||
| 2396 | rdt_last_cmd_printf("no space on %s:%d\n", | 2406 | rdt_last_cmd_printf("no space on %s:%d\n", |
| 2397 | r->name, d->id); | 2407 | r->name, d->id); |
| 2398 | return -ENOSPC; | 2408 | return -ENOSPC; |
diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c index 6490f618e096..b52bd2b6cdb4 100644 --- a/arch/x86/kernel/tsc.c +++ b/arch/x86/kernel/tsc.c | |||
| @@ -26,6 +26,7 @@ | |||
| 26 | #include <asm/apic.h> | 26 | #include <asm/apic.h> |
| 27 | #include <asm/intel-family.h> | 27 | #include <asm/intel-family.h> |
| 28 | #include <asm/i8259.h> | 28 | #include <asm/i8259.h> |
| 29 | #include <asm/uv/uv.h> | ||
| 29 | 30 | ||
| 30 | unsigned int __read_mostly cpu_khz; /* TSC clocks / usec, not used here */ | 31 | unsigned int __read_mostly cpu_khz; /* TSC clocks / usec, not used here */ |
| 31 | EXPORT_SYMBOL(cpu_khz); | 32 | EXPORT_SYMBOL(cpu_khz); |
| @@ -1433,6 +1434,9 @@ void __init tsc_early_init(void) | |||
| 1433 | { | 1434 | { |
| 1434 | if (!boot_cpu_has(X86_FEATURE_TSC)) | 1435 | if (!boot_cpu_has(X86_FEATURE_TSC)) |
| 1435 | return; | 1436 | return; |
| 1437 | /* Don't change UV TSC multi-chassis synchronization */ | ||
| 1438 | if (is_early_uv_system()) | ||
| 1439 | return; | ||
| 1436 | if (!determine_cpu_tsc_frequencies(true)) | 1440 | if (!determine_cpu_tsc_frequencies(true)) |
| 1437 | return; | 1441 | return; |
| 1438 | loops_per_jiffy = get_loops_per_jiffy(); | 1442 | loops_per_jiffy = get_loops_per_jiffy(); |
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index d7e9bce6ff61..51b953ad9d4e 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c | |||
| @@ -249,6 +249,17 @@ static u64 __read_mostly shadow_nonpresent_or_rsvd_mask; | |||
| 249 | */ | 249 | */ |
| 250 | static const u64 shadow_nonpresent_or_rsvd_mask_len = 5; | 250 | static const u64 shadow_nonpresent_or_rsvd_mask_len = 5; |
| 251 | 251 | ||
| 252 | /* | ||
| 253 | * In some cases, we need to preserve the GFN of a non-present or reserved | ||
| 254 | * SPTE when we usurp the upper five bits of the physical address space to | ||
| 255 | * defend against L1TF, e.g. for MMIO SPTEs. To preserve the GFN, we'll | ||
| 256 | * shift bits of the GFN that overlap with shadow_nonpresent_or_rsvd_mask | ||
| 257 | * left into the reserved bits, i.e. the GFN in the SPTE will be split into | ||
| 258 | * high and low parts. This mask covers the lower bits of the GFN. | ||
| 259 | */ | ||
| 260 | static u64 __read_mostly shadow_nonpresent_or_rsvd_lower_gfn_mask; | ||
| 261 | |||
| 262 | |||
| 252 | static void mmu_spte_set(u64 *sptep, u64 spte); | 263 | static void mmu_spte_set(u64 *sptep, u64 spte); |
| 253 | static union kvm_mmu_page_role | 264 | static union kvm_mmu_page_role |
| 254 | kvm_mmu_calc_root_page_role(struct kvm_vcpu *vcpu); | 265 | kvm_mmu_calc_root_page_role(struct kvm_vcpu *vcpu); |
| @@ -357,9 +368,7 @@ static bool is_mmio_spte(u64 spte) | |||
| 357 | 368 | ||
| 358 | static gfn_t get_mmio_spte_gfn(u64 spte) | 369 | static gfn_t get_mmio_spte_gfn(u64 spte) |
| 359 | { | 370 | { |
| 360 | u64 mask = generation_mmio_spte_mask(MMIO_GEN_MASK) | shadow_mmio_mask | | 371 | u64 gpa = spte & shadow_nonpresent_or_rsvd_lower_gfn_mask; |
| 361 | shadow_nonpresent_or_rsvd_mask; | ||
| 362 | u64 gpa = spte & ~mask; | ||
| 363 | 372 | ||
| 364 | gpa |= (spte >> shadow_nonpresent_or_rsvd_mask_len) | 373 | gpa |= (spte >> shadow_nonpresent_or_rsvd_mask_len) |
| 365 | & shadow_nonpresent_or_rsvd_mask; | 374 | & shadow_nonpresent_or_rsvd_mask; |
| @@ -423,6 +432,8 @@ EXPORT_SYMBOL_GPL(kvm_mmu_set_mask_ptes); | |||
| 423 | 432 | ||
| 424 | static void kvm_mmu_reset_all_pte_masks(void) | 433 | static void kvm_mmu_reset_all_pte_masks(void) |
| 425 | { | 434 | { |
| 435 | u8 low_phys_bits; | ||
| 436 | |||
| 426 | shadow_user_mask = 0; | 437 | shadow_user_mask = 0; |
| 427 | shadow_accessed_mask = 0; | 438 | shadow_accessed_mask = 0; |
| 428 | shadow_dirty_mask = 0; | 439 | shadow_dirty_mask = 0; |
| @@ -437,12 +448,17 @@ static void kvm_mmu_reset_all_pte_masks(void) | |||
| 437 | * appropriate mask to guard against L1TF attacks. Otherwise, it is | 448 | * appropriate mask to guard against L1TF attacks. Otherwise, it is |
| 438 | * assumed that the CPU is not vulnerable to L1TF. | 449 | * assumed that the CPU is not vulnerable to L1TF. |
| 439 | */ | 450 | */ |
| 451 | low_phys_bits = boot_cpu_data.x86_phys_bits; | ||
| 440 | if (boot_cpu_data.x86_phys_bits < | 452 | if (boot_cpu_data.x86_phys_bits < |
| 441 | 52 - shadow_nonpresent_or_rsvd_mask_len) | 453 | 52 - shadow_nonpresent_or_rsvd_mask_len) { |
| 442 | shadow_nonpresent_or_rsvd_mask = | 454 | shadow_nonpresent_or_rsvd_mask = |
| 443 | rsvd_bits(boot_cpu_data.x86_phys_bits - | 455 | rsvd_bits(boot_cpu_data.x86_phys_bits - |
| 444 | shadow_nonpresent_or_rsvd_mask_len, | 456 | shadow_nonpresent_or_rsvd_mask_len, |
| 445 | boot_cpu_data.x86_phys_bits - 1); | 457 | boot_cpu_data.x86_phys_bits - 1); |
| 458 | low_phys_bits -= shadow_nonpresent_or_rsvd_mask_len; | ||
| 459 | } | ||
| 460 | shadow_nonpresent_or_rsvd_lower_gfn_mask = | ||
| 461 | GENMASK_ULL(low_phys_bits - 1, PAGE_SHIFT); | ||
| 446 | } | 462 | } |
| 447 | 463 | ||
| 448 | static int is_cpuid_PSE36(void) | 464 | static int is_cpuid_PSE36(void) |
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 06412ba46aa3..612fd17be635 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c | |||
| @@ -121,7 +121,6 @@ module_param_named(pml, enable_pml, bool, S_IRUGO); | |||
| 121 | 121 | ||
| 122 | #define MSR_BITMAP_MODE_X2APIC 1 | 122 | #define MSR_BITMAP_MODE_X2APIC 1 |
| 123 | #define MSR_BITMAP_MODE_X2APIC_APICV 2 | 123 | #define MSR_BITMAP_MODE_X2APIC_APICV 2 |
| 124 | #define MSR_BITMAP_MODE_LM 4 | ||
| 125 | 124 | ||
| 126 | #define KVM_VMX_TSC_MULTIPLIER_MAX 0xffffffffffffffffULL | 125 | #define KVM_VMX_TSC_MULTIPLIER_MAX 0xffffffffffffffffULL |
| 127 | 126 | ||
| @@ -857,6 +856,7 @@ struct nested_vmx { | |||
| 857 | 856 | ||
| 858 | /* to migrate it to L2 if VM_ENTRY_LOAD_DEBUG_CONTROLS is off */ | 857 | /* to migrate it to L2 if VM_ENTRY_LOAD_DEBUG_CONTROLS is off */ |
| 859 | u64 vmcs01_debugctl; | 858 | u64 vmcs01_debugctl; |
| 859 | u64 vmcs01_guest_bndcfgs; | ||
| 860 | 860 | ||
| 861 | u16 vpid02; | 861 | u16 vpid02; |
| 862 | u16 last_vpid; | 862 | u16 last_vpid; |
| @@ -2899,8 +2899,7 @@ static void vmx_prepare_switch_to_guest(struct kvm_vcpu *vcpu) | |||
| 2899 | vmx->msr_host_kernel_gs_base = read_msr(MSR_KERNEL_GS_BASE); | 2899 | vmx->msr_host_kernel_gs_base = read_msr(MSR_KERNEL_GS_BASE); |
| 2900 | } | 2900 | } |
| 2901 | 2901 | ||
| 2902 | if (is_long_mode(&vmx->vcpu)) | 2902 | wrmsrl(MSR_KERNEL_GS_BASE, vmx->msr_guest_kernel_gs_base); |
| 2903 | wrmsrl(MSR_KERNEL_GS_BASE, vmx->msr_guest_kernel_gs_base); | ||
| 2904 | #else | 2903 | #else |
| 2905 | savesegment(fs, fs_sel); | 2904 | savesegment(fs, fs_sel); |
| 2906 | savesegment(gs, gs_sel); | 2905 | savesegment(gs, gs_sel); |
| @@ -2951,8 +2950,7 @@ static void vmx_prepare_switch_to_host(struct vcpu_vmx *vmx) | |||
| 2951 | vmx->loaded_cpu_state = NULL; | 2950 | vmx->loaded_cpu_state = NULL; |
| 2952 | 2951 | ||
| 2953 | #ifdef CONFIG_X86_64 | 2952 | #ifdef CONFIG_X86_64 |
| 2954 | if (is_long_mode(&vmx->vcpu)) | 2953 | rdmsrl(MSR_KERNEL_GS_BASE, vmx->msr_guest_kernel_gs_base); |
| 2955 | rdmsrl(MSR_KERNEL_GS_BASE, vmx->msr_guest_kernel_gs_base); | ||
| 2956 | #endif | 2954 | #endif |
| 2957 | if (host_state->ldt_sel || (host_state->gs_sel & 7)) { | 2955 | if (host_state->ldt_sel || (host_state->gs_sel & 7)) { |
| 2958 | kvm_load_ldt(host_state->ldt_sel); | 2956 | kvm_load_ldt(host_state->ldt_sel); |
| @@ -2980,24 +2978,19 @@ static void vmx_prepare_switch_to_host(struct vcpu_vmx *vmx) | |||
| 2980 | #ifdef CONFIG_X86_64 | 2978 | #ifdef CONFIG_X86_64 |
| 2981 | static u64 vmx_read_guest_kernel_gs_base(struct vcpu_vmx *vmx) | 2979 | static u64 vmx_read_guest_kernel_gs_base(struct vcpu_vmx *vmx) |
| 2982 | { | 2980 | { |
| 2983 | if (is_long_mode(&vmx->vcpu)) { | 2981 | preempt_disable(); |
| 2984 | preempt_disable(); | 2982 | if (vmx->loaded_cpu_state) |
| 2985 | if (vmx->loaded_cpu_state) | 2983 | rdmsrl(MSR_KERNEL_GS_BASE, vmx->msr_guest_kernel_gs_base); |
| 2986 | rdmsrl(MSR_KERNEL_GS_BASE, | 2984 | preempt_enable(); |
| 2987 | vmx->msr_guest_kernel_gs_base); | ||
| 2988 | preempt_enable(); | ||
| 2989 | } | ||
| 2990 | return vmx->msr_guest_kernel_gs_base; | 2985 | return vmx->msr_guest_kernel_gs_base; |
| 2991 | } | 2986 | } |
| 2992 | 2987 | ||
| 2993 | static void vmx_write_guest_kernel_gs_base(struct vcpu_vmx *vmx, u64 data) | 2988 | static void vmx_write_guest_kernel_gs_base(struct vcpu_vmx *vmx, u64 data) |
| 2994 | { | 2989 | { |
| 2995 | if (is_long_mode(&vmx->vcpu)) { | 2990 | preempt_disable(); |
| 2996 | preempt_disable(); | 2991 | if (vmx->loaded_cpu_state) |
| 2997 | if (vmx->loaded_cpu_state) | 2992 | wrmsrl(MSR_KERNEL_GS_BASE, data); |
| 2998 | wrmsrl(MSR_KERNEL_GS_BASE, data); | 2993 | preempt_enable(); |
| 2999 | preempt_enable(); | ||
| 3000 | } | ||
| 3001 | vmx->msr_guest_kernel_gs_base = data; | 2994 | vmx->msr_guest_kernel_gs_base = data; |
| 3002 | } | 2995 | } |
| 3003 | #endif | 2996 | #endif |
| @@ -3533,9 +3526,6 @@ static void nested_vmx_setup_ctls_msrs(struct nested_vmx_msrs *msrs, bool apicv) | |||
| 3533 | VM_EXIT_LOAD_IA32_EFER | VM_EXIT_SAVE_IA32_EFER | | 3526 | VM_EXIT_LOAD_IA32_EFER | VM_EXIT_SAVE_IA32_EFER | |
| 3534 | VM_EXIT_SAVE_VMX_PREEMPTION_TIMER | VM_EXIT_ACK_INTR_ON_EXIT; | 3527 | VM_EXIT_SAVE_VMX_PREEMPTION_TIMER | VM_EXIT_ACK_INTR_ON_EXIT; |
| 3535 | 3528 | ||
| 3536 | if (kvm_mpx_supported()) | ||
| 3537 | msrs->exit_ctls_high |= VM_EXIT_CLEAR_BNDCFGS; | ||
| 3538 | |||
| 3539 | /* We support free control of debug control saving. */ | 3529 | /* We support free control of debug control saving. */ |
| 3540 | msrs->exit_ctls_low &= ~VM_EXIT_SAVE_DEBUG_CONTROLS; | 3530 | msrs->exit_ctls_low &= ~VM_EXIT_SAVE_DEBUG_CONTROLS; |
| 3541 | 3531 | ||
| @@ -3552,8 +3542,6 @@ static void nested_vmx_setup_ctls_msrs(struct nested_vmx_msrs *msrs, bool apicv) | |||
| 3552 | VM_ENTRY_LOAD_IA32_PAT; | 3542 | VM_ENTRY_LOAD_IA32_PAT; |
| 3553 | msrs->entry_ctls_high |= | 3543 | msrs->entry_ctls_high |= |
| 3554 | (VM_ENTRY_ALWAYSON_WITHOUT_TRUE_MSR | VM_ENTRY_LOAD_IA32_EFER); | 3544 | (VM_ENTRY_ALWAYSON_WITHOUT_TRUE_MSR | VM_ENTRY_LOAD_IA32_EFER); |
| 3555 | if (kvm_mpx_supported()) | ||
| 3556 | msrs->entry_ctls_high |= VM_ENTRY_LOAD_BNDCFGS; | ||
| 3557 | 3545 | ||
| 3558 | /* We support free control of debug control loading. */ | 3546 | /* We support free control of debug control loading. */ |
| 3559 | msrs->entry_ctls_low &= ~VM_ENTRY_LOAD_DEBUG_CONTROLS; | 3547 | msrs->entry_ctls_low &= ~VM_ENTRY_LOAD_DEBUG_CONTROLS; |
| @@ -3601,12 +3589,12 @@ static void nested_vmx_setup_ctls_msrs(struct nested_vmx_msrs *msrs, bool apicv) | |||
| 3601 | msrs->secondary_ctls_high); | 3589 | msrs->secondary_ctls_high); |
| 3602 | msrs->secondary_ctls_low = 0; | 3590 | msrs->secondary_ctls_low = 0; |
| 3603 | msrs->secondary_ctls_high &= | 3591 | msrs->secondary_ctls_high &= |
| 3604 | SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES | | ||
| 3605 | SECONDARY_EXEC_DESC | | 3592 | SECONDARY_EXEC_DESC | |
| 3606 | SECONDARY_EXEC_VIRTUALIZE_X2APIC_MODE | | 3593 | SECONDARY_EXEC_VIRTUALIZE_X2APIC_MODE | |
| 3607 | SECONDARY_EXEC_APIC_REGISTER_VIRT | | 3594 | SECONDARY_EXEC_APIC_REGISTER_VIRT | |
| 3608 | SECONDARY_EXEC_VIRTUAL_INTR_DELIVERY | | 3595 | SECONDARY_EXEC_VIRTUAL_INTR_DELIVERY | |
| 3609 | SECONDARY_EXEC_WBINVD_EXITING; | 3596 | SECONDARY_EXEC_WBINVD_EXITING; |
| 3597 | |||
| 3610 | /* | 3598 | /* |
| 3611 | * We can emulate "VMCS shadowing," even if the hardware | 3599 | * We can emulate "VMCS shadowing," even if the hardware |
| 3612 | * doesn't support it. | 3600 | * doesn't support it. |
| @@ -3663,6 +3651,10 @@ static void nested_vmx_setup_ctls_msrs(struct nested_vmx_msrs *msrs, bool apicv) | |||
| 3663 | msrs->secondary_ctls_high |= | 3651 | msrs->secondary_ctls_high |= |
| 3664 | SECONDARY_EXEC_UNRESTRICTED_GUEST; | 3652 | SECONDARY_EXEC_UNRESTRICTED_GUEST; |
| 3665 | 3653 | ||
| 3654 | if (flexpriority_enabled) | ||
| 3655 | msrs->secondary_ctls_high |= | ||
| 3656 | SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES; | ||
| 3657 | |||
| 3666 | /* miscellaneous data */ | 3658 | /* miscellaneous data */ |
| 3667 | rdmsr(MSR_IA32_VMX_MISC, | 3659 | rdmsr(MSR_IA32_VMX_MISC, |
| 3668 | msrs->misc_low, | 3660 | msrs->misc_low, |
| @@ -5073,19 +5065,6 @@ static void vmx_set_efer(struct kvm_vcpu *vcpu, u64 efer) | |||
| 5073 | if (!msr) | 5065 | if (!msr) |
| 5074 | return; | 5066 | return; |
| 5075 | 5067 | ||
| 5076 | /* | ||
| 5077 | * MSR_KERNEL_GS_BASE is not intercepted when the guest is in | ||
| 5078 | * 64-bit mode as a 64-bit kernel may frequently access the | ||
| 5079 | * MSR. This means we need to manually save/restore the MSR | ||
| 5080 | * when switching between guest and host state, but only if | ||
| 5081 | * the guest is in 64-bit mode. Sync our cached value if the | ||
| 5082 | * guest is transitioning to 32-bit mode and the CPU contains | ||
| 5083 | * guest state, i.e. the cache is stale. | ||
| 5084 | */ | ||
| 5085 | #ifdef CONFIG_X86_64 | ||
| 5086 | if (!(efer & EFER_LMA)) | ||
| 5087 | (void)vmx_read_guest_kernel_gs_base(vmx); | ||
| 5088 | #endif | ||
| 5089 | vcpu->arch.efer = efer; | 5068 | vcpu->arch.efer = efer; |
| 5090 | if (efer & EFER_LMA) { | 5069 | if (efer & EFER_LMA) { |
| 5091 | vm_entry_controls_setbit(to_vmx(vcpu), VM_ENTRY_IA32E_MODE); | 5070 | vm_entry_controls_setbit(to_vmx(vcpu), VM_ENTRY_IA32E_MODE); |
| @@ -6078,9 +6057,6 @@ static u8 vmx_msr_bitmap_mode(struct kvm_vcpu *vcpu) | |||
| 6078 | mode |= MSR_BITMAP_MODE_X2APIC_APICV; | 6057 | mode |= MSR_BITMAP_MODE_X2APIC_APICV; |
| 6079 | } | 6058 | } |
| 6080 | 6059 | ||
| 6081 | if (is_long_mode(vcpu)) | ||
| 6082 | mode |= MSR_BITMAP_MODE_LM; | ||
| 6083 | |||
| 6084 | return mode; | 6060 | return mode; |
| 6085 | } | 6061 | } |
| 6086 | 6062 | ||
| @@ -6121,9 +6097,6 @@ static void vmx_update_msr_bitmap(struct kvm_vcpu *vcpu) | |||
| 6121 | if (!changed) | 6097 | if (!changed) |
| 6122 | return; | 6098 | return; |
| 6123 | 6099 | ||
| 6124 | vmx_set_intercept_for_msr(msr_bitmap, MSR_KERNEL_GS_BASE, MSR_TYPE_RW, | ||
| 6125 | !(mode & MSR_BITMAP_MODE_LM)); | ||
| 6126 | |||
| 6127 | if (changed & (MSR_BITMAP_MODE_X2APIC | MSR_BITMAP_MODE_X2APIC_APICV)) | 6100 | if (changed & (MSR_BITMAP_MODE_X2APIC | MSR_BITMAP_MODE_X2APIC_APICV)) |
| 6128 | vmx_update_msr_bitmap_x2apic(msr_bitmap, mode); | 6101 | vmx_update_msr_bitmap_x2apic(msr_bitmap, mode); |
| 6129 | 6102 | ||
| @@ -6189,6 +6162,11 @@ static void vmx_complete_nested_posted_interrupt(struct kvm_vcpu *vcpu) | |||
| 6189 | nested_mark_vmcs12_pages_dirty(vcpu); | 6162 | nested_mark_vmcs12_pages_dirty(vcpu); |
| 6190 | } | 6163 | } |
| 6191 | 6164 | ||
| 6165 | static u8 vmx_get_rvi(void) | ||
| 6166 | { | ||
| 6167 | return vmcs_read16(GUEST_INTR_STATUS) & 0xff; | ||
| 6168 | } | ||
| 6169 | |||
| 6192 | static bool vmx_guest_apic_has_interrupt(struct kvm_vcpu *vcpu) | 6170 | static bool vmx_guest_apic_has_interrupt(struct kvm_vcpu *vcpu) |
| 6193 | { | 6171 | { |
| 6194 | struct vcpu_vmx *vmx = to_vmx(vcpu); | 6172 | struct vcpu_vmx *vmx = to_vmx(vcpu); |
| @@ -6201,7 +6179,7 @@ static bool vmx_guest_apic_has_interrupt(struct kvm_vcpu *vcpu) | |||
| 6201 | WARN_ON_ONCE(!vmx->nested.virtual_apic_page)) | 6179 | WARN_ON_ONCE(!vmx->nested.virtual_apic_page)) |
| 6202 | return false; | 6180 | return false; |
| 6203 | 6181 | ||
| 6204 | rvi = vmcs_read16(GUEST_INTR_STATUS) & 0xff; | 6182 | rvi = vmx_get_rvi(); |
| 6205 | 6183 | ||
| 6206 | vapic_page = kmap(vmx->nested.virtual_apic_page); | 6184 | vapic_page = kmap(vmx->nested.virtual_apic_page); |
| 6207 | vppr = *((u32 *)(vapic_page + APIC_PROCPRI)); | 6185 | vppr = *((u32 *)(vapic_page + APIC_PROCPRI)); |
| @@ -10245,15 +10223,16 @@ static void vmx_set_virtual_apic_mode(struct kvm_vcpu *vcpu) | |||
| 10245 | if (!lapic_in_kernel(vcpu)) | 10223 | if (!lapic_in_kernel(vcpu)) |
| 10246 | return; | 10224 | return; |
| 10247 | 10225 | ||
| 10226 | if (!flexpriority_enabled && | ||
| 10227 | !cpu_has_vmx_virtualize_x2apic_mode()) | ||
| 10228 | return; | ||
| 10229 | |||
| 10248 | /* Postpone execution until vmcs01 is the current VMCS. */ | 10230 | /* Postpone execution until vmcs01 is the current VMCS. */ |
| 10249 | if (is_guest_mode(vcpu)) { | 10231 | if (is_guest_mode(vcpu)) { |
| 10250 | to_vmx(vcpu)->nested.change_vmcs01_virtual_apic_mode = true; | 10232 | to_vmx(vcpu)->nested.change_vmcs01_virtual_apic_mode = true; |
| 10251 | return; | 10233 | return; |
| 10252 | } | 10234 | } |
| 10253 | 10235 | ||
| 10254 | if (!cpu_need_tpr_shadow(vcpu)) | ||
| 10255 | return; | ||
| 10256 | |||
| 10257 | sec_exec_control = vmcs_read32(SECONDARY_VM_EXEC_CONTROL); | 10236 | sec_exec_control = vmcs_read32(SECONDARY_VM_EXEC_CONTROL); |
| 10258 | sec_exec_control &= ~(SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES | | 10237 | sec_exec_control &= ~(SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES | |
| 10259 | SECONDARY_EXEC_VIRTUALIZE_X2APIC_MODE); | 10238 | SECONDARY_EXEC_VIRTUALIZE_X2APIC_MODE); |
| @@ -10375,6 +10354,14 @@ static int vmx_sync_pir_to_irr(struct kvm_vcpu *vcpu) | |||
| 10375 | return max_irr; | 10354 | return max_irr; |
| 10376 | } | 10355 | } |
| 10377 | 10356 | ||
| 10357 | static u8 vmx_has_apicv_interrupt(struct kvm_vcpu *vcpu) | ||
| 10358 | { | ||
| 10359 | u8 rvi = vmx_get_rvi(); | ||
| 10360 | u8 vppr = kvm_lapic_get_reg(vcpu->arch.apic, APIC_PROCPRI); | ||
| 10361 | |||
| 10362 | return ((rvi & 0xf0) > (vppr & 0xf0)); | ||
| 10363 | } | ||
| 10364 | |||
| 10378 | static void vmx_load_eoi_exitmap(struct kvm_vcpu *vcpu, u64 *eoi_exit_bitmap) | 10365 | static void vmx_load_eoi_exitmap(struct kvm_vcpu *vcpu, u64 *eoi_exit_bitmap) |
| 10379 | { | 10366 | { |
| 10380 | if (!kvm_vcpu_apicv_active(vcpu)) | 10367 | if (!kvm_vcpu_apicv_active(vcpu)) |
| @@ -11264,6 +11251,23 @@ static void nested_vmx_cr_fixed1_bits_update(struct kvm_vcpu *vcpu) | |||
| 11264 | #undef cr4_fixed1_update | 11251 | #undef cr4_fixed1_update |
| 11265 | } | 11252 | } |
| 11266 | 11253 | ||
| 11254 | static void nested_vmx_entry_exit_ctls_update(struct kvm_vcpu *vcpu) | ||
| 11255 | { | ||
| 11256 | struct vcpu_vmx *vmx = to_vmx(vcpu); | ||
| 11257 | |||
| 11258 | if (kvm_mpx_supported()) { | ||
| 11259 | bool mpx_enabled = guest_cpuid_has(vcpu, X86_FEATURE_MPX); | ||
| 11260 | |||
| 11261 | if (mpx_enabled) { | ||
| 11262 | vmx->nested.msrs.entry_ctls_high |= VM_ENTRY_LOAD_BNDCFGS; | ||
| 11263 | vmx->nested.msrs.exit_ctls_high |= VM_EXIT_CLEAR_BNDCFGS; | ||
| 11264 | } else { | ||
| 11265 | vmx->nested.msrs.entry_ctls_high &= ~VM_ENTRY_LOAD_BNDCFGS; | ||
| 11266 | vmx->nested.msrs.exit_ctls_high &= ~VM_EXIT_CLEAR_BNDCFGS; | ||
| 11267 | } | ||
| 11268 | } | ||
| 11269 | } | ||
| 11270 | |||
| 11267 | static void vmx_cpuid_update(struct kvm_vcpu *vcpu) | 11271 | static void vmx_cpuid_update(struct kvm_vcpu *vcpu) |
| 11268 | { | 11272 | { |
| 11269 | struct vcpu_vmx *vmx = to_vmx(vcpu); | 11273 | struct vcpu_vmx *vmx = to_vmx(vcpu); |
| @@ -11280,8 +11284,10 @@ static void vmx_cpuid_update(struct kvm_vcpu *vcpu) | |||
| 11280 | to_vmx(vcpu)->msr_ia32_feature_control_valid_bits &= | 11284 | to_vmx(vcpu)->msr_ia32_feature_control_valid_bits &= |
| 11281 | ~FEATURE_CONTROL_VMXON_ENABLED_OUTSIDE_SMX; | 11285 | ~FEATURE_CONTROL_VMXON_ENABLED_OUTSIDE_SMX; |
| 11282 | 11286 | ||
| 11283 | if (nested_vmx_allowed(vcpu)) | 11287 | if (nested_vmx_allowed(vcpu)) { |
| 11284 | nested_vmx_cr_fixed1_bits_update(vcpu); | 11288 | nested_vmx_cr_fixed1_bits_update(vcpu); |
| 11289 | nested_vmx_entry_exit_ctls_update(vcpu); | ||
| 11290 | } | ||
| 11285 | } | 11291 | } |
| 11286 | 11292 | ||
| 11287 | static void vmx_set_supported_cpuid(u32 func, struct kvm_cpuid_entry2 *entry) | 11293 | static void vmx_set_supported_cpuid(u32 func, struct kvm_cpuid_entry2 *entry) |
| @@ -12049,8 +12055,13 @@ static void prepare_vmcs02_full(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12) | |||
| 12049 | 12055 | ||
| 12050 | set_cr4_guest_host_mask(vmx); | 12056 | set_cr4_guest_host_mask(vmx); |
| 12051 | 12057 | ||
| 12052 | if (vmx_mpx_supported()) | 12058 | if (kvm_mpx_supported()) { |
| 12053 | vmcs_write64(GUEST_BNDCFGS, vmcs12->guest_bndcfgs); | 12059 | if (vmx->nested.nested_run_pending && |
| 12060 | (vmcs12->vm_entry_controls & VM_ENTRY_LOAD_BNDCFGS)) | ||
| 12061 | vmcs_write64(GUEST_BNDCFGS, vmcs12->guest_bndcfgs); | ||
| 12062 | else | ||
| 12063 | vmcs_write64(GUEST_BNDCFGS, vmx->nested.vmcs01_guest_bndcfgs); | ||
| 12064 | } | ||
| 12054 | 12065 | ||
| 12055 | if (enable_vpid) { | 12066 | if (enable_vpid) { |
| 12056 | if (nested_cpu_has_vpid(vmcs12) && vmx->nested.vpid02) | 12067 | if (nested_cpu_has_vpid(vmcs12) && vmx->nested.vpid02) |
| @@ -12595,15 +12606,21 @@ static int enter_vmx_non_root_mode(struct kvm_vcpu *vcpu, u32 *exit_qual) | |||
| 12595 | struct vmcs12 *vmcs12 = get_vmcs12(vcpu); | 12606 | struct vmcs12 *vmcs12 = get_vmcs12(vcpu); |
| 12596 | bool from_vmentry = !!exit_qual; | 12607 | bool from_vmentry = !!exit_qual; |
| 12597 | u32 dummy_exit_qual; | 12608 | u32 dummy_exit_qual; |
| 12598 | u32 vmcs01_cpu_exec_ctrl; | 12609 | bool evaluate_pending_interrupts; |
| 12599 | int r = 0; | 12610 | int r = 0; |
| 12600 | 12611 | ||
| 12601 | vmcs01_cpu_exec_ctrl = vmcs_read32(CPU_BASED_VM_EXEC_CONTROL); | 12612 | evaluate_pending_interrupts = vmcs_read32(CPU_BASED_VM_EXEC_CONTROL) & |
| 12613 | (CPU_BASED_VIRTUAL_INTR_PENDING | CPU_BASED_VIRTUAL_NMI_PENDING); | ||
| 12614 | if (likely(!evaluate_pending_interrupts) && kvm_vcpu_apicv_active(vcpu)) | ||
| 12615 | evaluate_pending_interrupts |= vmx_has_apicv_interrupt(vcpu); | ||
| 12602 | 12616 | ||
| 12603 | enter_guest_mode(vcpu); | 12617 | enter_guest_mode(vcpu); |
| 12604 | 12618 | ||
| 12605 | if (!(vmcs12->vm_entry_controls & VM_ENTRY_LOAD_DEBUG_CONTROLS)) | 12619 | if (!(vmcs12->vm_entry_controls & VM_ENTRY_LOAD_DEBUG_CONTROLS)) |
| 12606 | vmx->nested.vmcs01_debugctl = vmcs_read64(GUEST_IA32_DEBUGCTL); | 12620 | vmx->nested.vmcs01_debugctl = vmcs_read64(GUEST_IA32_DEBUGCTL); |
| 12621 | if (kvm_mpx_supported() && | ||
| 12622 | !(vmcs12->vm_entry_controls & VM_ENTRY_LOAD_BNDCFGS)) | ||
| 12623 | vmx->nested.vmcs01_guest_bndcfgs = vmcs_read64(GUEST_BNDCFGS); | ||
| 12607 | 12624 | ||
| 12608 | vmx_switch_vmcs(vcpu, &vmx->nested.vmcs02); | 12625 | vmx_switch_vmcs(vcpu, &vmx->nested.vmcs02); |
| 12609 | vmx_segment_cache_clear(vmx); | 12626 | vmx_segment_cache_clear(vmx); |
| @@ -12643,16 +12660,14 @@ static int enter_vmx_non_root_mode(struct kvm_vcpu *vcpu, u32 *exit_qual) | |||
| 12643 | * to L1 or delivered directly to L2 (e.g. In case L1 don't | 12660 | * to L1 or delivered directly to L2 (e.g. In case L1 don't |
| 12644 | * intercept EXTERNAL_INTERRUPT). | 12661 | * intercept EXTERNAL_INTERRUPT). |
| 12645 | * | 12662 | * |
| 12646 | * Usually this would be handled by L0 requesting a | 12663 | * Usually this would be handled by the processor noticing an |
| 12647 | * IRQ/NMI window by setting VMCS accordingly. However, | 12664 | * IRQ/NMI window request, or checking RVI during evaluation of |
| 12648 | * this setting was done on VMCS01 and now VMCS02 is active | 12665 | * pending virtual interrupts. However, this setting was done |
| 12649 | * instead. Thus, we force L0 to perform pending event | 12666 | * on VMCS01 and now VMCS02 is active instead. Thus, we force L0 |
| 12650 | * evaluation by requesting a KVM_REQ_EVENT. | 12667 | * to perform pending event evaluation by requesting a KVM_REQ_EVENT. |
| 12651 | */ | 12668 | */ |
| 12652 | if (vmcs01_cpu_exec_ctrl & | 12669 | if (unlikely(evaluate_pending_interrupts)) |
| 12653 | (CPU_BASED_VIRTUAL_INTR_PENDING | CPU_BASED_VIRTUAL_NMI_PENDING)) { | ||
| 12654 | kvm_make_request(KVM_REQ_EVENT, vcpu); | 12670 | kvm_make_request(KVM_REQ_EVENT, vcpu); |
| 12655 | } | ||
| 12656 | 12671 | ||
| 12657 | /* | 12672 | /* |
| 12658 | * Note no nested_vmx_succeed or nested_vmx_fail here. At this point | 12673 | * Note no nested_vmx_succeed or nested_vmx_fail here. At this point |
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index edbf00ec56b3..ca717737347e 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c | |||
| @@ -4698,7 +4698,7 @@ static void kvm_init_msr_list(void) | |||
| 4698 | */ | 4698 | */ |
| 4699 | switch (msrs_to_save[i]) { | 4699 | switch (msrs_to_save[i]) { |
| 4700 | case MSR_IA32_BNDCFGS: | 4700 | case MSR_IA32_BNDCFGS: |
| 4701 | if (!kvm_x86_ops->mpx_supported()) | 4701 | if (!kvm_mpx_supported()) |
| 4702 | continue; | 4702 | continue; |
| 4703 | break; | 4703 | break; |
| 4704 | case MSR_TSC_AUX: | 4704 | case MSR_TSC_AUX: |
