History

Merge branch 'cve-2019-3016' into kvm-next-5.6

From Boris Ostrovsky: The KVM hypervisor may provide a guest with ability to defer remote TLB flush when the remote VCPU is not running. When this feature is used, the TLB flush will happen only when the remote VPCU is scheduled to run again. This will avoid unnecessary (and expensive) IPIs. Under certain circumstances, when a guest initiates such deferred action, the hypervisor may miss the request. It is also possible that the guest may mistakenly assume that it has already marked remote VCPU as needing a flush when in fact that request had already been processed by the hypervisor. In both cases this will result in an invalid translation being present in a vCPU, potentially allowing accesses to memory locations in that guest's address space that should not be accessible. Note that only intra-guest memory is vulnerable. The five patches address both of these problems: 1. The first patch makes sure the hypervisor doesn't accidentally clear a guest's remote flush request 2. The rest of the patches prevent the race between hypervisor acknowledging a remote flush request and guest issuing a new one.

Paolo Bonzini committed 6 years ago

Commit 4cbc4182 parents 1d5920c a6bd81139 files · +338 −183Browse files

Unified · Split

39 files
  1. Documentation/devicetree/bindings/spi/spi-controller.yaml +2 −2
  2. arch/arc/include/asm/entry-arcv2.h +4 −4
  3. arch/arc/include/asm/hugepage.h +0 −1
  4. arch/arc/kernel/asm-offsets.c +9 −1
  5. arch/arc/plat-eznps/Kconfig +1 −1
  6. arch/arm64/include/asm/pgtable-prot.h +2 −3
  7. arch/arm64/include/asm/pgtable.h +3 −7
  8. arch/arm64/mm/fault.c +1 −1
  9. arch/x86/include/asm/kvm_host.h +2 −2
  10. arch/x86/kvm/x86.c +43 −26
  11. drivers/char/tpm/tpm_tis_core.c +15 −19
  12. drivers/regulator/axp20x-regulator.c +7 −4
  13. drivers/regulator/bd70528-regulator.c +0 −1
  14. drivers/rtc/rtc-mc146818-lib.c +1 −14
  15. drivers/rtc/rtc-mt6397.c +25 −14
  16. drivers/rtc/rtc-sun6i.c +16 −0
  17. drivers/spi/spi-dw.c +12 −3
  18. drivers/spi/spi-dw.h +1 −0
  19. drivers/spi/spi-fsl-dspi.c +10 −14
  20. drivers/spi/spi-uniphier.c +19 −12
  21. drivers/spi/spi.c +8 −14
  22. drivers/watchdog/Kconfig +2 −0
  23. drivers/watchdog/imx7ulp_wdt.c +1 −1
  24. drivers/watchdog/orion_wdt.c +2 −2
  25. drivers/watchdog/rn5t618_wdt.c +1 −0
  26. drivers/watchdog/w83627hf_wdt.c +1 −1
  27. include/linux/kvm_host.h +5 −0
  28. include/linux/kvm_types.h +8 −1
  29. include/linux/mfd/mt6397/rtc.h +8 −0
  30. include/linux/spi/spi.h +2 −2
  31. include/trace/events/preemptirq.h +4 −4
  32. kernel/trace/fgraph.c +14 −0
  33. kernel/trace/ftrace.c +3 −3
  34. kernel/trace/trace_events_inject.c +1 −1
  35. kernel/trace/trace_sched_wakeup.c +3 −1
  36. kernel/trace/trace_seq.c +1 −1
  37. kernel/trace/trace_stack.c +5 −0
  38. mm/mmap.c +0 −6
  39. virt/kvm/kvm_main.c +96 −17
Documentation/devicetree/bindings/spi/spi-controller.yaml+2−2
@@ -111,7 +111,7 @@ patternProperties: · 110 unmodified lines
111111 spi-rx-bus-width:
112112 allOf:
113113 - $ref: /schemas/types.yaml#/definitions/uint32
114− - enum: [ 1, 2, 4 ]
114+ - enum: [ 1, 2, 4, 8 ]
115115 - default: 1
116116 description:
117117 Bus width to the SPI bus used for MISO.
@@ -123,7 +123,7 @@ patternProperties: · 5 unmodified lines
123123 spi-tx-bus-width:
124124 allOf:
125125 - $ref: /schemas/types.yaml#/definitions/uint32
126− - enum: [ 1, 2, 4 ]
126+ - enum: [ 1, 2, 4, 8 ]
127127 - default: 1
128128 description:
129129 Bus width to the SPI bus used for MOSI.
arch/arc/include/asm/entry-arcv2.h+4−4
@@ -162,7 +162,7 @@ · 161 unmodified lines
162162 #endif
163163
164164 #ifdef CONFIG_ARC_HAS_ACCL_REGS
165− ST2 r58, r59, PT_sp + 12
165+ ST2 r58, r59, PT_r58
166166 #endif
167167
168168 .endm
@@ -172,8 +172,8 @@ · 3 unmodified lines
172172
173173 LD2 gp, fp, PT_r26 ; gp (r26), fp (r27)
174174
175− ld r12, [sp, PT_sp + 4]
176− ld r30, [sp, PT_sp + 8]
175+ ld r12, [sp, PT_r12]
176+ ld r30, [sp, PT_r30]
177177
178178 ; Restore SP (into AUX_USER_SP) only if returning to U mode
179179 ; - for K mode, it will be implicitly restored as stack is unwound
@@ -190,7 +190,7 @@ · 10 unmodified lines
190190 #endif
191191
192192 #ifdef CONFIG_ARC_HAS_ACCL_REGS
193− LD2 r58, r59, PT_sp + 12
193+ LD2 r58, r59, PT_r58
194194 #endif
195195 .endm
196196
arch/arc/include/asm/hugepage.h+0−1
@@ -8,7 +8,6 @@ · 7 unmodified lines
88 #define _ASM_ARC_HUGEPAGE_H
99
1010 #include <linux/types.h>
11−#define __ARCH_USE_5LEVEL_HACK
1211 #include <asm-generic/pgtable-nopmd.h>
1312
1413 static inline pte_t pmd_pte(pmd_t pmd)
arch/arc/kernel/asm-offsets.c+9−1
@@ -66,7 +66,15 @@ int main(void) · 65 unmodified lines
6666
6767 DEFINE(SZ_CALLEE_REGS, sizeof(struct callee_regs));
6868 DEFINE(SZ_PT_REGS, sizeof(struct pt_regs));
69− DEFINE(PT_user_r25, offsetof(struct pt_regs, user_r25));
69+
70+#ifdef CONFIG_ISA_ARCV2
71+ OFFSET(PT_r12, pt_regs, r12);
72+ OFFSET(PT_r30, pt_regs, r30);
73+#endif
74+#ifdef CONFIG_ARC_HAS_ACCL_REGS
75+ OFFSET(PT_r58, pt_regs, r58);
76+ OFFSET(PT_r59, pt_regs, r59);
77+#endif
7078
7179 return 0;
7280 }
arch/arc/plat-eznps/Kconfig+1−1
@@ -7,7 +7,7 @@ · 6 unmodified lines
77 menuconfig ARC_PLAT_EZNPS
88 bool "\"EZchip\" ARC dev platform"
99 select CPU_BIG_ENDIAN
10− select CLKSRC_NPS
10+ select CLKSRC_NPS if !PHYS_ADDR_T_64BIT
1111 select EZNPS_GIC
1212 select EZCHIP_NPS_MANAGEMENT_ENET if ETHERNET
1313 help
arch/arm64/include/asm/pgtable-prot.h+2−3
@@ -85,13 +85,12 @@ · 84 unmodified lines
8585 #define PAGE_SHARED_EXEC __pgprot(_PAGE_DEFAULT | PTE_USER | PTE_RDONLY | PTE_NG | PTE_PXN | PTE_WRITE)
8686 #define PAGE_READONLY __pgprot(_PAGE_DEFAULT | PTE_USER | PTE_RDONLY | PTE_NG | PTE_PXN | PTE_UXN)
8787 #define PAGE_READONLY_EXEC __pgprot(_PAGE_DEFAULT | PTE_USER | PTE_RDONLY | PTE_NG | PTE_PXN)
88−#define PAGE_EXECONLY __pgprot(_PAGE_DEFAULT | PTE_RDONLY | PTE_NG | PTE_PXN)
8988
9089 #define __P000 PAGE_NONE
9190 #define __P001 PAGE_READONLY
9291 #define __P010 PAGE_READONLY
9392 #define __P011 PAGE_READONLY
94−#define __P100 PAGE_EXECONLY
93+#define __P100 PAGE_READONLY_EXEC
9594 #define __P101 PAGE_READONLY_EXEC
9695 #define __P110 PAGE_READONLY_EXEC
9796 #define __P111 PAGE_READONLY_EXEC
@@ -100,7 +99,7 @@ · 2 unmodified lines
10099 #define __S001 PAGE_READONLY
101100 #define __S010 PAGE_SHARED
102101 #define __S011 PAGE_SHARED
103−#define __S100 PAGE_EXECONLY
102+#define __S100 PAGE_READONLY_EXEC
104103 #define __S101 PAGE_READONLY_EXEC
105104 #define __S110 PAGE_SHARED_EXEC
106105 #define __S111 PAGE_SHARED_EXEC
arch/arm64/include/asm/pgtable.h+3−7
@@ -96,12 +96,8 @@ extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)]; · 95 unmodified lines
9696 #define pte_dirty(pte) (pte_sw_dirty(pte) || pte_hw_dirty(pte))
9797
9898 #define pte_valid(pte) (!!(pte_val(pte) & PTE_VALID))
99−/*
100− * Execute-only user mappings do not have the PTE_USER bit set. All valid
101− * kernel mappings have the PTE_UXN bit set.
102− */
10399 #define pte_valid_not_user(pte) \
104− ((pte_val(pte) & (PTE_VALID | PTE_USER | PTE_UXN)) == (PTE_VALID | PTE_UXN))
100+ ((pte_val(pte) & (PTE_VALID | PTE_USER)) == PTE_VALID)
105101 #define pte_valid_young(pte) \
106102 ((pte_val(pte) & (PTE_VALID | PTE_AF)) == (PTE_VALID | PTE_AF))
107103 #define pte_valid_user(pte) \
@@ -117,8 +113,8 @@ extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)]; · 9 unmodified lines
117113
118114 /*
119115 * p??_access_permitted() is true for valid user mappings (subject to the
120− * write permission check) other than user execute-only which do not have the
121− * PTE_USER bit set. PROT_NONE mappings do not have the PTE_VALID bit set.
116+ * write permission check). PROT_NONE mappings do not have the PTE_VALID bit
117+ * set.
122118 */
123119 #define pte_access_permitted(pte, write) \
124120 (pte_valid_user(pte) && (!(write) || pte_write(pte)))
arch/arm64/mm/fault.c+1−1
@@ -445,7 +445,7 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr, · 444 unmodified lines
445445 const struct fault_info *inf;
446446 struct mm_struct *mm = current->mm;
447447 vm_fault_t fault, major = 0;
448− unsigned long vm_flags = VM_READ | VM_WRITE;
448+ unsigned long vm_flags = VM_READ | VM_WRITE | VM_EXEC;
449449 unsigned int mm_flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE;
450450
451451 if (kprobe_page_fault(regs, esr))
arch/x86/include/asm/kvm_host.h+2−2
@@ -690,10 +690,10 @@ struct kvm_vcpu_arch { · 689 unmodified lines
690690 bool pvclock_set_guest_stopped_request;
691691
692692 struct {
693+ u8 preempted;
693694 u64 msr_val;
694695 u64 last_steal;
695− struct gfn_to_hva_cache stime;
696− struct kvm_steal_time steal;
696+ struct gfn_to_pfn_cache cache;
697697 } st;
698698
699699 u64 tsc_offset;
arch/x86/kvm/x86.c+43−26
@@ -2648,45 +2648,47 @@ static void kvm_vcpu_flush_tlb(struct kvm_vcpu *vcpu, bool invalidate_gpa) · 2647 unmodified lines
26482648
26492649 static void record_steal_time(struct kvm_vcpu *vcpu)
26502650 {
2651+ struct kvm_host_map map;
2652+ struct kvm_steal_time *st;
2653+
26512654 if (!(vcpu->arch.st.msr_val & KVM_MSR_ENABLED))
26522655 return;
26532656
2654− if (unlikely(kvm_read_guest_cached(vcpu->kvm, &vcpu->arch.st.stime,
2655− &vcpu->arch.st.steal, sizeof(struct kvm_steal_time))))
2657+ /* -EAGAIN is returned in atomic context so we can just return. */
2658+ if (kvm_map_gfn(vcpu, vcpu->arch.st.msr_val >> PAGE_SHIFT,
2659+ &map, &vcpu->arch.st.cache, false))
26562660 return;
26572661
2662+ st = map.hva +
2663+ offset_in_page(vcpu->arch.st.msr_val & KVM_STEAL_VALID_BITS);
2664+
26582665 /*
26592666 * Doing a TLB flush here, on the guest's behalf, can avoid
26602667 * expensive IPIs.
26612668 */
26622669 trace_kvm_pv_tlb_flush(vcpu->vcpu_id,
2663− vcpu->arch.st.steal.preempted & KVM_VCPU_FLUSH_TLB);
2664− if (xchg(&vcpu->arch.st.steal.preempted, 0) & KVM_VCPU_FLUSH_TLB)
2670+ st->preempted & KVM_VCPU_FLUSH_TLB);
2671+ if (xchg(&st->preempted, 0) & KVM_VCPU_FLUSH_TLB)
26652672 kvm_vcpu_flush_tlb(vcpu, false);
26662673
2667− if (vcpu->arch.st.steal.version & 1)
2668− vcpu->arch.st.steal.version += 1; /* first time write, random junk */
2674+ vcpu->arch.st.preempted = 0;
26692675
2670− vcpu->arch.st.steal.version += 1;
2676+ if (st->version & 1)
2677+ st->version += 1; /* first time write, random junk */
26712678
2672− kvm_write_guest_cached(vcpu->kvm, &vcpu->arch.st.stime,
2673− &vcpu->arch.st.steal, sizeof(struct kvm_steal_time));
2679+ st->version += 1;
26742680
26752681 smp_wmb();
26762682
2677− vcpu->arch.st.steal.steal += current->sched_info.run_delay -
2683+ st->steal += current->sched_info.run_delay -
26782684 vcpu->arch.st.last_steal;
26792685 vcpu->arch.st.last_steal = current->sched_info.run_delay;
26802686
2681− kvm_write_guest_cached(vcpu->kvm, &vcpu->arch.st.stime,
2682− &vcpu->arch.st.steal, sizeof(struct kvm_steal_time));
2683−
26842687 smp_wmb();
26852688
2686− vcpu->arch.st.steal.version += 1;
2689+ st->version += 1;
26872690
2688− kvm_write_guest_cached(vcpu->kvm, &vcpu->arch.st.stime,
2689− &vcpu->arch.st.steal, sizeof(struct kvm_steal_time));
2691+ kvm_unmap_gfn(vcpu, &map, &vcpu->arch.st.cache, true, false);
26902692 }
26912693
26922694 int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
@@ -2853,11 +2855,6 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info) · 160 unmodified lines
28532855 if (data & KVM_STEAL_RESERVED_MASK)
28542856 return 1;
28552857
2856− if (kvm_gfn_to_hva_cache_init(vcpu->kvm, &vcpu->arch.st.stime,
2857− data & KVM_STEAL_VALID_BITS,
2858− sizeof(struct kvm_steal_time)))
2859− return 1;
2860−
28612858 vcpu->arch.st.msr_val = data;
28622859
28632860 if (!(data & KVM_MSR_ENABLED))
@@ -3567,15 +3564,25 @@ void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu) · 703 unmodified lines
35673564
35683565 static void kvm_steal_time_set_preempted(struct kvm_vcpu *vcpu)
35693566 {
3567+ struct kvm_host_map map;
3568+ struct kvm_steal_time *st;
3569+
35703570 if (!(vcpu->arch.st.msr_val & KVM_MSR_ENABLED))
35713571 return;
35723572
3573− vcpu->arch.st.steal.preempted = KVM_VCPU_PREEMPTED;
3573+ if (vcpu->arch.st.preempted)
3574+ return;
3575+
3576+ if (kvm_map_gfn(vcpu, vcpu->arch.st.msr_val >> PAGE_SHIFT, &map,
3577+ &vcpu->arch.st.cache, true))
3578+ return;
3579+
3580+ st = map.hva +
3581+ offset_in_page(vcpu->arch.st.msr_val & KVM_STEAL_VALID_BITS);
3582+
3583+ st->preempted = vcpu->arch.st.preempted = KVM_VCPU_PREEMPTED;
35743584
3575− kvm_write_guest_offset_cached(vcpu->kvm, &vcpu->arch.st.stime,
3576− &vcpu->arch.st.steal.preempted,
3577− offsetof(struct kvm_steal_time, preempted),
3578− sizeof(vcpu->arch.st.steal.preempted));
3585+ kvm_unmap_gfn(vcpu, &map, &vcpu->arch.st.cache, true, true);
35793586 }
35803587
35813588 void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu)
@@ -9325,8 +9332,11 @@ void kvm_arch_vcpu_postcreate(struct kvm_vcpu *vcpu) · 5743 unmodified lines
93259332
93269333 void kvm_arch_vcpu_destroy(struct kvm_vcpu *vcpu)
93279334 {
9335+ struct gfn_to_pfn_cache *cache = &vcpu->arch.st.cache;
93289336 int idx;
93299337
9338+ kvm_release_pfn(cache->pfn, cache->dirty, cache);
9339+
93309340 kvmclock_reset(vcpu);
93319341
93329342 kvm_x86_ops->vcpu_free(vcpu);
@@ -9855,11 +9865,18 @@ out_free: · 522 unmodified lines
98559865
98569866 void kvm_arch_memslots_updated(struct kvm *kvm, u64 gen)
98579867 {
9868+ struct kvm_vcpu *vcpu;
9869+ int i;
9870+
98589871 /*
98599872 * memslots->generation has been incremented.
98609873 * mmio generation may have reached its maximum value.
98619874 */
98629875 kvm_mmu_invalidate_mmio_sptes(kvm, gen);
9876+
9877+ /* Force re-initialization of steal_time cache */
9878+ kvm_for_each_vcpu(i, vcpu, kvm)
9879+ kvm_vcpu_kick(vcpu);
98639880 }
98649881
98659882 int kvm_arch_prepare_memory_region(struct kvm *kvm,
drivers/char/tpm/tpm_tis_core.c+15−19
@@ -978,13 +978,13 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq, · 977 unmodified lines
978978
979979 if (wait_startup(chip, 0) != 0) {
980980 rc = -ENODEV;
981− goto err_start;
981+ goto out_err;
982982 }
983983
984984 /* Take control of the TPM's interrupt hardware and shut it off */
985985 rc = tpm_tis_read32(priv, TPM_INT_ENABLE(priv->locality), &intmask);
986986 if (rc < 0)
987− goto err_start;
987+ goto out_err;
988988
989989 intmask |= TPM_INTF_CMD_READY_INT | TPM_INTF_LOCALITY_CHANGE_INT |
990990 TPM_INTF_DATA_AVAIL_INT | TPM_INTF_STS_VALID_INT;
@@ -993,21 +993,21 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq, · 2 unmodified lines
993993
994994 rc = tpm_chip_start(chip);
995995 if (rc)
996− goto err_start;
997−
996+ goto out_err;
998997 rc = tpm2_probe(chip);
998+ tpm_chip_stop(chip);
999999 if (rc)
1000− goto err_probe;
1000+ goto out_err;
10011001
10021002 rc = tpm_tis_read32(priv, TPM_DID_VID(0), &vendor);
10031003 if (rc < 0)
1004− goto err_probe;
1004+ goto out_err;
10051005
10061006 priv->manufacturer_id = vendor;
10071007
10081008 rc = tpm_tis_read8(priv, TPM_RID(0), &rid);
10091009 if (rc < 0)
1010− goto err_probe;
1010+ goto out_err;
10111011
10121012 dev_info(dev, "%s TPM (device-id 0x%X, rev-id %d)\n",
10131013 (chip->flags & TPM_CHIP_FLAG_TPM2) ? "2.0" : "1.2",
@@ -1016,13 +1016,13 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq, · 2 unmodified lines
10161016 probe = probe_itpm(chip);
10171017 if (probe < 0) {
10181018 rc = -ENODEV;
1019− goto err_probe;
1019+ goto out_err;
10201020 }
10211021
10221022 /* Figure out the capabilities */
10231023 rc = tpm_tis_read32(priv, TPM_INTF_CAPS(priv->locality), &intfcaps);
10241024 if (rc < 0)
1025− goto err_probe;
1025+ goto out_err;
10261026
10271027 dev_dbg(dev, "TPM interface capabilities (0x%x):\n",
10281028 intfcaps);
@@ -1056,10 +1056,9 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq, · 27 unmodified lines
10561056 if (tpm_get_timeouts(chip)) {
10571057 dev_err(dev, "Could not get TPM timeouts and durations\n");
10581058 rc = -ENODEV;
1059− goto err_probe;
1059+ goto out_err;
10601060 }
10611061
1062− chip->flags |= TPM_CHIP_FLAG_IRQ;
10631062 if (irq) {
10641063 tpm_tis_probe_irq_single(chip, intmask, IRQF_SHARED,
10651064 irq);
@@ -1071,18 +1070,15 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq, · 5 unmodified lines
10711070 }
10721071 }
10731072
1074− tpm_chip_stop(chip);
1075−
10761073 rc = tpm_chip_register(chip);
10771074 if (rc)
1078− goto err_start;
1079−
1080− return 0;
1075+ goto out_err;
10811076
1082−err_probe:
1083− tpm_chip_stop(chip);
1077+ if (chip->ops->clk_enable != NULL)
1078+ chip->ops->clk_enable(chip, false);
10841079
1085−err_start:
1080+ return 0;
1081+out_err:
10861082 if ((chip->ops != NULL) && (chip->ops->clk_enable != NULL))
10871083 chip->ops->clk_enable(chip, false);
10881084
drivers/regulator/axp20x-regulator.c+7−4
@@ -413,10 +413,13 @@ static int axp20x_set_ramp_delay(struct regulator_dev *rdev, int ramp) · 412 unmodified lines
413413 int i;
414414
415415 for (i = 0; i < rate_count; i++) {
416− if (ramp <= slew_rates[i])
417− cfg = AXP20X_DCDC2_LDO3_V_RAMP_LDO3_RATE(i);
418− else
416+ if (ramp > slew_rates[i])
419417 break;
418+
419+ if (id == AXP20X_DCDC2)
420+ cfg = AXP20X_DCDC2_LDO3_V_RAMP_DCDC2_RATE(i);
421+ else
422+ cfg = AXP20X_DCDC2_LDO3_V_RAMP_LDO3_RATE(i);
420423 }
421424
422425 if (cfg == 0xff) {
@@ -605,7 +608,7 @@ static const struct regulator_desc axp22x_regulators[] = { · 182 unmodified lines
605608 AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_ELDO1_MASK),
606609 AXP_DESC(AXP22X, ELDO2, "eldo2", "eldoin", 700, 3300, 100,
607610 AXP22X_ELDO2_V_OUT, AXP22X_ELDO2_V_OUT_MASK,
608− AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_ELDO1_MASK),
611+ AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_ELDO2_MASK),
609612 AXP_DESC(AXP22X, ELDO3, "eldo3", "eldoin", 700, 3300, 100,
610613 AXP22X_ELDO3_V_OUT, AXP22X_ELDO3_V_OUT_MASK,
611614 AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_ELDO3_MASK),
drivers/regulator/bd70528-regulator.c+0−1
@@ -101,7 +101,6 @@ static const struct regulator_ops bd70528_ldo_ops = { · 100 unmodified lines
101101 .set_voltage_sel = regulator_set_voltage_sel_regmap,
102102 .get_voltage_sel = regulator_get_voltage_sel_regmap,
103103 .set_voltage_time_sel = regulator_set_voltage_time_sel,
104− .set_ramp_delay = bd70528_set_ramp_delay,
105104 };
106105
107106 static const struct regulator_ops bd70528_led_ops = {
drivers/rtc/rtc-mc146818-lib.c+1−14
@@ -172,20 +172,7 @@ int mc146818_set_time(struct rtc_time *time) · 171 unmodified lines
172172 save_control = CMOS_READ(RTC_CONTROL);
173173 CMOS_WRITE((save_control|RTC_SET), RTC_CONTROL);
174174 save_freq_select = CMOS_READ(RTC_FREQ_SELECT);
175−
176−#ifdef CONFIG_X86
177− if ((boot_cpu_data.x86_vendor == X86_VENDOR_AMD &&
178− boot_cpu_data.x86 == 0x17) ||
179− boot_cpu_data.x86_vendor == X86_VENDOR_HYGON) {
180− CMOS_WRITE((save_freq_select & (~RTC_DIV_RESET2)),
181− RTC_FREQ_SELECT);
182− save_freq_select &= ~RTC_DIV_RESET2;
183− } else
184− CMOS_WRITE((save_freq_select | RTC_DIV_RESET2),
185− RTC_FREQ_SELECT);
186−#else
187− CMOS_WRITE((save_freq_select | RTC_DIV_RESET2), RTC_FREQ_SELECT);
188−#endif
175+ CMOS_WRITE((save_freq_select|RTC_DIV_RESET2), RTC_FREQ_SELECT);
189176
190177 #ifdef CONFIG_MACH_DECSTATION
191178 CMOS_WRITE(real_yrs, RTC_DEC_YEAR);
drivers/rtc/rtc-mt6397.c+25−14
@@ -47,7 +47,7 @@ static irqreturn_t mtk_rtc_irq_handler_thread(int irq, void *data) · 46 unmodified lines
4747 irqen = irqsta & ~RTC_IRQ_EN_AL;
4848 mutex_lock(&rtc->lock);
4949 if (regmap_write(rtc->regmap, rtc->addr_base + RTC_IRQ_EN,
50− irqen) < 0)
50+ irqen) == 0)
5151 mtk_rtc_write_trigger(rtc);
5252 mutex_unlock(&rtc->lock);
5353
@@ -169,12 +169,12 @@ static int mtk_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alm) · 115 unmodified lines
169169 alm->pending = !!(pdn2 & RTC_PDN2_PWRON_ALARM);
170170 mutex_unlock(&rtc->lock);
171171
172− tm->tm_sec = data[RTC_OFFSET_SEC];
173− tm->tm_min = data[RTC_OFFSET_MIN];
174− tm->tm_hour = data[RTC_OFFSET_HOUR];
175− tm->tm_mday = data[RTC_OFFSET_DOM];
176− tm->tm_mon = data[RTC_OFFSET_MTH];
177− tm->tm_year = data[RTC_OFFSET_YEAR];
172+ tm->tm_sec = data[RTC_OFFSET_SEC] & RTC_AL_SEC_MASK;
173+ tm->tm_min = data[RTC_OFFSET_MIN] & RTC_AL_MIN_MASK;
174+ tm->tm_hour = data[RTC_OFFSET_HOUR] & RTC_AL_HOU_MASK;
175+ tm->tm_mday = data[RTC_OFFSET_DOM] & RTC_AL_DOM_MASK;
176+ tm->tm_mon = data[RTC_OFFSET_MTH] & RTC_AL_MTH_MASK;
177+ tm->tm_year = data[RTC_OFFSET_YEAR] & RTC_AL_YEA_MASK;
178178
179179 tm->tm_year += RTC_MIN_YEAR_OFFSET;
180180 tm->tm_mon--;
@@ -195,14 +195,25 @@ static int mtk_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm) · 14 unmodified lines
195195 tm->tm_year -= RTC_MIN_YEAR_OFFSET;
196196 tm->tm_mon++;
197197
198− data[RTC_OFFSET_SEC] = tm->tm_sec;
199− data[RTC_OFFSET_MIN] = tm->tm_min;
200− data[RTC_OFFSET_HOUR] = tm->tm_hour;
201− data[RTC_OFFSET_DOM] = tm->tm_mday;
202− data[RTC_OFFSET_MTH] = tm->tm_mon;
203− data[RTC_OFFSET_YEAR] = tm->tm_year;
204−
205198 mutex_lock(&rtc->lock);
199+ ret = regmap_bulk_read(rtc->regmap, rtc->addr_base + RTC_AL_SEC,
200+ data, RTC_OFFSET_COUNT);
201+ if (ret < 0)
202+ goto exit;
203+
204+ data[RTC_OFFSET_SEC] = ((data[RTC_OFFSET_SEC] & ~(RTC_AL_SEC_MASK)) |
205+ (tm->tm_sec & RTC_AL_SEC_MASK));
206+ data[RTC_OFFSET_MIN] = ((data[RTC_OFFSET_MIN] & ~(RTC_AL_MIN_MASK)) |
207+ (tm->tm_min & RTC_AL_MIN_MASK));
208+ data[RTC_OFFSET_HOUR] = ((data[RTC_OFFSET_HOUR] & ~(RTC_AL_HOU_MASK)) |
209+ (tm->tm_hour & RTC_AL_HOU_MASK));
210+ data[RTC_OFFSET_DOM] = ((data[RTC_OFFSET_DOM] & ~(RTC_AL_DOM_MASK)) |
211+ (tm->tm_mday & RTC_AL_DOM_MASK));
212+ data[RTC_OFFSET_MTH] = ((data[RTC_OFFSET_MTH] & ~(RTC_AL_MTH_MASK)) |
213+ (tm->tm_mon & RTC_AL_MTH_MASK));
214+ data[RTC_OFFSET_YEAR] = ((data[RTC_OFFSET_YEAR] & ~(RTC_AL_YEA_MASK)) |
215+ (tm->tm_year & RTC_AL_YEA_MASK));
216+
206217 if (alm->enabled) {
207218 ret = regmap_bulk_write(rtc->regmap,
208219 rtc->addr_base + RTC_AL_SEC,
drivers/rtc/rtc-sun6i.c+16−0
@@ -379,6 +379,22 @@ static void __init sun50i_h6_rtc_clk_init(struct device_node *node) · 378 unmodified lines
379379 CLK_OF_DECLARE_DRIVER(sun50i_h6_rtc_clk, "allwinner,sun50i-h6-rtc",
380380 sun50i_h6_rtc_clk_init);
381381
382+/*
383+ * The R40 user manual is self-conflicting on whether the prescaler is
384+ * fixed or configurable. The clock diagram shows it as fixed, but there
385+ * is also a configurable divider in the RTC block.
386+ */
387+static const struct sun6i_rtc_clk_data sun8i_r40_rtc_data = {
388+ .rc_osc_rate = 16000000,
389+ .fixed_prescaler = 512,
390+};
391+static void __init sun8i_r40_rtc_clk_init(struct device_node *node)
392+{
393+ sun6i_rtc_clk_init(node, &sun8i_r40_rtc_data);
394+}
395+CLK_OF_DECLARE_DRIVER(sun8i_r40_rtc_clk, "allwinner,sun8i-r40-rtc",
396+ sun8i_r40_rtc_clk_init);
397+
382398 static const struct sun6i_rtc_clk_data sun8i_v3_rtc_data = {
383399 .rc_osc_rate = 32000,
384400 .has_out_clk = 1,
drivers/spi/spi-dw.c+12−3
@@ -172,9 +172,11 @@ static inline u32 rx_max(struct dw_spi *dws) · 171 unmodified lines
172172
173173 static void dw_writer(struct dw_spi *dws)
174174 {
175− u32 max = tx_max(dws);
175+ u32 max;
176176 u16 txw = 0;
177177
178+ spin_lock(&dws->buf_lock);
179+ max = tx_max(dws);
178180 while (max--) {
179181 /* Set the tx word if the transfer's original "tx" is not null */
180182 if (dws->tx_end - dws->len) {
@@ -186,13 +188,16 @@ static void dw_writer(struct dw_spi *dws) · 5 unmodified lines
186188 dw_write_io_reg(dws, DW_SPI_DR, txw);
187189 dws->tx += dws->n_bytes;
188190 }
191+ spin_unlock(&dws->buf_lock);
189192 }
190193
191194 static void dw_reader(struct dw_spi *dws)
192195 {
193− u32 max = rx_max(dws);
196+ u32 max;
194197 u16 rxw;
195198
199+ spin_lock(&dws->buf_lock);
200+ max = rx_max(dws);
196201 while (max--) {
197202 rxw = dw_read_io_reg(dws, DW_SPI_DR);
198203 /* Care rx only if the transfer's original "rx" is not null */
@@ -204,6 +209,7 @@ static void dw_reader(struct dw_spi *dws) · 5 unmodified lines
204209 }
205210 dws->rx += dws->n_bytes;
206211 }
212+ spin_unlock(&dws->buf_lock);
207213 }
208214
209215 static void int_error_stop(struct dw_spi *dws, const char *msg)
@@ -276,18 +282,20 @@ static int dw_spi_transfer_one(struct spi_controller *master, · 66 unmodified lines
276282 {
277283 struct dw_spi *dws = spi_controller_get_devdata(master);
278284 struct chip_data *chip = spi_get_ctldata(spi);
285+ unsigned long flags;
279286 u8 imask = 0;
280287 u16 txlevel = 0;
281288 u32 cr0;
282289 int ret;
283290
284291 dws->dma_mapped = 0;
285−
292+ spin_lock_irqsave(&dws->buf_lock, flags);
286293 dws->tx = (void *)transfer->tx_buf;
287294 dws->tx_end = dws->tx + transfer->len;
288295 dws->rx = transfer->rx_buf;
289296 dws->rx_end = dws->rx + transfer->len;
290297 dws->len = transfer->len;
298+ spin_unlock_irqrestore(&dws->buf_lock, flags);
291299
292300 spi_enable_chip(dws, 0);
293301
@@ -471,6 +479,7 @@ int dw_spi_add_host(struct device *dev, struct dw_spi *dws) · 177 unmodified lines
471479 dws->type = SSI_MOTO_SPI;
472480 dws->dma_inited = 0;
473481 dws->dma_addr = (dma_addr_t)(dws->paddr + DW_SPI_DR);
482+ spin_lock_init(&dws->buf_lock);
474483
475484 spi_controller_set_devdata(master, dws);
476485
drivers/spi/spi-dw.h+1−0
@@ -119,6 +119,7 @@ struct dw_spi { · 118 unmodified lines
119119 size_t len;
120120 void *tx;
121121 void *tx_end;
122+ spinlock_t buf_lock;
122123 void *rx;
123124 void *rx_end;
124125 int dma_mapped;
drivers/spi/spi-fsl-dspi.c+10−14
@@ -185,6 +185,7 @@ struct fsl_dspi { · 184 unmodified lines
185185 struct spi_transfer *cur_transfer;
186186 struct spi_message *cur_msg;
187187 struct chip_data *cur_chip;
188+ size_t progress;
188189 size_t len;
189190 const void *tx;
190191 void *rx;
@@ -586,21 +587,14 @@ static void dspi_tcfq_write(struct fsl_dspi *dspi) · 395 unmodified lines
586587 dspi->tx_cmd |= SPI_PUSHR_CMD_CTCNT;
587588
588589 if (dspi->devtype_data->xspi_mode && dspi->bits_per_word > 16) {
589− /* Write two TX FIFO entries first, and then the corresponding
590− * CMD FIFO entry.
590+ /* Write the CMD FIFO entry first, and then the two
591+ * corresponding TX FIFO entries.
591592 */
592593 u32 data = dspi_pop_tx(dspi);
593594
594− if (dspi->cur_chip->ctar_val & SPI_CTAR_LSBFE) {
595− /* LSB */
596− tx_fifo_write(dspi, data & 0xFFFF);
597− tx_fifo_write(dspi, data >> 16);
598− } else {
599− /* MSB */
600− tx_fifo_write(dspi, data >> 16);
601− tx_fifo_write(dspi, data & 0xFFFF);
602− }
603595 cmd_fifo_write(dspi);
596+ tx_fifo_write(dspi, data & 0xFFFF);
597+ tx_fifo_write(dspi, data >> 16);
604598 } else {
605599 /* Write one entry to both TX FIFO and CMD FIFO
606600 * simultaneously.
@@ -658,7 +652,7 @@ static int dspi_rxtx(struct fsl_dspi *dspi) · 51 unmodified lines
658652 u32 spi_tcr;
659653
660654 spi_take_timestamp_post(dspi->ctlr, dspi->cur_transfer,
661− dspi->tx - dspi->bytes_per_word, !dspi->irq);
655+ dspi->progress, !dspi->irq);
662656
663657 /* Get transfer counter (in number of SPI transfers). It was
664658 * reset to 0 when transfer(s) were started.
@@ -667,6 +661,7 @@ static int dspi_rxtx(struct fsl_dspi *dspi) · 2 unmodified lines
667661 spi_tcnt = SPI_TCR_GET_TCNT(spi_tcr);
668662 /* Update total number of bytes that were transferred */
669663 msg->actual_length += spi_tcnt * dspi->bytes_per_word;
664+ dspi->progress += spi_tcnt;
670665
671666 trans_mode = dspi->devtype_data->trans_mode;
672667 if (trans_mode == DSPI_EOQ_MODE)
@@ -679,7 +674,7 @@ static int dspi_rxtx(struct fsl_dspi *dspi) · 6 unmodified lines
679674 return 0;
680675
681676 spi_take_timestamp_pre(dspi->ctlr, dspi->cur_transfer,
682− dspi->tx, !dspi->irq);
677+ dspi->progress, !dspi->irq);
683678
684679 if (trans_mode == DSPI_EOQ_MODE)
685680 dspi_eoq_write(dspi);
@@ -768,6 +763,7 @@ static int dspi_transfer_one_message(struct spi_controller *ctlr, · 82 unmodified lines
768763 dspi->rx = transfer->rx_buf;
769764 dspi->rx_end = dspi->rx + transfer->len;
770765 dspi->len = transfer->len;
766+ dspi->progress = 0;
771767 /* Validated transfer specific frame size (defaults applied) */
772768 dspi->bits_per_word = transfer->bits_per_word;
773769 if (transfer->bits_per_word <= 8)
@@ -789,7 +785,7 @@ static int dspi_transfer_one_message(struct spi_controller *ctlr, · 15 unmodified lines
789785 SPI_CTARE_DTCP(1));
790786
791787 spi_take_timestamp_pre(dspi->ctlr, dspi->cur_transfer,
792− dspi->tx, !dspi->irq);
788+ dspi->progress, !dspi->irq);
793789
794790 trans_mode = dspi->devtype_data->trans_mode;
795791 switch (trans_mode) {
drivers/spi/spi-uniphier.c+19−12
@@ -290,25 +290,32 @@ static void uniphier_spi_recv(struct uniphier_spi_priv *priv) · 289 unmodified lines
290290 }
291291 }
292292
293−static void uniphier_spi_fill_tx_fifo(struct uniphier_spi_priv *priv)
293+static void uniphier_spi_set_fifo_threshold(struct uniphier_spi_priv *priv,
294+ unsigned int threshold)
294295 {
295− unsigned int fifo_threshold, fill_bytes;
296296 u32 val;
297297
298− fifo_threshold = DIV_ROUND_UP(priv->rx_bytes,
299− bytes_per_word(priv->bits_per_word));
300− fifo_threshold = min(fifo_threshold, SSI_FIFO_DEPTH);
301−
302− fill_bytes = fifo_threshold - (priv->rx_bytes - priv->tx_bytes);
303−
304− /* set fifo threshold */
305298 val = readl(priv->base + SSI_FC);
306299 val &= ~(SSI_FC_TXFTH_MASK | SSI_FC_RXFTH_MASK);
307− val |= FIELD_PREP(SSI_FC_TXFTH_MASK, fifo_threshold);
308− val |= FIELD_PREP(SSI_FC_RXFTH_MASK, fifo_threshold);
300+ val |= FIELD_PREP(SSI_FC_TXFTH_MASK, SSI_FIFO_DEPTH - threshold);
301+ val |= FIELD_PREP(SSI_FC_RXFTH_MASK, threshold);
309302 writel(val, priv->base + SSI_FC);
303+}
304+
305+static void uniphier_spi_fill_tx_fifo(struct uniphier_spi_priv *priv)
306+{
307+ unsigned int fifo_threshold, fill_words;
308+ unsigned int bpw = bytes_per_word(priv->bits_per_word);
309+
310+ fifo_threshold = DIV_ROUND_UP(priv->rx_bytes, bpw);
311+ fifo_threshold = min(fifo_threshold, SSI_FIFO_DEPTH);
312+
313+ uniphier_spi_set_fifo_threshold(priv, fifo_threshold);
314+
315+ fill_words = fifo_threshold -
316+ DIV_ROUND_UP(priv->rx_bytes - priv->tx_bytes, bpw);
310317
311− while (fill_bytes--)
318+ while (fill_words--)
312319 uniphier_spi_send(priv);
313320 }
314321
drivers/spi/spi.c+8−14
@@ -1499,8 +1499,7 @@ static void spi_pump_messages(struct kthread_work *work) · 1498 unmodified lines
14991499 * advances its @tx buffer pointer monotonically.
15001500 * @ctlr: Pointer to the spi_controller structure of the driver
15011501 * @xfer: Pointer to the transfer being timestamped
1502− * @tx: Pointer to the current word within the xfer->tx_buf that the driver is
1503− * preparing to transmit right now.
1502+ * @progress: How many words (not bytes) have been transferred so far
15041503 * @irqs_off: If true, will disable IRQs and preemption for the duration of the
15051504 * transfer, for less jitter in time measurement. Only compatible
15061505 * with PIO drivers. If true, must follow up with
@@ -1510,21 +1509,19 @@ static void spi_pump_messages(struct kthread_work *work) · 3 unmodified lines
15101509 */
15111510 void spi_take_timestamp_pre(struct spi_controller *ctlr,
15121511 struct spi_transfer *xfer,
1513− const void *tx, bool irqs_off)
1512+ size_t progress, bool irqs_off)
15141513 {
1515− u8 bytes_per_word = DIV_ROUND_UP(xfer->bits_per_word, 8);
1516−
15171514 if (!xfer->ptp_sts)
15181515 return;
15191516
15201517 if (xfer->timestamped_pre)
15211518 return;
15221519
1523− if (tx < (xfer->tx_buf + xfer->ptp_sts_word_pre * bytes_per_word))
1520+ if (progress < xfer->ptp_sts_word_pre)
15241521 return;
15251522
15261523 /* Capture the resolution of the timestamp */
1527− xfer->ptp_sts_word_pre = (tx - xfer->tx_buf) / bytes_per_word;
1524+ xfer->ptp_sts_word_pre = progress;
15281525
15291526 xfer->timestamped_pre = true;
15301527
@@ -1546,23 +1543,20 @@ EXPORT_SYMBOL_GPL(spi_take_timestamp_pre); · 15 unmodified lines
15461543 * timestamped.
15471544 * @ctlr: Pointer to the spi_controller structure of the driver
15481545 * @xfer: Pointer to the transfer being timestamped
1549− * @tx: Pointer to the current word within the xfer->tx_buf that the driver has
1550− * just transmitted.
1546+ * @progress: How many words (not bytes) have been transferred so far
15511547 * @irqs_off: If true, will re-enable IRQs and preemption for the local CPU.
15521548 */
15531549 void spi_take_timestamp_post(struct spi_controller *ctlr,
15541550 struct spi_transfer *xfer,
1555− const void *tx, bool irqs_off)
1551+ size_t progress, bool irqs_off)
15561552 {
1557− u8 bytes_per_word = DIV_ROUND_UP(xfer->bits_per_word, 8);
1558−
15591553 if (!xfer->ptp_sts)
15601554 return;
15611555
15621556 if (xfer->timestamped_post)
15631557 return;
15641558
1565− if (tx < (xfer->tx_buf + xfer->ptp_sts_word_post * bytes_per_word))
1559+ if (progress < xfer->ptp_sts_word_post)
15661560 return;
15671561
15681562 ptp_read_system_postts(xfer->ptp_sts);
@@ -1573,7 +1567,7 @@ void spi_take_timestamp_post(struct spi_controller *ctlr, · 4 unmodified lines
15731567 }
15741568
15751569 /* Capture the resolution of the timestamp */
1576− xfer->ptp_sts_word_post = (tx - xfer->tx_buf) / bytes_per_word;
1570+ xfer->ptp_sts_word_post = progress;
15771571
15781572 xfer->timestamped_post = true;
15791573 }
drivers/watchdog/Kconfig+2−0
@@ -687,6 +687,7 @@ config MAX63XX_WATCHDOG · 686 unmodified lines
687687 config MAX77620_WATCHDOG
688688 tristate "Maxim Max77620 Watchdog Timer"
689689 depends on MFD_MAX77620 || COMPILE_TEST
690+ select WATCHDOG_CORE
690691 help
691692 This is the driver for the Max77620 watchdog timer.
692693 Say 'Y' here to enable the watchdog timer support for
@@ -1444,6 +1445,7 @@ config SMSC37B787_WDT · 751 unmodified lines
14441445 config TQMX86_WDT
14451446 tristate "TQ-Systems TQMX86 Watchdog Timer"
14461447 depends on X86
1448+ select WATCHDOG_CORE
14471449 help
14481450 This is the driver for the hardware watchdog timer in the TQMX86 IO
14491451 controller found on some of their ComExpress Modules.
drivers/watchdog/imx7ulp_wdt.c+1−1
@@ -112,7 +112,7 @@ static int imx7ulp_wdt_restart(struct watchdog_device *wdog, · 111 unmodified lines
112112 {
113113 struct imx7ulp_wdt_device *wdt = watchdog_get_drvdata(wdog);
114114
115− imx7ulp_wdt_enable(wdt->base, true);
115+ imx7ulp_wdt_enable(wdog, true);
116116 imx7ulp_wdt_set_timeout(&wdt->wdd, 1);
117117
118118 /* wait for wdog to fire */
drivers/watchdog/orion_wdt.c+2−2
@@ -602,7 +602,7 @@ static int orion_wdt_probe(struct platform_device *pdev) · 601 unmodified lines
602602 set_bit(WDOG_HW_RUNNING, &dev->wdt.status);
603603
604604 /* Request the IRQ only after the watchdog is disabled */
605− irq = platform_get_irq(pdev, 0);
605+ irq = platform_get_irq_optional(pdev, 0);
606606 if (irq > 0) {
607607 /*
608608 * Not all supported platforms specify an interrupt for the
@@ -617,7 +617,7 @@ static int orion_wdt_probe(struct platform_device *pdev) · 8 unmodified lines
617617 }
618618
619619 /* Optional 2nd interrupt for pretimeout */
620− irq = platform_get_irq(pdev, 1);
620+ irq = platform_get_irq_optional(pdev, 1);
621621 if (irq > 0) {
622622 orion_wdt_info.options |= WDIOF_PRETIMEOUT;
623623 ret = devm_request_irq(&pdev->dev, irq, orion_wdt_pre_irq,
drivers/watchdog/rn5t618_wdt.c+1−0
@@ -188,6 +188,7 @@ static struct platform_driver rn5t618_wdt_driver = { · 187 unmodified lines
188188
189189 module_platform_driver(rn5t618_wdt_driver);
190190
191+MODULE_ALIAS("platform:rn5t618-wdt");
191192 MODULE_AUTHOR("Beniamino Galvani <b.galvani@gmail.com>");
192193 MODULE_DESCRIPTION("RN5T618 watchdog driver");
193194 MODULE_LICENSE("GPL v2");
drivers/watchdog/w83627hf_wdt.c+1−1
@@ -420,7 +420,7 @@ static int wdt_find(int addr) · 419 unmodified lines
420420 cr_wdt_csr = NCT6102D_WDT_CSR;
421421 break;
422422 case NCT6116_ID:
423− ret = nct6102;
423+ ret = nct6116;
424424 cr_wdt_timeout = NCT6102D_WDT_TIMEOUT;
425425 cr_wdt_control = NCT6102D_WDT_CONTROL;
426426 cr_wdt_csr = NCT6102D_WDT_CSR;
include/linux/kvm_host.h+5−0
@@ -720,6 +720,7 @@ void kvm_set_pfn_dirty(kvm_pfn_t pfn); · 719 unmodified lines
720720 void kvm_set_pfn_accessed(kvm_pfn_t pfn);
721721 void kvm_get_pfn(kvm_pfn_t pfn);
722722
723+void kvm_release_pfn(kvm_pfn_t pfn, bool dirty, struct gfn_to_pfn_cache *cache);
723724 int kvm_read_guest_page(struct kvm *kvm, gfn_t gfn, void *data, int offset,
724725 int len);
725726 int kvm_read_guest(struct kvm *kvm, gpa_t gpa, void *data, unsigned long len);
@@ -770,8 +771,12 @@ struct kvm_memory_slot *kvm_vcpu_gfn_to_memslot(struct kvm_vcpu *vcpu, gfn_t gfn · 44 unmodified lines
770771 kvm_pfn_t kvm_vcpu_gfn_to_pfn_atomic(struct kvm_vcpu *vcpu, gfn_t gfn);
771772 kvm_pfn_t kvm_vcpu_gfn_to_pfn(struct kvm_vcpu *vcpu, gfn_t gfn);
772773 int kvm_vcpu_map(struct kvm_vcpu *vcpu, gpa_t gpa, struct kvm_host_map *map);
774+int kvm_map_gfn(struct kvm_vcpu *vcpu, gfn_t gfn, struct kvm_host_map *map,
775+ struct gfn_to_pfn_cache *cache, bool atomic);
773776 struct page *kvm_vcpu_gfn_to_page(struct kvm_vcpu *vcpu, gfn_t gfn);
774777 void kvm_vcpu_unmap(struct kvm_vcpu *vcpu, struct kvm_host_map *map, bool dirty);
778+int kvm_unmap_gfn(struct kvm_vcpu *vcpu, struct kvm_host_map *map,
779+ struct gfn_to_pfn_cache *cache, bool dirty, bool atomic);
775780 unsigned long kvm_vcpu_gfn_to_hva(struct kvm_vcpu *vcpu, gfn_t gfn);
776781 unsigned long kvm_vcpu_gfn_to_hva_prot(struct kvm_vcpu *vcpu, gfn_t gfn, bool *writable);
777782 int kvm_vcpu_read_guest_page(struct kvm_vcpu *vcpu, gfn_t gfn, void *data, int offset,
include/linux/kvm_types.h+8−1
@@ -18,7 +18,7 @@ struct kvm_memslots; · 17 unmodified lines
1818
1919 enum kvm_mr_change;
2020
21−#include <asm/types.h>
21+#include <linux/types.h>
2222
2323 /*
2424 * Address types:
@@ -51,4 +51,11 @@ struct gfn_to_hva_cache { · 26 unmodified lines
5151 struct kvm_memory_slot *memslot;
5252 };
5353
54+struct gfn_to_pfn_cache {
55+ u64 generation;
56+ gfn_t gfn;
57+ kvm_pfn_t pfn;
58+ bool dirty;
59+};
60+
5461 #endif /* __KVM_TYPES_H__ */
include/linux/mfd/mt6397/rtc.h+8−0
@@ -46,6 +46,14 @@ · 45 unmodified lines
4646
4747 #define RTC_AL_SEC 0x0018
4848
49+#define RTC_AL_SEC_MASK 0x003f
50+#define RTC_AL_MIN_MASK 0x003f
51+#define RTC_AL_HOU_MASK 0x001f
52+#define RTC_AL_DOM_MASK 0x001f
53+#define RTC_AL_DOW_MASK 0x0007
54+#define RTC_AL_MTH_MASK 0x000f
55+#define RTC_AL_YEA_MASK 0x007f
56+
4957 #define RTC_PDN2 0x002e
5058 #define RTC_PDN2_PWRON_ALARM BIT(4)
5159
include/linux/spi/spi.h+2−2
@@ -689,10 +689,10 @@ extern void spi_finalize_current_transfer(struct spi_controller *ctlr); · 688 unmodified lines
689689 /* Helper calls for driver to timestamp transfer */
690690 void spi_take_timestamp_pre(struct spi_controller *ctlr,
691691 struct spi_transfer *xfer,
692− const void *tx, bool irqs_off);
692+ size_t progress, bool irqs_off);
693693 void spi_take_timestamp_post(struct spi_controller *ctlr,
694694 struct spi_transfer *xfer,
695− const void *tx, bool irqs_off);
695+ size_t progress, bool irqs_off);
696696
697697 /* the spi driver core manages memory for the spi_controller classdev */
698698 extern struct spi_controller *__spi_alloc_controller(struct device *host,
include/trace/events/preemptirq.h+4−4
@@ -18,13 +18,13 @@ DECLARE_EVENT_CLASS(preemptirq_template, · 17 unmodified lines
1818 TP_ARGS(ip, parent_ip),
1919
2020 TP_STRUCT__entry(
21− __field(u32, caller_offs)
22− __field(u32, parent_offs)
21+ __field(s32, caller_offs)
22+ __field(s32, parent_offs)
2323 ),
2424
2525 TP_fast_assign(
26− __entry->caller_offs = (u32)(ip - (unsigned long)_stext);
27− __entry->parent_offs = (u32)(parent_ip - (unsigned long)_stext);
26+ __entry->caller_offs = (s32)(ip - (unsigned long)_stext);
27+ __entry->parent_offs = (s32)(parent_ip - (unsigned long)_stext);
2828 ),
2929
3030 TP_printk("caller=%pS parent=%pS",
kernel/trace/fgraph.c+14−0
@@ -96,6 +96,20 @@ ftrace_push_return_trace(unsigned long ret, unsigned long func, · 95 unmodified lines
9696 return 0;
9797 }
9898
99+/*
100+ * Not all archs define MCOUNT_INSN_SIZE which is used to look for direct
101+ * functions. But those archs currently don't support direct functions
102+ * anyway, and ftrace_find_rec_direct() is just a stub for them.
103+ * Define MCOUNT_INSN_SIZE to keep those archs compiling.
104+ */
105+#ifndef MCOUNT_INSN_SIZE
106+/* Make sure this only works without direct calls */
107+# ifdef CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS
108+# error MCOUNT_INSN_SIZE not defined with direct calls enabled
109+# endif
110+# define MCOUNT_INSN_SIZE 0
111+#endif
112+
99113 int function_graph_enter(unsigned long ret, unsigned long func,
100114 unsigned long frame_pointer, unsigned long *retp)
101115 {
kernel/trace/ftrace.c+3−3
@@ -526,8 +526,7 @@ static int function_stat_show(struct seq_file *m, void *v) · 525 unmodified lines
526526 }
527527
528528 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
529− avg = rec->time;
530− do_div(avg, rec->counter);
529+ avg = div64_ul(rec->time, rec->counter);
531530 if (tracing_thresh && (avg < tracing_thresh))
532531 goto out;
533532 #endif
@@ -553,7 +552,8 @@ static int function_stat_show(struct seq_file *m, void *v) · 19 unmodified lines
553552 * Divide only 1000 for ns^2 -> us^2 conversion.
554553 * trace_print_graph_duration will divide 1000 again.
555554 */
556− do_div(stddev, rec->counter * (rec->counter - 1) * 1000);
555+ stddev = div64_ul(stddev,
556+ rec->counter * (rec->counter - 1) * 1000);
557557 }
558558
559559 trace_seq_init(&s);
kernel/trace/trace_events_inject.c+1−1
@@ -195,7 +195,7 @@ static int parse_entry(char *str, struct trace_event_call *call, void **pentry) · 194 unmodified lines
195195 unsigned long irq_flags;
196196 void *entry = NULL;
197197 int entry_size;
198− u64 val;
198+ u64 val = 0;
199199 int len;
200200
201201 entry = trace_alloc_entry(call, &entry_size);
kernel/trace/trace_sched_wakeup.c+3−1
@@ -630,7 +630,7 @@ static void start_wakeup_tracer(struct trace_array *tr) · 629 unmodified lines
630630 if (ret) {
631631 pr_info("wakeup trace: Couldn't activate tracepoint"
632632 " probe to kernel_sched_migrate_task\n");
633− return;
633+ goto fail_deprobe_sched_switch;
634634 }
635635
636636 wakeup_reset(tr);
@@ -648,6 +648,8 @@ static void start_wakeup_tracer(struct trace_array *tr) · 11 unmodified lines
648648 printk(KERN_ERR "failed to start wakeup tracer\n");
649649
650650 return;
651+fail_deprobe_sched_switch:
652+ unregister_trace_sched_switch(probe_wakeup_sched_switch, NULL);
651653 fail_deprobe_wake_new:
652654 unregister_trace_sched_wakeup_new(probe_wakeup, NULL);
653655 fail_deprobe:
kernel/trace/trace_seq.c+1−1
@@ -381,7 +381,7 @@ int trace_seq_hex_dump(struct trace_seq *s, const char *prefix_str, · 380 unmodified lines
381381 int prefix_type, int rowsize, int groupsize,
382382 const void *buf, size_t len, bool ascii)
383383 {
384− unsigned int save_len = s->seq.len;
384+ unsigned int save_len = s->seq.len;
385385
386386 if (s->full)
387387 return 0;
kernel/trace/trace_stack.c+5−0
@@ -283,6 +283,11 @@ static void check_stack(unsigned long ip, unsigned long *stack) · 282 unmodified lines
283283 local_irq_restore(flags);
284284 }
285285
286+/* Some archs may not define MCOUNT_INSN_SIZE */
287+#ifndef MCOUNT_INSN_SIZE
288+# define MCOUNT_INSN_SIZE 0
289+#endif
290+
286291 static void
287292 stack_trace_call(unsigned long ip, unsigned long parent_ip,
288293 struct ftrace_ops *op, struct pt_regs *pt_regs)
mm/mmap.c+0−6
@@ -90,12 +90,6 @@ static void unmap_region(struct mm_struct *mm, · 89 unmodified lines
9090 * MAP_PRIVATE r: (no) no r: (yes) yes r: (no) yes r: (no) yes
9191 * w: (no) no w: (no) no w: (copy) copy w: (no) no
9292 * x: (no) no x: (no) yes x: (no) yes x: (yes) yes
93− *
94− * On arm64, PROT_EXEC has the following behaviour for both MAP_SHARED and
95− * MAP_PRIVATE:
96− * r: (no) no
97− * w: (no) no
98− * x: (yes) yes
9993 */
10094 pgprot_t protection_map[16] __ro_after_init = {
10195 __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111,
virt/kvm/kvm_main.c+96−17
@@ -1817,26 +1817,72 @@ struct page *gfn_to_page(struct kvm *kvm, gfn_t gfn) · 1816 unmodified lines
18171817 }
18181818 EXPORT_SYMBOL_GPL(gfn_to_page);
18191819
1820−static int __kvm_map_gfn(struct kvm_memory_slot *slot, gfn_t gfn,
1821− struct kvm_host_map *map)
1820+void kvm_release_pfn(kvm_pfn_t pfn, bool dirty, struct gfn_to_pfn_cache *cache)
1821+{
1822+ if (pfn == 0)
1823+ return;
1824+
1825+ if (cache)
1826+ cache->pfn = cache->gfn = 0;
1827+
1828+ if (dirty)
1829+ kvm_release_pfn_dirty(pfn);
1830+ else
1831+ kvm_release_pfn_clean(pfn);
1832+}
1833+
1834+static void kvm_cache_gfn_to_pfn(struct kvm_memory_slot *slot, gfn_t gfn,
1835+ struct gfn_to_pfn_cache *cache, u64 gen)
1836+{
1837+ kvm_release_pfn(cache->pfn, cache->dirty, cache);
1838+
1839+ cache->pfn = gfn_to_pfn_memslot(slot, gfn);
1840+ cache->gfn = gfn;
1841+ cache->dirty = false;
1842+ cache->generation = gen;
1843+}
1844+
1845+static int __kvm_map_gfn(struct kvm_memslots *slots, gfn_t gfn,
1846+ struct kvm_host_map *map,
1847+ struct gfn_to_pfn_cache *cache,
1848+ bool atomic)
18221849 {
18231850 kvm_pfn_t pfn;
18241851 void *hva = NULL;
18251852 struct page *page = KVM_UNMAPPED_PAGE;
1853+ struct kvm_memory_slot *slot = __gfn_to_memslot(slots, gfn);
1854+ u64 gen = slots->generation;
18261855
18271856 if (!map)
18281857 return -EINVAL;
18291858
1830− pfn = gfn_to_pfn_memslot(slot, gfn);
1859+ if (cache) {
1860+ if (!cache->pfn || cache->gfn != gfn ||
1861+ cache->generation != gen) {
1862+ if (atomic)
1863+ return -EAGAIN;
1864+ kvm_cache_gfn_to_pfn(slot, gfn, cache, gen);
1865+ }
1866+ pfn = cache->pfn;
1867+ } else {
1868+ if (atomic)
1869+ return -EAGAIN;
1870+ pfn = gfn_to_pfn_memslot(slot, gfn);
1871+ }
18311872 if (is_error_noslot_pfn(pfn))
18321873 return -EINVAL;
18331874
18341875 if (pfn_valid(pfn)) {
18351876 page = pfn_to_page(pfn);
1836− hva = kmap(page);
1877+ if (atomic)
1878+ hva = kmap_atomic(page);
1879+ else
1880+ hva = kmap(page);
18371881 #ifdef CONFIG_HAS_IOMEM
1838− } else {
1882+ } else if (!atomic) {
18391883 hva = memremap(pfn_to_hpa(pfn), PAGE_SIZE, MEMREMAP_WB);
1884+ } else {
1885+ return -EINVAL;
18401886 #endif
18411887 }
18421888
@@ -1851,14 +1897,25 @@ static int __kvm_map_gfn(struct kvm_memory_slot *slot, gfn_t gfn, · 8 unmodified lines
18511897 return 0;
18521898 }
18531899
1900+int kvm_map_gfn(struct kvm_vcpu *vcpu, gfn_t gfn, struct kvm_host_map *map,
1901+ struct gfn_to_pfn_cache *cache, bool atomic)
1902+{
1903+ return __kvm_map_gfn(kvm_memslots(vcpu->kvm), gfn, map,
1904+ cache, atomic);
1905+}
1906+EXPORT_SYMBOL_GPL(kvm_map_gfn);
1907+
18541908 int kvm_vcpu_map(struct kvm_vcpu *vcpu, gfn_t gfn, struct kvm_host_map *map)
18551909 {
1856− return __kvm_map_gfn(kvm_vcpu_gfn_to_memslot(vcpu, gfn), gfn, map);
1910+ return __kvm_map_gfn(kvm_vcpu_memslots(vcpu), gfn, map,
1911+ NULL, false);
18571912 }
18581913 EXPORT_SYMBOL_GPL(kvm_vcpu_map);
18591914
1860−void kvm_vcpu_unmap(struct kvm_vcpu *vcpu, struct kvm_host_map *map,
1861− bool dirty)
1915+static void __kvm_unmap_gfn(struct kvm_memory_slot *memslot,
1916+ struct kvm_host_map *map,
1917+ struct gfn_to_pfn_cache *cache,
1918+ bool dirty, bool atomic)
18621919 {
18631920 if (!map)
18641921 return;
@@ -1866,23 +1923,45 @@ void kvm_vcpu_unmap(struct kvm_vcpu *vcpu, struct kvm_host_map *map, · 1 unmodified line
18661923 if (!map->hva)
18671924 return;
18681925
1869− if (map->page != KVM_UNMAPPED_PAGE)
1870− kunmap(map->page);
1926+ if (map->page != KVM_UNMAPPED_PAGE) {
1927+ if (atomic)
1928+ kunmap_atomic(map->hva);
1929+ else
1930+ kunmap(map->page);
1931+ }
18711932 #ifdef CONFIG_HAS_IOMEM
1872− else
1933+ else if (!atomic)
18731934 memunmap(map->hva);
1935+ else
1936+ WARN_ONCE(1, "Unexpected unmapping in atomic context");
18741937 #endif
18751938
1876− if (dirty) {
1877− kvm_vcpu_mark_page_dirty(vcpu, map->gfn);
1878− kvm_release_pfn_dirty(map->pfn);
1879− } else {
1880− kvm_release_pfn_clean(map->pfn);
1881− }
1939+ if (dirty)
1940+ mark_page_dirty_in_slot(memslot, map->gfn);
1941+
1942+ if (cache)
1943+ cache->dirty |= dirty;
1944+ else
1945+ kvm_release_pfn(map->pfn, dirty, NULL);
18821946
18831947 map->hva = NULL;
18841948 map->page = NULL;
18851949 }
1950+
1951+int kvm_unmap_gfn(struct kvm_vcpu *vcpu, struct kvm_host_map *map,
1952+ struct gfn_to_pfn_cache *cache, bool dirty, bool atomic)
1953+{
1954+ __kvm_unmap_gfn(gfn_to_memslot(vcpu->kvm, map->gfn), map,
1955+ cache, dirty, atomic);
1956+ return 0;
1957+}
1958+EXPORT_SYMBOL_GPL(kvm_unmap_gfn);
1959+
1960+void kvm_vcpu_unmap(struct kvm_vcpu *vcpu, struct kvm_host_map *map, bool dirty)
1961+{
1962+ __kvm_unmap_gfn(kvm_vcpu_gfn_to_memslot(vcpu, map->gfn), map, NULL,
1963+ dirty, false);
1964+}
18861965 EXPORT_SYMBOL_GPL(kvm_vcpu_unmap);
18871966
18881967 struct page *kvm_vcpu_gfn_to_page(struct kvm_vcpu *vcpu, gfn_t gfn)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t