Annotation of /trunk/kernel-alx/patches-4.4/0124-4.4.25-all-fixes.patch
Parent Directory | Revision Log
Revision 2860 -
(hide annotations)
(download)
Mon Mar 27 13:49:06 2017 UTC (7 years, 6 months ago) by niro
File size: 39769 byte(s)
Mon Mar 27 13:49:06 2017 UTC (7 years, 6 months ago) by niro
File size: 39769 byte(s)
linux-4.4.25
1 | niro | 2860 | diff --git a/Makefile b/Makefile |
2 | index cdbc185c3539..578a82554923 100644 | ||
3 | --- a/Makefile | ||
4 | +++ b/Makefile | ||
5 | @@ -1,6 +1,6 @@ | ||
6 | VERSION = 4 | ||
7 | PATCHLEVEL = 4 | ||
8 | -SUBLEVEL = 24 | ||
9 | +SUBLEVEL = 25 | ||
10 | EXTRAVERSION = | ||
11 | NAME = Blurry Fish Butt | ||
12 | |||
13 | diff --git a/arch/arm/boot/dts/armada-390.dtsi b/arch/arm/boot/dts/armada-390.dtsi | ||
14 | index 094e39c66039..6cd18d8aaac7 100644 | ||
15 | --- a/arch/arm/boot/dts/armada-390.dtsi | ||
16 | +++ b/arch/arm/boot/dts/armada-390.dtsi | ||
17 | @@ -47,6 +47,8 @@ | ||
18 | #include "armada-39x.dtsi" | ||
19 | |||
20 | / { | ||
21 | + compatible = "marvell,armada390"; | ||
22 | + | ||
23 | soc { | ||
24 | internal-regs { | ||
25 | pinctrl@18000 { | ||
26 | @@ -54,4 +56,5 @@ | ||
27 | reg = <0x18000 0x20>; | ||
28 | }; | ||
29 | }; | ||
30 | + }; | ||
31 | }; | ||
32 | diff --git a/arch/arm/boot/dts/qcom-apq8064.dtsi b/arch/arm/boot/dts/qcom-apq8064.dtsi | ||
33 | index a4c1762b53ea..e00d50ef678f 100644 | ||
34 | --- a/arch/arm/boot/dts/qcom-apq8064.dtsi | ||
35 | +++ b/arch/arm/boot/dts/qcom-apq8064.dtsi | ||
36 | @@ -5,6 +5,7 @@ | ||
37 | #include <dt-bindings/reset/qcom,gcc-msm8960.h> | ||
38 | #include <dt-bindings/clock/qcom,mmcc-msm8960.h> | ||
39 | #include <dt-bindings/soc/qcom,gsbi.h> | ||
40 | +#include <dt-bindings/interrupt-controller/irq.h> | ||
41 | #include <dt-bindings/interrupt-controller/arm-gic.h> | ||
42 | / { | ||
43 | model = "Qualcomm APQ8064"; | ||
44 | @@ -354,22 +355,50 @@ | ||
45 | |||
46 | compatible = "qcom,pm8921-gpio"; | ||
47 | reg = <0x150>; | ||
48 | - interrupts = <192 1>, <193 1>, <194 1>, | ||
49 | - <195 1>, <196 1>, <197 1>, | ||
50 | - <198 1>, <199 1>, <200 1>, | ||
51 | - <201 1>, <202 1>, <203 1>, | ||
52 | - <204 1>, <205 1>, <206 1>, | ||
53 | - <207 1>, <208 1>, <209 1>, | ||
54 | - <210 1>, <211 1>, <212 1>, | ||
55 | - <213 1>, <214 1>, <215 1>, | ||
56 | - <216 1>, <217 1>, <218 1>, | ||
57 | - <219 1>, <220 1>, <221 1>, | ||
58 | - <222 1>, <223 1>, <224 1>, | ||
59 | - <225 1>, <226 1>, <227 1>, | ||
60 | - <228 1>, <229 1>, <230 1>, | ||
61 | - <231 1>, <232 1>, <233 1>, | ||
62 | - <234 1>, <235 1>; | ||
63 | - | ||
64 | + interrupts = <192 IRQ_TYPE_NONE>, | ||
65 | + <193 IRQ_TYPE_NONE>, | ||
66 | + <194 IRQ_TYPE_NONE>, | ||
67 | + <195 IRQ_TYPE_NONE>, | ||
68 | + <196 IRQ_TYPE_NONE>, | ||
69 | + <197 IRQ_TYPE_NONE>, | ||
70 | + <198 IRQ_TYPE_NONE>, | ||
71 | + <199 IRQ_TYPE_NONE>, | ||
72 | + <200 IRQ_TYPE_NONE>, | ||
73 | + <201 IRQ_TYPE_NONE>, | ||
74 | + <202 IRQ_TYPE_NONE>, | ||
75 | + <203 IRQ_TYPE_NONE>, | ||
76 | + <204 IRQ_TYPE_NONE>, | ||
77 | + <205 IRQ_TYPE_NONE>, | ||
78 | + <206 IRQ_TYPE_NONE>, | ||
79 | + <207 IRQ_TYPE_NONE>, | ||
80 | + <208 IRQ_TYPE_NONE>, | ||
81 | + <209 IRQ_TYPE_NONE>, | ||
82 | + <210 IRQ_TYPE_NONE>, | ||
83 | + <211 IRQ_TYPE_NONE>, | ||
84 | + <212 IRQ_TYPE_NONE>, | ||
85 | + <213 IRQ_TYPE_NONE>, | ||
86 | + <214 IRQ_TYPE_NONE>, | ||
87 | + <215 IRQ_TYPE_NONE>, | ||
88 | + <216 IRQ_TYPE_NONE>, | ||
89 | + <217 IRQ_TYPE_NONE>, | ||
90 | + <218 IRQ_TYPE_NONE>, | ||
91 | + <219 IRQ_TYPE_NONE>, | ||
92 | + <220 IRQ_TYPE_NONE>, | ||
93 | + <221 IRQ_TYPE_NONE>, | ||
94 | + <222 IRQ_TYPE_NONE>, | ||
95 | + <223 IRQ_TYPE_NONE>, | ||
96 | + <224 IRQ_TYPE_NONE>, | ||
97 | + <225 IRQ_TYPE_NONE>, | ||
98 | + <226 IRQ_TYPE_NONE>, | ||
99 | + <227 IRQ_TYPE_NONE>, | ||
100 | + <228 IRQ_TYPE_NONE>, | ||
101 | + <229 IRQ_TYPE_NONE>, | ||
102 | + <230 IRQ_TYPE_NONE>, | ||
103 | + <231 IRQ_TYPE_NONE>, | ||
104 | + <232 IRQ_TYPE_NONE>, | ||
105 | + <233 IRQ_TYPE_NONE>, | ||
106 | + <234 IRQ_TYPE_NONE>, | ||
107 | + <235 IRQ_TYPE_NONE>; | ||
108 | gpio-controller; | ||
109 | #gpio-cells = <2>; | ||
110 | |||
111 | @@ -381,9 +410,18 @@ | ||
112 | gpio-controller; | ||
113 | #gpio-cells = <2>; | ||
114 | interrupts = | ||
115 | - <128 1>, <129 1>, <130 1>, <131 1>, | ||
116 | - <132 1>, <133 1>, <134 1>, <135 1>, | ||
117 | - <136 1>, <137 1>, <138 1>, <139 1>; | ||
118 | + <128 IRQ_TYPE_NONE>, | ||
119 | + <129 IRQ_TYPE_NONE>, | ||
120 | + <130 IRQ_TYPE_NONE>, | ||
121 | + <131 IRQ_TYPE_NONE>, | ||
122 | + <132 IRQ_TYPE_NONE>, | ||
123 | + <133 IRQ_TYPE_NONE>, | ||
124 | + <134 IRQ_TYPE_NONE>, | ||
125 | + <135 IRQ_TYPE_NONE>, | ||
126 | + <136 IRQ_TYPE_NONE>, | ||
127 | + <137 IRQ_TYPE_NONE>, | ||
128 | + <138 IRQ_TYPE_NONE>, | ||
129 | + <139 IRQ_TYPE_NONE>; | ||
130 | }; | ||
131 | |||
132 | rtc@11d { | ||
133 | diff --git a/arch/mips/kvm/emulate.c b/arch/mips/kvm/emulate.c | ||
134 | index d6476d11212e..3251b206e55a 100644 | ||
135 | --- a/arch/mips/kvm/emulate.c | ||
136 | +++ b/arch/mips/kvm/emulate.c | ||
137 | @@ -807,6 +807,47 @@ enum emulation_result kvm_mips_emul_tlbr(struct kvm_vcpu *vcpu) | ||
138 | return EMULATE_FAIL; | ||
139 | } | ||
140 | |||
141 | +/** | ||
142 | + * kvm_mips_invalidate_guest_tlb() - Indicates a change in guest MMU map. | ||
143 | + * @vcpu: VCPU with changed mappings. | ||
144 | + * @tlb: TLB entry being removed. | ||
145 | + * | ||
146 | + * This is called to indicate a single change in guest MMU mappings, so that we | ||
147 | + * can arrange TLB flushes on this and other CPUs. | ||
148 | + */ | ||
149 | +static void kvm_mips_invalidate_guest_tlb(struct kvm_vcpu *vcpu, | ||
150 | + struct kvm_mips_tlb *tlb) | ||
151 | +{ | ||
152 | + int cpu, i; | ||
153 | + bool user; | ||
154 | + | ||
155 | + /* No need to flush for entries which are already invalid */ | ||
156 | + if (!((tlb->tlb_lo[0] | tlb->tlb_lo[1]) & ENTRYLO_V)) | ||
157 | + return; | ||
158 | + /* User address space doesn't need flushing for KSeg2/3 changes */ | ||
159 | + user = tlb->tlb_hi < KVM_GUEST_KSEG0; | ||
160 | + | ||
161 | + preempt_disable(); | ||
162 | + | ||
163 | + /* | ||
164 | + * Probe the shadow host TLB for the entry being overwritten, if one | ||
165 | + * matches, invalidate it | ||
166 | + */ | ||
167 | + kvm_mips_host_tlb_inv(vcpu, tlb->tlb_hi); | ||
168 | + | ||
169 | + /* Invalidate the whole ASID on other CPUs */ | ||
170 | + cpu = smp_processor_id(); | ||
171 | + for_each_possible_cpu(i) { | ||
172 | + if (i == cpu) | ||
173 | + continue; | ||
174 | + if (user) | ||
175 | + vcpu->arch.guest_user_asid[i] = 0; | ||
176 | + vcpu->arch.guest_kernel_asid[i] = 0; | ||
177 | + } | ||
178 | + | ||
179 | + preempt_enable(); | ||
180 | +} | ||
181 | + | ||
182 | /* Write Guest TLB Entry @ Index */ | ||
183 | enum emulation_result kvm_mips_emul_tlbwi(struct kvm_vcpu *vcpu) | ||
184 | { | ||
185 | @@ -826,11 +867,8 @@ enum emulation_result kvm_mips_emul_tlbwi(struct kvm_vcpu *vcpu) | ||
186 | } | ||
187 | |||
188 | tlb = &vcpu->arch.guest_tlb[index]; | ||
189 | - /* | ||
190 | - * Probe the shadow host TLB for the entry being overwritten, if one | ||
191 | - * matches, invalidate it | ||
192 | - */ | ||
193 | - kvm_mips_host_tlb_inv(vcpu, tlb->tlb_hi); | ||
194 | + | ||
195 | + kvm_mips_invalidate_guest_tlb(vcpu, tlb); | ||
196 | |||
197 | tlb->tlb_mask = kvm_read_c0_guest_pagemask(cop0); | ||
198 | tlb->tlb_hi = kvm_read_c0_guest_entryhi(cop0); | ||
199 | @@ -859,11 +897,7 @@ enum emulation_result kvm_mips_emul_tlbwr(struct kvm_vcpu *vcpu) | ||
200 | |||
201 | tlb = &vcpu->arch.guest_tlb[index]; | ||
202 | |||
203 | - /* | ||
204 | - * Probe the shadow host TLB for the entry being overwritten, if one | ||
205 | - * matches, invalidate it | ||
206 | - */ | ||
207 | - kvm_mips_host_tlb_inv(vcpu, tlb->tlb_hi); | ||
208 | + kvm_mips_invalidate_guest_tlb(vcpu, tlb); | ||
209 | |||
210 | tlb->tlb_mask = kvm_read_c0_guest_pagemask(cop0); | ||
211 | tlb->tlb_hi = kvm_read_c0_guest_entryhi(cop0); | ||
212 | @@ -982,6 +1016,7 @@ enum emulation_result kvm_mips_emulate_CP0(uint32_t inst, uint32_t *opc, | ||
213 | int32_t rt, rd, copz, sel, co_bit, op; | ||
214 | uint32_t pc = vcpu->arch.pc; | ||
215 | unsigned long curr_pc; | ||
216 | + int cpu, i; | ||
217 | |||
218 | /* | ||
219 | * Update PC and hold onto current PC in case there is | ||
220 | @@ -1089,8 +1124,16 @@ enum emulation_result kvm_mips_emulate_CP0(uint32_t inst, uint32_t *opc, | ||
221 | vcpu->arch.gprs[rt] | ||
222 | & ASID_MASK); | ||
223 | |||
224 | + preempt_disable(); | ||
225 | /* Blow away the shadow host TLBs */ | ||
226 | kvm_mips_flush_host_tlb(1); | ||
227 | + cpu = smp_processor_id(); | ||
228 | + for_each_possible_cpu(i) | ||
229 | + if (i != cpu) { | ||
230 | + vcpu->arch.guest_user_asid[i] = 0; | ||
231 | + vcpu->arch.guest_kernel_asid[i] = 0; | ||
232 | + } | ||
233 | + preempt_enable(); | ||
234 | } | ||
235 | kvm_write_c0_guest_entryhi(cop0, | ||
236 | vcpu->arch.gprs[rt]); | ||
237 | diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h | ||
238 | index 070fa8552051..627d129d7fcb 100644 | ||
239 | --- a/arch/powerpc/include/asm/reg.h | ||
240 | +++ b/arch/powerpc/include/asm/reg.h | ||
241 | @@ -708,6 +708,7 @@ | ||
242 | #define MMCR0_FCHV 0x00000001UL /* freeze conditions in hypervisor mode */ | ||
243 | #define SPRN_MMCR1 798 | ||
244 | #define SPRN_MMCR2 785 | ||
245 | +#define SPRN_UMMCR2 769 | ||
246 | #define SPRN_MMCRA 0x312 | ||
247 | #define MMCRA_SDSYNC 0x80000000UL /* SDAR synced with SIAR */ | ||
248 | #define MMCRA_SDAR_DCACHE_MISS 0x40000000UL | ||
249 | diff --git a/arch/powerpc/kvm/book3s_emulate.c b/arch/powerpc/kvm/book3s_emulate.c | ||
250 | index 2afdb9c0937d..729f8faa95c5 100644 | ||
251 | --- a/arch/powerpc/kvm/book3s_emulate.c | ||
252 | +++ b/arch/powerpc/kvm/book3s_emulate.c | ||
253 | @@ -498,6 +498,7 @@ int kvmppc_core_emulate_mtspr_pr(struct kvm_vcpu *vcpu, int sprn, ulong spr_val) | ||
254 | case SPRN_MMCR0: | ||
255 | case SPRN_MMCR1: | ||
256 | case SPRN_MMCR2: | ||
257 | + case SPRN_UMMCR2: | ||
258 | #endif | ||
259 | break; | ||
260 | unprivileged: | ||
261 | @@ -640,6 +641,7 @@ int kvmppc_core_emulate_mfspr_pr(struct kvm_vcpu *vcpu, int sprn, ulong *spr_val | ||
262 | case SPRN_MMCR0: | ||
263 | case SPRN_MMCR1: | ||
264 | case SPRN_MMCR2: | ||
265 | + case SPRN_UMMCR2: | ||
266 | case SPRN_TIR: | ||
267 | #endif | ||
268 | *spr_val = 0; | ||
269 | diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c | ||
270 | index fd5875179e5c..6d63cd67b09b 100644 | ||
271 | --- a/arch/powerpc/kvm/booke.c | ||
272 | +++ b/arch/powerpc/kvm/booke.c | ||
273 | @@ -2033,7 +2033,7 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu, | ||
274 | if (type == KVMPPC_DEBUG_NONE) | ||
275 | continue; | ||
276 | |||
277 | - if (type & !(KVMPPC_DEBUG_WATCH_READ | | ||
278 | + if (type & ~(KVMPPC_DEBUG_WATCH_READ | | ||
279 | KVMPPC_DEBUG_WATCH_WRITE | | ||
280 | KVMPPC_DEBUG_BREAKPOINT)) | ||
281 | return -EINVAL; | ||
282 | diff --git a/arch/x86/kernel/apic/vector.c b/arch/x86/kernel/apic/vector.c | ||
283 | index df6b4eeac0bd..0988e204f1e3 100644 | ||
284 | --- a/arch/x86/kernel/apic/vector.c | ||
285 | +++ b/arch/x86/kernel/apic/vector.c | ||
286 | @@ -659,11 +659,28 @@ void irq_complete_move(struct irq_cfg *cfg) | ||
287 | */ | ||
288 | void irq_force_complete_move(struct irq_desc *desc) | ||
289 | { | ||
290 | - struct irq_data *irqdata = irq_desc_get_irq_data(desc); | ||
291 | - struct apic_chip_data *data = apic_chip_data(irqdata); | ||
292 | - struct irq_cfg *cfg = data ? &data->cfg : NULL; | ||
293 | + struct irq_data *irqdata; | ||
294 | + struct apic_chip_data *data; | ||
295 | + struct irq_cfg *cfg; | ||
296 | unsigned int cpu; | ||
297 | |||
298 | + /* | ||
299 | + * The function is called for all descriptors regardless of which | ||
300 | + * irqdomain they belong to. For example if an IRQ is provided by | ||
301 | + * an irq_chip as part of a GPIO driver, the chip data for that | ||
302 | + * descriptor is specific to the irq_chip in question. | ||
303 | + * | ||
304 | + * Check first that the chip_data is what we expect | ||
305 | + * (apic_chip_data) before touching it any further. | ||
306 | + */ | ||
307 | + irqdata = irq_domain_get_irq_data(x86_vector_domain, | ||
308 | + irq_desc_get_irq(desc)); | ||
309 | + if (!irqdata) | ||
310 | + return; | ||
311 | + | ||
312 | + data = apic_chip_data(irqdata); | ||
313 | + cfg = data ? &data->cfg : NULL; | ||
314 | + | ||
315 | if (!cfg) | ||
316 | return; | ||
317 | |||
318 | diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c | ||
319 | index 569c1e4f96fe..38b3ead7222d 100644 | ||
320 | --- a/arch/x86/kernel/e820.c | ||
321 | +++ b/arch/x86/kernel/e820.c | ||
322 | @@ -347,7 +347,7 @@ int __init sanitize_e820_map(struct e820entry *biosmap, int max_nr_map, | ||
323 | * continue building up new bios map based on this | ||
324 | * information | ||
325 | */ | ||
326 | - if (current_type != last_type || current_type == E820_PRAM) { | ||
327 | + if (current_type != last_type) { | ||
328 | if (last_type != 0) { | ||
329 | new_bios[new_bios_entry].size = | ||
330 | change_point[chgidx]->addr - last_addr; | ||
331 | @@ -753,7 +753,7 @@ u64 __init early_reserve_e820(u64 size, u64 align) | ||
332 | /* | ||
333 | * Find the highest page frame number we have available | ||
334 | */ | ||
335 | -static unsigned long __init e820_end_pfn(unsigned long limit_pfn) | ||
336 | +static unsigned long __init e820_end_pfn(unsigned long limit_pfn, unsigned type) | ||
337 | { | ||
338 | int i; | ||
339 | unsigned long last_pfn = 0; | ||
340 | @@ -764,11 +764,7 @@ static unsigned long __init e820_end_pfn(unsigned long limit_pfn) | ||
341 | unsigned long start_pfn; | ||
342 | unsigned long end_pfn; | ||
343 | |||
344 | - /* | ||
345 | - * Persistent memory is accounted as ram for purposes of | ||
346 | - * establishing max_pfn and mem_map. | ||
347 | - */ | ||
348 | - if (ei->type != E820_RAM && ei->type != E820_PRAM) | ||
349 | + if (ei->type != type) | ||
350 | continue; | ||
351 | |||
352 | start_pfn = ei->addr >> PAGE_SHIFT; | ||
353 | @@ -793,12 +789,12 @@ static unsigned long __init e820_end_pfn(unsigned long limit_pfn) | ||
354 | } | ||
355 | unsigned long __init e820_end_of_ram_pfn(void) | ||
356 | { | ||
357 | - return e820_end_pfn(MAX_ARCH_PFN); | ||
358 | + return e820_end_pfn(MAX_ARCH_PFN, E820_RAM); | ||
359 | } | ||
360 | |||
361 | unsigned long __init e820_end_of_low_ram_pfn(void) | ||
362 | { | ||
363 | - return e820_end_pfn(1UL << (32-PAGE_SHIFT)); | ||
364 | + return e820_end_pfn(1UL << (32 - PAGE_SHIFT), E820_RAM); | ||
365 | } | ||
366 | |||
367 | static void early_panic(char *msg) | ||
368 | diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c | ||
369 | index 558f50edebca..479a409ddac8 100644 | ||
370 | --- a/arch/x86/kernel/ptrace.c | ||
371 | +++ b/arch/x86/kernel/ptrace.c | ||
372 | @@ -188,8 +188,8 @@ unsigned long kernel_stack_pointer(struct pt_regs *regs) | ||
373 | return sp; | ||
374 | |||
375 | prev_esp = (u32 *)(context); | ||
376 | - if (prev_esp) | ||
377 | - return (unsigned long)prev_esp; | ||
378 | + if (*prev_esp) | ||
379 | + return (unsigned long)*prev_esp; | ||
380 | |||
381 | return (unsigned long)regs; | ||
382 | } | ||
383 | diff --git a/drivers/char/tpm/tpm-dev.c b/drivers/char/tpm/tpm-dev.c | ||
384 | index de0337ebd658..4f3137d9a35e 100644 | ||
385 | --- a/drivers/char/tpm/tpm-dev.c | ||
386 | +++ b/drivers/char/tpm/tpm-dev.c | ||
387 | @@ -139,7 +139,7 @@ static ssize_t tpm_write(struct file *file, const char __user *buf, | ||
388 | |||
389 | /* atomic tpm command send and result receive */ | ||
390 | out_size = tpm_transmit(priv->chip, priv->data_buffer, | ||
391 | - sizeof(priv->data_buffer)); | ||
392 | + sizeof(priv->data_buffer), 0); | ||
393 | if (out_size < 0) { | ||
394 | mutex_unlock(&priv->buffer_mutex); | ||
395 | return out_size; | ||
396 | diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c | ||
397 | index c50637db3a8a..17abe52e6365 100644 | ||
398 | --- a/drivers/char/tpm/tpm-interface.c | ||
399 | +++ b/drivers/char/tpm/tpm-interface.c | ||
400 | @@ -328,8 +328,8 @@ EXPORT_SYMBOL_GPL(tpm_calc_ordinal_duration); | ||
401 | /* | ||
402 | * Internal kernel interface to transmit TPM commands | ||
403 | */ | ||
404 | -ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf, | ||
405 | - size_t bufsiz) | ||
406 | +ssize_t tpm_transmit(struct tpm_chip *chip, const u8 *buf, size_t bufsiz, | ||
407 | + unsigned int flags) | ||
408 | { | ||
409 | ssize_t rc; | ||
410 | u32 count, ordinal; | ||
411 | @@ -348,7 +348,8 @@ ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf, | ||
412 | return -E2BIG; | ||
413 | } | ||
414 | |||
415 | - mutex_lock(&chip->tpm_mutex); | ||
416 | + if (!(flags & TPM_TRANSMIT_UNLOCKED)) | ||
417 | + mutex_lock(&chip->tpm_mutex); | ||
418 | |||
419 | rc = chip->ops->send(chip, (u8 *) buf, count); | ||
420 | if (rc < 0) { | ||
421 | @@ -391,20 +392,21 @@ out_recv: | ||
422 | dev_err(chip->pdev, | ||
423 | "tpm_transmit: tpm_recv: error %zd\n", rc); | ||
424 | out: | ||
425 | - mutex_unlock(&chip->tpm_mutex); | ||
426 | + if (!(flags & TPM_TRANSMIT_UNLOCKED)) | ||
427 | + mutex_unlock(&chip->tpm_mutex); | ||
428 | return rc; | ||
429 | } | ||
430 | |||
431 | #define TPM_DIGEST_SIZE 20 | ||
432 | #define TPM_RET_CODE_IDX 6 | ||
433 | |||
434 | -ssize_t tpm_transmit_cmd(struct tpm_chip *chip, void *cmd, | ||
435 | - int len, const char *desc) | ||
436 | +ssize_t tpm_transmit_cmd(struct tpm_chip *chip, const void *cmd, | ||
437 | + int len, unsigned int flags, const char *desc) | ||
438 | { | ||
439 | - struct tpm_output_header *header; | ||
440 | + const struct tpm_output_header *header; | ||
441 | int err; | ||
442 | |||
443 | - len = tpm_transmit(chip, (u8 *) cmd, len); | ||
444 | + len = tpm_transmit(chip, (const u8 *)cmd, len, flags); | ||
445 | if (len < 0) | ||
446 | return len; | ||
447 | else if (len < TPM_HEADER_SIZE) | ||
448 | @@ -452,7 +454,8 @@ ssize_t tpm_getcap(struct device *dev, __be32 subcap_id, cap_t *cap, | ||
449 | tpm_cmd.params.getcap_in.subcap_size = cpu_to_be32(4); | ||
450 | tpm_cmd.params.getcap_in.subcap = subcap_id; | ||
451 | } | ||
452 | - rc = tpm_transmit_cmd(chip, &tpm_cmd, TPM_INTERNAL_RESULT_SIZE, desc); | ||
453 | + rc = tpm_transmit_cmd(chip, &tpm_cmd, TPM_INTERNAL_RESULT_SIZE, 0, | ||
454 | + desc); | ||
455 | if (!rc) | ||
456 | *cap = tpm_cmd.params.getcap_out.cap; | ||
457 | return rc; | ||
458 | @@ -468,7 +471,7 @@ void tpm_gen_interrupt(struct tpm_chip *chip) | ||
459 | tpm_cmd.params.getcap_in.subcap_size = cpu_to_be32(4); | ||
460 | tpm_cmd.params.getcap_in.subcap = TPM_CAP_PROP_TIS_TIMEOUT; | ||
461 | |||
462 | - rc = tpm_transmit_cmd(chip, &tpm_cmd, TPM_INTERNAL_RESULT_SIZE, | ||
463 | + rc = tpm_transmit_cmd(chip, &tpm_cmd, TPM_INTERNAL_RESULT_SIZE, 0, | ||
464 | "attempting to determine the timeouts"); | ||
465 | } | ||
466 | EXPORT_SYMBOL_GPL(tpm_gen_interrupt); | ||
467 | @@ -489,7 +492,7 @@ static int tpm_startup(struct tpm_chip *chip, __be16 startup_type) | ||
468 | start_cmd.header.in = tpm_startup_header; | ||
469 | |||
470 | start_cmd.params.startup_in.startup_type = startup_type; | ||
471 | - return tpm_transmit_cmd(chip, &start_cmd, TPM_INTERNAL_RESULT_SIZE, | ||
472 | + return tpm_transmit_cmd(chip, &start_cmd, TPM_INTERNAL_RESULT_SIZE, 0, | ||
473 | "attempting to start the TPM"); | ||
474 | } | ||
475 | |||
476 | @@ -505,7 +508,8 @@ int tpm_get_timeouts(struct tpm_chip *chip) | ||
477 | tpm_cmd.params.getcap_in.cap = TPM_CAP_PROP; | ||
478 | tpm_cmd.params.getcap_in.subcap_size = cpu_to_be32(4); | ||
479 | tpm_cmd.params.getcap_in.subcap = TPM_CAP_PROP_TIS_TIMEOUT; | ||
480 | - rc = tpm_transmit_cmd(chip, &tpm_cmd, TPM_INTERNAL_RESULT_SIZE, NULL); | ||
481 | + rc = tpm_transmit_cmd(chip, &tpm_cmd, TPM_INTERNAL_RESULT_SIZE, 0, | ||
482 | + NULL); | ||
483 | |||
484 | if (rc == TPM_ERR_INVALID_POSTINIT) { | ||
485 | /* The TPM is not started, we are the first to talk to it. | ||
486 | @@ -519,7 +523,7 @@ int tpm_get_timeouts(struct tpm_chip *chip) | ||
487 | tpm_cmd.params.getcap_in.subcap_size = cpu_to_be32(4); | ||
488 | tpm_cmd.params.getcap_in.subcap = TPM_CAP_PROP_TIS_TIMEOUT; | ||
489 | rc = tpm_transmit_cmd(chip, &tpm_cmd, TPM_INTERNAL_RESULT_SIZE, | ||
490 | - NULL); | ||
491 | + 0, NULL); | ||
492 | } | ||
493 | if (rc) { | ||
494 | dev_err(chip->pdev, | ||
495 | @@ -580,7 +584,7 @@ duration: | ||
496 | tpm_cmd.params.getcap_in.subcap_size = cpu_to_be32(4); | ||
497 | tpm_cmd.params.getcap_in.subcap = TPM_CAP_PROP_TIS_DURATION; | ||
498 | |||
499 | - rc = tpm_transmit_cmd(chip, &tpm_cmd, TPM_INTERNAL_RESULT_SIZE, | ||
500 | + rc = tpm_transmit_cmd(chip, &tpm_cmd, TPM_INTERNAL_RESULT_SIZE, 0, | ||
501 | "attempting to determine the durations"); | ||
502 | if (rc) | ||
503 | return rc; | ||
504 | @@ -636,7 +640,7 @@ static int tpm_continue_selftest(struct tpm_chip *chip) | ||
505 | struct tpm_cmd_t cmd; | ||
506 | |||
507 | cmd.header.in = continue_selftest_header; | ||
508 | - rc = tpm_transmit_cmd(chip, &cmd, CONTINUE_SELFTEST_RESULT_SIZE, | ||
509 | + rc = tpm_transmit_cmd(chip, &cmd, CONTINUE_SELFTEST_RESULT_SIZE, 0, | ||
510 | "continue selftest"); | ||
511 | return rc; | ||
512 | } | ||
513 | @@ -656,7 +660,7 @@ int tpm_pcr_read_dev(struct tpm_chip *chip, int pcr_idx, u8 *res_buf) | ||
514 | |||
515 | cmd.header.in = pcrread_header; | ||
516 | cmd.params.pcrread_in.pcr_idx = cpu_to_be32(pcr_idx); | ||
517 | - rc = tpm_transmit_cmd(chip, &cmd, READ_PCR_RESULT_SIZE, | ||
518 | + rc = tpm_transmit_cmd(chip, &cmd, READ_PCR_RESULT_SIZE, 0, | ||
519 | "attempting to read a pcr value"); | ||
520 | |||
521 | if (rc == 0) | ||
522 | @@ -754,7 +758,7 @@ int tpm_pcr_extend(u32 chip_num, int pcr_idx, const u8 *hash) | ||
523 | cmd.header.in = pcrextend_header; | ||
524 | cmd.params.pcrextend_in.pcr_idx = cpu_to_be32(pcr_idx); | ||
525 | memcpy(cmd.params.pcrextend_in.hash, hash, TPM_DIGEST_SIZE); | ||
526 | - rc = tpm_transmit_cmd(chip, &cmd, EXTEND_PCR_RESULT_SIZE, | ||
527 | + rc = tpm_transmit_cmd(chip, &cmd, EXTEND_PCR_RESULT_SIZE, 0, | ||
528 | "attempting extend a PCR value"); | ||
529 | |||
530 | tpm_chip_put(chip); | ||
531 | @@ -793,7 +797,7 @@ int tpm_do_selftest(struct tpm_chip *chip) | ||
532 | /* Attempt to read a PCR value */ | ||
533 | cmd.header.in = pcrread_header; | ||
534 | cmd.params.pcrread_in.pcr_idx = cpu_to_be32(0); | ||
535 | - rc = tpm_transmit(chip, (u8 *) &cmd, READ_PCR_RESULT_SIZE); | ||
536 | + rc = tpm_transmit(chip, (u8 *) &cmd, READ_PCR_RESULT_SIZE, 0); | ||
537 | /* Some buggy TPMs will not respond to tpm_tis_ready() for | ||
538 | * around 300ms while the self test is ongoing, keep trying | ||
539 | * until the self test duration expires. */ | ||
540 | @@ -834,7 +838,7 @@ int tpm_send(u32 chip_num, void *cmd, size_t buflen) | ||
541 | if (chip == NULL) | ||
542 | return -ENODEV; | ||
543 | |||
544 | - rc = tpm_transmit_cmd(chip, cmd, buflen, "attempting tpm_cmd"); | ||
545 | + rc = tpm_transmit_cmd(chip, cmd, buflen, 0, "attempting tpm_cmd"); | ||
546 | |||
547 | tpm_chip_put(chip); | ||
548 | return rc; | ||
549 | @@ -936,14 +940,15 @@ int tpm_pm_suspend(struct device *dev) | ||
550 | cmd.params.pcrextend_in.pcr_idx = cpu_to_be32(tpm_suspend_pcr); | ||
551 | memcpy(cmd.params.pcrextend_in.hash, dummy_hash, | ||
552 | TPM_DIGEST_SIZE); | ||
553 | - rc = tpm_transmit_cmd(chip, &cmd, EXTEND_PCR_RESULT_SIZE, | ||
554 | + rc = tpm_transmit_cmd(chip, &cmd, EXTEND_PCR_RESULT_SIZE, 0, | ||
555 | "extending dummy pcr before suspend"); | ||
556 | } | ||
557 | |||
558 | /* now do the actual savestate */ | ||
559 | for (try = 0; try < TPM_RETRY; try++) { | ||
560 | cmd.header.in = savestate_header; | ||
561 | - rc = tpm_transmit_cmd(chip, &cmd, SAVESTATE_RESULT_SIZE, NULL); | ||
562 | + rc = tpm_transmit_cmd(chip, &cmd, SAVESTATE_RESULT_SIZE, 0, | ||
563 | + NULL); | ||
564 | |||
565 | /* | ||
566 | * If the TPM indicates that it is too busy to respond to | ||
567 | @@ -1027,8 +1032,8 @@ int tpm_get_random(u32 chip_num, u8 *out, size_t max) | ||
568 | tpm_cmd.params.getrandom_in.num_bytes = cpu_to_be32(num_bytes); | ||
569 | |||
570 | err = tpm_transmit_cmd(chip, &tpm_cmd, | ||
571 | - TPM_GETRANDOM_RESULT_SIZE + num_bytes, | ||
572 | - "attempting get random"); | ||
573 | + TPM_GETRANDOM_RESULT_SIZE + num_bytes, | ||
574 | + 0, "attempting get random"); | ||
575 | if (err) | ||
576 | break; | ||
577 | |||
578 | diff --git a/drivers/char/tpm/tpm-sysfs.c b/drivers/char/tpm/tpm-sysfs.c | ||
579 | index ee66fd4673f3..f880856aa75e 100644 | ||
580 | --- a/drivers/char/tpm/tpm-sysfs.c | ||
581 | +++ b/drivers/char/tpm/tpm-sysfs.c | ||
582 | @@ -39,7 +39,7 @@ static ssize_t pubek_show(struct device *dev, struct device_attribute *attr, | ||
583 | struct tpm_chip *chip = dev_get_drvdata(dev); | ||
584 | |||
585 | tpm_cmd.header.in = tpm_readpubek_header; | ||
586 | - err = tpm_transmit_cmd(chip, &tpm_cmd, READ_PUBEK_RESULT_SIZE, | ||
587 | + err = tpm_transmit_cmd(chip, &tpm_cmd, READ_PUBEK_RESULT_SIZE, 0, | ||
588 | "attempting to read the PUBEK"); | ||
589 | if (err) | ||
590 | goto out; | ||
591 | diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h | ||
592 | index a4257a32964f..2216861f89f1 100644 | ||
593 | --- a/drivers/char/tpm/tpm.h | ||
594 | +++ b/drivers/char/tpm/tpm.h | ||
595 | @@ -498,11 +498,15 @@ extern struct class *tpm_class; | ||
596 | extern dev_t tpm_devt; | ||
597 | extern const struct file_operations tpm_fops; | ||
598 | |||
599 | +enum tpm_transmit_flags { | ||
600 | + TPM_TRANSMIT_UNLOCKED = BIT(0), | ||
601 | +}; | ||
602 | + | ||
603 | +ssize_t tpm_transmit(struct tpm_chip *chip, const u8 *buf, size_t bufsiz, | ||
604 | + unsigned int flags); | ||
605 | +ssize_t tpm_transmit_cmd(struct tpm_chip *chip, const void *cmd, int len, | ||
606 | + unsigned int flags, const char *desc); | ||
607 | ssize_t tpm_getcap(struct device *, __be32, cap_t *, const char *); | ||
608 | -ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf, | ||
609 | - size_t bufsiz); | ||
610 | -ssize_t tpm_transmit_cmd(struct tpm_chip *chip, void *cmd, int len, | ||
611 | - const char *desc); | ||
612 | extern int tpm_get_timeouts(struct tpm_chip *); | ||
613 | extern void tpm_gen_interrupt(struct tpm_chip *); | ||
614 | extern int tpm_do_selftest(struct tpm_chip *); | ||
615 | diff --git a/drivers/char/tpm/tpm2-cmd.c b/drivers/char/tpm/tpm2-cmd.c | ||
616 | index 678af51fb29e..cb7e4f6b70ba 100644 | ||
617 | --- a/drivers/char/tpm/tpm2-cmd.c | ||
618 | +++ b/drivers/char/tpm/tpm2-cmd.c | ||
619 | @@ -264,7 +264,7 @@ int tpm2_pcr_read(struct tpm_chip *chip, int pcr_idx, u8 *res_buf) | ||
620 | sizeof(cmd.params.pcrread_in.pcr_select)); | ||
621 | cmd.params.pcrread_in.pcr_select[pcr_idx >> 3] = 1 << (pcr_idx & 0x7); | ||
622 | |||
623 | - rc = tpm_transmit_cmd(chip, &cmd, sizeof(cmd), | ||
624 | + rc = tpm_transmit_cmd(chip, &cmd, sizeof(cmd), 0, | ||
625 | "attempting to read a pcr value"); | ||
626 | if (rc == 0) { | ||
627 | buf = cmd.params.pcrread_out.digest; | ||
628 | @@ -312,7 +312,7 @@ int tpm2_pcr_extend(struct tpm_chip *chip, int pcr_idx, const u8 *hash) | ||
629 | cmd.params.pcrextend_in.hash_alg = cpu_to_be16(TPM2_ALG_SHA1); | ||
630 | memcpy(cmd.params.pcrextend_in.digest, hash, TPM_DIGEST_SIZE); | ||
631 | |||
632 | - rc = tpm_transmit_cmd(chip, &cmd, sizeof(cmd), | ||
633 | + rc = tpm_transmit_cmd(chip, &cmd, sizeof(cmd), 0, | ||
634 | "attempting extend a PCR value"); | ||
635 | |||
636 | return rc; | ||
637 | @@ -358,7 +358,7 @@ int tpm2_get_random(struct tpm_chip *chip, u8 *out, size_t max) | ||
638 | cmd.header.in = tpm2_getrandom_header; | ||
639 | cmd.params.getrandom_in.size = cpu_to_be16(num_bytes); | ||
640 | |||
641 | - err = tpm_transmit_cmd(chip, &cmd, sizeof(cmd), | ||
642 | + err = tpm_transmit_cmd(chip, &cmd, sizeof(cmd), 0, | ||
643 | "attempting get random"); | ||
644 | if (err) | ||
645 | break; | ||
646 | @@ -416,12 +416,12 @@ static void tpm2_buf_append_auth(struct tpm_buf *buf, u32 session_handle, | ||
647 | } | ||
648 | |||
649 | /** | ||
650 | - * tpm2_seal_trusted() - seal a trusted key | ||
651 | - * @chip_num: A specific chip number for the request or TPM_ANY_NUM | ||
652 | - * @options: authentication values and other options | ||
653 | + * tpm2_seal_trusted() - seal the payload of a trusted key | ||
654 | + * @chip_num: TPM chip to use | ||
655 | * @payload: the key data in clear and encrypted form | ||
656 | + * @options: authentication values and other options | ||
657 | * | ||
658 | - * Returns < 0 on error and 0 on success. | ||
659 | + * Return: < 0 on error and 0 on success. | ||
660 | */ | ||
661 | int tpm2_seal_trusted(struct tpm_chip *chip, | ||
662 | struct trusted_key_payload *payload, | ||
663 | @@ -472,7 +472,7 @@ int tpm2_seal_trusted(struct tpm_chip *chip, | ||
664 | goto out; | ||
665 | } | ||
666 | |||
667 | - rc = tpm_transmit_cmd(chip, buf.data, PAGE_SIZE, "sealing data"); | ||
668 | + rc = tpm_transmit_cmd(chip, buf.data, PAGE_SIZE, 0, "sealing data"); | ||
669 | if (rc) | ||
670 | goto out; | ||
671 | |||
672 | @@ -494,10 +494,18 @@ out: | ||
673 | return rc; | ||
674 | } | ||
675 | |||
676 | -static int tpm2_load(struct tpm_chip *chip, | ||
677 | - struct trusted_key_payload *payload, | ||
678 | - struct trusted_key_options *options, | ||
679 | - u32 *blob_handle) | ||
680 | +/** | ||
681 | + * tpm2_load_cmd() - execute a TPM2_Load command | ||
682 | + * @chip_num: TPM chip to use | ||
683 | + * @payload: the key data in clear and encrypted form | ||
684 | + * @options: authentication values and other options | ||
685 | + * | ||
686 | + * Return: same as with tpm_transmit_cmd | ||
687 | + */ | ||
688 | +static int tpm2_load_cmd(struct tpm_chip *chip, | ||
689 | + struct trusted_key_payload *payload, | ||
690 | + struct trusted_key_options *options, | ||
691 | + u32 *blob_handle, unsigned int flags) | ||
692 | { | ||
693 | struct tpm_buf buf; | ||
694 | unsigned int private_len; | ||
695 | @@ -532,7 +540,7 @@ static int tpm2_load(struct tpm_chip *chip, | ||
696 | goto out; | ||
697 | } | ||
698 | |||
699 | - rc = tpm_transmit_cmd(chip, buf.data, PAGE_SIZE, "loading blob"); | ||
700 | + rc = tpm_transmit_cmd(chip, buf.data, PAGE_SIZE, flags, "loading blob"); | ||
701 | if (!rc) | ||
702 | *blob_handle = be32_to_cpup( | ||
703 | (__be32 *) &buf.data[TPM_HEADER_SIZE]); | ||
704 | @@ -546,7 +554,16 @@ out: | ||
705 | return rc; | ||
706 | } | ||
707 | |||
708 | -static void tpm2_flush_context(struct tpm_chip *chip, u32 handle) | ||
709 | +/** | ||
710 | + * tpm2_flush_context_cmd() - execute a TPM2_FlushContext command | ||
711 | + * @chip_num: TPM chip to use | ||
712 | + * @payload: the key data in clear and encrypted form | ||
713 | + * @options: authentication values and other options | ||
714 | + * | ||
715 | + * Return: same as with tpm_transmit_cmd | ||
716 | + */ | ||
717 | +static void tpm2_flush_context_cmd(struct tpm_chip *chip, u32 handle, | ||
718 | + unsigned int flags) | ||
719 | { | ||
720 | struct tpm_buf buf; | ||
721 | int rc; | ||
722 | @@ -560,7 +577,8 @@ static void tpm2_flush_context(struct tpm_chip *chip, u32 handle) | ||
723 | |||
724 | tpm_buf_append_u32(&buf, handle); | ||
725 | |||
726 | - rc = tpm_transmit_cmd(chip, buf.data, PAGE_SIZE, "flushing context"); | ||
727 | + rc = tpm_transmit_cmd(chip, buf.data, PAGE_SIZE, flags, | ||
728 | + "flushing context"); | ||
729 | if (rc) | ||
730 | dev_warn(chip->pdev, "0x%08x was not flushed, rc=%d\n", handle, | ||
731 | rc); | ||
732 | @@ -568,10 +586,18 @@ static void tpm2_flush_context(struct tpm_chip *chip, u32 handle) | ||
733 | tpm_buf_destroy(&buf); | ||
734 | } | ||
735 | |||
736 | -static int tpm2_unseal(struct tpm_chip *chip, | ||
737 | - struct trusted_key_payload *payload, | ||
738 | - struct trusted_key_options *options, | ||
739 | - u32 blob_handle) | ||
740 | +/** | ||
741 | + * tpm2_unseal_cmd() - execute a TPM2_Unload command | ||
742 | + * @chip_num: TPM chip to use | ||
743 | + * @payload: the key data in clear and encrypted form | ||
744 | + * @options: authentication values and other options | ||
745 | + * | ||
746 | + * Return: same as with tpm_transmit_cmd | ||
747 | + */ | ||
748 | +static int tpm2_unseal_cmd(struct tpm_chip *chip, | ||
749 | + struct trusted_key_payload *payload, | ||
750 | + struct trusted_key_options *options, | ||
751 | + u32 blob_handle, unsigned int flags) | ||
752 | { | ||
753 | struct tpm_buf buf; | ||
754 | u16 data_len; | ||
755 | @@ -589,7 +615,7 @@ static int tpm2_unseal(struct tpm_chip *chip, | ||
756 | options->blobauth /* hmac */, | ||
757 | TPM_DIGEST_SIZE); | ||
758 | |||
759 | - rc = tpm_transmit_cmd(chip, buf.data, PAGE_SIZE, "unsealing"); | ||
760 | + rc = tpm_transmit_cmd(chip, buf.data, PAGE_SIZE, flags, "unsealing"); | ||
761 | if (rc > 0) | ||
762 | rc = -EPERM; | ||
763 | |||
764 | @@ -608,12 +634,12 @@ static int tpm2_unseal(struct tpm_chip *chip, | ||
765 | } | ||
766 | |||
767 | /** | ||
768 | - * tpm_unseal_trusted() - unseal a trusted key | ||
769 | - * @chip_num: A specific chip number for the request or TPM_ANY_NUM | ||
770 | - * @options: authentication values and other options | ||
771 | + * tpm_unseal_trusted() - unseal the payload of a trusted key | ||
772 | + * @chip_num: TPM chip to use | ||
773 | * @payload: the key data in clear and encrypted form | ||
774 | + * @options: authentication values and other options | ||
775 | * | ||
776 | - * Returns < 0 on error and 0 on success. | ||
777 | + * Return: < 0 on error and 0 on success. | ||
778 | */ | ||
779 | int tpm2_unseal_trusted(struct tpm_chip *chip, | ||
780 | struct trusted_key_payload *payload, | ||
781 | @@ -622,14 +648,17 @@ int tpm2_unseal_trusted(struct tpm_chip *chip, | ||
782 | u32 blob_handle; | ||
783 | int rc; | ||
784 | |||
785 | - rc = tpm2_load(chip, payload, options, &blob_handle); | ||
786 | + mutex_lock(&chip->tpm_mutex); | ||
787 | + rc = tpm2_load_cmd(chip, payload, options, &blob_handle, | ||
788 | + TPM_TRANSMIT_UNLOCKED); | ||
789 | if (rc) | ||
790 | - return rc; | ||
791 | - | ||
792 | - rc = tpm2_unseal(chip, payload, options, blob_handle); | ||
793 | - | ||
794 | - tpm2_flush_context(chip, blob_handle); | ||
795 | + goto out; | ||
796 | |||
797 | + rc = tpm2_unseal_cmd(chip, payload, options, blob_handle, | ||
798 | + TPM_TRANSMIT_UNLOCKED); | ||
799 | + tpm2_flush_context_cmd(chip, blob_handle, TPM_TRANSMIT_UNLOCKED); | ||
800 | +out: | ||
801 | + mutex_unlock(&chip->tpm_mutex); | ||
802 | return rc; | ||
803 | } | ||
804 | |||
805 | @@ -655,7 +684,7 @@ ssize_t tpm2_get_tpm_pt(struct tpm_chip *chip, u32 property_id, u32 *value, | ||
806 | cmd.params.get_tpm_pt_in.property_id = cpu_to_be32(property_id); | ||
807 | cmd.params.get_tpm_pt_in.property_cnt = cpu_to_be32(1); | ||
808 | |||
809 | - rc = tpm_transmit_cmd(chip, &cmd, sizeof(cmd), desc); | ||
810 | + rc = tpm_transmit_cmd(chip, &cmd, sizeof(cmd), 0, desc); | ||
811 | if (!rc) | ||
812 | *value = be32_to_cpu(cmd.params.get_tpm_pt_out.value); | ||
813 | |||
814 | @@ -689,7 +718,7 @@ int tpm2_startup(struct tpm_chip *chip, u16 startup_type) | ||
815 | cmd.header.in = tpm2_startup_header; | ||
816 | |||
817 | cmd.params.startup_in.startup_type = cpu_to_be16(startup_type); | ||
818 | - return tpm_transmit_cmd(chip, &cmd, sizeof(cmd), | ||
819 | + return tpm_transmit_cmd(chip, &cmd, sizeof(cmd), 0, | ||
820 | "attempting to start the TPM"); | ||
821 | } | ||
822 | EXPORT_SYMBOL_GPL(tpm2_startup); | ||
823 | @@ -718,7 +747,7 @@ void tpm2_shutdown(struct tpm_chip *chip, u16 shutdown_type) | ||
824 | cmd.header.in = tpm2_shutdown_header; | ||
825 | cmd.params.startup_in.startup_type = cpu_to_be16(shutdown_type); | ||
826 | |||
827 | - rc = tpm_transmit_cmd(chip, &cmd, sizeof(cmd), "stopping the TPM"); | ||
828 | + rc = tpm_transmit_cmd(chip, &cmd, sizeof(cmd), 0, "stopping the TPM"); | ||
829 | |||
830 | /* In places where shutdown command is sent there's no much we can do | ||
831 | * except print the error code on a system failure. | ||
832 | @@ -784,7 +813,7 @@ static int tpm2_start_selftest(struct tpm_chip *chip, bool full) | ||
833 | cmd.header.in = tpm2_selftest_header; | ||
834 | cmd.params.selftest_in.full_test = full; | ||
835 | |||
836 | - rc = tpm_transmit_cmd(chip, &cmd, TPM2_SELF_TEST_IN_SIZE, | ||
837 | + rc = tpm_transmit_cmd(chip, &cmd, TPM2_SELF_TEST_IN_SIZE, 0, | ||
838 | "continue selftest"); | ||
839 | |||
840 | /* At least some prototype chips seem to give RC_TESTING error | ||
841 | @@ -836,7 +865,7 @@ int tpm2_do_selftest(struct tpm_chip *chip) | ||
842 | cmd.params.pcrread_in.pcr_select[1] = 0x00; | ||
843 | cmd.params.pcrread_in.pcr_select[2] = 0x00; | ||
844 | |||
845 | - rc = tpm_transmit_cmd(chip, (u8 *) &cmd, sizeof(cmd), NULL); | ||
846 | + rc = tpm_transmit_cmd(chip, &cmd, sizeof(cmd), 0, NULL); | ||
847 | if (rc < 0) | ||
848 | break; | ||
849 | |||
850 | @@ -885,7 +914,7 @@ int tpm2_probe(struct tpm_chip *chip) | ||
851 | cmd.params.get_tpm_pt_in.property_id = cpu_to_be32(0x100); | ||
852 | cmd.params.get_tpm_pt_in.property_cnt = cpu_to_be32(1); | ||
853 | |||
854 | - rc = tpm_transmit(chip, (const char *) &cmd, sizeof(cmd)); | ||
855 | + rc = tpm_transmit(chip, (const u8 *)&cmd, sizeof(cmd), 0); | ||
856 | if (rc < 0) | ||
857 | return rc; | ||
858 | else if (rc < TPM_HEADER_SIZE) | ||
859 | diff --git a/drivers/char/tpm/tpm_crb.c b/drivers/char/tpm/tpm_crb.c | ||
860 | index 61e64293b765..2b21398c3adc 100644 | ||
861 | --- a/drivers/char/tpm/tpm_crb.c | ||
862 | +++ b/drivers/char/tpm/tpm_crb.c | ||
863 | @@ -149,6 +149,11 @@ static int crb_send(struct tpm_chip *chip, u8 *buf, size_t len) | ||
864 | struct crb_priv *priv = chip->vendor.priv; | ||
865 | int rc = 0; | ||
866 | |||
867 | + /* Zero the cancel register so that the next command will not get | ||
868 | + * canceled. | ||
869 | + */ | ||
870 | + iowrite32(0, &priv->cca->cancel); | ||
871 | + | ||
872 | if (len > le32_to_cpu(ioread32(&priv->cca->cmd_size))) { | ||
873 | dev_err(&chip->dev, | ||
874 | "invalid command count value %x %zx\n", | ||
875 | @@ -182,8 +187,6 @@ static void crb_cancel(struct tpm_chip *chip) | ||
876 | |||
877 | if ((priv->flags & CRB_FL_ACPI_START) && crb_do_acpi_start(chip)) | ||
878 | dev_err(&chip->dev, "ACPI Start failed\n"); | ||
879 | - | ||
880 | - iowrite32(0, &priv->cca->cancel); | ||
881 | } | ||
882 | |||
883 | static bool crb_req_canceled(struct tpm_chip *chip, u8 status) | ||
884 | diff --git a/drivers/cpuidle/cpuidle-arm.c b/drivers/cpuidle/cpuidle-arm.c | ||
885 | index e342565e8715..1855b9ee807f 100644 | ||
886 | --- a/drivers/cpuidle/cpuidle-arm.c | ||
887 | +++ b/drivers/cpuidle/cpuidle-arm.c | ||
888 | @@ -135,6 +135,7 @@ static int __init arm_idle_init(void) | ||
889 | dev = kzalloc(sizeof(*dev), GFP_KERNEL); | ||
890 | if (!dev) { | ||
891 | pr_err("Failed to allocate cpuidle device\n"); | ||
892 | + ret = -ENOMEM; | ||
893 | goto out_fail; | ||
894 | } | ||
895 | dev->cpu = cpu; | ||
896 | diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig | ||
897 | index 4d92df6ef9fe..7398262a2fab 100644 | ||
898 | --- a/drivers/mfd/Kconfig | ||
899 | +++ b/drivers/mfd/Kconfig | ||
900 | @@ -1460,6 +1460,7 @@ config MFD_WM8350 | ||
901 | config MFD_WM8350_I2C | ||
902 | bool "Wolfson Microelectronics WM8350 with I2C" | ||
903 | select MFD_WM8350 | ||
904 | + select REGMAP_I2C | ||
905 | depends on I2C=y | ||
906 | help | ||
907 | The WM8350 is an integrated audio and power management | ||
908 | diff --git a/drivers/mfd/atmel-hlcdc.c b/drivers/mfd/atmel-hlcdc.c | ||
909 | index 06c205868573..c216c3a55793 100644 | ||
910 | --- a/drivers/mfd/atmel-hlcdc.c | ||
911 | +++ b/drivers/mfd/atmel-hlcdc.c | ||
912 | @@ -50,8 +50,9 @@ static int regmap_atmel_hlcdc_reg_write(void *context, unsigned int reg, | ||
913 | if (reg <= ATMEL_HLCDC_DIS) { | ||
914 | u32 status; | ||
915 | |||
916 | - readl_poll_timeout(hregmap->regs + ATMEL_HLCDC_SR, status, | ||
917 | - !(status & ATMEL_HLCDC_SIP), 1, 100); | ||
918 | + readl_poll_timeout_atomic(hregmap->regs + ATMEL_HLCDC_SR, | ||
919 | + status, !(status & ATMEL_HLCDC_SIP), | ||
920 | + 1, 100); | ||
921 | } | ||
922 | |||
923 | writel(val, hregmap->regs + reg); | ||
924 | diff --git a/drivers/mfd/rtsx_usb.c b/drivers/mfd/rtsx_usb.c | ||
925 | index dbd907d7170e..691dab791f7a 100644 | ||
926 | --- a/drivers/mfd/rtsx_usb.c | ||
927 | +++ b/drivers/mfd/rtsx_usb.c | ||
928 | @@ -46,9 +46,6 @@ static void rtsx_usb_sg_timed_out(unsigned long data) | ||
929 | |||
930 | dev_dbg(&ucr->pusb_intf->dev, "%s: sg transfer timed out", __func__); | ||
931 | usb_sg_cancel(&ucr->current_sg); | ||
932 | - | ||
933 | - /* we know the cancellation is caused by time-out */ | ||
934 | - ucr->current_sg.status = -ETIMEDOUT; | ||
935 | } | ||
936 | |||
937 | static int rtsx_usb_bulk_transfer_sglist(struct rtsx_ucr *ucr, | ||
938 | @@ -67,12 +64,15 @@ static int rtsx_usb_bulk_transfer_sglist(struct rtsx_ucr *ucr, | ||
939 | ucr->sg_timer.expires = jiffies + msecs_to_jiffies(timeout); | ||
940 | add_timer(&ucr->sg_timer); | ||
941 | usb_sg_wait(&ucr->current_sg); | ||
942 | - del_timer_sync(&ucr->sg_timer); | ||
943 | + if (!del_timer_sync(&ucr->sg_timer)) | ||
944 | + ret = -ETIMEDOUT; | ||
945 | + else | ||
946 | + ret = ucr->current_sg.status; | ||
947 | |||
948 | if (act_len) | ||
949 | *act_len = ucr->current_sg.bytes; | ||
950 | |||
951 | - return ucr->current_sg.status; | ||
952 | + return ret; | ||
953 | } | ||
954 | |||
955 | int rtsx_usb_transfer_data(struct rtsx_ucr *ucr, unsigned int pipe, | ||
956 | diff --git a/include/linux/mfd/88pm80x.h b/include/linux/mfd/88pm80x.h | ||
957 | index d409ceb2231e..c118a7ec94d6 100644 | ||
958 | --- a/include/linux/mfd/88pm80x.h | ||
959 | +++ b/include/linux/mfd/88pm80x.h | ||
960 | @@ -350,7 +350,7 @@ static inline int pm80x_dev_suspend(struct device *dev) | ||
961 | int irq = platform_get_irq(pdev, 0); | ||
962 | |||
963 | if (device_may_wakeup(dev)) | ||
964 | - set_bit((1 << irq), &chip->wu_flag); | ||
965 | + set_bit(irq, &chip->wu_flag); | ||
966 | |||
967 | return 0; | ||
968 | } | ||
969 | @@ -362,7 +362,7 @@ static inline int pm80x_dev_resume(struct device *dev) | ||
970 | int irq = platform_get_irq(pdev, 0); | ||
971 | |||
972 | if (device_may_wakeup(dev)) | ||
973 | - clear_bit((1 << irq), &chip->wu_flag); | ||
974 | + clear_bit(irq, &chip->wu_flag); | ||
975 | |||
976 | return 0; | ||
977 | } | ||
978 | diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c | ||
979 | index 4ff237dbc006..445601c580d6 100644 | ||
980 | --- a/kernel/time/timekeeping.c | ||
981 | +++ b/kernel/time/timekeeping.c | ||
982 | @@ -298,17 +298,34 @@ u32 (*arch_gettimeoffset)(void) = default_arch_gettimeoffset; | ||
983 | static inline u32 arch_gettimeoffset(void) { return 0; } | ||
984 | #endif | ||
985 | |||
986 | +static inline s64 timekeeping_delta_to_ns(struct tk_read_base *tkr, | ||
987 | + cycle_t delta) | ||
988 | +{ | ||
989 | + s64 nsec; | ||
990 | + | ||
991 | + nsec = delta * tkr->mult + tkr->xtime_nsec; | ||
992 | + nsec >>= tkr->shift; | ||
993 | + | ||
994 | + /* If arch requires, add in get_arch_timeoffset() */ | ||
995 | + return nsec + arch_gettimeoffset(); | ||
996 | +} | ||
997 | + | ||
998 | static inline s64 timekeeping_get_ns(struct tk_read_base *tkr) | ||
999 | { | ||
1000 | cycle_t delta; | ||
1001 | - s64 nsec; | ||
1002 | |||
1003 | delta = timekeeping_get_delta(tkr); | ||
1004 | + return timekeeping_delta_to_ns(tkr, delta); | ||
1005 | +} | ||
1006 | |||
1007 | - nsec = (delta * tkr->mult + tkr->xtime_nsec) >> tkr->shift; | ||
1008 | +static inline s64 timekeeping_cycles_to_ns(struct tk_read_base *tkr, | ||
1009 | + cycle_t cycles) | ||
1010 | +{ | ||
1011 | + cycle_t delta; | ||
1012 | |||
1013 | - /* If arch requires, add in get_arch_timeoffset() */ | ||
1014 | - return nsec + arch_gettimeoffset(); | ||
1015 | + /* calculate the delta since the last update_wall_time */ | ||
1016 | + delta = clocksource_delta(cycles, tkr->cycle_last, tkr->mask); | ||
1017 | + return timekeeping_delta_to_ns(tkr, delta); | ||
1018 | } | ||
1019 | |||
1020 | /** | ||
1021 | @@ -385,8 +402,11 @@ static __always_inline u64 __ktime_get_fast_ns(struct tk_fast *tkf) | ||
1022 | tkr = tkf->base + (seq & 0x01); | ||
1023 | now = ktime_to_ns(tkr->base); | ||
1024 | |||
1025 | - now += clocksource_delta(tkr->read(tkr->clock), | ||
1026 | - tkr->cycle_last, tkr->mask); | ||
1027 | + now += timekeeping_delta_to_ns(tkr, | ||
1028 | + clocksource_delta( | ||
1029 | + tkr->read(tkr->clock), | ||
1030 | + tkr->cycle_last, | ||
1031 | + tkr->mask)); | ||
1032 | } while (read_seqcount_retry(&tkf->seq, seq)); | ||
1033 | |||
1034 | return now; | ||
1035 | diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c | ||
1036 | index 1d950fbb2aec..2d1fe34781fa 100644 | ||
1037 | --- a/security/integrity/ima/ima_api.c | ||
1038 | +++ b/security/integrity/ima/ima_api.c | ||
1039 | @@ -202,7 +202,7 @@ int ima_collect_measurement(struct integrity_iint_cache *iint, | ||
1040 | } hash; | ||
1041 | |||
1042 | if (xattr_value) | ||
1043 | - *xattr_len = ima_read_xattr(file->f_path.dentry, xattr_value); | ||
1044 | + *xattr_len = ima_read_xattr(file_dentry(file), xattr_value); | ||
1045 | |||
1046 | if (!(iint->flags & IMA_COLLECTED)) { | ||
1047 | u64 i_version = file_inode(file)->i_version; | ||
1048 | diff --git a/security/integrity/ima/ima_appraise.c b/security/integrity/ima/ima_appraise.c | ||
1049 | index 1873b5536f80..ed5a9c110b3a 100644 | ||
1050 | --- a/security/integrity/ima/ima_appraise.c | ||
1051 | +++ b/security/integrity/ima/ima_appraise.c | ||
1052 | @@ -189,7 +189,7 @@ int ima_appraise_measurement(int func, struct integrity_iint_cache *iint, | ||
1053 | { | ||
1054 | static const char op[] = "appraise_data"; | ||
1055 | char *cause = "unknown"; | ||
1056 | - struct dentry *dentry = file->f_path.dentry; | ||
1057 | + struct dentry *dentry = file_dentry(file); | ||
1058 | struct inode *inode = d_backing_inode(dentry); | ||
1059 | enum integrity_status status = INTEGRITY_UNKNOWN; | ||
1060 | int rc = xattr_len, hash_start = 0; | ||
1061 | @@ -289,7 +289,7 @@ out: | ||
1062 | */ | ||
1063 | void ima_update_xattr(struct integrity_iint_cache *iint, struct file *file) | ||
1064 | { | ||
1065 | - struct dentry *dentry = file->f_path.dentry; | ||
1066 | + struct dentry *dentry = file_dentry(file); | ||
1067 | int rc = 0; | ||
1068 | |||
1069 | /* do not collect and update hash for digital signatures */ | ||
1070 | diff --git a/sound/pci/ali5451/ali5451.c b/sound/pci/ali5451/ali5451.c | ||
1071 | index 36470af7eda7..92b819e4f729 100644 | ||
1072 | --- a/sound/pci/ali5451/ali5451.c | ||
1073 | +++ b/sound/pci/ali5451/ali5451.c | ||
1074 | @@ -1408,6 +1408,7 @@ snd_ali_playback_pointer(struct snd_pcm_substream *substream) | ||
1075 | spin_unlock(&codec->reg_lock); | ||
1076 | dev_dbg(codec->card->dev, "playback pointer returned cso=%xh.\n", cso); | ||
1077 | |||
1078 | + cso %= runtime->buffer_size; | ||
1079 | return cso; | ||
1080 | } | ||
1081 | |||
1082 | @@ -1428,6 +1429,7 @@ static snd_pcm_uframes_t snd_ali_pointer(struct snd_pcm_substream *substream) | ||
1083 | cso = inw(ALI_REG(codec, ALI_CSO_ALPHA_FMS + 2)); | ||
1084 | spin_unlock(&codec->reg_lock); | ||
1085 | |||
1086 | + cso %= runtime->buffer_size; | ||
1087 | return cso; | ||
1088 | } | ||
1089 | |||
1090 | diff --git a/sound/usb/line6/driver.c b/sound/usb/line6/driver.c | ||
1091 | index 81b7da8e56d3..183311cb849e 100644 | ||
1092 | --- a/sound/usb/line6/driver.c | ||
1093 | +++ b/sound/usb/line6/driver.c | ||
1094 | @@ -29,7 +29,7 @@ | ||
1095 | /* | ||
1096 | This is Line 6's MIDI manufacturer ID. | ||
1097 | */ | ||
1098 | -const unsigned char line6_midi_id[] = { | ||
1099 | +const unsigned char line6_midi_id[3] = { | ||
1100 | 0x00, 0x01, 0x0c | ||
1101 | }; | ||
1102 | EXPORT_SYMBOL_GPL(line6_midi_id); | ||
1103 | diff --git a/sound/usb/mixer_quirks.c b/sound/usb/mixer_quirks.c | ||
1104 | index f6c3bf79af9a..04991b009132 100644 | ||
1105 | --- a/sound/usb/mixer_quirks.c | ||
1106 | +++ b/sound/usb/mixer_quirks.c | ||
1107 | @@ -1831,6 +1831,7 @@ void snd_usb_mixer_rc_memory_change(struct usb_mixer_interface *mixer, | ||
1108 | } | ||
1109 | |||
1110 | static void snd_dragonfly_quirk_db_scale(struct usb_mixer_interface *mixer, | ||
1111 | + struct usb_mixer_elem_info *cval, | ||
1112 | struct snd_kcontrol *kctl) | ||
1113 | { | ||
1114 | /* Approximation using 10 ranges based on output measurement on hw v1.2. | ||
1115 | @@ -1848,10 +1849,19 @@ static void snd_dragonfly_quirk_db_scale(struct usb_mixer_interface *mixer, | ||
1116 | 41, 50, TLV_DB_MINMAX_ITEM(-441, 0), | ||
1117 | ); | ||
1118 | |||
1119 | - usb_audio_info(mixer->chip, "applying DragonFly dB scale quirk\n"); | ||
1120 | - kctl->tlv.p = scale; | ||
1121 | - kctl->vd[0].access |= SNDRV_CTL_ELEM_ACCESS_TLV_READ; | ||
1122 | - kctl->vd[0].access &= ~SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK; | ||
1123 | + if (cval->min == 0 && cval->max == 50) { | ||
1124 | + usb_audio_info(mixer->chip, "applying DragonFly dB scale quirk (0-50 variant)\n"); | ||
1125 | + kctl->tlv.p = scale; | ||
1126 | + kctl->vd[0].access |= SNDRV_CTL_ELEM_ACCESS_TLV_READ; | ||
1127 | + kctl->vd[0].access &= ~SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK; | ||
1128 | + | ||
1129 | + } else if (cval->min == 0 && cval->max <= 1000) { | ||
1130 | + /* Some other clearly broken DragonFly variant. | ||
1131 | + * At least a 0..53 variant (hw v1.0) exists. | ||
1132 | + */ | ||
1133 | + usb_audio_info(mixer->chip, "ignoring too narrow dB range on a DragonFly device"); | ||
1134 | + kctl->vd[0].access &= ~SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK; | ||
1135 | + } | ||
1136 | } | ||
1137 | |||
1138 | void snd_usb_mixer_fu_apply_quirk(struct usb_mixer_interface *mixer, | ||
1139 | @@ -1860,8 +1870,8 @@ void snd_usb_mixer_fu_apply_quirk(struct usb_mixer_interface *mixer, | ||
1140 | { | ||
1141 | switch (mixer->chip->usb_id) { | ||
1142 | case USB_ID(0x21b4, 0x0081): /* AudioQuest DragonFly */ | ||
1143 | - if (unitid == 7 && cval->min == 0 && cval->max == 50) | ||
1144 | - snd_dragonfly_quirk_db_scale(mixer, kctl); | ||
1145 | + if (unitid == 7 && cval->control == UAC_FU_VOLUME) | ||
1146 | + snd_dragonfly_quirk_db_scale(mixer, cval, kctl); | ||
1147 | break; | ||
1148 | } | ||
1149 | } |