diff options
author | Ingo Molnar <mingo@kernel.org> | 2017-08-31 08:20:06 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2017-08-31 08:20:06 -0400 |
commit | 3e83dfd5d8e374328078f527f1f7d189824896ab (patch) | |
tree | 2f82b2e82f7a4b5c513fed42d4228a8bce938180 | |
parent | 3308376a914b9c3f57a12072c063814403d983a8 (diff) | |
parent | 9e52fc2b50de3a1c08b44f94c610fbe998c0031a (diff) |
Merge branch 'x86/mm' into x86/platform, to pick up TLB flush dependency
Signed-off-by: Ingo Molnar <mingo@kernel.org>
596 files changed, 7066 insertions, 2300 deletions
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index d9c171ce4190..372cc66bba23 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt | |||
@@ -2233,6 +2233,17 @@ | |||
2233 | memory contents and reserves bad memory | 2233 | memory contents and reserves bad memory |
2234 | regions that are detected. | 2234 | regions that are detected. |
2235 | 2235 | ||
2236 | mem_encrypt= [X86-64] AMD Secure Memory Encryption (SME) control | ||
2237 | Valid arguments: on, off | ||
2238 | Default (depends on kernel configuration option): | ||
2239 | on (CONFIG_AMD_MEM_ENCRYPT_ACTIVE_BY_DEFAULT=y) | ||
2240 | off (CONFIG_AMD_MEM_ENCRYPT_ACTIVE_BY_DEFAULT=n) | ||
2241 | mem_encrypt=on: Activate SME | ||
2242 | mem_encrypt=off: Do not activate SME | ||
2243 | |||
2244 | Refer to Documentation/x86/amd-memory-encryption.txt | ||
2245 | for details on when memory encryption can be activated. | ||
2246 | |||
2236 | mem_sleep_default= [SUSPEND] Default system suspend mode: | 2247 | mem_sleep_default= [SUSPEND] Default system suspend mode: |
2237 | s2idle - Suspend-To-Idle | 2248 | s2idle - Suspend-To-Idle |
2238 | shallow - Power-On Suspend or equivalent (if supported) | 2249 | shallow - Power-On Suspend or equivalent (if supported) |
@@ -2696,6 +2707,8 @@ | |||
2696 | nopat [X86] Disable PAT (page attribute table extension of | 2707 | nopat [X86] Disable PAT (page attribute table extension of |
2697 | pagetables) support. | 2708 | pagetables) support. |
2698 | 2709 | ||
2710 | nopcid [X86-64] Disable the PCID cpu feature. | ||
2711 | |||
2699 | norandmaps Don't use address space randomization. Equivalent to | 2712 | norandmaps Don't use address space randomization. Equivalent to |
2700 | echo 0 > /proc/sys/kernel/randomize_va_space | 2713 | echo 0 > /proc/sys/kernel/randomize_va_space |
2701 | 2714 | ||
diff --git a/Documentation/fb/efifb.txt b/Documentation/fb/efifb.txt index a59916c29b33..1a85c1bdaf38 100644 --- a/Documentation/fb/efifb.txt +++ b/Documentation/fb/efifb.txt | |||
@@ -27,5 +27,11 @@ You have to add the following kernel parameters in your elilo.conf: | |||
27 | Macbook Pro 17", iMac 20" : | 27 | Macbook Pro 17", iMac 20" : |
28 | video=efifb:i20 | 28 | video=efifb:i20 |
29 | 29 | ||
30 | Accepted options: | ||
31 | |||
32 | nowc Don't map the framebuffer write combined. This can be used | ||
33 | to workaround side-effects and slowdowns on other CPU cores | ||
34 | when large amounts of console data are written. | ||
35 | |||
30 | -- | 36 | -- |
31 | Edgar Hucek <gimli@dark-green.com> | 37 | Edgar Hucek <gimli@dark-green.com> |
diff --git a/Documentation/networking/switchdev.txt b/Documentation/networking/switchdev.txt index 3e7b946dea27..5e40e1f68873 100644 --- a/Documentation/networking/switchdev.txt +++ b/Documentation/networking/switchdev.txt | |||
@@ -228,7 +228,7 @@ Learning on the device port should be enabled, as well as learning_sync: | |||
228 | bridge link set dev DEV learning on self | 228 | bridge link set dev DEV learning on self |
229 | bridge link set dev DEV learning_sync on self | 229 | bridge link set dev DEV learning_sync on self |
230 | 230 | ||
231 | Learning_sync attribute enables syncing of the learned/forgotton FDB entry to | 231 | Learning_sync attribute enables syncing of the learned/forgotten FDB entry to |
232 | the bridge's FDB. It's possible, but not optimal, to enable learning on the | 232 | the bridge's FDB. It's possible, but not optimal, to enable learning on the |
233 | device port and on the bridge port, and disable learning_sync. | 233 | device port and on the bridge port, and disable learning_sync. |
234 | 234 | ||
@@ -245,7 +245,7 @@ the responsibility of the port driver/device to age out these entries. If the | |||
245 | port device supports ageing, when the FDB entry expires, it will notify the | 245 | port device supports ageing, when the FDB entry expires, it will notify the |
246 | driver which in turn will notify the bridge with SWITCHDEV_FDB_DEL. If the | 246 | driver which in turn will notify the bridge with SWITCHDEV_FDB_DEL. If the |
247 | device does not support ageing, the driver can simulate ageing using a | 247 | device does not support ageing, the driver can simulate ageing using a |
248 | garbage collection timer to monitor FBD entries. Expired entries will be | 248 | garbage collection timer to monitor FDB entries. Expired entries will be |
249 | notified to the bridge using SWITCHDEV_FDB_DEL. See rocker driver for | 249 | notified to the bridge using SWITCHDEV_FDB_DEL. See rocker driver for |
250 | example of driver running ageing timer. | 250 | example of driver running ageing timer. |
251 | 251 | ||
diff --git a/Documentation/printk-formats.txt b/Documentation/printk-formats.txt index 65ea5915178b..074670b98bac 100644 --- a/Documentation/printk-formats.txt +++ b/Documentation/printk-formats.txt | |||
@@ -58,20 +58,23 @@ Symbols/Function Pointers | |||
58 | %ps versatile_init | 58 | %ps versatile_init |
59 | %pB prev_fn_of_versatile_init+0x88/0x88 | 59 | %pB prev_fn_of_versatile_init+0x88/0x88 |
60 | 60 | ||
61 | For printing symbols and function pointers. The ``S`` and ``s`` specifiers | 61 | The ``F`` and ``f`` specifiers are for printing function pointers, |
62 | result in the symbol name with (``S``) or without (``s``) offsets. Where | 62 | for example, f->func, &gettimeofday. They have the same result as |
63 | this is used on a kernel without KALLSYMS - the symbol address is | 63 | ``S`` and ``s`` specifiers. But they do an extra conversion on |
64 | printed instead. | 64 | ia64, ppc64 and parisc64 architectures where the function pointers |
65 | are actually function descriptors. | ||
66 | |||
67 | The ``S`` and ``s`` specifiers can be used for printing symbols | ||
68 | from direct addresses, for example, __builtin_return_address(0), | ||
69 | (void *)regs->ip. They result in the symbol name with (``S``) or | ||
70 | without (``s``) offsets. If KALLSYMS are disabled then the symbol | ||
71 | address is printed instead. | ||
65 | 72 | ||
66 | The ``B`` specifier results in the symbol name with offsets and should be | 73 | The ``B`` specifier results in the symbol name with offsets and should be |
67 | used when printing stack backtraces. The specifier takes into | 74 | used when printing stack backtraces. The specifier takes into |
68 | consideration the effect of compiler optimisations which may occur | 75 | consideration the effect of compiler optimisations which may occur |
69 | when tail-call``s are used and marked with the noreturn GCC attribute. | 76 | when tail-call``s are used and marked with the noreturn GCC attribute. |
70 | 77 | ||
71 | On ia64, ppc64 and parisc64 architectures function pointers are | ||
72 | actually function descriptors which must first be resolved. The ``F`` and | ||
73 | ``f`` specifiers perform this resolution and then provide the same | ||
74 | functionality as the ``S`` and ``s`` specifiers. | ||
75 | 78 | ||
76 | Kernel Pointers | 79 | Kernel Pointers |
77 | =============== | 80 | =============== |
diff --git a/Documentation/sysctl/net.txt b/Documentation/sysctl/net.txt index 14db18c970b1..28596e03220b 100644 --- a/Documentation/sysctl/net.txt +++ b/Documentation/sysctl/net.txt | |||
@@ -35,9 +35,34 @@ Table : Subdirectories in /proc/sys/net | |||
35 | bpf_jit_enable | 35 | bpf_jit_enable |
36 | -------------- | 36 | -------------- |
37 | 37 | ||
38 | This enables Berkeley Packet Filter Just in Time compiler. | 38 | This enables the BPF Just in Time (JIT) compiler. BPF is a flexible |
39 | Currently supported on x86_64 architecture, bpf_jit provides a framework | 39 | and efficient infrastructure allowing to execute bytecode at various |
40 | to speed packet filtering, the one used by tcpdump/libpcap for example. | 40 | hook points. It is used in a number of Linux kernel subsystems such |
41 | as networking (e.g. XDP, tc), tracing (e.g. kprobes, uprobes, tracepoints) | ||
42 | and security (e.g. seccomp). LLVM has a BPF back end that can compile | ||
43 | restricted C into a sequence of BPF instructions. After program load | ||
44 | through bpf(2) and passing a verifier in the kernel, a JIT will then | ||
45 | translate these BPF proglets into native CPU instructions. There are | ||
46 | two flavors of JITs, the newer eBPF JIT currently supported on: | ||
47 | - x86_64 | ||
48 | - arm64 | ||
49 | - ppc64 | ||
50 | - sparc64 | ||
51 | - mips64 | ||
52 | - s390x | ||
53 | |||
54 | And the older cBPF JIT supported on the following archs: | ||
55 | - arm | ||
56 | - mips | ||
57 | - ppc | ||
58 | - sparc | ||
59 | |||
60 | eBPF JITs are a superset of cBPF JITs, meaning the kernel will | ||
61 | migrate cBPF instructions into eBPF instructions and then JIT | ||
62 | compile them transparently. Older cBPF JITs can only translate | ||
63 | tcpdump filters, seccomp rules, etc, but not mentioned eBPF | ||
64 | programs loaded through bpf(2). | ||
65 | |||
41 | Values : | 66 | Values : |
42 | 0 - disable the JIT (default value) | 67 | 0 - disable the JIT (default value) |
43 | 1 - enable the JIT | 68 | 1 - enable the JIT |
@@ -46,9 +71,9 @@ Values : | |||
46 | bpf_jit_harden | 71 | bpf_jit_harden |
47 | -------------- | 72 | -------------- |
48 | 73 | ||
49 | This enables hardening for the Berkeley Packet Filter Just in Time compiler. | 74 | This enables hardening for the BPF JIT compiler. Supported are eBPF |
50 | Supported are eBPF JIT backends. Enabling hardening trades off performance, | 75 | JIT backends. Enabling hardening trades off performance, but can |
51 | but can mitigate JIT spraying. | 76 | mitigate JIT spraying. |
52 | Values : | 77 | Values : |
53 | 0 - disable JIT hardening (default value) | 78 | 0 - disable JIT hardening (default value) |
54 | 1 - enable JIT hardening for unprivileged users only | 79 | 1 - enable JIT hardening for unprivileged users only |
@@ -57,11 +82,11 @@ Values : | |||
57 | bpf_jit_kallsyms | 82 | bpf_jit_kallsyms |
58 | ---------------- | 83 | ---------------- |
59 | 84 | ||
60 | When Berkeley Packet Filter Just in Time compiler is enabled, then compiled | 85 | When BPF JIT compiler is enabled, then compiled images are unknown |
61 | images are unknown addresses to the kernel, meaning they neither show up in | 86 | addresses to the kernel, meaning they neither show up in traces nor |
62 | traces nor in /proc/kallsyms. This enables export of these addresses, which | 87 | in /proc/kallsyms. This enables export of these addresses, which can |
63 | can be used for debugging/tracing. If bpf_jit_harden is enabled, this feature | 88 | be used for debugging/tracing. If bpf_jit_harden is enabled, this |
64 | is disabled. | 89 | feature is disabled. |
65 | Values : | 90 | Values : |
66 | 0 - disable JIT kallsyms export (default value) | 91 | 0 - disable JIT kallsyms export (default value) |
67 | 1 - enable JIT kallsyms export for privileged users only | 92 | 1 - enable JIT kallsyms export for privileged users only |
diff --git a/Documentation/x86/amd-memory-encryption.txt b/Documentation/x86/amd-memory-encryption.txt new file mode 100644 index 000000000000..f512ab718541 --- /dev/null +++ b/Documentation/x86/amd-memory-encryption.txt | |||
@@ -0,0 +1,68 @@ | |||
1 | Secure Memory Encryption (SME) is a feature found on AMD processors. | ||
2 | |||
3 | SME provides the ability to mark individual pages of memory as encrypted using | ||
4 | the standard x86 page tables. A page that is marked encrypted will be | ||
5 | automatically decrypted when read from DRAM and encrypted when written to | ||
6 | DRAM. SME can therefore be used to protect the contents of DRAM from physical | ||
7 | attacks on the system. | ||
8 | |||
9 | A page is encrypted when a page table entry has the encryption bit set (see | ||
10 | below on how to determine its position). The encryption bit can also be | ||
11 | specified in the cr3 register, allowing the PGD table to be encrypted. Each | ||
12 | successive level of page tables can also be encrypted by setting the encryption | ||
13 | bit in the page table entry that points to the next table. This allows the full | ||
14 | page table hierarchy to be encrypted. Note, this means that just because the | ||
15 | encryption bit is set in cr3, doesn't imply the full hierarchy is encyrpted. | ||
16 | Each page table entry in the hierarchy needs to have the encryption bit set to | ||
17 | achieve that. So, theoretically, you could have the encryption bit set in cr3 | ||
18 | so that the PGD is encrypted, but not set the encryption bit in the PGD entry | ||
19 | for a PUD which results in the PUD pointed to by that entry to not be | ||
20 | encrypted. | ||
21 | |||
22 | Support for SME can be determined through the CPUID instruction. The CPUID | ||
23 | function 0x8000001f reports information related to SME: | ||
24 | |||
25 | 0x8000001f[eax]: | ||
26 | Bit[0] indicates support for SME | ||
27 | 0x8000001f[ebx]: | ||
28 | Bits[5:0] pagetable bit number used to activate memory | ||
29 | encryption | ||
30 | Bits[11:6] reduction in physical address space, in bits, when | ||
31 | memory encryption is enabled (this only affects | ||
32 | system physical addresses, not guest physical | ||
33 | addresses) | ||
34 | |||
35 | If support for SME is present, MSR 0xc00100010 (MSR_K8_SYSCFG) can be used to | ||
36 | determine if SME is enabled and/or to enable memory encryption: | ||
37 | |||
38 | 0xc0010010: | ||
39 | Bit[23] 0 = memory encryption features are disabled | ||
40 | 1 = memory encryption features are enabled | ||
41 | |||
42 | Linux relies on BIOS to set this bit if BIOS has determined that the reduction | ||
43 | in the physical address space as a result of enabling memory encryption (see | ||
44 | CPUID information above) will not conflict with the address space resource | ||
45 | requirements for the system. If this bit is not set upon Linux startup then | ||
46 | Linux itself will not set it and memory encryption will not be possible. | ||
47 | |||
48 | The state of SME in the Linux kernel can be documented as follows: | ||
49 | - Supported: | ||
50 | The CPU supports SME (determined through CPUID instruction). | ||
51 | |||
52 | - Enabled: | ||
53 | Supported and bit 23 of MSR_K8_SYSCFG is set. | ||
54 | |||
55 | - Active: | ||
56 | Supported, Enabled and the Linux kernel is actively applying | ||
57 | the encryption bit to page table entries (the SME mask in the | ||
58 | kernel is non-zero). | ||
59 | |||
60 | SME can also be enabled and activated in the BIOS. If SME is enabled and | ||
61 | activated in the BIOS, then all memory accesses will be encrypted and it will | ||
62 | not be necessary to activate the Linux memory encryption support. If the BIOS | ||
63 | merely enables SME (sets bit 23 of the MSR_K8_SYSCFG), then Linux can activate | ||
64 | memory encryption by default (CONFIG_AMD_MEM_ENCRYPT_ACTIVE_BY_DEFAULT=y) or | ||
65 | by supplying mem_encrypt=on on the kernel command line. However, if BIOS does | ||
66 | not enable SME, then Linux will not be able to activate memory encryption, even | ||
67 | if configured to do so by default or the mem_encrypt=on command line parameter | ||
68 | is specified. | ||
diff --git a/Documentation/x86/protection-keys.txt b/Documentation/x86/protection-keys.txt index b64304540821..fa46dcb347bc 100644 --- a/Documentation/x86/protection-keys.txt +++ b/Documentation/x86/protection-keys.txt | |||
@@ -34,7 +34,7 @@ with a key. In this example WRPKRU is wrapped by a C function | |||
34 | called pkey_set(). | 34 | called pkey_set(). |
35 | 35 | ||
36 | int real_prot = PROT_READ|PROT_WRITE; | 36 | int real_prot = PROT_READ|PROT_WRITE; |
37 | pkey = pkey_alloc(0, PKEY_DENY_WRITE); | 37 | pkey = pkey_alloc(0, PKEY_DISABLE_WRITE); |
38 | ptr = mmap(NULL, PAGE_SIZE, PROT_NONE, MAP_ANONYMOUS|MAP_PRIVATE, -1, 0); | 38 | ptr = mmap(NULL, PAGE_SIZE, PROT_NONE, MAP_ANONYMOUS|MAP_PRIVATE, -1, 0); |
39 | ret = pkey_mprotect(ptr, PAGE_SIZE, real_prot, pkey); | 39 | ret = pkey_mprotect(ptr, PAGE_SIZE, real_prot, pkey); |
40 | ... application runs here | 40 | ... application runs here |
@@ -42,9 +42,9 @@ called pkey_set(). | |||
42 | Now, if the application needs to update the data at 'ptr', it can | 42 | Now, if the application needs to update the data at 'ptr', it can |
43 | gain access, do the update, then remove its write access: | 43 | gain access, do the update, then remove its write access: |
44 | 44 | ||
45 | pkey_set(pkey, 0); // clear PKEY_DENY_WRITE | 45 | pkey_set(pkey, 0); // clear PKEY_DISABLE_WRITE |
46 | *ptr = foo; // assign something | 46 | *ptr = foo; // assign something |
47 | pkey_set(pkey, PKEY_DENY_WRITE); // set PKEY_DENY_WRITE again | 47 | pkey_set(pkey, PKEY_DISABLE_WRITE); // set PKEY_DISABLE_WRITE again |
48 | 48 | ||
49 | Now when it frees the memory, it will also free the pkey since it | 49 | Now when it frees the memory, it will also free the pkey since it |
50 | is no longer in use: | 50 | is no longer in use: |
diff --git a/Documentation/x86/x86_64/5level-paging.txt b/Documentation/x86/x86_64/5level-paging.txt new file mode 100644 index 000000000000..087251a0d99c --- /dev/null +++ b/Documentation/x86/x86_64/5level-paging.txt | |||
@@ -0,0 +1,64 @@ | |||
1 | == Overview == | ||
2 | |||
3 | Original x86-64 was limited by 4-level paing to 256 TiB of virtual address | ||
4 | space and 64 TiB of physical address space. We are already bumping into | ||
5 | this limit: some vendors offers servers with 64 TiB of memory today. | ||
6 | |||
7 | To overcome the limitation upcoming hardware will introduce support for | ||
8 | 5-level paging. It is a straight-forward extension of the current page | ||
9 | table structure adding one more layer of translation. | ||
10 | |||
11 | It bumps the limits to 128 PiB of virtual address space and 4 PiB of | ||
12 | physical address space. This "ought to be enough for anybody" ©. | ||
13 | |||
14 | QEMU 2.9 and later support 5-level paging. | ||
15 | |||
16 | Virtual memory layout for 5-level paging is described in | ||
17 | Documentation/x86/x86_64/mm.txt | ||
18 | |||
19 | == Enabling 5-level paging == | ||
20 | |||
21 | CONFIG_X86_5LEVEL=y enables the feature. | ||
22 | |||
23 | So far, a kernel compiled with the option enabled will be able to boot | ||
24 | only on machines that supports the feature -- see for 'la57' flag in | ||
25 | /proc/cpuinfo. | ||
26 | |||
27 | The plan is to implement boot-time switching between 4- and 5-level paging | ||
28 | in the future. | ||
29 | |||
30 | == User-space and large virtual address space == | ||
31 | |||
32 | On x86, 5-level paging enables 56-bit userspace virtual address space. | ||
33 | Not all user space is ready to handle wide addresses. It's known that | ||
34 | at least some JIT compilers use higher bits in pointers to encode their | ||
35 | information. It collides with valid pointers with 5-level paging and | ||
36 | leads to crashes. | ||
37 | |||
38 | To mitigate this, we are not going to allocate virtual address space | ||
39 | above 47-bit by default. | ||
40 | |||
41 | But userspace can ask for allocation from full address space by | ||
42 | specifying hint address (with or without MAP_FIXED) above 47-bits. | ||
43 | |||
44 | If hint address set above 47-bit, but MAP_FIXED is not specified, we try | ||
45 | to look for unmapped area by specified address. If it's already | ||
46 | occupied, we look for unmapped area in *full* address space, rather than | ||
47 | from 47-bit window. | ||
48 | |||
49 | A high hint address would only affect the allocation in question, but not | ||
50 | any future mmap()s. | ||
51 | |||
52 | Specifying high hint address on older kernel or on machine without 5-level | ||
53 | paging support is safe. The hint will be ignored and kernel will fall back | ||
54 | to allocation from 47-bit address space. | ||
55 | |||
56 | This approach helps to easily make application's memory allocator aware | ||
57 | about large address space without manually tracking allocated virtual | ||
58 | address space. | ||
59 | |||
60 | One important case we need to handle here is interaction with MPX. | ||
61 | MPX (without MAWA extension) cannot handle addresses above 47-bit, so we | ||
62 | need to make sure that MPX cannot be enabled we already have VMA above | ||
63 | the boundary and forbid creating such VMAs once MPX is enabled. | ||
64 | |||
diff --git a/MAINTAINERS b/MAINTAINERS index e99c74812f8d..b3eadf39ecf4 100644 --- a/MAINTAINERS +++ b/MAINTAINERS | |||
@@ -7111,7 +7111,6 @@ M: Marc Zyngier <marc.zyngier@arm.com> | |||
7111 | L: linux-kernel@vger.kernel.org | 7111 | L: linux-kernel@vger.kernel.org |
7112 | S: Maintained | 7112 | S: Maintained |
7113 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git irq/core | 7113 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git irq/core |
7114 | T: git git://git.infradead.org/users/jcooper/linux.git irqchip/core | ||
7115 | F: Documentation/devicetree/bindings/interrupt-controller/ | 7114 | F: Documentation/devicetree/bindings/interrupt-controller/ |
7116 | F: drivers/irqchip/ | 7115 | F: drivers/irqchip/ |
7117 | 7116 | ||
@@ -14005,6 +14004,7 @@ F: drivers/block/virtio_blk.c | |||
14005 | F: include/linux/virtio*.h | 14004 | F: include/linux/virtio*.h |
14006 | F: include/uapi/linux/virtio_*.h | 14005 | F: include/uapi/linux/virtio_*.h |
14007 | F: drivers/crypto/virtio/ | 14006 | F: drivers/crypto/virtio/ |
14007 | F: mm/balloon_compaction.c | ||
14008 | 14008 | ||
14009 | VIRTIO CRYPTO DRIVER | 14009 | VIRTIO CRYPTO DRIVER |
14010 | M: Gonglei <arei.gonglei@huawei.com> | 14010 | M: Gonglei <arei.gonglei@huawei.com> |
@@ -1,7 +1,7 @@ | |||
1 | VERSION = 4 | 1 | VERSION = 4 |
2 | PATCHLEVEL = 13 | 2 | PATCHLEVEL = 13 |
3 | SUBLEVEL = 0 | 3 | SUBLEVEL = 0 |
4 | EXTRAVERSION = -rc4 | 4 | EXTRAVERSION = -rc6 |
5 | NAME = Fearless Coyote | 5 | NAME = Fearless Coyote |
6 | 6 | ||
7 | # *DOCUMENTATION* | 7 | # *DOCUMENTATION* |
@@ -396,7 +396,7 @@ LINUXINCLUDE := \ | |||
396 | KBUILD_CPPFLAGS := -D__KERNEL__ | 396 | KBUILD_CPPFLAGS := -D__KERNEL__ |
397 | 397 | ||
398 | KBUILD_CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ | 398 | KBUILD_CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ |
399 | -fno-strict-aliasing -fno-common \ | 399 | -fno-strict-aliasing -fno-common -fshort-wchar \ |
400 | -Werror-implicit-function-declaration \ | 400 | -Werror-implicit-function-declaration \ |
401 | -Wno-format-security \ | 401 | -Wno-format-security \ |
402 | -std=gnu89 $(call cc-option,-fno-PIE) | 402 | -std=gnu89 $(call cc-option,-fno-PIE) |
@@ -442,7 +442,7 @@ export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn \ | |||
442 | # =========================================================================== | 442 | # =========================================================================== |
443 | # Rules shared between *config targets and build targets | 443 | # Rules shared between *config targets and build targets |
444 | 444 | ||
445 | # Basic helpers built in scripts/ | 445 | # Basic helpers built in scripts/basic/ |
446 | PHONY += scripts_basic | 446 | PHONY += scripts_basic |
447 | scripts_basic: | 447 | scripts_basic: |
448 | $(Q)$(MAKE) $(build)=scripts/basic | 448 | $(Q)$(MAKE) $(build)=scripts/basic |
@@ -505,7 +505,7 @@ ifeq ($(KBUILD_EXTMOD),) | |||
505 | endif | 505 | endif |
506 | endif | 506 | endif |
507 | endif | 507 | endif |
508 | # install and module_install need also be processed one by one | 508 | # install and modules_install need also be processed one by one |
509 | ifneq ($(filter install,$(MAKECMDGOALS)),) | 509 | ifneq ($(filter install,$(MAKECMDGOALS)),) |
510 | ifneq ($(filter modules_install,$(MAKECMDGOALS)),) | 510 | ifneq ($(filter modules_install,$(MAKECMDGOALS)),) |
511 | mixed-targets := 1 | 511 | mixed-targets := 1 |
@@ -964,7 +964,7 @@ export KBUILD_VMLINUX_MAIN := $(core-y) $(libs-y2) $(drivers-y) $(net-y) $(virt- | |||
964 | export KBUILD_VMLINUX_LIBS := $(libs-y1) | 964 | export KBUILD_VMLINUX_LIBS := $(libs-y1) |
965 | export KBUILD_LDS := arch/$(SRCARCH)/kernel/vmlinux.lds | 965 | export KBUILD_LDS := arch/$(SRCARCH)/kernel/vmlinux.lds |
966 | export LDFLAGS_vmlinux | 966 | export LDFLAGS_vmlinux |
967 | # used by scripts/pacmage/Makefile | 967 | # used by scripts/package/Makefile |
968 | export KBUILD_ALLDIRS := $(sort $(filter-out arch/%,$(vmlinux-alldirs)) arch Documentation include samples scripts tools) | 968 | export KBUILD_ALLDIRS := $(sort $(filter-out arch/%,$(vmlinux-alldirs)) arch Documentation include samples scripts tools) |
969 | 969 | ||
970 | vmlinux-deps := $(KBUILD_LDS) $(KBUILD_VMLINUX_INIT) $(KBUILD_VMLINUX_MAIN) $(KBUILD_VMLINUX_LIBS) | 970 | vmlinux-deps := $(KBUILD_LDS) $(KBUILD_VMLINUX_INIT) $(KBUILD_VMLINUX_MAIN) $(KBUILD_VMLINUX_LIBS) |
@@ -992,8 +992,8 @@ include/generated/autoksyms.h: FORCE | |||
992 | ARCH_POSTLINK := $(wildcard $(srctree)/arch/$(SRCARCH)/Makefile.postlink) | 992 | ARCH_POSTLINK := $(wildcard $(srctree)/arch/$(SRCARCH)/Makefile.postlink) |
993 | 993 | ||
994 | # Final link of vmlinux with optional arch pass after final link | 994 | # Final link of vmlinux with optional arch pass after final link |
995 | cmd_link-vmlinux = \ | 995 | cmd_link-vmlinux = \ |
996 | $(CONFIG_SHELL) $< $(LD) $(LDFLAGS) $(LDFLAGS_vmlinux) ; \ | 996 | $(CONFIG_SHELL) $< $(LD) $(LDFLAGS) $(LDFLAGS_vmlinux) ; \ |
997 | $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true) | 997 | $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true) |
998 | 998 | ||
999 | vmlinux: scripts/link-vmlinux.sh vmlinux_prereq $(vmlinux-deps) FORCE | 999 | vmlinux: scripts/link-vmlinux.sh vmlinux_prereq $(vmlinux-deps) FORCE |
@@ -1184,6 +1184,7 @@ PHONY += kselftest | |||
1184 | kselftest: | 1184 | kselftest: |
1185 | $(Q)$(MAKE) -C tools/testing/selftests run_tests | 1185 | $(Q)$(MAKE) -C tools/testing/selftests run_tests |
1186 | 1186 | ||
1187 | PHONY += kselftest-clean | ||
1187 | kselftest-clean: | 1188 | kselftest-clean: |
1188 | $(Q)$(MAKE) -C tools/testing/selftests clean | 1189 | $(Q)$(MAKE) -C tools/testing/selftests clean |
1189 | 1190 | ||
diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig index a5459698f0ee..7db85ab00c52 100644 --- a/arch/arc/Kconfig +++ b/arch/arc/Kconfig | |||
@@ -96,7 +96,6 @@ menu "ARC Architecture Configuration" | |||
96 | 96 | ||
97 | menu "ARC Platform/SoC/Board" | 97 | menu "ARC Platform/SoC/Board" |
98 | 98 | ||
99 | source "arch/arc/plat-sim/Kconfig" | ||
100 | source "arch/arc/plat-tb10x/Kconfig" | 99 | source "arch/arc/plat-tb10x/Kconfig" |
101 | source "arch/arc/plat-axs10x/Kconfig" | 100 | source "arch/arc/plat-axs10x/Kconfig" |
102 | #New platform adds here | 101 | #New platform adds here |
diff --git a/arch/arc/Makefile b/arch/arc/Makefile index 44ef35d33956..3a61cfcc38c0 100644 --- a/arch/arc/Makefile +++ b/arch/arc/Makefile | |||
@@ -107,7 +107,7 @@ core-y += arch/arc/ | |||
107 | # w/o this dtb won't embed into kernel binary | 107 | # w/o this dtb won't embed into kernel binary |
108 | core-y += arch/arc/boot/dts/ | 108 | core-y += arch/arc/boot/dts/ |
109 | 109 | ||
110 | core-$(CONFIG_ARC_PLAT_SIM) += arch/arc/plat-sim/ | 110 | core-y += arch/arc/plat-sim/ |
111 | core-$(CONFIG_ARC_PLAT_TB10X) += arch/arc/plat-tb10x/ | 111 | core-$(CONFIG_ARC_PLAT_TB10X) += arch/arc/plat-tb10x/ |
112 | core-$(CONFIG_ARC_PLAT_AXS10X) += arch/arc/plat-axs10x/ | 112 | core-$(CONFIG_ARC_PLAT_AXS10X) += arch/arc/plat-axs10x/ |
113 | core-$(CONFIG_ARC_PLAT_EZNPS) += arch/arc/plat-eznps/ | 113 | core-$(CONFIG_ARC_PLAT_EZNPS) += arch/arc/plat-eznps/ |
diff --git a/arch/arc/boot/dts/axc001.dtsi b/arch/arc/boot/dts/axc001.dtsi index 53ce226f77a5..a380ffa1a458 100644 --- a/arch/arc/boot/dts/axc001.dtsi +++ b/arch/arc/boot/dts/axc001.dtsi | |||
@@ -15,15 +15,15 @@ | |||
15 | 15 | ||
16 | / { | 16 | / { |
17 | compatible = "snps,arc"; | 17 | compatible = "snps,arc"; |
18 | #address-cells = <1>; | 18 | #address-cells = <2>; |
19 | #size-cells = <1>; | 19 | #size-cells = <2>; |
20 | 20 | ||
21 | cpu_card { | 21 | cpu_card { |
22 | compatible = "simple-bus"; | 22 | compatible = "simple-bus"; |
23 | #address-cells = <1>; | 23 | #address-cells = <1>; |
24 | #size-cells = <1>; | 24 | #size-cells = <1>; |
25 | 25 | ||
26 | ranges = <0x00000000 0xf0000000 0x10000000>; | 26 | ranges = <0x00000000 0x0 0xf0000000 0x10000000>; |
27 | 27 | ||
28 | core_clk: core_clk { | 28 | core_clk: core_clk { |
29 | #clock-cells = <0>; | 29 | #clock-cells = <0>; |
@@ -91,23 +91,21 @@ | |||
91 | mb_intc: dw-apb-ictl@0xe0012000 { | 91 | mb_intc: dw-apb-ictl@0xe0012000 { |
92 | #interrupt-cells = <1>; | 92 | #interrupt-cells = <1>; |
93 | compatible = "snps,dw-apb-ictl"; | 93 | compatible = "snps,dw-apb-ictl"; |
94 | reg = < 0xe0012000 0x200 >; | 94 | reg = < 0x0 0xe0012000 0x0 0x200 >; |
95 | interrupt-controller; | 95 | interrupt-controller; |
96 | interrupt-parent = <&core_intc>; | 96 | interrupt-parent = <&core_intc>; |
97 | interrupts = < 7 >; | 97 | interrupts = < 7 >; |
98 | }; | 98 | }; |
99 | 99 | ||
100 | memory { | 100 | memory { |
101 | #address-cells = <1>; | ||
102 | #size-cells = <1>; | ||
103 | ranges = <0x00000000 0x80000000 0x20000000>; | ||
104 | device_type = "memory"; | 101 | device_type = "memory"; |
105 | reg = <0x80000000 0x1b000000>; /* (512 - 32) MiB */ | 102 | /* CONFIG_KERNEL_RAM_BASE_ADDRESS needs to match low mem start */ |
103 | reg = <0x0 0x80000000 0x0 0x1b000000>; /* (512 - 32) MiB */ | ||
106 | }; | 104 | }; |
107 | 105 | ||
108 | reserved-memory { | 106 | reserved-memory { |
109 | #address-cells = <1>; | 107 | #address-cells = <2>; |
110 | #size-cells = <1>; | 108 | #size-cells = <2>; |
111 | ranges; | 109 | ranges; |
112 | /* | 110 | /* |
113 | * We just move frame buffer area to the very end of | 111 | * We just move frame buffer area to the very end of |
@@ -118,7 +116,7 @@ | |||
118 | */ | 116 | */ |
119 | frame_buffer: frame_buffer@9e000000 { | 117 | frame_buffer: frame_buffer@9e000000 { |
120 | compatible = "shared-dma-pool"; | 118 | compatible = "shared-dma-pool"; |
121 | reg = <0x9e000000 0x2000000>; | 119 | reg = <0x0 0x9e000000 0x0 0x2000000>; |
122 | no-map; | 120 | no-map; |
123 | }; | 121 | }; |
124 | }; | 122 | }; |
diff --git a/arch/arc/boot/dts/axc003.dtsi b/arch/arc/boot/dts/axc003.dtsi index 14df46f141bf..cc9239ef8d08 100644 --- a/arch/arc/boot/dts/axc003.dtsi +++ b/arch/arc/boot/dts/axc003.dtsi | |||
@@ -14,15 +14,15 @@ | |||
14 | 14 | ||
15 | / { | 15 | / { |
16 | compatible = "snps,arc"; | 16 | compatible = "snps,arc"; |
17 | #address-cells = <1>; | 17 | #address-cells = <2>; |
18 | #size-cells = <1>; | 18 | #size-cells = <2>; |
19 | 19 | ||
20 | cpu_card { | 20 | cpu_card { |
21 | compatible = "simple-bus"; | 21 | compatible = "simple-bus"; |
22 | #address-cells = <1>; | 22 | #address-cells = <1>; |
23 | #size-cells = <1>; | 23 | #size-cells = <1>; |
24 | 24 | ||
25 | ranges = <0x00000000 0xf0000000 0x10000000>; | 25 | ranges = <0x00000000 0x0 0xf0000000 0x10000000>; |
26 | 26 | ||
27 | core_clk: core_clk { | 27 | core_clk: core_clk { |
28 | #clock-cells = <0>; | 28 | #clock-cells = <0>; |
@@ -94,30 +94,29 @@ | |||
94 | mb_intc: dw-apb-ictl@0xe0012000 { | 94 | mb_intc: dw-apb-ictl@0xe0012000 { |
95 | #interrupt-cells = <1>; | 95 | #interrupt-cells = <1>; |
96 | compatible = "snps,dw-apb-ictl"; | 96 | compatible = "snps,dw-apb-ictl"; |
97 | reg = < 0xe0012000 0x200 >; | 97 | reg = < 0x0 0xe0012000 0x0 0x200 >; |
98 | interrupt-controller; | 98 | interrupt-controller; |
99 | interrupt-parent = <&core_intc>; | 99 | interrupt-parent = <&core_intc>; |
100 | interrupts = < 24 >; | 100 | interrupts = < 24 >; |
101 | }; | 101 | }; |
102 | 102 | ||
103 | memory { | 103 | memory { |
104 | #address-cells = <1>; | ||
105 | #size-cells = <1>; | ||
106 | ranges = <0x00000000 0x80000000 0x40000000>; | ||
107 | device_type = "memory"; | 104 | device_type = "memory"; |
108 | reg = <0x80000000 0x20000000>; /* 512MiB */ | 105 | /* CONFIG_KERNEL_RAM_BASE_ADDRESS needs to match low mem start */ |
106 | reg = <0x0 0x80000000 0x0 0x20000000 /* 512 MiB low mem */ | ||
107 | 0x1 0xc0000000 0x0 0x40000000>; /* 1 GiB highmem */ | ||
109 | }; | 108 | }; |
110 | 109 | ||
111 | reserved-memory { | 110 | reserved-memory { |
112 | #address-cells = <1>; | 111 | #address-cells = <2>; |
113 | #size-cells = <1>; | 112 | #size-cells = <2>; |
114 | ranges; | 113 | ranges; |
115 | /* | 114 | /* |
116 | * Move frame buffer out of IOC aperture (0x8z-0xAz). | 115 | * Move frame buffer out of IOC aperture (0x8z-0xAz). |
117 | */ | 116 | */ |
118 | frame_buffer: frame_buffer@be000000 { | 117 | frame_buffer: frame_buffer@be000000 { |
119 | compatible = "shared-dma-pool"; | 118 | compatible = "shared-dma-pool"; |
120 | reg = <0xbe000000 0x2000000>; | 119 | reg = <0x0 0xbe000000 0x0 0x2000000>; |
121 | no-map; | 120 | no-map; |
122 | }; | 121 | }; |
123 | }; | 122 | }; |
diff --git a/arch/arc/boot/dts/axc003_idu.dtsi b/arch/arc/boot/dts/axc003_idu.dtsi index 695f9fa1996b..4ebb2170abec 100644 --- a/arch/arc/boot/dts/axc003_idu.dtsi +++ b/arch/arc/boot/dts/axc003_idu.dtsi | |||
@@ -14,15 +14,15 @@ | |||
14 | 14 | ||
15 | / { | 15 | / { |
16 | compatible = "snps,arc"; | 16 | compatible = "snps,arc"; |
17 | #address-cells = <1>; | 17 | #address-cells = <2>; |
18 | #size-cells = <1>; | 18 | #size-cells = <2>; |
19 | 19 | ||
20 | cpu_card { | 20 | cpu_card { |
21 | compatible = "simple-bus"; | 21 | compatible = "simple-bus"; |
22 | #address-cells = <1>; | 22 | #address-cells = <1>; |
23 | #size-cells = <1>; | 23 | #size-cells = <1>; |
24 | 24 | ||
25 | ranges = <0x00000000 0xf0000000 0x10000000>; | 25 | ranges = <0x00000000 0x0 0xf0000000 0x10000000>; |
26 | 26 | ||
27 | core_clk: core_clk { | 27 | core_clk: core_clk { |
28 | #clock-cells = <0>; | 28 | #clock-cells = <0>; |
@@ -100,30 +100,29 @@ | |||
100 | mb_intc: dw-apb-ictl@0xe0012000 { | 100 | mb_intc: dw-apb-ictl@0xe0012000 { |
101 | #interrupt-cells = <1>; | 101 | #interrupt-cells = <1>; |
102 | compatible = "snps,dw-apb-ictl"; | 102 | compatible = "snps,dw-apb-ictl"; |
103 | reg = < 0xe0012000 0x200 >; | 103 | reg = < 0x0 0xe0012000 0x0 0x200 >; |
104 | interrupt-controller; | 104 | interrupt-controller; |
105 | interrupt-parent = <&idu_intc>; | 105 | interrupt-parent = <&idu_intc>; |
106 | interrupts = <0>; | 106 | interrupts = <0>; |
107 | }; | 107 | }; |
108 | 108 | ||
109 | memory { | 109 | memory { |
110 | #address-cells = <1>; | ||
111 | #size-cells = <1>; | ||
112 | ranges = <0x00000000 0x80000000 0x40000000>; | ||
113 | device_type = "memory"; | 110 | device_type = "memory"; |
114 | reg = <0x80000000 0x20000000>; /* 512MiB */ | 111 | /* CONFIG_KERNEL_RAM_BASE_ADDRESS needs to match low mem start */ |
112 | reg = <0x0 0x80000000 0x0 0x20000000 /* 512 MiB low mem */ | ||
113 | 0x1 0xc0000000 0x0 0x40000000>; /* 1 GiB highmem */ | ||
115 | }; | 114 | }; |
116 | 115 | ||
117 | reserved-memory { | 116 | reserved-memory { |
118 | #address-cells = <1>; | 117 | #address-cells = <2>; |
119 | #size-cells = <1>; | 118 | #size-cells = <2>; |
120 | ranges; | 119 | ranges; |
121 | /* | 120 | /* |
122 | * Move frame buffer out of IOC aperture (0x8z-0xAz). | 121 | * Move frame buffer out of IOC aperture (0x8z-0xAz). |
123 | */ | 122 | */ |
124 | frame_buffer: frame_buffer@be000000 { | 123 | frame_buffer: frame_buffer@be000000 { |
125 | compatible = "shared-dma-pool"; | 124 | compatible = "shared-dma-pool"; |
126 | reg = <0xbe000000 0x2000000>; | 125 | reg = <0x0 0xbe000000 0x0 0x2000000>; |
127 | no-map; | 126 | no-map; |
128 | }; | 127 | }; |
129 | }; | 128 | }; |
diff --git a/arch/arc/boot/dts/axs10x_mb.dtsi b/arch/arc/boot/dts/axs10x_mb.dtsi index 41cfb29b62c1..0ff7e07edcd4 100644 --- a/arch/arc/boot/dts/axs10x_mb.dtsi +++ b/arch/arc/boot/dts/axs10x_mb.dtsi | |||
@@ -13,7 +13,7 @@ | |||
13 | compatible = "simple-bus"; | 13 | compatible = "simple-bus"; |
14 | #address-cells = <1>; | 14 | #address-cells = <1>; |
15 | #size-cells = <1>; | 15 | #size-cells = <1>; |
16 | ranges = <0x00000000 0xe0000000 0x10000000>; | 16 | ranges = <0x00000000 0x0 0xe0000000 0x10000000>; |
17 | interrupt-parent = <&mb_intc>; | 17 | interrupt-parent = <&mb_intc>; |
18 | 18 | ||
19 | i2sclk: i2sclk@100a0 { | 19 | i2sclk: i2sclk@100a0 { |
diff --git a/arch/arc/configs/haps_hs_defconfig b/arch/arc/configs/haps_hs_defconfig index 57b3e599322f..db04ea4dd2d9 100644 --- a/arch/arc/configs/haps_hs_defconfig +++ b/arch/arc/configs/haps_hs_defconfig | |||
@@ -21,7 +21,6 @@ CONFIG_MODULES=y | |||
21 | # CONFIG_BLK_DEV_BSG is not set | 21 | # CONFIG_BLK_DEV_BSG is not set |
22 | # CONFIG_IOSCHED_DEADLINE is not set | 22 | # CONFIG_IOSCHED_DEADLINE is not set |
23 | # CONFIG_IOSCHED_CFQ is not set | 23 | # CONFIG_IOSCHED_CFQ is not set |
24 | CONFIG_ARC_PLAT_SIM=y | ||
25 | CONFIG_ISA_ARCV2=y | 24 | CONFIG_ISA_ARCV2=y |
26 | CONFIG_ARC_BUILTIN_DTB_NAME="haps_hs" | 25 | CONFIG_ARC_BUILTIN_DTB_NAME="haps_hs" |
27 | CONFIG_PREEMPT=y | 26 | CONFIG_PREEMPT=y |
diff --git a/arch/arc/configs/haps_hs_smp_defconfig b/arch/arc/configs/haps_hs_smp_defconfig index f85985adebb2..821a2e562f3f 100644 --- a/arch/arc/configs/haps_hs_smp_defconfig +++ b/arch/arc/configs/haps_hs_smp_defconfig | |||
@@ -23,7 +23,6 @@ CONFIG_MODULES=y | |||
23 | # CONFIG_BLK_DEV_BSG is not set | 23 | # CONFIG_BLK_DEV_BSG is not set |
24 | # CONFIG_IOSCHED_DEADLINE is not set | 24 | # CONFIG_IOSCHED_DEADLINE is not set |
25 | # CONFIG_IOSCHED_CFQ is not set | 25 | # CONFIG_IOSCHED_CFQ is not set |
26 | CONFIG_ARC_PLAT_SIM=y | ||
27 | CONFIG_ISA_ARCV2=y | 26 | CONFIG_ISA_ARCV2=y |
28 | CONFIG_SMP=y | 27 | CONFIG_SMP=y |
29 | CONFIG_ARC_BUILTIN_DTB_NAME="haps_hs_idu" | 28 | CONFIG_ARC_BUILTIN_DTB_NAME="haps_hs_idu" |
diff --git a/arch/arc/configs/nps_defconfig b/arch/arc/configs/nps_defconfig index ede625c76216..7c9c706ae7f6 100644 --- a/arch/arc/configs/nps_defconfig +++ b/arch/arc/configs/nps_defconfig | |||
@@ -39,7 +39,6 @@ CONFIG_IP_PNP=y | |||
39 | # CONFIG_INET_XFRM_MODE_TRANSPORT is not set | 39 | # CONFIG_INET_XFRM_MODE_TRANSPORT is not set |
40 | # CONFIG_INET_XFRM_MODE_TUNNEL is not set | 40 | # CONFIG_INET_XFRM_MODE_TUNNEL is not set |
41 | # CONFIG_INET_XFRM_MODE_BEET is not set | 41 | # CONFIG_INET_XFRM_MODE_BEET is not set |
42 | # CONFIG_INET_LRO is not set | ||
43 | # CONFIG_INET_DIAG is not set | 42 | # CONFIG_INET_DIAG is not set |
44 | # CONFIG_IPV6 is not set | 43 | # CONFIG_IPV6 is not set |
45 | # CONFIG_WIRELESS is not set | 44 | # CONFIG_WIRELESS is not set |
diff --git a/arch/arc/configs/nsim_700_defconfig b/arch/arc/configs/nsim_700_defconfig index b0066a749d4c..6dff83a238b8 100644 --- a/arch/arc/configs/nsim_700_defconfig +++ b/arch/arc/configs/nsim_700_defconfig | |||
@@ -23,7 +23,6 @@ CONFIG_MODULES=y | |||
23 | # CONFIG_BLK_DEV_BSG is not set | 23 | # CONFIG_BLK_DEV_BSG is not set |
24 | # CONFIG_IOSCHED_DEADLINE is not set | 24 | # CONFIG_IOSCHED_DEADLINE is not set |
25 | # CONFIG_IOSCHED_CFQ is not set | 25 | # CONFIG_IOSCHED_CFQ is not set |
26 | CONFIG_ARC_PLAT_SIM=y | ||
27 | CONFIG_ARC_BUILTIN_DTB_NAME="nsim_700" | 26 | CONFIG_ARC_BUILTIN_DTB_NAME="nsim_700" |
28 | CONFIG_PREEMPT=y | 27 | CONFIG_PREEMPT=y |
29 | # CONFIG_COMPACTION is not set | 28 | # CONFIG_COMPACTION is not set |
diff --git a/arch/arc/configs/nsim_hs_defconfig b/arch/arc/configs/nsim_hs_defconfig index ebe9ebb92933..31ee51b987e7 100644 --- a/arch/arc/configs/nsim_hs_defconfig +++ b/arch/arc/configs/nsim_hs_defconfig | |||
@@ -26,7 +26,6 @@ CONFIG_MODULE_FORCE_UNLOAD=y | |||
26 | # CONFIG_BLK_DEV_BSG is not set | 26 | # CONFIG_BLK_DEV_BSG is not set |
27 | # CONFIG_IOSCHED_DEADLINE is not set | 27 | # CONFIG_IOSCHED_DEADLINE is not set |
28 | # CONFIG_IOSCHED_CFQ is not set | 28 | # CONFIG_IOSCHED_CFQ is not set |
29 | CONFIG_ARC_PLAT_SIM=y | ||
30 | CONFIG_ISA_ARCV2=y | 29 | CONFIG_ISA_ARCV2=y |
31 | CONFIG_ARC_BUILTIN_DTB_NAME="nsim_hs" | 30 | CONFIG_ARC_BUILTIN_DTB_NAME="nsim_hs" |
32 | CONFIG_PREEMPT=y | 31 | CONFIG_PREEMPT=y |
diff --git a/arch/arc/configs/nsim_hs_smp_defconfig b/arch/arc/configs/nsim_hs_smp_defconfig index 4bde43278be6..8d3b1f67cae4 100644 --- a/arch/arc/configs/nsim_hs_smp_defconfig +++ b/arch/arc/configs/nsim_hs_smp_defconfig | |||
@@ -24,7 +24,6 @@ CONFIG_MODULE_FORCE_UNLOAD=y | |||
24 | # CONFIG_BLK_DEV_BSG is not set | 24 | # CONFIG_BLK_DEV_BSG is not set |
25 | # CONFIG_IOSCHED_DEADLINE is not set | 25 | # CONFIG_IOSCHED_DEADLINE is not set |
26 | # CONFIG_IOSCHED_CFQ is not set | 26 | # CONFIG_IOSCHED_CFQ is not set |
27 | CONFIG_ARC_PLAT_SIM=y | ||
28 | CONFIG_ISA_ARCV2=y | 27 | CONFIG_ISA_ARCV2=y |
29 | CONFIG_SMP=y | 28 | CONFIG_SMP=y |
30 | CONFIG_ARC_BUILTIN_DTB_NAME="nsim_hs_idu" | 29 | CONFIG_ARC_BUILTIN_DTB_NAME="nsim_hs_idu" |
diff --git a/arch/arc/configs/nsimosci_defconfig b/arch/arc/configs/nsimosci_defconfig index f6fb3d26557e..6168ce2ac2ef 100644 --- a/arch/arc/configs/nsimosci_defconfig +++ b/arch/arc/configs/nsimosci_defconfig | |||
@@ -23,7 +23,6 @@ CONFIG_MODULES=y | |||
23 | # CONFIG_BLK_DEV_BSG is not set | 23 | # CONFIG_BLK_DEV_BSG is not set |
24 | # CONFIG_IOSCHED_DEADLINE is not set | 24 | # CONFIG_IOSCHED_DEADLINE is not set |
25 | # CONFIG_IOSCHED_CFQ is not set | 25 | # CONFIG_IOSCHED_CFQ is not set |
26 | CONFIG_ARC_PLAT_SIM=y | ||
27 | CONFIG_ARC_BUILTIN_DTB_NAME="nsimosci" | 26 | CONFIG_ARC_BUILTIN_DTB_NAME="nsimosci" |
28 | # CONFIG_COMPACTION is not set | 27 | # CONFIG_COMPACTION is not set |
29 | CONFIG_NET=y | 28 | CONFIG_NET=y |
diff --git a/arch/arc/configs/nsimosci_hs_defconfig b/arch/arc/configs/nsimosci_hs_defconfig index b9f0fe00044b..a70bdeb2b3fd 100644 --- a/arch/arc/configs/nsimosci_hs_defconfig +++ b/arch/arc/configs/nsimosci_hs_defconfig | |||
@@ -23,7 +23,6 @@ CONFIG_MODULES=y | |||
23 | # CONFIG_BLK_DEV_BSG is not set | 23 | # CONFIG_BLK_DEV_BSG is not set |
24 | # CONFIG_IOSCHED_DEADLINE is not set | 24 | # CONFIG_IOSCHED_DEADLINE is not set |
25 | # CONFIG_IOSCHED_CFQ is not set | 25 | # CONFIG_IOSCHED_CFQ is not set |
26 | CONFIG_ARC_PLAT_SIM=y | ||
27 | CONFIG_ISA_ARCV2=y | 26 | CONFIG_ISA_ARCV2=y |
28 | CONFIG_ARC_BUILTIN_DTB_NAME="nsimosci_hs" | 27 | CONFIG_ARC_BUILTIN_DTB_NAME="nsimosci_hs" |
29 | # CONFIG_COMPACTION is not set | 28 | # CONFIG_COMPACTION is not set |
diff --git a/arch/arc/configs/nsimosci_hs_smp_defconfig b/arch/arc/configs/nsimosci_hs_smp_defconfig index 155add7761ed..ef96406c446e 100644 --- a/arch/arc/configs/nsimosci_hs_smp_defconfig +++ b/arch/arc/configs/nsimosci_hs_smp_defconfig | |||
@@ -18,7 +18,6 @@ CONFIG_MODULES=y | |||
18 | # CONFIG_BLK_DEV_BSG is not set | 18 | # CONFIG_BLK_DEV_BSG is not set |
19 | # CONFIG_IOSCHED_DEADLINE is not set | 19 | # CONFIG_IOSCHED_DEADLINE is not set |
20 | # CONFIG_IOSCHED_CFQ is not set | 20 | # CONFIG_IOSCHED_CFQ is not set |
21 | CONFIG_ARC_PLAT_SIM=y | ||
22 | CONFIG_ISA_ARCV2=y | 21 | CONFIG_ISA_ARCV2=y |
23 | CONFIG_SMP=y | 22 | CONFIG_SMP=y |
24 | # CONFIG_ARC_TIMERS_64BIT is not set | 23 | # CONFIG_ARC_TIMERS_64BIT is not set |
diff --git a/arch/arc/configs/tb10x_defconfig b/arch/arc/configs/tb10x_defconfig index 4c5118384eb5..f30182549395 100644 --- a/arch/arc/configs/tb10x_defconfig +++ b/arch/arc/configs/tb10x_defconfig | |||
@@ -38,7 +38,6 @@ CONFIG_IP_MULTICAST=y | |||
38 | # CONFIG_INET_XFRM_MODE_TRANSPORT is not set | 38 | # CONFIG_INET_XFRM_MODE_TRANSPORT is not set |
39 | # CONFIG_INET_XFRM_MODE_TUNNEL is not set | 39 | # CONFIG_INET_XFRM_MODE_TUNNEL is not set |
40 | # CONFIG_INET_XFRM_MODE_BEET is not set | 40 | # CONFIG_INET_XFRM_MODE_BEET is not set |
41 | # CONFIG_INET_LRO is not set | ||
42 | # CONFIG_INET_DIAG is not set | 41 | # CONFIG_INET_DIAG is not set |
43 | # CONFIG_IPV6 is not set | 42 | # CONFIG_IPV6 is not set |
44 | # CONFIG_WIRELESS is not set | 43 | # CONFIG_WIRELESS is not set |
diff --git a/arch/arc/include/asm/cache.h b/arch/arc/include/asm/cache.h index 19ebddffb279..02fd1cece6ef 100644 --- a/arch/arc/include/asm/cache.h +++ b/arch/arc/include/asm/cache.h | |||
@@ -96,7 +96,9 @@ extern unsigned long perip_base, perip_end; | |||
96 | #define ARC_REG_SLC_FLUSH 0x904 | 96 | #define ARC_REG_SLC_FLUSH 0x904 |
97 | #define ARC_REG_SLC_INVALIDATE 0x905 | 97 | #define ARC_REG_SLC_INVALIDATE 0x905 |
98 | #define ARC_REG_SLC_RGN_START 0x914 | 98 | #define ARC_REG_SLC_RGN_START 0x914 |
99 | #define ARC_REG_SLC_RGN_START1 0x915 | ||
99 | #define ARC_REG_SLC_RGN_END 0x916 | 100 | #define ARC_REG_SLC_RGN_END 0x916 |
101 | #define ARC_REG_SLC_RGN_END1 0x917 | ||
100 | 102 | ||
101 | /* Bit val in SLC_CONTROL */ | 103 | /* Bit val in SLC_CONTROL */ |
102 | #define SLC_CTRL_DIS 0x001 | 104 | #define SLC_CTRL_DIS 0x001 |
diff --git a/arch/arc/include/asm/mmu.h b/arch/arc/include/asm/mmu.h index db7319e9b506..efb79fafff1d 100644 --- a/arch/arc/include/asm/mmu.h +++ b/arch/arc/include/asm/mmu.h | |||
@@ -94,6 +94,8 @@ static inline int is_pae40_enabled(void) | |||
94 | return IS_ENABLED(CONFIG_ARC_HAS_PAE40); | 94 | return IS_ENABLED(CONFIG_ARC_HAS_PAE40); |
95 | } | 95 | } |
96 | 96 | ||
97 | extern int pae40_exist_but_not_enab(void); | ||
98 | |||
97 | #endif /* !__ASSEMBLY__ */ | 99 | #endif /* !__ASSEMBLY__ */ |
98 | 100 | ||
99 | #endif | 101 | #endif |
diff --git a/arch/arc/kernel/intc-arcv2.c b/arch/arc/kernel/intc-arcv2.c index f928795fd07a..cf90714a676d 100644 --- a/arch/arc/kernel/intc-arcv2.c +++ b/arch/arc/kernel/intc-arcv2.c | |||
@@ -75,10 +75,13 @@ void arc_init_IRQ(void) | |||
75 | * Set a default priority for all available interrupts to prevent | 75 | * Set a default priority for all available interrupts to prevent |
76 | * switching of register banks if Fast IRQ and multiple register banks | 76 | * switching of register banks if Fast IRQ and multiple register banks |
77 | * are supported by CPU. | 77 | * are supported by CPU. |
78 | * Also disable all IRQ lines so faulty external hardware won't | ||
79 | * trigger interrupt that kernel is not ready to handle. | ||
78 | */ | 80 | */ |
79 | for (i = NR_EXCEPTIONS; i < irq_bcr.irqs + NR_EXCEPTIONS; i++) { | 81 | for (i = NR_EXCEPTIONS; i < irq_bcr.irqs + NR_EXCEPTIONS; i++) { |
80 | write_aux_reg(AUX_IRQ_SELECT, i); | 82 | write_aux_reg(AUX_IRQ_SELECT, i); |
81 | write_aux_reg(AUX_IRQ_PRIORITY, ARCV2_IRQ_DEF_PRIO); | 83 | write_aux_reg(AUX_IRQ_PRIORITY, ARCV2_IRQ_DEF_PRIO); |
84 | write_aux_reg(AUX_IRQ_ENABLE, 0); | ||
82 | } | 85 | } |
83 | 86 | ||
84 | /* setup status32, don't enable intr yet as kernel doesn't want */ | 87 | /* setup status32, don't enable intr yet as kernel doesn't want */ |
diff --git a/arch/arc/kernel/intc-compact.c b/arch/arc/kernel/intc-compact.c index 7e608c6b0a01..cef388025adf 100644 --- a/arch/arc/kernel/intc-compact.c +++ b/arch/arc/kernel/intc-compact.c | |||
@@ -27,7 +27,7 @@ | |||
27 | */ | 27 | */ |
28 | void arc_init_IRQ(void) | 28 | void arc_init_IRQ(void) |
29 | { | 29 | { |
30 | int level_mask = 0; | 30 | int level_mask = 0, i; |
31 | 31 | ||
32 | /* Is timer high priority Interrupt (Level2 in ARCompact jargon) */ | 32 | /* Is timer high priority Interrupt (Level2 in ARCompact jargon) */ |
33 | level_mask |= IS_ENABLED(CONFIG_ARC_COMPACT_IRQ_LEVELS) << TIMER0_IRQ; | 33 | level_mask |= IS_ENABLED(CONFIG_ARC_COMPACT_IRQ_LEVELS) << TIMER0_IRQ; |
@@ -40,6 +40,18 @@ void arc_init_IRQ(void) | |||
40 | 40 | ||
41 | if (level_mask) | 41 | if (level_mask) |
42 | pr_info("Level-2 interrupts bitset %x\n", level_mask); | 42 | pr_info("Level-2 interrupts bitset %x\n", level_mask); |
43 | |||
44 | /* | ||
45 | * Disable all IRQ lines so faulty external hardware won't | ||
46 | * trigger interrupt that kernel is not ready to handle. | ||
47 | */ | ||
48 | for (i = TIMER0_IRQ; i < NR_CPU_IRQS; i++) { | ||
49 | unsigned int ienb; | ||
50 | |||
51 | ienb = read_aux_reg(AUX_IENABLE); | ||
52 | ienb &= ~(1 << i); | ||
53 | write_aux_reg(AUX_IENABLE, ienb); | ||
54 | } | ||
43 | } | 55 | } |
44 | 56 | ||
45 | /* | 57 | /* |
diff --git a/arch/arc/mm/cache.c b/arch/arc/mm/cache.c index a867575a758b..7db283b46ebd 100644 --- a/arch/arc/mm/cache.c +++ b/arch/arc/mm/cache.c | |||
@@ -665,6 +665,7 @@ noinline void slc_op(phys_addr_t paddr, unsigned long sz, const int op) | |||
665 | static DEFINE_SPINLOCK(lock); | 665 | static DEFINE_SPINLOCK(lock); |
666 | unsigned long flags; | 666 | unsigned long flags; |
667 | unsigned int ctrl; | 667 | unsigned int ctrl; |
668 | phys_addr_t end; | ||
668 | 669 | ||
669 | spin_lock_irqsave(&lock, flags); | 670 | spin_lock_irqsave(&lock, flags); |
670 | 671 | ||
@@ -694,8 +695,19 @@ noinline void slc_op(phys_addr_t paddr, unsigned long sz, const int op) | |||
694 | * END needs to be setup before START (latter triggers the operation) | 695 | * END needs to be setup before START (latter triggers the operation) |
695 | * END can't be same as START, so add (l2_line_sz - 1) to sz | 696 | * END can't be same as START, so add (l2_line_sz - 1) to sz |
696 | */ | 697 | */ |
697 | write_aux_reg(ARC_REG_SLC_RGN_END, (paddr + sz + l2_line_sz - 1)); | 698 | end = paddr + sz + l2_line_sz - 1; |
698 | write_aux_reg(ARC_REG_SLC_RGN_START, paddr); | 699 | if (is_pae40_enabled()) |
700 | write_aux_reg(ARC_REG_SLC_RGN_END1, upper_32_bits(end)); | ||
701 | |||
702 | write_aux_reg(ARC_REG_SLC_RGN_END, lower_32_bits(end)); | ||
703 | |||
704 | if (is_pae40_enabled()) | ||
705 | write_aux_reg(ARC_REG_SLC_RGN_START1, upper_32_bits(paddr)); | ||
706 | |||
707 | write_aux_reg(ARC_REG_SLC_RGN_START, lower_32_bits(paddr)); | ||
708 | |||
709 | /* Make sure "busy" bit reports correct stataus, see STAR 9001165532 */ | ||
710 | read_aux_reg(ARC_REG_SLC_CTRL); | ||
699 | 711 | ||
700 | while (read_aux_reg(ARC_REG_SLC_CTRL) & SLC_CTRL_BUSY); | 712 | while (read_aux_reg(ARC_REG_SLC_CTRL) & SLC_CTRL_BUSY); |
701 | 713 | ||
@@ -1111,6 +1123,13 @@ noinline void __init arc_ioc_setup(void) | |||
1111 | __dc_enable(); | 1123 | __dc_enable(); |
1112 | } | 1124 | } |
1113 | 1125 | ||
1126 | /* | ||
1127 | * Cache related boot time checks/setups only needed on master CPU: | ||
1128 | * - Geometry checks (kernel build and hardware agree: e.g. L1_CACHE_BYTES) | ||
1129 | * Assume SMP only, so all cores will have same cache config. A check on | ||
1130 | * one core suffices for all | ||
1131 | * - IOC setup / dma callbacks only need to be done once | ||
1132 | */ | ||
1114 | void __init arc_cache_init_master(void) | 1133 | void __init arc_cache_init_master(void) |
1115 | { | 1134 | { |
1116 | unsigned int __maybe_unused cpu = smp_processor_id(); | 1135 | unsigned int __maybe_unused cpu = smp_processor_id(); |
@@ -1190,12 +1209,27 @@ void __ref arc_cache_init(void) | |||
1190 | 1209 | ||
1191 | printk(arc_cache_mumbojumbo(0, str, sizeof(str))); | 1210 | printk(arc_cache_mumbojumbo(0, str, sizeof(str))); |
1192 | 1211 | ||
1193 | /* | ||
1194 | * Only master CPU needs to execute rest of function: | ||
1195 | * - Assume SMP so all cores will have same cache config so | ||
1196 | * any geomtry checks will be same for all | ||
1197 | * - IOC setup / dma callbacks only need to be setup once | ||
1198 | */ | ||
1199 | if (!cpu) | 1212 | if (!cpu) |
1200 | arc_cache_init_master(); | 1213 | arc_cache_init_master(); |
1214 | |||
1215 | /* | ||
1216 | * In PAE regime, TLB and cache maintenance ops take wider addresses | ||
1217 | * And even if PAE is not enabled in kernel, the upper 32-bits still need | ||
1218 | * to be zeroed to keep the ops sane. | ||
1219 | * As an optimization for more common !PAE enabled case, zero them out | ||
1220 | * once at init, rather than checking/setting to 0 for every runtime op | ||
1221 | */ | ||
1222 | if (is_isa_arcv2() && pae40_exist_but_not_enab()) { | ||
1223 | |||
1224 | if (IS_ENABLED(CONFIG_ARC_HAS_ICACHE)) | ||
1225 | write_aux_reg(ARC_REG_IC_PTAG_HI, 0); | ||
1226 | |||
1227 | if (IS_ENABLED(CONFIG_ARC_HAS_DCACHE)) | ||
1228 | write_aux_reg(ARC_REG_DC_PTAG_HI, 0); | ||
1229 | |||
1230 | if (l2_line_sz) { | ||
1231 | write_aux_reg(ARC_REG_SLC_RGN_END1, 0); | ||
1232 | write_aux_reg(ARC_REG_SLC_RGN_START1, 0); | ||
1233 | } | ||
1234 | } | ||
1201 | } | 1235 | } |
diff --git a/arch/arc/mm/dma.c b/arch/arc/mm/dma.c index 71d3efff99d3..e9d93604ad0f 100644 --- a/arch/arc/mm/dma.c +++ b/arch/arc/mm/dma.c | |||
@@ -153,6 +153,19 @@ static void _dma_cache_sync(phys_addr_t paddr, size_t size, | |||
153 | } | 153 | } |
154 | } | 154 | } |
155 | 155 | ||
156 | /* | ||
157 | * arc_dma_map_page - map a portion of a page for streaming DMA | ||
158 | * | ||
159 | * Ensure that any data held in the cache is appropriately discarded | ||
160 | * or written back. | ||
161 | * | ||
162 | * The device owns this memory once this call has completed. The CPU | ||
163 | * can regain ownership by calling dma_unmap_page(). | ||
164 | * | ||
165 | * Note: while it takes struct page as arg, caller can "abuse" it to pass | ||
166 | * a region larger than PAGE_SIZE, provided it is physically contiguous | ||
167 | * and this still works correctly | ||
168 | */ | ||
156 | static dma_addr_t arc_dma_map_page(struct device *dev, struct page *page, | 169 | static dma_addr_t arc_dma_map_page(struct device *dev, struct page *page, |
157 | unsigned long offset, size_t size, enum dma_data_direction dir, | 170 | unsigned long offset, size_t size, enum dma_data_direction dir, |
158 | unsigned long attrs) | 171 | unsigned long attrs) |
@@ -165,6 +178,24 @@ static dma_addr_t arc_dma_map_page(struct device *dev, struct page *page, | |||
165 | return plat_phys_to_dma(dev, paddr); | 178 | return plat_phys_to_dma(dev, paddr); |
166 | } | 179 | } |
167 | 180 | ||
181 | /* | ||
182 | * arc_dma_unmap_page - unmap a buffer previously mapped through dma_map_page() | ||
183 | * | ||
184 | * After this call, reads by the CPU to the buffer are guaranteed to see | ||
185 | * whatever the device wrote there. | ||
186 | * | ||
187 | * Note: historically this routine was not implemented for ARC | ||
188 | */ | ||
189 | static void arc_dma_unmap_page(struct device *dev, dma_addr_t handle, | ||
190 | size_t size, enum dma_data_direction dir, | ||
191 | unsigned long attrs) | ||
192 | { | ||
193 | phys_addr_t paddr = plat_dma_to_phys(dev, handle); | ||
194 | |||
195 | if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC)) | ||
196 | _dma_cache_sync(paddr, size, dir); | ||
197 | } | ||
198 | |||
168 | static int arc_dma_map_sg(struct device *dev, struct scatterlist *sg, | 199 | static int arc_dma_map_sg(struct device *dev, struct scatterlist *sg, |
169 | int nents, enum dma_data_direction dir, unsigned long attrs) | 200 | int nents, enum dma_data_direction dir, unsigned long attrs) |
170 | { | 201 | { |
@@ -178,6 +209,18 @@ static int arc_dma_map_sg(struct device *dev, struct scatterlist *sg, | |||
178 | return nents; | 209 | return nents; |
179 | } | 210 | } |
180 | 211 | ||
212 | static void arc_dma_unmap_sg(struct device *dev, struct scatterlist *sg, | ||
213 | int nents, enum dma_data_direction dir, | ||
214 | unsigned long attrs) | ||
215 | { | ||
216 | struct scatterlist *s; | ||
217 | int i; | ||
218 | |||
219 | for_each_sg(sg, s, nents, i) | ||
220 | arc_dma_unmap_page(dev, sg_dma_address(s), sg_dma_len(s), dir, | ||
221 | attrs); | ||
222 | } | ||
223 | |||
181 | static void arc_dma_sync_single_for_cpu(struct device *dev, | 224 | static void arc_dma_sync_single_for_cpu(struct device *dev, |
182 | dma_addr_t dma_handle, size_t size, enum dma_data_direction dir) | 225 | dma_addr_t dma_handle, size_t size, enum dma_data_direction dir) |
183 | { | 226 | { |
@@ -223,7 +266,9 @@ const struct dma_map_ops arc_dma_ops = { | |||
223 | .free = arc_dma_free, | 266 | .free = arc_dma_free, |
224 | .mmap = arc_dma_mmap, | 267 | .mmap = arc_dma_mmap, |
225 | .map_page = arc_dma_map_page, | 268 | .map_page = arc_dma_map_page, |
269 | .unmap_page = arc_dma_unmap_page, | ||
226 | .map_sg = arc_dma_map_sg, | 270 | .map_sg = arc_dma_map_sg, |
271 | .unmap_sg = arc_dma_unmap_sg, | ||
227 | .sync_single_for_device = arc_dma_sync_single_for_device, | 272 | .sync_single_for_device = arc_dma_sync_single_for_device, |
228 | .sync_single_for_cpu = arc_dma_sync_single_for_cpu, | 273 | .sync_single_for_cpu = arc_dma_sync_single_for_cpu, |
229 | .sync_sg_for_cpu = arc_dma_sync_sg_for_cpu, | 274 | .sync_sg_for_cpu = arc_dma_sync_sg_for_cpu, |
diff --git a/arch/arc/mm/tlb.c b/arch/arc/mm/tlb.c index d0126fdfe2d8..b181f3ee38aa 100644 --- a/arch/arc/mm/tlb.c +++ b/arch/arc/mm/tlb.c | |||
@@ -104,6 +104,8 @@ | |||
104 | /* A copy of the ASID from the PID reg is kept in asid_cache */ | 104 | /* A copy of the ASID from the PID reg is kept in asid_cache */ |
105 | DEFINE_PER_CPU(unsigned int, asid_cache) = MM_CTXT_FIRST_CYCLE; | 105 | DEFINE_PER_CPU(unsigned int, asid_cache) = MM_CTXT_FIRST_CYCLE; |
106 | 106 | ||
107 | static int __read_mostly pae_exists; | ||
108 | |||
107 | /* | 109 | /* |
108 | * Utility Routine to erase a J-TLB entry | 110 | * Utility Routine to erase a J-TLB entry |
109 | * Caller needs to setup Index Reg (manually or via getIndex) | 111 | * Caller needs to setup Index Reg (manually or via getIndex) |
@@ -784,7 +786,7 @@ void read_decode_mmu_bcr(void) | |||
784 | mmu->u_dtlb = mmu4->u_dtlb * 4; | 786 | mmu->u_dtlb = mmu4->u_dtlb * 4; |
785 | mmu->u_itlb = mmu4->u_itlb * 4; | 787 | mmu->u_itlb = mmu4->u_itlb * 4; |
786 | mmu->sasid = mmu4->sasid; | 788 | mmu->sasid = mmu4->sasid; |
787 | mmu->pae = mmu4->pae; | 789 | pae_exists = mmu->pae = mmu4->pae; |
788 | } | 790 | } |
789 | } | 791 | } |
790 | 792 | ||
@@ -809,6 +811,11 @@ char *arc_mmu_mumbojumbo(int cpu_id, char *buf, int len) | |||
809 | return buf; | 811 | return buf; |
810 | } | 812 | } |
811 | 813 | ||
814 | int pae40_exist_but_not_enab(void) | ||
815 | { | ||
816 | return pae_exists && !is_pae40_enabled(); | ||
817 | } | ||
818 | |||
812 | void arc_mmu_init(void) | 819 | void arc_mmu_init(void) |
813 | { | 820 | { |
814 | char str[256]; | 821 | char str[256]; |
@@ -859,6 +866,9 @@ void arc_mmu_init(void) | |||
859 | /* swapper_pg_dir is the pgd for the kernel, used by vmalloc */ | 866 | /* swapper_pg_dir is the pgd for the kernel, used by vmalloc */ |
860 | write_aux_reg(ARC_REG_SCRATCH_DATA0, swapper_pg_dir); | 867 | write_aux_reg(ARC_REG_SCRATCH_DATA0, swapper_pg_dir); |
861 | #endif | 868 | #endif |
869 | |||
870 | if (pae40_exist_but_not_enab()) | ||
871 | write_aux_reg(ARC_REG_TLBPD1HI, 0); | ||
862 | } | 872 | } |
863 | 873 | ||
864 | /* | 874 | /* |
diff --git a/arch/arc/plat-sim/Kconfig b/arch/arc/plat-sim/Kconfig deleted file mode 100644 index ac6af96a82f3..000000000000 --- a/arch/arc/plat-sim/Kconfig +++ /dev/null | |||
@@ -1,13 +0,0 @@ | |||
1 | # | ||
2 | # Copyright (C) 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com) | ||
3 | # | ||
4 | # This program is free software; you can redistribute it and/or modify | ||
5 | # it under the terms of the GNU General Public License version 2 as | ||
6 | # published by the Free Software Foundation. | ||
7 | # | ||
8 | |||
9 | menuconfig ARC_PLAT_SIM | ||
10 | bool "ARC nSIM based simulation virtual platforms" | ||
11 | help | ||
12 | Support for nSIM based ARC simulation platforms | ||
13 | This includes the standalone nSIM (uart only) vs. System C OSCI VP | ||
diff --git a/arch/arc/plat-sim/platform.c b/arch/arc/plat-sim/platform.c index aea87389e44b..5cda56b1a2ea 100644 --- a/arch/arc/plat-sim/platform.c +++ b/arch/arc/plat-sim/platform.c | |||
@@ -20,11 +20,14 @@ | |||
20 | */ | 20 | */ |
21 | 21 | ||
22 | static const char *simulation_compat[] __initconst = { | 22 | static const char *simulation_compat[] __initconst = { |
23 | #ifdef CONFIG_ISA_ARCOMPACT | ||
23 | "snps,nsim", | 24 | "snps,nsim", |
24 | "snps,nsim_hs", | ||
25 | "snps,nsimosci", | 25 | "snps,nsimosci", |
26 | #else | ||
27 | "snps,nsim_hs", | ||
26 | "snps,nsimosci_hs", | 28 | "snps,nsimosci_hs", |
27 | "snps,zebu_hs", | 29 | "snps,zebu_hs", |
30 | #endif | ||
28 | NULL, | 31 | NULL, |
29 | }; | 32 | }; |
30 | 33 | ||
diff --git a/arch/arm/boot/dts/exynos5422-odroidxu3-common.dtsi b/arch/arm/boot/dts/exynos5422-odroidxu3-common.dtsi index f92f95741207..a183b56283f8 100644 --- a/arch/arm/boot/dts/exynos5422-odroidxu3-common.dtsi +++ b/arch/arm/boot/dts/exynos5422-odroidxu3-common.dtsi | |||
@@ -266,6 +266,7 @@ | |||
266 | 266 | ||
267 | &hdmicec { | 267 | &hdmicec { |
268 | status = "okay"; | 268 | status = "okay"; |
269 | needs-hpd; | ||
269 | }; | 270 | }; |
270 | 271 | ||
271 | &hsi2c_4 { | 272 | &hsi2c_4 { |
diff --git a/arch/arm/boot/dts/imx25.dtsi b/arch/arm/boot/dts/imx25.dtsi index dfcc8e00cf1c..0ade3619f3c3 100644 --- a/arch/arm/boot/dts/imx25.dtsi +++ b/arch/arm/boot/dts/imx25.dtsi | |||
@@ -297,6 +297,7 @@ | |||
297 | #address-cells = <1>; | 297 | #address-cells = <1>; |
298 | #size-cells = <1>; | 298 | #size-cells = <1>; |
299 | status = "disabled"; | 299 | status = "disabled"; |
300 | ranges; | ||
300 | 301 | ||
301 | adc: adc@50030800 { | 302 | adc: adc@50030800 { |
302 | compatible = "fsl,imx25-gcq"; | 303 | compatible = "fsl,imx25-gcq"; |
diff --git a/arch/arm/boot/dts/imx6qdl-nitrogen6_som2.dtsi b/arch/arm/boot/dts/imx6qdl-nitrogen6_som2.dtsi index aeaa5a6e4fcf..a24e4f1911ab 100644 --- a/arch/arm/boot/dts/imx6qdl-nitrogen6_som2.dtsi +++ b/arch/arm/boot/dts/imx6qdl-nitrogen6_som2.dtsi | |||
@@ -507,7 +507,7 @@ | |||
507 | pinctrl_pcie: pciegrp { | 507 | pinctrl_pcie: pciegrp { |
508 | fsl,pins = < | 508 | fsl,pins = < |
509 | /* PCIe reset */ | 509 | /* PCIe reset */ |
510 | MX6QDL_PAD_EIM_BCLK__GPIO6_IO31 0x030b0 | 510 | MX6QDL_PAD_EIM_DA0__GPIO3_IO00 0x030b0 |
511 | MX6QDL_PAD_EIM_DA4__GPIO3_IO04 0x030b0 | 511 | MX6QDL_PAD_EIM_DA4__GPIO3_IO04 0x030b0 |
512 | >; | 512 | >; |
513 | }; | 513 | }; |
@@ -668,7 +668,7 @@ | |||
668 | &pcie { | 668 | &pcie { |
669 | pinctrl-names = "default"; | 669 | pinctrl-names = "default"; |
670 | pinctrl-0 = <&pinctrl_pcie>; | 670 | pinctrl-0 = <&pinctrl_pcie>; |
671 | reset-gpio = <&gpio6 31 GPIO_ACTIVE_LOW>; | 671 | reset-gpio = <&gpio3 0 GPIO_ACTIVE_LOW>; |
672 | status = "okay"; | 672 | status = "okay"; |
673 | }; | 673 | }; |
674 | 674 | ||
diff --git a/arch/arm/boot/dts/imx7d-sdb.dts b/arch/arm/boot/dts/imx7d-sdb.dts index 54c45402286b..0a24d1bf3c39 100644 --- a/arch/arm/boot/dts/imx7d-sdb.dts +++ b/arch/arm/boot/dts/imx7d-sdb.dts | |||
@@ -557,6 +557,14 @@ | |||
557 | >; | 557 | >; |
558 | }; | 558 | }; |
559 | 559 | ||
560 | pinctrl_spi4: spi4grp { | ||
561 | fsl,pins = < | ||
562 | MX7D_PAD_GPIO1_IO09__GPIO1_IO9 0x59 | ||
563 | MX7D_PAD_GPIO1_IO12__GPIO1_IO12 0x59 | ||
564 | MX7D_PAD_GPIO1_IO13__GPIO1_IO13 0x59 | ||
565 | >; | ||
566 | }; | ||
567 | |||
560 | pinctrl_tsc2046_pendown: tsc2046_pendown { | 568 | pinctrl_tsc2046_pendown: tsc2046_pendown { |
561 | fsl,pins = < | 569 | fsl,pins = < |
562 | MX7D_PAD_EPDC_BDR1__GPIO2_IO29 0x59 | 570 | MX7D_PAD_EPDC_BDR1__GPIO2_IO29 0x59 |
@@ -697,13 +705,5 @@ | |||
697 | fsl,pins = < | 705 | fsl,pins = < |
698 | MX7D_PAD_LPSR_GPIO1_IO01__PWM1_OUT 0x110b0 | 706 | MX7D_PAD_LPSR_GPIO1_IO01__PWM1_OUT 0x110b0 |
699 | >; | 707 | >; |
700 | |||
701 | pinctrl_spi4: spi4grp { | ||
702 | fsl,pins = < | ||
703 | MX7D_PAD_GPIO1_IO09__GPIO1_IO9 0x59 | ||
704 | MX7D_PAD_GPIO1_IO12__GPIO1_IO12 0x59 | ||
705 | MX7D_PAD_GPIO1_IO13__GPIO1_IO13 0x59 | ||
706 | >; | ||
707 | }; | ||
708 | }; | 708 | }; |
709 | }; | 709 | }; |
diff --git a/arch/arm/boot/dts/sama5d2.dtsi b/arch/arm/boot/dts/sama5d2.dtsi index cc06da394366..60e69aeacbdb 100644 --- a/arch/arm/boot/dts/sama5d2.dtsi +++ b/arch/arm/boot/dts/sama5d2.dtsi | |||
@@ -303,7 +303,7 @@ | |||
303 | #size-cells = <1>; | 303 | #size-cells = <1>; |
304 | atmel,smc = <&hsmc>; | 304 | atmel,smc = <&hsmc>; |
305 | reg = <0x10000000 0x10000000 | 305 | reg = <0x10000000 0x10000000 |
306 | 0x40000000 0x30000000>; | 306 | 0x60000000 0x30000000>; |
307 | ranges = <0x0 0x0 0x10000000 0x10000000 | 307 | ranges = <0x0 0x0 0x10000000 0x10000000 |
308 | 0x1 0x0 0x60000000 0x10000000 | 308 | 0x1 0x0 0x60000000 0x10000000 |
309 | 0x2 0x0 0x70000000 0x10000000 | 309 | 0x2 0x0 0x70000000 0x10000000 |
@@ -1048,18 +1048,18 @@ | |||
1048 | }; | 1048 | }; |
1049 | 1049 | ||
1050 | hsmc: hsmc@f8014000 { | 1050 | hsmc: hsmc@f8014000 { |
1051 | compatible = "atmel,sama5d3-smc", "syscon", "simple-mfd"; | 1051 | compatible = "atmel,sama5d2-smc", "syscon", "simple-mfd"; |
1052 | reg = <0xf8014000 0x1000>; | 1052 | reg = <0xf8014000 0x1000>; |
1053 | interrupts = <5 IRQ_TYPE_LEVEL_HIGH 6>; | 1053 | interrupts = <17 IRQ_TYPE_LEVEL_HIGH 6>; |
1054 | clocks = <&hsmc_clk>; | 1054 | clocks = <&hsmc_clk>; |
1055 | #address-cells = <1>; | 1055 | #address-cells = <1>; |
1056 | #size-cells = <1>; | 1056 | #size-cells = <1>; |
1057 | ranges; | 1057 | ranges; |
1058 | 1058 | ||
1059 | pmecc: ecc-engine@ffffc070 { | 1059 | pmecc: ecc-engine@f8014070 { |
1060 | compatible = "atmel,sama5d2-pmecc"; | 1060 | compatible = "atmel,sama5d2-pmecc"; |
1061 | reg = <0xffffc070 0x490>, | 1061 | reg = <0xf8014070 0x490>, |
1062 | <0xffffc500 0x100>; | 1062 | <0xf8014500 0x100>; |
1063 | }; | 1063 | }; |
1064 | }; | 1064 | }; |
1065 | 1065 | ||
diff --git a/arch/arm/include/asm/tlb.h b/arch/arm/include/asm/tlb.h index 3f2eb76243e3..d5562f9ce600 100644 --- a/arch/arm/include/asm/tlb.h +++ b/arch/arm/include/asm/tlb.h | |||
@@ -148,7 +148,8 @@ static inline void tlb_flush_mmu(struct mmu_gather *tlb) | |||
148 | } | 148 | } |
149 | 149 | ||
150 | static inline void | 150 | static inline void |
151 | tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, unsigned long start, unsigned long end) | 151 | arch_tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, |
152 | unsigned long start, unsigned long end) | ||
152 | { | 153 | { |
153 | tlb->mm = mm; | 154 | tlb->mm = mm; |
154 | tlb->fullmm = !(start | (end+1)); | 155 | tlb->fullmm = !(start | (end+1)); |
@@ -166,8 +167,14 @@ tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, unsigned long start | |||
166 | } | 167 | } |
167 | 168 | ||
168 | static inline void | 169 | static inline void |
169 | tlb_finish_mmu(struct mmu_gather *tlb, unsigned long start, unsigned long end) | 170 | arch_tlb_finish_mmu(struct mmu_gather *tlb, |
171 | unsigned long start, unsigned long end, bool force) | ||
170 | { | 172 | { |
173 | if (force) { | ||
174 | tlb->range_start = start; | ||
175 | tlb->range_end = end; | ||
176 | } | ||
177 | |||
171 | tlb_flush_mmu(tlb); | 178 | tlb_flush_mmu(tlb); |
172 | 179 | ||
173 | /* keep the page table cache within bounds */ | 180 | /* keep the page table cache within bounds */ |
diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig index d735e5fc4772..195da38cb9a2 100644 --- a/arch/arm/mach-at91/Kconfig +++ b/arch/arm/mach-at91/Kconfig | |||
@@ -1,7 +1,7 @@ | |||
1 | menuconfig ARCH_AT91 | 1 | menuconfig ARCH_AT91 |
2 | bool "Atmel SoCs" | 2 | bool "Atmel SoCs" |
3 | depends on ARCH_MULTI_V4T || ARCH_MULTI_V5 || ARCH_MULTI_V7 || ARM_SINGLE_ARMV7M | 3 | depends on ARCH_MULTI_V4T || ARCH_MULTI_V5 || ARCH_MULTI_V7 || ARM_SINGLE_ARMV7M |
4 | select ARM_CPU_SUSPEND if PM | 4 | select ARM_CPU_SUSPEND if PM && ARCH_MULTI_V7 |
5 | select COMMON_CLK_AT91 | 5 | select COMMON_CLK_AT91 |
6 | select GPIOLIB | 6 | select GPIOLIB |
7 | select PINCTRL | 7 | select PINCTRL |
diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c index 667fddac3856..5036f996e694 100644 --- a/arch/arm/mach-at91/pm.c +++ b/arch/arm/mach-at91/pm.c | |||
@@ -608,6 +608,9 @@ static void __init at91_pm_init(void (*pm_idle)(void)) | |||
608 | 608 | ||
609 | void __init at91rm9200_pm_init(void) | 609 | void __init at91rm9200_pm_init(void) |
610 | { | 610 | { |
611 | if (!IS_ENABLED(CONFIG_SOC_AT91RM9200)) | ||
612 | return; | ||
613 | |||
611 | at91_dt_ramc(); | 614 | at91_dt_ramc(); |
612 | 615 | ||
613 | /* | 616 | /* |
@@ -620,18 +623,27 @@ void __init at91rm9200_pm_init(void) | |||
620 | 623 | ||
621 | void __init at91sam9_pm_init(void) | 624 | void __init at91sam9_pm_init(void) |
622 | { | 625 | { |
626 | if (!IS_ENABLED(CONFIG_SOC_AT91SAM9)) | ||
627 | return; | ||
628 | |||
623 | at91_dt_ramc(); | 629 | at91_dt_ramc(); |
624 | at91_pm_init(at91sam9_idle); | 630 | at91_pm_init(at91sam9_idle); |
625 | } | 631 | } |
626 | 632 | ||
627 | void __init sama5_pm_init(void) | 633 | void __init sama5_pm_init(void) |
628 | { | 634 | { |
635 | if (!IS_ENABLED(CONFIG_SOC_SAMA5)) | ||
636 | return; | ||
637 | |||
629 | at91_dt_ramc(); | 638 | at91_dt_ramc(); |
630 | at91_pm_init(NULL); | 639 | at91_pm_init(NULL); |
631 | } | 640 | } |
632 | 641 | ||
633 | void __init sama5d2_pm_init(void) | 642 | void __init sama5d2_pm_init(void) |
634 | { | 643 | { |
644 | if (!IS_ENABLED(CONFIG_SOC_SAMA5D2)) | ||
645 | return; | ||
646 | |||
635 | at91_pm_backup_init(); | 647 | at91_pm_backup_init(); |
636 | sama5_pm_init(); | 648 | sama5_pm_init(); |
637 | } | 649 | } |
diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64-bananapi-m64.dts b/arch/arm64/boot/dts/allwinner/sun50i-a64-bananapi-m64.dts index 0d1f026d831a..ba2fde2909f9 100644 --- a/arch/arm64/boot/dts/allwinner/sun50i-a64-bananapi-m64.dts +++ b/arch/arm64/boot/dts/allwinner/sun50i-a64-bananapi-m64.dts | |||
@@ -51,6 +51,7 @@ | |||
51 | compatible = "sinovoip,bananapi-m64", "allwinner,sun50i-a64"; | 51 | compatible = "sinovoip,bananapi-m64", "allwinner,sun50i-a64"; |
52 | 52 | ||
53 | aliases { | 53 | aliases { |
54 | ethernet0 = &emac; | ||
54 | serial0 = &uart0; | 55 | serial0 = &uart0; |
55 | serial1 = &uart1; | 56 | serial1 = &uart1; |
56 | }; | 57 | }; |
diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64-pine64.dts b/arch/arm64/boot/dts/allwinner/sun50i-a64-pine64.dts index 08cda24ea194..827168bc22ed 100644 --- a/arch/arm64/boot/dts/allwinner/sun50i-a64-pine64.dts +++ b/arch/arm64/boot/dts/allwinner/sun50i-a64-pine64.dts | |||
@@ -51,6 +51,7 @@ | |||
51 | compatible = "pine64,pine64", "allwinner,sun50i-a64"; | 51 | compatible = "pine64,pine64", "allwinner,sun50i-a64"; |
52 | 52 | ||
53 | aliases { | 53 | aliases { |
54 | ethernet0 = &emac; | ||
54 | serial0 = &uart0; | 55 | serial0 = &uart0; |
55 | serial1 = &uart1; | 56 | serial1 = &uart1; |
56 | serial2 = &uart2; | 57 | serial2 = &uart2; |
diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64-sopine-baseboard.dts b/arch/arm64/boot/dts/allwinner/sun50i-a64-sopine-baseboard.dts index 17eb1cc5bf6b..216e3a5dafae 100644 --- a/arch/arm64/boot/dts/allwinner/sun50i-a64-sopine-baseboard.dts +++ b/arch/arm64/boot/dts/allwinner/sun50i-a64-sopine-baseboard.dts | |||
@@ -53,6 +53,7 @@ | |||
53 | "allwinner,sun50i-a64"; | 53 | "allwinner,sun50i-a64"; |
54 | 54 | ||
55 | aliases { | 55 | aliases { |
56 | ethernet0 = &emac; | ||
56 | serial0 = &uart0; | 57 | serial0 = &uart0; |
57 | }; | 58 | }; |
58 | 59 | ||
diff --git a/arch/arm64/boot/dts/allwinner/sun50i-h5.dtsi b/arch/arm64/boot/dts/allwinner/sun50i-h5.dtsi index 732e2e06f503..d9a720bff05d 100644 --- a/arch/arm64/boot/dts/allwinner/sun50i-h5.dtsi +++ b/arch/arm64/boot/dts/allwinner/sun50i-h5.dtsi | |||
@@ -120,5 +120,8 @@ | |||
120 | }; | 120 | }; |
121 | 121 | ||
122 | &pio { | 122 | &pio { |
123 | interrupts = <GIC_SPI 11 IRQ_TYPE_LEVEL_HIGH>, | ||
124 | <GIC_SPI 17 IRQ_TYPE_LEVEL_HIGH>, | ||
125 | <GIC_SPI 23 IRQ_TYPE_LEVEL_HIGH>; | ||
123 | compatible = "allwinner,sun50i-h5-pinctrl"; | 126 | compatible = "allwinner,sun50i-h5-pinctrl"; |
124 | }; | 127 | }; |
diff --git a/arch/arm64/boot/dts/renesas/salvator-common.dtsi b/arch/arm64/boot/dts/renesas/salvator-common.dtsi index a451996f590a..f903957da504 100644 --- a/arch/arm64/boot/dts/renesas/salvator-common.dtsi +++ b/arch/arm64/boot/dts/renesas/salvator-common.dtsi | |||
@@ -45,7 +45,7 @@ | |||
45 | stdout-path = "serial0:115200n8"; | 45 | stdout-path = "serial0:115200n8"; |
46 | }; | 46 | }; |
47 | 47 | ||
48 | audio_clkout: audio_clkout { | 48 | audio_clkout: audio-clkout { |
49 | /* | 49 | /* |
50 | * This is same as <&rcar_sound 0> | 50 | * This is same as <&rcar_sound 0> |
51 | * but needed to avoid cs2000/rcar_sound probe dead-lock | 51 | * but needed to avoid cs2000/rcar_sound probe dead-lock |
diff --git a/arch/arm64/include/asm/arch_timer.h b/arch/arm64/include/asm/arch_timer.h index 74d08e44a651..a652ce0a5cb2 100644 --- a/arch/arm64/include/asm/arch_timer.h +++ b/arch/arm64/include/asm/arch_timer.h | |||
@@ -65,13 +65,13 @@ DECLARE_PER_CPU(const struct arch_timer_erratum_workaround *, | |||
65 | u64 _val; \ | 65 | u64 _val; \ |
66 | if (needs_unstable_timer_counter_workaround()) { \ | 66 | if (needs_unstable_timer_counter_workaround()) { \ |
67 | const struct arch_timer_erratum_workaround *wa; \ | 67 | const struct arch_timer_erratum_workaround *wa; \ |
68 | preempt_disable(); \ | 68 | preempt_disable_notrace(); \ |
69 | wa = __this_cpu_read(timer_unstable_counter_workaround); \ | 69 | wa = __this_cpu_read(timer_unstable_counter_workaround); \ |
70 | if (wa && wa->read_##reg) \ | 70 | if (wa && wa->read_##reg) \ |
71 | _val = wa->read_##reg(); \ | 71 | _val = wa->read_##reg(); \ |
72 | else \ | 72 | else \ |
73 | _val = read_sysreg(reg); \ | 73 | _val = read_sysreg(reg); \ |
74 | preempt_enable(); \ | 74 | preempt_enable_notrace(); \ |
75 | } else { \ | 75 | } else { \ |
76 | _val = read_sysreg(reg); \ | 76 | _val = read_sysreg(reg); \ |
77 | } \ | 77 | } \ |
diff --git a/arch/arm64/include/asm/elf.h b/arch/arm64/include/asm/elf.h index acae781f7359..3288c2b36731 100644 --- a/arch/arm64/include/asm/elf.h +++ b/arch/arm64/include/asm/elf.h | |||
@@ -114,10 +114,10 @@ | |||
114 | 114 | ||
115 | /* | 115 | /* |
116 | * This is the base location for PIE (ET_DYN with INTERP) loads. On | 116 | * This is the base location for PIE (ET_DYN with INTERP) loads. On |
117 | * 64-bit, this is raised to 4GB to leave the entire 32-bit address | 117 | * 64-bit, this is above 4GB to leave the entire 32-bit address |
118 | * space open for things that want to use the area for 32-bit pointers. | 118 | * space open for things that want to use the area for 32-bit pointers. |
119 | */ | 119 | */ |
120 | #define ELF_ET_DYN_BASE 0x100000000UL | 120 | #define ELF_ET_DYN_BASE (2 * TASK_SIZE_64 / 3) |
121 | 121 | ||
122 | #ifndef __ASSEMBLY__ | 122 | #ifndef __ASSEMBLY__ |
123 | 123 | ||
diff --git a/arch/arm64/kernel/fpsimd.c b/arch/arm64/kernel/fpsimd.c index 06da8ea16bbe..c7b4995868e1 100644 --- a/arch/arm64/kernel/fpsimd.c +++ b/arch/arm64/kernel/fpsimd.c | |||
@@ -161,9 +161,11 @@ void fpsimd_flush_thread(void) | |||
161 | { | 161 | { |
162 | if (!system_supports_fpsimd()) | 162 | if (!system_supports_fpsimd()) |
163 | return; | 163 | return; |
164 | preempt_disable(); | ||
164 | memset(¤t->thread.fpsimd_state, 0, sizeof(struct fpsimd_state)); | 165 | memset(¤t->thread.fpsimd_state, 0, sizeof(struct fpsimd_state)); |
165 | fpsimd_flush_task_state(current); | 166 | fpsimd_flush_task_state(current); |
166 | set_thread_flag(TIF_FOREIGN_FPSTATE); | 167 | set_thread_flag(TIF_FOREIGN_FPSTATE); |
168 | preempt_enable(); | ||
167 | } | 169 | } |
168 | 170 | ||
169 | /* | 171 | /* |
diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S index 973df7de7bf8..adb0910b88f5 100644 --- a/arch/arm64/kernel/head.S +++ b/arch/arm64/kernel/head.S | |||
@@ -354,7 +354,6 @@ __primary_switched: | |||
354 | tst x23, ~(MIN_KIMG_ALIGN - 1) // already running randomized? | 354 | tst x23, ~(MIN_KIMG_ALIGN - 1) // already running randomized? |
355 | b.ne 0f | 355 | b.ne 0f |
356 | mov x0, x21 // pass FDT address in x0 | 356 | mov x0, x21 // pass FDT address in x0 |
357 | mov x1, x23 // pass modulo offset in x1 | ||
358 | bl kaslr_early_init // parse FDT for KASLR options | 357 | bl kaslr_early_init // parse FDT for KASLR options |
359 | cbz x0, 0f // KASLR disabled? just proceed | 358 | cbz x0, 0f // KASLR disabled? just proceed |
360 | orr x23, x23, x0 // record KASLR offset | 359 | orr x23, x23, x0 // record KASLR offset |
diff --git a/arch/arm64/kernel/kaslr.c b/arch/arm64/kernel/kaslr.c index a9710efb8c01..47080c49cc7e 100644 --- a/arch/arm64/kernel/kaslr.c +++ b/arch/arm64/kernel/kaslr.c | |||
@@ -75,7 +75,7 @@ extern void *__init __fixmap_remap_fdt(phys_addr_t dt_phys, int *size, | |||
75 | * containing function pointers) to be reinitialized, and zero-initialized | 75 | * containing function pointers) to be reinitialized, and zero-initialized |
76 | * .bss variables will be reset to 0. | 76 | * .bss variables will be reset to 0. |
77 | */ | 77 | */ |
78 | u64 __init kaslr_early_init(u64 dt_phys, u64 modulo_offset) | 78 | u64 __init kaslr_early_init(u64 dt_phys) |
79 | { | 79 | { |
80 | void *fdt; | 80 | void *fdt; |
81 | u64 seed, offset, mask, module_range; | 81 | u64 seed, offset, mask, module_range; |
@@ -131,15 +131,17 @@ u64 __init kaslr_early_init(u64 dt_phys, u64 modulo_offset) | |||
131 | /* | 131 | /* |
132 | * The kernel Image should not extend across a 1GB/32MB/512MB alignment | 132 | * The kernel Image should not extend across a 1GB/32MB/512MB alignment |
133 | * boundary (for 4KB/16KB/64KB granule kernels, respectively). If this | 133 | * boundary (for 4KB/16KB/64KB granule kernels, respectively). If this |
134 | * happens, increase the KASLR offset by the size of the kernel image | 134 | * happens, round down the KASLR offset by (1 << SWAPPER_TABLE_SHIFT). |
135 | * rounded up by SWAPPER_BLOCK_SIZE. | 135 | * |
136 | * NOTE: The references to _text and _end below will already take the | ||
137 | * modulo offset (the physical displacement modulo 2 MB) into | ||
138 | * account, given that the physical placement is controlled by | ||
139 | * the loader, and will not change as a result of the virtual | ||
140 | * mapping we choose. | ||
136 | */ | 141 | */ |
137 | if ((((u64)_text + offset + modulo_offset) >> SWAPPER_TABLE_SHIFT) != | 142 | if ((((u64)_text + offset) >> SWAPPER_TABLE_SHIFT) != |
138 | (((u64)_end + offset + modulo_offset) >> SWAPPER_TABLE_SHIFT)) { | 143 | (((u64)_end + offset) >> SWAPPER_TABLE_SHIFT)) |
139 | u64 kimg_sz = _end - _text; | 144 | offset = round_down(offset, 1 << SWAPPER_TABLE_SHIFT); |
140 | offset = (offset + round_up(kimg_sz, SWAPPER_BLOCK_SIZE)) | ||
141 | & mask; | ||
142 | } | ||
143 | 145 | ||
144 | if (IS_ENABLED(CONFIG_KASAN)) | 146 | if (IS_ENABLED(CONFIG_KASAN)) |
145 | /* | 147 | /* |
diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c index 2509e4fe6992..1f22a41565a3 100644 --- a/arch/arm64/mm/fault.c +++ b/arch/arm64/mm/fault.c | |||
@@ -435,8 +435,11 @@ retry: | |||
435 | * the mmap_sem because it would already be released | 435 | * the mmap_sem because it would already be released |
436 | * in __lock_page_or_retry in mm/filemap.c. | 436 | * in __lock_page_or_retry in mm/filemap.c. |
437 | */ | 437 | */ |
438 | if (fatal_signal_pending(current)) | 438 | if (fatal_signal_pending(current)) { |
439 | if (!user_mode(regs)) | ||
440 | goto no_context; | ||
439 | return 0; | 441 | return 0; |
442 | } | ||
440 | 443 | ||
441 | /* | 444 | /* |
442 | * Clear FAULT_FLAG_ALLOW_RETRY to avoid any risk of | 445 | * Clear FAULT_FLAG_ALLOW_RETRY to avoid any risk of |
diff --git a/arch/ia64/include/asm/acpi.h b/arch/ia64/include/asm/acpi.h index a3d0211970e9..c86a947f5368 100644 --- a/arch/ia64/include/asm/acpi.h +++ b/arch/ia64/include/asm/acpi.h | |||
@@ -112,8 +112,6 @@ static inline void arch_acpi_set_pdc_bits(u32 *buf) | |||
112 | buf[2] |= ACPI_PDC_EST_CAPABILITY_SMP; | 112 | buf[2] |= ACPI_PDC_EST_CAPABILITY_SMP; |
113 | } | 113 | } |
114 | 114 | ||
115 | #define acpi_unlazy_tlb(x) | ||
116 | |||
117 | #ifdef CONFIG_ACPI_NUMA | 115 | #ifdef CONFIG_ACPI_NUMA |
118 | extern cpumask_t early_cpu_possible_map; | 116 | extern cpumask_t early_cpu_possible_map; |
119 | #define for_each_possible_early_cpu(cpu) \ | 117 | #define for_each_possible_early_cpu(cpu) \ |
diff --git a/arch/ia64/include/asm/tlb.h b/arch/ia64/include/asm/tlb.h index fced197b9626..cbe5ac3699bf 100644 --- a/arch/ia64/include/asm/tlb.h +++ b/arch/ia64/include/asm/tlb.h | |||
@@ -168,7 +168,8 @@ static inline void __tlb_alloc_page(struct mmu_gather *tlb) | |||
168 | 168 | ||
169 | 169 | ||
170 | static inline void | 170 | static inline void |
171 | tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, unsigned long start, unsigned long end) | 171 | arch_tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, |
172 | unsigned long start, unsigned long end) | ||
172 | { | 173 | { |
173 | tlb->mm = mm; | 174 | tlb->mm = mm; |
174 | tlb->max = ARRAY_SIZE(tlb->local); | 175 | tlb->max = ARRAY_SIZE(tlb->local); |
@@ -185,8 +186,11 @@ tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, unsigned long start | |||
185 | * collected. | 186 | * collected. |
186 | */ | 187 | */ |
187 | static inline void | 188 | static inline void |
188 | tlb_finish_mmu(struct mmu_gather *tlb, unsigned long start, unsigned long end) | 189 | arch_tlb_finish_mmu(struct mmu_gather *tlb, |
190 | unsigned long start, unsigned long end, bool force) | ||
189 | { | 191 | { |
192 | if (force) | ||
193 | tlb->need_flush = 1; | ||
190 | /* | 194 | /* |
191 | * Note: tlb->nr may be 0 at this point, so we can't rely on tlb->start_addr and | 195 | * Note: tlb->nr may be 0 at this point, so we can't rely on tlb->start_addr and |
192 | * tlb->end_addr. | 196 | * tlb->end_addr. |
diff --git a/arch/ia64/kernel/efi.c b/arch/ia64/kernel/efi.c index 121295637d0d..81416000c5e0 100644 --- a/arch/ia64/kernel/efi.c +++ b/arch/ia64/kernel/efi.c | |||
@@ -757,14 +757,14 @@ efi_memmap_intersects (unsigned long phys_addr, unsigned long size) | |||
757 | return 0; | 757 | return 0; |
758 | } | 758 | } |
759 | 759 | ||
760 | u32 | 760 | int |
761 | efi_mem_type (unsigned long phys_addr) | 761 | efi_mem_type (unsigned long phys_addr) |
762 | { | 762 | { |
763 | efi_memory_desc_t *md = efi_memory_descriptor(phys_addr); | 763 | efi_memory_desc_t *md = efi_memory_descriptor(phys_addr); |
764 | 764 | ||
765 | if (md) | 765 | if (md) |
766 | return md->type; | 766 | return md->type; |
767 | return 0; | 767 | return -EINVAL; |
768 | } | 768 | } |
769 | 769 | ||
770 | u64 | 770 | u64 |
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 8dd20358464f..48d91d5be4e9 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig | |||
@@ -2260,7 +2260,7 @@ config CPU_R4K_CACHE_TLB | |||
2260 | 2260 | ||
2261 | config MIPS_MT_SMP | 2261 | config MIPS_MT_SMP |
2262 | bool "MIPS MT SMP support (1 TC on each available VPE)" | 2262 | bool "MIPS MT SMP support (1 TC on each available VPE)" |
2263 | depends on SYS_SUPPORTS_MULTITHREADING && !CPU_MIPSR6 | 2263 | depends on SYS_SUPPORTS_MULTITHREADING && !CPU_MIPSR6 && !CPU_MICROMIPS |
2264 | select CPU_MIPSR2_IRQ_VI | 2264 | select CPU_MIPSR2_IRQ_VI |
2265 | select CPU_MIPSR2_IRQ_EI | 2265 | select CPU_MIPSR2_IRQ_EI |
2266 | select SYNC_R4K | 2266 | select SYNC_R4K |
diff --git a/arch/mips/Makefile b/arch/mips/Makefile index 04343625b929..bc2708c9ada4 100644 --- a/arch/mips/Makefile +++ b/arch/mips/Makefile | |||
@@ -243,8 +243,21 @@ include arch/mips/Kbuild.platforms | |||
243 | ifdef CONFIG_PHYSICAL_START | 243 | ifdef CONFIG_PHYSICAL_START |
244 | load-y = $(CONFIG_PHYSICAL_START) | 244 | load-y = $(CONFIG_PHYSICAL_START) |
245 | endif | 245 | endif |
246 | entry-y = 0x$(shell $(NM) vmlinux 2>/dev/null \ | 246 | |
247 | entry-noisa-y = 0x$(shell $(NM) vmlinux 2>/dev/null \ | ||
247 | | grep "\bkernel_entry\b" | cut -f1 -d \ ) | 248 | | grep "\bkernel_entry\b" | cut -f1 -d \ ) |
249 | ifdef CONFIG_CPU_MICROMIPS | ||
250 | # | ||
251 | # Set the ISA bit, since the kernel_entry symbol in the ELF will have it | ||
252 | # clear which would lead to images containing addresses which bootloaders may | ||
253 | # jump to as MIPS32 code. | ||
254 | # | ||
255 | entry-y = $(patsubst %0,%1,$(patsubst %2,%3,$(patsubst %4,%5, \ | ||
256 | $(patsubst %6,%7,$(patsubst %8,%9,$(patsubst %a,%b, \ | ||
257 | $(patsubst %c,%d,$(patsubst %e,%f,$(entry-noisa-y))))))))) | ||
258 | else | ||
259 | entry-y = $(entry-noisa-y) | ||
260 | endif | ||
248 | 261 | ||
249 | cflags-y += -I$(srctree)/arch/mips/include/asm/mach-generic | 262 | cflags-y += -I$(srctree)/arch/mips/include/asm/mach-generic |
250 | drivers-$(CONFIG_PCI) += arch/mips/pci/ | 263 | drivers-$(CONFIG_PCI) += arch/mips/pci/ |
diff --git a/arch/mips/boot/compressed/.gitignore b/arch/mips/boot/compressed/.gitignore new file mode 100644 index 000000000000..ebae133f1d00 --- /dev/null +++ b/arch/mips/boot/compressed/.gitignore | |||
@@ -0,0 +1,2 @@ | |||
1 | ashldi3.c | ||
2 | bswapsi.c | ||
diff --git a/arch/mips/cavium-octeon/octeon-usb.c b/arch/mips/cavium-octeon/octeon-usb.c index 542be1cd0f32..bfdfaf32d2c4 100644 --- a/arch/mips/cavium-octeon/octeon-usb.c +++ b/arch/mips/cavium-octeon/octeon-usb.c | |||
@@ -13,9 +13,9 @@ | |||
13 | #include <linux/mutex.h> | 13 | #include <linux/mutex.h> |
14 | #include <linux/delay.h> | 14 | #include <linux/delay.h> |
15 | #include <linux/of_platform.h> | 15 | #include <linux/of_platform.h> |
16 | #include <linux/io.h> | ||
16 | 17 | ||
17 | #include <asm/octeon/octeon.h> | 18 | #include <asm/octeon/octeon.h> |
18 | #include <asm/octeon/cvmx-gpio-defs.h> | ||
19 | 19 | ||
20 | /* USB Control Register */ | 20 | /* USB Control Register */ |
21 | union cvm_usbdrd_uctl_ctl { | 21 | union cvm_usbdrd_uctl_ctl { |
diff --git a/arch/mips/dec/int-handler.S b/arch/mips/dec/int-handler.S index 1910223a9c02..cea2bb1621e6 100644 --- a/arch/mips/dec/int-handler.S +++ b/arch/mips/dec/int-handler.S | |||
@@ -147,23 +147,12 @@ | |||
147 | * Find irq with highest priority | 147 | * Find irq with highest priority |
148 | */ | 148 | */ |
149 | # open coded PTR_LA t1, cpu_mask_nr_tbl | 149 | # open coded PTR_LA t1, cpu_mask_nr_tbl |
150 | #if (_MIPS_SZPTR == 32) | 150 | #if defined(CONFIG_32BIT) || defined(KBUILD_64BIT_SYM32) |
151 | # open coded la t1, cpu_mask_nr_tbl | 151 | # open coded la t1, cpu_mask_nr_tbl |
152 | lui t1, %hi(cpu_mask_nr_tbl) | 152 | lui t1, %hi(cpu_mask_nr_tbl) |
153 | addiu t1, %lo(cpu_mask_nr_tbl) | 153 | addiu t1, %lo(cpu_mask_nr_tbl) |
154 | 154 | #else | |
155 | #endif | 155 | #error GCC `-msym32' option required for 64-bit DECstation builds |
156 | #if (_MIPS_SZPTR == 64) | ||
157 | # open coded dla t1, cpu_mask_nr_tbl | ||
158 | .set push | ||
159 | .set noat | ||
160 | lui t1, %highest(cpu_mask_nr_tbl) | ||
161 | lui AT, %hi(cpu_mask_nr_tbl) | ||
162 | daddiu t1, t1, %higher(cpu_mask_nr_tbl) | ||
163 | daddiu AT, AT, %lo(cpu_mask_nr_tbl) | ||
164 | dsll t1, 32 | ||
165 | daddu t1, t1, AT | ||
166 | .set pop | ||
167 | #endif | 156 | #endif |
168 | 1: lw t2,(t1) | 157 | 1: lw t2,(t1) |
169 | nop | 158 | nop |
@@ -214,23 +203,12 @@ | |||
214 | * Find irq with highest priority | 203 | * Find irq with highest priority |
215 | */ | 204 | */ |
216 | # open coded PTR_LA t1,asic_mask_nr_tbl | 205 | # open coded PTR_LA t1,asic_mask_nr_tbl |
217 | #if (_MIPS_SZPTR == 32) | 206 | #if defined(CONFIG_32BIT) || defined(KBUILD_64BIT_SYM32) |
218 | # open coded la t1, asic_mask_nr_tbl | 207 | # open coded la t1, asic_mask_nr_tbl |
219 | lui t1, %hi(asic_mask_nr_tbl) | 208 | lui t1, %hi(asic_mask_nr_tbl) |
220 | addiu t1, %lo(asic_mask_nr_tbl) | 209 | addiu t1, %lo(asic_mask_nr_tbl) |
221 | 210 | #else | |
222 | #endif | 211 | #error GCC `-msym32' option required for 64-bit DECstation builds |
223 | #if (_MIPS_SZPTR == 64) | ||
224 | # open coded dla t1, asic_mask_nr_tbl | ||
225 | .set push | ||
226 | .set noat | ||
227 | lui t1, %highest(asic_mask_nr_tbl) | ||
228 | lui AT, %hi(asic_mask_nr_tbl) | ||
229 | daddiu t1, t1, %higher(asic_mask_nr_tbl) | ||
230 | daddiu AT, AT, %lo(asic_mask_nr_tbl) | ||
231 | dsll t1, 32 | ||
232 | daddu t1, t1, AT | ||
233 | .set pop | ||
234 | #endif | 212 | #endif |
235 | 2: lw t2,(t1) | 213 | 2: lw t2,(t1) |
236 | nop | 214 | nop |
diff --git a/arch/mips/include/asm/cache.h b/arch/mips/include/asm/cache.h index fc67947ed658..8b14c2706aa5 100644 --- a/arch/mips/include/asm/cache.h +++ b/arch/mips/include/asm/cache.h | |||
@@ -9,6 +9,8 @@ | |||
9 | #ifndef _ASM_CACHE_H | 9 | #ifndef _ASM_CACHE_H |
10 | #define _ASM_CACHE_H | 10 | #define _ASM_CACHE_H |
11 | 11 | ||
12 | #include <kmalloc.h> | ||
13 | |||
12 | #define L1_CACHE_SHIFT CONFIG_MIPS_L1_CACHE_SHIFT | 14 | #define L1_CACHE_SHIFT CONFIG_MIPS_L1_CACHE_SHIFT |
13 | #define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT) | 15 | #define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT) |
14 | 16 | ||
diff --git a/arch/mips/include/asm/cpu-features.h b/arch/mips/include/asm/cpu-features.h index 8baa9033b181..721b698bfe3c 100644 --- a/arch/mips/include/asm/cpu-features.h +++ b/arch/mips/include/asm/cpu-features.h | |||
@@ -428,6 +428,9 @@ | |||
428 | #ifndef cpu_scache_line_size | 428 | #ifndef cpu_scache_line_size |
429 | #define cpu_scache_line_size() cpu_data[0].scache.linesz | 429 | #define cpu_scache_line_size() cpu_data[0].scache.linesz |
430 | #endif | 430 | #endif |
431 | #ifndef cpu_tcache_line_size | ||
432 | #define cpu_tcache_line_size() cpu_data[0].tcache.linesz | ||
433 | #endif | ||
431 | 434 | ||
432 | #ifndef cpu_hwrena_impl_bits | 435 | #ifndef cpu_hwrena_impl_bits |
433 | #define cpu_hwrena_impl_bits 0 | 436 | #define cpu_hwrena_impl_bits 0 |
diff --git a/arch/mips/include/asm/octeon/cvmx-l2c-defs.h b/arch/mips/include/asm/octeon/cvmx-l2c-defs.h index d045973ddb33..3ea84acf1814 100644 --- a/arch/mips/include/asm/octeon/cvmx-l2c-defs.h +++ b/arch/mips/include/asm/octeon/cvmx-l2c-defs.h | |||
@@ -33,6 +33,10 @@ | |||
33 | #define CVMX_L2C_DBG (CVMX_ADD_IO_SEG(0x0001180080000030ull)) | 33 | #define CVMX_L2C_DBG (CVMX_ADD_IO_SEG(0x0001180080000030ull)) |
34 | #define CVMX_L2C_CFG (CVMX_ADD_IO_SEG(0x0001180080000000ull)) | 34 | #define CVMX_L2C_CFG (CVMX_ADD_IO_SEG(0x0001180080000000ull)) |
35 | #define CVMX_L2C_CTL (CVMX_ADD_IO_SEG(0x0001180080800000ull)) | 35 | #define CVMX_L2C_CTL (CVMX_ADD_IO_SEG(0x0001180080800000ull)) |
36 | #define CVMX_L2C_ERR_TDTX(block_id) \ | ||
37 | (CVMX_ADD_IO_SEG(0x0001180080A007E0ull) + ((block_id) & 3) * 0x40000ull) | ||
38 | #define CVMX_L2C_ERR_TTGX(block_id) \ | ||
39 | (CVMX_ADD_IO_SEG(0x0001180080A007E8ull) + ((block_id) & 3) * 0x40000ull) | ||
36 | #define CVMX_L2C_LCKBASE (CVMX_ADD_IO_SEG(0x0001180080000058ull)) | 40 | #define CVMX_L2C_LCKBASE (CVMX_ADD_IO_SEG(0x0001180080000058ull)) |
37 | #define CVMX_L2C_LCKOFF (CVMX_ADD_IO_SEG(0x0001180080000060ull)) | 41 | #define CVMX_L2C_LCKOFF (CVMX_ADD_IO_SEG(0x0001180080000060ull)) |
38 | #define CVMX_L2C_PFCTL (CVMX_ADD_IO_SEG(0x0001180080000090ull)) | 42 | #define CVMX_L2C_PFCTL (CVMX_ADD_IO_SEG(0x0001180080000090ull)) |
@@ -66,9 +70,40 @@ | |||
66 | ((offset) & 1) * 8) | 70 | ((offset) & 1) * 8) |
67 | #define CVMX_L2C_WPAR_PPX(offset) (CVMX_ADD_IO_SEG(0x0001180080840000ull) + \ | 71 | #define CVMX_L2C_WPAR_PPX(offset) (CVMX_ADD_IO_SEG(0x0001180080840000ull) + \ |
68 | ((offset) & 31) * 8) | 72 | ((offset) & 31) * 8) |
69 | #define CVMX_L2D_FUS3 (CVMX_ADD_IO_SEG(0x00011800800007B8ull)) | ||
70 | 73 | ||
71 | 74 | ||
75 | union cvmx_l2c_err_tdtx { | ||
76 | uint64_t u64; | ||
77 | struct cvmx_l2c_err_tdtx_s { | ||
78 | __BITFIELD_FIELD(uint64_t dbe:1, | ||
79 | __BITFIELD_FIELD(uint64_t sbe:1, | ||
80 | __BITFIELD_FIELD(uint64_t vdbe:1, | ||
81 | __BITFIELD_FIELD(uint64_t vsbe:1, | ||
82 | __BITFIELD_FIELD(uint64_t syn:10, | ||
83 | __BITFIELD_FIELD(uint64_t reserved_22_49:28, | ||
84 | __BITFIELD_FIELD(uint64_t wayidx:18, | ||
85 | __BITFIELD_FIELD(uint64_t reserved_2_3:2, | ||
86 | __BITFIELD_FIELD(uint64_t type:2, | ||
87 | ;))))))))) | ||
88 | } s; | ||
89 | }; | ||
90 | |||
91 | union cvmx_l2c_err_ttgx { | ||
92 | uint64_t u64; | ||
93 | struct cvmx_l2c_err_ttgx_s { | ||
94 | __BITFIELD_FIELD(uint64_t dbe:1, | ||
95 | __BITFIELD_FIELD(uint64_t sbe:1, | ||
96 | __BITFIELD_FIELD(uint64_t noway:1, | ||
97 | __BITFIELD_FIELD(uint64_t reserved_56_60:5, | ||
98 | __BITFIELD_FIELD(uint64_t syn:6, | ||
99 | __BITFIELD_FIELD(uint64_t reserved_22_49:28, | ||
100 | __BITFIELD_FIELD(uint64_t wayidx:15, | ||
101 | __BITFIELD_FIELD(uint64_t reserved_2_6:5, | ||
102 | __BITFIELD_FIELD(uint64_t type:2, | ||
103 | ;))))))))) | ||
104 | } s; | ||
105 | }; | ||
106 | |||
72 | union cvmx_l2c_cfg { | 107 | union cvmx_l2c_cfg { |
73 | uint64_t u64; | 108 | uint64_t u64; |
74 | struct cvmx_l2c_cfg_s { | 109 | struct cvmx_l2c_cfg_s { |
diff --git a/arch/mips/include/asm/octeon/cvmx-l2d-defs.h b/arch/mips/include/asm/octeon/cvmx-l2d-defs.h new file mode 100644 index 000000000000..a951ad5d65ad --- /dev/null +++ b/arch/mips/include/asm/octeon/cvmx-l2d-defs.h | |||
@@ -0,0 +1,60 @@ | |||
1 | /***********************license start*************** | ||
2 | * Author: Cavium Networks | ||
3 | * | ||
4 | * Contact: support@caviumnetworks.com | ||
5 | * This file is part of the OCTEON SDK | ||
6 | * | ||
7 | * Copyright (c) 2003-2017 Cavium, Inc. | ||
8 | * | ||
9 | * This file is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License, Version 2, as | ||
11 | * published by the Free Software Foundation. | ||
12 | * | ||
13 | * This file is distributed in the hope that it will be useful, but | ||
14 | * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty | ||
15 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or | ||
16 | * NONINFRINGEMENT. See the GNU General Public License for more | ||
17 | * details. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License | ||
20 | * along with this file; if not, write to the Free Software | ||
21 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
22 | * or visit http://www.gnu.org/licenses/. | ||
23 | * | ||
24 | * This file may also be available under a different license from Cavium. | ||
25 | * Contact Cavium Networks for more information | ||
26 | ***********************license end**************************************/ | ||
27 | |||
28 | #ifndef __CVMX_L2D_DEFS_H__ | ||
29 | #define __CVMX_L2D_DEFS_H__ | ||
30 | |||
31 | #define CVMX_L2D_ERR (CVMX_ADD_IO_SEG(0x0001180080000010ull)) | ||
32 | #define CVMX_L2D_FUS3 (CVMX_ADD_IO_SEG(0x00011800800007B8ull)) | ||
33 | |||
34 | |||
35 | union cvmx_l2d_err { | ||
36 | uint64_t u64; | ||
37 | struct cvmx_l2d_err_s { | ||
38 | __BITFIELD_FIELD(uint64_t reserved_6_63:58, | ||
39 | __BITFIELD_FIELD(uint64_t bmhclsel:1, | ||
40 | __BITFIELD_FIELD(uint64_t ded_err:1, | ||
41 | __BITFIELD_FIELD(uint64_t sec_err:1, | ||
42 | __BITFIELD_FIELD(uint64_t ded_intena:1, | ||
43 | __BITFIELD_FIELD(uint64_t sec_intena:1, | ||
44 | __BITFIELD_FIELD(uint64_t ecc_ena:1, | ||
45 | ;))))))) | ||
46 | } s; | ||
47 | }; | ||
48 | |||
49 | union cvmx_l2d_fus3 { | ||
50 | uint64_t u64; | ||
51 | struct cvmx_l2d_fus3_s { | ||
52 | __BITFIELD_FIELD(uint64_t reserved_40_63:24, | ||
53 | __BITFIELD_FIELD(uint64_t ema_ctl:3, | ||
54 | __BITFIELD_FIELD(uint64_t reserved_34_36:3, | ||
55 | __BITFIELD_FIELD(uint64_t q3fus:34, | ||
56 | ;)))) | ||
57 | } s; | ||
58 | }; | ||
59 | |||
60 | #endif | ||
diff --git a/arch/mips/include/asm/octeon/cvmx.h b/arch/mips/include/asm/octeon/cvmx.h index 9742202f2a32..e638735cc3ac 100644 --- a/arch/mips/include/asm/octeon/cvmx.h +++ b/arch/mips/include/asm/octeon/cvmx.h | |||
@@ -62,6 +62,7 @@ enum cvmx_mips_space { | |||
62 | #include <asm/octeon/cvmx-iob-defs.h> | 62 | #include <asm/octeon/cvmx-iob-defs.h> |
63 | #include <asm/octeon/cvmx-ipd-defs.h> | 63 | #include <asm/octeon/cvmx-ipd-defs.h> |
64 | #include <asm/octeon/cvmx-l2c-defs.h> | 64 | #include <asm/octeon/cvmx-l2c-defs.h> |
65 | #include <asm/octeon/cvmx-l2d-defs.h> | ||
65 | #include <asm/octeon/cvmx-l2t-defs.h> | 66 | #include <asm/octeon/cvmx-l2t-defs.h> |
66 | #include <asm/octeon/cvmx-led-defs.h> | 67 | #include <asm/octeon/cvmx-led-defs.h> |
67 | #include <asm/octeon/cvmx-mio-defs.h> | 68 | #include <asm/octeon/cvmx-mio-defs.h> |
diff --git a/arch/mips/kernel/smp.c b/arch/mips/kernel/smp.c index 770d4d1516cb..6bace7695788 100644 --- a/arch/mips/kernel/smp.c +++ b/arch/mips/kernel/smp.c | |||
@@ -376,9 +376,6 @@ asmlinkage void start_secondary(void) | |||
376 | cpumask_set_cpu(cpu, &cpu_coherent_mask); | 376 | cpumask_set_cpu(cpu, &cpu_coherent_mask); |
377 | notify_cpu_starting(cpu); | 377 | notify_cpu_starting(cpu); |
378 | 378 | ||
379 | complete(&cpu_running); | ||
380 | synchronise_count_slave(cpu); | ||
381 | |||
382 | set_cpu_online(cpu, true); | 379 | set_cpu_online(cpu, true); |
383 | 380 | ||
384 | set_cpu_sibling_map(cpu); | 381 | set_cpu_sibling_map(cpu); |
@@ -386,6 +383,9 @@ asmlinkage void start_secondary(void) | |||
386 | 383 | ||
387 | calculate_cpu_foreign_map(); | 384 | calculate_cpu_foreign_map(); |
388 | 385 | ||
386 | complete(&cpu_running); | ||
387 | synchronise_count_slave(cpu); | ||
388 | |||
389 | /* | 389 | /* |
390 | * irq will be enabled in ->smp_finish(), enabling it too early | 390 | * irq will be enabled in ->smp_finish(), enabling it too early |
391 | * is dangerous. | 391 | * is dangerous. |
diff --git a/arch/mips/mm/uasm-mips.c b/arch/mips/mm/uasm-mips.c index 3f74f6c1f065..9fea6c6bbf49 100644 --- a/arch/mips/mm/uasm-mips.c +++ b/arch/mips/mm/uasm-mips.c | |||
@@ -48,7 +48,7 @@ | |||
48 | 48 | ||
49 | #include "uasm.c" | 49 | #include "uasm.c" |
50 | 50 | ||
51 | static const struct insn const insn_table[insn_invalid] = { | 51 | static const struct insn insn_table[insn_invalid] = { |
52 | [insn_addiu] = {M(addiu_op, 0, 0, 0, 0, 0), RS | RT | SIMM}, | 52 | [insn_addiu] = {M(addiu_op, 0, 0, 0, 0, 0), RS | RT | SIMM}, |
53 | [insn_addu] = {M(spec_op, 0, 0, 0, 0, addu_op), RS | RT | RD}, | 53 | [insn_addu] = {M(spec_op, 0, 0, 0, 0, addu_op), RS | RT | RD}, |
54 | [insn_and] = {M(spec_op, 0, 0, 0, 0, and_op), RS | RT | RD}, | 54 | [insn_and] = {M(spec_op, 0, 0, 0, 0, and_op), RS | RT | RD}, |
diff --git a/arch/mips/pci/pci.c b/arch/mips/pci/pci.c index bd67ac74fe2d..9632436d74d7 100644 --- a/arch/mips/pci/pci.c +++ b/arch/mips/pci/pci.c | |||
@@ -28,16 +28,15 @@ EXPORT_SYMBOL(PCIBIOS_MIN_MEM); | |||
28 | 28 | ||
29 | static int __init pcibios_set_cache_line_size(void) | 29 | static int __init pcibios_set_cache_line_size(void) |
30 | { | 30 | { |
31 | struct cpuinfo_mips *c = ¤t_cpu_data; | ||
32 | unsigned int lsize; | 31 | unsigned int lsize; |
33 | 32 | ||
34 | /* | 33 | /* |
35 | * Set PCI cacheline size to that of the highest level in the | 34 | * Set PCI cacheline size to that of the highest level in the |
36 | * cache hierarchy. | 35 | * cache hierarchy. |
37 | */ | 36 | */ |
38 | lsize = c->dcache.linesz; | 37 | lsize = cpu_dcache_line_size(); |
39 | lsize = c->scache.linesz ? : lsize; | 38 | lsize = cpu_scache_line_size() ? : lsize; |
40 | lsize = c->tcache.linesz ? : lsize; | 39 | lsize = cpu_tcache_line_size() ? : lsize; |
41 | 40 | ||
42 | BUG_ON(!lsize); | 41 | BUG_ON(!lsize); |
43 | 42 | ||
diff --git a/arch/mips/vdso/gettimeofday.c b/arch/mips/vdso/gettimeofday.c index 974276e828b2..e2690d7ca4dd 100644 --- a/arch/mips/vdso/gettimeofday.c +++ b/arch/mips/vdso/gettimeofday.c | |||
@@ -35,7 +35,8 @@ static __always_inline long gettimeofday_fallback(struct timeval *_tv, | |||
35 | " syscall\n" | 35 | " syscall\n" |
36 | : "=r" (ret), "=r" (error) | 36 | : "=r" (ret), "=r" (error) |
37 | : "r" (tv), "r" (tz), "r" (nr) | 37 | : "r" (tv), "r" (tz), "r" (nr) |
38 | : "memory"); | 38 | : "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13", |
39 | "$14", "$15", "$24", "$25", "hi", "lo", "memory"); | ||
39 | 40 | ||
40 | return error ? -ret : ret; | 41 | return error ? -ret : ret; |
41 | } | 42 | } |
@@ -55,7 +56,8 @@ static __always_inline long clock_gettime_fallback(clockid_t _clkid, | |||
55 | " syscall\n" | 56 | " syscall\n" |
56 | : "=r" (ret), "=r" (error) | 57 | : "=r" (ret), "=r" (error) |
57 | : "r" (clkid), "r" (ts), "r" (nr) | 58 | : "r" (clkid), "r" (ts), "r" (nr) |
58 | : "memory"); | 59 | : "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13", |
60 | "$14", "$15", "$24", "$25", "hi", "lo", "memory"); | ||
59 | 61 | ||
60 | return error ? -ret : ret; | 62 | return error ? -ret : ret; |
61 | } | 63 | } |
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index 36f858c37ca7..81b0031f909f 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig | |||
@@ -199,7 +199,7 @@ config PPC | |||
199 | select HAVE_OPTPROBES if PPC64 | 199 | select HAVE_OPTPROBES if PPC64 |
200 | select HAVE_PERF_EVENTS | 200 | select HAVE_PERF_EVENTS |
201 | select HAVE_PERF_EVENTS_NMI if PPC64 | 201 | select HAVE_PERF_EVENTS_NMI if PPC64 |
202 | select HAVE_HARDLOCKUP_DETECTOR_PERF if HAVE_PERF_EVENTS_NMI && !HAVE_HARDLOCKUP_DETECTOR_ARCH | 202 | select HAVE_HARDLOCKUP_DETECTOR_PERF if PERF_EVENTS && HAVE_PERF_EVENTS_NMI && !HAVE_HARDLOCKUP_DETECTOR_ARCH |
203 | select HAVE_PERF_REGS | 203 | select HAVE_PERF_REGS |
204 | select HAVE_PERF_USER_STACK_DUMP | 204 | select HAVE_PERF_USER_STACK_DUMP |
205 | select HAVE_RCU_TABLE_FREE if SMP | 205 | select HAVE_RCU_TABLE_FREE if SMP |
diff --git a/arch/powerpc/configs/powernv_defconfig b/arch/powerpc/configs/powernv_defconfig index 0695ce047d56..34fc9bbfca9e 100644 --- a/arch/powerpc/configs/powernv_defconfig +++ b/arch/powerpc/configs/powernv_defconfig | |||
@@ -293,7 +293,8 @@ CONFIG_MAGIC_SYSRQ=y | |||
293 | CONFIG_DEBUG_KERNEL=y | 293 | CONFIG_DEBUG_KERNEL=y |
294 | CONFIG_DEBUG_STACK_USAGE=y | 294 | CONFIG_DEBUG_STACK_USAGE=y |
295 | CONFIG_DEBUG_STACKOVERFLOW=y | 295 | CONFIG_DEBUG_STACKOVERFLOW=y |
296 | CONFIG_LOCKUP_DETECTOR=y | 296 | CONFIG_SOFTLOCKUP_DETECTOR=y |
297 | CONFIG_HARDLOCKUP_DETECTOR=y | ||
297 | CONFIG_LATENCYTOP=y | 298 | CONFIG_LATENCYTOP=y |
298 | CONFIG_SCHED_TRACER=y | 299 | CONFIG_SCHED_TRACER=y |
299 | CONFIG_BLK_DEV_IO_TRACE=y | 300 | CONFIG_BLK_DEV_IO_TRACE=y |
diff --git a/arch/powerpc/configs/ppc64_defconfig b/arch/powerpc/configs/ppc64_defconfig index 5175028c56ce..c5246d29f385 100644 --- a/arch/powerpc/configs/ppc64_defconfig +++ b/arch/powerpc/configs/ppc64_defconfig | |||
@@ -324,7 +324,8 @@ CONFIG_MAGIC_SYSRQ=y | |||
324 | CONFIG_DEBUG_KERNEL=y | 324 | CONFIG_DEBUG_KERNEL=y |
325 | CONFIG_DEBUG_STACK_USAGE=y | 325 | CONFIG_DEBUG_STACK_USAGE=y |
326 | CONFIG_DEBUG_STACKOVERFLOW=y | 326 | CONFIG_DEBUG_STACKOVERFLOW=y |
327 | CONFIG_LOCKUP_DETECTOR=y | 327 | CONFIG_SOFTLOCKUP_DETECTOR=y |
328 | CONFIG_HARDLOCKUP_DETECTOR=y | ||
328 | CONFIG_DEBUG_MUTEXES=y | 329 | CONFIG_DEBUG_MUTEXES=y |
329 | CONFIG_LATENCYTOP=y | 330 | CONFIG_LATENCYTOP=y |
330 | CONFIG_SCHED_TRACER=y | 331 | CONFIG_SCHED_TRACER=y |
diff --git a/arch/powerpc/configs/pseries_defconfig b/arch/powerpc/configs/pseries_defconfig index 1a61aa20dfba..fd5d98a0b95c 100644 --- a/arch/powerpc/configs/pseries_defconfig +++ b/arch/powerpc/configs/pseries_defconfig | |||
@@ -291,7 +291,8 @@ CONFIG_MAGIC_SYSRQ=y | |||
291 | CONFIG_DEBUG_KERNEL=y | 291 | CONFIG_DEBUG_KERNEL=y |
292 | CONFIG_DEBUG_STACK_USAGE=y | 292 | CONFIG_DEBUG_STACK_USAGE=y |
293 | CONFIG_DEBUG_STACKOVERFLOW=y | 293 | CONFIG_DEBUG_STACKOVERFLOW=y |
294 | CONFIG_LOCKUP_DETECTOR=y | 294 | CONFIG_SOFTLOCKUP_DETECTOR=y |
295 | CONFIG_HARDLOCKUP_DETECTOR=y | ||
295 | CONFIG_LATENCYTOP=y | 296 | CONFIG_LATENCYTOP=y |
296 | CONFIG_SCHED_TRACER=y | 297 | CONFIG_SCHED_TRACER=y |
297 | CONFIG_BLK_DEV_IO_TRACE=y | 298 | CONFIG_BLK_DEV_IO_TRACE=y |
diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S index 49d8422767b4..e925c1c99c71 100644 --- a/arch/powerpc/kernel/entry_64.S +++ b/arch/powerpc/kernel/entry_64.S | |||
@@ -223,17 +223,27 @@ system_call_exit: | |||
223 | andi. r0,r9,(_TIF_SYSCALL_DOTRACE|_TIF_SINGLESTEP|_TIF_USER_WORK_MASK|_TIF_PERSYSCALL_MASK) | 223 | andi. r0,r9,(_TIF_SYSCALL_DOTRACE|_TIF_SINGLESTEP|_TIF_USER_WORK_MASK|_TIF_PERSYSCALL_MASK) |
224 | bne- .Lsyscall_exit_work | 224 | bne- .Lsyscall_exit_work |
225 | 225 | ||
226 | /* If MSR_FP and MSR_VEC are set in user msr, then no need to restore */ | 226 | andi. r0,r8,MSR_FP |
227 | li r7,MSR_FP | 227 | beq 2f |
228 | #ifdef CONFIG_ALTIVEC | 228 | #ifdef CONFIG_ALTIVEC |
229 | oris r7,r7,MSR_VEC@h | 229 | andis. r0,r8,MSR_VEC@h |
230 | bne 3f | ||
230 | #endif | 231 | #endif |
231 | and r0,r8,r7 | 232 | 2: addi r3,r1,STACK_FRAME_OVERHEAD |
232 | cmpd r0,r7 | 233 | #ifdef CONFIG_PPC_BOOK3S |
233 | bne .Lsyscall_restore_math | 234 | li r10,MSR_RI |
234 | .Lsyscall_restore_math_cont: | 235 | mtmsrd r10,1 /* Restore RI */ |
236 | #endif | ||
237 | bl restore_math | ||
238 | #ifdef CONFIG_PPC_BOOK3S | ||
239 | li r11,0 | ||
240 | mtmsrd r11,1 | ||
241 | #endif | ||
242 | ld r8,_MSR(r1) | ||
243 | ld r3,RESULT(r1) | ||
244 | li r11,-MAX_ERRNO | ||
235 | 245 | ||
236 | cmpld r3,r11 | 246 | 3: cmpld r3,r11 |
237 | ld r5,_CCR(r1) | 247 | ld r5,_CCR(r1) |
238 | bge- .Lsyscall_error | 248 | bge- .Lsyscall_error |
239 | .Lsyscall_error_cont: | 249 | .Lsyscall_error_cont: |
@@ -267,40 +277,6 @@ END_FTR_SECTION_IFSET(CPU_FTR_HAS_PPR) | |||
267 | std r5,_CCR(r1) | 277 | std r5,_CCR(r1) |
268 | b .Lsyscall_error_cont | 278 | b .Lsyscall_error_cont |
269 | 279 | ||
270 | .Lsyscall_restore_math: | ||
271 | /* | ||
272 | * Some initial tests from restore_math to avoid the heavyweight | ||
273 | * C code entry and MSR manipulations. | ||
274 | */ | ||
275 | LOAD_REG_IMMEDIATE(r0, MSR_TS_MASK) | ||
276 | and. r0,r0,r8 | ||
277 | bne 1f | ||
278 | |||
279 | ld r7,PACACURRENT(r13) | ||
280 | lbz r0,THREAD+THREAD_LOAD_FP(r7) | ||
281 | #ifdef CONFIG_ALTIVEC | ||
282 | lbz r6,THREAD+THREAD_LOAD_VEC(r7) | ||
283 | add r0,r0,r6 | ||
284 | #endif | ||
285 | cmpdi r0,0 | ||
286 | beq .Lsyscall_restore_math_cont | ||
287 | |||
288 | 1: addi r3,r1,STACK_FRAME_OVERHEAD | ||
289 | #ifdef CONFIG_PPC_BOOK3S | ||
290 | li r10,MSR_RI | ||
291 | mtmsrd r10,1 /* Restore RI */ | ||
292 | #endif | ||
293 | bl restore_math | ||
294 | #ifdef CONFIG_PPC_BOOK3S | ||
295 | li r11,0 | ||
296 | mtmsrd r11,1 | ||
297 | #endif | ||
298 | /* Restore volatiles, reload MSR from updated one */ | ||
299 | ld r8,_MSR(r1) | ||
300 | ld r3,RESULT(r1) | ||
301 | li r11,-MAX_ERRNO | ||
302 | b .Lsyscall_restore_math_cont | ||
303 | |||
304 | /* Traced system call support */ | 280 | /* Traced system call support */ |
305 | .Lsyscall_dotrace: | 281 | .Lsyscall_dotrace: |
306 | bl save_nvgprs | 282 | bl save_nvgprs |
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c index 9f3e2c932dcc..1f0fd361e09b 100644 --- a/arch/powerpc/kernel/process.c +++ b/arch/powerpc/kernel/process.c | |||
@@ -362,7 +362,8 @@ void enable_kernel_vsx(void) | |||
362 | 362 | ||
363 | cpumsr = msr_check_and_set(MSR_FP|MSR_VEC|MSR_VSX); | 363 | cpumsr = msr_check_and_set(MSR_FP|MSR_VEC|MSR_VSX); |
364 | 364 | ||
365 | if (current->thread.regs && (current->thread.regs->msr & MSR_VSX)) { | 365 | if (current->thread.regs && |
366 | (current->thread.regs->msr & (MSR_VSX|MSR_VEC|MSR_FP))) { | ||
366 | check_if_tm_restore_required(current); | 367 | check_if_tm_restore_required(current); |
367 | /* | 368 | /* |
368 | * If a thread has already been reclaimed then the | 369 | * If a thread has already been reclaimed then the |
@@ -386,7 +387,7 @@ void flush_vsx_to_thread(struct task_struct *tsk) | |||
386 | { | 387 | { |
387 | if (tsk->thread.regs) { | 388 | if (tsk->thread.regs) { |
388 | preempt_disable(); | 389 | preempt_disable(); |
389 | if (tsk->thread.regs->msr & MSR_VSX) { | 390 | if (tsk->thread.regs->msr & (MSR_VSX|MSR_VEC|MSR_FP)) { |
390 | BUG_ON(tsk != current); | 391 | BUG_ON(tsk != current); |
391 | giveup_vsx(tsk); | 392 | giveup_vsx(tsk); |
392 | } | 393 | } |
@@ -511,10 +512,6 @@ void restore_math(struct pt_regs *regs) | |||
511 | { | 512 | { |
512 | unsigned long msr; | 513 | unsigned long msr; |
513 | 514 | ||
514 | /* | ||
515 | * Syscall exit makes a similar initial check before branching | ||
516 | * to restore_math. Keep them in synch. | ||
517 | */ | ||
518 | if (!msr_tm_active(regs->msr) && | 515 | if (!msr_tm_active(regs->msr) && |
519 | !current->thread.load_fp && !loadvec(current->thread)) | 516 | !current->thread.load_fp && !loadvec(current->thread)) |
520 | return; | 517 | return; |
diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c index cf0e1245b8cc..8d3320562c70 100644 --- a/arch/powerpc/kernel/smp.c +++ b/arch/powerpc/kernel/smp.c | |||
@@ -351,7 +351,7 @@ static void nmi_ipi_lock_start(unsigned long *flags) | |||
351 | hard_irq_disable(); | 351 | hard_irq_disable(); |
352 | while (atomic_cmpxchg(&__nmi_ipi_lock, 0, 1) == 1) { | 352 | while (atomic_cmpxchg(&__nmi_ipi_lock, 0, 1) == 1) { |
353 | raw_local_irq_restore(*flags); | 353 | raw_local_irq_restore(*flags); |
354 | cpu_relax(); | 354 | spin_until_cond(atomic_read(&__nmi_ipi_lock) == 0); |
355 | raw_local_irq_save(*flags); | 355 | raw_local_irq_save(*flags); |
356 | hard_irq_disable(); | 356 | hard_irq_disable(); |
357 | } | 357 | } |
@@ -360,7 +360,7 @@ static void nmi_ipi_lock_start(unsigned long *flags) | |||
360 | static void nmi_ipi_lock(void) | 360 | static void nmi_ipi_lock(void) |
361 | { | 361 | { |
362 | while (atomic_cmpxchg(&__nmi_ipi_lock, 0, 1) == 1) | 362 | while (atomic_cmpxchg(&__nmi_ipi_lock, 0, 1) == 1) |
363 | cpu_relax(); | 363 | spin_until_cond(atomic_read(&__nmi_ipi_lock) == 0); |
364 | } | 364 | } |
365 | 365 | ||
366 | static void nmi_ipi_unlock(void) | 366 | static void nmi_ipi_unlock(void) |
@@ -475,7 +475,7 @@ int smp_send_nmi_ipi(int cpu, void (*fn)(struct pt_regs *), u64 delay_us) | |||
475 | nmi_ipi_lock_start(&flags); | 475 | nmi_ipi_lock_start(&flags); |
476 | while (nmi_ipi_busy_count) { | 476 | while (nmi_ipi_busy_count) { |
477 | nmi_ipi_unlock_end(&flags); | 477 | nmi_ipi_unlock_end(&flags); |
478 | cpu_relax(); | 478 | spin_until_cond(nmi_ipi_busy_count == 0); |
479 | nmi_ipi_lock_start(&flags); | 479 | nmi_ipi_lock_start(&flags); |
480 | } | 480 | } |
481 | 481 | ||
diff --git a/arch/powerpc/kernel/watchdog.c b/arch/powerpc/kernel/watchdog.c index b67f8b03a32d..34721a257a77 100644 --- a/arch/powerpc/kernel/watchdog.c +++ b/arch/powerpc/kernel/watchdog.c | |||
@@ -71,15 +71,20 @@ static inline void wd_smp_lock(unsigned long *flags) | |||
71 | * This may be called from low level interrupt handlers at some | 71 | * This may be called from low level interrupt handlers at some |
72 | * point in future. | 72 | * point in future. |
73 | */ | 73 | */ |
74 | local_irq_save(*flags); | 74 | raw_local_irq_save(*flags); |
75 | while (unlikely(test_and_set_bit_lock(0, &__wd_smp_lock))) | 75 | hard_irq_disable(); /* Make it soft-NMI safe */ |
76 | cpu_relax(); | 76 | while (unlikely(test_and_set_bit_lock(0, &__wd_smp_lock))) { |
77 | raw_local_irq_restore(*flags); | ||
78 | spin_until_cond(!test_bit(0, &__wd_smp_lock)); | ||
79 | raw_local_irq_save(*flags); | ||
80 | hard_irq_disable(); | ||
81 | } | ||
77 | } | 82 | } |
78 | 83 | ||
79 | static inline void wd_smp_unlock(unsigned long *flags) | 84 | static inline void wd_smp_unlock(unsigned long *flags) |
80 | { | 85 | { |
81 | clear_bit_unlock(0, &__wd_smp_lock); | 86 | clear_bit_unlock(0, &__wd_smp_lock); |
82 | local_irq_restore(*flags); | 87 | raw_local_irq_restore(*flags); |
83 | } | 88 | } |
84 | 89 | ||
85 | static void wd_lockup_ipi(struct pt_regs *regs) | 90 | static void wd_lockup_ipi(struct pt_regs *regs) |
@@ -96,10 +101,10 @@ static void wd_lockup_ipi(struct pt_regs *regs) | |||
96 | nmi_panic(regs, "Hard LOCKUP"); | 101 | nmi_panic(regs, "Hard LOCKUP"); |
97 | } | 102 | } |
98 | 103 | ||
99 | static void set_cpu_stuck(int cpu, u64 tb) | 104 | static void set_cpumask_stuck(const struct cpumask *cpumask, u64 tb) |
100 | { | 105 | { |
101 | cpumask_set_cpu(cpu, &wd_smp_cpus_stuck); | 106 | cpumask_or(&wd_smp_cpus_stuck, &wd_smp_cpus_stuck, cpumask); |
102 | cpumask_clear_cpu(cpu, &wd_smp_cpus_pending); | 107 | cpumask_andnot(&wd_smp_cpus_pending, &wd_smp_cpus_pending, cpumask); |
103 | if (cpumask_empty(&wd_smp_cpus_pending)) { | 108 | if (cpumask_empty(&wd_smp_cpus_pending)) { |
104 | wd_smp_last_reset_tb = tb; | 109 | wd_smp_last_reset_tb = tb; |
105 | cpumask_andnot(&wd_smp_cpus_pending, | 110 | cpumask_andnot(&wd_smp_cpus_pending, |
@@ -107,6 +112,10 @@ static void set_cpu_stuck(int cpu, u64 tb) | |||
107 | &wd_smp_cpus_stuck); | 112 | &wd_smp_cpus_stuck); |
108 | } | 113 | } |
109 | } | 114 | } |
115 | static void set_cpu_stuck(int cpu, u64 tb) | ||
116 | { | ||
117 | set_cpumask_stuck(cpumask_of(cpu), tb); | ||
118 | } | ||
110 | 119 | ||
111 | static void watchdog_smp_panic(int cpu, u64 tb) | 120 | static void watchdog_smp_panic(int cpu, u64 tb) |
112 | { | 121 | { |
@@ -135,11 +144,9 @@ static void watchdog_smp_panic(int cpu, u64 tb) | |||
135 | } | 144 | } |
136 | smp_flush_nmi_ipi(1000000); | 145 | smp_flush_nmi_ipi(1000000); |
137 | 146 | ||
138 | /* Take the stuck CPU out of the watch group */ | 147 | /* Take the stuck CPUs out of the watch group */ |
139 | for_each_cpu(c, &wd_smp_cpus_pending) | 148 | set_cpumask_stuck(&wd_smp_cpus_pending, tb); |
140 | set_cpu_stuck(c, tb); | ||
141 | 149 | ||
142 | out: | ||
143 | wd_smp_unlock(&flags); | 150 | wd_smp_unlock(&flags); |
144 | 151 | ||
145 | printk_safe_flush(); | 152 | printk_safe_flush(); |
@@ -152,6 +159,11 @@ out: | |||
152 | 159 | ||
153 | if (hardlockup_panic) | 160 | if (hardlockup_panic) |
154 | nmi_panic(NULL, "Hard LOCKUP"); | 161 | nmi_panic(NULL, "Hard LOCKUP"); |
162 | |||
163 | return; | ||
164 | |||
165 | out: | ||
166 | wd_smp_unlock(&flags); | ||
155 | } | 167 | } |
156 | 168 | ||
157 | static void wd_smp_clear_cpu_pending(int cpu, u64 tb) | 169 | static void wd_smp_clear_cpu_pending(int cpu, u64 tb) |
@@ -258,9 +270,11 @@ static void wd_timer_fn(unsigned long data) | |||
258 | 270 | ||
259 | void arch_touch_nmi_watchdog(void) | 271 | void arch_touch_nmi_watchdog(void) |
260 | { | 272 | { |
273 | unsigned long ticks = tb_ticks_per_usec * wd_timer_period_ms * 1000; | ||
261 | int cpu = smp_processor_id(); | 274 | int cpu = smp_processor_id(); |
262 | 275 | ||
263 | watchdog_timer_interrupt(cpu); | 276 | if (get_tb() - per_cpu(wd_timer_tb, cpu) >= ticks) |
277 | watchdog_timer_interrupt(cpu); | ||
264 | } | 278 | } |
265 | EXPORT_SYMBOL(arch_touch_nmi_watchdog); | 279 | EXPORT_SYMBOL(arch_touch_nmi_watchdog); |
266 | 280 | ||
@@ -283,6 +297,8 @@ static void stop_watchdog_timer_on(unsigned int cpu) | |||
283 | 297 | ||
284 | static int start_wd_on_cpu(unsigned int cpu) | 298 | static int start_wd_on_cpu(unsigned int cpu) |
285 | { | 299 | { |
300 | unsigned long flags; | ||
301 | |||
286 | if (cpumask_test_cpu(cpu, &wd_cpus_enabled)) { | 302 | if (cpumask_test_cpu(cpu, &wd_cpus_enabled)) { |
287 | WARN_ON(1); | 303 | WARN_ON(1); |
288 | return 0; | 304 | return 0; |
@@ -297,12 +313,14 @@ static int start_wd_on_cpu(unsigned int cpu) | |||
297 | if (!cpumask_test_cpu(cpu, &watchdog_cpumask)) | 313 | if (!cpumask_test_cpu(cpu, &watchdog_cpumask)) |
298 | return 0; | 314 | return 0; |
299 | 315 | ||
316 | wd_smp_lock(&flags); | ||
300 | cpumask_set_cpu(cpu, &wd_cpus_enabled); | 317 | cpumask_set_cpu(cpu, &wd_cpus_enabled); |
301 | if (cpumask_weight(&wd_cpus_enabled) == 1) { | 318 | if (cpumask_weight(&wd_cpus_enabled) == 1) { |
302 | cpumask_set_cpu(cpu, &wd_smp_cpus_pending); | 319 | cpumask_set_cpu(cpu, &wd_smp_cpus_pending); |
303 | wd_smp_last_reset_tb = get_tb(); | 320 | wd_smp_last_reset_tb = get_tb(); |
304 | } | 321 | } |
305 | smp_wmb(); | 322 | wd_smp_unlock(&flags); |
323 | |||
306 | start_watchdog_timer_on(cpu); | 324 | start_watchdog_timer_on(cpu); |
307 | 325 | ||
308 | return 0; | 326 | return 0; |
@@ -310,12 +328,17 @@ static int start_wd_on_cpu(unsigned int cpu) | |||
310 | 328 | ||
311 | static int stop_wd_on_cpu(unsigned int cpu) | 329 | static int stop_wd_on_cpu(unsigned int cpu) |
312 | { | 330 | { |
331 | unsigned long flags; | ||
332 | |||
313 | if (!cpumask_test_cpu(cpu, &wd_cpus_enabled)) | 333 | if (!cpumask_test_cpu(cpu, &wd_cpus_enabled)) |
314 | return 0; /* Can happen in CPU unplug case */ | 334 | return 0; /* Can happen in CPU unplug case */ |
315 | 335 | ||
316 | stop_watchdog_timer_on(cpu); | 336 | stop_watchdog_timer_on(cpu); |
317 | 337 | ||
338 | wd_smp_lock(&flags); | ||
318 | cpumask_clear_cpu(cpu, &wd_cpus_enabled); | 339 | cpumask_clear_cpu(cpu, &wd_cpus_enabled); |
340 | wd_smp_unlock(&flags); | ||
341 | |||
319 | wd_smp_clear_cpu_pending(cpu, get_tb()); | 342 | wd_smp_clear_cpu_pending(cpu, get_tb()); |
320 | 343 | ||
321 | return 0; | 344 | return 0; |
diff --git a/arch/powerpc/platforms/powernv/idle.c b/arch/powerpc/platforms/powernv/idle.c index 2abee070373f..a553aeea7af6 100644 --- a/arch/powerpc/platforms/powernv/idle.c +++ b/arch/powerpc/platforms/powernv/idle.c | |||
@@ -56,6 +56,7 @@ u64 pnv_first_deep_stop_state = MAX_STOP_STATE; | |||
56 | */ | 56 | */ |
57 | static u64 pnv_deepest_stop_psscr_val; | 57 | static u64 pnv_deepest_stop_psscr_val; |
58 | static u64 pnv_deepest_stop_psscr_mask; | 58 | static u64 pnv_deepest_stop_psscr_mask; |
59 | static u64 pnv_deepest_stop_flag; | ||
59 | static bool deepest_stop_found; | 60 | static bool deepest_stop_found; |
60 | 61 | ||
61 | static int pnv_save_sprs_for_deep_states(void) | 62 | static int pnv_save_sprs_for_deep_states(void) |
@@ -185,8 +186,40 @@ static void pnv_alloc_idle_core_states(void) | |||
185 | 186 | ||
186 | update_subcore_sibling_mask(); | 187 | update_subcore_sibling_mask(); |
187 | 188 | ||
188 | if (supported_cpuidle_states & OPAL_PM_LOSE_FULL_CONTEXT) | 189 | if (supported_cpuidle_states & OPAL_PM_LOSE_FULL_CONTEXT) { |
189 | pnv_save_sprs_for_deep_states(); | 190 | int rc = pnv_save_sprs_for_deep_states(); |
191 | |||
192 | if (likely(!rc)) | ||
193 | return; | ||
194 | |||
195 | /* | ||
196 | * The stop-api is unable to restore hypervisor | ||
197 | * resources on wakeup from platform idle states which | ||
198 | * lose full context. So disable such states. | ||
199 | */ | ||
200 | supported_cpuidle_states &= ~OPAL_PM_LOSE_FULL_CONTEXT; | ||
201 | pr_warn("cpuidle-powernv: Disabling idle states that lose full context\n"); | ||
202 | pr_warn("cpuidle-powernv: Idle power-savings, CPU-Hotplug affected\n"); | ||
203 | |||
204 | if (cpu_has_feature(CPU_FTR_ARCH_300) && | ||
205 | (pnv_deepest_stop_flag & OPAL_PM_LOSE_FULL_CONTEXT)) { | ||
206 | /* | ||
207 | * Use the default stop state for CPU-Hotplug | ||
208 | * if available. | ||
209 | */ | ||
210 | if (default_stop_found) { | ||
211 | pnv_deepest_stop_psscr_val = | ||
212 | pnv_default_stop_val; | ||
213 | pnv_deepest_stop_psscr_mask = | ||
214 | pnv_default_stop_mask; | ||
215 | pr_warn("cpuidle-powernv: Offlined CPUs will stop with psscr = 0x%016llx\n", | ||
216 | pnv_deepest_stop_psscr_val); | ||
217 | } else { /* Fallback to snooze loop for CPU-Hotplug */ | ||
218 | deepest_stop_found = false; | ||
219 | pr_warn("cpuidle-powernv: Offlined CPUs will busy wait\n"); | ||
220 | } | ||
221 | } | ||
222 | } | ||
190 | } | 223 | } |
191 | 224 | ||
192 | u32 pnv_get_supported_cpuidle_states(void) | 225 | u32 pnv_get_supported_cpuidle_states(void) |
@@ -375,7 +408,8 @@ unsigned long pnv_cpu_offline(unsigned int cpu) | |||
375 | pnv_deepest_stop_psscr_val; | 408 | pnv_deepest_stop_psscr_val; |
376 | srr1 = power9_idle_stop(psscr); | 409 | srr1 = power9_idle_stop(psscr); |
377 | 410 | ||
378 | } else if (idle_states & OPAL_PM_WINKLE_ENABLED) { | 411 | } else if ((idle_states & OPAL_PM_WINKLE_ENABLED) && |
412 | (idle_states & OPAL_PM_LOSE_FULL_CONTEXT)) { | ||
379 | srr1 = power7_idle_insn(PNV_THREAD_WINKLE); | 413 | srr1 = power7_idle_insn(PNV_THREAD_WINKLE); |
380 | } else if ((idle_states & OPAL_PM_SLEEP_ENABLED) || | 414 | } else if ((idle_states & OPAL_PM_SLEEP_ENABLED) || |
381 | (idle_states & OPAL_PM_SLEEP_ENABLED_ER1)) { | 415 | (idle_states & OPAL_PM_SLEEP_ENABLED_ER1)) { |
@@ -553,6 +587,7 @@ static int __init pnv_power9_idle_init(struct device_node *np, u32 *flags, | |||
553 | max_residency_ns = residency_ns[i]; | 587 | max_residency_ns = residency_ns[i]; |
554 | pnv_deepest_stop_psscr_val = psscr_val[i]; | 588 | pnv_deepest_stop_psscr_val = psscr_val[i]; |
555 | pnv_deepest_stop_psscr_mask = psscr_mask[i]; | 589 | pnv_deepest_stop_psscr_mask = psscr_mask[i]; |
590 | pnv_deepest_stop_flag = flags[i]; | ||
556 | deepest_stop_found = true; | 591 | deepest_stop_found = true; |
557 | } | 592 | } |
558 | 593 | ||
diff --git a/arch/s390/include/asm/tlb.h b/arch/s390/include/asm/tlb.h index 7317b3108a88..2eb8ff0d6fca 100644 --- a/arch/s390/include/asm/tlb.h +++ b/arch/s390/include/asm/tlb.h | |||
@@ -47,10 +47,9 @@ struct mmu_table_batch { | |||
47 | extern void tlb_table_flush(struct mmu_gather *tlb); | 47 | extern void tlb_table_flush(struct mmu_gather *tlb); |
48 | extern void tlb_remove_table(struct mmu_gather *tlb, void *table); | 48 | extern void tlb_remove_table(struct mmu_gather *tlb, void *table); |
49 | 49 | ||
50 | static inline void tlb_gather_mmu(struct mmu_gather *tlb, | 50 | static inline void |
51 | struct mm_struct *mm, | 51 | arch_tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, |
52 | unsigned long start, | 52 | unsigned long start, unsigned long end) |
53 | unsigned long end) | ||
54 | { | 53 | { |
55 | tlb->mm = mm; | 54 | tlb->mm = mm; |
56 | tlb->start = start; | 55 | tlb->start = start; |
@@ -76,9 +75,15 @@ static inline void tlb_flush_mmu(struct mmu_gather *tlb) | |||
76 | tlb_flush_mmu_free(tlb); | 75 | tlb_flush_mmu_free(tlb); |
77 | } | 76 | } |
78 | 77 | ||
79 | static inline void tlb_finish_mmu(struct mmu_gather *tlb, | 78 | static inline void |
80 | unsigned long start, unsigned long end) | 79 | arch_tlb_finish_mmu(struct mmu_gather *tlb, |
80 | unsigned long start, unsigned long end, bool force) | ||
81 | { | 81 | { |
82 | if (force) { | ||
83 | tlb->start = start; | ||
84 | tlb->end = end; | ||
85 | } | ||
86 | |||
82 | tlb_flush_mmu(tlb); | 87 | tlb_flush_mmu(tlb); |
83 | } | 88 | } |
84 | 89 | ||
diff --git a/arch/sh/include/asm/tlb.h b/arch/sh/include/asm/tlb.h index 46e0d635e36f..51a8bc967e75 100644 --- a/arch/sh/include/asm/tlb.h +++ b/arch/sh/include/asm/tlb.h | |||
@@ -36,7 +36,8 @@ static inline void init_tlb_gather(struct mmu_gather *tlb) | |||
36 | } | 36 | } |
37 | 37 | ||
38 | static inline void | 38 | static inline void |
39 | tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, unsigned long start, unsigned long end) | 39 | arch_tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, |
40 | unsigned long start, unsigned long end) | ||
40 | { | 41 | { |
41 | tlb->mm = mm; | 42 | tlb->mm = mm; |
42 | tlb->start = start; | 43 | tlb->start = start; |
@@ -47,9 +48,10 @@ tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, unsigned long start | |||
47 | } | 48 | } |
48 | 49 | ||
49 | static inline void | 50 | static inline void |
50 | tlb_finish_mmu(struct mmu_gather *tlb, unsigned long start, unsigned long end) | 51 | arch_tlb_finish_mmu(struct mmu_gather *tlb, |
52 | unsigned long start, unsigned long end, bool force) | ||
51 | { | 53 | { |
52 | if (tlb->fullmm) | 54 | if (tlb->fullmm || force) |
53 | flush_tlb_mm(tlb->mm); | 55 | flush_tlb_mm(tlb->mm); |
54 | 56 | ||
55 | /* keep the page table cache within bounds */ | 57 | /* keep the page table cache within bounds */ |
diff --git a/arch/sparc/include/asm/page_32.h b/arch/sparc/include/asm/page_32.h index 0efd0583a8c9..6249214148c2 100644 --- a/arch/sparc/include/asm/page_32.h +++ b/arch/sparc/include/asm/page_32.h | |||
@@ -68,6 +68,7 @@ typedef struct { unsigned long iopgprot; } iopgprot_t; | |||
68 | #define iopgprot_val(x) ((x).iopgprot) | 68 | #define iopgprot_val(x) ((x).iopgprot) |
69 | 69 | ||
70 | #define __pte(x) ((pte_t) { (x) } ) | 70 | #define __pte(x) ((pte_t) { (x) } ) |
71 | #define __pmd(x) ((pmd_t) { { (x) }, }) | ||
71 | #define __iopte(x) ((iopte_t) { (x) } ) | 72 | #define __iopte(x) ((iopte_t) { (x) } ) |
72 | #define __pgd(x) ((pgd_t) { (x) } ) | 73 | #define __pgd(x) ((pgd_t) { (x) } ) |
73 | #define __ctxd(x) ((ctxd_t) { (x) } ) | 74 | #define __ctxd(x) ((ctxd_t) { (x) } ) |
@@ -95,6 +96,7 @@ typedef unsigned long iopgprot_t; | |||
95 | #define iopgprot_val(x) (x) | 96 | #define iopgprot_val(x) (x) |
96 | 97 | ||
97 | #define __pte(x) (x) | 98 | #define __pte(x) (x) |
99 | #define __pmd(x) ((pmd_t) { { (x) }, }) | ||
98 | #define __iopte(x) (x) | 100 | #define __iopte(x) (x) |
99 | #define __pgd(x) (x) | 101 | #define __pgd(x) (x) |
100 | #define __ctxd(x) (x) | 102 | #define __ctxd(x) (x) |
diff --git a/arch/sparc/include/asm/spitfire.h b/arch/sparc/include/asm/spitfire.h index 1d8321c827a8..1b1286d05069 100644 --- a/arch/sparc/include/asm/spitfire.h +++ b/arch/sparc/include/asm/spitfire.h | |||
@@ -47,10 +47,26 @@ | |||
47 | #define SUN4V_CHIP_NIAGARA5 0x05 | 47 | #define SUN4V_CHIP_NIAGARA5 0x05 |
48 | #define SUN4V_CHIP_SPARC_M6 0x06 | 48 | #define SUN4V_CHIP_SPARC_M6 0x06 |
49 | #define SUN4V_CHIP_SPARC_M7 0x07 | 49 | #define SUN4V_CHIP_SPARC_M7 0x07 |
50 | #define SUN4V_CHIP_SPARC_M8 0x08 | ||
50 | #define SUN4V_CHIP_SPARC64X 0x8a | 51 | #define SUN4V_CHIP_SPARC64X 0x8a |
51 | #define SUN4V_CHIP_SPARC_SN 0x8b | 52 | #define SUN4V_CHIP_SPARC_SN 0x8b |
52 | #define SUN4V_CHIP_UNKNOWN 0xff | 53 | #define SUN4V_CHIP_UNKNOWN 0xff |
53 | 54 | ||
55 | /* | ||
56 | * The following CPU_ID_xxx constants are used | ||
57 | * to identify the CPU type in the setup phase | ||
58 | * (see head_64.S) | ||
59 | */ | ||
60 | #define CPU_ID_NIAGARA1 ('1') | ||
61 | #define CPU_ID_NIAGARA2 ('2') | ||
62 | #define CPU_ID_NIAGARA3 ('3') | ||
63 | #define CPU_ID_NIAGARA4 ('4') | ||
64 | #define CPU_ID_NIAGARA5 ('5') | ||
65 | #define CPU_ID_M6 ('6') | ||
66 | #define CPU_ID_M7 ('7') | ||
67 | #define CPU_ID_M8 ('8') | ||
68 | #define CPU_ID_SONOMA1 ('N') | ||
69 | |||
54 | #ifndef __ASSEMBLY__ | 70 | #ifndef __ASSEMBLY__ |
55 | 71 | ||
56 | enum ultra_tlb_layout { | 72 | enum ultra_tlb_layout { |
diff --git a/arch/sparc/kernel/cpu.c b/arch/sparc/kernel/cpu.c index 493e023a468a..ef4f18f7a674 100644 --- a/arch/sparc/kernel/cpu.c +++ b/arch/sparc/kernel/cpu.c | |||
@@ -506,6 +506,12 @@ static void __init sun4v_cpu_probe(void) | |||
506 | sparc_pmu_type = "sparc-m7"; | 506 | sparc_pmu_type = "sparc-m7"; |
507 | break; | 507 | break; |
508 | 508 | ||
509 | case SUN4V_CHIP_SPARC_M8: | ||
510 | sparc_cpu_type = "SPARC-M8"; | ||
511 | sparc_fpu_type = "SPARC-M8 integrated FPU"; | ||
512 | sparc_pmu_type = "sparc-m8"; | ||
513 | break; | ||
514 | |||
509 | case SUN4V_CHIP_SPARC_SN: | 515 | case SUN4V_CHIP_SPARC_SN: |
510 | sparc_cpu_type = "SPARC-SN"; | 516 | sparc_cpu_type = "SPARC-SN"; |
511 | sparc_fpu_type = "SPARC-SN integrated FPU"; | 517 | sparc_fpu_type = "SPARC-SN integrated FPU"; |
diff --git a/arch/sparc/kernel/cpumap.c b/arch/sparc/kernel/cpumap.c index 45c820e1cba5..90d550bbfeef 100644 --- a/arch/sparc/kernel/cpumap.c +++ b/arch/sparc/kernel/cpumap.c | |||
@@ -328,6 +328,7 @@ static int iterate_cpu(struct cpuinfo_tree *t, unsigned int root_index) | |||
328 | case SUN4V_CHIP_NIAGARA5: | 328 | case SUN4V_CHIP_NIAGARA5: |
329 | case SUN4V_CHIP_SPARC_M6: | 329 | case SUN4V_CHIP_SPARC_M6: |
330 | case SUN4V_CHIP_SPARC_M7: | 330 | case SUN4V_CHIP_SPARC_M7: |
331 | case SUN4V_CHIP_SPARC_M8: | ||
331 | case SUN4V_CHIP_SPARC_SN: | 332 | case SUN4V_CHIP_SPARC_SN: |
332 | case SUN4V_CHIP_SPARC64X: | 333 | case SUN4V_CHIP_SPARC64X: |
333 | rover_inc_table = niagara_iterate_method; | 334 | rover_inc_table = niagara_iterate_method; |
diff --git a/arch/sparc/kernel/head_64.S b/arch/sparc/kernel/head_64.S index 41a407328667..78e0211753d2 100644 --- a/arch/sparc/kernel/head_64.S +++ b/arch/sparc/kernel/head_64.S | |||
@@ -424,22 +424,25 @@ EXPORT_SYMBOL(sun4v_chip_type) | |||
424 | nop | 424 | nop |
425 | 425 | ||
426 | 70: ldub [%g1 + 7], %g2 | 426 | 70: ldub [%g1 + 7], %g2 |
427 | cmp %g2, '3' | 427 | cmp %g2, CPU_ID_NIAGARA3 |
428 | be,pt %xcc, 5f | 428 | be,pt %xcc, 5f |
429 | mov SUN4V_CHIP_NIAGARA3, %g4 | 429 | mov SUN4V_CHIP_NIAGARA3, %g4 |
430 | cmp %g2, '4' | 430 | cmp %g2, CPU_ID_NIAGARA4 |
431 | be,pt %xcc, 5f | 431 | be,pt %xcc, 5f |
432 | mov SUN4V_CHIP_NIAGARA4, %g4 | 432 | mov SUN4V_CHIP_NIAGARA4, %g4 |
433 | cmp %g2, '5' | 433 | cmp %g2, CPU_ID_NIAGARA5 |
434 | be,pt %xcc, 5f | 434 | be,pt %xcc, 5f |
435 | mov SUN4V_CHIP_NIAGARA5, %g4 | 435 | mov SUN4V_CHIP_NIAGARA5, %g4 |
436 | cmp %g2, '6' | 436 | cmp %g2, CPU_ID_M6 |
437 | be,pt %xcc, 5f | 437 | be,pt %xcc, 5f |
438 | mov SUN4V_CHIP_SPARC_M6, %g4 | 438 | mov SUN4V_CHIP_SPARC_M6, %g4 |
439 | cmp %g2, '7' | 439 | cmp %g2, CPU_ID_M7 |
440 | be,pt %xcc, 5f | 440 | be,pt %xcc, 5f |
441 | mov SUN4V_CHIP_SPARC_M7, %g4 | 441 | mov SUN4V_CHIP_SPARC_M7, %g4 |
442 | cmp %g2, 'N' | 442 | cmp %g2, CPU_ID_M8 |
443 | be,pt %xcc, 5f | ||
444 | mov SUN4V_CHIP_SPARC_M8, %g4 | ||
445 | cmp %g2, CPU_ID_SONOMA1 | ||
443 | be,pt %xcc, 5f | 446 | be,pt %xcc, 5f |
444 | mov SUN4V_CHIP_SPARC_SN, %g4 | 447 | mov SUN4V_CHIP_SPARC_SN, %g4 |
445 | ba,pt %xcc, 49f | 448 | ba,pt %xcc, 49f |
@@ -448,10 +451,10 @@ EXPORT_SYMBOL(sun4v_chip_type) | |||
448 | 91: sethi %hi(prom_cpu_compatible), %g1 | 451 | 91: sethi %hi(prom_cpu_compatible), %g1 |
449 | or %g1, %lo(prom_cpu_compatible), %g1 | 452 | or %g1, %lo(prom_cpu_compatible), %g1 |
450 | ldub [%g1 + 17], %g2 | 453 | ldub [%g1 + 17], %g2 |
451 | cmp %g2, '1' | 454 | cmp %g2, CPU_ID_NIAGARA1 |
452 | be,pt %xcc, 5f | 455 | be,pt %xcc, 5f |
453 | mov SUN4V_CHIP_NIAGARA1, %g4 | 456 | mov SUN4V_CHIP_NIAGARA1, %g4 |
454 | cmp %g2, '2' | 457 | cmp %g2, CPU_ID_NIAGARA2 |
455 | be,pt %xcc, 5f | 458 | be,pt %xcc, 5f |
456 | mov SUN4V_CHIP_NIAGARA2, %g4 | 459 | mov SUN4V_CHIP_NIAGARA2, %g4 |
457 | 460 | ||
@@ -602,6 +605,9 @@ niagara_tlb_fixup: | |||
602 | cmp %g1, SUN4V_CHIP_SPARC_M7 | 605 | cmp %g1, SUN4V_CHIP_SPARC_M7 |
603 | be,pt %xcc, niagara4_patch | 606 | be,pt %xcc, niagara4_patch |
604 | nop | 607 | nop |
608 | cmp %g1, SUN4V_CHIP_SPARC_M8 | ||
609 | be,pt %xcc, niagara4_patch | ||
610 | nop | ||
605 | cmp %g1, SUN4V_CHIP_SPARC_SN | 611 | cmp %g1, SUN4V_CHIP_SPARC_SN |
606 | be,pt %xcc, niagara4_patch | 612 | be,pt %xcc, niagara4_patch |
607 | nop | 613 | nop |
diff --git a/arch/sparc/kernel/pci_sun4v.c b/arch/sparc/kernel/pci_sun4v.c index f10e2f712394..9ebebf1fd93d 100644 --- a/arch/sparc/kernel/pci_sun4v.c +++ b/arch/sparc/kernel/pci_sun4v.c | |||
@@ -1266,8 +1266,6 @@ static int pci_sun4v_probe(struct platform_device *op) | |||
1266 | * ATU group, but ATU hcalls won't be available. | 1266 | * ATU group, but ATU hcalls won't be available. |
1267 | */ | 1267 | */ |
1268 | hv_atu = false; | 1268 | hv_atu = false; |
1269 | pr_err(PFX "Could not register hvapi ATU err=%d\n", | ||
1270 | err); | ||
1271 | } else { | 1269 | } else { |
1272 | pr_info(PFX "Registered hvapi ATU major[%lu] minor[%lu]\n", | 1270 | pr_info(PFX "Registered hvapi ATU major[%lu] minor[%lu]\n", |
1273 | vatu_major, vatu_minor); | 1271 | vatu_major, vatu_minor); |
diff --git a/arch/sparc/kernel/pcic.c b/arch/sparc/kernel/pcic.c index a38787b84322..732af9a9f6dd 100644 --- a/arch/sparc/kernel/pcic.c +++ b/arch/sparc/kernel/pcic.c | |||
@@ -602,7 +602,7 @@ void pcibios_fixup_bus(struct pci_bus *bus) | |||
602 | { | 602 | { |
603 | struct pci_dev *dev; | 603 | struct pci_dev *dev; |
604 | int i, has_io, has_mem; | 604 | int i, has_io, has_mem; |
605 | unsigned int cmd; | 605 | unsigned int cmd = 0; |
606 | struct linux_pcic *pcic; | 606 | struct linux_pcic *pcic; |
607 | /* struct linux_pbm_info* pbm = &pcic->pbm; */ | 607 | /* struct linux_pbm_info* pbm = &pcic->pbm; */ |
608 | int node; | 608 | int node; |
diff --git a/arch/sparc/kernel/setup_64.c b/arch/sparc/kernel/setup_64.c index 4d9c3e13c150..150ee7d4b059 100644 --- a/arch/sparc/kernel/setup_64.c +++ b/arch/sparc/kernel/setup_64.c | |||
@@ -288,10 +288,17 @@ static void __init sun4v_patch(void) | |||
288 | 288 | ||
289 | sun4v_patch_2insn_range(&__sun4v_2insn_patch, | 289 | sun4v_patch_2insn_range(&__sun4v_2insn_patch, |
290 | &__sun4v_2insn_patch_end); | 290 | &__sun4v_2insn_patch_end); |
291 | if (sun4v_chip_type == SUN4V_CHIP_SPARC_M7 || | 291 | |
292 | sun4v_chip_type == SUN4V_CHIP_SPARC_SN) | 292 | switch (sun4v_chip_type) { |
293 | case SUN4V_CHIP_SPARC_M7: | ||
294 | case SUN4V_CHIP_SPARC_M8: | ||
295 | case SUN4V_CHIP_SPARC_SN: | ||
293 | sun_m7_patch_2insn_range(&__sun_m7_2insn_patch, | 296 | sun_m7_patch_2insn_range(&__sun_m7_2insn_patch, |
294 | &__sun_m7_2insn_patch_end); | 297 | &__sun_m7_2insn_patch_end); |
298 | break; | ||
299 | default: | ||
300 | break; | ||
301 | } | ||
295 | 302 | ||
296 | sun4v_hvapi_init(); | 303 | sun4v_hvapi_init(); |
297 | } | 304 | } |
@@ -529,6 +536,7 @@ static void __init init_sparc64_elf_hwcap(void) | |||
529 | sun4v_chip_type == SUN4V_CHIP_NIAGARA5 || | 536 | sun4v_chip_type == SUN4V_CHIP_NIAGARA5 || |
530 | sun4v_chip_type == SUN4V_CHIP_SPARC_M6 || | 537 | sun4v_chip_type == SUN4V_CHIP_SPARC_M6 || |
531 | sun4v_chip_type == SUN4V_CHIP_SPARC_M7 || | 538 | sun4v_chip_type == SUN4V_CHIP_SPARC_M7 || |
539 | sun4v_chip_type == SUN4V_CHIP_SPARC_M8 || | ||
532 | sun4v_chip_type == SUN4V_CHIP_SPARC_SN || | 540 | sun4v_chip_type == SUN4V_CHIP_SPARC_SN || |
533 | sun4v_chip_type == SUN4V_CHIP_SPARC64X) | 541 | sun4v_chip_type == SUN4V_CHIP_SPARC64X) |
534 | cap |= HWCAP_SPARC_BLKINIT; | 542 | cap |= HWCAP_SPARC_BLKINIT; |
@@ -538,6 +546,7 @@ static void __init init_sparc64_elf_hwcap(void) | |||
538 | sun4v_chip_type == SUN4V_CHIP_NIAGARA5 || | 546 | sun4v_chip_type == SUN4V_CHIP_NIAGARA5 || |
539 | sun4v_chip_type == SUN4V_CHIP_SPARC_M6 || | 547 | sun4v_chip_type == SUN4V_CHIP_SPARC_M6 || |
540 | sun4v_chip_type == SUN4V_CHIP_SPARC_M7 || | 548 | sun4v_chip_type == SUN4V_CHIP_SPARC_M7 || |
549 | sun4v_chip_type == SUN4V_CHIP_SPARC_M8 || | ||
541 | sun4v_chip_type == SUN4V_CHIP_SPARC_SN || | 550 | sun4v_chip_type == SUN4V_CHIP_SPARC_SN || |
542 | sun4v_chip_type == SUN4V_CHIP_SPARC64X) | 551 | sun4v_chip_type == SUN4V_CHIP_SPARC64X) |
543 | cap |= HWCAP_SPARC_N2; | 552 | cap |= HWCAP_SPARC_N2; |
@@ -568,6 +577,7 @@ static void __init init_sparc64_elf_hwcap(void) | |||
568 | sun4v_chip_type == SUN4V_CHIP_NIAGARA5 || | 577 | sun4v_chip_type == SUN4V_CHIP_NIAGARA5 || |
569 | sun4v_chip_type == SUN4V_CHIP_SPARC_M6 || | 578 | sun4v_chip_type == SUN4V_CHIP_SPARC_M6 || |
570 | sun4v_chip_type == SUN4V_CHIP_SPARC_M7 || | 579 | sun4v_chip_type == SUN4V_CHIP_SPARC_M7 || |
580 | sun4v_chip_type == SUN4V_CHIP_SPARC_M8 || | ||
571 | sun4v_chip_type == SUN4V_CHIP_SPARC_SN || | 581 | sun4v_chip_type == SUN4V_CHIP_SPARC_SN || |
572 | sun4v_chip_type == SUN4V_CHIP_SPARC64X) | 582 | sun4v_chip_type == SUN4V_CHIP_SPARC64X) |
573 | cap |= (AV_SPARC_VIS | AV_SPARC_VIS2 | | 583 | cap |= (AV_SPARC_VIS | AV_SPARC_VIS2 | |
@@ -578,6 +588,7 @@ static void __init init_sparc64_elf_hwcap(void) | |||
578 | sun4v_chip_type == SUN4V_CHIP_NIAGARA5 || | 588 | sun4v_chip_type == SUN4V_CHIP_NIAGARA5 || |
579 | sun4v_chip_type == SUN4V_CHIP_SPARC_M6 || | 589 | sun4v_chip_type == SUN4V_CHIP_SPARC_M6 || |
580 | sun4v_chip_type == SUN4V_CHIP_SPARC_M7 || | 590 | sun4v_chip_type == SUN4V_CHIP_SPARC_M7 || |
591 | sun4v_chip_type == SUN4V_CHIP_SPARC_M8 || | ||
581 | sun4v_chip_type == SUN4V_CHIP_SPARC_SN || | 592 | sun4v_chip_type == SUN4V_CHIP_SPARC_SN || |
582 | sun4v_chip_type == SUN4V_CHIP_SPARC64X) | 593 | sun4v_chip_type == SUN4V_CHIP_SPARC64X) |
583 | cap |= (AV_SPARC_VIS3 | AV_SPARC_HPC | | 594 | cap |= (AV_SPARC_VIS3 | AV_SPARC_HPC | |
diff --git a/arch/sparc/lib/multi3.S b/arch/sparc/lib/multi3.S index d6b6c97fe3c7..703127aaf4a5 100644 --- a/arch/sparc/lib/multi3.S +++ b/arch/sparc/lib/multi3.S | |||
@@ -5,26 +5,26 @@ | |||
5 | .align 4 | 5 | .align 4 |
6 | ENTRY(__multi3) /* %o0 = u, %o1 = v */ | 6 | ENTRY(__multi3) /* %o0 = u, %o1 = v */ |
7 | mov %o1, %g1 | 7 | mov %o1, %g1 |
8 | srl %o3, 0, %g4 | 8 | srl %o3, 0, %o4 |
9 | mulx %g4, %g1, %o1 | 9 | mulx %o4, %g1, %o1 |
10 | srlx %g1, 0x20, %g3 | 10 | srlx %g1, 0x20, %g3 |
11 | mulx %g3, %g4, %g5 | 11 | mulx %g3, %o4, %g7 |
12 | sllx %g5, 0x20, %o5 | 12 | sllx %g7, 0x20, %o5 |
13 | srl %g1, 0, %g4 | 13 | srl %g1, 0, %o4 |
14 | sub %o1, %o5, %o5 | 14 | sub %o1, %o5, %o5 |
15 | srlx %o5, 0x20, %o5 | 15 | srlx %o5, 0x20, %o5 |
16 | addcc %g5, %o5, %g5 | 16 | addcc %g7, %o5, %g7 |
17 | srlx %o3, 0x20, %o5 | 17 | srlx %o3, 0x20, %o5 |
18 | mulx %g4, %o5, %g4 | 18 | mulx %o4, %o5, %o4 |
19 | mulx %g3, %o5, %o5 | 19 | mulx %g3, %o5, %o5 |
20 | sethi %hi(0x80000000), %g3 | 20 | sethi %hi(0x80000000), %g3 |
21 | addcc %g5, %g4, %g5 | 21 | addcc %g7, %o4, %g7 |
22 | srlx %g5, 0x20, %g5 | 22 | srlx %g7, 0x20, %g7 |
23 | add %g3, %g3, %g3 | 23 | add %g3, %g3, %g3 |
24 | movcc %xcc, %g0, %g3 | 24 | movcc %xcc, %g0, %g3 |
25 | addcc %o5, %g5, %o5 | 25 | addcc %o5, %g7, %o5 |
26 | sllx %g4, 0x20, %g4 | 26 | sllx %o4, 0x20, %o4 |
27 | add %o1, %g4, %o1 | 27 | add %o1, %o4, %o1 |
28 | add %o5, %g3, %g2 | 28 | add %o5, %g3, %g2 |
29 | mulx %g1, %o2, %g1 | 29 | mulx %g1, %o2, %g1 |
30 | add %g1, %g2, %g1 | 30 | add %g1, %g2, %g1 |
diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c index fed73f14aa49..afa0099f3748 100644 --- a/arch/sparc/mm/init_64.c +++ b/arch/sparc/mm/init_64.c | |||
@@ -1944,12 +1944,22 @@ static void __init setup_page_offset(void) | |||
1944 | break; | 1944 | break; |
1945 | case SUN4V_CHIP_SPARC_M7: | 1945 | case SUN4V_CHIP_SPARC_M7: |
1946 | case SUN4V_CHIP_SPARC_SN: | 1946 | case SUN4V_CHIP_SPARC_SN: |
1947 | default: | ||
1948 | /* M7 and later support 52-bit virtual addresses. */ | 1947 | /* M7 and later support 52-bit virtual addresses. */ |
1949 | sparc64_va_hole_top = 0xfff8000000000000UL; | 1948 | sparc64_va_hole_top = 0xfff8000000000000UL; |
1950 | sparc64_va_hole_bottom = 0x0008000000000000UL; | 1949 | sparc64_va_hole_bottom = 0x0008000000000000UL; |
1951 | max_phys_bits = 49; | 1950 | max_phys_bits = 49; |
1952 | break; | 1951 | break; |
1952 | case SUN4V_CHIP_SPARC_M8: | ||
1953 | default: | ||
1954 | /* M8 and later support 54-bit virtual addresses. | ||
1955 | * However, restricting M8 and above VA bits to 53 | ||
1956 | * as 4-level page table cannot support more than | ||
1957 | * 53 VA bits. | ||
1958 | */ | ||
1959 | sparc64_va_hole_top = 0xfff0000000000000UL; | ||
1960 | sparc64_va_hole_bottom = 0x0010000000000000UL; | ||
1961 | max_phys_bits = 51; | ||
1962 | break; | ||
1953 | } | 1963 | } |
1954 | } | 1964 | } |
1955 | 1965 | ||
@@ -2161,6 +2171,7 @@ static void __init sun4v_linear_pte_xor_finalize(void) | |||
2161 | */ | 2171 | */ |
2162 | switch (sun4v_chip_type) { | 2172 | switch (sun4v_chip_type) { |
2163 | case SUN4V_CHIP_SPARC_M7: | 2173 | case SUN4V_CHIP_SPARC_M7: |
2174 | case SUN4V_CHIP_SPARC_M8: | ||
2164 | case SUN4V_CHIP_SPARC_SN: | 2175 | case SUN4V_CHIP_SPARC_SN: |
2165 | pagecv_flag = 0x00; | 2176 | pagecv_flag = 0x00; |
2166 | break; | 2177 | break; |
@@ -2313,6 +2324,7 @@ void __init paging_init(void) | |||
2313 | */ | 2324 | */ |
2314 | switch (sun4v_chip_type) { | 2325 | switch (sun4v_chip_type) { |
2315 | case SUN4V_CHIP_SPARC_M7: | 2326 | case SUN4V_CHIP_SPARC_M7: |
2327 | case SUN4V_CHIP_SPARC_M8: | ||
2316 | case SUN4V_CHIP_SPARC_SN: | 2328 | case SUN4V_CHIP_SPARC_SN: |
2317 | page_cache4v_flag = _PAGE_CP_4V; | 2329 | page_cache4v_flag = _PAGE_CP_4V; |
2318 | break; | 2330 | break; |
diff --git a/arch/um/include/asm/tlb.h b/arch/um/include/asm/tlb.h index 600a2e9bfee2..344d95619d03 100644 --- a/arch/um/include/asm/tlb.h +++ b/arch/um/include/asm/tlb.h | |||
@@ -45,7 +45,8 @@ static inline void init_tlb_gather(struct mmu_gather *tlb) | |||
45 | } | 45 | } |
46 | 46 | ||
47 | static inline void | 47 | static inline void |
48 | tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, unsigned long start, unsigned long end) | 48 | arch_tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, |
49 | unsigned long start, unsigned long end) | ||
49 | { | 50 | { |
50 | tlb->mm = mm; | 51 | tlb->mm = mm; |
51 | tlb->start = start; | 52 | tlb->start = start; |
@@ -80,13 +81,19 @@ tlb_flush_mmu(struct mmu_gather *tlb) | |||
80 | tlb_flush_mmu_free(tlb); | 81 | tlb_flush_mmu_free(tlb); |
81 | } | 82 | } |
82 | 83 | ||
83 | /* tlb_finish_mmu | 84 | /* arch_tlb_finish_mmu |
84 | * Called at the end of the shootdown operation to free up any resources | 85 | * Called at the end of the shootdown operation to free up any resources |
85 | * that were required. | 86 | * that were required. |
86 | */ | 87 | */ |
87 | static inline void | 88 | static inline void |
88 | tlb_finish_mmu(struct mmu_gather *tlb, unsigned long start, unsigned long end) | 89 | arch_tlb_finish_mmu(struct mmu_gather *tlb, |
90 | unsigned long start, unsigned long end, bool force) | ||
89 | { | 91 | { |
92 | if (force) { | ||
93 | tlb->start = start; | ||
94 | tlb->end = end; | ||
95 | tlb->need_flush = 1; | ||
96 | } | ||
90 | tlb_flush_mmu(tlb); | 97 | tlb_flush_mmu(tlb); |
91 | 98 | ||
92 | /* keep the page table cache within bounds */ | 99 | /* keep the page table cache within bounds */ |
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 781521b7cf9e..87e447286c37 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig | |||
@@ -100,6 +100,7 @@ config X86 | |||
100 | select GENERIC_STRNCPY_FROM_USER | 100 | select GENERIC_STRNCPY_FROM_USER |
101 | select GENERIC_STRNLEN_USER | 101 | select GENERIC_STRNLEN_USER |
102 | select GENERIC_TIME_VSYSCALL | 102 | select GENERIC_TIME_VSYSCALL |
103 | select HARDLOCKUP_CHECK_TIMESTAMP if X86_64 | ||
103 | select HAVE_ACPI_APEI if ACPI | 104 | select HAVE_ACPI_APEI if ACPI |
104 | select HAVE_ACPI_APEI_NMI if ACPI | 105 | select HAVE_ACPI_APEI_NMI if ACPI |
105 | select HAVE_ALIGNED_STRUCT_PAGE if SLUB | 106 | select HAVE_ALIGNED_STRUCT_PAGE if SLUB |
@@ -163,9 +164,10 @@ config X86 | |||
163 | select HAVE_PCSPKR_PLATFORM | 164 | select HAVE_PCSPKR_PLATFORM |
164 | select HAVE_PERF_EVENTS | 165 | select HAVE_PERF_EVENTS |
165 | select HAVE_PERF_EVENTS_NMI | 166 | select HAVE_PERF_EVENTS_NMI |
166 | select HAVE_HARDLOCKUP_DETECTOR_PERF if HAVE_PERF_EVENTS_NMI | 167 | select HAVE_HARDLOCKUP_DETECTOR_PERF if PERF_EVENTS && HAVE_PERF_EVENTS_NMI |
167 | select HAVE_PERF_REGS | 168 | select HAVE_PERF_REGS |
168 | select HAVE_PERF_USER_STACK_DUMP | 169 | select HAVE_PERF_USER_STACK_DUMP |
170 | select HAVE_RCU_TABLE_FREE | ||
169 | select HAVE_REGS_AND_STACK_ACCESS_API | 171 | select HAVE_REGS_AND_STACK_ACCESS_API |
170 | select HAVE_RELIABLE_STACKTRACE if X86_64 && FRAME_POINTER && STACK_VALIDATION | 172 | select HAVE_RELIABLE_STACKTRACE if X86_64 && FRAME_POINTER && STACK_VALIDATION |
171 | select HAVE_STACK_VALIDATION if X86_64 | 173 | select HAVE_STACK_VALIDATION if X86_64 |
@@ -326,6 +328,7 @@ config FIX_EARLYCON_MEM | |||
326 | 328 | ||
327 | config PGTABLE_LEVELS | 329 | config PGTABLE_LEVELS |
328 | int | 330 | int |
331 | default 5 if X86_5LEVEL | ||
329 | default 4 if X86_64 | 332 | default 4 if X86_64 |
330 | default 3 if X86_PAE | 333 | default 3 if X86_PAE |
331 | default 2 | 334 | default 2 |
@@ -1398,6 +1401,24 @@ config X86_PAE | |||
1398 | has the cost of more pagetable lookup overhead, and also | 1401 | has the cost of more pagetable lookup overhead, and also |
1399 | consumes more pagetable space per process. | 1402 | consumes more pagetable space per process. |
1400 | 1403 | ||
1404 | config X86_5LEVEL | ||
1405 | bool "Enable 5-level page tables support" | ||
1406 | depends on X86_64 | ||
1407 | ---help--- | ||
1408 | 5-level paging enables access to larger address space: | ||
1409 | upto 128 PiB of virtual address space and 4 PiB of | ||
1410 | physical address space. | ||
1411 | |||
1412 | It will be supported by future Intel CPUs. | ||
1413 | |||
1414 | Note: a kernel with this option enabled can only be booted | ||
1415 | on machines that support the feature. | ||
1416 | |||
1417 | See Documentation/x86/x86_64/5level-paging.txt for more | ||
1418 | information. | ||
1419 | |||
1420 | Say N if unsure. | ||
1421 | |||
1401 | config ARCH_PHYS_ADDR_T_64BIT | 1422 | config ARCH_PHYS_ADDR_T_64BIT |
1402 | def_bool y | 1423 | def_bool y |
1403 | depends on X86_64 || X86_PAE | 1424 | depends on X86_64 || X86_PAE |
@@ -1415,6 +1436,35 @@ config X86_DIRECT_GBPAGES | |||
1415 | supports them), so don't confuse the user by printing | 1436 | supports them), so don't confuse the user by printing |
1416 | that we have them enabled. | 1437 | that we have them enabled. |
1417 | 1438 | ||
1439 | config ARCH_HAS_MEM_ENCRYPT | ||
1440 | def_bool y | ||
1441 | |||
1442 | config AMD_MEM_ENCRYPT | ||
1443 | bool "AMD Secure Memory Encryption (SME) support" | ||
1444 | depends on X86_64 && CPU_SUP_AMD | ||
1445 | ---help--- | ||
1446 | Say yes to enable support for the encryption of system memory. | ||
1447 | This requires an AMD processor that supports Secure Memory | ||
1448 | Encryption (SME). | ||
1449 | |||
1450 | config AMD_MEM_ENCRYPT_ACTIVE_BY_DEFAULT | ||
1451 | bool "Activate AMD Secure Memory Encryption (SME) by default" | ||
1452 | default y | ||
1453 | depends on AMD_MEM_ENCRYPT | ||
1454 | ---help--- | ||
1455 | Say yes to have system memory encrypted by default if running on | ||
1456 | an AMD processor that supports Secure Memory Encryption (SME). | ||
1457 | |||
1458 | If set to Y, then the encryption of system memory can be | ||
1459 | deactivated with the mem_encrypt=off command line option. | ||
1460 | |||
1461 | If set to N, then the encryption of system memory can be | ||
1462 | activated with the mem_encrypt=on command line option. | ||
1463 | |||
1464 | config ARCH_USE_MEMREMAP_PROT | ||
1465 | def_bool y | ||
1466 | depends on AMD_MEM_ENCRYPT | ||
1467 | |||
1418 | # Common NUMA Features | 1468 | # Common NUMA Features |
1419 | config NUMA | 1469 | config NUMA |
1420 | bool "Numa Memory Allocation and Scheduler Support" | 1470 | bool "Numa Memory Allocation and Scheduler Support" |
diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/kaslr.c index 91f27ab970ef..99c7194f7ea6 100644 --- a/arch/x86/boot/compressed/kaslr.c +++ b/arch/x86/boot/compressed/kaslr.c | |||
@@ -479,35 +479,31 @@ static unsigned long slots_fetch_random(void) | |||
479 | return 0; | 479 | return 0; |
480 | } | 480 | } |
481 | 481 | ||
482 | static void process_e820_entry(struct boot_e820_entry *entry, | 482 | static void process_mem_region(struct mem_vector *entry, |
483 | unsigned long minimum, | 483 | unsigned long minimum, |
484 | unsigned long image_size) | 484 | unsigned long image_size) |
485 | { | 485 | { |
486 | struct mem_vector region, overlap; | 486 | struct mem_vector region, overlap; |
487 | struct slot_area slot_area; | 487 | struct slot_area slot_area; |
488 | unsigned long start_orig, end; | 488 | unsigned long start_orig, end; |
489 | struct boot_e820_entry cur_entry; | 489 | struct mem_vector cur_entry; |
490 | |||
491 | /* Skip non-RAM entries. */ | ||
492 | if (entry->type != E820_TYPE_RAM) | ||
493 | return; | ||
494 | 490 | ||
495 | /* On 32-bit, ignore entries entirely above our maximum. */ | 491 | /* On 32-bit, ignore entries entirely above our maximum. */ |
496 | if (IS_ENABLED(CONFIG_X86_32) && entry->addr >= KERNEL_IMAGE_SIZE) | 492 | if (IS_ENABLED(CONFIG_X86_32) && entry->start >= KERNEL_IMAGE_SIZE) |
497 | return; | 493 | return; |
498 | 494 | ||
499 | /* Ignore entries entirely below our minimum. */ | 495 | /* Ignore entries entirely below our minimum. */ |
500 | if (entry->addr + entry->size < minimum) | 496 | if (entry->start + entry->size < minimum) |
501 | return; | 497 | return; |
502 | 498 | ||
503 | /* Ignore entries above memory limit */ | 499 | /* Ignore entries above memory limit */ |
504 | end = min(entry->size + entry->addr, mem_limit); | 500 | end = min(entry->size + entry->start, mem_limit); |
505 | if (entry->addr >= end) | 501 | if (entry->start >= end) |
506 | return; | 502 | return; |
507 | cur_entry.addr = entry->addr; | 503 | cur_entry.start = entry->start; |
508 | cur_entry.size = end - entry->addr; | 504 | cur_entry.size = end - entry->start; |
509 | 505 | ||
510 | region.start = cur_entry.addr; | 506 | region.start = cur_entry.start; |
511 | region.size = cur_entry.size; | 507 | region.size = cur_entry.size; |
512 | 508 | ||
513 | /* Give up if slot area array is full. */ | 509 | /* Give up if slot area array is full. */ |
@@ -521,8 +517,8 @@ static void process_e820_entry(struct boot_e820_entry *entry, | |||
521 | /* Potentially raise address to meet alignment needs. */ | 517 | /* Potentially raise address to meet alignment needs. */ |
522 | region.start = ALIGN(region.start, CONFIG_PHYSICAL_ALIGN); | 518 | region.start = ALIGN(region.start, CONFIG_PHYSICAL_ALIGN); |
523 | 519 | ||
524 | /* Did we raise the address above this e820 region? */ | 520 | /* Did we raise the address above the passed in memory entry? */ |
525 | if (region.start > cur_entry.addr + cur_entry.size) | 521 | if (region.start > cur_entry.start + cur_entry.size) |
526 | return; | 522 | return; |
527 | 523 | ||
528 | /* Reduce size by any delta from the original address. */ | 524 | /* Reduce size by any delta from the original address. */ |
@@ -562,12 +558,32 @@ static void process_e820_entry(struct boot_e820_entry *entry, | |||
562 | } | 558 | } |
563 | } | 559 | } |
564 | 560 | ||
565 | static unsigned long find_random_phys_addr(unsigned long minimum, | 561 | static void process_e820_entries(unsigned long minimum, |
566 | unsigned long image_size) | 562 | unsigned long image_size) |
567 | { | 563 | { |
568 | int i; | 564 | int i; |
569 | unsigned long addr; | 565 | struct mem_vector region; |
566 | struct boot_e820_entry *entry; | ||
567 | |||
568 | /* Verify potential e820 positions, appending to slots list. */ | ||
569 | for (i = 0; i < boot_params->e820_entries; i++) { | ||
570 | entry = &boot_params->e820_table[i]; | ||
571 | /* Skip non-RAM entries. */ | ||
572 | if (entry->type != E820_TYPE_RAM) | ||
573 | continue; | ||
574 | region.start = entry->addr; | ||
575 | region.size = entry->size; | ||
576 | process_mem_region(®ion, minimum, image_size); | ||
577 | if (slot_area_index == MAX_SLOT_AREA) { | ||
578 | debug_putstr("Aborted e820 scan (slot_areas full)!\n"); | ||
579 | break; | ||
580 | } | ||
581 | } | ||
582 | } | ||
570 | 583 | ||
584 | static unsigned long find_random_phys_addr(unsigned long minimum, | ||
585 | unsigned long image_size) | ||
586 | { | ||
571 | /* Check if we had too many memmaps. */ | 587 | /* Check if we had too many memmaps. */ |
572 | if (memmap_too_large) { | 588 | if (memmap_too_large) { |
573 | debug_putstr("Aborted e820 scan (more than 4 memmap= args)!\n"); | 589 | debug_putstr("Aborted e820 scan (more than 4 memmap= args)!\n"); |
@@ -577,16 +593,7 @@ static unsigned long find_random_phys_addr(unsigned long minimum, | |||
577 | /* Make sure minimum is aligned. */ | 593 | /* Make sure minimum is aligned. */ |
578 | minimum = ALIGN(minimum, CONFIG_PHYSICAL_ALIGN); | 594 | minimum = ALIGN(minimum, CONFIG_PHYSICAL_ALIGN); |
579 | 595 | ||
580 | /* Verify potential e820 positions, appending to slots list. */ | 596 | process_e820_entries(minimum, image_size); |
581 | for (i = 0; i < boot_params->e820_entries; i++) { | ||
582 | process_e820_entry(&boot_params->e820_table[i], minimum, | ||
583 | image_size); | ||
584 | if (slot_area_index == MAX_SLOT_AREA) { | ||
585 | debug_putstr("Aborted e820 scan (slot_areas full)!\n"); | ||
586 | break; | ||
587 | } | ||
588 | } | ||
589 | |||
590 | return slots_fetch_random(); | 597 | return slots_fetch_random(); |
591 | } | 598 | } |
592 | 599 | ||
diff --git a/arch/x86/boot/compressed/pagetable.c b/arch/x86/boot/compressed/pagetable.c index 28029be47fbb..f1aa43854bed 100644 --- a/arch/x86/boot/compressed/pagetable.c +++ b/arch/x86/boot/compressed/pagetable.c | |||
@@ -15,6 +15,13 @@ | |||
15 | #define __pa(x) ((unsigned long)(x)) | 15 | #define __pa(x) ((unsigned long)(x)) |
16 | #define __va(x) ((void *)((unsigned long)(x))) | 16 | #define __va(x) ((void *)((unsigned long)(x))) |
17 | 17 | ||
18 | /* | ||
19 | * The pgtable.h and mm/ident_map.c includes make use of the SME related | ||
20 | * information which is not used in the compressed image support. Un-define | ||
21 | * the SME support to avoid any compile and link errors. | ||
22 | */ | ||
23 | #undef CONFIG_AMD_MEM_ENCRYPT | ||
24 | |||
18 | #include "misc.h" | 25 | #include "misc.h" |
19 | 26 | ||
20 | /* These actually do the work of building the kernel identity maps. */ | 27 | /* These actually do the work of building the kernel identity maps. */ |
diff --git a/arch/x86/crypto/sha1_avx2_x86_64_asm.S b/arch/x86/crypto/sha1_avx2_x86_64_asm.S index 1cd792db15ef..1eab79c9ac48 100644 --- a/arch/x86/crypto/sha1_avx2_x86_64_asm.S +++ b/arch/x86/crypto/sha1_avx2_x86_64_asm.S | |||
@@ -117,11 +117,10 @@ | |||
117 | .set T1, REG_T1 | 117 | .set T1, REG_T1 |
118 | .endm | 118 | .endm |
119 | 119 | ||
120 | #define K_BASE %r8 | ||
121 | #define HASH_PTR %r9 | 120 | #define HASH_PTR %r9 |
121 | #define BLOCKS_CTR %r8 | ||
122 | #define BUFFER_PTR %r10 | 122 | #define BUFFER_PTR %r10 |
123 | #define BUFFER_PTR2 %r13 | 123 | #define BUFFER_PTR2 %r13 |
124 | #define BUFFER_END %r11 | ||
125 | 124 | ||
126 | #define PRECALC_BUF %r14 | 125 | #define PRECALC_BUF %r14 |
127 | #define WK_BUF %r15 | 126 | #define WK_BUF %r15 |
@@ -205,14 +204,14 @@ | |||
205 | * blended AVX2 and ALU instruction scheduling | 204 | * blended AVX2 and ALU instruction scheduling |
206 | * 1 vector iteration per 8 rounds | 205 | * 1 vector iteration per 8 rounds |
207 | */ | 206 | */ |
208 | vmovdqu ((i * 2) + PRECALC_OFFSET)(BUFFER_PTR), W_TMP | 207 | vmovdqu (i * 2)(BUFFER_PTR), W_TMP |
209 | .elseif ((i & 7) == 1) | 208 | .elseif ((i & 7) == 1) |
210 | vinsertf128 $1, (((i-1) * 2)+PRECALC_OFFSET)(BUFFER_PTR2),\ | 209 | vinsertf128 $1, ((i-1) * 2)(BUFFER_PTR2),\ |
211 | WY_TMP, WY_TMP | 210 | WY_TMP, WY_TMP |
212 | .elseif ((i & 7) == 2) | 211 | .elseif ((i & 7) == 2) |
213 | vpshufb YMM_SHUFB_BSWAP, WY_TMP, WY | 212 | vpshufb YMM_SHUFB_BSWAP, WY_TMP, WY |
214 | .elseif ((i & 7) == 4) | 213 | .elseif ((i & 7) == 4) |
215 | vpaddd K_XMM(K_BASE), WY, WY_TMP | 214 | vpaddd K_XMM + K_XMM_AR(%rip), WY, WY_TMP |
216 | .elseif ((i & 7) == 7) | 215 | .elseif ((i & 7) == 7) |
217 | vmovdqu WY_TMP, PRECALC_WK(i&~7) | 216 | vmovdqu WY_TMP, PRECALC_WK(i&~7) |
218 | 217 | ||
@@ -255,7 +254,7 @@ | |||
255 | vpxor WY, WY_TMP, WY_TMP | 254 | vpxor WY, WY_TMP, WY_TMP |
256 | .elseif ((i & 7) == 7) | 255 | .elseif ((i & 7) == 7) |
257 | vpxor WY_TMP2, WY_TMP, WY | 256 | vpxor WY_TMP2, WY_TMP, WY |
258 | vpaddd K_XMM(K_BASE), WY, WY_TMP | 257 | vpaddd K_XMM + K_XMM_AR(%rip), WY, WY_TMP |
259 | vmovdqu WY_TMP, PRECALC_WK(i&~7) | 258 | vmovdqu WY_TMP, PRECALC_WK(i&~7) |
260 | 259 | ||
261 | PRECALC_ROTATE_WY | 260 | PRECALC_ROTATE_WY |
@@ -291,7 +290,7 @@ | |||
291 | vpsrld $30, WY, WY | 290 | vpsrld $30, WY, WY |
292 | vpor WY, WY_TMP, WY | 291 | vpor WY, WY_TMP, WY |
293 | .elseif ((i & 7) == 7) | 292 | .elseif ((i & 7) == 7) |
294 | vpaddd K_XMM(K_BASE), WY, WY_TMP | 293 | vpaddd K_XMM + K_XMM_AR(%rip), WY, WY_TMP |
295 | vmovdqu WY_TMP, PRECALC_WK(i&~7) | 294 | vmovdqu WY_TMP, PRECALC_WK(i&~7) |
296 | 295 | ||
297 | PRECALC_ROTATE_WY | 296 | PRECALC_ROTATE_WY |
@@ -446,6 +445,16 @@ | |||
446 | 445 | ||
447 | .endm | 446 | .endm |
448 | 447 | ||
448 | /* Add constant only if (%2 > %3) condition met (uses RTA as temp) | ||
449 | * %1 + %2 >= %3 ? %4 : 0 | ||
450 | */ | ||
451 | .macro ADD_IF_GE a, b, c, d | ||
452 | mov \a, RTA | ||
453 | add $\d, RTA | ||
454 | cmp $\c, \b | ||
455 | cmovge RTA, \a | ||
456 | .endm | ||
457 | |||
449 | /* | 458 | /* |
450 | * macro implements 80 rounds of SHA-1, for multiple blocks with s/w pipelining | 459 | * macro implements 80 rounds of SHA-1, for multiple blocks with s/w pipelining |
451 | */ | 460 | */ |
@@ -463,13 +472,16 @@ | |||
463 | lea (2*4*80+32)(%rsp), WK_BUF | 472 | lea (2*4*80+32)(%rsp), WK_BUF |
464 | 473 | ||
465 | # Precalc WK for first 2 blocks | 474 | # Precalc WK for first 2 blocks |
466 | PRECALC_OFFSET = 0 | 475 | ADD_IF_GE BUFFER_PTR2, BLOCKS_CTR, 2, 64 |
467 | .set i, 0 | 476 | .set i, 0 |
468 | .rept 160 | 477 | .rept 160 |
469 | PRECALC i | 478 | PRECALC i |
470 | .set i, i + 1 | 479 | .set i, i + 1 |
471 | .endr | 480 | .endr |
472 | PRECALC_OFFSET = 128 | 481 | |
482 | /* Go to next block if needed */ | ||
483 | ADD_IF_GE BUFFER_PTR, BLOCKS_CTR, 3, 128 | ||
484 | ADD_IF_GE BUFFER_PTR2, BLOCKS_CTR, 4, 128 | ||
473 | xchg WK_BUF, PRECALC_BUF | 485 | xchg WK_BUF, PRECALC_BUF |
474 | 486 | ||
475 | .align 32 | 487 | .align 32 |
@@ -479,8 +491,8 @@ _loop: | |||
479 | * we use K_BASE value as a signal of a last block, | 491 | * we use K_BASE value as a signal of a last block, |
480 | * it is set below by: cmovae BUFFER_PTR, K_BASE | 492 | * it is set below by: cmovae BUFFER_PTR, K_BASE |
481 | */ | 493 | */ |
482 | cmp K_BASE, BUFFER_PTR | 494 | test BLOCKS_CTR, BLOCKS_CTR |
483 | jne _begin | 495 | jnz _begin |
484 | .align 32 | 496 | .align 32 |
485 | jmp _end | 497 | jmp _end |
486 | .align 32 | 498 | .align 32 |
@@ -512,10 +524,10 @@ _loop0: | |||
512 | .set j, j+2 | 524 | .set j, j+2 |
513 | .endr | 525 | .endr |
514 | 526 | ||
515 | add $(2*64), BUFFER_PTR /* move to next odd-64-byte block */ | 527 | /* Update Counter */ |
516 | cmp BUFFER_END, BUFFER_PTR /* is current block the last one? */ | 528 | sub $1, BLOCKS_CTR |
517 | cmovae K_BASE, BUFFER_PTR /* signal the last iteration smartly */ | 529 | /* Move to the next block only if needed*/ |
518 | 530 | ADD_IF_GE BUFFER_PTR, BLOCKS_CTR, 4, 128 | |
519 | /* | 531 | /* |
520 | * rounds | 532 | * rounds |
521 | * 60,62,64,66,68 | 533 | * 60,62,64,66,68 |
@@ -532,8 +544,8 @@ _loop0: | |||
532 | UPDATE_HASH 12(HASH_PTR), D | 544 | UPDATE_HASH 12(HASH_PTR), D |
533 | UPDATE_HASH 16(HASH_PTR), E | 545 | UPDATE_HASH 16(HASH_PTR), E |
534 | 546 | ||
535 | cmp K_BASE, BUFFER_PTR /* is current block the last one? */ | 547 | test BLOCKS_CTR, BLOCKS_CTR |
536 | je _loop | 548 | jz _loop |
537 | 549 | ||
538 | mov TB, B | 550 | mov TB, B |
539 | 551 | ||
@@ -575,10 +587,10 @@ _loop2: | |||
575 | .set j, j+2 | 587 | .set j, j+2 |
576 | .endr | 588 | .endr |
577 | 589 | ||
578 | add $(2*64), BUFFER_PTR2 /* move to next even-64-byte block */ | 590 | /* update counter */ |
579 | 591 | sub $1, BLOCKS_CTR | |
580 | cmp BUFFER_END, BUFFER_PTR2 /* is current block the last one */ | 592 | /* Move to the next block only if needed*/ |
581 | cmovae K_BASE, BUFFER_PTR /* signal the last iteration smartly */ | 593 | ADD_IF_GE BUFFER_PTR2, BLOCKS_CTR, 4, 128 |
582 | 594 | ||
583 | jmp _loop3 | 595 | jmp _loop3 |
584 | _loop3: | 596 | _loop3: |
@@ -641,19 +653,12 @@ _loop3: | |||
641 | 653 | ||
642 | avx2_zeroupper | 654 | avx2_zeroupper |
643 | 655 | ||
644 | lea K_XMM_AR(%rip), K_BASE | 656 | /* Setup initial values */ |
645 | |||
646 | mov CTX, HASH_PTR | 657 | mov CTX, HASH_PTR |
647 | mov BUF, BUFFER_PTR | 658 | mov BUF, BUFFER_PTR |
648 | lea 64(BUF), BUFFER_PTR2 | ||
649 | |||
650 | shl $6, CNT /* mul by 64 */ | ||
651 | add BUF, CNT | ||
652 | add $64, CNT | ||
653 | mov CNT, BUFFER_END | ||
654 | 659 | ||
655 | cmp BUFFER_END, BUFFER_PTR2 | 660 | mov BUF, BUFFER_PTR2 |
656 | cmovae K_BASE, BUFFER_PTR2 | 661 | mov CNT, BLOCKS_CTR |
657 | 662 | ||
658 | xmm_mov BSWAP_SHUFB_CTL(%rip), YMM_SHUFB_BSWAP | 663 | xmm_mov BSWAP_SHUFB_CTL(%rip), YMM_SHUFB_BSWAP |
659 | 664 | ||
diff --git a/arch/x86/crypto/sha1_ssse3_glue.c b/arch/x86/crypto/sha1_ssse3_glue.c index f960a043cdeb..fc61739150e7 100644 --- a/arch/x86/crypto/sha1_ssse3_glue.c +++ b/arch/x86/crypto/sha1_ssse3_glue.c | |||
@@ -201,7 +201,7 @@ asmlinkage void sha1_transform_avx2(u32 *digest, const char *data, | |||
201 | 201 | ||
202 | static bool avx2_usable(void) | 202 | static bool avx2_usable(void) |
203 | { | 203 | { |
204 | if (false && avx_usable() && boot_cpu_has(X86_FEATURE_AVX2) | 204 | if (avx_usable() && boot_cpu_has(X86_FEATURE_AVX2) |
205 | && boot_cpu_has(X86_FEATURE_BMI1) | 205 | && boot_cpu_has(X86_FEATURE_BMI1) |
206 | && boot_cpu_has(X86_FEATURE_BMI2)) | 206 | && boot_cpu_has(X86_FEATURE_BMI2)) |
207 | return true; | 207 | return true; |
diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S index d271fb79248f..6d078b89a5e8 100644 --- a/arch/x86/entry/entry_64.S +++ b/arch/x86/entry/entry_64.S | |||
@@ -1211,6 +1211,8 @@ ENTRY(nmi) | |||
1211 | * other IST entries. | 1211 | * other IST entries. |
1212 | */ | 1212 | */ |
1213 | 1213 | ||
1214 | ASM_CLAC | ||
1215 | |||
1214 | /* Use %rdx as our temp variable throughout */ | 1216 | /* Use %rdx as our temp variable throughout */ |
1215 | pushq %rdx | 1217 | pushq %rdx |
1216 | 1218 | ||
diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c index 8e3db8f642a7..af12e294caed 100644 --- a/arch/x86/events/core.c +++ b/arch/x86/events/core.c | |||
@@ -2114,7 +2114,7 @@ static void refresh_pce(void *ignored) | |||
2114 | load_mm_cr4(this_cpu_read(cpu_tlbstate.loaded_mm)); | 2114 | load_mm_cr4(this_cpu_read(cpu_tlbstate.loaded_mm)); |
2115 | } | 2115 | } |
2116 | 2116 | ||
2117 | static void x86_pmu_event_mapped(struct perf_event *event) | 2117 | static void x86_pmu_event_mapped(struct perf_event *event, struct mm_struct *mm) |
2118 | { | 2118 | { |
2119 | if (!(event->hw.flags & PERF_X86_EVENT_RDPMC_ALLOWED)) | 2119 | if (!(event->hw.flags & PERF_X86_EVENT_RDPMC_ALLOWED)) |
2120 | return; | 2120 | return; |
@@ -2129,22 +2129,20 @@ static void x86_pmu_event_mapped(struct perf_event *event) | |||
2129 | * For now, this can't happen because all callers hold mmap_sem | 2129 | * For now, this can't happen because all callers hold mmap_sem |
2130 | * for write. If this changes, we'll need a different solution. | 2130 | * for write. If this changes, we'll need a different solution. |
2131 | */ | 2131 | */ |
2132 | lockdep_assert_held_exclusive(¤t->mm->mmap_sem); | 2132 | lockdep_assert_held_exclusive(&mm->mmap_sem); |
2133 | 2133 | ||
2134 | if (atomic_inc_return(¤t->mm->context.perf_rdpmc_allowed) == 1) | 2134 | if (atomic_inc_return(&mm->context.perf_rdpmc_allowed) == 1) |
2135 | on_each_cpu_mask(mm_cpumask(current->mm), refresh_pce, NULL, 1); | 2135 | on_each_cpu_mask(mm_cpumask(mm), refresh_pce, NULL, 1); |
2136 | } | 2136 | } |
2137 | 2137 | ||
2138 | static void x86_pmu_event_unmapped(struct perf_event *event) | 2138 | static void x86_pmu_event_unmapped(struct perf_event *event, struct mm_struct *mm) |
2139 | { | 2139 | { |
2140 | if (!current->mm) | ||
2141 | return; | ||
2142 | 2140 | ||
2143 | if (!(event->hw.flags & PERF_X86_EVENT_RDPMC_ALLOWED)) | 2141 | if (!(event->hw.flags & PERF_X86_EVENT_RDPMC_ALLOWED)) |
2144 | return; | 2142 | return; |
2145 | 2143 | ||
2146 | if (atomic_dec_and_test(¤t->mm->context.perf_rdpmc_allowed)) | 2144 | if (atomic_dec_and_test(&mm->context.perf_rdpmc_allowed)) |
2147 | on_each_cpu_mask(mm_cpumask(current->mm), refresh_pce, NULL, 1); | 2145 | on_each_cpu_mask(mm_cpumask(mm), refresh_pce, NULL, 1); |
2148 | } | 2146 | } |
2149 | 2147 | ||
2150 | static int x86_pmu_event_idx(struct perf_event *event) | 2148 | static int x86_pmu_event_idx(struct perf_event *event) |
diff --git a/arch/x86/events/intel/bts.c b/arch/x86/events/intel/bts.c index 8ae8c5ce3a1f..ddd8d3516bfc 100644 --- a/arch/x86/events/intel/bts.c +++ b/arch/x86/events/intel/bts.c | |||
@@ -69,7 +69,7 @@ struct bts_buffer { | |||
69 | struct bts_phys buf[0]; | 69 | struct bts_phys buf[0]; |
70 | }; | 70 | }; |
71 | 71 | ||
72 | struct pmu bts_pmu; | 72 | static struct pmu bts_pmu; |
73 | 73 | ||
74 | static size_t buf_size(struct page *page) | 74 | static size_t buf_size(struct page *page) |
75 | { | 75 | { |
diff --git a/arch/x86/events/intel/p4.c b/arch/x86/events/intel/p4.c index eb0533558c2b..d32c0eed38ca 100644 --- a/arch/x86/events/intel/p4.c +++ b/arch/x86/events/intel/p4.c | |||
@@ -587,7 +587,7 @@ static __initconst const u64 p4_hw_cache_event_ids | |||
587 | * P4_CONFIG_ALIASABLE or bits for P4_PEBS_METRIC, they are | 587 | * P4_CONFIG_ALIASABLE or bits for P4_PEBS_METRIC, they are |
588 | * either up to date automatically or not applicable at all. | 588 | * either up to date automatically or not applicable at all. |
589 | */ | 589 | */ |
590 | struct p4_event_alias { | 590 | static struct p4_event_alias { |
591 | u64 original; | 591 | u64 original; |
592 | u64 alternative; | 592 | u64 alternative; |
593 | } p4_event_aliases[] = { | 593 | } p4_event_aliases[] = { |
diff --git a/arch/x86/events/intel/rapl.c b/arch/x86/events/intel/rapl.c index a45e2114a846..8e2457cb6b4a 100644 --- a/arch/x86/events/intel/rapl.c +++ b/arch/x86/events/intel/rapl.c | |||
@@ -559,7 +559,7 @@ static struct attribute_group rapl_pmu_format_group = { | |||
559 | .attrs = rapl_formats_attr, | 559 | .attrs = rapl_formats_attr, |
560 | }; | 560 | }; |
561 | 561 | ||
562 | const struct attribute_group *rapl_attr_groups[] = { | 562 | static const struct attribute_group *rapl_attr_groups[] = { |
563 | &rapl_pmu_attr_group, | 563 | &rapl_pmu_attr_group, |
564 | &rapl_pmu_format_group, | 564 | &rapl_pmu_format_group, |
565 | &rapl_pmu_events_group, | 565 | &rapl_pmu_events_group, |
diff --git a/arch/x86/events/intel/uncore.c b/arch/x86/events/intel/uncore.c index 44ec523287f6..1c5390f1cf09 100644 --- a/arch/x86/events/intel/uncore.c +++ b/arch/x86/events/intel/uncore.c | |||
@@ -721,7 +721,7 @@ static struct attribute *uncore_pmu_attrs[] = { | |||
721 | NULL, | 721 | NULL, |
722 | }; | 722 | }; |
723 | 723 | ||
724 | static struct attribute_group uncore_pmu_attr_group = { | 724 | static const struct attribute_group uncore_pmu_attr_group = { |
725 | .attrs = uncore_pmu_attrs, | 725 | .attrs = uncore_pmu_attrs, |
726 | }; | 726 | }; |
727 | 727 | ||
diff --git a/arch/x86/events/intel/uncore_nhmex.c b/arch/x86/events/intel/uncore_nhmex.c index cda569332005..6a5cbe90f859 100644 --- a/arch/x86/events/intel/uncore_nhmex.c +++ b/arch/x86/events/intel/uncore_nhmex.c | |||
@@ -272,7 +272,7 @@ static struct attribute *nhmex_uncore_ubox_formats_attr[] = { | |||
272 | NULL, | 272 | NULL, |
273 | }; | 273 | }; |
274 | 274 | ||
275 | static struct attribute_group nhmex_uncore_ubox_format_group = { | 275 | static const struct attribute_group nhmex_uncore_ubox_format_group = { |
276 | .name = "format", | 276 | .name = "format", |
277 | .attrs = nhmex_uncore_ubox_formats_attr, | 277 | .attrs = nhmex_uncore_ubox_formats_attr, |
278 | }; | 278 | }; |
@@ -299,7 +299,7 @@ static struct attribute *nhmex_uncore_cbox_formats_attr[] = { | |||
299 | NULL, | 299 | NULL, |
300 | }; | 300 | }; |
301 | 301 | ||
302 | static struct attribute_group nhmex_uncore_cbox_format_group = { | 302 | static const struct attribute_group nhmex_uncore_cbox_format_group = { |
303 | .name = "format", | 303 | .name = "format", |
304 | .attrs = nhmex_uncore_cbox_formats_attr, | 304 | .attrs = nhmex_uncore_cbox_formats_attr, |
305 | }; | 305 | }; |
@@ -407,7 +407,7 @@ static struct attribute *nhmex_uncore_bbox_formats_attr[] = { | |||
407 | NULL, | 407 | NULL, |
408 | }; | 408 | }; |
409 | 409 | ||
410 | static struct attribute_group nhmex_uncore_bbox_format_group = { | 410 | static const struct attribute_group nhmex_uncore_bbox_format_group = { |
411 | .name = "format", | 411 | .name = "format", |
412 | .attrs = nhmex_uncore_bbox_formats_attr, | 412 | .attrs = nhmex_uncore_bbox_formats_attr, |
413 | }; | 413 | }; |
@@ -484,7 +484,7 @@ static struct attribute *nhmex_uncore_sbox_formats_attr[] = { | |||
484 | NULL, | 484 | NULL, |
485 | }; | 485 | }; |
486 | 486 | ||
487 | static struct attribute_group nhmex_uncore_sbox_format_group = { | 487 | static const struct attribute_group nhmex_uncore_sbox_format_group = { |
488 | .name = "format", | 488 | .name = "format", |
489 | .attrs = nhmex_uncore_sbox_formats_attr, | 489 | .attrs = nhmex_uncore_sbox_formats_attr, |
490 | }; | 490 | }; |
@@ -898,7 +898,7 @@ static struct attribute *nhmex_uncore_mbox_formats_attr[] = { | |||
898 | NULL, | 898 | NULL, |
899 | }; | 899 | }; |
900 | 900 | ||
901 | static struct attribute_group nhmex_uncore_mbox_format_group = { | 901 | static const struct attribute_group nhmex_uncore_mbox_format_group = { |
902 | .name = "format", | 902 | .name = "format", |
903 | .attrs = nhmex_uncore_mbox_formats_attr, | 903 | .attrs = nhmex_uncore_mbox_formats_attr, |
904 | }; | 904 | }; |
@@ -1163,7 +1163,7 @@ static struct attribute *nhmex_uncore_rbox_formats_attr[] = { | |||
1163 | NULL, | 1163 | NULL, |
1164 | }; | 1164 | }; |
1165 | 1165 | ||
1166 | static struct attribute_group nhmex_uncore_rbox_format_group = { | 1166 | static const struct attribute_group nhmex_uncore_rbox_format_group = { |
1167 | .name = "format", | 1167 | .name = "format", |
1168 | .attrs = nhmex_uncore_rbox_formats_attr, | 1168 | .attrs = nhmex_uncore_rbox_formats_attr, |
1169 | }; | 1169 | }; |
diff --git a/arch/x86/events/intel/uncore_snb.c b/arch/x86/events/intel/uncore_snb.c index a3dcc12bef4a..db1127ce685e 100644 --- a/arch/x86/events/intel/uncore_snb.c +++ b/arch/x86/events/intel/uncore_snb.c | |||
@@ -130,7 +130,7 @@ static struct attribute *snb_uncore_formats_attr[] = { | |||
130 | NULL, | 130 | NULL, |
131 | }; | 131 | }; |
132 | 132 | ||
133 | static struct attribute_group snb_uncore_format_group = { | 133 | static const struct attribute_group snb_uncore_format_group = { |
134 | .name = "format", | 134 | .name = "format", |
135 | .attrs = snb_uncore_formats_attr, | 135 | .attrs = snb_uncore_formats_attr, |
136 | }; | 136 | }; |
@@ -289,7 +289,7 @@ static struct attribute *snb_uncore_imc_formats_attr[] = { | |||
289 | NULL, | 289 | NULL, |
290 | }; | 290 | }; |
291 | 291 | ||
292 | static struct attribute_group snb_uncore_imc_format_group = { | 292 | static const struct attribute_group snb_uncore_imc_format_group = { |
293 | .name = "format", | 293 | .name = "format", |
294 | .attrs = snb_uncore_imc_formats_attr, | 294 | .attrs = snb_uncore_imc_formats_attr, |
295 | }; | 295 | }; |
@@ -769,7 +769,7 @@ static struct attribute *nhm_uncore_formats_attr[] = { | |||
769 | NULL, | 769 | NULL, |
770 | }; | 770 | }; |
771 | 771 | ||
772 | static struct attribute_group nhm_uncore_format_group = { | 772 | static const struct attribute_group nhm_uncore_format_group = { |
773 | .name = "format", | 773 | .name = "format", |
774 | .attrs = nhm_uncore_formats_attr, | 774 | .attrs = nhm_uncore_formats_attr, |
775 | }; | 775 | }; |
diff --git a/arch/x86/events/intel/uncore_snbep.c b/arch/x86/events/intel/uncore_snbep.c index 4f9127644b80..db1fe377e6dd 100644 --- a/arch/x86/events/intel/uncore_snbep.c +++ b/arch/x86/events/intel/uncore_snbep.c | |||
@@ -602,27 +602,27 @@ static struct uncore_event_desc snbep_uncore_qpi_events[] = { | |||
602 | { /* end: all zeroes */ }, | 602 | { /* end: all zeroes */ }, |
603 | }; | 603 | }; |
604 | 604 | ||
605 | static struct attribute_group snbep_uncore_format_group = { | 605 | static const struct attribute_group snbep_uncore_format_group = { |
606 | .name = "format", | 606 | .name = "format", |
607 | .attrs = snbep_uncore_formats_attr, | 607 | .attrs = snbep_uncore_formats_attr, |
608 | }; | 608 | }; |
609 | 609 | ||
610 | static struct attribute_group snbep_uncore_ubox_format_group = { | 610 | static const struct attribute_group snbep_uncore_ubox_format_group = { |
611 | .name = "format", | 611 | .name = "format", |
612 | .attrs = snbep_uncore_ubox_formats_attr, | 612 | .attrs = snbep_uncore_ubox_formats_attr, |
613 | }; | 613 | }; |
614 | 614 | ||
615 | static struct attribute_group snbep_uncore_cbox_format_group = { | 615 | static const struct attribute_group snbep_uncore_cbox_format_group = { |
616 | .name = "format", | 616 | .name = "format", |
617 | .attrs = snbep_uncore_cbox_formats_attr, | 617 | .attrs = snbep_uncore_cbox_formats_attr, |
618 | }; | 618 | }; |
619 | 619 | ||
620 | static struct attribute_group snbep_uncore_pcu_format_group = { | 620 | static const struct attribute_group snbep_uncore_pcu_format_group = { |
621 | .name = "format", | 621 | .name = "format", |
622 | .attrs = snbep_uncore_pcu_formats_attr, | 622 | .attrs = snbep_uncore_pcu_formats_attr, |
623 | }; | 623 | }; |
624 | 624 | ||
625 | static struct attribute_group snbep_uncore_qpi_format_group = { | 625 | static const struct attribute_group snbep_uncore_qpi_format_group = { |
626 | .name = "format", | 626 | .name = "format", |
627 | .attrs = snbep_uncore_qpi_formats_attr, | 627 | .attrs = snbep_uncore_qpi_formats_attr, |
628 | }; | 628 | }; |
@@ -1431,27 +1431,27 @@ static struct attribute *ivbep_uncore_qpi_formats_attr[] = { | |||
1431 | NULL, | 1431 | NULL, |
1432 | }; | 1432 | }; |
1433 | 1433 | ||
1434 | static struct attribute_group ivbep_uncore_format_group = { | 1434 | static const struct attribute_group ivbep_uncore_format_group = { |
1435 | .name = "format", | 1435 | .name = "format", |
1436 | .attrs = ivbep_uncore_formats_attr, | 1436 | .attrs = ivbep_uncore_formats_attr, |
1437 | }; | 1437 | }; |
1438 | 1438 | ||
1439 | static struct attribute_group ivbep_uncore_ubox_format_group = { | 1439 | static const struct attribute_group ivbep_uncore_ubox_format_group = { |
1440 | .name = "format", | 1440 | .name = "format", |
1441 | .attrs = ivbep_uncore_ubox_formats_attr, | 1441 | .attrs = ivbep_uncore_ubox_formats_attr, |
1442 | }; | 1442 | }; |
1443 | 1443 | ||
1444 | static struct attribute_group ivbep_uncore_cbox_format_group = { | 1444 | static const struct attribute_group ivbep_uncore_cbox_format_group = { |
1445 | .name = "format", | 1445 | .name = "format", |
1446 | .attrs = ivbep_uncore_cbox_formats_attr, | 1446 | .attrs = ivbep_uncore_cbox_formats_attr, |
1447 | }; | 1447 | }; |
1448 | 1448 | ||
1449 | static struct attribute_group ivbep_uncore_pcu_format_group = { | 1449 | static const struct attribute_group ivbep_uncore_pcu_format_group = { |
1450 | .name = "format", | 1450 | .name = "format", |
1451 | .attrs = ivbep_uncore_pcu_formats_attr, | 1451 | .attrs = ivbep_uncore_pcu_formats_attr, |
1452 | }; | 1452 | }; |
1453 | 1453 | ||
1454 | static struct attribute_group ivbep_uncore_qpi_format_group = { | 1454 | static const struct attribute_group ivbep_uncore_qpi_format_group = { |
1455 | .name = "format", | 1455 | .name = "format", |
1456 | .attrs = ivbep_uncore_qpi_formats_attr, | 1456 | .attrs = ivbep_uncore_qpi_formats_attr, |
1457 | }; | 1457 | }; |
@@ -1887,7 +1887,7 @@ static struct attribute *knl_uncore_ubox_formats_attr[] = { | |||
1887 | NULL, | 1887 | NULL, |
1888 | }; | 1888 | }; |
1889 | 1889 | ||
1890 | static struct attribute_group knl_uncore_ubox_format_group = { | 1890 | static const struct attribute_group knl_uncore_ubox_format_group = { |
1891 | .name = "format", | 1891 | .name = "format", |
1892 | .attrs = knl_uncore_ubox_formats_attr, | 1892 | .attrs = knl_uncore_ubox_formats_attr, |
1893 | }; | 1893 | }; |
@@ -1927,7 +1927,7 @@ static struct attribute *knl_uncore_cha_formats_attr[] = { | |||
1927 | NULL, | 1927 | NULL, |
1928 | }; | 1928 | }; |
1929 | 1929 | ||
1930 | static struct attribute_group knl_uncore_cha_format_group = { | 1930 | static const struct attribute_group knl_uncore_cha_format_group = { |
1931 | .name = "format", | 1931 | .name = "format", |
1932 | .attrs = knl_uncore_cha_formats_attr, | 1932 | .attrs = knl_uncore_cha_formats_attr, |
1933 | }; | 1933 | }; |
@@ -2037,7 +2037,7 @@ static struct attribute *knl_uncore_pcu_formats_attr[] = { | |||
2037 | NULL, | 2037 | NULL, |
2038 | }; | 2038 | }; |
2039 | 2039 | ||
2040 | static struct attribute_group knl_uncore_pcu_format_group = { | 2040 | static const struct attribute_group knl_uncore_pcu_format_group = { |
2041 | .name = "format", | 2041 | .name = "format", |
2042 | .attrs = knl_uncore_pcu_formats_attr, | 2042 | .attrs = knl_uncore_pcu_formats_attr, |
2043 | }; | 2043 | }; |
@@ -2187,7 +2187,7 @@ static struct attribute *knl_uncore_irp_formats_attr[] = { | |||
2187 | NULL, | 2187 | NULL, |
2188 | }; | 2188 | }; |
2189 | 2189 | ||
2190 | static struct attribute_group knl_uncore_irp_format_group = { | 2190 | static const struct attribute_group knl_uncore_irp_format_group = { |
2191 | .name = "format", | 2191 | .name = "format", |
2192 | .attrs = knl_uncore_irp_formats_attr, | 2192 | .attrs = knl_uncore_irp_formats_attr, |
2193 | }; | 2193 | }; |
@@ -2385,7 +2385,7 @@ static struct attribute *hswep_uncore_ubox_formats_attr[] = { | |||
2385 | NULL, | 2385 | NULL, |
2386 | }; | 2386 | }; |
2387 | 2387 | ||
2388 | static struct attribute_group hswep_uncore_ubox_format_group = { | 2388 | static const struct attribute_group hswep_uncore_ubox_format_group = { |
2389 | .name = "format", | 2389 | .name = "format", |
2390 | .attrs = hswep_uncore_ubox_formats_attr, | 2390 | .attrs = hswep_uncore_ubox_formats_attr, |
2391 | }; | 2391 | }; |
@@ -2439,7 +2439,7 @@ static struct attribute *hswep_uncore_cbox_formats_attr[] = { | |||
2439 | NULL, | 2439 | NULL, |
2440 | }; | 2440 | }; |
2441 | 2441 | ||
2442 | static struct attribute_group hswep_uncore_cbox_format_group = { | 2442 | static const struct attribute_group hswep_uncore_cbox_format_group = { |
2443 | .name = "format", | 2443 | .name = "format", |
2444 | .attrs = hswep_uncore_cbox_formats_attr, | 2444 | .attrs = hswep_uncore_cbox_formats_attr, |
2445 | }; | 2445 | }; |
@@ -2621,7 +2621,7 @@ static struct attribute *hswep_uncore_sbox_formats_attr[] = { | |||
2621 | NULL, | 2621 | NULL, |
2622 | }; | 2622 | }; |
2623 | 2623 | ||
2624 | static struct attribute_group hswep_uncore_sbox_format_group = { | 2624 | static const struct attribute_group hswep_uncore_sbox_format_group = { |
2625 | .name = "format", | 2625 | .name = "format", |
2626 | .attrs = hswep_uncore_sbox_formats_attr, | 2626 | .attrs = hswep_uncore_sbox_formats_attr, |
2627 | }; | 2627 | }; |
@@ -3314,7 +3314,7 @@ static struct attribute *skx_uncore_cha_formats_attr[] = { | |||
3314 | NULL, | 3314 | NULL, |
3315 | }; | 3315 | }; |
3316 | 3316 | ||
3317 | static struct attribute_group skx_uncore_chabox_format_group = { | 3317 | static const struct attribute_group skx_uncore_chabox_format_group = { |
3318 | .name = "format", | 3318 | .name = "format", |
3319 | .attrs = skx_uncore_cha_formats_attr, | 3319 | .attrs = skx_uncore_cha_formats_attr, |
3320 | }; | 3320 | }; |
@@ -3427,7 +3427,7 @@ static struct attribute *skx_uncore_iio_formats_attr[] = { | |||
3427 | NULL, | 3427 | NULL, |
3428 | }; | 3428 | }; |
3429 | 3429 | ||
3430 | static struct attribute_group skx_uncore_iio_format_group = { | 3430 | static const struct attribute_group skx_uncore_iio_format_group = { |
3431 | .name = "format", | 3431 | .name = "format", |
3432 | .attrs = skx_uncore_iio_formats_attr, | 3432 | .attrs = skx_uncore_iio_formats_attr, |
3433 | }; | 3433 | }; |
@@ -3484,7 +3484,7 @@ static struct attribute *skx_uncore_formats_attr[] = { | |||
3484 | NULL, | 3484 | NULL, |
3485 | }; | 3485 | }; |
3486 | 3486 | ||
3487 | static struct attribute_group skx_uncore_format_group = { | 3487 | static const struct attribute_group skx_uncore_format_group = { |
3488 | .name = "format", | 3488 | .name = "format", |
3489 | .attrs = skx_uncore_formats_attr, | 3489 | .attrs = skx_uncore_formats_attr, |
3490 | }; | 3490 | }; |
@@ -3605,7 +3605,7 @@ static struct attribute *skx_upi_uncore_formats_attr[] = { | |||
3605 | NULL, | 3605 | NULL, |
3606 | }; | 3606 | }; |
3607 | 3607 | ||
3608 | static struct attribute_group skx_upi_uncore_format_group = { | 3608 | static const struct attribute_group skx_upi_uncore_format_group = { |
3609 | .name = "format", | 3609 | .name = "format", |
3610 | .attrs = skx_upi_uncore_formats_attr, | 3610 | .attrs = skx_upi_uncore_formats_attr, |
3611 | }; | 3611 | }; |
diff --git a/arch/x86/include/asm/acpi.h b/arch/x86/include/asm/acpi.h index 2efc768e4362..72d867f6b518 100644 --- a/arch/x86/include/asm/acpi.h +++ b/arch/x86/include/asm/acpi.h | |||
@@ -150,8 +150,6 @@ static inline void disable_acpi(void) { } | |||
150 | extern int x86_acpi_numa_init(void); | 150 | extern int x86_acpi_numa_init(void); |
151 | #endif /* CONFIG_ACPI_NUMA */ | 151 | #endif /* CONFIG_ACPI_NUMA */ |
152 | 152 | ||
153 | #define acpi_unlazy_tlb(x) leave_mm(x) | ||
154 | |||
155 | #ifdef CONFIG_ACPI_APEI | 153 | #ifdef CONFIG_ACPI_APEI |
156 | static inline pgprot_t arch_apei_get_mem_attribute(phys_addr_t addr) | 154 | static inline pgprot_t arch_apei_get_mem_attribute(phys_addr_t addr) |
157 | { | 155 | { |
@@ -162,12 +160,13 @@ static inline pgprot_t arch_apei_get_mem_attribute(phys_addr_t addr) | |||
162 | * you call efi_mem_attributes() during boot and at runtime, | 160 | * you call efi_mem_attributes() during boot and at runtime, |
163 | * you could theoretically see different attributes. | 161 | * you could theoretically see different attributes. |
164 | * | 162 | * |
165 | * Since we are yet to see any x86 platforms that require | 163 | * We are yet to see any x86 platforms that require anything |
166 | * anything other than PAGE_KERNEL (some arm64 platforms | 164 | * other than PAGE_KERNEL (some ARM64 platforms require the |
167 | * require the equivalent of PAGE_KERNEL_NOCACHE), return that | 165 | * equivalent of PAGE_KERNEL_NOCACHE). Additionally, if SME |
168 | * until we know differently. | 166 | * is active, the ACPI information will not be encrypted, |
167 | * so return PAGE_KERNEL_NOENC until we know differently. | ||
169 | */ | 168 | */ |
170 | return PAGE_KERNEL; | 169 | return PAGE_KERNEL_NOENC; |
171 | } | 170 | } |
172 | #endif | 171 | #endif |
173 | 172 | ||
diff --git a/arch/x86/include/asm/cmdline.h b/arch/x86/include/asm/cmdline.h index e01f7f7ccb0c..84ae170bc3d0 100644 --- a/arch/x86/include/asm/cmdline.h +++ b/arch/x86/include/asm/cmdline.h | |||
@@ -2,5 +2,7 @@ | |||
2 | #define _ASM_X86_CMDLINE_H | 2 | #define _ASM_X86_CMDLINE_H |
3 | 3 | ||
4 | int cmdline_find_option_bool(const char *cmdline_ptr, const char *option); | 4 | int cmdline_find_option_bool(const char *cmdline_ptr, const char *option); |
5 | int cmdline_find_option(const char *cmdline_ptr, const char *option, | ||
6 | char *buffer, int bufsize); | ||
5 | 7 | ||
6 | #endif /* _ASM_X86_CMDLINE_H */ | 8 | #endif /* _ASM_X86_CMDLINE_H */ |
diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h index ca3c48c0872f..66ac08607471 100644 --- a/arch/x86/include/asm/cpufeatures.h +++ b/arch/x86/include/asm/cpufeatures.h | |||
@@ -196,6 +196,7 @@ | |||
196 | 196 | ||
197 | #define X86_FEATURE_HW_PSTATE ( 7*32+ 8) /* AMD HW-PState */ | 197 | #define X86_FEATURE_HW_PSTATE ( 7*32+ 8) /* AMD HW-PState */ |
198 | #define X86_FEATURE_PROC_FEEDBACK ( 7*32+ 9) /* AMD ProcFeedbackInterface */ | 198 | #define X86_FEATURE_PROC_FEEDBACK ( 7*32+ 9) /* AMD ProcFeedbackInterface */ |
199 | #define X86_FEATURE_SME ( 7*32+10) /* AMD Secure Memory Encryption */ | ||
199 | 200 | ||
200 | #define X86_FEATURE_INTEL_PPIN ( 7*32+14) /* Intel Processor Inventory Number */ | 201 | #define X86_FEATURE_INTEL_PPIN ( 7*32+14) /* Intel Processor Inventory Number */ |
201 | #define X86_FEATURE_INTEL_PT ( 7*32+15) /* Intel Processor Trace */ | 202 | #define X86_FEATURE_INTEL_PT ( 7*32+15) /* Intel Processor Trace */ |
@@ -286,7 +287,7 @@ | |||
286 | #define X86_FEATURE_PAUSEFILTER (15*32+10) /* filtered pause intercept */ | 287 | #define X86_FEATURE_PAUSEFILTER (15*32+10) /* filtered pause intercept */ |
287 | #define X86_FEATURE_PFTHRESHOLD (15*32+12) /* pause filter threshold */ | 288 | #define X86_FEATURE_PFTHRESHOLD (15*32+12) /* pause filter threshold */ |
288 | #define X86_FEATURE_AVIC (15*32+13) /* Virtual Interrupt Controller */ | 289 | #define X86_FEATURE_AVIC (15*32+13) /* Virtual Interrupt Controller */ |
289 | #define X86_FEATURE_VIRTUAL_VMLOAD_VMSAVE (15*32+15) /* Virtual VMLOAD VMSAVE */ | 290 | #define X86_FEATURE_V_VMSAVE_VMLOAD (15*32+15) /* Virtual VMSAVE VMLOAD */ |
290 | 291 | ||
291 | /* Intel-defined CPU features, CPUID level 0x00000007:0 (ecx), word 16 */ | 292 | /* Intel-defined CPU features, CPUID level 0x00000007:0 (ecx), word 16 */ |
292 | #define X86_FEATURE_AVX512VBMI (16*32+ 1) /* AVX512 Vector Bit Manipulation instructions*/ | 293 | #define X86_FEATURE_AVX512VBMI (16*32+ 1) /* AVX512 Vector Bit Manipulation instructions*/ |
diff --git a/arch/x86/include/asm/disabled-features.h b/arch/x86/include/asm/disabled-features.h index 5dff775af7cd..c10c9128f54e 100644 --- a/arch/x86/include/asm/disabled-features.h +++ b/arch/x86/include/asm/disabled-features.h | |||
@@ -21,11 +21,13 @@ | |||
21 | # define DISABLE_K6_MTRR (1<<(X86_FEATURE_K6_MTRR & 31)) | 21 | # define DISABLE_K6_MTRR (1<<(X86_FEATURE_K6_MTRR & 31)) |
22 | # define DISABLE_CYRIX_ARR (1<<(X86_FEATURE_CYRIX_ARR & 31)) | 22 | # define DISABLE_CYRIX_ARR (1<<(X86_FEATURE_CYRIX_ARR & 31)) |
23 | # define DISABLE_CENTAUR_MCR (1<<(X86_FEATURE_CENTAUR_MCR & 31)) | 23 | # define DISABLE_CENTAUR_MCR (1<<(X86_FEATURE_CENTAUR_MCR & 31)) |
24 | # define DISABLE_PCID 0 | ||
24 | #else | 25 | #else |
25 | # define DISABLE_VME 0 | 26 | # define DISABLE_VME 0 |
26 | # define DISABLE_K6_MTRR 0 | 27 | # define DISABLE_K6_MTRR 0 |
27 | # define DISABLE_CYRIX_ARR 0 | 28 | # define DISABLE_CYRIX_ARR 0 |
28 | # define DISABLE_CENTAUR_MCR 0 | 29 | # define DISABLE_CENTAUR_MCR 0 |
30 | # define DISABLE_PCID (1<<(X86_FEATURE_PCID & 31)) | ||
29 | #endif /* CONFIG_X86_64 */ | 31 | #endif /* CONFIG_X86_64 */ |
30 | 32 | ||
31 | #ifdef CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS | 33 | #ifdef CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS |
@@ -49,7 +51,7 @@ | |||
49 | #define DISABLED_MASK1 0 | 51 | #define DISABLED_MASK1 0 |
50 | #define DISABLED_MASK2 0 | 52 | #define DISABLED_MASK2 0 |
51 | #define DISABLED_MASK3 (DISABLE_CYRIX_ARR|DISABLE_CENTAUR_MCR|DISABLE_K6_MTRR) | 53 | #define DISABLED_MASK3 (DISABLE_CYRIX_ARR|DISABLE_CENTAUR_MCR|DISABLE_K6_MTRR) |
52 | #define DISABLED_MASK4 0 | 54 | #define DISABLED_MASK4 (DISABLE_PCID) |
53 | #define DISABLED_MASK5 0 | 55 | #define DISABLED_MASK5 0 |
54 | #define DISABLED_MASK6 0 | 56 | #define DISABLED_MASK6 0 |
55 | #define DISABLED_MASK7 0 | 57 | #define DISABLED_MASK7 0 |
diff --git a/arch/x86/include/asm/dma-mapping.h b/arch/x86/include/asm/dma-mapping.h index 398c79889f5c..1387dafdba2d 100644 --- a/arch/x86/include/asm/dma-mapping.h +++ b/arch/x86/include/asm/dma-mapping.h | |||
@@ -12,6 +12,7 @@ | |||
12 | #include <asm/io.h> | 12 | #include <asm/io.h> |
13 | #include <asm/swiotlb.h> | 13 | #include <asm/swiotlb.h> |
14 | #include <linux/dma-contiguous.h> | 14 | #include <linux/dma-contiguous.h> |
15 | #include <linux/mem_encrypt.h> | ||
15 | 16 | ||
16 | #ifdef CONFIG_ISA | 17 | #ifdef CONFIG_ISA |
17 | # define ISA_DMA_BIT_MASK DMA_BIT_MASK(24) | 18 | # define ISA_DMA_BIT_MASK DMA_BIT_MASK(24) |
@@ -57,12 +58,12 @@ static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size) | |||
57 | 58 | ||
58 | static inline dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr) | 59 | static inline dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr) |
59 | { | 60 | { |
60 | return paddr; | 61 | return __sme_set(paddr); |
61 | } | 62 | } |
62 | 63 | ||
63 | static inline phys_addr_t dma_to_phys(struct device *dev, dma_addr_t daddr) | 64 | static inline phys_addr_t dma_to_phys(struct device *dev, dma_addr_t daddr) |
64 | { | 65 | { |
65 | return daddr; | 66 | return __sme_clr(daddr); |
66 | } | 67 | } |
67 | #endif /* CONFIG_X86_DMA_REMAP */ | 68 | #endif /* CONFIG_X86_DMA_REMAP */ |
68 | 69 | ||
diff --git a/arch/x86/include/asm/dmi.h b/arch/x86/include/asm/dmi.h index 3c69fed215c5..a8e15b04565b 100644 --- a/arch/x86/include/asm/dmi.h +++ b/arch/x86/include/asm/dmi.h | |||
@@ -13,9 +13,9 @@ static __always_inline __init void *dmi_alloc(unsigned len) | |||
13 | } | 13 | } |
14 | 14 | ||
15 | /* Use early IO mappings for DMI because it's initialized early */ | 15 | /* Use early IO mappings for DMI because it's initialized early */ |
16 | #define dmi_early_remap early_ioremap | 16 | #define dmi_early_remap early_memremap |
17 | #define dmi_early_unmap early_iounmap | 17 | #define dmi_early_unmap early_memunmap |
18 | #define dmi_remap ioremap_cache | 18 | #define dmi_remap(_x, _l) memremap(_x, _l, MEMREMAP_WB) |
19 | #define dmi_unmap iounmap | 19 | #define dmi_unmap(_x) memunmap(_x) |
20 | 20 | ||
21 | #endif /* _ASM_X86_DMI_H */ | 21 | #endif /* _ASM_X86_DMI_H */ |
diff --git a/arch/x86/include/asm/e820/api.h b/arch/x86/include/asm/e820/api.h index a504adc661a4..cd266d830e49 100644 --- a/arch/x86/include/asm/e820/api.h +++ b/arch/x86/include/asm/e820/api.h | |||
@@ -39,6 +39,8 @@ extern void e820__setup_pci_gap(void); | |||
39 | extern void e820__reallocate_tables(void); | 39 | extern void e820__reallocate_tables(void); |
40 | extern void e820__register_nosave_regions(unsigned long limit_pfn); | 40 | extern void e820__register_nosave_regions(unsigned long limit_pfn); |
41 | 41 | ||
42 | extern int e820__get_entry_type(u64 start, u64 end); | ||
43 | |||
42 | /* | 44 | /* |
43 | * Returns true iff the specified range [start,end) is completely contained inside | 45 | * Returns true iff the specified range [start,end) is completely contained inside |
44 | * the ISA region. | 46 | * the ISA region. |
diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h index 1c18d83d3f09..a3de31ffb722 100644 --- a/arch/x86/include/asm/elf.h +++ b/arch/x86/include/asm/elf.h | |||
@@ -247,11 +247,11 @@ extern int force_personality32; | |||
247 | 247 | ||
248 | /* | 248 | /* |
249 | * This is the base location for PIE (ET_DYN with INTERP) loads. On | 249 | * This is the base location for PIE (ET_DYN with INTERP) loads. On |
250 | * 64-bit, this is raised to 4GB to leave the entire 32-bit address | 250 | * 64-bit, this is above 4GB to leave the entire 32-bit address |
251 | * space open for things that want to use the area for 32-bit pointers. | 251 | * space open for things that want to use the area for 32-bit pointers. |
252 | */ | 252 | */ |
253 | #define ELF_ET_DYN_BASE (mmap_is_ia32() ? 0x000400000UL : \ | 253 | #define ELF_ET_DYN_BASE (mmap_is_ia32() ? 0x000400000UL : \ |
254 | 0x100000000UL) | 254 | (TASK_SIZE / 3 * 2)) |
255 | 255 | ||
256 | /* This yields a mask that user programs can use to figure out what | 256 | /* This yields a mask that user programs can use to figure out what |
257 | instruction set this CPU supports. This could be done in user space, | 257 | instruction set this CPU supports. This could be done in user space, |
@@ -304,8 +304,8 @@ static inline int mmap_is_ia32(void) | |||
304 | test_thread_flag(TIF_ADDR32)); | 304 | test_thread_flag(TIF_ADDR32)); |
305 | } | 305 | } |
306 | 306 | ||
307 | extern unsigned long tasksize_32bit(void); | 307 | extern unsigned long task_size_32bit(void); |
308 | extern unsigned long tasksize_64bit(void); | 308 | extern unsigned long task_size_64bit(int full_addr_space); |
309 | extern unsigned long get_mmap_base(int is_legacy); | 309 | extern unsigned long get_mmap_base(int is_legacy); |
310 | 310 | ||
311 | #ifdef CONFIG_X86_32 | 311 | #ifdef CONFIG_X86_32 |
diff --git a/arch/x86/include/asm/fixmap.h b/arch/x86/include/asm/fixmap.h index b65155cc3760..dcd9fb55e679 100644 --- a/arch/x86/include/asm/fixmap.h +++ b/arch/x86/include/asm/fixmap.h | |||
@@ -157,6 +157,26 @@ static inline void __set_fixmap(enum fixed_addresses idx, | |||
157 | } | 157 | } |
158 | #endif | 158 | #endif |
159 | 159 | ||
160 | /* | ||
161 | * FIXMAP_PAGE_NOCACHE is used for MMIO. Memory encryption is not | ||
162 | * supported for MMIO addresses, so make sure that the memory encryption | ||
163 | * mask is not part of the page attributes. | ||
164 | */ | ||
165 | #define FIXMAP_PAGE_NOCACHE PAGE_KERNEL_IO_NOCACHE | ||
166 | |||
167 | /* | ||
168 | * Early memremap routines used for in-place encryption. The mappings created | ||
169 | * by these routines are intended to be used as temporary mappings. | ||
170 | */ | ||
171 | void __init *early_memremap_encrypted(resource_size_t phys_addr, | ||
172 | unsigned long size); | ||
173 | void __init *early_memremap_encrypted_wp(resource_size_t phys_addr, | ||
174 | unsigned long size); | ||
175 | void __init *early_memremap_decrypted(resource_size_t phys_addr, | ||
176 | unsigned long size); | ||
177 | void __init *early_memremap_decrypted_wp(resource_size_t phys_addr, | ||
178 | unsigned long size); | ||
179 | |||
160 | #include <asm-generic/fixmap.h> | 180 | #include <asm-generic/fixmap.h> |
161 | 181 | ||
162 | #define __late_set_fixmap(idx, phys, flags) __set_fixmap(idx, phys, flags) | 182 | #define __late_set_fixmap(idx, phys, flags) __set_fixmap(idx, phys, flags) |
diff --git a/arch/x86/include/asm/hypervisor.h b/arch/x86/include/asm/hypervisor.h index 21126155a739..0ead9dbb9130 100644 --- a/arch/x86/include/asm/hypervisor.h +++ b/arch/x86/include/asm/hypervisor.h | |||
@@ -43,6 +43,9 @@ struct hypervisor_x86 { | |||
43 | 43 | ||
44 | /* pin current vcpu to specified physical cpu (run rarely) */ | 44 | /* pin current vcpu to specified physical cpu (run rarely) */ |
45 | void (*pin_vcpu)(int); | 45 | void (*pin_vcpu)(int); |
46 | |||
47 | /* called during init_mem_mapping() to setup early mappings. */ | ||
48 | void (*init_mem_mapping)(void); | ||
46 | }; | 49 | }; |
47 | 50 | ||
48 | extern const struct hypervisor_x86 *x86_hyper; | 51 | extern const struct hypervisor_x86 *x86_hyper; |
@@ -57,8 +60,15 @@ extern const struct hypervisor_x86 x86_hyper_kvm; | |||
57 | extern void init_hypervisor_platform(void); | 60 | extern void init_hypervisor_platform(void); |
58 | extern bool hypervisor_x2apic_available(void); | 61 | extern bool hypervisor_x2apic_available(void); |
59 | extern void hypervisor_pin_vcpu(int cpu); | 62 | extern void hypervisor_pin_vcpu(int cpu); |
63 | |||
64 | static inline void hypervisor_init_mem_mapping(void) | ||
65 | { | ||
66 | if (x86_hyper && x86_hyper->init_mem_mapping) | ||
67 | x86_hyper->init_mem_mapping(); | ||
68 | } | ||
60 | #else | 69 | #else |
61 | static inline void init_hypervisor_platform(void) { } | 70 | static inline void init_hypervisor_platform(void) { } |
62 | static inline bool hypervisor_x2apic_available(void) { return false; } | 71 | static inline bool hypervisor_x2apic_available(void) { return false; } |
72 | static inline void hypervisor_init_mem_mapping(void) { } | ||
63 | #endif /* CONFIG_HYPERVISOR_GUEST */ | 73 | #endif /* CONFIG_HYPERVISOR_GUEST */ |
64 | #endif /* _ASM_X86_HYPERVISOR_H */ | 74 | #endif /* _ASM_X86_HYPERVISOR_H */ |
diff --git a/arch/x86/include/asm/init.h b/arch/x86/include/asm/init.h index 474eb8c66fee..05c4aa00cc86 100644 --- a/arch/x86/include/asm/init.h +++ b/arch/x86/include/asm/init.h | |||
@@ -7,6 +7,7 @@ struct x86_mapping_info { | |||
7 | unsigned long page_flag; /* page flag for PMD or PUD entry */ | 7 | unsigned long page_flag; /* page flag for PMD or PUD entry */ |
8 | unsigned long offset; /* ident mapping offset */ | 8 | unsigned long offset; /* ident mapping offset */ |
9 | bool direct_gbpages; /* PUD level 1GB page support */ | 9 | bool direct_gbpages; /* PUD level 1GB page support */ |
10 | unsigned long kernpg_flag; /* kernel pagetable flag override */ | ||
10 | }; | 11 | }; |
11 | 12 | ||
12 | int kernel_ident_mapping_init(struct x86_mapping_info *info, pgd_t *pgd_page, | 13 | int kernel_ident_mapping_init(struct x86_mapping_info *info, pgd_t *pgd_page, |
diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h index 48febf07e828..4bc6f459a8b6 100644 --- a/arch/x86/include/asm/io.h +++ b/arch/x86/include/asm/io.h | |||
@@ -381,4 +381,12 @@ extern void arch_io_free_memtype_wc(resource_size_t start, resource_size_t size) | |||
381 | #define arch_io_reserve_memtype_wc arch_io_reserve_memtype_wc | 381 | #define arch_io_reserve_memtype_wc arch_io_reserve_memtype_wc |
382 | #endif | 382 | #endif |
383 | 383 | ||
384 | extern bool arch_memremap_can_ram_remap(resource_size_t offset, | ||
385 | unsigned long size, | ||
386 | unsigned long flags); | ||
387 | #define arch_memremap_can_ram_remap arch_memremap_can_ram_remap | ||
388 | |||
389 | extern bool phys_mem_access_encrypted(unsigned long phys_addr, | ||
390 | unsigned long size); | ||
391 | |||
384 | #endif /* _ASM_X86_IO_H */ | 392 | #endif /* _ASM_X86_IO_H */ |
diff --git a/arch/x86/include/asm/kexec.h b/arch/x86/include/asm/kexec.h index 70ef205489f0..942c1f444da8 100644 --- a/arch/x86/include/asm/kexec.h +++ b/arch/x86/include/asm/kexec.h | |||
@@ -147,7 +147,8 @@ unsigned long | |||
147 | relocate_kernel(unsigned long indirection_page, | 147 | relocate_kernel(unsigned long indirection_page, |
148 | unsigned long page_list, | 148 | unsigned long page_list, |
149 | unsigned long start_address, | 149 | unsigned long start_address, |
150 | unsigned int preserve_context); | 150 | unsigned int preserve_context, |
151 | unsigned int sme_active); | ||
151 | #endif | 152 | #endif |
152 | 153 | ||
153 | #define ARCH_HAS_KIMAGE_ARCH | 154 | #define ARCH_HAS_KIMAGE_ARCH |
@@ -207,6 +208,14 @@ struct kexec_entry64_regs { | |||
207 | uint64_t r15; | 208 | uint64_t r15; |
208 | uint64_t rip; | 209 | uint64_t rip; |
209 | }; | 210 | }; |
211 | |||
212 | extern int arch_kexec_post_alloc_pages(void *vaddr, unsigned int pages, | ||
213 | gfp_t gfp); | ||
214 | #define arch_kexec_post_alloc_pages arch_kexec_post_alloc_pages | ||
215 | |||
216 | extern void arch_kexec_pre_free_pages(void *vaddr, unsigned int pages); | ||
217 | #define arch_kexec_pre_free_pages arch_kexec_pre_free_pages | ||
218 | |||
210 | #endif | 219 | #endif |
211 | 220 | ||
212 | typedef void crash_vmclear_fn(void); | 221 | typedef void crash_vmclear_fn(void); |
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index 87ac4fba6d8e..7cbaab523f22 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h | |||
@@ -1078,7 +1078,7 @@ void kvm_mmu_init_vm(struct kvm *kvm); | |||
1078 | void kvm_mmu_uninit_vm(struct kvm *kvm); | 1078 | void kvm_mmu_uninit_vm(struct kvm *kvm); |
1079 | void kvm_mmu_set_mask_ptes(u64 user_mask, u64 accessed_mask, | 1079 | void kvm_mmu_set_mask_ptes(u64 user_mask, u64 accessed_mask, |
1080 | u64 dirty_mask, u64 nx_mask, u64 x_mask, u64 p_mask, | 1080 | u64 dirty_mask, u64 nx_mask, u64 x_mask, u64 p_mask, |
1081 | u64 acc_track_mask); | 1081 | u64 acc_track_mask, u64 me_mask); |
1082 | 1082 | ||
1083 | void kvm_mmu_reset_context(struct kvm_vcpu *vcpu); | 1083 | void kvm_mmu_reset_context(struct kvm_vcpu *vcpu); |
1084 | void kvm_mmu_slot_remove_write_access(struct kvm *kvm, | 1084 | void kvm_mmu_slot_remove_write_access(struct kvm *kvm, |
diff --git a/arch/x86/include/asm/mem_encrypt.h b/arch/x86/include/asm/mem_encrypt.h new file mode 100644 index 000000000000..8e618fcf1f7c --- /dev/null +++ b/arch/x86/include/asm/mem_encrypt.h | |||
@@ -0,0 +1,80 @@ | |||
1 | /* | ||
2 | * AMD Memory Encryption Support | ||
3 | * | ||
4 | * Copyright (C) 2016 Advanced Micro Devices, Inc. | ||
5 | * | ||
6 | * Author: Tom Lendacky <thomas.lendacky@amd.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License version 2 as | ||
10 | * published by the Free Software Foundation. | ||
11 | */ | ||
12 | |||
13 | #ifndef __X86_MEM_ENCRYPT_H__ | ||
14 | #define __X86_MEM_ENCRYPT_H__ | ||
15 | |||
16 | #ifndef __ASSEMBLY__ | ||
17 | |||
18 | #include <linux/init.h> | ||
19 | |||
20 | #include <asm/bootparam.h> | ||
21 | |||
22 | #ifdef CONFIG_AMD_MEM_ENCRYPT | ||
23 | |||
24 | extern unsigned long sme_me_mask; | ||
25 | |||
26 | void sme_encrypt_execute(unsigned long encrypted_kernel_vaddr, | ||
27 | unsigned long decrypted_kernel_vaddr, | ||
28 | unsigned long kernel_len, | ||
29 | unsigned long encryption_wa, | ||
30 | unsigned long encryption_pgd); | ||
31 | |||
32 | void __init sme_early_encrypt(resource_size_t paddr, | ||
33 | unsigned long size); | ||
34 | void __init sme_early_decrypt(resource_size_t paddr, | ||
35 | unsigned long size); | ||
36 | |||
37 | void __init sme_map_bootdata(char *real_mode_data); | ||
38 | void __init sme_unmap_bootdata(char *real_mode_data); | ||
39 | |||
40 | void __init sme_early_init(void); | ||
41 | |||
42 | void __init sme_encrypt_kernel(void); | ||
43 | void __init sme_enable(struct boot_params *bp); | ||
44 | |||
45 | /* Architecture __weak replacement functions */ | ||
46 | void __init mem_encrypt_init(void); | ||
47 | |||
48 | void swiotlb_set_mem_attributes(void *vaddr, unsigned long size); | ||
49 | |||
50 | #else /* !CONFIG_AMD_MEM_ENCRYPT */ | ||
51 | |||
52 | #define sme_me_mask 0UL | ||
53 | |||
54 | static inline void __init sme_early_encrypt(resource_size_t paddr, | ||
55 | unsigned long size) { } | ||
56 | static inline void __init sme_early_decrypt(resource_size_t paddr, | ||
57 | unsigned long size) { } | ||
58 | |||
59 | static inline void __init sme_map_bootdata(char *real_mode_data) { } | ||
60 | static inline void __init sme_unmap_bootdata(char *real_mode_data) { } | ||
61 | |||
62 | static inline void __init sme_early_init(void) { } | ||
63 | |||
64 | static inline void __init sme_encrypt_kernel(void) { } | ||
65 | static inline void __init sme_enable(struct boot_params *bp) { } | ||
66 | |||
67 | #endif /* CONFIG_AMD_MEM_ENCRYPT */ | ||
68 | |||
69 | /* | ||
70 | * The __sme_pa() and __sme_pa_nodebug() macros are meant for use when | ||
71 | * writing to or comparing values from the cr3 register. Having the | ||
72 | * encryption mask set in cr3 enables the PGD entry to be encrypted and | ||
73 | * avoid special case handling of PGD allocations. | ||
74 | */ | ||
75 | #define __sme_pa(x) (__pa(x) | sme_me_mask) | ||
76 | #define __sme_pa_nodebug(x) (__pa_nodebug(x) | sme_me_mask) | ||
77 | |||
78 | #endif /* __ASSEMBLY__ */ | ||
79 | |||
80 | #endif /* __X86_MEM_ENCRYPT_H__ */ | ||
diff --git a/arch/x86/include/asm/mmu.h b/arch/x86/include/asm/mmu.h index 79b647a7ebd0..bb8c597c2248 100644 --- a/arch/x86/include/asm/mmu.h +++ b/arch/x86/include/asm/mmu.h | |||
@@ -3,12 +3,28 @@ | |||
3 | 3 | ||
4 | #include <linux/spinlock.h> | 4 | #include <linux/spinlock.h> |
5 | #include <linux/mutex.h> | 5 | #include <linux/mutex.h> |
6 | #include <linux/atomic.h> | ||
6 | 7 | ||
7 | /* | 8 | /* |
8 | * The x86 doesn't have a mmu context, but | 9 | * x86 has arch-specific MMU state beyond what lives in mm_struct. |
9 | * we put the segment information here. | ||
10 | */ | 10 | */ |
11 | typedef struct { | 11 | typedef struct { |
12 | /* | ||
13 | * ctx_id uniquely identifies this mm_struct. A ctx_id will never | ||
14 | * be reused, and zero is not a valid ctx_id. | ||
15 | */ | ||
16 | u64 ctx_id; | ||
17 | |||
18 | /* | ||
19 | * Any code that needs to do any sort of TLB flushing for this | ||
20 | * mm will first make its changes to the page tables, then | ||
21 | * increment tlb_gen, then flush. This lets the low-level | ||
22 | * flushing code keep track of what needs flushing. | ||
23 | * | ||
24 | * This is not used on Xen PV. | ||
25 | */ | ||
26 | atomic64_t tlb_gen; | ||
27 | |||
12 | #ifdef CONFIG_MODIFY_LDT_SYSCALL | 28 | #ifdef CONFIG_MODIFY_LDT_SYSCALL |
13 | struct ldt_struct *ldt; | 29 | struct ldt_struct *ldt; |
14 | #endif | 30 | #endif |
@@ -37,6 +53,11 @@ typedef struct { | |||
37 | #endif | 53 | #endif |
38 | } mm_context_t; | 54 | } mm_context_t; |
39 | 55 | ||
56 | #define INIT_MM_CONTEXT(mm) \ | ||
57 | .context = { \ | ||
58 | .ctx_id = 1, \ | ||
59 | } | ||
60 | |||
40 | void leave_mm(int cpu); | 61 | void leave_mm(int cpu); |
41 | 62 | ||
42 | #endif /* _ASM_X86_MMU_H */ | 63 | #endif /* _ASM_X86_MMU_H */ |
diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h index 265c907d7d4c..d25d9f4abb15 100644 --- a/arch/x86/include/asm/mmu_context.h +++ b/arch/x86/include/asm/mmu_context.h | |||
@@ -12,6 +12,9 @@ | |||
12 | #include <asm/tlbflush.h> | 12 | #include <asm/tlbflush.h> |
13 | #include <asm/paravirt.h> | 13 | #include <asm/paravirt.h> |
14 | #include <asm/mpx.h> | 14 | #include <asm/mpx.h> |
15 | |||
16 | extern atomic64_t last_mm_ctx_id; | ||
17 | |||
15 | #ifndef CONFIG_PARAVIRT | 18 | #ifndef CONFIG_PARAVIRT |
16 | static inline void paravirt_activate_mm(struct mm_struct *prev, | 19 | static inline void paravirt_activate_mm(struct mm_struct *prev, |
17 | struct mm_struct *next) | 20 | struct mm_struct *next) |
@@ -125,13 +128,18 @@ static inline void switch_ldt(struct mm_struct *prev, struct mm_struct *next) | |||
125 | 128 | ||
126 | static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk) | 129 | static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk) |
127 | { | 130 | { |
128 | if (this_cpu_read(cpu_tlbstate.state) == TLBSTATE_OK) | 131 | int cpu = smp_processor_id(); |
129 | this_cpu_write(cpu_tlbstate.state, TLBSTATE_LAZY); | 132 | |
133 | if (cpumask_test_cpu(cpu, mm_cpumask(mm))) | ||
134 | cpumask_clear_cpu(cpu, mm_cpumask(mm)); | ||
130 | } | 135 | } |
131 | 136 | ||
132 | static inline int init_new_context(struct task_struct *tsk, | 137 | static inline int init_new_context(struct task_struct *tsk, |
133 | struct mm_struct *mm) | 138 | struct mm_struct *mm) |
134 | { | 139 | { |
140 | mm->context.ctx_id = atomic64_inc_return(&last_mm_ctx_id); | ||
141 | atomic64_set(&mm->context.tlb_gen, 0); | ||
142 | |||
135 | #ifdef CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS | 143 | #ifdef CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS |
136 | if (cpu_feature_enabled(X86_FEATURE_OSPKE)) { | 144 | if (cpu_feature_enabled(X86_FEATURE_OSPKE)) { |
137 | /* pkey 0 is the default and always allocated */ | 145 | /* pkey 0 is the default and always allocated */ |
@@ -292,6 +300,9 @@ static inline unsigned long __get_current_cr3_fast(void) | |||
292 | { | 300 | { |
293 | unsigned long cr3 = __pa(this_cpu_read(cpu_tlbstate.loaded_mm)->pgd); | 301 | unsigned long cr3 = __pa(this_cpu_read(cpu_tlbstate.loaded_mm)->pgd); |
294 | 302 | ||
303 | if (static_cpu_has(X86_FEATURE_PCID)) | ||
304 | cr3 |= this_cpu_read(cpu_tlbstate.loaded_mm_asid); | ||
305 | |||
295 | /* For now, be very restrictive about when this can be called. */ | 306 | /* For now, be very restrictive about when this can be called. */ |
296 | VM_WARN_ON(in_nmi() || preemptible()); | 307 | VM_WARN_ON(in_nmi() || preemptible()); |
297 | 308 | ||
diff --git a/arch/x86/include/asm/mpx.h b/arch/x86/include/asm/mpx.h index a0d662be4c5b..7d7404756bb4 100644 --- a/arch/x86/include/asm/mpx.h +++ b/arch/x86/include/asm/mpx.h | |||
@@ -73,6 +73,9 @@ static inline void mpx_mm_init(struct mm_struct *mm) | |||
73 | } | 73 | } |
74 | void mpx_notify_unmap(struct mm_struct *mm, struct vm_area_struct *vma, | 74 | void mpx_notify_unmap(struct mm_struct *mm, struct vm_area_struct *vma, |
75 | unsigned long start, unsigned long end); | 75 | unsigned long start, unsigned long end); |
76 | |||
77 | unsigned long mpx_unmapped_area_check(unsigned long addr, unsigned long len, | ||
78 | unsigned long flags); | ||
76 | #else | 79 | #else |
77 | static inline siginfo_t *mpx_generate_siginfo(struct pt_regs *regs) | 80 | static inline siginfo_t *mpx_generate_siginfo(struct pt_regs *regs) |
78 | { | 81 | { |
@@ -94,6 +97,12 @@ static inline void mpx_notify_unmap(struct mm_struct *mm, | |||
94 | unsigned long start, unsigned long end) | 97 | unsigned long start, unsigned long end) |
95 | { | 98 | { |
96 | } | 99 | } |
100 | |||
101 | static inline unsigned long mpx_unmapped_area_check(unsigned long addr, | ||
102 | unsigned long len, unsigned long flags) | ||
103 | { | ||
104 | return addr; | ||
105 | } | ||
97 | #endif /* CONFIG_X86_INTEL_MPX */ | 106 | #endif /* CONFIG_X86_INTEL_MPX */ |
98 | 107 | ||
99 | #endif /* _ASM_X86_MPX_H */ | 108 | #endif /* _ASM_X86_MPX_H */ |
diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h index 5573c75f8e4c..17f5c12e1afd 100644 --- a/arch/x86/include/asm/msr-index.h +++ b/arch/x86/include/asm/msr-index.h | |||
@@ -356,6 +356,8 @@ | |||
356 | #define MSR_K8_TOP_MEM1 0xc001001a | 356 | #define MSR_K8_TOP_MEM1 0xc001001a |
357 | #define MSR_K8_TOP_MEM2 0xc001001d | 357 | #define MSR_K8_TOP_MEM2 0xc001001d |
358 | #define MSR_K8_SYSCFG 0xc0010010 | 358 | #define MSR_K8_SYSCFG 0xc0010010 |
359 | #define MSR_K8_SYSCFG_MEM_ENCRYPT_BIT 23 | ||
360 | #define MSR_K8_SYSCFG_MEM_ENCRYPT BIT_ULL(MSR_K8_SYSCFG_MEM_ENCRYPT_BIT) | ||
359 | #define MSR_K8_INT_PENDING_MSG 0xc0010055 | 361 | #define MSR_K8_INT_PENDING_MSG 0xc0010055 |
360 | /* C1E active bits in int pending message */ | 362 | /* C1E active bits in int pending message */ |
361 | #define K8_INTP_C1E_ACTIVE_MASK 0x18000000 | 363 | #define K8_INTP_C1E_ACTIVE_MASK 0x18000000 |
diff --git a/arch/x86/include/asm/page_64.h b/arch/x86/include/asm/page_64.h index b4a0d43248cf..b50df06ad251 100644 --- a/arch/x86/include/asm/page_64.h +++ b/arch/x86/include/asm/page_64.h | |||
@@ -51,6 +51,10 @@ static inline void clear_page(void *page) | |||
51 | 51 | ||
52 | void copy_page(void *to, void *from); | 52 | void copy_page(void *to, void *from); |
53 | 53 | ||
54 | #ifdef CONFIG_X86_MCE | ||
55 | #define arch_unmap_kpfn arch_unmap_kpfn | ||
56 | #endif | ||
57 | |||
54 | #endif /* !__ASSEMBLY__ */ | 58 | #endif /* !__ASSEMBLY__ */ |
55 | 59 | ||
56 | #ifdef CONFIG_X86_VSYSCALL_EMULATION | 60 | #ifdef CONFIG_X86_VSYSCALL_EMULATION |
diff --git a/arch/x86/include/asm/page_types.h b/arch/x86/include/asm/page_types.h index 7bd0099384ca..b98ed9d14630 100644 --- a/arch/x86/include/asm/page_types.h +++ b/arch/x86/include/asm/page_types.h | |||
@@ -3,6 +3,7 @@ | |||
3 | 3 | ||
4 | #include <linux/const.h> | 4 | #include <linux/const.h> |
5 | #include <linux/types.h> | 5 | #include <linux/types.h> |
6 | #include <linux/mem_encrypt.h> | ||
6 | 7 | ||
7 | /* PAGE_SHIFT determines the page size */ | 8 | /* PAGE_SHIFT determines the page size */ |
8 | #define PAGE_SHIFT 12 | 9 | #define PAGE_SHIFT 12 |
@@ -15,7 +16,7 @@ | |||
15 | #define PUD_PAGE_SIZE (_AC(1, UL) << PUD_SHIFT) | 16 | #define PUD_PAGE_SIZE (_AC(1, UL) << PUD_SHIFT) |
16 | #define PUD_PAGE_MASK (~(PUD_PAGE_SIZE-1)) | 17 | #define PUD_PAGE_MASK (~(PUD_PAGE_SIZE-1)) |
17 | 18 | ||
18 | #define __PHYSICAL_MASK ((phys_addr_t)((1ULL << __PHYSICAL_MASK_SHIFT) - 1)) | 19 | #define __PHYSICAL_MASK ((phys_addr_t)(__sme_clr((1ULL << __PHYSICAL_MASK_SHIFT) - 1))) |
19 | #define __VIRTUAL_MASK ((1UL << __VIRTUAL_MASK_SHIFT) - 1) | 20 | #define __VIRTUAL_MASK ((1UL << __VIRTUAL_MASK_SHIFT) - 1) |
20 | 21 | ||
21 | /* Cast *PAGE_MASK to a signed type so that it is sign-extended if | 22 | /* Cast *PAGE_MASK to a signed type so that it is sign-extended if |
diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h index 77037b6f1caa..bbeae4a2bd01 100644 --- a/arch/x86/include/asm/pgtable.h +++ b/arch/x86/include/asm/pgtable.h | |||
@@ -1,6 +1,7 @@ | |||
1 | #ifndef _ASM_X86_PGTABLE_H | 1 | #ifndef _ASM_X86_PGTABLE_H |
2 | #define _ASM_X86_PGTABLE_H | 2 | #define _ASM_X86_PGTABLE_H |
3 | 3 | ||
4 | #include <linux/mem_encrypt.h> | ||
4 | #include <asm/page.h> | 5 | #include <asm/page.h> |
5 | #include <asm/pgtable_types.h> | 6 | #include <asm/pgtable_types.h> |
6 | 7 | ||
@@ -13,9 +14,18 @@ | |||
13 | cachemode2protval(_PAGE_CACHE_MODE_UC_MINUS))) \ | 14 | cachemode2protval(_PAGE_CACHE_MODE_UC_MINUS))) \ |
14 | : (prot)) | 15 | : (prot)) |
15 | 16 | ||
17 | /* | ||
18 | * Macros to add or remove encryption attribute | ||
19 | */ | ||
20 | #define pgprot_encrypted(prot) __pgprot(__sme_set(pgprot_val(prot))) | ||
21 | #define pgprot_decrypted(prot) __pgprot(__sme_clr(pgprot_val(prot))) | ||
22 | |||
16 | #ifndef __ASSEMBLY__ | 23 | #ifndef __ASSEMBLY__ |
17 | #include <asm/x86_init.h> | 24 | #include <asm/x86_init.h> |
18 | 25 | ||
26 | extern pgd_t early_top_pgt[PTRS_PER_PGD]; | ||
27 | int __init __early_make_pgtable(unsigned long address, pmdval_t pmd); | ||
28 | |||
19 | void ptdump_walk_pgd_level(struct seq_file *m, pgd_t *pgd); | 29 | void ptdump_walk_pgd_level(struct seq_file *m, pgd_t *pgd); |
20 | void ptdump_walk_pgd_level_checkwx(void); | 30 | void ptdump_walk_pgd_level_checkwx(void); |
21 | 31 | ||
@@ -38,6 +48,8 @@ extern struct list_head pgd_list; | |||
38 | 48 | ||
39 | extern struct mm_struct *pgd_page_get_mm(struct page *page); | 49 | extern struct mm_struct *pgd_page_get_mm(struct page *page); |
40 | 50 | ||
51 | extern pmdval_t early_pmd_flags; | ||
52 | |||
41 | #ifdef CONFIG_PARAVIRT | 53 | #ifdef CONFIG_PARAVIRT |
42 | #include <asm/paravirt.h> | 54 | #include <asm/paravirt.h> |
43 | #else /* !CONFIG_PARAVIRT */ | 55 | #else /* !CONFIG_PARAVIRT */ |
@@ -195,6 +207,11 @@ static inline unsigned long p4d_pfn(p4d_t p4d) | |||
195 | return (p4d_val(p4d) & p4d_pfn_mask(p4d)) >> PAGE_SHIFT; | 207 | return (p4d_val(p4d) & p4d_pfn_mask(p4d)) >> PAGE_SHIFT; |
196 | } | 208 | } |
197 | 209 | ||
210 | static inline unsigned long pgd_pfn(pgd_t pgd) | ||
211 | { | ||
212 | return (pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT; | ||
213 | } | ||
214 | |||
198 | static inline int p4d_large(p4d_t p4d) | 215 | static inline int p4d_large(p4d_t p4d) |
199 | { | 216 | { |
200 | /* No 512 GiB pages yet */ | 217 | /* No 512 GiB pages yet */ |
@@ -704,8 +721,7 @@ static inline unsigned long pmd_page_vaddr(pmd_t pmd) | |||
704 | * Currently stuck as a macro due to indirect forward reference to | 721 | * Currently stuck as a macro due to indirect forward reference to |
705 | * linux/mmzone.h's __section_mem_map_addr() definition: | 722 | * linux/mmzone.h's __section_mem_map_addr() definition: |
706 | */ | 723 | */ |
707 | #define pmd_page(pmd) \ | 724 | #define pmd_page(pmd) pfn_to_page(pmd_pfn(pmd)) |
708 | pfn_to_page((pmd_val(pmd) & pmd_pfn_mask(pmd)) >> PAGE_SHIFT) | ||
709 | 725 | ||
710 | /* | 726 | /* |
711 | * the pmd page can be thought of an array like this: pmd_t[PTRS_PER_PMD] | 727 | * the pmd page can be thought of an array like this: pmd_t[PTRS_PER_PMD] |
@@ -773,8 +789,7 @@ static inline unsigned long pud_page_vaddr(pud_t pud) | |||
773 | * Currently stuck as a macro due to indirect forward reference to | 789 | * Currently stuck as a macro due to indirect forward reference to |
774 | * linux/mmzone.h's __section_mem_map_addr() definition: | 790 | * linux/mmzone.h's __section_mem_map_addr() definition: |
775 | */ | 791 | */ |
776 | #define pud_page(pud) \ | 792 | #define pud_page(pud) pfn_to_page(pud_pfn(pud)) |
777 | pfn_to_page((pud_val(pud) & pud_pfn_mask(pud)) >> PAGE_SHIFT) | ||
778 | 793 | ||
779 | /* Find an entry in the second-level page table.. */ | 794 | /* Find an entry in the second-level page table.. */ |
780 | static inline pmd_t *pmd_offset(pud_t *pud, unsigned long address) | 795 | static inline pmd_t *pmd_offset(pud_t *pud, unsigned long address) |
@@ -824,8 +839,7 @@ static inline unsigned long p4d_page_vaddr(p4d_t p4d) | |||
824 | * Currently stuck as a macro due to indirect forward reference to | 839 | * Currently stuck as a macro due to indirect forward reference to |
825 | * linux/mmzone.h's __section_mem_map_addr() definition: | 840 | * linux/mmzone.h's __section_mem_map_addr() definition: |
826 | */ | 841 | */ |
827 | #define p4d_page(p4d) \ | 842 | #define p4d_page(p4d) pfn_to_page(p4d_pfn(p4d)) |
828 | pfn_to_page((p4d_val(p4d) & p4d_pfn_mask(p4d)) >> PAGE_SHIFT) | ||
829 | 843 | ||
830 | /* Find an entry in the third-level page table.. */ | 844 | /* Find an entry in the third-level page table.. */ |
831 | static inline pud_t *pud_offset(p4d_t *p4d, unsigned long address) | 845 | static inline pud_t *pud_offset(p4d_t *p4d, unsigned long address) |
@@ -859,7 +873,7 @@ static inline unsigned long pgd_page_vaddr(pgd_t pgd) | |||
859 | * Currently stuck as a macro due to indirect forward reference to | 873 | * Currently stuck as a macro due to indirect forward reference to |
860 | * linux/mmzone.h's __section_mem_map_addr() definition: | 874 | * linux/mmzone.h's __section_mem_map_addr() definition: |
861 | */ | 875 | */ |
862 | #define pgd_page(pgd) pfn_to_page(pgd_val(pgd) >> PAGE_SHIFT) | 876 | #define pgd_page(pgd) pfn_to_page(pgd_pfn(pgd)) |
863 | 877 | ||
864 | /* to find an entry in a page-table-directory. */ | 878 | /* to find an entry in a page-table-directory. */ |
865 | static inline p4d_t *p4d_offset(pgd_t *pgd, unsigned long address) | 879 | static inline p4d_t *p4d_offset(pgd_t *pgd, unsigned long address) |
diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h index bf9638e1ee42..399261ce904c 100644 --- a/arch/x86/include/asm/pgtable_types.h +++ b/arch/x86/include/asm/pgtable_types.h | |||
@@ -2,6 +2,8 @@ | |||
2 | #define _ASM_X86_PGTABLE_DEFS_H | 2 | #define _ASM_X86_PGTABLE_DEFS_H |
3 | 3 | ||
4 | #include <linux/const.h> | 4 | #include <linux/const.h> |
5 | #include <linux/mem_encrypt.h> | ||
6 | |||
5 | #include <asm/page_types.h> | 7 | #include <asm/page_types.h> |
6 | 8 | ||
7 | #define FIRST_USER_ADDRESS 0UL | 9 | #define FIRST_USER_ADDRESS 0UL |
@@ -121,10 +123,10 @@ | |||
121 | 123 | ||
122 | #define _PAGE_PROTNONE (_AT(pteval_t, 1) << _PAGE_BIT_PROTNONE) | 124 | #define _PAGE_PROTNONE (_AT(pteval_t, 1) << _PAGE_BIT_PROTNONE) |
123 | 125 | ||
124 | #define _PAGE_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | \ | 126 | #define _PAGE_TABLE_NOENC (_PAGE_PRESENT | _PAGE_RW | _PAGE_USER |\ |
125 | _PAGE_ACCESSED | _PAGE_DIRTY) | 127 | _PAGE_ACCESSED | _PAGE_DIRTY) |
126 | #define _KERNPG_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED | \ | 128 | #define _KERNPG_TABLE_NOENC (_PAGE_PRESENT | _PAGE_RW | \ |
127 | _PAGE_DIRTY) | 129 | _PAGE_ACCESSED | _PAGE_DIRTY) |
128 | 130 | ||
129 | /* | 131 | /* |
130 | * Set of bits not changed in pte_modify. The pte's | 132 | * Set of bits not changed in pte_modify. The pte's |
@@ -159,6 +161,7 @@ enum page_cache_mode { | |||
159 | 161 | ||
160 | #define _PAGE_CACHE_MASK (_PAGE_PAT | _PAGE_PCD | _PAGE_PWT) | 162 | #define _PAGE_CACHE_MASK (_PAGE_PAT | _PAGE_PCD | _PAGE_PWT) |
161 | #define _PAGE_NOCACHE (cachemode2protval(_PAGE_CACHE_MODE_UC)) | 163 | #define _PAGE_NOCACHE (cachemode2protval(_PAGE_CACHE_MODE_UC)) |
164 | #define _PAGE_CACHE_WP (cachemode2protval(_PAGE_CACHE_MODE_WP)) | ||
162 | 165 | ||
163 | #define PAGE_NONE __pgprot(_PAGE_PROTNONE | _PAGE_ACCESSED) | 166 | #define PAGE_NONE __pgprot(_PAGE_PROTNONE | _PAGE_ACCESSED) |
164 | #define PAGE_SHARED __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | \ | 167 | #define PAGE_SHARED __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | \ |
@@ -187,22 +190,42 @@ enum page_cache_mode { | |||
187 | #define __PAGE_KERNEL_VVAR (__PAGE_KERNEL_RO | _PAGE_USER) | 190 | #define __PAGE_KERNEL_VVAR (__PAGE_KERNEL_RO | _PAGE_USER) |
188 | #define __PAGE_KERNEL_LARGE (__PAGE_KERNEL | _PAGE_PSE) | 191 | #define __PAGE_KERNEL_LARGE (__PAGE_KERNEL | _PAGE_PSE) |
189 | #define __PAGE_KERNEL_LARGE_EXEC (__PAGE_KERNEL_EXEC | _PAGE_PSE) | 192 | #define __PAGE_KERNEL_LARGE_EXEC (__PAGE_KERNEL_EXEC | _PAGE_PSE) |
193 | #define __PAGE_KERNEL_WP (__PAGE_KERNEL | _PAGE_CACHE_WP) | ||
190 | 194 | ||
191 | #define __PAGE_KERNEL_IO (__PAGE_KERNEL) | 195 | #define __PAGE_KERNEL_IO (__PAGE_KERNEL) |
192 | #define __PAGE_KERNEL_IO_NOCACHE (__PAGE_KERNEL_NOCACHE) | 196 | #define __PAGE_KERNEL_IO_NOCACHE (__PAGE_KERNEL_NOCACHE) |
193 | 197 | ||
194 | #define PAGE_KERNEL __pgprot(__PAGE_KERNEL) | 198 | #ifndef __ASSEMBLY__ |
195 | #define PAGE_KERNEL_RO __pgprot(__PAGE_KERNEL_RO) | 199 | |
196 | #define PAGE_KERNEL_EXEC __pgprot(__PAGE_KERNEL_EXEC) | 200 | #define _PAGE_ENC (_AT(pteval_t, sme_me_mask)) |
197 | #define PAGE_KERNEL_RX __pgprot(__PAGE_KERNEL_RX) | 201 | |
198 | #define PAGE_KERNEL_NOCACHE __pgprot(__PAGE_KERNEL_NOCACHE) | 202 | #define _PAGE_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | \ |
199 | #define PAGE_KERNEL_LARGE __pgprot(__PAGE_KERNEL_LARGE) | 203 | _PAGE_ACCESSED | _PAGE_DIRTY | _PAGE_ENC) |
200 | #define PAGE_KERNEL_LARGE_EXEC __pgprot(__PAGE_KERNEL_LARGE_EXEC) | 204 | #define _KERNPG_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED | \ |
201 | #define PAGE_KERNEL_VSYSCALL __pgprot(__PAGE_KERNEL_VSYSCALL) | 205 | _PAGE_DIRTY | _PAGE_ENC) |
202 | #define PAGE_KERNEL_VVAR __pgprot(__PAGE_KERNEL_VVAR) | 206 | |
207 | #define __PAGE_KERNEL_ENC (__PAGE_KERNEL | _PAGE_ENC) | ||
208 | #define __PAGE_KERNEL_ENC_WP (__PAGE_KERNEL_WP | _PAGE_ENC) | ||
209 | |||
210 | #define __PAGE_KERNEL_NOENC (__PAGE_KERNEL) | ||
211 | #define __PAGE_KERNEL_NOENC_WP (__PAGE_KERNEL_WP) | ||
212 | |||
213 | #define PAGE_KERNEL __pgprot(__PAGE_KERNEL | _PAGE_ENC) | ||
214 | #define PAGE_KERNEL_NOENC __pgprot(__PAGE_KERNEL) | ||
215 | #define PAGE_KERNEL_RO __pgprot(__PAGE_KERNEL_RO | _PAGE_ENC) | ||
216 | #define PAGE_KERNEL_EXEC __pgprot(__PAGE_KERNEL_EXEC | _PAGE_ENC) | ||
217 | #define PAGE_KERNEL_EXEC_NOENC __pgprot(__PAGE_KERNEL_EXEC) | ||
218 | #define PAGE_KERNEL_RX __pgprot(__PAGE_KERNEL_RX | _PAGE_ENC) | ||
219 | #define PAGE_KERNEL_NOCACHE __pgprot(__PAGE_KERNEL_NOCACHE | _PAGE_ENC) | ||
220 | #define PAGE_KERNEL_LARGE __pgprot(__PAGE_KERNEL_LARGE | _PAGE_ENC) | ||
221 | #define PAGE_KERNEL_LARGE_EXEC __pgprot(__PAGE_KERNEL_LARGE_EXEC | _PAGE_ENC) | ||
222 | #define PAGE_KERNEL_VSYSCALL __pgprot(__PAGE_KERNEL_VSYSCALL | _PAGE_ENC) | ||
223 | #define PAGE_KERNEL_VVAR __pgprot(__PAGE_KERNEL_VVAR | _PAGE_ENC) | ||
224 | |||
225 | #define PAGE_KERNEL_IO __pgprot(__PAGE_KERNEL_IO) | ||
226 | #define PAGE_KERNEL_IO_NOCACHE __pgprot(__PAGE_KERNEL_IO_NOCACHE) | ||
203 | 227 | ||
204 | #define PAGE_KERNEL_IO __pgprot(__PAGE_KERNEL_IO) | 228 | #endif /* __ASSEMBLY__ */ |
205 | #define PAGE_KERNEL_IO_NOCACHE __pgprot(__PAGE_KERNEL_IO_NOCACHE) | ||
206 | 229 | ||
207 | /* xwr */ | 230 | /* xwr */ |
208 | #define __P000 PAGE_NONE | 231 | #define __P000 PAGE_NONE |
@@ -287,6 +310,11 @@ static inline p4dval_t native_p4d_val(p4d_t p4d) | |||
287 | #else | 310 | #else |
288 | #include <asm-generic/pgtable-nop4d.h> | 311 | #include <asm-generic/pgtable-nop4d.h> |
289 | 312 | ||
313 | static inline p4d_t native_make_p4d(pudval_t val) | ||
314 | { | ||
315 | return (p4d_t) { .pgd = native_make_pgd((pgdval_t)val) }; | ||
316 | } | ||
317 | |||
290 | static inline p4dval_t native_p4d_val(p4d_t p4d) | 318 | static inline p4dval_t native_p4d_val(p4d_t p4d) |
291 | { | 319 | { |
292 | return native_pgd_val(p4d.pgd); | 320 | return native_pgd_val(p4d.pgd); |
diff --git a/arch/x86/include/asm/processor-flags.h b/arch/x86/include/asm/processor-flags.h index 79aa2f98398d..dc723b64acf0 100644 --- a/arch/x86/include/asm/processor-flags.h +++ b/arch/x86/include/asm/processor-flags.h | |||
@@ -2,6 +2,7 @@ | |||
2 | #define _ASM_X86_PROCESSOR_FLAGS_H | 2 | #define _ASM_X86_PROCESSOR_FLAGS_H |
3 | 3 | ||
4 | #include <uapi/asm/processor-flags.h> | 4 | #include <uapi/asm/processor-flags.h> |
5 | #include <linux/mem_encrypt.h> | ||
5 | 6 | ||
6 | #ifdef CONFIG_VM86 | 7 | #ifdef CONFIG_VM86 |
7 | #define X86_VM_MASK X86_EFLAGS_VM | 8 | #define X86_VM_MASK X86_EFLAGS_VM |
@@ -32,16 +33,18 @@ | |||
32 | * CR3_ADDR_MASK is the mask used by read_cr3_pa(). | 33 | * CR3_ADDR_MASK is the mask used by read_cr3_pa(). |
33 | */ | 34 | */ |
34 | #ifdef CONFIG_X86_64 | 35 | #ifdef CONFIG_X86_64 |
35 | /* Mask off the address space ID bits. */ | 36 | /* Mask off the address space ID and SME encryption bits. */ |
36 | #define CR3_ADDR_MASK 0x7FFFFFFFFFFFF000ull | 37 | #define CR3_ADDR_MASK __sme_clr(0x7FFFFFFFFFFFF000ull) |
37 | #define CR3_PCID_MASK 0xFFFull | 38 | #define CR3_PCID_MASK 0xFFFull |
39 | #define CR3_NOFLUSH BIT_ULL(63) | ||
38 | #else | 40 | #else |
39 | /* | 41 | /* |
40 | * CR3_ADDR_MASK needs at least bits 31:5 set on PAE systems, and we save | 42 | * CR3_ADDR_MASK needs at least bits 31:5 set on PAE systems, and we save |
41 | * a tiny bit of code size by setting all the bits. | 43 | * a tiny bit of code size by setting all the bits. |
42 | */ | 44 | */ |
43 | #define CR3_ADDR_MASK 0xFFFFFFFFull | 45 | #define CR3_ADDR_MASK 0xFFFFFFFFull |
44 | #define CR3_PCID_MASK 0ull | 46 | #define CR3_PCID_MASK 0ull |
47 | #define CR3_NOFLUSH 0 | ||
45 | #endif | 48 | #endif |
46 | 49 | ||
47 | #endif /* _ASM_X86_PROCESSOR_FLAGS_H */ | 50 | #endif /* _ASM_X86_PROCESSOR_FLAGS_H */ |
diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h index 028245e1c42b..c61bab07a84e 100644 --- a/arch/x86/include/asm/processor.h +++ b/arch/x86/include/asm/processor.h | |||
@@ -29,6 +29,7 @@ struct vm86; | |||
29 | #include <linux/math64.h> | 29 | #include <linux/math64.h> |
30 | #include <linux/err.h> | 30 | #include <linux/err.h> |
31 | #include <linux/irqflags.h> | 31 | #include <linux/irqflags.h> |
32 | #include <linux/mem_encrypt.h> | ||
32 | 33 | ||
33 | /* | 34 | /* |
34 | * We handle most unaligned accesses in hardware. On the other hand | 35 | * We handle most unaligned accesses in hardware. On the other hand |
@@ -239,9 +240,14 @@ static inline unsigned long read_cr3_pa(void) | |||
239 | return __read_cr3() & CR3_ADDR_MASK; | 240 | return __read_cr3() & CR3_ADDR_MASK; |
240 | } | 241 | } |
241 | 242 | ||
243 | static inline unsigned long native_read_cr3_pa(void) | ||
244 | { | ||
245 | return __native_read_cr3() & CR3_ADDR_MASK; | ||
246 | } | ||
247 | |||
242 | static inline void load_cr3(pgd_t *pgdir) | 248 | static inline void load_cr3(pgd_t *pgdir) |
243 | { | 249 | { |
244 | write_cr3(__pa(pgdir)); | 250 | write_cr3(__sme_pa(pgdir)); |
245 | } | 251 | } |
246 | 252 | ||
247 | #ifdef CONFIG_X86_32 | 253 | #ifdef CONFIG_X86_32 |
@@ -802,7 +808,9 @@ static inline void spin_lock_prefetch(const void *x) | |||
802 | */ | 808 | */ |
803 | #define IA32_PAGE_OFFSET PAGE_OFFSET | 809 | #define IA32_PAGE_OFFSET PAGE_OFFSET |
804 | #define TASK_SIZE PAGE_OFFSET | 810 | #define TASK_SIZE PAGE_OFFSET |
811 | #define TASK_SIZE_LOW TASK_SIZE | ||
805 | #define TASK_SIZE_MAX TASK_SIZE | 812 | #define TASK_SIZE_MAX TASK_SIZE |
813 | #define DEFAULT_MAP_WINDOW TASK_SIZE | ||
806 | #define STACK_TOP TASK_SIZE | 814 | #define STACK_TOP TASK_SIZE |
807 | #define STACK_TOP_MAX STACK_TOP | 815 | #define STACK_TOP_MAX STACK_TOP |
808 | 816 | ||
@@ -842,7 +850,9 @@ static inline void spin_lock_prefetch(const void *x) | |||
842 | * particular problem by preventing anything from being mapped | 850 | * particular problem by preventing anything from being mapped |
843 | * at the maximum canonical address. | 851 | * at the maximum canonical address. |
844 | */ | 852 | */ |
845 | #define TASK_SIZE_MAX ((1UL << 47) - PAGE_SIZE) | 853 | #define TASK_SIZE_MAX ((1UL << __VIRTUAL_MASK_SHIFT) - PAGE_SIZE) |
854 | |||
855 | #define DEFAULT_MAP_WINDOW ((1UL << 47) - PAGE_SIZE) | ||
846 | 856 | ||
847 | /* This decides where the kernel will search for a free chunk of vm | 857 | /* This decides where the kernel will search for a free chunk of vm |
848 | * space during mmap's. | 858 | * space during mmap's. |
@@ -850,12 +860,14 @@ static inline void spin_lock_prefetch(const void *x) | |||
850 | #define IA32_PAGE_OFFSET ((current->personality & ADDR_LIMIT_3GB) ? \ | 860 | #define IA32_PAGE_OFFSET ((current->personality & ADDR_LIMIT_3GB) ? \ |
851 | 0xc0000000 : 0xFFFFe000) | 861 | 0xc0000000 : 0xFFFFe000) |
852 | 862 | ||
863 | #define TASK_SIZE_LOW (test_thread_flag(TIF_ADDR32) ? \ | ||
864 | IA32_PAGE_OFFSET : DEFAULT_MAP_WINDOW) | ||
853 | #define TASK_SIZE (test_thread_flag(TIF_ADDR32) ? \ | 865 | #define TASK_SIZE (test_thread_flag(TIF_ADDR32) ? \ |
854 | IA32_PAGE_OFFSET : TASK_SIZE_MAX) | 866 | IA32_PAGE_OFFSET : TASK_SIZE_MAX) |
855 | #define TASK_SIZE_OF(child) ((test_tsk_thread_flag(child, TIF_ADDR32)) ? \ | 867 | #define TASK_SIZE_OF(child) ((test_tsk_thread_flag(child, TIF_ADDR32)) ? \ |
856 | IA32_PAGE_OFFSET : TASK_SIZE_MAX) | 868 | IA32_PAGE_OFFSET : TASK_SIZE_MAX) |
857 | 869 | ||
858 | #define STACK_TOP TASK_SIZE | 870 | #define STACK_TOP TASK_SIZE_LOW |
859 | #define STACK_TOP_MAX TASK_SIZE_MAX | 871 | #define STACK_TOP_MAX TASK_SIZE_MAX |
860 | 872 | ||
861 | #define INIT_THREAD { \ | 873 | #define INIT_THREAD { \ |
@@ -876,7 +888,7 @@ extern void start_thread(struct pt_regs *regs, unsigned long new_ip, | |||
876 | * space during mmap's. | 888 | * space during mmap's. |
877 | */ | 889 | */ |
878 | #define __TASK_UNMAPPED_BASE(task_size) (PAGE_ALIGN(task_size / 3)) | 890 | #define __TASK_UNMAPPED_BASE(task_size) (PAGE_ALIGN(task_size / 3)) |
879 | #define TASK_UNMAPPED_BASE __TASK_UNMAPPED_BASE(TASK_SIZE) | 891 | #define TASK_UNMAPPED_BASE __TASK_UNMAPPED_BASE(TASK_SIZE_LOW) |
880 | 892 | ||
881 | #define KSTK_EIP(task) (task_pt_regs(task)->ip) | 893 | #define KSTK_EIP(task) (task_pt_regs(task)->ip) |
882 | 894 | ||
diff --git a/arch/x86/include/asm/realmode.h b/arch/x86/include/asm/realmode.h index 230e1903acf0..90d91520c13a 100644 --- a/arch/x86/include/asm/realmode.h +++ b/arch/x86/include/asm/realmode.h | |||
@@ -1,6 +1,15 @@ | |||
1 | #ifndef _ARCH_X86_REALMODE_H | 1 | #ifndef _ARCH_X86_REALMODE_H |
2 | #define _ARCH_X86_REALMODE_H | 2 | #define _ARCH_X86_REALMODE_H |
3 | 3 | ||
4 | /* | ||
5 | * Flag bit definitions for use with the flags field of the trampoline header | ||
6 | * in the CONFIG_X86_64 variant. | ||
7 | */ | ||
8 | #define TH_FLAGS_SME_ACTIVE_BIT 0 | ||
9 | #define TH_FLAGS_SME_ACTIVE BIT(TH_FLAGS_SME_ACTIVE_BIT) | ||
10 | |||
11 | #ifndef __ASSEMBLY__ | ||
12 | |||
4 | #include <linux/types.h> | 13 | #include <linux/types.h> |
5 | #include <asm/io.h> | 14 | #include <asm/io.h> |
6 | 15 | ||
@@ -38,6 +47,7 @@ struct trampoline_header { | |||
38 | u64 start; | 47 | u64 start; |
39 | u64 efer; | 48 | u64 efer; |
40 | u32 cr4; | 49 | u32 cr4; |
50 | u32 flags; | ||
41 | #endif | 51 | #endif |
42 | }; | 52 | }; |
43 | 53 | ||
@@ -69,4 +79,6 @@ static inline size_t real_mode_size_needed(void) | |||
69 | void set_real_mode_mem(phys_addr_t mem, size_t size); | 79 | void set_real_mode_mem(phys_addr_t mem, size_t size); |
70 | void reserve_real_mode(void); | 80 | void reserve_real_mode(void); |
71 | 81 | ||
82 | #endif /* __ASSEMBLY__ */ | ||
83 | |||
72 | #endif /* _ARCH_X86_REALMODE_H */ | 84 | #endif /* _ARCH_X86_REALMODE_H */ |
diff --git a/arch/x86/include/asm/set_memory.h b/arch/x86/include/asm/set_memory.h index eaec6c364e42..cd71273ec49d 100644 --- a/arch/x86/include/asm/set_memory.h +++ b/arch/x86/include/asm/set_memory.h | |||
@@ -11,6 +11,7 @@ | |||
11 | * Executability : eXeutable, NoteXecutable | 11 | * Executability : eXeutable, NoteXecutable |
12 | * Read/Write : ReadOnly, ReadWrite | 12 | * Read/Write : ReadOnly, ReadWrite |
13 | * Presence : NotPresent | 13 | * Presence : NotPresent |
14 | * Encryption : Encrypted, Decrypted | ||
14 | * | 15 | * |
15 | * Within a category, the attributes are mutually exclusive. | 16 | * Within a category, the attributes are mutually exclusive. |
16 | * | 17 | * |
@@ -42,6 +43,8 @@ int set_memory_wt(unsigned long addr, int numpages); | |||
42 | int set_memory_wb(unsigned long addr, int numpages); | 43 | int set_memory_wb(unsigned long addr, int numpages); |
43 | int set_memory_np(unsigned long addr, int numpages); | 44 | int set_memory_np(unsigned long addr, int numpages); |
44 | int set_memory_4k(unsigned long addr, int numpages); | 45 | int set_memory_4k(unsigned long addr, int numpages); |
46 | int set_memory_encrypted(unsigned long addr, int numpages); | ||
47 | int set_memory_decrypted(unsigned long addr, int numpages); | ||
45 | 48 | ||
46 | int set_memory_array_uc(unsigned long *addr, int addrinarray); | 49 | int set_memory_array_uc(unsigned long *addr, int addrinarray); |
47 | int set_memory_array_wc(unsigned long *addr, int addrinarray); | 50 | int set_memory_array_wc(unsigned long *addr, int addrinarray); |
diff --git a/arch/x86/include/asm/tlb.h b/arch/x86/include/asm/tlb.h index c7797307fc2b..79a4ca6a9606 100644 --- a/arch/x86/include/asm/tlb.h +++ b/arch/x86/include/asm/tlb.h | |||
@@ -15,4 +15,18 @@ | |||
15 | 15 | ||
16 | #include <asm-generic/tlb.h> | 16 | #include <asm-generic/tlb.h> |
17 | 17 | ||
18 | /* | ||
19 | * While x86 architecture in general requires an IPI to perform TLB | ||
20 | * shootdown, enablement code for several hypervisors overrides | ||
21 | * .flush_tlb_others hook in pv_mmu_ops and implements it by issuing | ||
22 | * a hypercall. To keep software pagetable walkers safe in this case we | ||
23 | * switch to RCU based table free (HAVE_RCU_TABLE_FREE). See the comment | ||
24 | * below 'ifdef CONFIG_HAVE_RCU_TABLE_FREE' in include/asm-generic/tlb.h | ||
25 | * for more details. | ||
26 | */ | ||
27 | static inline void __tlb_remove_table(void *table) | ||
28 | { | ||
29 | free_page_and_swap_cache(table); | ||
30 | } | ||
31 | |||
18 | #endif /* _ASM_X86_TLB_H */ | 32 | #endif /* _ASM_X86_TLB_H */ |
diff --git a/arch/x86/include/asm/tlbflush.h b/arch/x86/include/asm/tlbflush.h index 50ea3482e1d1..d23e61dc0640 100644 --- a/arch/x86/include/asm/tlbflush.h +++ b/arch/x86/include/asm/tlbflush.h | |||
@@ -57,6 +57,23 @@ static inline void invpcid_flush_all_nonglobals(void) | |||
57 | __invpcid(0, 0, INVPCID_TYPE_ALL_NON_GLOBAL); | 57 | __invpcid(0, 0, INVPCID_TYPE_ALL_NON_GLOBAL); |
58 | } | 58 | } |
59 | 59 | ||
60 | static inline u64 inc_mm_tlb_gen(struct mm_struct *mm) | ||
61 | { | ||
62 | u64 new_tlb_gen; | ||
63 | |||
64 | /* | ||
65 | * Bump the generation count. This also serves as a full barrier | ||
66 | * that synchronizes with switch_mm(): callers are required to order | ||
67 | * their read of mm_cpumask after their writes to the paging | ||
68 | * structures. | ||
69 | */ | ||
70 | smp_mb__before_atomic(); | ||
71 | new_tlb_gen = atomic64_inc_return(&mm->context.tlb_gen); | ||
72 | smp_mb__after_atomic(); | ||
73 | |||
74 | return new_tlb_gen; | ||
75 | } | ||
76 | |||
60 | #ifdef CONFIG_PARAVIRT | 77 | #ifdef CONFIG_PARAVIRT |
61 | #include <asm/paravirt.h> | 78 | #include <asm/paravirt.h> |
62 | #else | 79 | #else |
@@ -65,6 +82,17 @@ static inline void invpcid_flush_all_nonglobals(void) | |||
65 | #define __flush_tlb_single(addr) __native_flush_tlb_single(addr) | 82 | #define __flush_tlb_single(addr) __native_flush_tlb_single(addr) |
66 | #endif | 83 | #endif |
67 | 84 | ||
85 | /* | ||
86 | * 6 because 6 should be plenty and struct tlb_state will fit in | ||
87 | * two cache lines. | ||
88 | */ | ||
89 | #define TLB_NR_DYN_ASIDS 6 | ||
90 | |||
91 | struct tlb_context { | ||
92 | u64 ctx_id; | ||
93 | u64 tlb_gen; | ||
94 | }; | ||
95 | |||
68 | struct tlb_state { | 96 | struct tlb_state { |
69 | /* | 97 | /* |
70 | * cpu_tlbstate.loaded_mm should match CR3 whenever interrupts | 98 | * cpu_tlbstate.loaded_mm should match CR3 whenever interrupts |
@@ -73,13 +101,35 @@ struct tlb_state { | |||
73 | * mode even if we've already switched back to swapper_pg_dir. | 101 | * mode even if we've already switched back to swapper_pg_dir. |
74 | */ | 102 | */ |
75 | struct mm_struct *loaded_mm; | 103 | struct mm_struct *loaded_mm; |
76 | int state; | 104 | u16 loaded_mm_asid; |
105 | u16 next_asid; | ||
77 | 106 | ||
78 | /* | 107 | /* |
79 | * Access to this CR4 shadow and to H/W CR4 is protected by | 108 | * Access to this CR4 shadow and to H/W CR4 is protected by |
80 | * disabling interrupts when modifying either one. | 109 | * disabling interrupts when modifying either one. |
81 | */ | 110 | */ |
82 | unsigned long cr4; | 111 | unsigned long cr4; |
112 | |||
113 | /* | ||
114 | * This is a list of all contexts that might exist in the TLB. | ||
115 | * There is one per ASID that we use, and the ASID (what the | ||
116 | * CPU calls PCID) is the index into ctxts. | ||
117 | * | ||
118 | * For each context, ctx_id indicates which mm the TLB's user | ||
119 | * entries came from. As an invariant, the TLB will never | ||
120 | * contain entries that are out-of-date as when that mm reached | ||
121 | * the tlb_gen in the list. | ||
122 | * | ||
123 | * To be clear, this means that it's legal for the TLB code to | ||
124 | * flush the TLB without updating tlb_gen. This can happen | ||
125 | * (for now, at least) due to paravirt remote flushes. | ||
126 | * | ||
127 | * NB: context 0 is a bit special, since it's also used by | ||
128 | * various bits of init code. This is fine -- code that | ||
129 | * isn't aware of PCID will end up harmlessly flushing | ||
130 | * context 0. | ||
131 | */ | ||
132 | struct tlb_context ctxs[TLB_NR_DYN_ASIDS]; | ||
83 | }; | 133 | }; |
84 | DECLARE_PER_CPU_SHARED_ALIGNED(struct tlb_state, cpu_tlbstate); | 134 | DECLARE_PER_CPU_SHARED_ALIGNED(struct tlb_state, cpu_tlbstate); |
85 | 135 | ||
@@ -207,6 +257,14 @@ static inline void __flush_tlb_all(void) | |||
207 | __flush_tlb_global(); | 257 | __flush_tlb_global(); |
208 | else | 258 | else |
209 | __flush_tlb(); | 259 | __flush_tlb(); |
260 | |||
261 | /* | ||
262 | * Note: if we somehow had PCID but not PGE, then this wouldn't work -- | ||
263 | * we'd end up flushing kernel translations for the current ASID but | ||
264 | * we might fail to flush kernel translations for other cached ASIDs. | ||
265 | * | ||
266 | * To avoid this issue, we force PCID off if PGE is off. | ||
267 | */ | ||
210 | } | 268 | } |
211 | 269 | ||
212 | static inline void __flush_tlb_one(unsigned long addr) | 270 | static inline void __flush_tlb_one(unsigned long addr) |
@@ -231,9 +289,26 @@ static inline void __flush_tlb_one(unsigned long addr) | |||
231 | * and page-granular flushes are available only on i486 and up. | 289 | * and page-granular flushes are available only on i486 and up. |
232 | */ | 290 | */ |
233 | struct flush_tlb_info { | 291 | struct flush_tlb_info { |
234 | struct mm_struct *mm; | 292 | /* |
235 | unsigned long start; | 293 | * We support several kinds of flushes. |
236 | unsigned long end; | 294 | * |
295 | * - Fully flush a single mm. .mm will be set, .end will be | ||
296 | * TLB_FLUSH_ALL, and .new_tlb_gen will be the tlb_gen to | ||
297 | * which the IPI sender is trying to catch us up. | ||
298 | * | ||
299 | * - Partially flush a single mm. .mm will be set, .start and | ||
300 | * .end will indicate the range, and .new_tlb_gen will be set | ||
301 | * such that the changes between generation .new_tlb_gen-1 and | ||
302 | * .new_tlb_gen are entirely contained in the indicated range. | ||
303 | * | ||
304 | * - Fully flush all mms whose tlb_gens have been updated. .mm | ||
305 | * will be NULL, .end will be TLB_FLUSH_ALL, and .new_tlb_gen | ||
306 | * will be zero. | ||
307 | */ | ||
308 | struct mm_struct *mm; | ||
309 | unsigned long start; | ||
310 | unsigned long end; | ||
311 | u64 new_tlb_gen; | ||
237 | }; | 312 | }; |
238 | 313 | ||
239 | #define local_flush_tlb() __flush_tlb() | 314 | #define local_flush_tlb() __flush_tlb() |
@@ -256,12 +331,10 @@ static inline void flush_tlb_page(struct vm_area_struct *vma, unsigned long a) | |||
256 | void native_flush_tlb_others(const struct cpumask *cpumask, | 331 | void native_flush_tlb_others(const struct cpumask *cpumask, |
257 | const struct flush_tlb_info *info); | 332 | const struct flush_tlb_info *info); |
258 | 333 | ||
259 | #define TLBSTATE_OK 1 | ||
260 | #define TLBSTATE_LAZY 2 | ||
261 | |||
262 | static inline void arch_tlbbatch_add_mm(struct arch_tlbflush_unmap_batch *batch, | 334 | static inline void arch_tlbbatch_add_mm(struct arch_tlbflush_unmap_batch *batch, |
263 | struct mm_struct *mm) | 335 | struct mm_struct *mm) |
264 | { | 336 | { |
337 | inc_mm_tlb_gen(mm); | ||
265 | cpumask_or(&batch->cpumask, &batch->cpumask, mm_cpumask(mm)); | 338 | cpumask_or(&batch->cpumask, &batch->cpumask, mm_cpumask(mm)); |
266 | } | 339 | } |
267 | 340 | ||
diff --git a/arch/x86/include/asm/vga.h b/arch/x86/include/asm/vga.h index c4b9dc2f67c5..9f42beefc67a 100644 --- a/arch/x86/include/asm/vga.h +++ b/arch/x86/include/asm/vga.h | |||
@@ -7,12 +7,24 @@ | |||
7 | #ifndef _ASM_X86_VGA_H | 7 | #ifndef _ASM_X86_VGA_H |
8 | #define _ASM_X86_VGA_H | 8 | #define _ASM_X86_VGA_H |
9 | 9 | ||
10 | #include <asm/set_memory.h> | ||
11 | |||
10 | /* | 12 | /* |
11 | * On the PC, we can just recalculate addresses and then | 13 | * On the PC, we can just recalculate addresses and then |
12 | * access the videoram directly without any black magic. | 14 | * access the videoram directly without any black magic. |
15 | * To support memory encryption however, we need to access | ||
16 | * the videoram as decrypted memory. | ||
13 | */ | 17 | */ |
14 | 18 | ||
15 | #define VGA_MAP_MEM(x, s) (unsigned long)phys_to_virt(x) | 19 | #define VGA_MAP_MEM(x, s) \ |
20 | ({ \ | ||
21 | unsigned long start = (unsigned long)phys_to_virt(x); \ | ||
22 | \ | ||
23 | if (IS_ENABLED(CONFIG_AMD_MEM_ENCRYPT)) \ | ||
24 | set_memory_decrypted(start, (s) >> PAGE_SHIFT); \ | ||
25 | \ | ||
26 | start; \ | ||
27 | }) | ||
16 | 28 | ||
17 | #define vga_readb(x) (*(x)) | 29 | #define vga_readb(x) (*(x)) |
18 | #define vga_writeb(x, y) (*(y) = (x)) | 30 | #define vga_writeb(x, y) (*(y) = (x)) |
diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c index 7491e73d9253..97bb2caf3428 100644 --- a/arch/x86/kernel/acpi/boot.c +++ b/arch/x86/kernel/acpi/boot.c | |||
@@ -115,7 +115,7 @@ static u32 isa_irq_to_gsi[NR_IRQS_LEGACY] __read_mostly = { | |||
115 | #define ACPI_INVALID_GSI INT_MIN | 115 | #define ACPI_INVALID_GSI INT_MIN |
116 | 116 | ||
117 | /* | 117 | /* |
118 | * This is just a simple wrapper around early_ioremap(), | 118 | * This is just a simple wrapper around early_memremap(), |
119 | * with sanity checks for phys == 0 and size == 0. | 119 | * with sanity checks for phys == 0 and size == 0. |
120 | */ | 120 | */ |
121 | char *__init __acpi_map_table(unsigned long phys, unsigned long size) | 121 | char *__init __acpi_map_table(unsigned long phys, unsigned long size) |
@@ -124,7 +124,7 @@ char *__init __acpi_map_table(unsigned long phys, unsigned long size) | |||
124 | if (!phys || !size) | 124 | if (!phys || !size) |
125 | return NULL; | 125 | return NULL; |
126 | 126 | ||
127 | return early_ioremap(phys, size); | 127 | return early_memremap(phys, size); |
128 | } | 128 | } |
129 | 129 | ||
130 | void __init __acpi_unmap_table(char *map, unsigned long size) | 130 | void __init __acpi_unmap_table(char *map, unsigned long size) |
@@ -132,7 +132,7 @@ void __init __acpi_unmap_table(char *map, unsigned long size) | |||
132 | if (!map || !size) | 132 | if (!map || !size) |
133 | return; | 133 | return; |
134 | 134 | ||
135 | early_iounmap(map, size); | 135 | early_memunmap(map, size); |
136 | } | 136 | } |
137 | 137 | ||
138 | #ifdef CONFIG_X86_LOCAL_APIC | 138 | #ifdef CONFIG_X86_LOCAL_APIC |
diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c index 3b9e220621f8..110ca5d2bb87 100644 --- a/arch/x86/kernel/cpu/amd.c +++ b/arch/x86/kernel/cpu/amd.c | |||
@@ -548,8 +548,12 @@ static void bsp_init_amd(struct cpuinfo_x86 *c) | |||
548 | 548 | ||
549 | static void early_init_amd(struct cpuinfo_x86 *c) | 549 | static void early_init_amd(struct cpuinfo_x86 *c) |
550 | { | 550 | { |
551 | u32 dummy; | ||
552 | |||
551 | early_init_amd_mc(c); | 553 | early_init_amd_mc(c); |
552 | 554 | ||
555 | rdmsr_safe(MSR_AMD64_PATCH_LEVEL, &c->microcode, &dummy); | ||
556 | |||
553 | /* | 557 | /* |
554 | * c->x86_power is 8000_0007 edx. Bit 8 is TSC runs at constant rate | 558 | * c->x86_power is 8000_0007 edx. Bit 8 is TSC runs at constant rate |
555 | * with P/T states and does not stop in deep C-states | 559 | * with P/T states and does not stop in deep C-states |
@@ -612,6 +616,27 @@ static void early_init_amd(struct cpuinfo_x86 *c) | |||
612 | */ | 616 | */ |
613 | if (cpu_has_amd_erratum(c, amd_erratum_400)) | 617 | if (cpu_has_amd_erratum(c, amd_erratum_400)) |
614 | set_cpu_bug(c, X86_BUG_AMD_E400); | 618 | set_cpu_bug(c, X86_BUG_AMD_E400); |
619 | |||
620 | /* | ||
621 | * BIOS support is required for SME. If BIOS has enabled SME then | ||
622 | * adjust x86_phys_bits by the SME physical address space reduction | ||
623 | * value. If BIOS has not enabled SME then don't advertise the | ||
624 | * feature (set in scattered.c). Also, since the SME support requires | ||
625 | * long mode, don't advertise the feature under CONFIG_X86_32. | ||
626 | */ | ||
627 | if (cpu_has(c, X86_FEATURE_SME)) { | ||
628 | u64 msr; | ||
629 | |||
630 | /* Check if SME is enabled */ | ||
631 | rdmsrl(MSR_K8_SYSCFG, msr); | ||
632 | if (msr & MSR_K8_SYSCFG_MEM_ENCRYPT) { | ||
633 | c->x86_phys_bits -= (cpuid_ebx(0x8000001f) >> 6) & 0x3f; | ||
634 | if (IS_ENABLED(CONFIG_X86_32)) | ||
635 | clear_cpu_cap(c, X86_FEATURE_SME); | ||
636 | } else { | ||
637 | clear_cpu_cap(c, X86_FEATURE_SME); | ||
638 | } | ||
639 | } | ||
615 | } | 640 | } |
616 | 641 | ||
617 | static void init_amd_k8(struct cpuinfo_x86 *c) | 642 | static void init_amd_k8(struct cpuinfo_x86 *c) |
@@ -730,8 +755,6 @@ static void init_amd_bd(struct cpuinfo_x86 *c) | |||
730 | 755 | ||
731 | static void init_amd(struct cpuinfo_x86 *c) | 756 | static void init_amd(struct cpuinfo_x86 *c) |
732 | { | 757 | { |
733 | u32 dummy; | ||
734 | |||
735 | early_init_amd(c); | 758 | early_init_amd(c); |
736 | 759 | ||
737 | /* | 760 | /* |
@@ -793,8 +816,6 @@ static void init_amd(struct cpuinfo_x86 *c) | |||
793 | if (c->x86 > 0x11) | 816 | if (c->x86 > 0x11) |
794 | set_cpu_cap(c, X86_FEATURE_ARAT); | 817 | set_cpu_cap(c, X86_FEATURE_ARAT); |
795 | 818 | ||
796 | rdmsr_safe(MSR_AMD64_PATCH_LEVEL, &c->microcode, &dummy); | ||
797 | |||
798 | /* 3DNow or LM implies PREFETCHW */ | 819 | /* 3DNow or LM implies PREFETCHW */ |
799 | if (!cpu_has(c, X86_FEATURE_3DNOWPREFETCH)) | 820 | if (!cpu_has(c, X86_FEATURE_3DNOWPREFETCH)) |
800 | if (cpu_has(c, X86_FEATURE_3DNOW) || cpu_has(c, X86_FEATURE_LM)) | 821 | if (cpu_has(c, X86_FEATURE_3DNOW) || cpu_has(c, X86_FEATURE_LM)) |
diff --git a/arch/x86/kernel/cpu/aperfmperf.c b/arch/x86/kernel/cpu/aperfmperf.c index 7cf7c70b6ef2..0ee83321a313 100644 --- a/arch/x86/kernel/cpu/aperfmperf.c +++ b/arch/x86/kernel/cpu/aperfmperf.c | |||
@@ -40,13 +40,16 @@ static void aperfmperf_snapshot_khz(void *dummy) | |||
40 | struct aperfmperf_sample *s = this_cpu_ptr(&samples); | 40 | struct aperfmperf_sample *s = this_cpu_ptr(&samples); |
41 | ktime_t now = ktime_get(); | 41 | ktime_t now = ktime_get(); |
42 | s64 time_delta = ktime_ms_delta(now, s->time); | 42 | s64 time_delta = ktime_ms_delta(now, s->time); |
43 | unsigned long flags; | ||
43 | 44 | ||
44 | /* Don't bother re-computing within the cache threshold time. */ | 45 | /* Don't bother re-computing within the cache threshold time. */ |
45 | if (time_delta < APERFMPERF_CACHE_THRESHOLD_MS) | 46 | if (time_delta < APERFMPERF_CACHE_THRESHOLD_MS) |
46 | return; | 47 | return; |
47 | 48 | ||
49 | local_irq_save(flags); | ||
48 | rdmsrl(MSR_IA32_APERF, aperf); | 50 | rdmsrl(MSR_IA32_APERF, aperf); |
49 | rdmsrl(MSR_IA32_MPERF, mperf); | 51 | rdmsrl(MSR_IA32_MPERF, mperf); |
52 | local_irq_restore(flags); | ||
50 | 53 | ||
51 | aperf_delta = aperf - s->aperf; | 54 | aperf_delta = aperf - s->aperf; |
52 | mperf_delta = mperf - s->mperf; | 55 | mperf_delta = mperf - s->mperf; |
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c index 0af86d9242da..db684880d74a 100644 --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c | |||
@@ -21,6 +21,14 @@ | |||
21 | 21 | ||
22 | void __init check_bugs(void) | 22 | void __init check_bugs(void) |
23 | { | 23 | { |
24 | #ifdef CONFIG_X86_32 | ||
25 | /* | ||
26 | * Regardless of whether PCID is enumerated, the SDM says | ||
27 | * that it can't be enabled in 32-bit mode. | ||
28 | */ | ||
29 | setup_clear_cpu_cap(X86_FEATURE_PCID); | ||
30 | #endif | ||
31 | |||
24 | identify_boot_cpu(); | 32 | identify_boot_cpu(); |
25 | 33 | ||
26 | if (!IS_ENABLED(CONFIG_SMP)) { | 34 | if (!IS_ENABLED(CONFIG_SMP)) { |
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index c8b39870f33e..b95cd94ca97b 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c | |||
@@ -168,6 +168,24 @@ static int __init x86_mpx_setup(char *s) | |||
168 | } | 168 | } |
169 | __setup("nompx", x86_mpx_setup); | 169 | __setup("nompx", x86_mpx_setup); |
170 | 170 | ||
171 | #ifdef CONFIG_X86_64 | ||
172 | static int __init x86_pcid_setup(char *s) | ||
173 | { | ||
174 | /* require an exact match without trailing characters */ | ||
175 | if (strlen(s)) | ||
176 | return 0; | ||
177 | |||
178 | /* do not emit a message if the feature is not present */ | ||
179 | if (!boot_cpu_has(X86_FEATURE_PCID)) | ||
180 | return 1; | ||
181 | |||
182 | setup_clear_cpu_cap(X86_FEATURE_PCID); | ||
183 | pr_info("nopcid: PCID feature disabled\n"); | ||
184 | return 1; | ||
185 | } | ||
186 | __setup("nopcid", x86_pcid_setup); | ||
187 | #endif | ||
188 | |||
171 | static int __init x86_noinvpcid_setup(char *s) | 189 | static int __init x86_noinvpcid_setup(char *s) |
172 | { | 190 | { |
173 | /* noinvpcid doesn't accept parameters */ | 191 | /* noinvpcid doesn't accept parameters */ |
@@ -311,6 +329,25 @@ static __always_inline void setup_smap(struct cpuinfo_x86 *c) | |||
311 | } | 329 | } |
312 | } | 330 | } |
313 | 331 | ||
332 | static void setup_pcid(struct cpuinfo_x86 *c) | ||
333 | { | ||
334 | if (cpu_has(c, X86_FEATURE_PCID)) { | ||
335 | if (cpu_has(c, X86_FEATURE_PGE)) { | ||
336 | cr4_set_bits(X86_CR4_PCIDE); | ||
337 | } else { | ||
338 | /* | ||
339 | * flush_tlb_all(), as currently implemented, won't | ||
340 | * work if PCID is on but PGE is not. Since that | ||
341 | * combination doesn't exist on real hardware, there's | ||
342 | * no reason to try to fully support it, but it's | ||
343 | * polite to avoid corrupting data if we're on | ||
344 | * an improperly configured VM. | ||
345 | */ | ||
346 | clear_cpu_cap(c, X86_FEATURE_PCID); | ||
347 | } | ||
348 | } | ||
349 | } | ||
350 | |||
314 | /* | 351 | /* |
315 | * Protection Keys are not available in 32-bit mode. | 352 | * Protection Keys are not available in 32-bit mode. |
316 | */ | 353 | */ |
@@ -1125,6 +1162,9 @@ static void identify_cpu(struct cpuinfo_x86 *c) | |||
1125 | setup_smep(c); | 1162 | setup_smep(c); |
1126 | setup_smap(c); | 1163 | setup_smap(c); |
1127 | 1164 | ||
1165 | /* Set up PCID */ | ||
1166 | setup_pcid(c); | ||
1167 | |||
1128 | /* | 1168 | /* |
1129 | * The vendor-specific functions might have changed features. | 1169 | * The vendor-specific functions might have changed features. |
1130 | * Now we do "generic changes." | 1170 | * Now we do "generic changes." |
diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c index 6dde0497efc7..3b413065c613 100644 --- a/arch/x86/kernel/cpu/mcheck/mce.c +++ b/arch/x86/kernel/cpu/mcheck/mce.c | |||
@@ -51,6 +51,7 @@ | |||
51 | #include <asm/mce.h> | 51 | #include <asm/mce.h> |
52 | #include <asm/msr.h> | 52 | #include <asm/msr.h> |
53 | #include <asm/reboot.h> | 53 | #include <asm/reboot.h> |
54 | #include <asm/set_memory.h> | ||
54 | 55 | ||
55 | #include "mce-internal.h" | 56 | #include "mce-internal.h" |
56 | 57 | ||
@@ -1051,6 +1052,48 @@ static int do_memory_failure(struct mce *m) | |||
1051 | return ret; | 1052 | return ret; |
1052 | } | 1053 | } |
1053 | 1054 | ||
1055 | #if defined(arch_unmap_kpfn) && defined(CONFIG_MEMORY_FAILURE) | ||
1056 | |||
1057 | void arch_unmap_kpfn(unsigned long pfn) | ||
1058 | { | ||
1059 | unsigned long decoy_addr; | ||
1060 | |||
1061 | /* | ||
1062 | * Unmap this page from the kernel 1:1 mappings to make sure | ||
1063 | * we don't log more errors because of speculative access to | ||
1064 | * the page. | ||
1065 | * We would like to just call: | ||
1066 | * set_memory_np((unsigned long)pfn_to_kaddr(pfn), 1); | ||
1067 | * but doing that would radically increase the odds of a | ||
1068 | * speculative access to the posion page because we'd have | ||
1069 | * the virtual address of the kernel 1:1 mapping sitting | ||
1070 | * around in registers. | ||
1071 | * Instead we get tricky. We create a non-canonical address | ||
1072 | * that looks just like the one we want, but has bit 63 flipped. | ||
1073 | * This relies on set_memory_np() not checking whether we passed | ||
1074 | * a legal address. | ||
1075 | */ | ||
1076 | |||
1077 | /* | ||
1078 | * Build time check to see if we have a spare virtual bit. Don't want | ||
1079 | * to leave this until run time because most developers don't have a | ||
1080 | * system that can exercise this code path. This will only become a | ||
1081 | * problem if/when we move beyond 5-level page tables. | ||
1082 | * | ||
1083 | * Hard code "9" here because cpp doesn't grok ilog2(PTRS_PER_PGD) | ||
1084 | */ | ||
1085 | #if PGDIR_SHIFT + 9 < 63 | ||
1086 | decoy_addr = (pfn << PAGE_SHIFT) + (PAGE_OFFSET ^ BIT(63)); | ||
1087 | #else | ||
1088 | #error "no unused virtual bit available" | ||
1089 | #endif | ||
1090 | |||
1091 | if (set_memory_np(decoy_addr, 1)) | ||
1092 | pr_warn("Could not invalidate pfn=0x%lx from 1:1 map\n", pfn); | ||
1093 | |||
1094 | } | ||
1095 | #endif | ||
1096 | |||
1054 | /* | 1097 | /* |
1055 | * The actual machine check handler. This only handles real | 1098 | * The actual machine check handler. This only handles real |
1056 | * exceptions when something got corrupted coming in through int 18. | 1099 | * exceptions when something got corrupted coming in through int 18. |
diff --git a/arch/x86/kernel/cpu/mcheck/therm_throt.c b/arch/x86/kernel/cpu/mcheck/therm_throt.c index d7cc190ae457..f7370abd33c6 100644 --- a/arch/x86/kernel/cpu/mcheck/therm_throt.c +++ b/arch/x86/kernel/cpu/mcheck/therm_throt.c | |||
@@ -122,7 +122,7 @@ static struct attribute *thermal_throttle_attrs[] = { | |||
122 | NULL | 122 | NULL |
123 | }; | 123 | }; |
124 | 124 | ||
125 | static struct attribute_group thermal_attr_group = { | 125 | static const struct attribute_group thermal_attr_group = { |
126 | .attrs = thermal_throttle_attrs, | 126 | .attrs = thermal_throttle_attrs, |
127 | .name = "thermal_throttle" | 127 | .name = "thermal_throttle" |
128 | }; | 128 | }; |
diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c index 9cb98ee103db..86e8f0b2537b 100644 --- a/arch/x86/kernel/cpu/microcode/core.c +++ b/arch/x86/kernel/cpu/microcode/core.c | |||
@@ -561,7 +561,7 @@ static struct attribute *mc_default_attrs[] = { | |||
561 | NULL | 561 | NULL |
562 | }; | 562 | }; |
563 | 563 | ||
564 | static struct attribute_group mc_attr_group = { | 564 | static const struct attribute_group mc_attr_group = { |
565 | .attrs = mc_default_attrs, | 565 | .attrs = mc_default_attrs, |
566 | .name = "microcode", | 566 | .name = "microcode", |
567 | }; | 567 | }; |
@@ -707,7 +707,7 @@ static struct attribute *cpu_root_microcode_attrs[] = { | |||
707 | NULL | 707 | NULL |
708 | }; | 708 | }; |
709 | 709 | ||
710 | static struct attribute_group cpu_root_microcode_group = { | 710 | static const struct attribute_group cpu_root_microcode_group = { |
711 | .name = "microcode", | 711 | .name = "microcode", |
712 | .attrs = cpu_root_microcode_attrs, | 712 | .attrs = cpu_root_microcode_attrs, |
713 | }; | 713 | }; |
diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c index c5bb63be4ba1..40d5a8a75212 100644 --- a/arch/x86/kernel/cpu/mtrr/main.c +++ b/arch/x86/kernel/cpu/mtrr/main.c | |||
@@ -237,6 +237,18 @@ set_mtrr(unsigned int reg, unsigned long base, unsigned long size, mtrr_type typ | |||
237 | stop_machine(mtrr_rendezvous_handler, &data, cpu_online_mask); | 237 | stop_machine(mtrr_rendezvous_handler, &data, cpu_online_mask); |
238 | } | 238 | } |
239 | 239 | ||
240 | static void set_mtrr_cpuslocked(unsigned int reg, unsigned long base, | ||
241 | unsigned long size, mtrr_type type) | ||
242 | { | ||
243 | struct set_mtrr_data data = { .smp_reg = reg, | ||
244 | .smp_base = base, | ||
245 | .smp_size = size, | ||
246 | .smp_type = type | ||
247 | }; | ||
248 | |||
249 | stop_machine_cpuslocked(mtrr_rendezvous_handler, &data, cpu_online_mask); | ||
250 | } | ||
251 | |||
240 | static void set_mtrr_from_inactive_cpu(unsigned int reg, unsigned long base, | 252 | static void set_mtrr_from_inactive_cpu(unsigned int reg, unsigned long base, |
241 | unsigned long size, mtrr_type type) | 253 | unsigned long size, mtrr_type type) |
242 | { | 254 | { |
@@ -370,7 +382,7 @@ int mtrr_add_page(unsigned long base, unsigned long size, | |||
370 | /* Search for an empty MTRR */ | 382 | /* Search for an empty MTRR */ |
371 | i = mtrr_if->get_free_region(base, size, replace); | 383 | i = mtrr_if->get_free_region(base, size, replace); |
372 | if (i >= 0) { | 384 | if (i >= 0) { |
373 | set_mtrr(i, base, size, type); | 385 | set_mtrr_cpuslocked(i, base, size, type); |
374 | if (likely(replace < 0)) { | 386 | if (likely(replace < 0)) { |
375 | mtrr_usage_table[i] = 1; | 387 | mtrr_usage_table[i] = 1; |
376 | } else { | 388 | } else { |
@@ -378,7 +390,7 @@ int mtrr_add_page(unsigned long base, unsigned long size, | |||
378 | if (increment) | 390 | if (increment) |
379 | mtrr_usage_table[i]++; | 391 | mtrr_usage_table[i]++; |
380 | if (unlikely(replace != i)) { | 392 | if (unlikely(replace != i)) { |
381 | set_mtrr(replace, 0, 0, 0); | 393 | set_mtrr_cpuslocked(replace, 0, 0, 0); |
382 | mtrr_usage_table[replace] = 0; | 394 | mtrr_usage_table[replace] = 0; |
383 | } | 395 | } |
384 | } | 396 | } |
@@ -506,7 +518,7 @@ int mtrr_del_page(int reg, unsigned long base, unsigned long size) | |||
506 | goto out; | 518 | goto out; |
507 | } | 519 | } |
508 | if (--mtrr_usage_table[reg] < 1) | 520 | if (--mtrr_usage_table[reg] < 1) |
509 | set_mtrr(reg, 0, 0, 0); | 521 | set_mtrr_cpuslocked(reg, 0, 0, 0); |
510 | error = reg; | 522 | error = reg; |
511 | out: | 523 | out: |
512 | mutex_unlock(&mtrr_mutex); | 524 | mutex_unlock(&mtrr_mutex); |
diff --git a/arch/x86/kernel/cpu/scattered.c b/arch/x86/kernel/cpu/scattered.c index 23c23508c012..05459ad3db46 100644 --- a/arch/x86/kernel/cpu/scattered.c +++ b/arch/x86/kernel/cpu/scattered.c | |||
@@ -31,6 +31,7 @@ static const struct cpuid_bit cpuid_bits[] = { | |||
31 | { X86_FEATURE_HW_PSTATE, CPUID_EDX, 7, 0x80000007, 0 }, | 31 | { X86_FEATURE_HW_PSTATE, CPUID_EDX, 7, 0x80000007, 0 }, |
32 | { X86_FEATURE_CPB, CPUID_EDX, 9, 0x80000007, 0 }, | 32 | { X86_FEATURE_CPB, CPUID_EDX, 9, 0x80000007, 0 }, |
33 | { X86_FEATURE_PROC_FEEDBACK, CPUID_EDX, 11, 0x80000007, 0 }, | 33 | { X86_FEATURE_PROC_FEEDBACK, CPUID_EDX, 11, 0x80000007, 0 }, |
34 | { X86_FEATURE_SME, CPUID_EAX, 0, 0x8000001f, 0 }, | ||
34 | { 0, 0, 0, 0, 0 } | 35 | { 0, 0, 0, 0, 0 } |
35 | }; | 36 | }; |
36 | 37 | ||
diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c index 532da61d605c..71c11ad5643e 100644 --- a/arch/x86/kernel/e820.c +++ b/arch/x86/kernel/e820.c | |||
@@ -96,7 +96,8 @@ EXPORT_SYMBOL_GPL(e820__mapped_any); | |||
96 | * Note: this function only works correctly once the E820 table is sorted and | 96 | * Note: this function only works correctly once the E820 table is sorted and |
97 | * not-overlapping (at least for the range specified), which is the case normally. | 97 | * not-overlapping (at least for the range specified), which is the case normally. |
98 | */ | 98 | */ |
99 | bool __init e820__mapped_all(u64 start, u64 end, enum e820_type type) | 99 | static struct e820_entry *__e820__mapped_all(u64 start, u64 end, |
100 | enum e820_type type) | ||
100 | { | 101 | { |
101 | int i; | 102 | int i; |
102 | 103 | ||
@@ -122,9 +123,28 @@ bool __init e820__mapped_all(u64 start, u64 end, enum e820_type type) | |||
122 | * coverage of the desired range exists: | 123 | * coverage of the desired range exists: |
123 | */ | 124 | */ |
124 | if (start >= end) | 125 | if (start >= end) |
125 | return 1; | 126 | return entry; |
126 | } | 127 | } |
127 | return 0; | 128 | |
129 | return NULL; | ||
130 | } | ||
131 | |||
132 | /* | ||
133 | * This function checks if the entire range <start,end> is mapped with type. | ||
134 | */ | ||
135 | bool __init e820__mapped_all(u64 start, u64 end, enum e820_type type) | ||
136 | { | ||
137 | return __e820__mapped_all(start, end, type); | ||
138 | } | ||
139 | |||
140 | /* | ||
141 | * This function returns the type associated with the range <start,end>. | ||
142 | */ | ||
143 | int e820__get_entry_type(u64 start, u64 end) | ||
144 | { | ||
145 | struct e820_entry *entry = __e820__mapped_all(start, end, 0); | ||
146 | |||
147 | return entry ? entry->type : -EINVAL; | ||
128 | } | 148 | } |
129 | 149 | ||
130 | /* | 150 | /* |
diff --git a/arch/x86/kernel/espfix_64.c b/arch/x86/kernel/espfix_64.c index 6b91e2eb8d3f..9c4e7ba6870c 100644 --- a/arch/x86/kernel/espfix_64.c +++ b/arch/x86/kernel/espfix_64.c | |||
@@ -195,7 +195,7 @@ void init_espfix_ap(int cpu) | |||
195 | 195 | ||
196 | pte_p = pte_offset_kernel(&pmd, addr); | 196 | pte_p = pte_offset_kernel(&pmd, addr); |
197 | stack_page = page_address(alloc_pages_node(node, GFP_KERNEL, 0)); | 197 | stack_page = page_address(alloc_pages_node(node, GFP_KERNEL, 0)); |
198 | pte = __pte(__pa(stack_page) | (__PAGE_KERNEL_RO & ptemask)); | 198 | pte = __pte(__pa(stack_page) | ((__PAGE_KERNEL_RO | _PAGE_ENC) & ptemask)); |
199 | for (n = 0; n < ESPFIX_PTE_CLONES; n++) | 199 | for (n = 0; n < ESPFIX_PTE_CLONES; n++) |
200 | set_pte(&pte_p[n*PTE_STRIDE], pte); | 200 | set_pte(&pte_p[n*PTE_STRIDE], pte); |
201 | 201 | ||
diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c index 46c3c73e7f43..6a193b93fd95 100644 --- a/arch/x86/kernel/head64.c +++ b/arch/x86/kernel/head64.c | |||
@@ -14,6 +14,7 @@ | |||
14 | #include <linux/start_kernel.h> | 14 | #include <linux/start_kernel.h> |
15 | #include <linux/io.h> | 15 | #include <linux/io.h> |
16 | #include <linux/memblock.h> | 16 | #include <linux/memblock.h> |
17 | #include <linux/mem_encrypt.h> | ||
17 | 18 | ||
18 | #include <asm/processor.h> | 19 | #include <asm/processor.h> |
19 | #include <asm/proto.h> | 20 | #include <asm/proto.h> |
@@ -33,7 +34,6 @@ | |||
33 | /* | 34 | /* |
34 | * Manage page tables very early on. | 35 | * Manage page tables very early on. |
35 | */ | 36 | */ |
36 | extern pgd_t early_top_pgt[PTRS_PER_PGD]; | ||
37 | extern pmd_t early_dynamic_pgts[EARLY_DYNAMIC_PAGE_TABLES][PTRS_PER_PMD]; | 37 | extern pmd_t early_dynamic_pgts[EARLY_DYNAMIC_PAGE_TABLES][PTRS_PER_PMD]; |
38 | static unsigned int __initdata next_early_pgt; | 38 | static unsigned int __initdata next_early_pgt; |
39 | pmdval_t early_pmd_flags = __PAGE_KERNEL_LARGE & ~(_PAGE_GLOBAL | _PAGE_NX); | 39 | pmdval_t early_pmd_flags = __PAGE_KERNEL_LARGE & ~(_PAGE_GLOBAL | _PAGE_NX); |
@@ -45,14 +45,17 @@ static void __head *fixup_pointer(void *ptr, unsigned long physaddr) | |||
45 | return ptr - (void *)_text + (void *)physaddr; | 45 | return ptr - (void *)_text + (void *)physaddr; |
46 | } | 46 | } |
47 | 47 | ||
48 | void __head __startup_64(unsigned long physaddr) | 48 | unsigned long __head __startup_64(unsigned long physaddr, |
49 | struct boot_params *bp) | ||
49 | { | 50 | { |
50 | unsigned long load_delta, *p; | 51 | unsigned long load_delta, *p; |
52 | unsigned long pgtable_flags; | ||
51 | pgdval_t *pgd; | 53 | pgdval_t *pgd; |
52 | p4dval_t *p4d; | 54 | p4dval_t *p4d; |
53 | pudval_t *pud; | 55 | pudval_t *pud; |
54 | pmdval_t *pmd, pmd_entry; | 56 | pmdval_t *pmd, pmd_entry; |
55 | int i; | 57 | int i; |
58 | unsigned int *next_pgt_ptr; | ||
56 | 59 | ||
57 | /* Is the address too large? */ | 60 | /* Is the address too large? */ |
58 | if (physaddr >> MAX_PHYSMEM_BITS) | 61 | if (physaddr >> MAX_PHYSMEM_BITS) |
@@ -68,6 +71,12 @@ void __head __startup_64(unsigned long physaddr) | |||
68 | if (load_delta & ~PMD_PAGE_MASK) | 71 | if (load_delta & ~PMD_PAGE_MASK) |
69 | for (;;); | 72 | for (;;); |
70 | 73 | ||
74 | /* Activate Secure Memory Encryption (SME) if supported and enabled */ | ||
75 | sme_enable(bp); | ||
76 | |||
77 | /* Include the SME encryption mask in the fixup value */ | ||
78 | load_delta += sme_get_me_mask(); | ||
79 | |||
71 | /* Fixup the physical addresses in the page table */ | 80 | /* Fixup the physical addresses in the page table */ |
72 | 81 | ||
73 | pgd = fixup_pointer(&early_top_pgt, physaddr); | 82 | pgd = fixup_pointer(&early_top_pgt, physaddr); |
@@ -92,30 +101,34 @@ void __head __startup_64(unsigned long physaddr) | |||
92 | * it avoids problems around wraparound. | 101 | * it avoids problems around wraparound. |
93 | */ | 102 | */ |
94 | 103 | ||
95 | pud = fixup_pointer(early_dynamic_pgts[next_early_pgt++], physaddr); | 104 | next_pgt_ptr = fixup_pointer(&next_early_pgt, physaddr); |
96 | pmd = fixup_pointer(early_dynamic_pgts[next_early_pgt++], physaddr); | 105 | pud = fixup_pointer(early_dynamic_pgts[(*next_pgt_ptr)++], physaddr); |
106 | pmd = fixup_pointer(early_dynamic_pgts[(*next_pgt_ptr)++], physaddr); | ||
107 | |||
108 | pgtable_flags = _KERNPG_TABLE_NOENC + sme_get_me_mask(); | ||
97 | 109 | ||
98 | if (IS_ENABLED(CONFIG_X86_5LEVEL)) { | 110 | if (IS_ENABLED(CONFIG_X86_5LEVEL)) { |
99 | p4d = fixup_pointer(early_dynamic_pgts[next_early_pgt++], physaddr); | 111 | p4d = fixup_pointer(early_dynamic_pgts[next_early_pgt++], physaddr); |
100 | 112 | ||
101 | i = (physaddr >> PGDIR_SHIFT) % PTRS_PER_PGD; | 113 | i = (physaddr >> PGDIR_SHIFT) % PTRS_PER_PGD; |
102 | pgd[i + 0] = (pgdval_t)p4d + _KERNPG_TABLE; | 114 | pgd[i + 0] = (pgdval_t)p4d + pgtable_flags; |
103 | pgd[i + 1] = (pgdval_t)p4d + _KERNPG_TABLE; | 115 | pgd[i + 1] = (pgdval_t)p4d + pgtable_flags; |
104 | 116 | ||
105 | i = (physaddr >> P4D_SHIFT) % PTRS_PER_P4D; | 117 | i = (physaddr >> P4D_SHIFT) % PTRS_PER_P4D; |
106 | p4d[i + 0] = (pgdval_t)pud + _KERNPG_TABLE; | 118 | p4d[i + 0] = (pgdval_t)pud + pgtable_flags; |
107 | p4d[i + 1] = (pgdval_t)pud + _KERNPG_TABLE; | 119 | p4d[i + 1] = (pgdval_t)pud + pgtable_flags; |
108 | } else { | 120 | } else { |
109 | i = (physaddr >> PGDIR_SHIFT) % PTRS_PER_PGD; | 121 | i = (physaddr >> PGDIR_SHIFT) % PTRS_PER_PGD; |
110 | pgd[i + 0] = (pgdval_t)pud + _KERNPG_TABLE; | 122 | pgd[i + 0] = (pgdval_t)pud + pgtable_flags; |
111 | pgd[i + 1] = (pgdval_t)pud + _KERNPG_TABLE; | 123 | pgd[i + 1] = (pgdval_t)pud + pgtable_flags; |
112 | } | 124 | } |
113 | 125 | ||
114 | i = (physaddr >> PUD_SHIFT) % PTRS_PER_PUD; | 126 | i = (physaddr >> PUD_SHIFT) % PTRS_PER_PUD; |
115 | pud[i + 0] = (pudval_t)pmd + _KERNPG_TABLE; | 127 | pud[i + 0] = (pudval_t)pmd + pgtable_flags; |
116 | pud[i + 1] = (pudval_t)pmd + _KERNPG_TABLE; | 128 | pud[i + 1] = (pudval_t)pmd + pgtable_flags; |
117 | 129 | ||
118 | pmd_entry = __PAGE_KERNEL_LARGE_EXEC & ~_PAGE_GLOBAL; | 130 | pmd_entry = __PAGE_KERNEL_LARGE_EXEC & ~_PAGE_GLOBAL; |
131 | pmd_entry += sme_get_me_mask(); | ||
119 | pmd_entry += physaddr; | 132 | pmd_entry += physaddr; |
120 | 133 | ||
121 | for (i = 0; i < DIV_ROUND_UP(_end - _text, PMD_SIZE); i++) { | 134 | for (i = 0; i < DIV_ROUND_UP(_end - _text, PMD_SIZE); i++) { |
@@ -136,9 +149,30 @@ void __head __startup_64(unsigned long physaddr) | |||
136 | pmd[i] += load_delta; | 149 | pmd[i] += load_delta; |
137 | } | 150 | } |
138 | 151 | ||
139 | /* Fixup phys_base */ | 152 | /* |
153 | * Fixup phys_base - remove the memory encryption mask to obtain | ||
154 | * the true physical address. | ||
155 | */ | ||
140 | p = fixup_pointer(&phys_base, physaddr); | 156 | p = fixup_pointer(&phys_base, physaddr); |
141 | *p += load_delta; | 157 | *p += load_delta - sme_get_me_mask(); |
158 | |||
159 | /* Encrypt the kernel (if SME is active) */ | ||
160 | sme_encrypt_kernel(); | ||
161 | |||
162 | /* | ||
163 | * Return the SME encryption mask (if SME is active) to be used as a | ||
164 | * modifier for the initial pgdir entry programmed into CR3. | ||
165 | */ | ||
166 | return sme_get_me_mask(); | ||
167 | } | ||
168 | |||
169 | unsigned long __startup_secondary_64(void) | ||
170 | { | ||
171 | /* | ||
172 | * Return the SME encryption mask (if SME is active) to be used as a | ||
173 | * modifier for the initial pgdir entry programmed into CR3. | ||
174 | */ | ||
175 | return sme_get_me_mask(); | ||
142 | } | 176 | } |
143 | 177 | ||
144 | /* Wipe all early page tables except for the kernel symbol map */ | 178 | /* Wipe all early page tables except for the kernel symbol map */ |
@@ -146,17 +180,17 @@ static void __init reset_early_page_tables(void) | |||
146 | { | 180 | { |
147 | memset(early_top_pgt, 0, sizeof(pgd_t)*(PTRS_PER_PGD-1)); | 181 | memset(early_top_pgt, 0, sizeof(pgd_t)*(PTRS_PER_PGD-1)); |
148 | next_early_pgt = 0; | 182 | next_early_pgt = 0; |
149 | write_cr3(__pa_nodebug(early_top_pgt)); | 183 | write_cr3(__sme_pa_nodebug(early_top_pgt)); |
150 | } | 184 | } |
151 | 185 | ||
152 | /* Create a new PMD entry */ | 186 | /* Create a new PMD entry */ |
153 | int __init early_make_pgtable(unsigned long address) | 187 | int __init __early_make_pgtable(unsigned long address, pmdval_t pmd) |
154 | { | 188 | { |
155 | unsigned long physaddr = address - __PAGE_OFFSET; | 189 | unsigned long physaddr = address - __PAGE_OFFSET; |
156 | pgdval_t pgd, *pgd_p; | 190 | pgdval_t pgd, *pgd_p; |
157 | p4dval_t p4d, *p4d_p; | 191 | p4dval_t p4d, *p4d_p; |
158 | pudval_t pud, *pud_p; | 192 | pudval_t pud, *pud_p; |
159 | pmdval_t pmd, *pmd_p; | 193 | pmdval_t *pmd_p; |
160 | 194 | ||
161 | /* Invalid address or early pgt is done ? */ | 195 | /* Invalid address or early pgt is done ? */ |
162 | if (physaddr >= MAXMEM || read_cr3_pa() != __pa_nodebug(early_top_pgt)) | 196 | if (physaddr >= MAXMEM || read_cr3_pa() != __pa_nodebug(early_top_pgt)) |
@@ -215,12 +249,21 @@ again: | |||
215 | memset(pmd_p, 0, sizeof(*pmd_p) * PTRS_PER_PMD); | 249 | memset(pmd_p, 0, sizeof(*pmd_p) * PTRS_PER_PMD); |
216 | *pud_p = (pudval_t)pmd_p - __START_KERNEL_map + phys_base + _KERNPG_TABLE; | 250 | *pud_p = (pudval_t)pmd_p - __START_KERNEL_map + phys_base + _KERNPG_TABLE; |
217 | } | 251 | } |
218 | pmd = (physaddr & PMD_MASK) + early_pmd_flags; | ||
219 | pmd_p[pmd_index(address)] = pmd; | 252 | pmd_p[pmd_index(address)] = pmd; |
220 | 253 | ||
221 | return 0; | 254 | return 0; |
222 | } | 255 | } |
223 | 256 | ||
257 | int __init early_make_pgtable(unsigned long address) | ||
258 | { | ||
259 | unsigned long physaddr = address - __PAGE_OFFSET; | ||
260 | pmdval_t pmd; | ||
261 | |||
262 | pmd = (physaddr & PMD_MASK) + early_pmd_flags; | ||
263 | |||
264 | return __early_make_pgtable(address, pmd); | ||
265 | } | ||
266 | |||
224 | /* Don't add a printk in there. printk relies on the PDA which is not initialized | 267 | /* Don't add a printk in there. printk relies on the PDA which is not initialized |
225 | yet. */ | 268 | yet. */ |
226 | static void __init clear_bss(void) | 269 | static void __init clear_bss(void) |
@@ -243,6 +286,12 @@ static void __init copy_bootdata(char *real_mode_data) | |||
243 | char * command_line; | 286 | char * command_line; |
244 | unsigned long cmd_line_ptr; | 287 | unsigned long cmd_line_ptr; |
245 | 288 | ||
289 | /* | ||
290 | * If SME is active, this will create decrypted mappings of the | ||
291 | * boot data in advance of the copy operations. | ||
292 | */ | ||
293 | sme_map_bootdata(real_mode_data); | ||
294 | |||
246 | memcpy(&boot_params, real_mode_data, sizeof boot_params); | 295 | memcpy(&boot_params, real_mode_data, sizeof boot_params); |
247 | sanitize_boot_params(&boot_params); | 296 | sanitize_boot_params(&boot_params); |
248 | cmd_line_ptr = get_cmd_line_ptr(); | 297 | cmd_line_ptr = get_cmd_line_ptr(); |
@@ -250,6 +299,14 @@ static void __init copy_bootdata(char *real_mode_data) | |||
250 | command_line = __va(cmd_line_ptr); | 299 | command_line = __va(cmd_line_ptr); |
251 | memcpy(boot_command_line, command_line, COMMAND_LINE_SIZE); | 300 | memcpy(boot_command_line, command_line, COMMAND_LINE_SIZE); |
252 | } | 301 | } |
302 | |||
303 | /* | ||
304 | * The old boot data is no longer needed and won't be reserved, | ||
305 | * freeing up that memory for use by the system. If SME is active, | ||
306 | * we need to remove the mappings that were created so that the | ||
307 | * memory doesn't remain mapped as decrypted. | ||
308 | */ | ||
309 | sme_unmap_bootdata(real_mode_data); | ||
253 | } | 310 | } |
254 | 311 | ||
255 | asmlinkage __visible void __init x86_64_start_kernel(char * real_mode_data) | 312 | asmlinkage __visible void __init x86_64_start_kernel(char * real_mode_data) |
@@ -279,6 +336,13 @@ asmlinkage __visible void __init x86_64_start_kernel(char * real_mode_data) | |||
279 | 336 | ||
280 | clear_page(init_top_pgt); | 337 | clear_page(init_top_pgt); |
281 | 338 | ||
339 | /* | ||
340 | * SME support may update early_pmd_flags to include the memory | ||
341 | * encryption mask, so it needs to be called before anything | ||
342 | * that may generate a page fault. | ||
343 | */ | ||
344 | sme_early_init(); | ||
345 | |||
282 | kasan_early_init(); | 346 | kasan_early_init(); |
283 | 347 | ||
284 | for (i = 0; i < NUM_EXCEPTION_VECTORS; i++) | 348 | for (i = 0; i < NUM_EXCEPTION_VECTORS; i++) |
diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S index 6225550883df..513cbb012ecc 100644 --- a/arch/x86/kernel/head_64.S +++ b/arch/x86/kernel/head_64.S | |||
@@ -73,12 +73,19 @@ startup_64: | |||
73 | /* Sanitize CPU configuration */ | 73 | /* Sanitize CPU configuration */ |
74 | call verify_cpu | 74 | call verify_cpu |
75 | 75 | ||
76 | /* | ||
77 | * Perform pagetable fixups. Additionally, if SME is active, encrypt | ||
78 | * the kernel and retrieve the modifier (SME encryption mask if SME | ||
79 | * is active) to be added to the initial pgdir entry that will be | ||
80 | * programmed into CR3. | ||
81 | */ | ||
76 | leaq _text(%rip), %rdi | 82 | leaq _text(%rip), %rdi |
77 | pushq %rsi | 83 | pushq %rsi |
78 | call __startup_64 | 84 | call __startup_64 |
79 | popq %rsi | 85 | popq %rsi |
80 | 86 | ||
81 | movq $(early_top_pgt - __START_KERNEL_map), %rax | 87 | /* Form the CR3 value being sure to include the CR3 modifier */ |
88 | addq $(early_top_pgt - __START_KERNEL_map), %rax | ||
82 | jmp 1f | 89 | jmp 1f |
83 | ENTRY(secondary_startup_64) | 90 | ENTRY(secondary_startup_64) |
84 | /* | 91 | /* |
@@ -98,7 +105,16 @@ ENTRY(secondary_startup_64) | |||
98 | /* Sanitize CPU configuration */ | 105 | /* Sanitize CPU configuration */ |
99 | call verify_cpu | 106 | call verify_cpu |
100 | 107 | ||
101 | movq $(init_top_pgt - __START_KERNEL_map), %rax | 108 | /* |
109 | * Retrieve the modifier (SME encryption mask if SME is active) to be | ||
110 | * added to the initial pgdir entry that will be programmed into CR3. | ||
111 | */ | ||
112 | pushq %rsi | ||
113 | call __startup_secondary_64 | ||
114 | popq %rsi | ||
115 | |||
116 | /* Form the CR3 value being sure to include the CR3 modifier */ | ||
117 | addq $(init_top_pgt - __START_KERNEL_map), %rax | ||
102 | 1: | 118 | 1: |
103 | 119 | ||
104 | /* Enable PAE mode, PGE and LA57 */ | 120 | /* Enable PAE mode, PGE and LA57 */ |
@@ -335,9 +351,9 @@ GLOBAL(name) | |||
335 | NEXT_PAGE(early_top_pgt) | 351 | NEXT_PAGE(early_top_pgt) |
336 | .fill 511,8,0 | 352 | .fill 511,8,0 |
337 | #ifdef CONFIG_X86_5LEVEL | 353 | #ifdef CONFIG_X86_5LEVEL |
338 | .quad level4_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE | 354 | .quad level4_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE_NOENC |
339 | #else | 355 | #else |
340 | .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE | 356 | .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE_NOENC |
341 | #endif | 357 | #endif |
342 | 358 | ||
343 | NEXT_PAGE(early_dynamic_pgts) | 359 | NEXT_PAGE(early_dynamic_pgts) |
@@ -350,15 +366,15 @@ NEXT_PAGE(init_top_pgt) | |||
350 | .fill 512,8,0 | 366 | .fill 512,8,0 |
351 | #else | 367 | #else |
352 | NEXT_PAGE(init_top_pgt) | 368 | NEXT_PAGE(init_top_pgt) |
353 | .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE | 369 | .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE_NOENC |
354 | .org init_top_pgt + PGD_PAGE_OFFSET*8, 0 | 370 | .org init_top_pgt + PGD_PAGE_OFFSET*8, 0 |
355 | .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE | 371 | .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE_NOENC |
356 | .org init_top_pgt + PGD_START_KERNEL*8, 0 | 372 | .org init_top_pgt + PGD_START_KERNEL*8, 0 |
357 | /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */ | 373 | /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */ |
358 | .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE | 374 | .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE_NOENC |
359 | 375 | ||
360 | NEXT_PAGE(level3_ident_pgt) | 376 | NEXT_PAGE(level3_ident_pgt) |
361 | .quad level2_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE | 377 | .quad level2_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE_NOENC |
362 | .fill 511, 8, 0 | 378 | .fill 511, 8, 0 |
363 | NEXT_PAGE(level2_ident_pgt) | 379 | NEXT_PAGE(level2_ident_pgt) |
364 | /* Since I easily can, map the first 1G. | 380 | /* Since I easily can, map the first 1G. |
@@ -370,14 +386,14 @@ NEXT_PAGE(level2_ident_pgt) | |||
370 | #ifdef CONFIG_X86_5LEVEL | 386 | #ifdef CONFIG_X86_5LEVEL |
371 | NEXT_PAGE(level4_kernel_pgt) | 387 | NEXT_PAGE(level4_kernel_pgt) |
372 | .fill 511,8,0 | 388 | .fill 511,8,0 |
373 | .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE | 389 | .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE_NOENC |
374 | #endif | 390 | #endif |
375 | 391 | ||
376 | NEXT_PAGE(level3_kernel_pgt) | 392 | NEXT_PAGE(level3_kernel_pgt) |
377 | .fill L3_START_KERNEL,8,0 | 393 | .fill L3_START_KERNEL,8,0 |
378 | /* (2^48-(2*1024*1024*1024)-((2^39)*511))/(2^30) = 510 */ | 394 | /* (2^48-(2*1024*1024*1024)-((2^39)*511))/(2^30) = 510 */ |
379 | .quad level2_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE | 395 | .quad level2_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE_NOENC |
380 | .quad level2_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE | 396 | .quad level2_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE_NOENC |
381 | 397 | ||
382 | NEXT_PAGE(level2_kernel_pgt) | 398 | NEXT_PAGE(level2_kernel_pgt) |
383 | /* | 399 | /* |
@@ -395,7 +411,7 @@ NEXT_PAGE(level2_kernel_pgt) | |||
395 | 411 | ||
396 | NEXT_PAGE(level2_fixmap_pgt) | 412 | NEXT_PAGE(level2_fixmap_pgt) |
397 | .fill 506,8,0 | 413 | .fill 506,8,0 |
398 | .quad level1_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE | 414 | .quad level1_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE_NOENC |
399 | /* 8MB reserved for vsyscalls + a 2MB hole = 4 + 1 entries */ | 415 | /* 8MB reserved for vsyscalls + a 2MB hole = 4 + 1 entries */ |
400 | .fill 5,8,0 | 416 | .fill 5,8,0 |
401 | 417 | ||
diff --git a/arch/x86/kernel/kdebugfs.c b/arch/x86/kernel/kdebugfs.c index 38b64587b31b..fd6f8fbbe6f2 100644 --- a/arch/x86/kernel/kdebugfs.c +++ b/arch/x86/kernel/kdebugfs.c | |||
@@ -33,7 +33,6 @@ static ssize_t setup_data_read(struct file *file, char __user *user_buf, | |||
33 | struct setup_data_node *node = file->private_data; | 33 | struct setup_data_node *node = file->private_data; |
34 | unsigned long remain; | 34 | unsigned long remain; |
35 | loff_t pos = *ppos; | 35 | loff_t pos = *ppos; |
36 | struct page *pg; | ||
37 | void *p; | 36 | void *p; |
38 | u64 pa; | 37 | u64 pa; |
39 | 38 | ||
@@ -47,18 +46,13 @@ static ssize_t setup_data_read(struct file *file, char __user *user_buf, | |||
47 | count = node->len - pos; | 46 | count = node->len - pos; |
48 | 47 | ||
49 | pa = node->paddr + sizeof(struct setup_data) + pos; | 48 | pa = node->paddr + sizeof(struct setup_data) + pos; |
50 | pg = pfn_to_page((pa + count - 1) >> PAGE_SHIFT); | 49 | p = memremap(pa, count, MEMREMAP_WB); |
51 | if (PageHighMem(pg)) { | 50 | if (!p) |
52 | p = ioremap_cache(pa, count); | 51 | return -ENOMEM; |
53 | if (!p) | ||
54 | return -ENXIO; | ||
55 | } else | ||
56 | p = __va(pa); | ||
57 | 52 | ||
58 | remain = copy_to_user(user_buf, p, count); | 53 | remain = copy_to_user(user_buf, p, count); |
59 | 54 | ||
60 | if (PageHighMem(pg)) | 55 | memunmap(p); |
61 | iounmap(p); | ||
62 | 56 | ||
63 | if (remain) | 57 | if (remain) |
64 | return -EFAULT; | 58 | return -EFAULT; |
@@ -109,7 +103,6 @@ static int __init create_setup_data_nodes(struct dentry *parent) | |||
109 | struct setup_data *data; | 103 | struct setup_data *data; |
110 | int error; | 104 | int error; |
111 | struct dentry *d; | 105 | struct dentry *d; |
112 | struct page *pg; | ||
113 | u64 pa_data; | 106 | u64 pa_data; |
114 | int no = 0; | 107 | int no = 0; |
115 | 108 | ||
@@ -126,16 +119,12 @@ static int __init create_setup_data_nodes(struct dentry *parent) | |||
126 | goto err_dir; | 119 | goto err_dir; |
127 | } | 120 | } |
128 | 121 | ||
129 | pg = pfn_to_page((pa_data+sizeof(*data)-1) >> PAGE_SHIFT); | 122 | data = memremap(pa_data, sizeof(*data), MEMREMAP_WB); |
130 | if (PageHighMem(pg)) { | 123 | if (!data) { |
131 | data = ioremap_cache(pa_data, sizeof(*data)); | 124 | kfree(node); |
132 | if (!data) { | 125 | error = -ENOMEM; |
133 | kfree(node); | 126 | goto err_dir; |
134 | error = -ENXIO; | 127 | } |
135 | goto err_dir; | ||
136 | } | ||
137 | } else | ||
138 | data = __va(pa_data); | ||
139 | 128 | ||
140 | node->paddr = pa_data; | 129 | node->paddr = pa_data; |
141 | node->type = data->type; | 130 | node->type = data->type; |
@@ -143,8 +132,7 @@ static int __init create_setup_data_nodes(struct dentry *parent) | |||
143 | error = create_setup_data_node(d, no, node); | 132 | error = create_setup_data_node(d, no, node); |
144 | pa_data = data->next; | 133 | pa_data = data->next; |
145 | 134 | ||
146 | if (PageHighMem(pg)) | 135 | memunmap(data); |
147 | iounmap(data); | ||
148 | if (error) | 136 | if (error) |
149 | goto err_dir; | 137 | goto err_dir; |
150 | no++; | 138 | no++; |
diff --git a/arch/x86/kernel/ksysfs.c b/arch/x86/kernel/ksysfs.c index 4afc67f5facc..4b0592ca9e47 100644 --- a/arch/x86/kernel/ksysfs.c +++ b/arch/x86/kernel/ksysfs.c | |||
@@ -16,8 +16,8 @@ | |||
16 | #include <linux/stat.h> | 16 | #include <linux/stat.h> |
17 | #include <linux/slab.h> | 17 | #include <linux/slab.h> |
18 | #include <linux/mm.h> | 18 | #include <linux/mm.h> |
19 | #include <linux/io.h> | ||
19 | 20 | ||
20 | #include <asm/io.h> | ||
21 | #include <asm/setup.h> | 21 | #include <asm/setup.h> |
22 | 22 | ||
23 | static ssize_t version_show(struct kobject *kobj, | 23 | static ssize_t version_show(struct kobject *kobj, |
@@ -55,7 +55,7 @@ static struct bin_attribute *boot_params_data_attrs[] = { | |||
55 | NULL, | 55 | NULL, |
56 | }; | 56 | }; |
57 | 57 | ||
58 | static struct attribute_group boot_params_attr_group = { | 58 | static const struct attribute_group boot_params_attr_group = { |
59 | .attrs = boot_params_version_attrs, | 59 | .attrs = boot_params_version_attrs, |
60 | .bin_attrs = boot_params_data_attrs, | 60 | .bin_attrs = boot_params_data_attrs, |
61 | }; | 61 | }; |
@@ -79,12 +79,12 @@ static int get_setup_data_paddr(int nr, u64 *paddr) | |||
79 | *paddr = pa_data; | 79 | *paddr = pa_data; |
80 | return 0; | 80 | return 0; |
81 | } | 81 | } |
82 | data = ioremap_cache(pa_data, sizeof(*data)); | 82 | data = memremap(pa_data, sizeof(*data), MEMREMAP_WB); |
83 | if (!data) | 83 | if (!data) |
84 | return -ENOMEM; | 84 | return -ENOMEM; |
85 | 85 | ||
86 | pa_data = data->next; | 86 | pa_data = data->next; |
87 | iounmap(data); | 87 | memunmap(data); |
88 | i++; | 88 | i++; |
89 | } | 89 | } |
90 | return -EINVAL; | 90 | return -EINVAL; |
@@ -97,17 +97,17 @@ static int __init get_setup_data_size(int nr, size_t *size) | |||
97 | u64 pa_data = boot_params.hdr.setup_data; | 97 | u64 pa_data = boot_params.hdr.setup_data; |
98 | 98 | ||
99 | while (pa_data) { | 99 | while (pa_data) { |
100 | data = ioremap_cache(pa_data, sizeof(*data)); | 100 | data = memremap(pa_data, sizeof(*data), MEMREMAP_WB); |
101 | if (!data) | 101 | if (!data) |
102 | return -ENOMEM; | 102 | return -ENOMEM; |
103 | if (nr == i) { | 103 | if (nr == i) { |
104 | *size = data->len; | 104 | *size = data->len; |
105 | iounmap(data); | 105 | memunmap(data); |
106 | return 0; | 106 | return 0; |
107 | } | 107 | } |
108 | 108 | ||
109 | pa_data = data->next; | 109 | pa_data = data->next; |
110 | iounmap(data); | 110 | memunmap(data); |
111 | i++; | 111 | i++; |
112 | } | 112 | } |
113 | return -EINVAL; | 113 | return -EINVAL; |
@@ -127,12 +127,12 @@ static ssize_t type_show(struct kobject *kobj, | |||
127 | ret = get_setup_data_paddr(nr, &paddr); | 127 | ret = get_setup_data_paddr(nr, &paddr); |
128 | if (ret) | 128 | if (ret) |
129 | return ret; | 129 | return ret; |
130 | data = ioremap_cache(paddr, sizeof(*data)); | 130 | data = memremap(paddr, sizeof(*data), MEMREMAP_WB); |
131 | if (!data) | 131 | if (!data) |
132 | return -ENOMEM; | 132 | return -ENOMEM; |
133 | 133 | ||
134 | ret = sprintf(buf, "0x%x\n", data->type); | 134 | ret = sprintf(buf, "0x%x\n", data->type); |
135 | iounmap(data); | 135 | memunmap(data); |
136 | return ret; | 136 | return ret; |
137 | } | 137 | } |
138 | 138 | ||
@@ -154,7 +154,7 @@ static ssize_t setup_data_data_read(struct file *fp, | |||
154 | ret = get_setup_data_paddr(nr, &paddr); | 154 | ret = get_setup_data_paddr(nr, &paddr); |
155 | if (ret) | 155 | if (ret) |
156 | return ret; | 156 | return ret; |
157 | data = ioremap_cache(paddr, sizeof(*data)); | 157 | data = memremap(paddr, sizeof(*data), MEMREMAP_WB); |
158 | if (!data) | 158 | if (!data) |
159 | return -ENOMEM; | 159 | return -ENOMEM; |
160 | 160 | ||
@@ -170,15 +170,15 @@ static ssize_t setup_data_data_read(struct file *fp, | |||
170 | goto out; | 170 | goto out; |
171 | 171 | ||
172 | ret = count; | 172 | ret = count; |
173 | p = ioremap_cache(paddr + sizeof(*data), data->len); | 173 | p = memremap(paddr + sizeof(*data), data->len, MEMREMAP_WB); |
174 | if (!p) { | 174 | if (!p) { |
175 | ret = -ENOMEM; | 175 | ret = -ENOMEM; |
176 | goto out; | 176 | goto out; |
177 | } | 177 | } |
178 | memcpy(buf, p + off, count); | 178 | memcpy(buf, p + off, count); |
179 | iounmap(p); | 179 | memunmap(p); |
180 | out: | 180 | out: |
181 | iounmap(data); | 181 | memunmap(data); |
182 | return ret; | 182 | return ret; |
183 | } | 183 | } |
184 | 184 | ||
@@ -202,7 +202,7 @@ static struct bin_attribute *setup_data_data_attrs[] = { | |||
202 | NULL, | 202 | NULL, |
203 | }; | 203 | }; |
204 | 204 | ||
205 | static struct attribute_group setup_data_attr_group = { | 205 | static const struct attribute_group setup_data_attr_group = { |
206 | .attrs = setup_data_type_attrs, | 206 | .attrs = setup_data_type_attrs, |
207 | .bin_attrs = setup_data_data_attrs, | 207 | .bin_attrs = setup_data_data_attrs, |
208 | }; | 208 | }; |
@@ -250,13 +250,13 @@ static int __init get_setup_data_total_num(u64 pa_data, int *nr) | |||
250 | *nr = 0; | 250 | *nr = 0; |
251 | while (pa_data) { | 251 | while (pa_data) { |
252 | *nr += 1; | 252 | *nr += 1; |
253 | data = ioremap_cache(pa_data, sizeof(*data)); | 253 | data = memremap(pa_data, sizeof(*data), MEMREMAP_WB); |
254 | if (!data) { | 254 | if (!data) { |
255 | ret = -ENOMEM; | 255 | ret = -ENOMEM; |
256 | goto out; | 256 | goto out; |
257 | } | 257 | } |
258 | pa_data = data->next; | 258 | pa_data = data->next; |
259 | iounmap(data); | 259 | memunmap(data); |
260 | } | 260 | } |
261 | 261 | ||
262 | out: | 262 | out: |
diff --git a/arch/x86/kernel/machine_kexec_64.c b/arch/x86/kernel/machine_kexec_64.c index cb0a30473c23..1f790cf9d38f 100644 --- a/arch/x86/kernel/machine_kexec_64.c +++ b/arch/x86/kernel/machine_kexec_64.c | |||
@@ -87,7 +87,7 @@ static int init_transition_pgtable(struct kimage *image, pgd_t *pgd) | |||
87 | set_pmd(pmd, __pmd(__pa(pte) | _KERNPG_TABLE)); | 87 | set_pmd(pmd, __pmd(__pa(pte) | _KERNPG_TABLE)); |
88 | } | 88 | } |
89 | pte = pte_offset_kernel(pmd, vaddr); | 89 | pte = pte_offset_kernel(pmd, vaddr); |
90 | set_pte(pte, pfn_pte(paddr >> PAGE_SHIFT, PAGE_KERNEL_EXEC)); | 90 | set_pte(pte, pfn_pte(paddr >> PAGE_SHIFT, PAGE_KERNEL_EXEC_NOENC)); |
91 | return 0; | 91 | return 0; |
92 | err: | 92 | err: |
93 | free_transition_pgtable(image); | 93 | free_transition_pgtable(image); |
@@ -115,6 +115,7 @@ static int init_pgtable(struct kimage *image, unsigned long start_pgtable) | |||
115 | .alloc_pgt_page = alloc_pgt_page, | 115 | .alloc_pgt_page = alloc_pgt_page, |
116 | .context = image, | 116 | .context = image, |
117 | .page_flag = __PAGE_KERNEL_LARGE_EXEC, | 117 | .page_flag = __PAGE_KERNEL_LARGE_EXEC, |
118 | .kernpg_flag = _KERNPG_TABLE_NOENC, | ||
118 | }; | 119 | }; |
119 | unsigned long mstart, mend; | 120 | unsigned long mstart, mend; |
120 | pgd_t *level4p; | 121 | pgd_t *level4p; |
@@ -334,7 +335,8 @@ void machine_kexec(struct kimage *image) | |||
334 | image->start = relocate_kernel((unsigned long)image->head, | 335 | image->start = relocate_kernel((unsigned long)image->head, |
335 | (unsigned long)page_list, | 336 | (unsigned long)page_list, |
336 | image->start, | 337 | image->start, |
337 | image->preserve_context); | 338 | image->preserve_context, |
339 | sme_active()); | ||
338 | 340 | ||
339 | #ifdef CONFIG_KEXEC_JUMP | 341 | #ifdef CONFIG_KEXEC_JUMP |
340 | if (image->preserve_context) | 342 | if (image->preserve_context) |
@@ -602,3 +604,22 @@ void arch_kexec_unprotect_crashkres(void) | |||
602 | { | 604 | { |
603 | kexec_mark_crashkres(false); | 605 | kexec_mark_crashkres(false); |
604 | } | 606 | } |
607 | |||
608 | int arch_kexec_post_alloc_pages(void *vaddr, unsigned int pages, gfp_t gfp) | ||
609 | { | ||
610 | /* | ||
611 | * If SME is active we need to be sure that kexec pages are | ||
612 | * not encrypted because when we boot to the new kernel the | ||
613 | * pages won't be accessed encrypted (initially). | ||
614 | */ | ||
615 | return set_memory_decrypted((unsigned long)vaddr, pages); | ||
616 | } | ||
617 | |||
618 | void arch_kexec_pre_free_pages(void *vaddr, unsigned int pages) | ||
619 | { | ||
620 | /* | ||
621 | * If SME is active we need to reset the pages back to being | ||
622 | * an encrypted mapping before freeing them. | ||
623 | */ | ||
624 | set_memory_encrypted((unsigned long)vaddr, pages); | ||
625 | } | ||
diff --git a/arch/x86/kernel/mpparse.c b/arch/x86/kernel/mpparse.c index 0d904d759ff1..5cbb3177ed17 100644 --- a/arch/x86/kernel/mpparse.c +++ b/arch/x86/kernel/mpparse.c | |||
@@ -429,16 +429,16 @@ static inline void __init construct_default_ISA_mptable(int mpc_default_type) | |||
429 | } | 429 | } |
430 | } | 430 | } |
431 | 431 | ||
432 | static struct mpf_intel *mpf_found; | 432 | static unsigned long mpf_base; |
433 | 433 | ||
434 | static unsigned long __init get_mpc_size(unsigned long physptr) | 434 | static unsigned long __init get_mpc_size(unsigned long physptr) |
435 | { | 435 | { |
436 | struct mpc_table *mpc; | 436 | struct mpc_table *mpc; |
437 | unsigned long size; | 437 | unsigned long size; |
438 | 438 | ||
439 | mpc = early_ioremap(physptr, PAGE_SIZE); | 439 | mpc = early_memremap(physptr, PAGE_SIZE); |
440 | size = mpc->length; | 440 | size = mpc->length; |
441 | early_iounmap(mpc, PAGE_SIZE); | 441 | early_memunmap(mpc, PAGE_SIZE); |
442 | apic_printk(APIC_VERBOSE, " mpc: %lx-%lx\n", physptr, physptr + size); | 442 | apic_printk(APIC_VERBOSE, " mpc: %lx-%lx\n", physptr, physptr + size); |
443 | 443 | ||
444 | return size; | 444 | return size; |
@@ -450,7 +450,8 @@ static int __init check_physptr(struct mpf_intel *mpf, unsigned int early) | |||
450 | unsigned long size; | 450 | unsigned long size; |
451 | 451 | ||
452 | size = get_mpc_size(mpf->physptr); | 452 | size = get_mpc_size(mpf->physptr); |
453 | mpc = early_ioremap(mpf->physptr, size); | 453 | mpc = early_memremap(mpf->physptr, size); |
454 | |||
454 | /* | 455 | /* |
455 | * Read the physical hardware table. Anything here will | 456 | * Read the physical hardware table. Anything here will |
456 | * override the defaults. | 457 | * override the defaults. |
@@ -461,10 +462,10 @@ static int __init check_physptr(struct mpf_intel *mpf, unsigned int early) | |||
461 | #endif | 462 | #endif |
462 | pr_err("BIOS bug, MP table errors detected!...\n"); | 463 | pr_err("BIOS bug, MP table errors detected!...\n"); |
463 | pr_cont("... disabling SMP support. (tell your hw vendor)\n"); | 464 | pr_cont("... disabling SMP support. (tell your hw vendor)\n"); |
464 | early_iounmap(mpc, size); | 465 | early_memunmap(mpc, size); |
465 | return -1; | 466 | return -1; |
466 | } | 467 | } |
467 | early_iounmap(mpc, size); | 468 | early_memunmap(mpc, size); |
468 | 469 | ||
469 | if (early) | 470 | if (early) |
470 | return -1; | 471 | return -1; |
@@ -497,12 +498,12 @@ static int __init check_physptr(struct mpf_intel *mpf, unsigned int early) | |||
497 | */ | 498 | */ |
498 | void __init default_get_smp_config(unsigned int early) | 499 | void __init default_get_smp_config(unsigned int early) |
499 | { | 500 | { |
500 | struct mpf_intel *mpf = mpf_found; | 501 | struct mpf_intel *mpf; |
501 | 502 | ||
502 | if (!smp_found_config) | 503 | if (!smp_found_config) |
503 | return; | 504 | return; |
504 | 505 | ||
505 | if (!mpf) | 506 | if (!mpf_base) |
506 | return; | 507 | return; |
507 | 508 | ||
508 | if (acpi_lapic && early) | 509 | if (acpi_lapic && early) |
@@ -515,6 +516,12 @@ void __init default_get_smp_config(unsigned int early) | |||
515 | if (acpi_lapic && acpi_ioapic) | 516 | if (acpi_lapic && acpi_ioapic) |
516 | return; | 517 | return; |
517 | 518 | ||
519 | mpf = early_memremap(mpf_base, sizeof(*mpf)); | ||
520 | if (!mpf) { | ||
521 | pr_err("MPTABLE: error mapping MP table\n"); | ||
522 | return; | ||
523 | } | ||
524 | |||
518 | pr_info("Intel MultiProcessor Specification v1.%d\n", | 525 | pr_info("Intel MultiProcessor Specification v1.%d\n", |
519 | mpf->specification); | 526 | mpf->specification); |
520 | #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86_32) | 527 | #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86_32) |
@@ -529,7 +536,7 @@ void __init default_get_smp_config(unsigned int early) | |||
529 | /* | 536 | /* |
530 | * Now see if we need to read further. | 537 | * Now see if we need to read further. |
531 | */ | 538 | */ |
532 | if (mpf->feature1 != 0) { | 539 | if (mpf->feature1) { |
533 | if (early) { | 540 | if (early) { |
534 | /* | 541 | /* |
535 | * local APIC has default address | 542 | * local APIC has default address |
@@ -542,8 +549,10 @@ void __init default_get_smp_config(unsigned int early) | |||
542 | construct_default_ISA_mptable(mpf->feature1); | 549 | construct_default_ISA_mptable(mpf->feature1); |
543 | 550 | ||
544 | } else if (mpf->physptr) { | 551 | } else if (mpf->physptr) { |
545 | if (check_physptr(mpf, early)) | 552 | if (check_physptr(mpf, early)) { |
553 | early_memunmap(mpf, sizeof(*mpf)); | ||
546 | return; | 554 | return; |
555 | } | ||
547 | } else | 556 | } else |
548 | BUG(); | 557 | BUG(); |
549 | 558 | ||
@@ -552,6 +561,8 @@ void __init default_get_smp_config(unsigned int early) | |||
552 | /* | 561 | /* |
553 | * Only use the first configuration found. | 562 | * Only use the first configuration found. |
554 | */ | 563 | */ |
564 | |||
565 | early_memunmap(mpf, sizeof(*mpf)); | ||
555 | } | 566 | } |
556 | 567 | ||
557 | static void __init smp_reserve_memory(struct mpf_intel *mpf) | 568 | static void __init smp_reserve_memory(struct mpf_intel *mpf) |
@@ -561,15 +572,16 @@ static void __init smp_reserve_memory(struct mpf_intel *mpf) | |||
561 | 572 | ||
562 | static int __init smp_scan_config(unsigned long base, unsigned long length) | 573 | static int __init smp_scan_config(unsigned long base, unsigned long length) |
563 | { | 574 | { |
564 | unsigned int *bp = phys_to_virt(base); | 575 | unsigned int *bp; |
565 | struct mpf_intel *mpf; | 576 | struct mpf_intel *mpf; |
566 | unsigned long mem; | 577 | int ret = 0; |
567 | 578 | ||
568 | apic_printk(APIC_VERBOSE, "Scan for SMP in [mem %#010lx-%#010lx]\n", | 579 | apic_printk(APIC_VERBOSE, "Scan for SMP in [mem %#010lx-%#010lx]\n", |
569 | base, base + length - 1); | 580 | base, base + length - 1); |
570 | BUILD_BUG_ON(sizeof(*mpf) != 16); | 581 | BUILD_BUG_ON(sizeof(*mpf) != 16); |
571 | 582 | ||
572 | while (length > 0) { | 583 | while (length > 0) { |
584 | bp = early_memremap(base, length); | ||
573 | mpf = (struct mpf_intel *)bp; | 585 | mpf = (struct mpf_intel *)bp; |
574 | if ((*bp == SMP_MAGIC_IDENT) && | 586 | if ((*bp == SMP_MAGIC_IDENT) && |
575 | (mpf->length == 1) && | 587 | (mpf->length == 1) && |
@@ -579,24 +591,26 @@ static int __init smp_scan_config(unsigned long base, unsigned long length) | |||
579 | #ifdef CONFIG_X86_LOCAL_APIC | 591 | #ifdef CONFIG_X86_LOCAL_APIC |
580 | smp_found_config = 1; | 592 | smp_found_config = 1; |
581 | #endif | 593 | #endif |
582 | mpf_found = mpf; | 594 | mpf_base = base; |
583 | 595 | ||
584 | pr_info("found SMP MP-table at [mem %#010llx-%#010llx] mapped at [%p]\n", | 596 | pr_info("found SMP MP-table at [mem %#010lx-%#010lx] mapped at [%p]\n", |
585 | (unsigned long long) virt_to_phys(mpf), | 597 | base, base + sizeof(*mpf) - 1, mpf); |
586 | (unsigned long long) virt_to_phys(mpf) + | ||
587 | sizeof(*mpf) - 1, mpf); | ||
588 | 598 | ||
589 | mem = virt_to_phys(mpf); | 599 | memblock_reserve(base, sizeof(*mpf)); |
590 | memblock_reserve(mem, sizeof(*mpf)); | ||
591 | if (mpf->physptr) | 600 | if (mpf->physptr) |
592 | smp_reserve_memory(mpf); | 601 | smp_reserve_memory(mpf); |
593 | 602 | ||
594 | return 1; | 603 | ret = 1; |
595 | } | 604 | } |
596 | bp += 4; | 605 | early_memunmap(bp, length); |
606 | |||
607 | if (ret) | ||
608 | break; | ||
609 | |||
610 | base += 16; | ||
597 | length -= 16; | 611 | length -= 16; |
598 | } | 612 | } |
599 | return 0; | 613 | return ret; |
600 | } | 614 | } |
601 | 615 | ||
602 | void __init default_find_smp_config(void) | 616 | void __init default_find_smp_config(void) |
@@ -838,29 +852,40 @@ static int __init update_mp_table(void) | |||
838 | char oem[10]; | 852 | char oem[10]; |
839 | struct mpf_intel *mpf; | 853 | struct mpf_intel *mpf; |
840 | struct mpc_table *mpc, *mpc_new; | 854 | struct mpc_table *mpc, *mpc_new; |
855 | unsigned long size; | ||
841 | 856 | ||
842 | if (!enable_update_mptable) | 857 | if (!enable_update_mptable) |
843 | return 0; | 858 | return 0; |
844 | 859 | ||
845 | mpf = mpf_found; | 860 | if (!mpf_base) |
846 | if (!mpf) | ||
847 | return 0; | 861 | return 0; |
848 | 862 | ||
863 | mpf = early_memremap(mpf_base, sizeof(*mpf)); | ||
864 | if (!mpf) { | ||
865 | pr_err("MPTABLE: mpf early_memremap() failed\n"); | ||
866 | return 0; | ||
867 | } | ||
868 | |||
849 | /* | 869 | /* |
850 | * Now see if we need to go further. | 870 | * Now see if we need to go further. |
851 | */ | 871 | */ |
852 | if (mpf->feature1 != 0) | 872 | if (mpf->feature1) |
853 | return 0; | 873 | goto do_unmap_mpf; |
854 | 874 | ||
855 | if (!mpf->physptr) | 875 | if (!mpf->physptr) |
856 | return 0; | 876 | goto do_unmap_mpf; |
857 | 877 | ||
858 | mpc = phys_to_virt(mpf->physptr); | 878 | size = get_mpc_size(mpf->physptr); |
879 | mpc = early_memremap(mpf->physptr, size); | ||
880 | if (!mpc) { | ||
881 | pr_err("MPTABLE: mpc early_memremap() failed\n"); | ||
882 | goto do_unmap_mpf; | ||
883 | } | ||
859 | 884 | ||
860 | if (!smp_check_mpc(mpc, oem, str)) | 885 | if (!smp_check_mpc(mpc, oem, str)) |
861 | return 0; | 886 | goto do_unmap_mpc; |
862 | 887 | ||
863 | pr_info("mpf: %llx\n", (u64)virt_to_phys(mpf)); | 888 | pr_info("mpf: %llx\n", (u64)mpf_base); |
864 | pr_info("physptr: %x\n", mpf->physptr); | 889 | pr_info("physptr: %x\n", mpf->physptr); |
865 | 890 | ||
866 | if (mpc_new_phys && mpc->length > mpc_new_length) { | 891 | if (mpc_new_phys && mpc->length > mpc_new_length) { |
@@ -878,21 +903,32 @@ static int __init update_mp_table(void) | |||
878 | new = mpf_checksum((unsigned char *)mpc, mpc->length); | 903 | new = mpf_checksum((unsigned char *)mpc, mpc->length); |
879 | if (old == new) { | 904 | if (old == new) { |
880 | pr_info("mpc is readonly, please try alloc_mptable instead\n"); | 905 | pr_info("mpc is readonly, please try alloc_mptable instead\n"); |
881 | return 0; | 906 | goto do_unmap_mpc; |
882 | } | 907 | } |
883 | pr_info("use in-position replacing\n"); | 908 | pr_info("use in-position replacing\n"); |
884 | } else { | 909 | } else { |
910 | mpc_new = early_memremap(mpc_new_phys, mpc_new_length); | ||
911 | if (!mpc_new) { | ||
912 | pr_err("MPTABLE: new mpc early_memremap() failed\n"); | ||
913 | goto do_unmap_mpc; | ||
914 | } | ||
885 | mpf->physptr = mpc_new_phys; | 915 | mpf->physptr = mpc_new_phys; |
886 | mpc_new = phys_to_virt(mpc_new_phys); | ||
887 | memcpy(mpc_new, mpc, mpc->length); | 916 | memcpy(mpc_new, mpc, mpc->length); |
917 | early_memunmap(mpc, size); | ||
888 | mpc = mpc_new; | 918 | mpc = mpc_new; |
919 | size = mpc_new_length; | ||
889 | /* check if we can modify that */ | 920 | /* check if we can modify that */ |
890 | if (mpc_new_phys - mpf->physptr) { | 921 | if (mpc_new_phys - mpf->physptr) { |
891 | struct mpf_intel *mpf_new; | 922 | struct mpf_intel *mpf_new; |
892 | /* steal 16 bytes from [0, 1k) */ | 923 | /* steal 16 bytes from [0, 1k) */ |
924 | mpf_new = early_memremap(0x400 - 16, sizeof(*mpf_new)); | ||
925 | if (!mpf_new) { | ||
926 | pr_err("MPTABLE: new mpf early_memremap() failed\n"); | ||
927 | goto do_unmap_mpc; | ||
928 | } | ||
893 | pr_info("mpf new: %x\n", 0x400 - 16); | 929 | pr_info("mpf new: %x\n", 0x400 - 16); |
894 | mpf_new = phys_to_virt(0x400 - 16); | ||
895 | memcpy(mpf_new, mpf, 16); | 930 | memcpy(mpf_new, mpf, 16); |
931 | early_memunmap(mpf, sizeof(*mpf)); | ||
896 | mpf = mpf_new; | 932 | mpf = mpf_new; |
897 | mpf->physptr = mpc_new_phys; | 933 | mpf->physptr = mpc_new_phys; |
898 | } | 934 | } |
@@ -909,6 +945,12 @@ static int __init update_mp_table(void) | |||
909 | */ | 945 | */ |
910 | replace_intsrc_all(mpc, mpc_new_phys, mpc_new_length); | 946 | replace_intsrc_all(mpc, mpc_new_phys, mpc_new_length); |
911 | 947 | ||
948 | do_unmap_mpc: | ||
949 | early_memunmap(mpc, size); | ||
950 | |||
951 | do_unmap_mpf: | ||
952 | early_memunmap(mpf, sizeof(*mpf)); | ||
953 | |||
912 | return 0; | 954 | return 0; |
913 | } | 955 | } |
914 | 956 | ||
diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c index 5e16d3f29594..0accc2404b92 100644 --- a/arch/x86/kernel/pci-dma.c +++ b/arch/x86/kernel/pci-dma.c | |||
@@ -93,9 +93,12 @@ again: | |||
93 | if (gfpflags_allow_blocking(flag)) { | 93 | if (gfpflags_allow_blocking(flag)) { |
94 | page = dma_alloc_from_contiguous(dev, count, get_order(size), | 94 | page = dma_alloc_from_contiguous(dev, count, get_order(size), |
95 | flag); | 95 | flag); |
96 | if (page && page_to_phys(page) + size > dma_mask) { | 96 | if (page) { |
97 | dma_release_from_contiguous(dev, page, count); | 97 | addr = phys_to_dma(dev, page_to_phys(page)); |
98 | page = NULL; | 98 | if (addr + size > dma_mask) { |
99 | dma_release_from_contiguous(dev, page, count); | ||
100 | page = NULL; | ||
101 | } | ||
99 | } | 102 | } |
100 | } | 103 | } |
101 | /* fallback */ | 104 | /* fallback */ |
@@ -104,7 +107,7 @@ again: | |||
104 | if (!page) | 107 | if (!page) |
105 | return NULL; | 108 | return NULL; |
106 | 109 | ||
107 | addr = page_to_phys(page); | 110 | addr = phys_to_dma(dev, page_to_phys(page)); |
108 | if (addr + size > dma_mask) { | 111 | if (addr + size > dma_mask) { |
109 | __free_pages(page, get_order(size)); | 112 | __free_pages(page, get_order(size)); |
110 | 113 | ||
diff --git a/arch/x86/kernel/pci-nommu.c b/arch/x86/kernel/pci-nommu.c index a6d404087fe3..4fc3cb60ea11 100644 --- a/arch/x86/kernel/pci-nommu.c +++ b/arch/x86/kernel/pci-nommu.c | |||
@@ -32,7 +32,7 @@ static dma_addr_t nommu_map_page(struct device *dev, struct page *page, | |||
32 | enum dma_data_direction dir, | 32 | enum dma_data_direction dir, |
33 | unsigned long attrs) | 33 | unsigned long attrs) |
34 | { | 34 | { |
35 | dma_addr_t bus = page_to_phys(page) + offset; | 35 | dma_addr_t bus = phys_to_dma(dev, page_to_phys(page)) + offset; |
36 | WARN_ON(size == 0); | 36 | WARN_ON(size == 0); |
37 | if (!check_addr("map_single", dev, bus, size)) | 37 | if (!check_addr("map_single", dev, bus, size)) |
38 | return NOMMU_MAPPING_ERROR; | 38 | return NOMMU_MAPPING_ERROR; |
diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c index 1e23577e17cf..677077510e30 100644 --- a/arch/x86/kernel/pci-swiotlb.c +++ b/arch/x86/kernel/pci-swiotlb.c | |||
@@ -6,12 +6,14 @@ | |||
6 | #include <linux/swiotlb.h> | 6 | #include <linux/swiotlb.h> |
7 | #include <linux/bootmem.h> | 7 | #include <linux/bootmem.h> |
8 | #include <linux/dma-mapping.h> | 8 | #include <linux/dma-mapping.h> |
9 | #include <linux/mem_encrypt.h> | ||
9 | 10 | ||
10 | #include <asm/iommu.h> | 11 | #include <asm/iommu.h> |
11 | #include <asm/swiotlb.h> | 12 | #include <asm/swiotlb.h> |
12 | #include <asm/dma.h> | 13 | #include <asm/dma.h> |
13 | #include <asm/xen/swiotlb-xen.h> | 14 | #include <asm/xen/swiotlb-xen.h> |
14 | #include <asm/iommu_table.h> | 15 | #include <asm/iommu_table.h> |
16 | |||
15 | int swiotlb __read_mostly; | 17 | int swiotlb __read_mostly; |
16 | 18 | ||
17 | void *x86_swiotlb_alloc_coherent(struct device *hwdev, size_t size, | 19 | void *x86_swiotlb_alloc_coherent(struct device *hwdev, size_t size, |
@@ -79,8 +81,8 @@ IOMMU_INIT_FINISH(pci_swiotlb_detect_override, | |||
79 | pci_swiotlb_late_init); | 81 | pci_swiotlb_late_init); |
80 | 82 | ||
81 | /* | 83 | /* |
82 | * if 4GB or more detected (and iommu=off not set) return 1 | 84 | * If 4GB or more detected (and iommu=off not set) or if SME is active |
83 | * and set swiotlb to 1. | 85 | * then set swiotlb to 1 and return 1. |
84 | */ | 86 | */ |
85 | int __init pci_swiotlb_detect_4gb(void) | 87 | int __init pci_swiotlb_detect_4gb(void) |
86 | { | 88 | { |
@@ -89,6 +91,15 @@ int __init pci_swiotlb_detect_4gb(void) | |||
89 | if (!no_iommu && max_possible_pfn > MAX_DMA32_PFN) | 91 | if (!no_iommu && max_possible_pfn > MAX_DMA32_PFN) |
90 | swiotlb = 1; | 92 | swiotlb = 1; |
91 | #endif | 93 | #endif |
94 | |||
95 | /* | ||
96 | * If SME is active then swiotlb will be set to 1 so that bounce | ||
97 | * buffers are allocated and used for devices that do not support | ||
98 | * the addressing range required for the encryption mask. | ||
99 | */ | ||
100 | if (sme_active()) | ||
101 | swiotlb = 1; | ||
102 | |||
92 | return swiotlb; | 103 | return swiotlb; |
93 | } | 104 | } |
94 | IOMMU_INIT(pci_swiotlb_detect_4gb, | 105 | IOMMU_INIT(pci_swiotlb_detect_4gb, |
diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c index 3ca198080ea9..bd6b85fac666 100644 --- a/arch/x86/kernel/process.c +++ b/arch/x86/kernel/process.c | |||
@@ -355,6 +355,7 @@ bool xen_set_default_idle(void) | |||
355 | return ret; | 355 | return ret; |
356 | } | 356 | } |
357 | #endif | 357 | #endif |
358 | |||
358 | void stop_this_cpu(void *dummy) | 359 | void stop_this_cpu(void *dummy) |
359 | { | 360 | { |
360 | local_irq_disable(); | 361 | local_irq_disable(); |
@@ -365,8 +366,20 @@ void stop_this_cpu(void *dummy) | |||
365 | disable_local_APIC(); | 366 | disable_local_APIC(); |
366 | mcheck_cpu_clear(this_cpu_ptr(&cpu_info)); | 367 | mcheck_cpu_clear(this_cpu_ptr(&cpu_info)); |
367 | 368 | ||
368 | for (;;) | 369 | for (;;) { |
369 | halt(); | 370 | /* |
371 | * Use wbinvd followed by hlt to stop the processor. This | ||
372 | * provides support for kexec on a processor that supports | ||
373 | * SME. With kexec, going from SME inactive to SME active | ||
374 | * requires clearing cache entries so that addresses without | ||
375 | * the encryption bit set don't corrupt the same physical | ||
376 | * address that has the encryption bit set when caches are | ||
377 | * flushed. To achieve this a wbinvd is performed followed by | ||
378 | * a hlt. Even if the processor is not in the kexec/SME | ||
379 | * scenario this only adds a wbinvd to a halting processor. | ||
380 | */ | ||
381 | asm volatile("wbinvd; hlt" : : : "memory"); | ||
382 | } | ||
370 | } | 383 | } |
371 | 384 | ||
372 | /* | 385 | /* |
diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocate_kernel_64.S index 98111b38ebfd..307d3bac5f04 100644 --- a/arch/x86/kernel/relocate_kernel_64.S +++ b/arch/x86/kernel/relocate_kernel_64.S | |||
@@ -47,6 +47,7 @@ relocate_kernel: | |||
47 | * %rsi page_list | 47 | * %rsi page_list |
48 | * %rdx start address | 48 | * %rdx start address |
49 | * %rcx preserve_context | 49 | * %rcx preserve_context |
50 | * %r8 sme_active | ||
50 | */ | 51 | */ |
51 | 52 | ||
52 | /* Save the CPU context, used for jumping back */ | 53 | /* Save the CPU context, used for jumping back */ |
@@ -71,6 +72,9 @@ relocate_kernel: | |||
71 | pushq $0 | 72 | pushq $0 |
72 | popfq | 73 | popfq |
73 | 74 | ||
75 | /* Save SME active flag */ | ||
76 | movq %r8, %r12 | ||
77 | |||
74 | /* | 78 | /* |
75 | * get physical address of control page now | 79 | * get physical address of control page now |
76 | * this is impossible after page table switch | 80 | * this is impossible after page table switch |
@@ -132,6 +136,16 @@ identity_mapped: | |||
132 | /* Flush the TLB (needed?) */ | 136 | /* Flush the TLB (needed?) */ |
133 | movq %r9, %cr3 | 137 | movq %r9, %cr3 |
134 | 138 | ||
139 | /* | ||
140 | * If SME is active, there could be old encrypted cache line | ||
141 | * entries that will conflict with the now unencrypted memory | ||
142 | * used by kexec. Flush the caches before copying the kernel. | ||
143 | */ | ||
144 | testq %r12, %r12 | ||
145 | jz 1f | ||
146 | wbinvd | ||
147 | 1: | ||
148 | |||
135 | movq %rcx, %r11 | 149 | movq %rcx, %r11 |
136 | call swap_pages | 150 | call swap_pages |
137 | 151 | ||
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index 3486d0498800..0bfe0c1628f6 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c | |||
@@ -69,6 +69,7 @@ | |||
69 | #include <linux/crash_dump.h> | 69 | #include <linux/crash_dump.h> |
70 | #include <linux/tboot.h> | 70 | #include <linux/tboot.h> |
71 | #include <linux/jiffies.h> | 71 | #include <linux/jiffies.h> |
72 | #include <linux/mem_encrypt.h> | ||
72 | 73 | ||
73 | #include <linux/usb/xhci-dbgp.h> | 74 | #include <linux/usb/xhci-dbgp.h> |
74 | #include <video/edid.h> | 75 | #include <video/edid.h> |
@@ -374,6 +375,14 @@ static void __init reserve_initrd(void) | |||
374 | !ramdisk_image || !ramdisk_size) | 375 | !ramdisk_image || !ramdisk_size) |
375 | return; /* No initrd provided by bootloader */ | 376 | return; /* No initrd provided by bootloader */ |
376 | 377 | ||
378 | /* | ||
379 | * If SME is active, this memory will be marked encrypted by the | ||
380 | * kernel when it is accessed (including relocation). However, the | ||
381 | * ramdisk image was loaded decrypted by the bootloader, so make | ||
382 | * sure that it is encrypted before accessing it. | ||
383 | */ | ||
384 | sme_early_encrypt(ramdisk_image, ramdisk_end - ramdisk_image); | ||
385 | |||
377 | initrd_start = 0; | 386 | initrd_start = 0; |
378 | 387 | ||
379 | mapped_size = memblock_mem_size(max_pfn_mapped); | 388 | mapped_size = memblock_mem_size(max_pfn_mapped); |
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c index b474c8de7fba..54b9e89d4d6b 100644 --- a/arch/x86/kernel/smpboot.c +++ b/arch/x86/kernel/smpboot.c | |||
@@ -971,7 +971,8 @@ void common_cpu_up(unsigned int cpu, struct task_struct *idle) | |||
971 | * Returns zero if CPU booted OK, else error code from | 971 | * Returns zero if CPU booted OK, else error code from |
972 | * ->wakeup_secondary_cpu. | 972 | * ->wakeup_secondary_cpu. |
973 | */ | 973 | */ |
974 | static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle) | 974 | static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle, |
975 | int *cpu0_nmi_registered) | ||
975 | { | 976 | { |
976 | volatile u32 *trampoline_status = | 977 | volatile u32 *trampoline_status = |
977 | (volatile u32 *) __va(real_mode_header->trampoline_status); | 978 | (volatile u32 *) __va(real_mode_header->trampoline_status); |
@@ -979,7 +980,6 @@ static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle) | |||
979 | unsigned long start_ip = real_mode_header->trampoline_start; | 980 | unsigned long start_ip = real_mode_header->trampoline_start; |
980 | 981 | ||
981 | unsigned long boot_error = 0; | 982 | unsigned long boot_error = 0; |
982 | int cpu0_nmi_registered = 0; | ||
983 | unsigned long timeout; | 983 | unsigned long timeout; |
984 | 984 | ||
985 | idle->thread.sp = (unsigned long)task_pt_regs(idle); | 985 | idle->thread.sp = (unsigned long)task_pt_regs(idle); |
@@ -1035,7 +1035,7 @@ static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle) | |||
1035 | boot_error = apic->wakeup_secondary_cpu(apicid, start_ip); | 1035 | boot_error = apic->wakeup_secondary_cpu(apicid, start_ip); |
1036 | else | 1036 | else |
1037 | boot_error = wakeup_cpu_via_init_nmi(cpu, start_ip, apicid, | 1037 | boot_error = wakeup_cpu_via_init_nmi(cpu, start_ip, apicid, |
1038 | &cpu0_nmi_registered); | 1038 | cpu0_nmi_registered); |
1039 | 1039 | ||
1040 | if (!boot_error) { | 1040 | if (!boot_error) { |
1041 | /* | 1041 | /* |
@@ -1080,12 +1080,6 @@ static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle) | |||
1080 | */ | 1080 | */ |
1081 | smpboot_restore_warm_reset_vector(); | 1081 | smpboot_restore_warm_reset_vector(); |
1082 | } | 1082 | } |
1083 | /* | ||
1084 | * Clean up the nmi handler. Do this after the callin and callout sync | ||
1085 | * to avoid impact of possible long unregister time. | ||
1086 | */ | ||
1087 | if (cpu0_nmi_registered) | ||
1088 | unregister_nmi_handler(NMI_LOCAL, "wake_cpu0"); | ||
1089 | 1083 | ||
1090 | return boot_error; | 1084 | return boot_error; |
1091 | } | 1085 | } |
@@ -1093,8 +1087,9 @@ static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle) | |||
1093 | int native_cpu_up(unsigned int cpu, struct task_struct *tidle) | 1087 | int native_cpu_up(unsigned int cpu, struct task_struct *tidle) |
1094 | { | 1088 | { |
1095 | int apicid = apic->cpu_present_to_apicid(cpu); | 1089 | int apicid = apic->cpu_present_to_apicid(cpu); |
1090 | int cpu0_nmi_registered = 0; | ||
1096 | unsigned long flags; | 1091 | unsigned long flags; |
1097 | int err; | 1092 | int err, ret = 0; |
1098 | 1093 | ||
1099 | WARN_ON(irqs_disabled()); | 1094 | WARN_ON(irqs_disabled()); |
1100 | 1095 | ||
@@ -1131,10 +1126,11 @@ int native_cpu_up(unsigned int cpu, struct task_struct *tidle) | |||
1131 | 1126 | ||
1132 | common_cpu_up(cpu, tidle); | 1127 | common_cpu_up(cpu, tidle); |
1133 | 1128 | ||
1134 | err = do_boot_cpu(apicid, cpu, tidle); | 1129 | err = do_boot_cpu(apicid, cpu, tidle, &cpu0_nmi_registered); |
1135 | if (err) { | 1130 | if (err) { |
1136 | pr_err("do_boot_cpu failed(%d) to wakeup CPU#%u\n", err, cpu); | 1131 | pr_err("do_boot_cpu failed(%d) to wakeup CPU#%u\n", err, cpu); |
1137 | return -EIO; | 1132 | ret = -EIO; |
1133 | goto unreg_nmi; | ||
1138 | } | 1134 | } |
1139 | 1135 | ||
1140 | /* | 1136 | /* |
@@ -1150,7 +1146,15 @@ int native_cpu_up(unsigned int cpu, struct task_struct *tidle) | |||
1150 | touch_nmi_watchdog(); | 1146 | touch_nmi_watchdog(); |
1151 | } | 1147 | } |
1152 | 1148 | ||
1153 | return 0; | 1149 | unreg_nmi: |
1150 | /* | ||
1151 | * Clean up the nmi handler. Do this after the callin and callout sync | ||
1152 | * to avoid impact of possible long unregister time. | ||
1153 | */ | ||
1154 | if (cpu0_nmi_registered) | ||
1155 | unregister_nmi_handler(NMI_LOCAL, "wake_cpu0"); | ||
1156 | |||
1157 | return ret; | ||
1154 | } | 1158 | } |
1155 | 1159 | ||
1156 | /** | 1160 | /** |
diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c index 213ddf3e937d..73e4d28112f8 100644 --- a/arch/x86/kernel/sys_x86_64.c +++ b/arch/x86/kernel/sys_x86_64.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #include <asm/compat.h> | 21 | #include <asm/compat.h> |
22 | #include <asm/ia32.h> | 22 | #include <asm/ia32.h> |
23 | #include <asm/syscalls.h> | 23 | #include <asm/syscalls.h> |
24 | #include <asm/mpx.h> | ||
24 | 25 | ||
25 | /* | 26 | /* |
26 | * Align a virtual address to avoid aliasing in the I$ on AMD F15h. | 27 | * Align a virtual address to avoid aliasing in the I$ on AMD F15h. |
@@ -100,8 +101,8 @@ out: | |||
100 | return error; | 101 | return error; |
101 | } | 102 | } |
102 | 103 | ||
103 | static void find_start_end(unsigned long flags, unsigned long *begin, | 104 | static void find_start_end(unsigned long addr, unsigned long flags, |
104 | unsigned long *end) | 105 | unsigned long *begin, unsigned long *end) |
105 | { | 106 | { |
106 | if (!in_compat_syscall() && (flags & MAP_32BIT)) { | 107 | if (!in_compat_syscall() && (flags & MAP_32BIT)) { |
107 | /* This is usually used needed to map code in small | 108 | /* This is usually used needed to map code in small |
@@ -120,7 +121,10 @@ static void find_start_end(unsigned long flags, unsigned long *begin, | |||
120 | } | 121 | } |
121 | 122 | ||
122 | *begin = get_mmap_base(1); | 123 | *begin = get_mmap_base(1); |
123 | *end = in_compat_syscall() ? tasksize_32bit() : tasksize_64bit(); | 124 | if (in_compat_syscall()) |
125 | *end = task_size_32bit(); | ||
126 | else | ||
127 | *end = task_size_64bit(addr > DEFAULT_MAP_WINDOW); | ||
124 | } | 128 | } |
125 | 129 | ||
126 | unsigned long | 130 | unsigned long |
@@ -132,10 +136,14 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr, | |||
132 | struct vm_unmapped_area_info info; | 136 | struct vm_unmapped_area_info info; |
133 | unsigned long begin, end; | 137 | unsigned long begin, end; |
134 | 138 | ||
139 | addr = mpx_unmapped_area_check(addr, len, flags); | ||
140 | if (IS_ERR_VALUE(addr)) | ||
141 | return addr; | ||
142 | |||
135 | if (flags & MAP_FIXED) | 143 | if (flags & MAP_FIXED) |
136 | return addr; | 144 | return addr; |
137 | 145 | ||
138 | find_start_end(flags, &begin, &end); | 146 | find_start_end(addr, flags, &begin, &end); |
139 | 147 | ||
140 | if (len > end) | 148 | if (len > end) |
141 | return -ENOMEM; | 149 | return -ENOMEM; |
@@ -171,6 +179,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0, | |||
171 | unsigned long addr = addr0; | 179 | unsigned long addr = addr0; |
172 | struct vm_unmapped_area_info info; | 180 | struct vm_unmapped_area_info info; |
173 | 181 | ||
182 | addr = mpx_unmapped_area_check(addr, len, flags); | ||
183 | if (IS_ERR_VALUE(addr)) | ||
184 | return addr; | ||
185 | |||
174 | /* requested length too big for entire address space */ | 186 | /* requested length too big for entire address space */ |
175 | if (len > TASK_SIZE) | 187 | if (len > TASK_SIZE) |
176 | return -ENOMEM; | 188 | return -ENOMEM; |
@@ -195,6 +207,16 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0, | |||
195 | info.length = len; | 207 | info.length = len; |
196 | info.low_limit = PAGE_SIZE; | 208 | info.low_limit = PAGE_SIZE; |
197 | info.high_limit = get_mmap_base(0); | 209 | info.high_limit = get_mmap_base(0); |
210 | |||
211 | /* | ||
212 | * If hint address is above DEFAULT_MAP_WINDOW, look for unmapped area | ||
213 | * in the full address space. | ||
214 | * | ||
215 | * !in_compat_syscall() check to avoid high addresses for x32. | ||
216 | */ | ||
217 | if (addr > DEFAULT_MAP_WINDOW && !in_compat_syscall()) | ||
218 | info.high_limit += TASK_SIZE_MAX - DEFAULT_MAP_WINDOW; | ||
219 | |||
198 | info.align_mask = 0; | 220 | info.align_mask = 0; |
199 | info.align_offset = pgoff << PAGE_SHIFT; | 221 | info.align_offset = pgoff << PAGE_SHIFT; |
200 | if (filp) { | 222 | if (filp) { |
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index 9b1dd114956a..04d750813c9d 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c | |||
@@ -108,7 +108,7 @@ module_param(dbg, bool, 0644); | |||
108 | (((address) >> PT32_LEVEL_SHIFT(level)) & ((1 << PT32_LEVEL_BITS) - 1)) | 108 | (((address) >> PT32_LEVEL_SHIFT(level)) & ((1 << PT32_LEVEL_BITS) - 1)) |
109 | 109 | ||
110 | 110 | ||
111 | #define PT64_BASE_ADDR_MASK (((1ULL << 52) - 1) & ~(u64)(PAGE_SIZE-1)) | 111 | #define PT64_BASE_ADDR_MASK __sme_clr((((1ULL << 52) - 1) & ~(u64)(PAGE_SIZE-1))) |
112 | #define PT64_DIR_BASE_ADDR_MASK \ | 112 | #define PT64_DIR_BASE_ADDR_MASK \ |
113 | (PT64_BASE_ADDR_MASK & ~((1ULL << (PAGE_SHIFT + PT64_LEVEL_BITS)) - 1)) | 113 | (PT64_BASE_ADDR_MASK & ~((1ULL << (PAGE_SHIFT + PT64_LEVEL_BITS)) - 1)) |
114 | #define PT64_LVL_ADDR_MASK(level) \ | 114 | #define PT64_LVL_ADDR_MASK(level) \ |
@@ -126,7 +126,7 @@ module_param(dbg, bool, 0644); | |||
126 | * PT32_LEVEL_BITS))) - 1)) | 126 | * PT32_LEVEL_BITS))) - 1)) |
127 | 127 | ||
128 | #define PT64_PERM_MASK (PT_PRESENT_MASK | PT_WRITABLE_MASK | shadow_user_mask \ | 128 | #define PT64_PERM_MASK (PT_PRESENT_MASK | PT_WRITABLE_MASK | shadow_user_mask \ |
129 | | shadow_x_mask | shadow_nx_mask) | 129 | | shadow_x_mask | shadow_nx_mask | shadow_me_mask) |
130 | 130 | ||
131 | #define ACC_EXEC_MASK 1 | 131 | #define ACC_EXEC_MASK 1 |
132 | #define ACC_WRITE_MASK PT_WRITABLE_MASK | 132 | #define ACC_WRITE_MASK PT_WRITABLE_MASK |
@@ -186,6 +186,7 @@ static u64 __read_mostly shadow_dirty_mask; | |||
186 | static u64 __read_mostly shadow_mmio_mask; | 186 | static u64 __read_mostly shadow_mmio_mask; |
187 | static u64 __read_mostly shadow_mmio_value; | 187 | static u64 __read_mostly shadow_mmio_value; |
188 | static u64 __read_mostly shadow_present_mask; | 188 | static u64 __read_mostly shadow_present_mask; |
189 | static u64 __read_mostly shadow_me_mask; | ||
189 | 190 | ||
190 | /* | 191 | /* |
191 | * SPTEs used by MMUs without A/D bits are marked with shadow_acc_track_value. | 192 | * SPTEs used by MMUs without A/D bits are marked with shadow_acc_track_value. |
@@ -349,7 +350,7 @@ static bool check_mmio_spte(struct kvm_vcpu *vcpu, u64 spte) | |||
349 | */ | 350 | */ |
350 | void kvm_mmu_set_mask_ptes(u64 user_mask, u64 accessed_mask, | 351 | void kvm_mmu_set_mask_ptes(u64 user_mask, u64 accessed_mask, |
351 | u64 dirty_mask, u64 nx_mask, u64 x_mask, u64 p_mask, | 352 | u64 dirty_mask, u64 nx_mask, u64 x_mask, u64 p_mask, |
352 | u64 acc_track_mask) | 353 | u64 acc_track_mask, u64 me_mask) |
353 | { | 354 | { |
354 | BUG_ON(!dirty_mask != !accessed_mask); | 355 | BUG_ON(!dirty_mask != !accessed_mask); |
355 | BUG_ON(!accessed_mask && !acc_track_mask); | 356 | BUG_ON(!accessed_mask && !acc_track_mask); |
@@ -362,6 +363,7 @@ void kvm_mmu_set_mask_ptes(u64 user_mask, u64 accessed_mask, | |||
362 | shadow_x_mask = x_mask; | 363 | shadow_x_mask = x_mask; |
363 | shadow_present_mask = p_mask; | 364 | shadow_present_mask = p_mask; |
364 | shadow_acc_track_mask = acc_track_mask; | 365 | shadow_acc_track_mask = acc_track_mask; |
366 | shadow_me_mask = me_mask; | ||
365 | } | 367 | } |
366 | EXPORT_SYMBOL_GPL(kvm_mmu_set_mask_ptes); | 368 | EXPORT_SYMBOL_GPL(kvm_mmu_set_mask_ptes); |
367 | 369 | ||
@@ -2433,7 +2435,7 @@ static void link_shadow_page(struct kvm_vcpu *vcpu, u64 *sptep, | |||
2433 | BUILD_BUG_ON(VMX_EPT_WRITABLE_MASK != PT_WRITABLE_MASK); | 2435 | BUILD_BUG_ON(VMX_EPT_WRITABLE_MASK != PT_WRITABLE_MASK); |
2434 | 2436 | ||
2435 | spte = __pa(sp->spt) | shadow_present_mask | PT_WRITABLE_MASK | | 2437 | spte = __pa(sp->spt) | shadow_present_mask | PT_WRITABLE_MASK | |
2436 | shadow_user_mask | shadow_x_mask; | 2438 | shadow_user_mask | shadow_x_mask | shadow_me_mask; |
2437 | 2439 | ||
2438 | if (sp_ad_disabled(sp)) | 2440 | if (sp_ad_disabled(sp)) |
2439 | spte |= shadow_acc_track_value; | 2441 | spte |= shadow_acc_track_value; |
@@ -2745,6 +2747,7 @@ static int set_spte(struct kvm_vcpu *vcpu, u64 *sptep, | |||
2745 | pte_access &= ~ACC_WRITE_MASK; | 2747 | pte_access &= ~ACC_WRITE_MASK; |
2746 | 2748 | ||
2747 | spte |= (u64)pfn << PAGE_SHIFT; | 2749 | spte |= (u64)pfn << PAGE_SHIFT; |
2750 | spte |= shadow_me_mask; | ||
2748 | 2751 | ||
2749 | if (pte_access & ACC_WRITE_MASK) { | 2752 | if (pte_access & ACC_WRITE_MASK) { |
2750 | 2753 | ||
@@ -4106,16 +4109,28 @@ void | |||
4106 | reset_shadow_zero_bits_mask(struct kvm_vcpu *vcpu, struct kvm_mmu *context) | 4109 | reset_shadow_zero_bits_mask(struct kvm_vcpu *vcpu, struct kvm_mmu *context) |
4107 | { | 4110 | { |
4108 | bool uses_nx = context->nx || context->base_role.smep_andnot_wp; | 4111 | bool uses_nx = context->nx || context->base_role.smep_andnot_wp; |
4112 | struct rsvd_bits_validate *shadow_zero_check; | ||
4113 | int i; | ||
4109 | 4114 | ||
4110 | /* | 4115 | /* |
4111 | * Passing "true" to the last argument is okay; it adds a check | 4116 | * Passing "true" to the last argument is okay; it adds a check |
4112 | * on bit 8 of the SPTEs which KVM doesn't use anyway. | 4117 | * on bit 8 of the SPTEs which KVM doesn't use anyway. |
4113 | */ | 4118 | */ |
4114 | __reset_rsvds_bits_mask(vcpu, &context->shadow_zero_check, | 4119 | shadow_zero_check = &context->shadow_zero_check; |
4120 | __reset_rsvds_bits_mask(vcpu, shadow_zero_check, | ||
4115 | boot_cpu_data.x86_phys_bits, | 4121 | boot_cpu_data.x86_phys_bits, |
4116 | context->shadow_root_level, uses_nx, | 4122 | context->shadow_root_level, uses_nx, |
4117 | guest_cpuid_has_gbpages(vcpu), is_pse(vcpu), | 4123 | guest_cpuid_has_gbpages(vcpu), is_pse(vcpu), |
4118 | true); | 4124 | true); |
4125 | |||
4126 | if (!shadow_me_mask) | ||
4127 | return; | ||
4128 | |||
4129 | for (i = context->shadow_root_level; --i >= 0;) { | ||
4130 | shadow_zero_check->rsvd_bits_mask[0][i] &= ~shadow_me_mask; | ||
4131 | shadow_zero_check->rsvd_bits_mask[1][i] &= ~shadow_me_mask; | ||
4132 | } | ||
4133 | |||
4119 | } | 4134 | } |
4120 | EXPORT_SYMBOL_GPL(reset_shadow_zero_bits_mask); | 4135 | EXPORT_SYMBOL_GPL(reset_shadow_zero_bits_mask); |
4121 | 4136 | ||
@@ -4133,17 +4148,29 @@ static void | |||
4133 | reset_tdp_shadow_zero_bits_mask(struct kvm_vcpu *vcpu, | 4148 | reset_tdp_shadow_zero_bits_mask(struct kvm_vcpu *vcpu, |
4134 | struct kvm_mmu *context) | 4149 | struct kvm_mmu *context) |
4135 | { | 4150 | { |
4151 | struct rsvd_bits_validate *shadow_zero_check; | ||
4152 | int i; | ||
4153 | |||
4154 | shadow_zero_check = &context->shadow_zero_check; | ||
4155 | |||
4136 | if (boot_cpu_is_amd()) | 4156 | if (boot_cpu_is_amd()) |
4137 | __reset_rsvds_bits_mask(vcpu, &context->shadow_zero_check, | 4157 | __reset_rsvds_bits_mask(vcpu, shadow_zero_check, |
4138 | boot_cpu_data.x86_phys_bits, | 4158 | boot_cpu_data.x86_phys_bits, |
4139 | context->shadow_root_level, false, | 4159 | context->shadow_root_level, false, |
4140 | boot_cpu_has(X86_FEATURE_GBPAGES), | 4160 | boot_cpu_has(X86_FEATURE_GBPAGES), |
4141 | true, true); | 4161 | true, true); |
4142 | else | 4162 | else |
4143 | __reset_rsvds_bits_mask_ept(&context->shadow_zero_check, | 4163 | __reset_rsvds_bits_mask_ept(shadow_zero_check, |
4144 | boot_cpu_data.x86_phys_bits, | 4164 | boot_cpu_data.x86_phys_bits, |
4145 | false); | 4165 | false); |
4146 | 4166 | ||
4167 | if (!shadow_me_mask) | ||
4168 | return; | ||
4169 | |||
4170 | for (i = context->shadow_root_level; --i >= 0;) { | ||
4171 | shadow_zero_check->rsvd_bits_mask[0][i] &= ~shadow_me_mask; | ||
4172 | shadow_zero_check->rsvd_bits_mask[1][i] &= ~shadow_me_mask; | ||
4173 | } | ||
4147 | } | 4174 | } |
4148 | 4175 | ||
4149 | /* | 4176 | /* |
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index 1107626938cc..099ff08b4aff 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c | |||
@@ -1100,7 +1100,7 @@ static __init int svm_hardware_setup(void) | |||
1100 | 1100 | ||
1101 | if (vls) { | 1101 | if (vls) { |
1102 | if (!npt_enabled || | 1102 | if (!npt_enabled || |
1103 | !boot_cpu_has(X86_FEATURE_VIRTUAL_VMLOAD_VMSAVE) || | 1103 | !boot_cpu_has(X86_FEATURE_V_VMSAVE_VMLOAD) || |
1104 | !IS_ENABLED(CONFIG_X86_64)) { | 1104 | !IS_ENABLED(CONFIG_X86_64)) { |
1105 | vls = false; | 1105 | vls = false; |
1106 | } else { | 1106 | } else { |
@@ -1167,9 +1167,9 @@ static void avic_init_vmcb(struct vcpu_svm *svm) | |||
1167 | { | 1167 | { |
1168 | struct vmcb *vmcb = svm->vmcb; | 1168 | struct vmcb *vmcb = svm->vmcb; |
1169 | struct kvm_arch *vm_data = &svm->vcpu.kvm->arch; | 1169 | struct kvm_arch *vm_data = &svm->vcpu.kvm->arch; |
1170 | phys_addr_t bpa = page_to_phys(svm->avic_backing_page); | 1170 | phys_addr_t bpa = __sme_set(page_to_phys(svm->avic_backing_page)); |
1171 | phys_addr_t lpa = page_to_phys(vm_data->avic_logical_id_table_page); | 1171 | phys_addr_t lpa = __sme_set(page_to_phys(vm_data->avic_logical_id_table_page)); |
1172 | phys_addr_t ppa = page_to_phys(vm_data->avic_physical_id_table_page); | 1172 | phys_addr_t ppa = __sme_set(page_to_phys(vm_data->avic_physical_id_table_page)); |
1173 | 1173 | ||
1174 | vmcb->control.avic_backing_page = bpa & AVIC_HPA_MASK; | 1174 | vmcb->control.avic_backing_page = bpa & AVIC_HPA_MASK; |
1175 | vmcb->control.avic_logical_id = lpa & AVIC_HPA_MASK; | 1175 | vmcb->control.avic_logical_id = lpa & AVIC_HPA_MASK; |
@@ -1232,8 +1232,8 @@ static void init_vmcb(struct vcpu_svm *svm) | |||
1232 | set_intercept(svm, INTERCEPT_MWAIT); | 1232 | set_intercept(svm, INTERCEPT_MWAIT); |
1233 | } | 1233 | } |
1234 | 1234 | ||
1235 | control->iopm_base_pa = iopm_base; | 1235 | control->iopm_base_pa = __sme_set(iopm_base); |
1236 | control->msrpm_base_pa = __pa(svm->msrpm); | 1236 | control->msrpm_base_pa = __sme_set(__pa(svm->msrpm)); |
1237 | control->int_ctl = V_INTR_MASKING_MASK; | 1237 | control->int_ctl = V_INTR_MASKING_MASK; |
1238 | 1238 | ||
1239 | init_seg(&save->es); | 1239 | init_seg(&save->es); |
@@ -1377,9 +1377,9 @@ static int avic_init_backing_page(struct kvm_vcpu *vcpu) | |||
1377 | return -EINVAL; | 1377 | return -EINVAL; |
1378 | 1378 | ||
1379 | new_entry = READ_ONCE(*entry); | 1379 | new_entry = READ_ONCE(*entry); |
1380 | new_entry = (page_to_phys(svm->avic_backing_page) & | 1380 | new_entry = __sme_set((page_to_phys(svm->avic_backing_page) & |
1381 | AVIC_PHYSICAL_ID_ENTRY_BACKING_PAGE_MASK) | | 1381 | AVIC_PHYSICAL_ID_ENTRY_BACKING_PAGE_MASK) | |
1382 | AVIC_PHYSICAL_ID_ENTRY_VALID_MASK; | 1382 | AVIC_PHYSICAL_ID_ENTRY_VALID_MASK); |
1383 | WRITE_ONCE(*entry, new_entry); | 1383 | WRITE_ONCE(*entry, new_entry); |
1384 | 1384 | ||
1385 | svm->avic_physical_id_cache = entry; | 1385 | svm->avic_physical_id_cache = entry; |
@@ -1647,7 +1647,7 @@ static struct kvm_vcpu *svm_create_vcpu(struct kvm *kvm, unsigned int id) | |||
1647 | 1647 | ||
1648 | svm->vmcb = page_address(page); | 1648 | svm->vmcb = page_address(page); |
1649 | clear_page(svm->vmcb); | 1649 | clear_page(svm->vmcb); |
1650 | svm->vmcb_pa = page_to_pfn(page) << PAGE_SHIFT; | 1650 | svm->vmcb_pa = __sme_set(page_to_pfn(page) << PAGE_SHIFT); |
1651 | svm->asid_generation = 0; | 1651 | svm->asid_generation = 0; |
1652 | init_vmcb(svm); | 1652 | init_vmcb(svm); |
1653 | 1653 | ||
@@ -1675,7 +1675,7 @@ static void svm_free_vcpu(struct kvm_vcpu *vcpu) | |||
1675 | { | 1675 | { |
1676 | struct vcpu_svm *svm = to_svm(vcpu); | 1676 | struct vcpu_svm *svm = to_svm(vcpu); |
1677 | 1677 | ||
1678 | __free_page(pfn_to_page(svm->vmcb_pa >> PAGE_SHIFT)); | 1678 | __free_page(pfn_to_page(__sme_clr(svm->vmcb_pa) >> PAGE_SHIFT)); |
1679 | __free_pages(virt_to_page(svm->msrpm), MSRPM_ALLOC_ORDER); | 1679 | __free_pages(virt_to_page(svm->msrpm), MSRPM_ALLOC_ORDER); |
1680 | __free_page(virt_to_page(svm->nested.hsave)); | 1680 | __free_page(virt_to_page(svm->nested.hsave)); |
1681 | __free_pages(virt_to_page(svm->nested.msrpm), MSRPM_ALLOC_ORDER); | 1681 | __free_pages(virt_to_page(svm->nested.msrpm), MSRPM_ALLOC_ORDER); |
@@ -2335,7 +2335,7 @@ static u64 nested_svm_get_tdp_pdptr(struct kvm_vcpu *vcpu, int index) | |||
2335 | u64 pdpte; | 2335 | u64 pdpte; |
2336 | int ret; | 2336 | int ret; |
2337 | 2337 | ||
2338 | ret = kvm_vcpu_read_guest_page(vcpu, gpa_to_gfn(cr3), &pdpte, | 2338 | ret = kvm_vcpu_read_guest_page(vcpu, gpa_to_gfn(__sme_clr(cr3)), &pdpte, |
2339 | offset_in_page(cr3) + index * 8, 8); | 2339 | offset_in_page(cr3) + index * 8, 8); |
2340 | if (ret) | 2340 | if (ret) |
2341 | return 0; | 2341 | return 0; |
@@ -2347,7 +2347,7 @@ static void nested_svm_set_tdp_cr3(struct kvm_vcpu *vcpu, | |||
2347 | { | 2347 | { |
2348 | struct vcpu_svm *svm = to_svm(vcpu); | 2348 | struct vcpu_svm *svm = to_svm(vcpu); |
2349 | 2349 | ||
2350 | svm->vmcb->control.nested_cr3 = root; | 2350 | svm->vmcb->control.nested_cr3 = __sme_set(root); |
2351 | mark_dirty(svm->vmcb, VMCB_NPT); | 2351 | mark_dirty(svm->vmcb, VMCB_NPT); |
2352 | svm_flush_tlb(vcpu); | 2352 | svm_flush_tlb(vcpu); |
2353 | } | 2353 | } |
@@ -2878,7 +2878,7 @@ static bool nested_svm_vmrun_msrpm(struct vcpu_svm *svm) | |||
2878 | svm->nested.msrpm[p] = svm->msrpm[p] | value; | 2878 | svm->nested.msrpm[p] = svm->msrpm[p] | value; |
2879 | } | 2879 | } |
2880 | 2880 | ||
2881 | svm->vmcb->control.msrpm_base_pa = __pa(svm->nested.msrpm); | 2881 | svm->vmcb->control.msrpm_base_pa = __sme_set(__pa(svm->nested.msrpm)); |
2882 | 2882 | ||
2883 | return true; | 2883 | return true; |
2884 | } | 2884 | } |
@@ -4511,7 +4511,7 @@ get_pi_vcpu_info(struct kvm *kvm, struct kvm_kernel_irq_routing_entry *e, | |||
4511 | pr_debug("SVM: %s: use GA mode for irq %u\n", __func__, | 4511 | pr_debug("SVM: %s: use GA mode for irq %u\n", __func__, |
4512 | irq.vector); | 4512 | irq.vector); |
4513 | *svm = to_svm(vcpu); | 4513 | *svm = to_svm(vcpu); |
4514 | vcpu_info->pi_desc_addr = page_to_phys((*svm)->avic_backing_page); | 4514 | vcpu_info->pi_desc_addr = __sme_set(page_to_phys((*svm)->avic_backing_page)); |
4515 | vcpu_info->vector = irq.vector; | 4515 | vcpu_info->vector = irq.vector; |
4516 | 4516 | ||
4517 | return 0; | 4517 | return 0; |
@@ -4562,7 +4562,8 @@ static int svm_update_pi_irte(struct kvm *kvm, unsigned int host_irq, | |||
4562 | struct amd_iommu_pi_data pi; | 4562 | struct amd_iommu_pi_data pi; |
4563 | 4563 | ||
4564 | /* Try to enable guest_mode in IRTE */ | 4564 | /* Try to enable guest_mode in IRTE */ |
4565 | pi.base = page_to_phys(svm->avic_backing_page) & AVIC_HPA_MASK; | 4565 | pi.base = __sme_set(page_to_phys(svm->avic_backing_page) & |
4566 | AVIC_HPA_MASK); | ||
4566 | pi.ga_tag = AVIC_GATAG(kvm->arch.avic_vm_id, | 4567 | pi.ga_tag = AVIC_GATAG(kvm->arch.avic_vm_id, |
4567 | svm->vcpu.vcpu_id); | 4568 | svm->vcpu.vcpu_id); |
4568 | pi.is_guest_mode = true; | 4569 | pi.is_guest_mode = true; |
@@ -5011,7 +5012,7 @@ static void svm_set_cr3(struct kvm_vcpu *vcpu, unsigned long root) | |||
5011 | { | 5012 | { |
5012 | struct vcpu_svm *svm = to_svm(vcpu); | 5013 | struct vcpu_svm *svm = to_svm(vcpu); |
5013 | 5014 | ||
5014 | svm->vmcb->save.cr3 = root; | 5015 | svm->vmcb->save.cr3 = __sme_set(root); |
5015 | mark_dirty(svm->vmcb, VMCB_CR); | 5016 | mark_dirty(svm->vmcb, VMCB_CR); |
5016 | svm_flush_tlb(vcpu); | 5017 | svm_flush_tlb(vcpu); |
5017 | } | 5018 | } |
@@ -5020,7 +5021,7 @@ static void set_tdp_cr3(struct kvm_vcpu *vcpu, unsigned long root) | |||
5020 | { | 5021 | { |
5021 | struct vcpu_svm *svm = to_svm(vcpu); | 5022 | struct vcpu_svm *svm = to_svm(vcpu); |
5022 | 5023 | ||
5023 | svm->vmcb->control.nested_cr3 = root; | 5024 | svm->vmcb->control.nested_cr3 = __sme_set(root); |
5024 | mark_dirty(svm->vmcb, VMCB_NPT); | 5025 | mark_dirty(svm->vmcb, VMCB_NPT); |
5025 | 5026 | ||
5026 | /* Also sync guest cr3 here in case we live migrate */ | 5027 | /* Also sync guest cr3 here in case we live migrate */ |
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 9b21b1223035..416d5ed320b6 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c | |||
@@ -6563,7 +6563,7 @@ void vmx_enable_tdp(void) | |||
6563 | enable_ept_ad_bits ? VMX_EPT_DIRTY_BIT : 0ull, | 6563 | enable_ept_ad_bits ? VMX_EPT_DIRTY_BIT : 0ull, |
6564 | 0ull, VMX_EPT_EXECUTABLE_MASK, | 6564 | 0ull, VMX_EPT_EXECUTABLE_MASK, |
6565 | cpu_has_vmx_ept_execute_only() ? 0ull : VMX_EPT_READABLE_MASK, | 6565 | cpu_has_vmx_ept_execute_only() ? 0ull : VMX_EPT_READABLE_MASK, |
6566 | VMX_EPT_RWX_MASK); | 6566 | VMX_EPT_RWX_MASK, 0ull); |
6567 | 6567 | ||
6568 | ept_set_mmio_spte_mask(); | 6568 | ept_set_mmio_spte_mask(); |
6569 | kvm_enable_tdp(); | 6569 | kvm_enable_tdp(); |
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index d734aa8c5b4f..eda4bdbd7e5e 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c | |||
@@ -54,6 +54,7 @@ | |||
54 | #include <linux/kvm_irqfd.h> | 54 | #include <linux/kvm_irqfd.h> |
55 | #include <linux/irqbypass.h> | 55 | #include <linux/irqbypass.h> |
56 | #include <linux/sched/stat.h> | 56 | #include <linux/sched/stat.h> |
57 | #include <linux/mem_encrypt.h> | ||
57 | 58 | ||
58 | #include <trace/events/kvm.h> | 59 | #include <trace/events/kvm.h> |
59 | 60 | ||
@@ -6116,7 +6117,7 @@ int kvm_arch_init(void *opaque) | |||
6116 | 6117 | ||
6117 | kvm_mmu_set_mask_ptes(PT_USER_MASK, PT_ACCESSED_MASK, | 6118 | kvm_mmu_set_mask_ptes(PT_USER_MASK, PT_ACCESSED_MASK, |
6118 | PT_DIRTY_MASK, PT64_NX_MASK, 0, | 6119 | PT_DIRTY_MASK, PT64_NX_MASK, 0, |
6119 | PT_PRESENT_MASK, 0); | 6120 | PT_PRESENT_MASK, 0, sme_me_mask); |
6120 | kvm_timer_init(); | 6121 | kvm_timer_init(); |
6121 | 6122 | ||
6122 | perf_register_guest_info_callbacks(&kvm_guest_cbs); | 6123 | perf_register_guest_info_callbacks(&kvm_guest_cbs); |
diff --git a/arch/x86/lib/cmdline.c b/arch/x86/lib/cmdline.c index 5cc78bf57232..3261abb21ef4 100644 --- a/arch/x86/lib/cmdline.c +++ b/arch/x86/lib/cmdline.c | |||
@@ -104,7 +104,112 @@ __cmdline_find_option_bool(const char *cmdline, int max_cmdline_size, | |||
104 | return 0; /* Buffer overrun */ | 104 | return 0; /* Buffer overrun */ |
105 | } | 105 | } |
106 | 106 | ||
107 | /* | ||
108 | * Find a non-boolean option (i.e. option=argument). In accordance with | ||
109 | * standard Linux practice, if this option is repeated, this returns the | ||
110 | * last instance on the command line. | ||
111 | * | ||
112 | * @cmdline: the cmdline string | ||
113 | * @max_cmdline_size: the maximum size of cmdline | ||
114 | * @option: option string to look for | ||
115 | * @buffer: memory buffer to return the option argument | ||
116 | * @bufsize: size of the supplied memory buffer | ||
117 | * | ||
118 | * Returns the length of the argument (regardless of if it was | ||
119 | * truncated to fit in the buffer), or -1 on not found. | ||
120 | */ | ||
121 | static int | ||
122 | __cmdline_find_option(const char *cmdline, int max_cmdline_size, | ||
123 | const char *option, char *buffer, int bufsize) | ||
124 | { | ||
125 | char c; | ||
126 | int pos = 0, len = -1; | ||
127 | const char *opptr = NULL; | ||
128 | char *bufptr = buffer; | ||
129 | enum { | ||
130 | st_wordstart = 0, /* Start of word/after whitespace */ | ||
131 | st_wordcmp, /* Comparing this word */ | ||
132 | st_wordskip, /* Miscompare, skip */ | ||
133 | st_bufcpy, /* Copying this to buffer */ | ||
134 | } state = st_wordstart; | ||
135 | |||
136 | if (!cmdline) | ||
137 | return -1; /* No command line */ | ||
138 | |||
139 | /* | ||
140 | * This 'pos' check ensures we do not overrun | ||
141 | * a non-NULL-terminated 'cmdline' | ||
142 | */ | ||
143 | while (pos++ < max_cmdline_size) { | ||
144 | c = *(char *)cmdline++; | ||
145 | if (!c) | ||
146 | break; | ||
147 | |||
148 | switch (state) { | ||
149 | case st_wordstart: | ||
150 | if (myisspace(c)) | ||
151 | break; | ||
152 | |||
153 | state = st_wordcmp; | ||
154 | opptr = option; | ||
155 | /* fall through */ | ||
156 | |||
157 | case st_wordcmp: | ||
158 | if ((c == '=') && !*opptr) { | ||
159 | /* | ||
160 | * We matched all the way to the end of the | ||
161 | * option we were looking for, prepare to | ||
162 | * copy the argument. | ||
163 | */ | ||
164 | len = 0; | ||
165 | bufptr = buffer; | ||
166 | state = st_bufcpy; | ||
167 | break; | ||
168 | } else if (c == *opptr++) { | ||
169 | /* | ||
170 | * We are currently matching, so continue | ||
171 | * to the next character on the cmdline. | ||
172 | */ | ||
173 | break; | ||
174 | } | ||
175 | state = st_wordskip; | ||
176 | /* fall through */ | ||
177 | |||
178 | case st_wordskip: | ||
179 | if (myisspace(c)) | ||
180 | state = st_wordstart; | ||
181 | break; | ||
182 | |||
183 | case st_bufcpy: | ||
184 | if (myisspace(c)) { | ||
185 | state = st_wordstart; | ||
186 | } else { | ||
187 | /* | ||
188 | * Increment len, but don't overrun the | ||
189 | * supplied buffer and leave room for the | ||
190 | * NULL terminator. | ||
191 | */ | ||
192 | if (++len < bufsize) | ||
193 | *bufptr++ = c; | ||
194 | } | ||
195 | break; | ||
196 | } | ||
197 | } | ||
198 | |||
199 | if (bufsize) | ||
200 | *bufptr = '\0'; | ||
201 | |||
202 | return len; | ||
203 | } | ||
204 | |||
107 | int cmdline_find_option_bool(const char *cmdline, const char *option) | 205 | int cmdline_find_option_bool(const char *cmdline, const char *option) |
108 | { | 206 | { |
109 | return __cmdline_find_option_bool(cmdline, COMMAND_LINE_SIZE, option); | 207 | return __cmdline_find_option_bool(cmdline, COMMAND_LINE_SIZE, option); |
110 | } | 208 | } |
209 | |||
210 | int cmdline_find_option(const char *cmdline, const char *option, char *buffer, | ||
211 | int bufsize) | ||
212 | { | ||
213 | return __cmdline_find_option(cmdline, COMMAND_LINE_SIZE, option, | ||
214 | buffer, bufsize); | ||
215 | } | ||
diff --git a/arch/x86/mm/Makefile b/arch/x86/mm/Makefile index 0fbdcb64f9f8..72bf8c01c6e3 100644 --- a/arch/x86/mm/Makefile +++ b/arch/x86/mm/Makefile | |||
@@ -39,3 +39,5 @@ obj-$(CONFIG_X86_INTEL_MPX) += mpx.o | |||
39 | obj-$(CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS) += pkeys.o | 39 | obj-$(CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS) += pkeys.o |
40 | obj-$(CONFIG_RANDOMIZE_MEMORY) += kaslr.o | 40 | obj-$(CONFIG_RANDOMIZE_MEMORY) += kaslr.o |
41 | 41 | ||
42 | obj-$(CONFIG_AMD_MEM_ENCRYPT) += mem_encrypt.o | ||
43 | obj-$(CONFIG_AMD_MEM_ENCRYPT) += mem_encrypt_boot.o | ||
diff --git a/arch/x86/mm/dump_pagetables.c b/arch/x86/mm/dump_pagetables.c index 0470826d2bdc..5e3ac6fe6c9e 100644 --- a/arch/x86/mm/dump_pagetables.c +++ b/arch/x86/mm/dump_pagetables.c | |||
@@ -13,12 +13,12 @@ | |||
13 | */ | 13 | */ |
14 | 14 | ||
15 | #include <linux/debugfs.h> | 15 | #include <linux/debugfs.h> |
16 | #include <linux/kasan.h> | ||
16 | #include <linux/mm.h> | 17 | #include <linux/mm.h> |
17 | #include <linux/init.h> | 18 | #include <linux/init.h> |
18 | #include <linux/sched.h> | 19 | #include <linux/sched.h> |
19 | #include <linux/seq_file.h> | 20 | #include <linux/seq_file.h> |
20 | 21 | ||
21 | #include <asm/kasan.h> | ||
22 | #include <asm/pgtable.h> | 22 | #include <asm/pgtable.h> |
23 | 23 | ||
24 | /* | 24 | /* |
@@ -138,7 +138,7 @@ static void printk_prot(struct seq_file *m, pgprot_t prot, int level, bool dmsg) | |||
138 | { | 138 | { |
139 | pgprotval_t pr = pgprot_val(prot); | 139 | pgprotval_t pr = pgprot_val(prot); |
140 | static const char * const level_name[] = | 140 | static const char * const level_name[] = |
141 | { "cr3", "pgd", "pud", "pmd", "pte" }; | 141 | { "cr3", "pgd", "p4d", "pud", "pmd", "pte" }; |
142 | 142 | ||
143 | if (!pgprot_val(prot)) { | 143 | if (!pgprot_val(prot)) { |
144 | /* Not present */ | 144 | /* Not present */ |
@@ -162,12 +162,12 @@ static void printk_prot(struct seq_file *m, pgprot_t prot, int level, bool dmsg) | |||
162 | pt_dump_cont_printf(m, dmsg, " "); | 162 | pt_dump_cont_printf(m, dmsg, " "); |
163 | 163 | ||
164 | /* Bit 7 has a different meaning on level 3 vs 4 */ | 164 | /* Bit 7 has a different meaning on level 3 vs 4 */ |
165 | if (level <= 3 && pr & _PAGE_PSE) | 165 | if (level <= 4 && pr & _PAGE_PSE) |
166 | pt_dump_cont_printf(m, dmsg, "PSE "); | 166 | pt_dump_cont_printf(m, dmsg, "PSE "); |
167 | else | 167 | else |
168 | pt_dump_cont_printf(m, dmsg, " "); | 168 | pt_dump_cont_printf(m, dmsg, " "); |
169 | if ((level == 4 && pr & _PAGE_PAT) || | 169 | if ((level == 5 && pr & _PAGE_PAT) || |
170 | ((level == 3 || level == 2) && pr & _PAGE_PAT_LARGE)) | 170 | ((level == 4 || level == 3) && pr & _PAGE_PAT_LARGE)) |
171 | pt_dump_cont_printf(m, dmsg, "PAT "); | 171 | pt_dump_cont_printf(m, dmsg, "PAT "); |
172 | else | 172 | else |
173 | pt_dump_cont_printf(m, dmsg, " "); | 173 | pt_dump_cont_printf(m, dmsg, " "); |
@@ -188,11 +188,12 @@ static void printk_prot(struct seq_file *m, pgprot_t prot, int level, bool dmsg) | |||
188 | */ | 188 | */ |
189 | static unsigned long normalize_addr(unsigned long u) | 189 | static unsigned long normalize_addr(unsigned long u) |
190 | { | 190 | { |
191 | #ifdef CONFIG_X86_64 | 191 | int shift; |
192 | return (signed long)(u << 16) >> 16; | 192 | if (!IS_ENABLED(CONFIG_X86_64)) |
193 | #else | 193 | return u; |
194 | return u; | 194 | |
195 | #endif | 195 | shift = 64 - (__VIRTUAL_MASK_SHIFT + 1); |
196 | return (signed long)(u << shift) >> shift; | ||
196 | } | 197 | } |
197 | 198 | ||
198 | /* | 199 | /* |
@@ -297,32 +298,62 @@ static void walk_pte_level(struct seq_file *m, struct pg_state *st, pmd_t addr, | |||
297 | for (i = 0; i < PTRS_PER_PTE; i++) { | 298 | for (i = 0; i < PTRS_PER_PTE; i++) { |
298 | prot = pte_flags(*start); | 299 | prot = pte_flags(*start); |
299 | st->current_address = normalize_addr(P + i * PTE_LEVEL_MULT); | 300 | st->current_address = normalize_addr(P + i * PTE_LEVEL_MULT); |
300 | note_page(m, st, __pgprot(prot), 4); | 301 | note_page(m, st, __pgprot(prot), 5); |
301 | start++; | 302 | start++; |
302 | } | 303 | } |
303 | } | 304 | } |
305 | #ifdef CONFIG_KASAN | ||
306 | |||
307 | /* | ||
308 | * This is an optimization for KASAN=y case. Since all kasan page tables | ||
309 | * eventually point to the kasan_zero_page we could call note_page() | ||
310 | * right away without walking through lower level page tables. This saves | ||
311 | * us dozens of seconds (minutes for 5-level config) while checking for | ||
312 | * W+X mapping or reading kernel_page_tables debugfs file. | ||
313 | */ | ||
314 | static inline bool kasan_page_table(struct seq_file *m, struct pg_state *st, | ||
315 | void *pt) | ||
316 | { | ||
317 | if (__pa(pt) == __pa(kasan_zero_pmd) || | ||
318 | #ifdef CONFIG_X86_5LEVEL | ||
319 | __pa(pt) == __pa(kasan_zero_p4d) || | ||
320 | #endif | ||
321 | __pa(pt) == __pa(kasan_zero_pud)) { | ||
322 | pgprotval_t prot = pte_flags(kasan_zero_pte[0]); | ||
323 | note_page(m, st, __pgprot(prot), 5); | ||
324 | return true; | ||
325 | } | ||
326 | return false; | ||
327 | } | ||
328 | #else | ||
329 | static inline bool kasan_page_table(struct seq_file *m, struct pg_state *st, | ||
330 | void *pt) | ||
331 | { | ||
332 | return false; | ||
333 | } | ||
334 | #endif | ||
304 | 335 | ||
305 | #if PTRS_PER_PMD > 1 | 336 | #if PTRS_PER_PMD > 1 |
306 | 337 | ||
307 | static void walk_pmd_level(struct seq_file *m, struct pg_state *st, pud_t addr, unsigned long P) | 338 | static void walk_pmd_level(struct seq_file *m, struct pg_state *st, pud_t addr, unsigned long P) |
308 | { | 339 | { |
309 | int i; | 340 | int i; |
310 | pmd_t *start; | 341 | pmd_t *start, *pmd_start; |
311 | pgprotval_t prot; | 342 | pgprotval_t prot; |
312 | 343 | ||
313 | start = (pmd_t *)pud_page_vaddr(addr); | 344 | pmd_start = start = (pmd_t *)pud_page_vaddr(addr); |
314 | for (i = 0; i < PTRS_PER_PMD; i++) { | 345 | for (i = 0; i < PTRS_PER_PMD; i++) { |
315 | st->current_address = normalize_addr(P + i * PMD_LEVEL_MULT); | 346 | st->current_address = normalize_addr(P + i * PMD_LEVEL_MULT); |
316 | if (!pmd_none(*start)) { | 347 | if (!pmd_none(*start)) { |
317 | if (pmd_large(*start) || !pmd_present(*start)) { | 348 | if (pmd_large(*start) || !pmd_present(*start)) { |
318 | prot = pmd_flags(*start); | 349 | prot = pmd_flags(*start); |
319 | note_page(m, st, __pgprot(prot), 3); | 350 | note_page(m, st, __pgprot(prot), 4); |
320 | } else { | 351 | } else if (!kasan_page_table(m, st, pmd_start)) { |
321 | walk_pte_level(m, st, *start, | 352 | walk_pte_level(m, st, *start, |
322 | P + i * PMD_LEVEL_MULT); | 353 | P + i * PMD_LEVEL_MULT); |
323 | } | 354 | } |
324 | } else | 355 | } else |
325 | note_page(m, st, __pgprot(0), 3); | 356 | note_page(m, st, __pgprot(0), 4); |
326 | start++; | 357 | start++; |
327 | } | 358 | } |
328 | } | 359 | } |
@@ -335,39 +366,27 @@ static void walk_pmd_level(struct seq_file *m, struct pg_state *st, pud_t addr, | |||
335 | 366 | ||
336 | #if PTRS_PER_PUD > 1 | 367 | #if PTRS_PER_PUD > 1 |
337 | 368 | ||
338 | /* | ||
339 | * This is an optimization for CONFIG_DEBUG_WX=y + CONFIG_KASAN=y | ||
340 | * KASAN fills page tables with the same values. Since there is no | ||
341 | * point in checking page table more than once we just skip repeated | ||
342 | * entries. This saves us dozens of seconds during boot. | ||
343 | */ | ||
344 | static bool pud_already_checked(pud_t *prev_pud, pud_t *pud, bool checkwx) | ||
345 | { | ||
346 | return checkwx && prev_pud && (pud_val(*prev_pud) == pud_val(*pud)); | ||
347 | } | ||
348 | |||
349 | static void walk_pud_level(struct seq_file *m, struct pg_state *st, p4d_t addr, unsigned long P) | 369 | static void walk_pud_level(struct seq_file *m, struct pg_state *st, p4d_t addr, unsigned long P) |
350 | { | 370 | { |
351 | int i; | 371 | int i; |
352 | pud_t *start; | 372 | pud_t *start, *pud_start; |
353 | pgprotval_t prot; | 373 | pgprotval_t prot; |
354 | pud_t *prev_pud = NULL; | 374 | pud_t *prev_pud = NULL; |
355 | 375 | ||
356 | start = (pud_t *)p4d_page_vaddr(addr); | 376 | pud_start = start = (pud_t *)p4d_page_vaddr(addr); |
357 | 377 | ||
358 | for (i = 0; i < PTRS_PER_PUD; i++) { | 378 | for (i = 0; i < PTRS_PER_PUD; i++) { |
359 | st->current_address = normalize_addr(P + i * PUD_LEVEL_MULT); | 379 | st->current_address = normalize_addr(P + i * PUD_LEVEL_MULT); |
360 | if (!pud_none(*start) && | 380 | if (!pud_none(*start)) { |
361 | !pud_already_checked(prev_pud, start, st->check_wx)) { | ||
362 | if (pud_large(*start) || !pud_present(*start)) { | 381 | if (pud_large(*start) || !pud_present(*start)) { |
363 | prot = pud_flags(*start); | 382 | prot = pud_flags(*start); |
364 | note_page(m, st, __pgprot(prot), 2); | 383 | note_page(m, st, __pgprot(prot), 3); |
365 | } else { | 384 | } else if (!kasan_page_table(m, st, pud_start)) { |
366 | walk_pmd_level(m, st, *start, | 385 | walk_pmd_level(m, st, *start, |
367 | P + i * PUD_LEVEL_MULT); | 386 | P + i * PUD_LEVEL_MULT); |
368 | } | 387 | } |
369 | } else | 388 | } else |
370 | note_page(m, st, __pgprot(0), 2); | 389 | note_page(m, st, __pgprot(0), 3); |
371 | 390 | ||
372 | prev_pud = start; | 391 | prev_pud = start; |
373 | start++; | 392 | start++; |
@@ -385,10 +404,10 @@ static void walk_pud_level(struct seq_file *m, struct pg_state *st, p4d_t addr, | |||
385 | static void walk_p4d_level(struct seq_file *m, struct pg_state *st, pgd_t addr, unsigned long P) | 404 | static void walk_p4d_level(struct seq_file *m, struct pg_state *st, pgd_t addr, unsigned long P) |
386 | { | 405 | { |
387 | int i; | 406 | int i; |
388 | p4d_t *start; | 407 | p4d_t *start, *p4d_start; |
389 | pgprotval_t prot; | 408 | pgprotval_t prot; |
390 | 409 | ||
391 | start = (p4d_t *)pgd_page_vaddr(addr); | 410 | p4d_start = start = (p4d_t *)pgd_page_vaddr(addr); |
392 | 411 | ||
393 | for (i = 0; i < PTRS_PER_P4D; i++) { | 412 | for (i = 0; i < PTRS_PER_P4D; i++) { |
394 | st->current_address = normalize_addr(P + i * P4D_LEVEL_MULT); | 413 | st->current_address = normalize_addr(P + i * P4D_LEVEL_MULT); |
@@ -396,7 +415,7 @@ static void walk_p4d_level(struct seq_file *m, struct pg_state *st, pgd_t addr, | |||
396 | if (p4d_large(*start) || !p4d_present(*start)) { | 415 | if (p4d_large(*start) || !p4d_present(*start)) { |
397 | prot = p4d_flags(*start); | 416 | prot = p4d_flags(*start); |
398 | note_page(m, st, __pgprot(prot), 2); | 417 | note_page(m, st, __pgprot(prot), 2); |
399 | } else { | 418 | } else if (!kasan_page_table(m, st, p4d_start)) { |
400 | walk_pud_level(m, st, *start, | 419 | walk_pud_level(m, st, *start, |
401 | P + i * P4D_LEVEL_MULT); | 420 | P + i * P4D_LEVEL_MULT); |
402 | } | 421 | } |
diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c index 2a1fa10c6a98..0cdf14cf3270 100644 --- a/arch/x86/mm/fault.c +++ b/arch/x86/mm/fault.c | |||
@@ -396,14 +396,18 @@ static void dump_pagetable(unsigned long address) | |||
396 | pte_t *pte; | 396 | pte_t *pte; |
397 | 397 | ||
398 | #ifdef CONFIG_X86_PAE | 398 | #ifdef CONFIG_X86_PAE |
399 | printk("*pdpt = %016Lx ", pgd_val(*pgd)); | 399 | pr_info("*pdpt = %016Lx ", pgd_val(*pgd)); |
400 | if (!low_pfn(pgd_val(*pgd) >> PAGE_SHIFT) || !pgd_present(*pgd)) | 400 | if (!low_pfn(pgd_val(*pgd) >> PAGE_SHIFT) || !pgd_present(*pgd)) |
401 | goto out; | 401 | goto out; |
402 | #define pr_pde pr_cont | ||
403 | #else | ||
404 | #define pr_pde pr_info | ||
402 | #endif | 405 | #endif |
403 | p4d = p4d_offset(pgd, address); | 406 | p4d = p4d_offset(pgd, address); |
404 | pud = pud_offset(p4d, address); | 407 | pud = pud_offset(p4d, address); |
405 | pmd = pmd_offset(pud, address); | 408 | pmd = pmd_offset(pud, address); |
406 | printk(KERN_CONT "*pde = %0*Lx ", sizeof(*pmd) * 2, (u64)pmd_val(*pmd)); | 409 | pr_pde("*pde = %0*Lx ", sizeof(*pmd) * 2, (u64)pmd_val(*pmd)); |
410 | #undef pr_pde | ||
407 | 411 | ||
408 | /* | 412 | /* |
409 | * We must not directly access the pte in the highpte | 413 | * We must not directly access the pte in the highpte |
@@ -415,9 +419,9 @@ static void dump_pagetable(unsigned long address) | |||
415 | goto out; | 419 | goto out; |
416 | 420 | ||
417 | pte = pte_offset_kernel(pmd, address); | 421 | pte = pte_offset_kernel(pmd, address); |
418 | printk("*pte = %0*Lx ", sizeof(*pte) * 2, (u64)pte_val(*pte)); | 422 | pr_cont("*pte = %0*Lx ", sizeof(*pte) * 2, (u64)pte_val(*pte)); |
419 | out: | 423 | out: |
420 | printk("\n"); | 424 | pr_cont("\n"); |
421 | } | 425 | } |
422 | 426 | ||
423 | #else /* CONFIG_X86_64: */ | 427 | #else /* CONFIG_X86_64: */ |
@@ -565,7 +569,7 @@ static void dump_pagetable(unsigned long address) | |||
565 | if (bad_address(pgd)) | 569 | if (bad_address(pgd)) |
566 | goto bad; | 570 | goto bad; |
567 | 571 | ||
568 | printk("PGD %lx ", pgd_val(*pgd)); | 572 | pr_info("PGD %lx ", pgd_val(*pgd)); |
569 | 573 | ||
570 | if (!pgd_present(*pgd)) | 574 | if (!pgd_present(*pgd)) |
571 | goto out; | 575 | goto out; |
@@ -574,7 +578,7 @@ static void dump_pagetable(unsigned long address) | |||
574 | if (bad_address(p4d)) | 578 | if (bad_address(p4d)) |
575 | goto bad; | 579 | goto bad; |
576 | 580 | ||
577 | printk("P4D %lx ", p4d_val(*p4d)); | 581 | pr_cont("P4D %lx ", p4d_val(*p4d)); |
578 | if (!p4d_present(*p4d) || p4d_large(*p4d)) | 582 | if (!p4d_present(*p4d) || p4d_large(*p4d)) |
579 | goto out; | 583 | goto out; |
580 | 584 | ||
@@ -582,7 +586,7 @@ static void dump_pagetable(unsigned long address) | |||
582 | if (bad_address(pud)) | 586 | if (bad_address(pud)) |
583 | goto bad; | 587 | goto bad; |
584 | 588 | ||
585 | printk("PUD %lx ", pud_val(*pud)); | 589 | pr_cont("PUD %lx ", pud_val(*pud)); |
586 | if (!pud_present(*pud) || pud_large(*pud)) | 590 | if (!pud_present(*pud) || pud_large(*pud)) |
587 | goto out; | 591 | goto out; |
588 | 592 | ||
@@ -590,7 +594,7 @@ static void dump_pagetable(unsigned long address) | |||
590 | if (bad_address(pmd)) | 594 | if (bad_address(pmd)) |
591 | goto bad; | 595 | goto bad; |
592 | 596 | ||
593 | printk("PMD %lx ", pmd_val(*pmd)); | 597 | pr_cont("PMD %lx ", pmd_val(*pmd)); |
594 | if (!pmd_present(*pmd) || pmd_large(*pmd)) | 598 | if (!pmd_present(*pmd) || pmd_large(*pmd)) |
595 | goto out; | 599 | goto out; |
596 | 600 | ||
@@ -598,12 +602,12 @@ static void dump_pagetable(unsigned long address) | |||
598 | if (bad_address(pte)) | 602 | if (bad_address(pte)) |
599 | goto bad; | 603 | goto bad; |
600 | 604 | ||
601 | printk("PTE %lx", pte_val(*pte)); | 605 | pr_cont("PTE %lx", pte_val(*pte)); |
602 | out: | 606 | out: |
603 | printk("\n"); | 607 | pr_cont("\n"); |
604 | return; | 608 | return; |
605 | bad: | 609 | bad: |
606 | printk("BAD\n"); | 610 | pr_info("BAD\n"); |
607 | } | 611 | } |
608 | 612 | ||
609 | #endif /* CONFIG_X86_64 */ | 613 | #endif /* CONFIG_X86_64 */ |
diff --git a/arch/x86/mm/hugetlbpage.c b/arch/x86/mm/hugetlbpage.c index 2824607df108..6d06cf33e3de 100644 --- a/arch/x86/mm/hugetlbpage.c +++ b/arch/x86/mm/hugetlbpage.c | |||
@@ -18,6 +18,7 @@ | |||
18 | #include <asm/tlbflush.h> | 18 | #include <asm/tlbflush.h> |
19 | #include <asm/pgalloc.h> | 19 | #include <asm/pgalloc.h> |
20 | #include <asm/elf.h> | 20 | #include <asm/elf.h> |
21 | #include <asm/mpx.h> | ||
21 | 22 | ||
22 | #if 0 /* This is just for testing */ | 23 | #if 0 /* This is just for testing */ |
23 | struct page * | 24 | struct page * |
@@ -85,25 +86,38 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file, | |||
85 | info.flags = 0; | 86 | info.flags = 0; |
86 | info.length = len; | 87 | info.length = len; |
87 | info.low_limit = get_mmap_base(1); | 88 | info.low_limit = get_mmap_base(1); |
89 | |||
90 | /* | ||
91 | * If hint address is above DEFAULT_MAP_WINDOW, look for unmapped area | ||
92 | * in the full address space. | ||
93 | */ | ||
88 | info.high_limit = in_compat_syscall() ? | 94 | info.high_limit = in_compat_syscall() ? |
89 | tasksize_32bit() : tasksize_64bit(); | 95 | task_size_32bit() : task_size_64bit(addr > DEFAULT_MAP_WINDOW); |
96 | |||
90 | info.align_mask = PAGE_MASK & ~huge_page_mask(h); | 97 | info.align_mask = PAGE_MASK & ~huge_page_mask(h); |
91 | info.align_offset = 0; | 98 | info.align_offset = 0; |
92 | return vm_unmapped_area(&info); | 99 | return vm_unmapped_area(&info); |
93 | } | 100 | } |
94 | 101 | ||
95 | static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file, | 102 | static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file, |
96 | unsigned long addr0, unsigned long len, | 103 | unsigned long addr, unsigned long len, |
97 | unsigned long pgoff, unsigned long flags) | 104 | unsigned long pgoff, unsigned long flags) |
98 | { | 105 | { |
99 | struct hstate *h = hstate_file(file); | 106 | struct hstate *h = hstate_file(file); |
100 | struct vm_unmapped_area_info info; | 107 | struct vm_unmapped_area_info info; |
101 | unsigned long addr; | ||
102 | 108 | ||
103 | info.flags = VM_UNMAPPED_AREA_TOPDOWN; | 109 | info.flags = VM_UNMAPPED_AREA_TOPDOWN; |
104 | info.length = len; | 110 | info.length = len; |
105 | info.low_limit = PAGE_SIZE; | 111 | info.low_limit = PAGE_SIZE; |
106 | info.high_limit = get_mmap_base(0); | 112 | info.high_limit = get_mmap_base(0); |
113 | |||
114 | /* | ||
115 | * If hint address is above DEFAULT_MAP_WINDOW, look for unmapped area | ||
116 | * in the full address space. | ||
117 | */ | ||
118 | if (addr > DEFAULT_MAP_WINDOW && !in_compat_syscall()) | ||
119 | info.high_limit += TASK_SIZE_MAX - DEFAULT_MAP_WINDOW; | ||
120 | |||
107 | info.align_mask = PAGE_MASK & ~huge_page_mask(h); | 121 | info.align_mask = PAGE_MASK & ~huge_page_mask(h); |
108 | info.align_offset = 0; | 122 | info.align_offset = 0; |
109 | addr = vm_unmapped_area(&info); | 123 | addr = vm_unmapped_area(&info); |
@@ -118,7 +132,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file, | |||
118 | VM_BUG_ON(addr != -ENOMEM); | 132 | VM_BUG_ON(addr != -ENOMEM); |
119 | info.flags = 0; | 133 | info.flags = 0; |
120 | info.low_limit = TASK_UNMAPPED_BASE; | 134 | info.low_limit = TASK_UNMAPPED_BASE; |
121 | info.high_limit = TASK_SIZE; | 135 | info.high_limit = TASK_SIZE_LOW; |
122 | addr = vm_unmapped_area(&info); | 136 | addr = vm_unmapped_area(&info); |
123 | } | 137 | } |
124 | 138 | ||
@@ -135,6 +149,11 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr, | |||
135 | 149 | ||
136 | if (len & ~huge_page_mask(h)) | 150 | if (len & ~huge_page_mask(h)) |
137 | return -EINVAL; | 151 | return -EINVAL; |
152 | |||
153 | addr = mpx_unmapped_area_check(addr, len, flags); | ||
154 | if (IS_ERR_VALUE(addr)) | ||
155 | return addr; | ||
156 | |||
138 | if (len > TASK_SIZE) | 157 | if (len > TASK_SIZE) |
139 | return -ENOMEM; | 158 | return -ENOMEM; |
140 | 159 | ||
diff --git a/arch/x86/mm/ident_map.c b/arch/x86/mm/ident_map.c index adab1595f4bd..31cea988fa36 100644 --- a/arch/x86/mm/ident_map.c +++ b/arch/x86/mm/ident_map.c | |||
@@ -51,7 +51,7 @@ static int ident_pud_init(struct x86_mapping_info *info, pud_t *pud_page, | |||
51 | if (!pmd) | 51 | if (!pmd) |
52 | return -ENOMEM; | 52 | return -ENOMEM; |
53 | ident_pmd_init(info, pmd, addr, next); | 53 | ident_pmd_init(info, pmd, addr, next); |
54 | set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE)); | 54 | set_pud(pud, __pud(__pa(pmd) | info->kernpg_flag)); |
55 | } | 55 | } |
56 | 56 | ||
57 | return 0; | 57 | return 0; |
@@ -79,7 +79,7 @@ static int ident_p4d_init(struct x86_mapping_info *info, p4d_t *p4d_page, | |||
79 | if (!pud) | 79 | if (!pud) |
80 | return -ENOMEM; | 80 | return -ENOMEM; |
81 | ident_pud_init(info, pud, addr, next); | 81 | ident_pud_init(info, pud, addr, next); |
82 | set_p4d(p4d, __p4d(__pa(pud) | _KERNPG_TABLE)); | 82 | set_p4d(p4d, __p4d(__pa(pud) | info->kernpg_flag)); |
83 | } | 83 | } |
84 | 84 | ||
85 | return 0; | 85 | return 0; |
@@ -93,6 +93,10 @@ int kernel_ident_mapping_init(struct x86_mapping_info *info, pgd_t *pgd_page, | |||
93 | unsigned long next; | 93 | unsigned long next; |
94 | int result; | 94 | int result; |
95 | 95 | ||
96 | /* Set the default pagetable flags if not supplied */ | ||
97 | if (!info->kernpg_flag) | ||
98 | info->kernpg_flag = _KERNPG_TABLE; | ||
99 | |||
96 | for (; addr < end; addr = next) { | 100 | for (; addr < end; addr = next) { |
97 | pgd_t *pgd = pgd_page + pgd_index(addr); | 101 | pgd_t *pgd = pgd_page + pgd_index(addr); |
98 | p4d_t *p4d; | 102 | p4d_t *p4d; |
@@ -116,14 +120,14 @@ int kernel_ident_mapping_init(struct x86_mapping_info *info, pgd_t *pgd_page, | |||
116 | if (result) | 120 | if (result) |
117 | return result; | 121 | return result; |
118 | if (IS_ENABLED(CONFIG_X86_5LEVEL)) { | 122 | if (IS_ENABLED(CONFIG_X86_5LEVEL)) { |
119 | set_pgd(pgd, __pgd(__pa(p4d) | _KERNPG_TABLE)); | 123 | set_pgd(pgd, __pgd(__pa(p4d) | info->kernpg_flag)); |
120 | } else { | 124 | } else { |
121 | /* | 125 | /* |
122 | * With p4d folded, pgd is equal to p4d. | 126 | * With p4d folded, pgd is equal to p4d. |
123 | * The pgd entry has to point to the pud page table in this case. | 127 | * The pgd entry has to point to the pud page table in this case. |
124 | */ | 128 | */ |
125 | pud_t *pud = pud_offset(p4d, 0); | 129 | pud_t *pud = pud_offset(p4d, 0); |
126 | set_pgd(pgd, __pgd(__pa(pud) | _KERNPG_TABLE)); | 130 | set_pgd(pgd, __pgd(__pa(pud) | info->kernpg_flag)); |
127 | } | 131 | } |
128 | } | 132 | } |
129 | 133 | ||
diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c index 673541eb3b3f..7777ccc0e9f9 100644 --- a/arch/x86/mm/init.c +++ b/arch/x86/mm/init.c | |||
@@ -18,6 +18,7 @@ | |||
18 | #include <asm/dma.h> /* for MAX_DMA_PFN */ | 18 | #include <asm/dma.h> /* for MAX_DMA_PFN */ |
19 | #include <asm/microcode.h> | 19 | #include <asm/microcode.h> |
20 | #include <asm/kaslr.h> | 20 | #include <asm/kaslr.h> |
21 | #include <asm/hypervisor.h> | ||
21 | 22 | ||
22 | /* | 23 | /* |
23 | * We need to define the tracepoints somewhere, and tlb.c | 24 | * We need to define the tracepoints somewhere, and tlb.c |
@@ -636,6 +637,8 @@ void __init init_mem_mapping(void) | |||
636 | load_cr3(swapper_pg_dir); | 637 | load_cr3(swapper_pg_dir); |
637 | __flush_tlb_all(); | 638 | __flush_tlb_all(); |
638 | 639 | ||
640 | hypervisor_init_mem_mapping(); | ||
641 | |||
639 | early_memtest(0, max_pfn_mapped << PAGE_SHIFT); | 642 | early_memtest(0, max_pfn_mapped << PAGE_SHIFT); |
640 | } | 643 | } |
641 | 644 | ||
@@ -812,7 +815,7 @@ void __init zone_sizes_init(void) | |||
812 | 815 | ||
813 | DEFINE_PER_CPU_SHARED_ALIGNED(struct tlb_state, cpu_tlbstate) = { | 816 | DEFINE_PER_CPU_SHARED_ALIGNED(struct tlb_state, cpu_tlbstate) = { |
814 | .loaded_mm = &init_mm, | 817 | .loaded_mm = &init_mm, |
815 | .state = 0, | 818 | .next_asid = 1, |
816 | .cr4 = ~0UL, /* fail hard if we screw up cr4 shadow initialization */ | 819 | .cr4 = ~0UL, /* fail hard if we screw up cr4 shadow initialization */ |
817 | }; | 820 | }; |
818 | EXPORT_SYMBOL_GPL(cpu_tlbstate); | 821 | EXPORT_SYMBOL_GPL(cpu_tlbstate); |
diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c index 4c1b5fd0c7ad..34f0e1847dd6 100644 --- a/arch/x86/mm/ioremap.c +++ b/arch/x86/mm/ioremap.c | |||
@@ -13,6 +13,8 @@ | |||
13 | #include <linux/slab.h> | 13 | #include <linux/slab.h> |
14 | #include <linux/vmalloc.h> | 14 | #include <linux/vmalloc.h> |
15 | #include <linux/mmiotrace.h> | 15 | #include <linux/mmiotrace.h> |
16 | #include <linux/mem_encrypt.h> | ||
17 | #include <linux/efi.h> | ||
16 | 18 | ||
17 | #include <asm/set_memory.h> | 19 | #include <asm/set_memory.h> |
18 | #include <asm/e820/api.h> | 20 | #include <asm/e820/api.h> |
@@ -21,6 +23,7 @@ | |||
21 | #include <asm/tlbflush.h> | 23 | #include <asm/tlbflush.h> |
22 | #include <asm/pgalloc.h> | 24 | #include <asm/pgalloc.h> |
23 | #include <asm/pat.h> | 25 | #include <asm/pat.h> |
26 | #include <asm/setup.h> | ||
24 | 27 | ||
25 | #include "physaddr.h" | 28 | #include "physaddr.h" |
26 | 29 | ||
@@ -106,12 +109,6 @@ static void __iomem *__ioremap_caller(resource_size_t phys_addr, | |||
106 | } | 109 | } |
107 | 110 | ||
108 | /* | 111 | /* |
109 | * Don't remap the low PCI/ISA area, it's always mapped.. | ||
110 | */ | ||
111 | if (is_ISA_range(phys_addr, last_addr)) | ||
112 | return (__force void __iomem *)phys_to_virt(phys_addr); | ||
113 | |||
114 | /* | ||
115 | * Don't allow anybody to remap normal RAM that we're using.. | 112 | * Don't allow anybody to remap normal RAM that we're using.. |
116 | */ | 113 | */ |
117 | pfn = phys_addr >> PAGE_SHIFT; | 114 | pfn = phys_addr >> PAGE_SHIFT; |
@@ -340,13 +337,17 @@ void iounmap(volatile void __iomem *addr) | |||
340 | return; | 337 | return; |
341 | 338 | ||
342 | /* | 339 | /* |
343 | * __ioremap special-cases the PCI/ISA range by not instantiating a | 340 | * The PCI/ISA range special-casing was removed from __ioremap() |
344 | * vm_area and by simply returning an address into the kernel mapping | 341 | * so this check, in theory, can be removed. However, there are |
345 | * of ISA space. So handle that here. | 342 | * cases where iounmap() is called for addresses not obtained via |
343 | * ioremap() (vga16fb for example). Add a warning so that these | ||
344 | * cases can be caught and fixed. | ||
346 | */ | 345 | */ |
347 | if ((void __force *)addr >= phys_to_virt(ISA_START_ADDRESS) && | 346 | if ((void __force *)addr >= phys_to_virt(ISA_START_ADDRESS) && |
348 | (void __force *)addr < phys_to_virt(ISA_END_ADDRESS)) | 347 | (void __force *)addr < phys_to_virt(ISA_END_ADDRESS)) { |
348 | WARN(1, "iounmap() called for ISA range not obtained using ioremap()\n"); | ||
349 | return; | 349 | return; |
350 | } | ||
350 | 351 | ||
351 | addr = (volatile void __iomem *) | 352 | addr = (volatile void __iomem *) |
352 | (PAGE_MASK & (unsigned long __force)addr); | 353 | (PAGE_MASK & (unsigned long __force)addr); |
@@ -399,12 +400,10 @@ void *xlate_dev_mem_ptr(phys_addr_t phys) | |||
399 | unsigned long offset = phys & ~PAGE_MASK; | 400 | unsigned long offset = phys & ~PAGE_MASK; |
400 | void *vaddr; | 401 | void *vaddr; |
401 | 402 | ||
402 | /* If page is RAM, we can use __va. Otherwise ioremap and unmap. */ | 403 | /* memremap() maps if RAM, otherwise falls back to ioremap() */ |
403 | if (page_is_ram(start >> PAGE_SHIFT)) | 404 | vaddr = memremap(start, PAGE_SIZE, MEMREMAP_WB); |
404 | return __va(phys); | ||
405 | 405 | ||
406 | vaddr = ioremap_cache(start, PAGE_SIZE); | 406 | /* Only add the offset on success and return NULL if memremap() failed */ |
407 | /* Only add the offset on success and return NULL if the ioremap() failed: */ | ||
408 | if (vaddr) | 407 | if (vaddr) |
409 | vaddr += offset; | 408 | vaddr += offset; |
410 | 409 | ||
@@ -413,11 +412,263 @@ void *xlate_dev_mem_ptr(phys_addr_t phys) | |||
413 | 412 | ||
414 | void unxlate_dev_mem_ptr(phys_addr_t phys, void *addr) | 413 | void unxlate_dev_mem_ptr(phys_addr_t phys, void *addr) |
415 | { | 414 | { |
416 | if (page_is_ram(phys >> PAGE_SHIFT)) | 415 | memunmap((void *)((unsigned long)addr & PAGE_MASK)); |
417 | return; | 416 | } |
417 | |||
418 | /* | ||
419 | * Examine the physical address to determine if it is an area of memory | ||
420 | * that should be mapped decrypted. If the memory is not part of the | ||
421 | * kernel usable area it was accessed and created decrypted, so these | ||
422 | * areas should be mapped decrypted. And since the encryption key can | ||
423 | * change across reboots, persistent memory should also be mapped | ||
424 | * decrypted. | ||
425 | */ | ||
426 | static bool memremap_should_map_decrypted(resource_size_t phys_addr, | ||
427 | unsigned long size) | ||
428 | { | ||
429 | int is_pmem; | ||
430 | |||
431 | /* | ||
432 | * Check if the address is part of a persistent memory region. | ||
433 | * This check covers areas added by E820, EFI and ACPI. | ||
434 | */ | ||
435 | is_pmem = region_intersects(phys_addr, size, IORESOURCE_MEM, | ||
436 | IORES_DESC_PERSISTENT_MEMORY); | ||
437 | if (is_pmem != REGION_DISJOINT) | ||
438 | return true; | ||
439 | |||
440 | /* | ||
441 | * Check if the non-volatile attribute is set for an EFI | ||
442 | * reserved area. | ||
443 | */ | ||
444 | if (efi_enabled(EFI_BOOT)) { | ||
445 | switch (efi_mem_type(phys_addr)) { | ||
446 | case EFI_RESERVED_TYPE: | ||
447 | if (efi_mem_attributes(phys_addr) & EFI_MEMORY_NV) | ||
448 | return true; | ||
449 | break; | ||
450 | default: | ||
451 | break; | ||
452 | } | ||
453 | } | ||
454 | |||
455 | /* Check if the address is outside kernel usable area */ | ||
456 | switch (e820__get_entry_type(phys_addr, phys_addr + size - 1)) { | ||
457 | case E820_TYPE_RESERVED: | ||
458 | case E820_TYPE_ACPI: | ||
459 | case E820_TYPE_NVS: | ||
460 | case E820_TYPE_UNUSABLE: | ||
461 | case E820_TYPE_PRAM: | ||
462 | return true; | ||
463 | default: | ||
464 | break; | ||
465 | } | ||
466 | |||
467 | return false; | ||
468 | } | ||
469 | |||
470 | /* | ||
471 | * Examine the physical address to determine if it is EFI data. Check | ||
472 | * it against the boot params structure and EFI tables and memory types. | ||
473 | */ | ||
474 | static bool memremap_is_efi_data(resource_size_t phys_addr, | ||
475 | unsigned long size) | ||
476 | { | ||
477 | u64 paddr; | ||
478 | |||
479 | /* Check if the address is part of EFI boot/runtime data */ | ||
480 | if (!efi_enabled(EFI_BOOT)) | ||
481 | return false; | ||
482 | |||
483 | paddr = boot_params.efi_info.efi_memmap_hi; | ||
484 | paddr <<= 32; | ||
485 | paddr |= boot_params.efi_info.efi_memmap; | ||
486 | if (phys_addr == paddr) | ||
487 | return true; | ||
488 | |||
489 | paddr = boot_params.efi_info.efi_systab_hi; | ||
490 | paddr <<= 32; | ||
491 | paddr |= boot_params.efi_info.efi_systab; | ||
492 | if (phys_addr == paddr) | ||
493 | return true; | ||
494 | |||
495 | if (efi_is_table_address(phys_addr)) | ||
496 | return true; | ||
497 | |||
498 | switch (efi_mem_type(phys_addr)) { | ||
499 | case EFI_BOOT_SERVICES_DATA: | ||
500 | case EFI_RUNTIME_SERVICES_DATA: | ||
501 | return true; | ||
502 | default: | ||
503 | break; | ||
504 | } | ||
505 | |||
506 | return false; | ||
507 | } | ||
508 | |||
509 | /* | ||
510 | * Examine the physical address to determine if it is boot data by checking | ||
511 | * it against the boot params setup_data chain. | ||
512 | */ | ||
513 | static bool memremap_is_setup_data(resource_size_t phys_addr, | ||
514 | unsigned long size) | ||
515 | { | ||
516 | struct setup_data *data; | ||
517 | u64 paddr, paddr_next; | ||
518 | |||
519 | paddr = boot_params.hdr.setup_data; | ||
520 | while (paddr) { | ||
521 | unsigned int len; | ||
522 | |||
523 | if (phys_addr == paddr) | ||
524 | return true; | ||
525 | |||
526 | data = memremap(paddr, sizeof(*data), | ||
527 | MEMREMAP_WB | MEMREMAP_DEC); | ||
528 | |||
529 | paddr_next = data->next; | ||
530 | len = data->len; | ||
531 | |||
532 | memunmap(data); | ||
533 | |||
534 | if ((phys_addr > paddr) && (phys_addr < (paddr + len))) | ||
535 | return true; | ||
536 | |||
537 | paddr = paddr_next; | ||
538 | } | ||
539 | |||
540 | return false; | ||
541 | } | ||
542 | |||
543 | /* | ||
544 | * Examine the physical address to determine if it is boot data by checking | ||
545 | * it against the boot params setup_data chain (early boot version). | ||
546 | */ | ||
547 | static bool __init early_memremap_is_setup_data(resource_size_t phys_addr, | ||
548 | unsigned long size) | ||
549 | { | ||
550 | struct setup_data *data; | ||
551 | u64 paddr, paddr_next; | ||
552 | |||
553 | paddr = boot_params.hdr.setup_data; | ||
554 | while (paddr) { | ||
555 | unsigned int len; | ||
556 | |||
557 | if (phys_addr == paddr) | ||
558 | return true; | ||
559 | |||
560 | data = early_memremap_decrypted(paddr, sizeof(*data)); | ||
561 | |||
562 | paddr_next = data->next; | ||
563 | len = data->len; | ||
564 | |||
565 | early_memunmap(data, sizeof(*data)); | ||
566 | |||
567 | if ((phys_addr > paddr) && (phys_addr < (paddr + len))) | ||
568 | return true; | ||
569 | |||
570 | paddr = paddr_next; | ||
571 | } | ||
572 | |||
573 | return false; | ||
574 | } | ||
575 | |||
576 | /* | ||
577 | * Architecture function to determine if RAM remap is allowed. By default, a | ||
578 | * RAM remap will map the data as encrypted. Determine if a RAM remap should | ||
579 | * not be done so that the data will be mapped decrypted. | ||
580 | */ | ||
581 | bool arch_memremap_can_ram_remap(resource_size_t phys_addr, unsigned long size, | ||
582 | unsigned long flags) | ||
583 | { | ||
584 | if (!sme_active()) | ||
585 | return true; | ||
586 | |||
587 | if (flags & MEMREMAP_ENC) | ||
588 | return true; | ||
589 | |||
590 | if (flags & MEMREMAP_DEC) | ||
591 | return false; | ||
592 | |||
593 | if (memremap_is_setup_data(phys_addr, size) || | ||
594 | memremap_is_efi_data(phys_addr, size) || | ||
595 | memremap_should_map_decrypted(phys_addr, size)) | ||
596 | return false; | ||
597 | |||
598 | return true; | ||
599 | } | ||
600 | |||
601 | /* | ||
602 | * Architecture override of __weak function to adjust the protection attributes | ||
603 | * used when remapping memory. By default, early_memremap() will map the data | ||
604 | * as encrypted. Determine if an encrypted mapping should not be done and set | ||
605 | * the appropriate protection attributes. | ||
606 | */ | ||
607 | pgprot_t __init early_memremap_pgprot_adjust(resource_size_t phys_addr, | ||
608 | unsigned long size, | ||
609 | pgprot_t prot) | ||
610 | { | ||
611 | if (!sme_active()) | ||
612 | return prot; | ||
613 | |||
614 | if (early_memremap_is_setup_data(phys_addr, size) || | ||
615 | memremap_is_efi_data(phys_addr, size) || | ||
616 | memremap_should_map_decrypted(phys_addr, size)) | ||
617 | prot = pgprot_decrypted(prot); | ||
618 | else | ||
619 | prot = pgprot_encrypted(prot); | ||
620 | |||
621 | return prot; | ||
622 | } | ||
623 | |||
624 | bool phys_mem_access_encrypted(unsigned long phys_addr, unsigned long size) | ||
625 | { | ||
626 | return arch_memremap_can_ram_remap(phys_addr, size, 0); | ||
627 | } | ||
628 | |||
629 | #ifdef CONFIG_ARCH_USE_MEMREMAP_PROT | ||
630 | /* Remap memory with encryption */ | ||
631 | void __init *early_memremap_encrypted(resource_size_t phys_addr, | ||
632 | unsigned long size) | ||
633 | { | ||
634 | return early_memremap_prot(phys_addr, size, __PAGE_KERNEL_ENC); | ||
635 | } | ||
636 | |||
637 | /* | ||
638 | * Remap memory with encryption and write-protected - cannot be called | ||
639 | * before pat_init() is called | ||
640 | */ | ||
641 | void __init *early_memremap_encrypted_wp(resource_size_t phys_addr, | ||
642 | unsigned long size) | ||
643 | { | ||
644 | /* Be sure the write-protect PAT entry is set for write-protect */ | ||
645 | if (__pte2cachemode_tbl[_PAGE_CACHE_MODE_WP] != _PAGE_CACHE_MODE_WP) | ||
646 | return NULL; | ||
647 | |||
648 | return early_memremap_prot(phys_addr, size, __PAGE_KERNEL_ENC_WP); | ||
649 | } | ||
650 | |||
651 | /* Remap memory without encryption */ | ||
652 | void __init *early_memremap_decrypted(resource_size_t phys_addr, | ||
653 | unsigned long size) | ||
654 | { | ||
655 | return early_memremap_prot(phys_addr, size, __PAGE_KERNEL_NOENC); | ||
656 | } | ||
657 | |||
658 | /* | ||
659 | * Remap memory without encryption and write-protected - cannot be called | ||
660 | * before pat_init() is called | ||
661 | */ | ||
662 | void __init *early_memremap_decrypted_wp(resource_size_t phys_addr, | ||
663 | unsigned long size) | ||
664 | { | ||
665 | /* Be sure the write-protect PAT entry is set for write-protect */ | ||
666 | if (__pte2cachemode_tbl[_PAGE_CACHE_MODE_WP] != _PAGE_CACHE_MODE_WP) | ||
667 | return NULL; | ||
418 | 668 | ||
419 | iounmap((void __iomem *)((unsigned long)addr & PAGE_MASK)); | 669 | return early_memremap_prot(phys_addr, size, __PAGE_KERNEL_NOENC_WP); |
420 | } | 670 | } |
671 | #endif /* CONFIG_ARCH_USE_MEMREMAP_PROT */ | ||
421 | 672 | ||
422 | static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __page_aligned_bss; | 673 | static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __page_aligned_bss; |
423 | 674 | ||
diff --git a/arch/x86/mm/kasan_init_64.c b/arch/x86/mm/kasan_init_64.c index 02c9d7553409..bc84b73684b7 100644 --- a/arch/x86/mm/kasan_init_64.c +++ b/arch/x86/mm/kasan_init_64.c | |||
@@ -11,8 +11,8 @@ | |||
11 | #include <asm/e820/types.h> | 11 | #include <asm/e820/types.h> |
12 | #include <asm/tlbflush.h> | 12 | #include <asm/tlbflush.h> |
13 | #include <asm/sections.h> | 13 | #include <asm/sections.h> |
14 | #include <asm/pgtable.h> | ||
14 | 15 | ||
15 | extern pgd_t early_top_pgt[PTRS_PER_PGD]; | ||
16 | extern struct range pfn_mapped[E820_MAX_ENTRIES]; | 16 | extern struct range pfn_mapped[E820_MAX_ENTRIES]; |
17 | 17 | ||
18 | static int __init map_range(struct range *range) | 18 | static int __init map_range(struct range *range) |
@@ -87,7 +87,7 @@ static struct notifier_block kasan_die_notifier = { | |||
87 | void __init kasan_early_init(void) | 87 | void __init kasan_early_init(void) |
88 | { | 88 | { |
89 | int i; | 89 | int i; |
90 | pteval_t pte_val = __pa_nodebug(kasan_zero_page) | __PAGE_KERNEL; | 90 | pteval_t pte_val = __pa_nodebug(kasan_zero_page) | __PAGE_KERNEL | _PAGE_ENC; |
91 | pmdval_t pmd_val = __pa_nodebug(kasan_zero_pte) | _KERNPG_TABLE; | 91 | pmdval_t pmd_val = __pa_nodebug(kasan_zero_pte) | _KERNPG_TABLE; |
92 | pudval_t pud_val = __pa_nodebug(kasan_zero_pmd) | _KERNPG_TABLE; | 92 | pudval_t pud_val = __pa_nodebug(kasan_zero_pmd) | _KERNPG_TABLE; |
93 | p4dval_t p4d_val = __pa_nodebug(kasan_zero_pud) | _KERNPG_TABLE; | 93 | p4dval_t p4d_val = __pa_nodebug(kasan_zero_pud) | _KERNPG_TABLE; |
@@ -153,7 +153,7 @@ void __init kasan_init(void) | |||
153 | */ | 153 | */ |
154 | memset(kasan_zero_page, 0, PAGE_SIZE); | 154 | memset(kasan_zero_page, 0, PAGE_SIZE); |
155 | for (i = 0; i < PTRS_PER_PTE; i++) { | 155 | for (i = 0; i < PTRS_PER_PTE; i++) { |
156 | pte_t pte = __pte(__pa(kasan_zero_page) | __PAGE_KERNEL_RO); | 156 | pte_t pte = __pte(__pa(kasan_zero_page) | __PAGE_KERNEL_RO | _PAGE_ENC); |
157 | set_pte(&kasan_zero_pte[i], pte); | 157 | set_pte(&kasan_zero_pte[i], pte); |
158 | } | 158 | } |
159 | /* Flush TLBs again to be sure that write protection applied. */ | 159 | /* Flush TLBs again to be sure that write protection applied. */ |
diff --git a/arch/x86/mm/mem_encrypt.c b/arch/x86/mm/mem_encrypt.c new file mode 100644 index 000000000000..0fbd09269757 --- /dev/null +++ b/arch/x86/mm/mem_encrypt.c | |||
@@ -0,0 +1,593 @@ | |||
1 | /* | ||
2 | * AMD Memory Encryption Support | ||
3 | * | ||
4 | * Copyright (C) 2016 Advanced Micro Devices, Inc. | ||
5 | * | ||
6 | * Author: Tom Lendacky <thomas.lendacky@amd.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License version 2 as | ||
10 | * published by the Free Software Foundation. | ||
11 | */ | ||
12 | |||
13 | #include <linux/linkage.h> | ||
14 | #include <linux/init.h> | ||
15 | #include <linux/mm.h> | ||
16 | #include <linux/dma-mapping.h> | ||
17 | #include <linux/swiotlb.h> | ||
18 | #include <linux/mem_encrypt.h> | ||
19 | |||
20 | #include <asm/tlbflush.h> | ||
21 | #include <asm/fixmap.h> | ||
22 | #include <asm/setup.h> | ||
23 | #include <asm/bootparam.h> | ||
24 | #include <asm/set_memory.h> | ||
25 | #include <asm/cacheflush.h> | ||
26 | #include <asm/sections.h> | ||
27 | #include <asm/processor-flags.h> | ||
28 | #include <asm/msr.h> | ||
29 | #include <asm/cmdline.h> | ||
30 | |||
31 | static char sme_cmdline_arg[] __initdata = "mem_encrypt"; | ||
32 | static char sme_cmdline_on[] __initdata = "on"; | ||
33 | static char sme_cmdline_off[] __initdata = "off"; | ||
34 | |||
35 | /* | ||
36 | * Since SME related variables are set early in the boot process they must | ||
37 | * reside in the .data section so as not to be zeroed out when the .bss | ||
38 | * section is later cleared. | ||
39 | */ | ||
40 | unsigned long sme_me_mask __section(.data) = 0; | ||
41 | EXPORT_SYMBOL_GPL(sme_me_mask); | ||
42 | |||
43 | /* Buffer used for early in-place encryption by BSP, no locking needed */ | ||
44 | static char sme_early_buffer[PAGE_SIZE] __aligned(PAGE_SIZE); | ||
45 | |||
46 | /* | ||
47 | * This routine does not change the underlying encryption setting of the | ||
48 | * page(s) that map this memory. It assumes that eventually the memory is | ||
49 | * meant to be accessed as either encrypted or decrypted but the contents | ||
50 | * are currently not in the desired state. | ||
51 | * | ||
52 | * This routine follows the steps outlined in the AMD64 Architecture | ||
53 | * Programmer's Manual Volume 2, Section 7.10.8 Encrypt-in-Place. | ||
54 | */ | ||
55 | static void __init __sme_early_enc_dec(resource_size_t paddr, | ||
56 | unsigned long size, bool enc) | ||
57 | { | ||
58 | void *src, *dst; | ||
59 | size_t len; | ||
60 | |||
61 | if (!sme_me_mask) | ||
62 | return; | ||
63 | |||
64 | local_flush_tlb(); | ||
65 | wbinvd(); | ||
66 | |||
67 | /* | ||
68 | * There are limited number of early mapping slots, so map (at most) | ||
69 | * one page at time. | ||
70 | */ | ||
71 | while (size) { | ||
72 | len = min_t(size_t, sizeof(sme_early_buffer), size); | ||
73 | |||
74 | /* | ||
75 | * Create mappings for the current and desired format of | ||
76 | * the memory. Use a write-protected mapping for the source. | ||
77 | */ | ||
78 | src = enc ? early_memremap_decrypted_wp(paddr, len) : | ||
79 | early_memremap_encrypted_wp(paddr, len); | ||
80 | |||
81 | dst = enc ? early_memremap_encrypted(paddr, len) : | ||
82 | early_memremap_decrypted(paddr, len); | ||
83 | |||
84 | /* | ||
85 | * If a mapping can't be obtained to perform the operation, | ||
86 | * then eventual access of that area in the desired mode | ||
87 | * will cause a crash. | ||
88 | */ | ||
89 | BUG_ON(!src || !dst); | ||
90 | |||
91 | /* | ||
92 | * Use a temporary buffer, of cache-line multiple size, to | ||
93 | * avoid data corruption as documented in the APM. | ||
94 | */ | ||
95 | memcpy(sme_early_buffer, src, len); | ||
96 | memcpy(dst, sme_early_buffer, len); | ||
97 | |||
98 | early_memunmap(dst, len); | ||
99 | early_memunmap(src, len); | ||
100 | |||
101 | paddr += len; | ||
102 | size -= len; | ||
103 | } | ||
104 | } | ||
105 | |||
106 | void __init sme_early_encrypt(resource_size_t paddr, unsigned long size) | ||
107 | { | ||
108 | __sme_early_enc_dec(paddr, size, true); | ||
109 | } | ||
110 | |||
111 | void __init sme_early_decrypt(resource_size_t paddr, unsigned long size) | ||
112 | { | ||
113 | __sme_early_enc_dec(paddr, size, false); | ||
114 | } | ||
115 | |||
116 | static void __init __sme_early_map_unmap_mem(void *vaddr, unsigned long size, | ||
117 | bool map) | ||
118 | { | ||
119 | unsigned long paddr = (unsigned long)vaddr - __PAGE_OFFSET; | ||
120 | pmdval_t pmd_flags, pmd; | ||
121 | |||
122 | /* Use early_pmd_flags but remove the encryption mask */ | ||
123 | pmd_flags = __sme_clr(early_pmd_flags); | ||
124 | |||
125 | do { | ||
126 | pmd = map ? (paddr & PMD_MASK) + pmd_flags : 0; | ||
127 | __early_make_pgtable((unsigned long)vaddr, pmd); | ||
128 | |||
129 | vaddr += PMD_SIZE; | ||
130 | paddr += PMD_SIZE; | ||
131 | size = (size <= PMD_SIZE) ? 0 : size - PMD_SIZE; | ||
132 | } while (size); | ||
133 | |||
134 | __native_flush_tlb(); | ||
135 | } | ||
136 | |||
137 | void __init sme_unmap_bootdata(char *real_mode_data) | ||
138 | { | ||
139 | struct boot_params *boot_data; | ||
140 | unsigned long cmdline_paddr; | ||
141 | |||
142 | if (!sme_active()) | ||
143 | return; | ||
144 | |||
145 | /* Get the command line address before unmapping the real_mode_data */ | ||
146 | boot_data = (struct boot_params *)real_mode_data; | ||
147 | cmdline_paddr = boot_data->hdr.cmd_line_ptr | ((u64)boot_data->ext_cmd_line_ptr << 32); | ||
148 | |||
149 | __sme_early_map_unmap_mem(real_mode_data, sizeof(boot_params), false); | ||
150 | |||
151 | if (!cmdline_paddr) | ||
152 | return; | ||
153 | |||
154 | __sme_early_map_unmap_mem(__va(cmdline_paddr), COMMAND_LINE_SIZE, false); | ||
155 | } | ||
156 | |||
157 | void __init sme_map_bootdata(char *real_mode_data) | ||
158 | { | ||
159 | struct boot_params *boot_data; | ||
160 | unsigned long cmdline_paddr; | ||
161 | |||
162 | if (!sme_active()) | ||
163 | return; | ||
164 | |||
165 | __sme_early_map_unmap_mem(real_mode_data, sizeof(boot_params), true); | ||
166 | |||
167 | /* Get the command line address after mapping the real_mode_data */ | ||
168 | boot_data = (struct boot_params *)real_mode_data; | ||
169 | cmdline_paddr = boot_data->hdr.cmd_line_ptr | ((u64)boot_data->ext_cmd_line_ptr << 32); | ||
170 | |||
171 | if (!cmdline_paddr) | ||
172 | return; | ||
173 | |||
174 | __sme_early_map_unmap_mem(__va(cmdline_paddr), COMMAND_LINE_SIZE, true); | ||
175 | } | ||
176 | |||
177 | void __init sme_early_init(void) | ||
178 | { | ||
179 | unsigned int i; | ||
180 | |||
181 | if (!sme_me_mask) | ||
182 | return; | ||
183 | |||
184 | early_pmd_flags = __sme_set(early_pmd_flags); | ||
185 | |||
186 | __supported_pte_mask = __sme_set(__supported_pte_mask); | ||
187 | |||
188 | /* Update the protection map with memory encryption mask */ | ||
189 | for (i = 0; i < ARRAY_SIZE(protection_map); i++) | ||
190 | protection_map[i] = pgprot_encrypted(protection_map[i]); | ||
191 | } | ||
192 | |||
193 | /* Architecture __weak replacement functions */ | ||
194 | void __init mem_encrypt_init(void) | ||
195 | { | ||
196 | if (!sme_me_mask) | ||
197 | return; | ||
198 | |||
199 | /* Call into SWIOTLB to update the SWIOTLB DMA buffers */ | ||
200 | swiotlb_update_mem_attributes(); | ||
201 | |||
202 | pr_info("AMD Secure Memory Encryption (SME) active\n"); | ||
203 | } | ||
204 | |||
205 | void swiotlb_set_mem_attributes(void *vaddr, unsigned long size) | ||
206 | { | ||
207 | WARN(PAGE_ALIGN(size) != size, | ||
208 | "size is not page-aligned (%#lx)\n", size); | ||
209 | |||
210 | /* Make the SWIOTLB buffer area decrypted */ | ||
211 | set_memory_decrypted((unsigned long)vaddr, size >> PAGE_SHIFT); | ||
212 | } | ||
213 | |||
214 | static void __init sme_clear_pgd(pgd_t *pgd_base, unsigned long start, | ||
215 | unsigned long end) | ||
216 | { | ||
217 | unsigned long pgd_start, pgd_end, pgd_size; | ||
218 | pgd_t *pgd_p; | ||
219 | |||
220 | pgd_start = start & PGDIR_MASK; | ||
221 | pgd_end = end & PGDIR_MASK; | ||
222 | |||
223 | pgd_size = (((pgd_end - pgd_start) / PGDIR_SIZE) + 1); | ||
224 | pgd_size *= sizeof(pgd_t); | ||
225 | |||
226 | pgd_p = pgd_base + pgd_index(start); | ||
227 | |||
228 | memset(pgd_p, 0, pgd_size); | ||
229 | } | ||
230 | |||
231 | #define PGD_FLAGS _KERNPG_TABLE_NOENC | ||
232 | #define P4D_FLAGS _KERNPG_TABLE_NOENC | ||
233 | #define PUD_FLAGS _KERNPG_TABLE_NOENC | ||
234 | #define PMD_FLAGS (__PAGE_KERNEL_LARGE_EXEC & ~_PAGE_GLOBAL) | ||
235 | |||
236 | static void __init *sme_populate_pgd(pgd_t *pgd_base, void *pgtable_area, | ||
237 | unsigned long vaddr, pmdval_t pmd_val) | ||
238 | { | ||
239 | pgd_t *pgd_p; | ||
240 | p4d_t *p4d_p; | ||
241 | pud_t *pud_p; | ||
242 | pmd_t *pmd_p; | ||
243 | |||
244 | pgd_p = pgd_base + pgd_index(vaddr); | ||
245 | if (native_pgd_val(*pgd_p)) { | ||
246 | if (IS_ENABLED(CONFIG_X86_5LEVEL)) | ||
247 | p4d_p = (p4d_t *)(native_pgd_val(*pgd_p) & ~PTE_FLAGS_MASK); | ||
248 | else | ||
249 | pud_p = (pud_t *)(native_pgd_val(*pgd_p) & ~PTE_FLAGS_MASK); | ||
250 | } else { | ||
251 | pgd_t pgd; | ||
252 | |||
253 | if (IS_ENABLED(CONFIG_X86_5LEVEL)) { | ||
254 | p4d_p = pgtable_area; | ||
255 | memset(p4d_p, 0, sizeof(*p4d_p) * PTRS_PER_P4D); | ||
256 | pgtable_area += sizeof(*p4d_p) * PTRS_PER_P4D; | ||
257 | |||
258 | pgd = native_make_pgd((pgdval_t)p4d_p + PGD_FLAGS); | ||
259 | } else { | ||
260 | pud_p = pgtable_area; | ||
261 | memset(pud_p, 0, sizeof(*pud_p) * PTRS_PER_PUD); | ||
262 | pgtable_area += sizeof(*pud_p) * PTRS_PER_PUD; | ||
263 | |||
264 | pgd = native_make_pgd((pgdval_t)pud_p + PGD_FLAGS); | ||
265 | } | ||
266 | native_set_pgd(pgd_p, pgd); | ||
267 | } | ||
268 | |||
269 | if (IS_ENABLED(CONFIG_X86_5LEVEL)) { | ||
270 | p4d_p += p4d_index(vaddr); | ||
271 | if (native_p4d_val(*p4d_p)) { | ||
272 | pud_p = (pud_t *)(native_p4d_val(*p4d_p) & ~PTE_FLAGS_MASK); | ||
273 | } else { | ||
274 | p4d_t p4d; | ||
275 | |||
276 | pud_p = pgtable_area; | ||
277 | memset(pud_p, 0, sizeof(*pud_p) * PTRS_PER_PUD); | ||
278 | pgtable_area += sizeof(*pud_p) * PTRS_PER_PUD; | ||
279 | |||
280 | p4d = native_make_p4d((pudval_t)pud_p + P4D_FLAGS); | ||
281 | native_set_p4d(p4d_p, p4d); | ||
282 | } | ||
283 | } | ||
284 | |||
285 | pud_p += pud_index(vaddr); | ||
286 | if (native_pud_val(*pud_p)) { | ||
287 | if (native_pud_val(*pud_p) & _PAGE_PSE) | ||
288 | goto out; | ||
289 | |||
290 | pmd_p = (pmd_t *)(native_pud_val(*pud_p) & ~PTE_FLAGS_MASK); | ||
291 | } else { | ||
292 | pud_t pud; | ||
293 | |||
294 | pmd_p = pgtable_area; | ||
295 | memset(pmd_p, 0, sizeof(*pmd_p) * PTRS_PER_PMD); | ||
296 | pgtable_area += sizeof(*pmd_p) * PTRS_PER_PMD; | ||
297 | |||
298 | pud = native_make_pud((pmdval_t)pmd_p + PUD_FLAGS); | ||
299 | native_set_pud(pud_p, pud); | ||
300 | } | ||
301 | |||
302 | pmd_p += pmd_index(vaddr); | ||
303 | if (!native_pmd_val(*pmd_p) || !(native_pmd_val(*pmd_p) & _PAGE_PSE)) | ||
304 | native_set_pmd(pmd_p, native_make_pmd(pmd_val)); | ||
305 | |||
306 | out: | ||
307 | return pgtable_area; | ||
308 | } | ||
309 | |||
310 | static unsigned long __init sme_pgtable_calc(unsigned long len) | ||
311 | { | ||
312 | unsigned long p4d_size, pud_size, pmd_size; | ||
313 | unsigned long total; | ||
314 | |||
315 | /* | ||
316 | * Perform a relatively simplistic calculation of the pagetable | ||
317 | * entries that are needed. That mappings will be covered by 2MB | ||
318 | * PMD entries so we can conservatively calculate the required | ||
319 | * number of P4D, PUD and PMD structures needed to perform the | ||
320 | * mappings. Incrementing the count for each covers the case where | ||
321 | * the addresses cross entries. | ||
322 | */ | ||
323 | if (IS_ENABLED(CONFIG_X86_5LEVEL)) { | ||
324 | p4d_size = (ALIGN(len, PGDIR_SIZE) / PGDIR_SIZE) + 1; | ||
325 | p4d_size *= sizeof(p4d_t) * PTRS_PER_P4D; | ||
326 | pud_size = (ALIGN(len, P4D_SIZE) / P4D_SIZE) + 1; | ||
327 | pud_size *= sizeof(pud_t) * PTRS_PER_PUD; | ||
328 | } else { | ||
329 | p4d_size = 0; | ||
330 | pud_size = (ALIGN(len, PGDIR_SIZE) / PGDIR_SIZE) + 1; | ||
331 | pud_size *= sizeof(pud_t) * PTRS_PER_PUD; | ||
332 | } | ||
333 | pmd_size = (ALIGN(len, PUD_SIZE) / PUD_SIZE) + 1; | ||
334 | pmd_size *= sizeof(pmd_t) * PTRS_PER_PMD; | ||
335 | |||
336 | total = p4d_size + pud_size + pmd_size; | ||
337 | |||
338 | /* | ||
339 | * Now calculate the added pagetable structures needed to populate | ||
340 | * the new pagetables. | ||
341 | */ | ||
342 | if (IS_ENABLED(CONFIG_X86_5LEVEL)) { | ||
343 | p4d_size = ALIGN(total, PGDIR_SIZE) / PGDIR_SIZE; | ||
344 | p4d_size *= sizeof(p4d_t) * PTRS_PER_P4D; | ||
345 | pud_size = ALIGN(total, P4D_SIZE) / P4D_SIZE; | ||
346 | pud_size *= sizeof(pud_t) * PTRS_PER_PUD; | ||
347 | } else { | ||
348 | p4d_size = 0; | ||
349 | pud_size = ALIGN(total, PGDIR_SIZE) / PGDIR_SIZE; | ||
350 | pud_size *= sizeof(pud_t) * PTRS_PER_PUD; | ||
351 | } | ||
352 | pmd_size = ALIGN(total, PUD_SIZE) / PUD_SIZE; | ||
353 | pmd_size *= sizeof(pmd_t) * PTRS_PER_PMD; | ||
354 | |||
355 | total += p4d_size + pud_size + pmd_size; | ||
356 | |||
357 | return total; | ||
358 | } | ||
359 | |||
360 | void __init sme_encrypt_kernel(void) | ||
361 | { | ||
362 | unsigned long workarea_start, workarea_end, workarea_len; | ||
363 | unsigned long execute_start, execute_end, execute_len; | ||
364 | unsigned long kernel_start, kernel_end, kernel_len; | ||
365 | unsigned long pgtable_area_len; | ||
366 | unsigned long paddr, pmd_flags; | ||
367 | unsigned long decrypted_base; | ||
368 | void *pgtable_area; | ||
369 | pgd_t *pgd; | ||
370 | |||
371 | if (!sme_active()) | ||
372 | return; | ||
373 | |||
374 | /* | ||
375 | * Prepare for encrypting the kernel by building new pagetables with | ||
376 | * the necessary attributes needed to encrypt the kernel in place. | ||
377 | * | ||
378 | * One range of virtual addresses will map the memory occupied | ||
379 | * by the kernel as encrypted. | ||
380 | * | ||
381 | * Another range of virtual addresses will map the memory occupied | ||
382 | * by the kernel as decrypted and write-protected. | ||
383 | * | ||
384 | * The use of write-protect attribute will prevent any of the | ||
385 | * memory from being cached. | ||
386 | */ | ||
387 | |||
388 | /* Physical addresses gives us the identity mapped virtual addresses */ | ||
389 | kernel_start = __pa_symbol(_text); | ||
390 | kernel_end = ALIGN(__pa_symbol(_end), PMD_PAGE_SIZE); | ||
391 | kernel_len = kernel_end - kernel_start; | ||
392 | |||
393 | /* Set the encryption workarea to be immediately after the kernel */ | ||
394 | workarea_start = kernel_end; | ||
395 | |||
396 | /* | ||
397 | * Calculate required number of workarea bytes needed: | ||
398 | * executable encryption area size: | ||
399 | * stack page (PAGE_SIZE) | ||
400 | * encryption routine page (PAGE_SIZE) | ||
401 | * intermediate copy buffer (PMD_PAGE_SIZE) | ||
402 | * pagetable structures for the encryption of the kernel | ||
403 | * pagetable structures for workarea (in case not currently mapped) | ||
404 | */ | ||
405 | execute_start = workarea_start; | ||
406 | execute_end = execute_start + (PAGE_SIZE * 2) + PMD_PAGE_SIZE; | ||
407 | execute_len = execute_end - execute_start; | ||
408 | |||
409 | /* | ||
410 | * One PGD for both encrypted and decrypted mappings and a set of | ||
411 | * PUDs and PMDs for each of the encrypted and decrypted mappings. | ||
412 | */ | ||
413 | pgtable_area_len = sizeof(pgd_t) * PTRS_PER_PGD; | ||
414 | pgtable_area_len += sme_pgtable_calc(execute_end - kernel_start) * 2; | ||
415 | |||
416 | /* PUDs and PMDs needed in the current pagetables for the workarea */ | ||
417 | pgtable_area_len += sme_pgtable_calc(execute_len + pgtable_area_len); | ||
418 | |||
419 | /* | ||
420 | * The total workarea includes the executable encryption area and | ||
421 | * the pagetable area. | ||
422 | */ | ||
423 | workarea_len = execute_len + pgtable_area_len; | ||
424 | workarea_end = workarea_start + workarea_len; | ||
425 | |||
426 | /* | ||
427 | * Set the address to the start of where newly created pagetable | ||
428 | * structures (PGDs, PUDs and PMDs) will be allocated. New pagetable | ||
429 | * structures are created when the workarea is added to the current | ||
430 | * pagetables and when the new encrypted and decrypted kernel | ||
431 | * mappings are populated. | ||
432 | */ | ||
433 | pgtable_area = (void *)execute_end; | ||
434 | |||
435 | /* | ||
436 | * Make sure the current pagetable structure has entries for | ||
437 | * addressing the workarea. | ||
438 | */ | ||
439 | pgd = (pgd_t *)native_read_cr3_pa(); | ||
440 | paddr = workarea_start; | ||
441 | while (paddr < workarea_end) { | ||
442 | pgtable_area = sme_populate_pgd(pgd, pgtable_area, | ||
443 | paddr, | ||
444 | paddr + PMD_FLAGS); | ||
445 | |||
446 | paddr += PMD_PAGE_SIZE; | ||
447 | } | ||
448 | |||
449 | /* Flush the TLB - no globals so cr3 is enough */ | ||
450 | native_write_cr3(__native_read_cr3()); | ||
451 | |||
452 | /* | ||
453 | * A new pagetable structure is being built to allow for the kernel | ||
454 | * to be encrypted. It starts with an empty PGD that will then be | ||
455 | * populated with new PUDs and PMDs as the encrypted and decrypted | ||
456 | * kernel mappings are created. | ||
457 | */ | ||
458 | pgd = pgtable_area; | ||
459 | memset(pgd, 0, sizeof(*pgd) * PTRS_PER_PGD); | ||
460 | pgtable_area += sizeof(*pgd) * PTRS_PER_PGD; | ||
461 | |||
462 | /* Add encrypted kernel (identity) mappings */ | ||
463 | pmd_flags = PMD_FLAGS | _PAGE_ENC; | ||
464 | paddr = kernel_start; | ||
465 | while (paddr < kernel_end) { | ||
466 | pgtable_area = sme_populate_pgd(pgd, pgtable_area, | ||
467 | paddr, | ||
468 | paddr + pmd_flags); | ||
469 | |||
470 | paddr += PMD_PAGE_SIZE; | ||
471 | } | ||
472 | |||
473 | /* | ||
474 | * A different PGD index/entry must be used to get different | ||
475 | * pagetable entries for the decrypted mapping. Choose the next | ||
476 | * PGD index and convert it to a virtual address to be used as | ||
477 | * the base of the mapping. | ||
478 | */ | ||
479 | decrypted_base = (pgd_index(workarea_end) + 1) & (PTRS_PER_PGD - 1); | ||
480 | decrypted_base <<= PGDIR_SHIFT; | ||
481 | |||
482 | /* Add decrypted, write-protected kernel (non-identity) mappings */ | ||
483 | pmd_flags = (PMD_FLAGS & ~_PAGE_CACHE_MASK) | (_PAGE_PAT | _PAGE_PWT); | ||
484 | paddr = kernel_start; | ||
485 | while (paddr < kernel_end) { | ||
486 | pgtable_area = sme_populate_pgd(pgd, pgtable_area, | ||
487 | paddr + decrypted_base, | ||
488 | paddr + pmd_flags); | ||
489 | |||
490 | paddr += PMD_PAGE_SIZE; | ||
491 | } | ||
492 | |||
493 | /* Add decrypted workarea mappings to both kernel mappings */ | ||
494 | paddr = workarea_start; | ||
495 | while (paddr < workarea_end) { | ||
496 | pgtable_area = sme_populate_pgd(pgd, pgtable_area, | ||
497 | paddr, | ||
498 | paddr + PMD_FLAGS); | ||
499 | |||
500 | pgtable_area = sme_populate_pgd(pgd, pgtable_area, | ||
501 | paddr + decrypted_base, | ||
502 | paddr + PMD_FLAGS); | ||
503 | |||
504 | paddr += PMD_PAGE_SIZE; | ||
505 | } | ||
506 | |||
507 | /* Perform the encryption */ | ||
508 | sme_encrypt_execute(kernel_start, kernel_start + decrypted_base, | ||
509 | kernel_len, workarea_start, (unsigned long)pgd); | ||
510 | |||
511 | /* | ||
512 | * At this point we are running encrypted. Remove the mappings for | ||
513 | * the decrypted areas - all that is needed for this is to remove | ||
514 | * the PGD entry/entries. | ||
515 | */ | ||
516 | sme_clear_pgd(pgd, kernel_start + decrypted_base, | ||
517 | kernel_end + decrypted_base); | ||
518 | |||
519 | sme_clear_pgd(pgd, workarea_start + decrypted_base, | ||
520 | workarea_end + decrypted_base); | ||
521 | |||
522 | /* Flush the TLB - no globals so cr3 is enough */ | ||
523 | native_write_cr3(__native_read_cr3()); | ||
524 | } | ||
525 | |||
526 | void __init __nostackprotector sme_enable(struct boot_params *bp) | ||
527 | { | ||
528 | const char *cmdline_ptr, *cmdline_arg, *cmdline_on, *cmdline_off; | ||
529 | unsigned int eax, ebx, ecx, edx; | ||
530 | bool active_by_default; | ||
531 | unsigned long me_mask; | ||
532 | char buffer[16]; | ||
533 | u64 msr; | ||
534 | |||
535 | /* Check for the SME support leaf */ | ||
536 | eax = 0x80000000; | ||
537 | ecx = 0; | ||
538 | native_cpuid(&eax, &ebx, &ecx, &edx); | ||
539 | if (eax < 0x8000001f) | ||
540 | return; | ||
541 | |||
542 | /* | ||
543 | * Check for the SME feature: | ||
544 | * CPUID Fn8000_001F[EAX] - Bit 0 | ||
545 | * Secure Memory Encryption support | ||
546 | * CPUID Fn8000_001F[EBX] - Bits 5:0 | ||
547 | * Pagetable bit position used to indicate encryption | ||
548 | */ | ||
549 | eax = 0x8000001f; | ||
550 | ecx = 0; | ||
551 | native_cpuid(&eax, &ebx, &ecx, &edx); | ||
552 | if (!(eax & 1)) | ||
553 | return; | ||
554 | |||
555 | me_mask = 1UL << (ebx & 0x3f); | ||
556 | |||
557 | /* Check if SME is enabled */ | ||
558 | msr = __rdmsr(MSR_K8_SYSCFG); | ||
559 | if (!(msr & MSR_K8_SYSCFG_MEM_ENCRYPT)) | ||
560 | return; | ||
561 | |||
562 | /* | ||
563 | * Fixups have not been applied to phys_base yet and we're running | ||
564 | * identity mapped, so we must obtain the address to the SME command | ||
565 | * line argument data using rip-relative addressing. | ||
566 | */ | ||
567 | asm ("lea sme_cmdline_arg(%%rip), %0" | ||
568 | : "=r" (cmdline_arg) | ||
569 | : "p" (sme_cmdline_arg)); | ||
570 | asm ("lea sme_cmdline_on(%%rip), %0" | ||
571 | : "=r" (cmdline_on) | ||
572 | : "p" (sme_cmdline_on)); | ||
573 | asm ("lea sme_cmdline_off(%%rip), %0" | ||
574 | : "=r" (cmdline_off) | ||
575 | : "p" (sme_cmdline_off)); | ||
576 | |||
577 | if (IS_ENABLED(CONFIG_AMD_MEM_ENCRYPT_ACTIVE_BY_DEFAULT)) | ||
578 | active_by_default = true; | ||
579 | else | ||
580 | active_by_default = false; | ||
581 | |||
582 | cmdline_ptr = (const char *)((u64)bp->hdr.cmd_line_ptr | | ||
583 | ((u64)bp->ext_cmd_line_ptr << 32)); | ||
584 | |||
585 | cmdline_find_option(cmdline_ptr, cmdline_arg, buffer, sizeof(buffer)); | ||
586 | |||
587 | if (!strncmp(buffer, cmdline_on, sizeof(buffer))) | ||
588 | sme_me_mask = me_mask; | ||
589 | else if (!strncmp(buffer, cmdline_off, sizeof(buffer))) | ||
590 | sme_me_mask = 0; | ||
591 | else | ||
592 | sme_me_mask = active_by_default ? me_mask : 0; | ||
593 | } | ||
diff --git a/arch/x86/mm/mem_encrypt_boot.S b/arch/x86/mm/mem_encrypt_boot.S new file mode 100644 index 000000000000..730e6d541df1 --- /dev/null +++ b/arch/x86/mm/mem_encrypt_boot.S | |||
@@ -0,0 +1,149 @@ | |||
1 | /* | ||
2 | * AMD Memory Encryption Support | ||
3 | * | ||
4 | * Copyright (C) 2016 Advanced Micro Devices, Inc. | ||
5 | * | ||
6 | * Author: Tom Lendacky <thomas.lendacky@amd.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License version 2 as | ||
10 | * published by the Free Software Foundation. | ||
11 | */ | ||
12 | |||
13 | #include <linux/linkage.h> | ||
14 | #include <asm/pgtable.h> | ||
15 | #include <asm/page.h> | ||
16 | #include <asm/processor-flags.h> | ||
17 | #include <asm/msr-index.h> | ||
18 | |||
19 | .text | ||
20 | .code64 | ||
21 | ENTRY(sme_encrypt_execute) | ||
22 | |||
23 | /* | ||
24 | * Entry parameters: | ||
25 | * RDI - virtual address for the encrypted kernel mapping | ||
26 | * RSI - virtual address for the decrypted kernel mapping | ||
27 | * RDX - length of kernel | ||
28 | * RCX - virtual address of the encryption workarea, including: | ||
29 | * - stack page (PAGE_SIZE) | ||
30 | * - encryption routine page (PAGE_SIZE) | ||
31 | * - intermediate copy buffer (PMD_PAGE_SIZE) | ||
32 | * R8 - physcial address of the pagetables to use for encryption | ||
33 | */ | ||
34 | |||
35 | push %rbp | ||
36 | movq %rsp, %rbp /* RBP now has original stack pointer */ | ||
37 | |||
38 | /* Set up a one page stack in the non-encrypted memory area */ | ||
39 | movq %rcx, %rax /* Workarea stack page */ | ||
40 | leaq PAGE_SIZE(%rax), %rsp /* Set new stack pointer */ | ||
41 | addq $PAGE_SIZE, %rax /* Workarea encryption routine */ | ||
42 | |||
43 | push %r12 | ||
44 | movq %rdi, %r10 /* Encrypted kernel */ | ||
45 | movq %rsi, %r11 /* Decrypted kernel */ | ||
46 | movq %rdx, %r12 /* Kernel length */ | ||
47 | |||
48 | /* Copy encryption routine into the workarea */ | ||
49 | movq %rax, %rdi /* Workarea encryption routine */ | ||
50 | leaq __enc_copy(%rip), %rsi /* Encryption routine */ | ||
51 | movq $(.L__enc_copy_end - __enc_copy), %rcx /* Encryption routine length */ | ||
52 | rep movsb | ||
53 | |||
54 | /* Setup registers for call */ | ||
55 | movq %r10, %rdi /* Encrypted kernel */ | ||
56 | movq %r11, %rsi /* Decrypted kernel */ | ||
57 | movq %r8, %rdx /* Pagetables used for encryption */ | ||
58 | movq %r12, %rcx /* Kernel length */ | ||
59 | movq %rax, %r8 /* Workarea encryption routine */ | ||
60 | addq $PAGE_SIZE, %r8 /* Workarea intermediate copy buffer */ | ||
61 | |||
62 | call *%rax /* Call the encryption routine */ | ||
63 | |||
64 | pop %r12 | ||
65 | |||
66 | movq %rbp, %rsp /* Restore original stack pointer */ | ||
67 | pop %rbp | ||
68 | |||
69 | ret | ||
70 | ENDPROC(sme_encrypt_execute) | ||
71 | |||
72 | ENTRY(__enc_copy) | ||
73 | /* | ||
74 | * Routine used to encrypt kernel. | ||
75 | * This routine must be run outside of the kernel proper since | ||
76 | * the kernel will be encrypted during the process. So this | ||
77 | * routine is defined here and then copied to an area outside | ||
78 | * of the kernel where it will remain and run decrypted | ||
79 | * during execution. | ||
80 | * | ||
81 | * On entry the registers must be: | ||
82 | * RDI - virtual address for the encrypted kernel mapping | ||
83 | * RSI - virtual address for the decrypted kernel mapping | ||
84 | * RDX - address of the pagetables to use for encryption | ||
85 | * RCX - length of kernel | ||
86 | * R8 - intermediate copy buffer | ||
87 | * | ||
88 | * RAX - points to this routine | ||
89 | * | ||
90 | * The kernel will be encrypted by copying from the non-encrypted | ||
91 | * kernel space to an intermediate buffer and then copying from the | ||
92 | * intermediate buffer back to the encrypted kernel space. The physical | ||
93 | * addresses of the two kernel space mappings are the same which | ||
94 | * results in the kernel being encrypted "in place". | ||
95 | */ | ||
96 | /* Enable the new page tables */ | ||
97 | mov %rdx, %cr3 | ||
98 | |||
99 | /* Flush any global TLBs */ | ||
100 | mov %cr4, %rdx | ||
101 | andq $~X86_CR4_PGE, %rdx | ||
102 | mov %rdx, %cr4 | ||
103 | orq $X86_CR4_PGE, %rdx | ||
104 | mov %rdx, %cr4 | ||
105 | |||
106 | /* Set the PAT register PA5 entry to write-protect */ | ||
107 | push %rcx | ||
108 | movl $MSR_IA32_CR_PAT, %ecx | ||
109 | rdmsr | ||
110 | push %rdx /* Save original PAT value */ | ||
111 | andl $0xffff00ff, %edx /* Clear PA5 */ | ||
112 | orl $0x00000500, %edx /* Set PA5 to WP */ | ||
113 | wrmsr | ||
114 | pop %rdx /* RDX contains original PAT value */ | ||
115 | pop %rcx | ||
116 | |||
117 | movq %rcx, %r9 /* Save kernel length */ | ||
118 | movq %rdi, %r10 /* Save encrypted kernel address */ | ||
119 | movq %rsi, %r11 /* Save decrypted kernel address */ | ||
120 | |||
121 | wbinvd /* Invalidate any cache entries */ | ||
122 | |||
123 | /* Copy/encrypt 2MB at a time */ | ||
124 | 1: | ||
125 | movq %r11, %rsi /* Source - decrypted kernel */ | ||
126 | movq %r8, %rdi /* Dest - intermediate copy buffer */ | ||
127 | movq $PMD_PAGE_SIZE, %rcx /* 2MB length */ | ||
128 | rep movsb | ||
129 | |||
130 | movq %r8, %rsi /* Source - intermediate copy buffer */ | ||
131 | movq %r10, %rdi /* Dest - encrypted kernel */ | ||
132 | movq $PMD_PAGE_SIZE, %rcx /* 2MB length */ | ||
133 | rep movsb | ||
134 | |||
135 | addq $PMD_PAGE_SIZE, %r11 | ||
136 | addq $PMD_PAGE_SIZE, %r10 | ||
137 | subq $PMD_PAGE_SIZE, %r9 /* Kernel length decrement */ | ||
138 | jnz 1b /* Kernel length not zero? */ | ||
139 | |||
140 | /* Restore PAT register */ | ||
141 | push %rdx /* Save original PAT value */ | ||
142 | movl $MSR_IA32_CR_PAT, %ecx | ||
143 | rdmsr | ||
144 | pop %rdx /* Restore original PAT value */ | ||
145 | wrmsr | ||
146 | |||
147 | ret | ||
148 | .L__enc_copy_end: | ||
149 | ENDPROC(__enc_copy) | ||
diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c index 229d04a83f85..a99679826846 100644 --- a/arch/x86/mm/mmap.c +++ b/arch/x86/mm/mmap.c | |||
@@ -37,22 +37,21 @@ struct va_alignment __read_mostly va_align = { | |||
37 | .flags = -1, | 37 | .flags = -1, |
38 | }; | 38 | }; |
39 | 39 | ||
40 | unsigned long tasksize_32bit(void) | 40 | unsigned long task_size_32bit(void) |
41 | { | 41 | { |
42 | return IA32_PAGE_OFFSET; | 42 | return IA32_PAGE_OFFSET; |
43 | } | 43 | } |
44 | 44 | ||
45 | unsigned long tasksize_64bit(void) | 45 | unsigned long task_size_64bit(int full_addr_space) |
46 | { | 46 | { |
47 | return TASK_SIZE_MAX; | 47 | return full_addr_space ? TASK_SIZE_MAX : DEFAULT_MAP_WINDOW; |
48 | } | 48 | } |
49 | 49 | ||
50 | static unsigned long stack_maxrandom_size(unsigned long task_size) | 50 | static unsigned long stack_maxrandom_size(unsigned long task_size) |
51 | { | 51 | { |
52 | unsigned long max = 0; | 52 | unsigned long max = 0; |
53 | if ((current->flags & PF_RANDOMIZE) && | 53 | if (current->flags & PF_RANDOMIZE) { |
54 | !(current->personality & ADDR_NO_RANDOMIZE)) { | 54 | max = (-1UL) & __STACK_RND_MASK(task_size == task_size_32bit()); |
55 | max = (-1UL) & __STACK_RND_MASK(task_size == tasksize_32bit()); | ||
56 | max <<= PAGE_SHIFT; | 55 | max <<= PAGE_SHIFT; |
57 | } | 56 | } |
58 | 57 | ||
@@ -79,13 +78,13 @@ static int mmap_is_legacy(void) | |||
79 | 78 | ||
80 | static unsigned long arch_rnd(unsigned int rndbits) | 79 | static unsigned long arch_rnd(unsigned int rndbits) |
81 | { | 80 | { |
81 | if (!(current->flags & PF_RANDOMIZE)) | ||
82 | return 0; | ||
82 | return (get_random_long() & ((1UL << rndbits) - 1)) << PAGE_SHIFT; | 83 | return (get_random_long() & ((1UL << rndbits) - 1)) << PAGE_SHIFT; |
83 | } | 84 | } |
84 | 85 | ||
85 | unsigned long arch_mmap_rnd(void) | 86 | unsigned long arch_mmap_rnd(void) |
86 | { | 87 | { |
87 | if (!(current->flags & PF_RANDOMIZE)) | ||
88 | return 0; | ||
89 | return arch_rnd(mmap_is_ia32() ? mmap32_rnd_bits : mmap64_rnd_bits); | 88 | return arch_rnd(mmap_is_ia32() ? mmap32_rnd_bits : mmap64_rnd_bits); |
90 | } | 89 | } |
91 | 90 | ||
@@ -142,7 +141,7 @@ void arch_pick_mmap_layout(struct mm_struct *mm) | |||
142 | mm->get_unmapped_area = arch_get_unmapped_area_topdown; | 141 | mm->get_unmapped_area = arch_get_unmapped_area_topdown; |
143 | 142 | ||
144 | arch_pick_mmap_base(&mm->mmap_base, &mm->mmap_legacy_base, | 143 | arch_pick_mmap_base(&mm->mmap_base, &mm->mmap_legacy_base, |
145 | arch_rnd(mmap64_rnd_bits), tasksize_64bit()); | 144 | arch_rnd(mmap64_rnd_bits), task_size_64bit(0)); |
146 | 145 | ||
147 | #ifdef CONFIG_HAVE_ARCH_COMPAT_MMAP_BASES | 146 | #ifdef CONFIG_HAVE_ARCH_COMPAT_MMAP_BASES |
148 | /* | 147 | /* |
@@ -152,7 +151,7 @@ void arch_pick_mmap_layout(struct mm_struct *mm) | |||
152 | * mmap_base, the compat syscall uses mmap_compat_base. | 151 | * mmap_base, the compat syscall uses mmap_compat_base. |
153 | */ | 152 | */ |
154 | arch_pick_mmap_base(&mm->mmap_compat_base, &mm->mmap_compat_legacy_base, | 153 | arch_pick_mmap_base(&mm->mmap_compat_base, &mm->mmap_compat_legacy_base, |
155 | arch_rnd(mmap32_rnd_bits), tasksize_32bit()); | 154 | arch_rnd(mmap32_rnd_bits), task_size_32bit()); |
156 | #endif | 155 | #endif |
157 | } | 156 | } |
158 | 157 | ||
diff --git a/arch/x86/mm/mpx.c b/arch/x86/mm/mpx.c index 1c34b767c84c..9ceaa955d2ba 100644 --- a/arch/x86/mm/mpx.c +++ b/arch/x86/mm/mpx.c | |||
@@ -355,10 +355,19 @@ int mpx_enable_management(void) | |||
355 | */ | 355 | */ |
356 | bd_base = mpx_get_bounds_dir(); | 356 | bd_base = mpx_get_bounds_dir(); |
357 | down_write(&mm->mmap_sem); | 357 | down_write(&mm->mmap_sem); |
358 | |||
359 | /* MPX doesn't support addresses above 47 bits yet. */ | ||
360 | if (find_vma(mm, DEFAULT_MAP_WINDOW)) { | ||
361 | pr_warn_once("%s (%d): MPX cannot handle addresses " | ||
362 | "above 47-bits. Disabling.", | ||
363 | current->comm, current->pid); | ||
364 | ret = -ENXIO; | ||
365 | goto out; | ||
366 | } | ||
358 | mm->context.bd_addr = bd_base; | 367 | mm->context.bd_addr = bd_base; |
359 | if (mm->context.bd_addr == MPX_INVALID_BOUNDS_DIR) | 368 | if (mm->context.bd_addr == MPX_INVALID_BOUNDS_DIR) |
360 | ret = -ENXIO; | 369 | ret = -ENXIO; |
361 | 370 | out: | |
362 | up_write(&mm->mmap_sem); | 371 | up_write(&mm->mmap_sem); |
363 | return ret; | 372 | return ret; |
364 | } | 373 | } |
@@ -1030,3 +1039,25 @@ void mpx_notify_unmap(struct mm_struct *mm, struct vm_area_struct *vma, | |||
1030 | if (ret) | 1039 | if (ret) |
1031 | force_sig(SIGSEGV, current); | 1040 | force_sig(SIGSEGV, current); |
1032 | } | 1041 | } |
1042 | |||
1043 | /* MPX cannot handle addresses above 47 bits yet. */ | ||
1044 | unsigned long mpx_unmapped_area_check(unsigned long addr, unsigned long len, | ||
1045 | unsigned long flags) | ||
1046 | { | ||
1047 | if (!kernel_managing_mpx_tables(current->mm)) | ||
1048 | return addr; | ||
1049 | if (addr + len <= DEFAULT_MAP_WINDOW) | ||
1050 | return addr; | ||
1051 | if (flags & MAP_FIXED) | ||
1052 | return -ENOMEM; | ||
1053 | |||
1054 | /* | ||
1055 | * Requested len is larger than the whole area we're allowed to map in. | ||
1056 | * Resetting hinting address wouldn't do much good -- fail early. | ||
1057 | */ | ||
1058 | if (len > DEFAULT_MAP_WINDOW) | ||
1059 | return -ENOMEM; | ||
1060 | |||
1061 | /* Look for unmap area within DEFAULT_MAP_WINDOW */ | ||
1062 | return 0; | ||
1063 | } | ||
diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c index 757b0bcdf712..dfb7d657cf43 100644 --- a/arch/x86/mm/pageattr.c +++ b/arch/x86/mm/pageattr.c | |||
@@ -1775,6 +1775,70 @@ int set_memory_4k(unsigned long addr, int numpages) | |||
1775 | __pgprot(0), 1, 0, NULL); | 1775 | __pgprot(0), 1, 0, NULL); |
1776 | } | 1776 | } |
1777 | 1777 | ||
1778 | static int __set_memory_enc_dec(unsigned long addr, int numpages, bool enc) | ||
1779 | { | ||
1780 | struct cpa_data cpa; | ||
1781 | unsigned long start; | ||
1782 | int ret; | ||
1783 | |||
1784 | /* Nothing to do if the SME is not active */ | ||
1785 | if (!sme_active()) | ||
1786 | return 0; | ||
1787 | |||
1788 | /* Should not be working on unaligned addresses */ | ||
1789 | if (WARN_ONCE(addr & ~PAGE_MASK, "misaligned address: %#lx\n", addr)) | ||
1790 | addr &= PAGE_MASK; | ||
1791 | |||
1792 | start = addr; | ||
1793 | |||
1794 | memset(&cpa, 0, sizeof(cpa)); | ||
1795 | cpa.vaddr = &addr; | ||
1796 | cpa.numpages = numpages; | ||
1797 | cpa.mask_set = enc ? __pgprot(_PAGE_ENC) : __pgprot(0); | ||
1798 | cpa.mask_clr = enc ? __pgprot(0) : __pgprot(_PAGE_ENC); | ||
1799 | cpa.pgd = init_mm.pgd; | ||
1800 | |||
1801 | /* Must avoid aliasing mappings in the highmem code */ | ||
1802 | kmap_flush_unused(); | ||
1803 | vm_unmap_aliases(); | ||
1804 | |||
1805 | /* | ||
1806 | * Before changing the encryption attribute, we need to flush caches. | ||
1807 | */ | ||
1808 | if (static_cpu_has(X86_FEATURE_CLFLUSH)) | ||
1809 | cpa_flush_range(start, numpages, 1); | ||
1810 | else | ||
1811 | cpa_flush_all(1); | ||
1812 | |||
1813 | ret = __change_page_attr_set_clr(&cpa, 1); | ||
1814 | |||
1815 | /* | ||
1816 | * After changing the encryption attribute, we need to flush TLBs | ||
1817 | * again in case any speculative TLB caching occurred (but no need | ||
1818 | * to flush caches again). We could just use cpa_flush_all(), but | ||
1819 | * in case TLB flushing gets optimized in the cpa_flush_range() | ||
1820 | * path use the same logic as above. | ||
1821 | */ | ||
1822 | if (static_cpu_has(X86_FEATURE_CLFLUSH)) | ||
1823 | cpa_flush_range(start, numpages, 0); | ||
1824 | else | ||
1825 | cpa_flush_all(0); | ||
1826 | |||
1827 | return ret; | ||
1828 | } | ||
1829 | |||
1830 | int set_memory_encrypted(unsigned long addr, int numpages) | ||
1831 | { | ||
1832 | return __set_memory_enc_dec(addr, numpages, true); | ||
1833 | } | ||
1834 | EXPORT_SYMBOL_GPL(set_memory_encrypted); | ||
1835 | |||
1836 | int set_memory_decrypted(unsigned long addr, int numpages) | ||
1837 | { | ||
1838 | return __set_memory_enc_dec(addr, numpages, false); | ||
1839 | } | ||
1840 | EXPORT_SYMBOL_GPL(set_memory_decrypted); | ||
1841 | |||
1778 | int set_pages_uc(struct page *page, int numpages) | 1842 | int set_pages_uc(struct page *page, int numpages) |
1779 | { | 1843 | { |
1780 | unsigned long addr = (unsigned long)page_address(page); | 1844 | unsigned long addr = (unsigned long)page_address(page); |
@@ -2020,6 +2084,9 @@ int kernel_map_pages_in_pgd(pgd_t *pgd, u64 pfn, unsigned long address, | |||
2020 | if (!(page_flags & _PAGE_RW)) | 2084 | if (!(page_flags & _PAGE_RW)) |
2021 | cpa.mask_clr = __pgprot(_PAGE_RW); | 2085 | cpa.mask_clr = __pgprot(_PAGE_RW); |
2022 | 2086 | ||
2087 | if (!(page_flags & _PAGE_ENC)) | ||
2088 | cpa.mask_clr = pgprot_encrypted(cpa.mask_clr); | ||
2089 | |||
2023 | cpa.mask_set = __pgprot(_PAGE_PRESENT | page_flags); | 2090 | cpa.mask_set = __pgprot(_PAGE_PRESENT | page_flags); |
2024 | 2091 | ||
2025 | retval = __change_page_attr_set_clr(&cpa, 0); | 2092 | retval = __change_page_attr_set_clr(&cpa, 0); |
diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c index 45979502f64b..fe7d57a8fb60 100644 --- a/arch/x86/mm/pat.c +++ b/arch/x86/mm/pat.c | |||
@@ -293,7 +293,7 @@ void init_cache_modes(void) | |||
293 | * pat_init - Initialize PAT MSR and PAT table | 293 | * pat_init - Initialize PAT MSR and PAT table |
294 | * | 294 | * |
295 | * This function initializes PAT MSR and PAT table with an OS-defined value | 295 | * This function initializes PAT MSR and PAT table with an OS-defined value |
296 | * to enable additional cache attributes, WC and WT. | 296 | * to enable additional cache attributes, WC, WT and WP. |
297 | * | 297 | * |
298 | * This function must be called on all CPUs using the specific sequence of | 298 | * This function must be called on all CPUs using the specific sequence of |
299 | * operations defined in Intel SDM. mtrr_rendezvous_handler() provides this | 299 | * operations defined in Intel SDM. mtrr_rendezvous_handler() provides this |
@@ -352,7 +352,7 @@ void pat_init(void) | |||
352 | * 010 2 UC-: _PAGE_CACHE_MODE_UC_MINUS | 352 | * 010 2 UC-: _PAGE_CACHE_MODE_UC_MINUS |
353 | * 011 3 UC : _PAGE_CACHE_MODE_UC | 353 | * 011 3 UC : _PAGE_CACHE_MODE_UC |
354 | * 100 4 WB : Reserved | 354 | * 100 4 WB : Reserved |
355 | * 101 5 WC : Reserved | 355 | * 101 5 WP : _PAGE_CACHE_MODE_WP |
356 | * 110 6 UC-: Reserved | 356 | * 110 6 UC-: Reserved |
357 | * 111 7 WT : _PAGE_CACHE_MODE_WT | 357 | * 111 7 WT : _PAGE_CACHE_MODE_WT |
358 | * | 358 | * |
@@ -360,7 +360,7 @@ void pat_init(void) | |||
360 | * corresponding types in the presence of PAT errata. | 360 | * corresponding types in the presence of PAT errata. |
361 | */ | 361 | */ |
362 | pat = PAT(0, WB) | PAT(1, WC) | PAT(2, UC_MINUS) | PAT(3, UC) | | 362 | pat = PAT(0, WB) | PAT(1, WC) | PAT(2, UC_MINUS) | PAT(3, UC) | |
363 | PAT(4, WB) | PAT(5, WC) | PAT(6, UC_MINUS) | PAT(7, WT); | 363 | PAT(4, WB) | PAT(5, WP) | PAT(6, UC_MINUS) | PAT(7, WT); |
364 | } | 364 | } |
365 | 365 | ||
366 | if (!boot_cpu_done) { | 366 | if (!boot_cpu_done) { |
@@ -744,6 +744,9 @@ EXPORT_SYMBOL(arch_io_free_memtype_wc); | |||
744 | pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn, | 744 | pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn, |
745 | unsigned long size, pgprot_t vma_prot) | 745 | unsigned long size, pgprot_t vma_prot) |
746 | { | 746 | { |
747 | if (!phys_mem_access_encrypted(pfn << PAGE_SHIFT, size)) | ||
748 | vma_prot = pgprot_decrypted(vma_prot); | ||
749 | |||
747 | return vma_prot; | 750 | return vma_prot; |
748 | } | 751 | } |
749 | 752 | ||
diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c index 508a708eb9a6..218834a3e9ad 100644 --- a/arch/x86/mm/pgtable.c +++ b/arch/x86/mm/pgtable.c | |||
@@ -56,7 +56,7 @@ void ___pte_free_tlb(struct mmu_gather *tlb, struct page *pte) | |||
56 | { | 56 | { |
57 | pgtable_page_dtor(pte); | 57 | pgtable_page_dtor(pte); |
58 | paravirt_release_pte(page_to_pfn(pte)); | 58 | paravirt_release_pte(page_to_pfn(pte)); |
59 | tlb_remove_page(tlb, pte); | 59 | tlb_remove_table(tlb, pte); |
60 | } | 60 | } |
61 | 61 | ||
62 | #if CONFIG_PGTABLE_LEVELS > 2 | 62 | #if CONFIG_PGTABLE_LEVELS > 2 |
@@ -72,21 +72,21 @@ void ___pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd) | |||
72 | tlb->need_flush_all = 1; | 72 | tlb->need_flush_all = 1; |
73 | #endif | 73 | #endif |
74 | pgtable_pmd_page_dtor(page); | 74 | pgtable_pmd_page_dtor(page); |
75 | tlb_remove_page(tlb, page); | 75 | tlb_remove_table(tlb, page); |
76 | } | 76 | } |
77 | 77 | ||
78 | #if CONFIG_PGTABLE_LEVELS > 3 | 78 | #if CONFIG_PGTABLE_LEVELS > 3 |
79 | void ___pud_free_tlb(struct mmu_gather *tlb, pud_t *pud) | 79 | void ___pud_free_tlb(struct mmu_gather *tlb, pud_t *pud) |
80 | { | 80 | { |
81 | paravirt_release_pud(__pa(pud) >> PAGE_SHIFT); | 81 | paravirt_release_pud(__pa(pud) >> PAGE_SHIFT); |
82 | tlb_remove_page(tlb, virt_to_page(pud)); | 82 | tlb_remove_table(tlb, virt_to_page(pud)); |
83 | } | 83 | } |
84 | 84 | ||
85 | #if CONFIG_PGTABLE_LEVELS > 4 | 85 | #if CONFIG_PGTABLE_LEVELS > 4 |
86 | void ___p4d_free_tlb(struct mmu_gather *tlb, p4d_t *p4d) | 86 | void ___p4d_free_tlb(struct mmu_gather *tlb, p4d_t *p4d) |
87 | { | 87 | { |
88 | paravirt_release_p4d(__pa(p4d) >> PAGE_SHIFT); | 88 | paravirt_release_p4d(__pa(p4d) >> PAGE_SHIFT); |
89 | tlb_remove_page(tlb, virt_to_page(p4d)); | 89 | tlb_remove_table(tlb, virt_to_page(p4d)); |
90 | } | 90 | } |
91 | #endif /* CONFIG_PGTABLE_LEVELS > 4 */ | 91 | #endif /* CONFIG_PGTABLE_LEVELS > 4 */ |
92 | #endif /* CONFIG_PGTABLE_LEVELS > 3 */ | 92 | #endif /* CONFIG_PGTABLE_LEVELS > 3 */ |
diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c index 014d07a80053..ce104b962a17 100644 --- a/arch/x86/mm/tlb.c +++ b/arch/x86/mm/tlb.c | |||
@@ -28,6 +28,42 @@ | |||
28 | * Implement flush IPI by CALL_FUNCTION_VECTOR, Alex Shi | 28 | * Implement flush IPI by CALL_FUNCTION_VECTOR, Alex Shi |
29 | */ | 29 | */ |
30 | 30 | ||
31 | atomic64_t last_mm_ctx_id = ATOMIC64_INIT(1); | ||
32 | |||
33 | static void choose_new_asid(struct mm_struct *next, u64 next_tlb_gen, | ||
34 | u16 *new_asid, bool *need_flush) | ||
35 | { | ||
36 | u16 asid; | ||
37 | |||
38 | if (!static_cpu_has(X86_FEATURE_PCID)) { | ||
39 | *new_asid = 0; | ||
40 | *need_flush = true; | ||
41 | return; | ||
42 | } | ||
43 | |||
44 | for (asid = 0; asid < TLB_NR_DYN_ASIDS; asid++) { | ||
45 | if (this_cpu_read(cpu_tlbstate.ctxs[asid].ctx_id) != | ||
46 | next->context.ctx_id) | ||
47 | continue; | ||
48 | |||
49 | *new_asid = asid; | ||
50 | *need_flush = (this_cpu_read(cpu_tlbstate.ctxs[asid].tlb_gen) < | ||
51 | next_tlb_gen); | ||
52 | return; | ||
53 | } | ||
54 | |||
55 | /* | ||
56 | * We don't currently own an ASID slot on this CPU. | ||
57 | * Allocate a slot. | ||
58 | */ | ||
59 | *new_asid = this_cpu_add_return(cpu_tlbstate.next_asid, 1) - 1; | ||
60 | if (*new_asid >= TLB_NR_DYN_ASIDS) { | ||
61 | *new_asid = 0; | ||
62 | this_cpu_write(cpu_tlbstate.next_asid, 1); | ||
63 | } | ||
64 | *need_flush = true; | ||
65 | } | ||
66 | |||
31 | void leave_mm(int cpu) | 67 | void leave_mm(int cpu) |
32 | { | 68 | { |
33 | struct mm_struct *loaded_mm = this_cpu_read(cpu_tlbstate.loaded_mm); | 69 | struct mm_struct *loaded_mm = this_cpu_read(cpu_tlbstate.loaded_mm); |
@@ -43,12 +79,11 @@ void leave_mm(int cpu) | |||
43 | if (loaded_mm == &init_mm) | 79 | if (loaded_mm == &init_mm) |
44 | return; | 80 | return; |
45 | 81 | ||
46 | if (this_cpu_read(cpu_tlbstate.state) == TLBSTATE_OK) | 82 | /* Warn if we're not lazy. */ |
47 | BUG(); | 83 | WARN_ON(cpumask_test_cpu(smp_processor_id(), mm_cpumask(loaded_mm))); |
48 | 84 | ||
49 | switch_mm(NULL, &init_mm, NULL); | 85 | switch_mm(NULL, &init_mm, NULL); |
50 | } | 86 | } |
51 | EXPORT_SYMBOL_GPL(leave_mm); | ||
52 | 87 | ||
53 | void switch_mm(struct mm_struct *prev, struct mm_struct *next, | 88 | void switch_mm(struct mm_struct *prev, struct mm_struct *next, |
54 | struct task_struct *tsk) | 89 | struct task_struct *tsk) |
@@ -63,115 +98,219 @@ void switch_mm(struct mm_struct *prev, struct mm_struct *next, | |||
63 | void switch_mm_irqs_off(struct mm_struct *prev, struct mm_struct *next, | 98 | void switch_mm_irqs_off(struct mm_struct *prev, struct mm_struct *next, |
64 | struct task_struct *tsk) | 99 | struct task_struct *tsk) |
65 | { | 100 | { |
66 | unsigned cpu = smp_processor_id(); | ||
67 | struct mm_struct *real_prev = this_cpu_read(cpu_tlbstate.loaded_mm); | 101 | struct mm_struct *real_prev = this_cpu_read(cpu_tlbstate.loaded_mm); |
102 | u16 prev_asid = this_cpu_read(cpu_tlbstate.loaded_mm_asid); | ||
103 | unsigned cpu = smp_processor_id(); | ||
104 | u64 next_tlb_gen; | ||
68 | 105 | ||
69 | /* | 106 | /* |
70 | * NB: The scheduler will call us with prev == next when | 107 | * NB: The scheduler will call us with prev == next when switching |
71 | * switching from lazy TLB mode to normal mode if active_mm | 108 | * from lazy TLB mode to normal mode if active_mm isn't changing. |
72 | * isn't changing. When this happens, there is no guarantee | 109 | * When this happens, we don't assume that CR3 (and hence |
73 | * that CR3 (and hence cpu_tlbstate.loaded_mm) matches next. | 110 | * cpu_tlbstate.loaded_mm) matches next. |
74 | * | 111 | * |
75 | * NB: leave_mm() calls us with prev == NULL and tsk == NULL. | 112 | * NB: leave_mm() calls us with prev == NULL and tsk == NULL. |
76 | */ | 113 | */ |
77 | 114 | ||
78 | this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK); | 115 | /* We don't want flush_tlb_func_* to run concurrently with us. */ |
116 | if (IS_ENABLED(CONFIG_PROVE_LOCKING)) | ||
117 | WARN_ON_ONCE(!irqs_disabled()); | ||
118 | |||
119 | /* | ||
120 | * Verify that CR3 is what we think it is. This will catch | ||
121 | * hypothetical buggy code that directly switches to swapper_pg_dir | ||
122 | * without going through leave_mm() / switch_mm_irqs_off() or that | ||
123 | * does something like write_cr3(read_cr3_pa()). | ||
124 | */ | ||
125 | VM_BUG_ON(__read_cr3() != (__sme_pa(real_prev->pgd) | prev_asid)); | ||
79 | 126 | ||
80 | if (real_prev == next) { | 127 | if (real_prev == next) { |
81 | /* | 128 | VM_BUG_ON(this_cpu_read(cpu_tlbstate.ctxs[prev_asid].ctx_id) != |
82 | * There's nothing to do: we always keep the per-mm control | 129 | next->context.ctx_id); |
83 | * regs in sync with cpu_tlbstate.loaded_mm. Just | 130 | |
84 | * sanity-check mm_cpumask. | 131 | if (cpumask_test_cpu(cpu, mm_cpumask(next))) { |
85 | */ | 132 | /* |
86 | if (WARN_ON_ONCE(!cpumask_test_cpu(cpu, mm_cpumask(next)))) | 133 | * There's nothing to do: we weren't lazy, and we |
87 | cpumask_set_cpu(cpu, mm_cpumask(next)); | 134 | * aren't changing our mm. We don't need to flush |
88 | return; | 135 | * anything, nor do we need to update CR3, CR4, or |
89 | } | 136 | * LDTR. |
137 | */ | ||
138 | return; | ||
139 | } | ||
140 | |||
141 | /* Resume remote flushes and then read tlb_gen. */ | ||
142 | cpumask_set_cpu(cpu, mm_cpumask(next)); | ||
143 | next_tlb_gen = atomic64_read(&next->context.tlb_gen); | ||
144 | |||
145 | if (this_cpu_read(cpu_tlbstate.ctxs[prev_asid].tlb_gen) < | ||
146 | next_tlb_gen) { | ||
147 | /* | ||
148 | * Ideally, we'd have a flush_tlb() variant that | ||
149 | * takes the known CR3 value as input. This would | ||
150 | * be faster on Xen PV and on hypothetical CPUs | ||
151 | * on which INVPCID is fast. | ||
152 | */ | ||
153 | this_cpu_write(cpu_tlbstate.ctxs[prev_asid].tlb_gen, | ||
154 | next_tlb_gen); | ||
155 | write_cr3(__sme_pa(next->pgd) | prev_asid); | ||
156 | trace_tlb_flush(TLB_FLUSH_ON_TASK_SWITCH, | ||
157 | TLB_FLUSH_ALL); | ||
158 | } | ||
90 | 159 | ||
91 | if (IS_ENABLED(CONFIG_VMAP_STACK)) { | ||
92 | /* | 160 | /* |
93 | * If our current stack is in vmalloc space and isn't | 161 | * We just exited lazy mode, which means that CR4 and/or LDTR |
94 | * mapped in the new pgd, we'll double-fault. Forcibly | 162 | * may be stale. (Changes to the required CR4 and LDTR states |
95 | * map it. | 163 | * are not reflected in tlb_gen.) |
96 | */ | 164 | */ |
97 | unsigned int stack_pgd_index = pgd_index(current_stack_pointer()); | 165 | } else { |
98 | 166 | u16 new_asid; | |
99 | pgd_t *pgd = next->pgd + stack_pgd_index; | 167 | bool need_flush; |
100 | 168 | ||
101 | if (unlikely(pgd_none(*pgd))) | 169 | if (IS_ENABLED(CONFIG_VMAP_STACK)) { |
102 | set_pgd(pgd, init_mm.pgd[stack_pgd_index]); | 170 | /* |
103 | } | 171 | * If our current stack is in vmalloc space and isn't |
172 | * mapped in the new pgd, we'll double-fault. Forcibly | ||
173 | * map it. | ||
174 | */ | ||
175 | unsigned int index = pgd_index(current_stack_pointer()); | ||
176 | pgd_t *pgd = next->pgd + index; | ||
177 | |||
178 | if (unlikely(pgd_none(*pgd))) | ||
179 | set_pgd(pgd, init_mm.pgd[index]); | ||
180 | } | ||
104 | 181 | ||
105 | this_cpu_write(cpu_tlbstate.loaded_mm, next); | 182 | /* Stop remote flushes for the previous mm */ |
183 | if (cpumask_test_cpu(cpu, mm_cpumask(real_prev))) | ||
184 | cpumask_clear_cpu(cpu, mm_cpumask(real_prev)); | ||
106 | 185 | ||
107 | WARN_ON_ONCE(cpumask_test_cpu(cpu, mm_cpumask(next))); | 186 | VM_WARN_ON_ONCE(cpumask_test_cpu(cpu, mm_cpumask(next))); |
108 | cpumask_set_cpu(cpu, mm_cpumask(next)); | ||
109 | 187 | ||
110 | /* | 188 | /* |
111 | * Re-load page tables. | 189 | * Start remote flushes and then read tlb_gen. |
112 | * | 190 | */ |
113 | * This logic has an ordering constraint: | 191 | cpumask_set_cpu(cpu, mm_cpumask(next)); |
114 | * | 192 | next_tlb_gen = atomic64_read(&next->context.tlb_gen); |
115 | * CPU 0: Write to a PTE for 'next' | 193 | |
116 | * CPU 0: load bit 1 in mm_cpumask. if nonzero, send IPI. | 194 | choose_new_asid(next, next_tlb_gen, &new_asid, &need_flush); |
117 | * CPU 1: set bit 1 in next's mm_cpumask | 195 | |
118 | * CPU 1: load from the PTE that CPU 0 writes (implicit) | 196 | if (need_flush) { |
119 | * | 197 | this_cpu_write(cpu_tlbstate.ctxs[new_asid].ctx_id, next->context.ctx_id); |
120 | * We need to prevent an outcome in which CPU 1 observes | 198 | this_cpu_write(cpu_tlbstate.ctxs[new_asid].tlb_gen, next_tlb_gen); |
121 | * the new PTE value and CPU 0 observes bit 1 clear in | 199 | write_cr3(__sme_pa(next->pgd) | new_asid); |
122 | * mm_cpumask. (If that occurs, then the IPI will never | 200 | trace_tlb_flush(TLB_FLUSH_ON_TASK_SWITCH, |
123 | * be sent, and CPU 0's TLB will contain a stale entry.) | 201 | TLB_FLUSH_ALL); |
124 | * | 202 | } else { |
125 | * The bad outcome can occur if either CPU's load is | 203 | /* The new ASID is already up to date. */ |
126 | * reordered before that CPU's store, so both CPUs must | 204 | write_cr3(__sme_pa(next->pgd) | new_asid | CR3_NOFLUSH); |
127 | * execute full barriers to prevent this from happening. | 205 | trace_tlb_flush(TLB_FLUSH_ON_TASK_SWITCH, 0); |
128 | * | 206 | } |
129 | * Thus, switch_mm needs a full barrier between the | ||
130 | * store to mm_cpumask and any operation that could load | ||
131 | * from next->pgd. TLB fills are special and can happen | ||
132 | * due to instruction fetches or for no reason at all, | ||
133 | * and neither LOCK nor MFENCE orders them. | ||
134 | * Fortunately, load_cr3() is serializing and gives the | ||
135 | * ordering guarantee we need. | ||
136 | */ | ||
137 | load_cr3(next->pgd); | ||
138 | |||
139 | /* | ||
140 | * This gets called via leave_mm() in the idle path where RCU | ||
141 | * functions differently. Tracing normally uses RCU, so we have to | ||
142 | * call the tracepoint specially here. | ||
143 | */ | ||
144 | trace_tlb_flush_rcuidle(TLB_FLUSH_ON_TASK_SWITCH, TLB_FLUSH_ALL); | ||
145 | 207 | ||
146 | /* Stop flush ipis for the previous mm */ | 208 | this_cpu_write(cpu_tlbstate.loaded_mm, next); |
147 | WARN_ON_ONCE(!cpumask_test_cpu(cpu, mm_cpumask(real_prev)) && | 209 | this_cpu_write(cpu_tlbstate.loaded_mm_asid, new_asid); |
148 | real_prev != &init_mm); | 210 | } |
149 | cpumask_clear_cpu(cpu, mm_cpumask(real_prev)); | ||
150 | 211 | ||
151 | /* Load per-mm CR4 and LDTR state */ | ||
152 | load_mm_cr4(next); | 212 | load_mm_cr4(next); |
153 | switch_ldt(real_prev, next); | 213 | switch_ldt(real_prev, next); |
154 | } | 214 | } |
155 | 215 | ||
216 | /* | ||
217 | * flush_tlb_func_common()'s memory ordering requirement is that any | ||
218 | * TLB fills that happen after we flush the TLB are ordered after we | ||
219 | * read active_mm's tlb_gen. We don't need any explicit barriers | ||
220 | * because all x86 flush operations are serializing and the | ||
221 | * atomic64_read operation won't be reordered by the compiler. | ||
222 | */ | ||
156 | static void flush_tlb_func_common(const struct flush_tlb_info *f, | 223 | static void flush_tlb_func_common(const struct flush_tlb_info *f, |
157 | bool local, enum tlb_flush_reason reason) | 224 | bool local, enum tlb_flush_reason reason) |
158 | { | 225 | { |
226 | /* | ||
227 | * We have three different tlb_gen values in here. They are: | ||
228 | * | ||
229 | * - mm_tlb_gen: the latest generation. | ||
230 | * - local_tlb_gen: the generation that this CPU has already caught | ||
231 | * up to. | ||
232 | * - f->new_tlb_gen: the generation that the requester of the flush | ||
233 | * wants us to catch up to. | ||
234 | */ | ||
235 | struct mm_struct *loaded_mm = this_cpu_read(cpu_tlbstate.loaded_mm); | ||
236 | u32 loaded_mm_asid = this_cpu_read(cpu_tlbstate.loaded_mm_asid); | ||
237 | u64 mm_tlb_gen = atomic64_read(&loaded_mm->context.tlb_gen); | ||
238 | u64 local_tlb_gen = this_cpu_read(cpu_tlbstate.ctxs[loaded_mm_asid].tlb_gen); | ||
239 | |||
159 | /* This code cannot presently handle being reentered. */ | 240 | /* This code cannot presently handle being reentered. */ |
160 | VM_WARN_ON(!irqs_disabled()); | 241 | VM_WARN_ON(!irqs_disabled()); |
161 | 242 | ||
162 | if (this_cpu_read(cpu_tlbstate.state) != TLBSTATE_OK) { | 243 | VM_WARN_ON(this_cpu_read(cpu_tlbstate.ctxs[loaded_mm_asid].ctx_id) != |
163 | leave_mm(smp_processor_id()); | 244 | loaded_mm->context.ctx_id); |
245 | |||
246 | if (!cpumask_test_cpu(smp_processor_id(), mm_cpumask(loaded_mm))) { | ||
247 | /* | ||
248 | * We're in lazy mode -- don't flush. We can get here on | ||
249 | * remote flushes due to races and on local flushes if a | ||
250 | * kernel thread coincidentally flushes the mm it's lazily | ||
251 | * still using. | ||
252 | */ | ||
164 | return; | 253 | return; |
165 | } | 254 | } |
166 | 255 | ||
167 | if (f->end == TLB_FLUSH_ALL) { | 256 | if (unlikely(local_tlb_gen == mm_tlb_gen)) { |
168 | local_flush_tlb(); | 257 | /* |
169 | if (local) | 258 | * There's nothing to do: we're already up to date. This can |
170 | count_vm_tlb_event(NR_TLB_LOCAL_FLUSH_ALL); | 259 | * happen if two concurrent flushes happen -- the first flush to |
171 | trace_tlb_flush(reason, TLB_FLUSH_ALL); | 260 | * be handled can catch us all the way up, leaving no work for |
172 | } else { | 261 | * the second flush. |
262 | */ | ||
263 | trace_tlb_flush(reason, 0); | ||
264 | return; | ||
265 | } | ||
266 | |||
267 | WARN_ON_ONCE(local_tlb_gen > mm_tlb_gen); | ||
268 | WARN_ON_ONCE(f->new_tlb_gen > mm_tlb_gen); | ||
269 | |||
270 | /* | ||
271 | * If we get to this point, we know that our TLB is out of date. | ||
272 | * This does not strictly imply that we need to flush (it's | ||
273 | * possible that f->new_tlb_gen <= local_tlb_gen), but we're | ||
274 | * going to need to flush in the very near future, so we might | ||
275 | * as well get it over with. | ||
276 | * | ||
277 | * The only question is whether to do a full or partial flush. | ||
278 | * | ||
279 | * We do a partial flush if requested and two extra conditions | ||
280 | * are met: | ||
281 | * | ||
282 | * 1. f->new_tlb_gen == local_tlb_gen + 1. We have an invariant that | ||
283 | * we've always done all needed flushes to catch up to | ||
284 | * local_tlb_gen. If, for example, local_tlb_gen == 2 and | ||
285 | * f->new_tlb_gen == 3, then we know that the flush needed to bring | ||
286 | * us up to date for tlb_gen 3 is the partial flush we're | ||
287 | * processing. | ||
288 | * | ||
289 | * As an example of why this check is needed, suppose that there | ||
290 | * are two concurrent flushes. The first is a full flush that | ||
291 | * changes context.tlb_gen from 1 to 2. The second is a partial | ||
292 | * flush that changes context.tlb_gen from 2 to 3. If they get | ||
293 | * processed on this CPU in reverse order, we'll see | ||
294 | * local_tlb_gen == 1, mm_tlb_gen == 3, and end != TLB_FLUSH_ALL. | ||
295 | * If we were to use __flush_tlb_single() and set local_tlb_gen to | ||
296 | * 3, we'd be break the invariant: we'd update local_tlb_gen above | ||
297 | * 1 without the full flush that's needed for tlb_gen 2. | ||
298 | * | ||
299 | * 2. f->new_tlb_gen == mm_tlb_gen. This is purely an optimiation. | ||
300 | * Partial TLB flushes are not all that much cheaper than full TLB | ||
301 | * flushes, so it seems unlikely that it would be a performance win | ||
302 | * to do a partial flush if that won't bring our TLB fully up to | ||
303 | * date. By doing a full flush instead, we can increase | ||
304 | * local_tlb_gen all the way to mm_tlb_gen and we can probably | ||
305 | * avoid another flush in the very near future. | ||
306 | */ | ||
307 | if (f->end != TLB_FLUSH_ALL && | ||
308 | f->new_tlb_gen == local_tlb_gen + 1 && | ||
309 | f->new_tlb_gen == mm_tlb_gen) { | ||
310 | /* Partial flush */ | ||
173 | unsigned long addr; | 311 | unsigned long addr; |
174 | unsigned long nr_pages = (f->end - f->start) >> PAGE_SHIFT; | 312 | unsigned long nr_pages = (f->end - f->start) >> PAGE_SHIFT; |
313 | |||
175 | addr = f->start; | 314 | addr = f->start; |
176 | while (addr < f->end) { | 315 | while (addr < f->end) { |
177 | __flush_tlb_single(addr); | 316 | __flush_tlb_single(addr); |
@@ -180,7 +319,16 @@ static void flush_tlb_func_common(const struct flush_tlb_info *f, | |||
180 | if (local) | 319 | if (local) |
181 | count_vm_tlb_events(NR_TLB_LOCAL_FLUSH_ONE, nr_pages); | 320 | count_vm_tlb_events(NR_TLB_LOCAL_FLUSH_ONE, nr_pages); |
182 | trace_tlb_flush(reason, nr_pages); | 321 | trace_tlb_flush(reason, nr_pages); |
322 | } else { | ||
323 | /* Full flush. */ | ||
324 | local_flush_tlb(); | ||
325 | if (local) | ||
326 | count_vm_tlb_event(NR_TLB_LOCAL_FLUSH_ALL); | ||
327 | trace_tlb_flush(reason, TLB_FLUSH_ALL); | ||
183 | } | 328 | } |
329 | |||
330 | /* Both paths above update our state to mm_tlb_gen. */ | ||
331 | this_cpu_write(cpu_tlbstate.ctxs[loaded_mm_asid].tlb_gen, mm_tlb_gen); | ||
184 | } | 332 | } |
185 | 333 | ||
186 | static void flush_tlb_func_local(void *info, enum tlb_flush_reason reason) | 334 | static void flush_tlb_func_local(void *info, enum tlb_flush_reason reason) |
@@ -214,6 +362,21 @@ void native_flush_tlb_others(const struct cpumask *cpumask, | |||
214 | (info->end - info->start) >> PAGE_SHIFT); | 362 | (info->end - info->start) >> PAGE_SHIFT); |
215 | 363 | ||
216 | if (is_uv_system()) { | 364 | if (is_uv_system()) { |
365 | /* | ||
366 | * This whole special case is confused. UV has a "Broadcast | ||
367 | * Assist Unit", which seems to be a fancy way to send IPIs. | ||
368 | * Back when x86 used an explicit TLB flush IPI, UV was | ||
369 | * optimized to use its own mechanism. These days, x86 uses | ||
370 | * smp_call_function_many(), but UV still uses a manual IPI, | ||
371 | * and that IPI's action is out of date -- it does a manual | ||
372 | * flush instead of calling flush_tlb_func_remote(). This | ||
373 | * means that the percpu tlb_gen variables won't be updated | ||
374 | * and we'll do pointless flushes on future context switches. | ||
375 | * | ||
376 | * Rather than hooking native_flush_tlb_others() here, I think | ||
377 | * that UV should be updated so that smp_call_function_many(), | ||
378 | * etc, are optimal on UV. | ||
379 | */ | ||
217 | unsigned int cpu; | 380 | unsigned int cpu; |
218 | 381 | ||
219 | cpu = smp_processor_id(); | 382 | cpu = smp_processor_id(); |
@@ -250,8 +413,8 @@ void flush_tlb_mm_range(struct mm_struct *mm, unsigned long start, | |||
250 | 413 | ||
251 | cpu = get_cpu(); | 414 | cpu = get_cpu(); |
252 | 415 | ||
253 | /* Synchronize with switch_mm. */ | 416 | /* This is also a barrier that synchronizes with switch_mm(). */ |
254 | smp_mb(); | 417 | info.new_tlb_gen = inc_mm_tlb_gen(mm); |
255 | 418 | ||
256 | /* Should we flush just the requested range? */ | 419 | /* Should we flush just the requested range? */ |
257 | if ((end != TLB_FLUSH_ALL) && | 420 | if ((end != TLB_FLUSH_ALL) && |
@@ -273,6 +436,7 @@ void flush_tlb_mm_range(struct mm_struct *mm, unsigned long start, | |||
273 | 436 | ||
274 | if (cpumask_any_but(mm_cpumask(mm), cpu) < nr_cpu_ids) | 437 | if (cpumask_any_but(mm_cpumask(mm), cpu) < nr_cpu_ids) |
275 | flush_tlb_others(mm_cpumask(mm), &info); | 438 | flush_tlb_others(mm_cpumask(mm), &info); |
439 | |||
276 | put_cpu(); | 440 | put_cpu(); |
277 | } | 441 | } |
278 | 442 | ||
@@ -281,8 +445,6 @@ static void do_flush_tlb_all(void *info) | |||
281 | { | 445 | { |
282 | count_vm_tlb_event(NR_TLB_REMOTE_FLUSH_RECEIVED); | 446 | count_vm_tlb_event(NR_TLB_REMOTE_FLUSH_RECEIVED); |
283 | __flush_tlb_all(); | 447 | __flush_tlb_all(); |
284 | if (this_cpu_read(cpu_tlbstate.state) == TLBSTATE_LAZY) | ||
285 | leave_mm(smp_processor_id()); | ||
286 | } | 448 | } |
287 | 449 | ||
288 | void flush_tlb_all(void) | 450 | void flush_tlb_all(void) |
@@ -335,6 +497,7 @@ void arch_tlbbatch_flush(struct arch_tlbflush_unmap_batch *batch) | |||
335 | 497 | ||
336 | if (cpumask_any_but(&batch->cpumask, cpu) < nr_cpu_ids) | 498 | if (cpumask_any_but(&batch->cpumask, cpu) < nr_cpu_ids) |
337 | flush_tlb_others(&batch->cpumask, &info); | 499 | flush_tlb_others(&batch->cpumask, &info); |
500 | |||
338 | cpumask_clear(&batch->cpumask); | 501 | cpumask_clear(&batch->cpumask); |
339 | 502 | ||
340 | put_cpu(); | 503 | put_cpu(); |
diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c index dbe2132b0ed4..7a5350d08cef 100644 --- a/arch/x86/pci/common.c +++ b/arch/x86/pci/common.c | |||
@@ -674,7 +674,7 @@ int pcibios_add_device(struct pci_dev *dev) | |||
674 | 674 | ||
675 | pa_data = boot_params.hdr.setup_data; | 675 | pa_data = boot_params.hdr.setup_data; |
676 | while (pa_data) { | 676 | while (pa_data) { |
677 | data = ioremap(pa_data, sizeof(*rom)); | 677 | data = memremap(pa_data, sizeof(*rom), MEMREMAP_WB); |
678 | if (!data) | 678 | if (!data) |
679 | return -ENOMEM; | 679 | return -ENOMEM; |
680 | 680 | ||
@@ -693,7 +693,7 @@ int pcibios_add_device(struct pci_dev *dev) | |||
693 | } | 693 | } |
694 | } | 694 | } |
695 | pa_data = data->next; | 695 | pa_data = data->next; |
696 | iounmap(data); | 696 | memunmap(data); |
697 | } | 697 | } |
698 | set_dma_domain_ops(dev); | 698 | set_dma_domain_ops(dev); |
699 | set_dev_domain_options(dev); | 699 | set_dev_domain_options(dev); |
diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c index f084d8718ac4..6217b23e85f6 100644 --- a/arch/x86/platform/efi/efi.c +++ b/arch/x86/platform/efi/efi.c | |||
@@ -1035,12 +1035,12 @@ void __init efi_enter_virtual_mode(void) | |||
1035 | /* | 1035 | /* |
1036 | * Convenience functions to obtain memory types and attributes | 1036 | * Convenience functions to obtain memory types and attributes |
1037 | */ | 1037 | */ |
1038 | u32 efi_mem_type(unsigned long phys_addr) | 1038 | int efi_mem_type(unsigned long phys_addr) |
1039 | { | 1039 | { |
1040 | efi_memory_desc_t *md; | 1040 | efi_memory_desc_t *md; |
1041 | 1041 | ||
1042 | if (!efi_enabled(EFI_MEMMAP)) | 1042 | if (!efi_enabled(EFI_MEMMAP)) |
1043 | return 0; | 1043 | return -ENOTSUPP; |
1044 | 1044 | ||
1045 | for_each_efi_memory_desc(md) { | 1045 | for_each_efi_memory_desc(md) { |
1046 | if ((md->phys_addr <= phys_addr) && | 1046 | if ((md->phys_addr <= phys_addr) && |
@@ -1048,7 +1048,7 @@ u32 efi_mem_type(unsigned long phys_addr) | |||
1048 | (md->num_pages << EFI_PAGE_SHIFT)))) | 1048 | (md->num_pages << EFI_PAGE_SHIFT)))) |
1049 | return md->type; | 1049 | return md->type; |
1050 | } | 1050 | } |
1051 | return 0; | 1051 | return -EINVAL; |
1052 | } | 1052 | } |
1053 | 1053 | ||
1054 | static int __init arch_parse_efi_cmdline(char *str) | 1054 | static int __init arch_parse_efi_cmdline(char *str) |
diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c index 9bf72f5bfedb..12e83888e5b9 100644 --- a/arch/x86/platform/efi/efi_64.c +++ b/arch/x86/platform/efi/efi_64.c | |||
@@ -327,7 +327,7 @@ virt_to_phys_or_null_size(void *va, unsigned long size) | |||
327 | 327 | ||
328 | int __init efi_setup_page_tables(unsigned long pa_memmap, unsigned num_pages) | 328 | int __init efi_setup_page_tables(unsigned long pa_memmap, unsigned num_pages) |
329 | { | 329 | { |
330 | unsigned long pfn, text; | 330 | unsigned long pfn, text, pf; |
331 | struct page *page; | 331 | struct page *page; |
332 | unsigned npages; | 332 | unsigned npages; |
333 | pgd_t *pgd; | 333 | pgd_t *pgd; |
@@ -335,7 +335,12 @@ int __init efi_setup_page_tables(unsigned long pa_memmap, unsigned num_pages) | |||
335 | if (efi_enabled(EFI_OLD_MEMMAP)) | 335 | if (efi_enabled(EFI_OLD_MEMMAP)) |
336 | return 0; | 336 | return 0; |
337 | 337 | ||
338 | efi_scratch.efi_pgt = (pgd_t *)__pa(efi_pgd); | 338 | /* |
339 | * Since the PGD is encrypted, set the encryption mask so that when | ||
340 | * this value is loaded into cr3 the PGD will be decrypted during | ||
341 | * the pagetable walk. | ||
342 | */ | ||
343 | efi_scratch.efi_pgt = (pgd_t *)__sme_pa(efi_pgd); | ||
339 | pgd = efi_pgd; | 344 | pgd = efi_pgd; |
340 | 345 | ||
341 | /* | 346 | /* |
@@ -345,7 +350,8 @@ int __init efi_setup_page_tables(unsigned long pa_memmap, unsigned num_pages) | |||
345 | * phys_efi_set_virtual_address_map(). | 350 | * phys_efi_set_virtual_address_map(). |
346 | */ | 351 | */ |
347 | pfn = pa_memmap >> PAGE_SHIFT; | 352 | pfn = pa_memmap >> PAGE_SHIFT; |
348 | if (kernel_map_pages_in_pgd(pgd, pfn, pa_memmap, num_pages, _PAGE_NX | _PAGE_RW)) { | 353 | pf = _PAGE_NX | _PAGE_RW | _PAGE_ENC; |
354 | if (kernel_map_pages_in_pgd(pgd, pfn, pa_memmap, num_pages, pf)) { | ||
349 | pr_err("Error ident-mapping new memmap (0x%lx)!\n", pa_memmap); | 355 | pr_err("Error ident-mapping new memmap (0x%lx)!\n", pa_memmap); |
350 | return 1; | 356 | return 1; |
351 | } | 357 | } |
@@ -388,7 +394,8 @@ int __init efi_setup_page_tables(unsigned long pa_memmap, unsigned num_pages) | |||
388 | text = __pa(_text); | 394 | text = __pa(_text); |
389 | pfn = text >> PAGE_SHIFT; | 395 | pfn = text >> PAGE_SHIFT; |
390 | 396 | ||
391 | if (kernel_map_pages_in_pgd(pgd, pfn, text, npages, _PAGE_RW)) { | 397 | pf = _PAGE_RW | _PAGE_ENC; |
398 | if (kernel_map_pages_in_pgd(pgd, pfn, text, npages, pf)) { | ||
392 | pr_err("Failed to map kernel text 1:1\n"); | 399 | pr_err("Failed to map kernel text 1:1\n"); |
393 | return 1; | 400 | return 1; |
394 | } | 401 | } |
diff --git a/arch/x86/platform/uv/tlb_uv.c b/arch/x86/platform/uv/tlb_uv.c index 3e4bdb442fbc..f44c0bc95aa2 100644 --- a/arch/x86/platform/uv/tlb_uv.c +++ b/arch/x86/platform/uv/tlb_uv.c | |||
@@ -26,7 +26,7 @@ | |||
26 | static struct bau_operations ops __ro_after_init; | 26 | static struct bau_operations ops __ro_after_init; |
27 | 27 | ||
28 | /* timeouts in nanoseconds (indexed by UVH_AGING_PRESCALE_SEL urgency7 30:28) */ | 28 | /* timeouts in nanoseconds (indexed by UVH_AGING_PRESCALE_SEL urgency7 30:28) */ |
29 | static int timeout_base_ns[] = { | 29 | static const int timeout_base_ns[] = { |
30 | 20, | 30 | 20, |
31 | 160, | 31 | 160, |
32 | 1280, | 32 | 1280, |
@@ -1216,7 +1216,7 @@ static struct bau_pq_entry *find_another_by_swack(struct bau_pq_entry *msg, | |||
1216 | * set a bit in the UVH_LB_BAU_INTD_SOFTWARE_ACKNOWLEDGE register. | 1216 | * set a bit in the UVH_LB_BAU_INTD_SOFTWARE_ACKNOWLEDGE register. |
1217 | * Such a message must be ignored. | 1217 | * Such a message must be ignored. |
1218 | */ | 1218 | */ |
1219 | void process_uv2_message(struct msg_desc *mdp, struct bau_control *bcp) | 1219 | static void process_uv2_message(struct msg_desc *mdp, struct bau_control *bcp) |
1220 | { | 1220 | { |
1221 | unsigned long mmr_image; | 1221 | unsigned long mmr_image; |
1222 | unsigned char swack_vec; | 1222 | unsigned char swack_vec; |
diff --git a/arch/x86/realmode/init.c b/arch/x86/realmode/init.c index cd4be19c36dc..1f71980fc5e0 100644 --- a/arch/x86/realmode/init.c +++ b/arch/x86/realmode/init.c | |||
@@ -1,6 +1,7 @@ | |||
1 | #include <linux/io.h> | 1 | #include <linux/io.h> |
2 | #include <linux/slab.h> | 2 | #include <linux/slab.h> |
3 | #include <linux/memblock.h> | 3 | #include <linux/memblock.h> |
4 | #include <linux/mem_encrypt.h> | ||
4 | 5 | ||
5 | #include <asm/set_memory.h> | 6 | #include <asm/set_memory.h> |
6 | #include <asm/pgtable.h> | 7 | #include <asm/pgtable.h> |
@@ -59,6 +60,13 @@ static void __init setup_real_mode(void) | |||
59 | 60 | ||
60 | base = (unsigned char *)real_mode_header; | 61 | base = (unsigned char *)real_mode_header; |
61 | 62 | ||
63 | /* | ||
64 | * If SME is active, the trampoline area will need to be in | ||
65 | * decrypted memory in order to bring up other processors | ||
66 | * successfully. | ||
67 | */ | ||
68 | set_memory_decrypted((unsigned long)base, size >> PAGE_SHIFT); | ||
69 | |||
62 | memcpy(base, real_mode_blob, size); | 70 | memcpy(base, real_mode_blob, size); |
63 | 71 | ||
64 | phys_base = __pa(base); | 72 | phys_base = __pa(base); |
@@ -100,6 +108,10 @@ static void __init setup_real_mode(void) | |||
100 | trampoline_cr4_features = &trampoline_header->cr4; | 108 | trampoline_cr4_features = &trampoline_header->cr4; |
101 | *trampoline_cr4_features = mmu_cr4_features; | 109 | *trampoline_cr4_features = mmu_cr4_features; |
102 | 110 | ||
111 | trampoline_header->flags = 0; | ||
112 | if (sme_active()) | ||
113 | trampoline_header->flags |= TH_FLAGS_SME_ACTIVE; | ||
114 | |||
103 | trampoline_pgd = (u64 *) __va(real_mode_header->trampoline_pgd); | 115 | trampoline_pgd = (u64 *) __va(real_mode_header->trampoline_pgd); |
104 | trampoline_pgd[0] = trampoline_pgd_entry.pgd; | 116 | trampoline_pgd[0] = trampoline_pgd_entry.pgd; |
105 | trampoline_pgd[511] = init_top_pgt[511].pgd; | 117 | trampoline_pgd[511] = init_top_pgt[511].pgd; |
diff --git a/arch/x86/realmode/rm/trampoline_64.S b/arch/x86/realmode/rm/trampoline_64.S index dac7b20d2f9d..614fd7064d0a 100644 --- a/arch/x86/realmode/rm/trampoline_64.S +++ b/arch/x86/realmode/rm/trampoline_64.S | |||
@@ -30,6 +30,7 @@ | |||
30 | #include <asm/msr.h> | 30 | #include <asm/msr.h> |
31 | #include <asm/segment.h> | 31 | #include <asm/segment.h> |
32 | #include <asm/processor-flags.h> | 32 | #include <asm/processor-flags.h> |
33 | #include <asm/realmode.h> | ||
33 | #include "realmode.h" | 34 | #include "realmode.h" |
34 | 35 | ||
35 | .text | 36 | .text |
@@ -92,6 +93,28 @@ ENTRY(startup_32) | |||
92 | movl %edx, %fs | 93 | movl %edx, %fs |
93 | movl %edx, %gs | 94 | movl %edx, %gs |
94 | 95 | ||
96 | /* | ||
97 | * Check for memory encryption support. This is a safety net in | ||
98 | * case BIOS hasn't done the necessary step of setting the bit in | ||
99 | * the MSR for this AP. If SME is active and we've gotten this far | ||
100 | * then it is safe for us to set the MSR bit and continue. If we | ||
101 | * don't we'll eventually crash trying to execute encrypted | ||
102 | * instructions. | ||
103 | */ | ||
104 | bt $TH_FLAGS_SME_ACTIVE_BIT, pa_tr_flags | ||
105 | jnc .Ldone | ||
106 | movl $MSR_K8_SYSCFG, %ecx | ||
107 | rdmsr | ||
108 | bts $MSR_K8_SYSCFG_MEM_ENCRYPT_BIT, %eax | ||
109 | jc .Ldone | ||
110 | |||
111 | /* | ||
112 | * Memory encryption is enabled but the SME enable bit for this | ||
113 | * CPU has has not been set. It is safe to set it, so do so. | ||
114 | */ | ||
115 | wrmsr | ||
116 | .Ldone: | ||
117 | |||
95 | movl pa_tr_cr4, %eax | 118 | movl pa_tr_cr4, %eax |
96 | movl %eax, %cr4 # Enable PAE mode | 119 | movl %eax, %cr4 # Enable PAE mode |
97 | 120 | ||
@@ -147,6 +170,7 @@ GLOBAL(trampoline_header) | |||
147 | tr_start: .space 8 | 170 | tr_start: .space 8 |
148 | GLOBAL(tr_efer) .space 8 | 171 | GLOBAL(tr_efer) .space 8 |
149 | GLOBAL(tr_cr4) .space 4 | 172 | GLOBAL(tr_cr4) .space 4 |
173 | GLOBAL(tr_flags) .space 4 | ||
150 | END(trampoline_header) | 174 | END(trampoline_header) |
151 | 175 | ||
152 | #include "trampoline_common.S" | 176 | #include "trampoline_common.S" |
diff --git a/arch/x86/xen/Kconfig b/arch/x86/xen/Kconfig index 027987638e98..1ecd419811a2 100644 --- a/arch/x86/xen/Kconfig +++ b/arch/x86/xen/Kconfig | |||
@@ -17,6 +17,9 @@ config XEN_PV | |||
17 | bool "Xen PV guest support" | 17 | bool "Xen PV guest support" |
18 | default y | 18 | default y |
19 | depends on XEN | 19 | depends on XEN |
20 | # XEN_PV is not ready to work with 5-level paging. | ||
21 | # Changes to hypervisor are also required. | ||
22 | depends on !X86_5LEVEL | ||
20 | select XEN_HAVE_PVMMU | 23 | select XEN_HAVE_PVMMU |
21 | select XEN_HAVE_VPMU | 24 | select XEN_HAVE_VPMU |
22 | help | 25 | help |
@@ -75,4 +78,6 @@ config XEN_DEBUG_FS | |||
75 | config XEN_PVH | 78 | config XEN_PVH |
76 | bool "Support for running as a PVH guest" | 79 | bool "Support for running as a PVH guest" |
77 | depends on XEN && XEN_PVHVM && ACPI | 80 | depends on XEN && XEN_PVHVM && ACPI |
81 | # Pre-built page tables are not ready to handle 5-level paging. | ||
82 | depends on !X86_5LEVEL | ||
78 | def_bool n | 83 | def_bool n |
diff --git a/arch/x86/xen/enlighten_hvm.c b/arch/x86/xen/enlighten_hvm.c index 87d791356ea9..de503c225ae1 100644 --- a/arch/x86/xen/enlighten_hvm.c +++ b/arch/x86/xen/enlighten_hvm.c | |||
@@ -12,6 +12,7 @@ | |||
12 | #include <asm/setup.h> | 12 | #include <asm/setup.h> |
13 | #include <asm/hypervisor.h> | 13 | #include <asm/hypervisor.h> |
14 | #include <asm/e820/api.h> | 14 | #include <asm/e820/api.h> |
15 | #include <asm/early_ioremap.h> | ||
15 | 16 | ||
16 | #include <asm/xen/cpuid.h> | 17 | #include <asm/xen/cpuid.h> |
17 | #include <asm/xen/hypervisor.h> | 18 | #include <asm/xen/hypervisor.h> |
@@ -21,38 +22,50 @@ | |||
21 | #include "mmu.h" | 22 | #include "mmu.h" |
22 | #include "smp.h" | 23 | #include "smp.h" |
23 | 24 | ||
24 | void __ref xen_hvm_init_shared_info(void) | 25 | static unsigned long shared_info_pfn; |
26 | |||
27 | void xen_hvm_init_shared_info(void) | ||
25 | { | 28 | { |
26 | struct xen_add_to_physmap xatp; | 29 | struct xen_add_to_physmap xatp; |
27 | u64 pa; | ||
28 | |||
29 | if (HYPERVISOR_shared_info == &xen_dummy_shared_info) { | ||
30 | /* | ||
31 | * Search for a free page starting at 4kB physical address. | ||
32 | * Low memory is preferred to avoid an EPT large page split up | ||
33 | * by the mapping. | ||
34 | * Starting below X86_RESERVE_LOW (usually 64kB) is fine as | ||
35 | * the BIOS used for HVM guests is well behaved and won't | ||
36 | * clobber memory other than the first 4kB. | ||
37 | */ | ||
38 | for (pa = PAGE_SIZE; | ||
39 | !e820__mapped_all(pa, pa + PAGE_SIZE, E820_TYPE_RAM) || | ||
40 | memblock_is_reserved(pa); | ||
41 | pa += PAGE_SIZE) | ||
42 | ; | ||
43 | |||
44 | memblock_reserve(pa, PAGE_SIZE); | ||
45 | HYPERVISOR_shared_info = __va(pa); | ||
46 | } | ||
47 | 30 | ||
48 | xatp.domid = DOMID_SELF; | 31 | xatp.domid = DOMID_SELF; |
49 | xatp.idx = 0; | 32 | xatp.idx = 0; |
50 | xatp.space = XENMAPSPACE_shared_info; | 33 | xatp.space = XENMAPSPACE_shared_info; |
51 | xatp.gpfn = virt_to_pfn(HYPERVISOR_shared_info); | 34 | xatp.gpfn = shared_info_pfn; |
52 | if (HYPERVISOR_memory_op(XENMEM_add_to_physmap, &xatp)) | 35 | if (HYPERVISOR_memory_op(XENMEM_add_to_physmap, &xatp)) |
53 | BUG(); | 36 | BUG(); |
54 | } | 37 | } |
55 | 38 | ||
39 | static void __init reserve_shared_info(void) | ||
40 | { | ||
41 | u64 pa; | ||
42 | |||
43 | /* | ||
44 | * Search for a free page starting at 4kB physical address. | ||
45 | * Low memory is preferred to avoid an EPT large page split up | ||
46 | * by the mapping. | ||
47 | * Starting below X86_RESERVE_LOW (usually 64kB) is fine as | ||
48 | * the BIOS used for HVM guests is well behaved and won't | ||
49 | * clobber memory other than the first 4kB. | ||
50 | */ | ||
51 | for (pa = PAGE_SIZE; | ||
52 | !e820__mapped_all(pa, pa + PAGE_SIZE, E820_TYPE_RAM) || | ||
53 | memblock_is_reserved(pa); | ||
54 | pa += PAGE_SIZE) | ||
55 | ; | ||
56 | |||
57 | shared_info_pfn = PHYS_PFN(pa); | ||
58 | |||
59 | memblock_reserve(pa, PAGE_SIZE); | ||
60 | HYPERVISOR_shared_info = early_memremap(pa, PAGE_SIZE); | ||
61 | } | ||
62 | |||
63 | static void __init xen_hvm_init_mem_mapping(void) | ||
64 | { | ||
65 | early_memunmap(HYPERVISOR_shared_info, PAGE_SIZE); | ||
66 | HYPERVISOR_shared_info = __va(PFN_PHYS(shared_info_pfn)); | ||
67 | } | ||
68 | |||
56 | static void __init init_hvm_pv_info(void) | 69 | static void __init init_hvm_pv_info(void) |
57 | { | 70 | { |
58 | int major, minor; | 71 | int major, minor; |
@@ -153,6 +166,7 @@ static void __init xen_hvm_guest_init(void) | |||
153 | 166 | ||
154 | init_hvm_pv_info(); | 167 | init_hvm_pv_info(); |
155 | 168 | ||
169 | reserve_shared_info(); | ||
156 | xen_hvm_init_shared_info(); | 170 | xen_hvm_init_shared_info(); |
157 | 171 | ||
158 | /* | 172 | /* |
@@ -218,5 +232,6 @@ const struct hypervisor_x86 x86_hyper_xen_hvm = { | |||
218 | .init_platform = xen_hvm_guest_init, | 232 | .init_platform = xen_hvm_guest_init, |
219 | .pin_vcpu = xen_pin_vcpu, | 233 | .pin_vcpu = xen_pin_vcpu, |
220 | .x2apic_available = xen_x2apic_para_available, | 234 | .x2apic_available = xen_x2apic_para_available, |
235 | .init_mem_mapping = xen_hvm_init_mem_mapping, | ||
221 | }; | 236 | }; |
222 | EXPORT_SYMBOL(x86_hyper_xen_hvm); | 237 | EXPORT_SYMBOL(x86_hyper_xen_hvm); |
diff --git a/arch/x86/xen/enlighten_pv.c b/arch/x86/xen/enlighten_pv.c index 811e4ddb3f37..df1921751aa5 100644 --- a/arch/x86/xen/enlighten_pv.c +++ b/arch/x86/xen/enlighten_pv.c | |||
@@ -263,6 +263,13 @@ static void __init xen_init_capabilities(void) | |||
263 | setup_clear_cpu_cap(X86_FEATURE_MTRR); | 263 | setup_clear_cpu_cap(X86_FEATURE_MTRR); |
264 | setup_clear_cpu_cap(X86_FEATURE_ACC); | 264 | setup_clear_cpu_cap(X86_FEATURE_ACC); |
265 | setup_clear_cpu_cap(X86_FEATURE_X2APIC); | 265 | setup_clear_cpu_cap(X86_FEATURE_X2APIC); |
266 | setup_clear_cpu_cap(X86_FEATURE_SME); | ||
267 | |||
268 | /* | ||
269 | * Xen PV would need some work to support PCID: CR3 handling as well | ||
270 | * as xen_flush_tlb_others() would need updating. | ||
271 | */ | ||
272 | setup_clear_cpu_cap(X86_FEATURE_PCID); | ||
266 | 273 | ||
267 | if (!xen_initial_domain()) | 274 | if (!xen_initial_domain()) |
268 | setup_clear_cpu_cap(X86_FEATURE_ACPI); | 275 | setup_clear_cpu_cap(X86_FEATURE_ACPI); |
diff --git a/arch/x86/xen/mmu_pv.c b/arch/x86/xen/mmu_pv.c index cab28cf2cffb..e437714750f8 100644 --- a/arch/x86/xen/mmu_pv.c +++ b/arch/x86/xen/mmu_pv.c | |||
@@ -1005,14 +1005,12 @@ static void xen_drop_mm_ref(struct mm_struct *mm) | |||
1005 | /* Get the "official" set of cpus referring to our pagetable. */ | 1005 | /* Get the "official" set of cpus referring to our pagetable. */ |
1006 | if (!alloc_cpumask_var(&mask, GFP_ATOMIC)) { | 1006 | if (!alloc_cpumask_var(&mask, GFP_ATOMIC)) { |
1007 | for_each_online_cpu(cpu) { | 1007 | for_each_online_cpu(cpu) { |
1008 | if (!cpumask_test_cpu(cpu, mm_cpumask(mm)) | 1008 | if (per_cpu(xen_current_cr3, cpu) != __pa(mm->pgd)) |
1009 | && per_cpu(xen_current_cr3, cpu) != __pa(mm->pgd)) | ||
1010 | continue; | 1009 | continue; |
1011 | smp_call_function_single(cpu, drop_mm_ref_this_cpu, mm, 1); | 1010 | smp_call_function_single(cpu, drop_mm_ref_this_cpu, mm, 1); |
1012 | } | 1011 | } |
1013 | return; | 1012 | return; |
1014 | } | 1013 | } |
1015 | cpumask_copy(mask, mm_cpumask(mm)); | ||
1016 | 1014 | ||
1017 | /* | 1015 | /* |
1018 | * It's possible that a vcpu may have a stale reference to our | 1016 | * It's possible that a vcpu may have a stale reference to our |
@@ -1021,6 +1019,7 @@ static void xen_drop_mm_ref(struct mm_struct *mm) | |||
1021 | * look at its actual current cr3 value, and force it to flush | 1019 | * look at its actual current cr3 value, and force it to flush |
1022 | * if needed. | 1020 | * if needed. |
1023 | */ | 1021 | */ |
1022 | cpumask_clear(mask); | ||
1024 | for_each_online_cpu(cpu) { | 1023 | for_each_online_cpu(cpu) { |
1025 | if (per_cpu(xen_current_cr3, cpu) == __pa(mm->pgd)) | 1024 | if (per_cpu(xen_current_cr3, cpu) == __pa(mm->pgd)) |
1026 | cpumask_set_cpu(cpu, mask); | 1025 | cpumask_set_cpu(cpu, mask); |
diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S index 72a8e6adebe6..a7525e95d53f 100644 --- a/arch/x86/xen/xen-head.S +++ b/arch/x86/xen/xen-head.S | |||
@@ -58,7 +58,7 @@ ENTRY(hypercall_page) | |||
58 | #else | 58 | #else |
59 | ELFNOTE(Xen, XEN_ELFNOTE_VIRT_BASE, _ASM_PTR __START_KERNEL_map) | 59 | ELFNOTE(Xen, XEN_ELFNOTE_VIRT_BASE, _ASM_PTR __START_KERNEL_map) |
60 | /* Map the p2m table to a 512GB-aligned user address. */ | 60 | /* Map the p2m table to a 512GB-aligned user address. */ |
61 | ELFNOTE(Xen, XEN_ELFNOTE_INIT_P2M, .quad PGDIR_SIZE) | 61 | ELFNOTE(Xen, XEN_ELFNOTE_INIT_P2M, .quad (PUD_SIZE * PTRS_PER_PUD)) |
62 | #endif | 62 | #endif |
63 | #ifdef CONFIG_XEN_PV | 63 | #ifdef CONFIG_XEN_PV |
64 | ELFNOTE(Xen, XEN_ELFNOTE_ENTRY, _ASM_PTR startup_xen) | 64 | ELFNOTE(Xen, XEN_ELFNOTE_ENTRY, _ASM_PTR startup_xen) |
diff --git a/block/bio-integrity.c b/block/bio-integrity.c index 83e92beb3c9f..9b1ea478577b 100644 --- a/block/bio-integrity.c +++ b/block/bio-integrity.c | |||
@@ -387,9 +387,11 @@ static void bio_integrity_verify_fn(struct work_struct *work) | |||
387 | */ | 387 | */ |
388 | bool __bio_integrity_endio(struct bio *bio) | 388 | bool __bio_integrity_endio(struct bio *bio) |
389 | { | 389 | { |
390 | if (bio_op(bio) == REQ_OP_READ && !bio->bi_status) { | 390 | struct blk_integrity *bi = bdev_get_integrity(bio->bi_bdev); |
391 | struct bio_integrity_payload *bip = bio_integrity(bio); | 391 | struct bio_integrity_payload *bip = bio_integrity(bio); |
392 | 392 | ||
393 | if (bio_op(bio) == REQ_OP_READ && !bio->bi_status && | ||
394 | (bip->bip_flags & BIP_BLOCK_INTEGRITY) && bi->profile->verify_fn) { | ||
393 | INIT_WORK(&bip->bip_work, bio_integrity_verify_fn); | 395 | INIT_WORK(&bip->bip_work, bio_integrity_verify_fn); |
394 | queue_work(kintegrityd_wq, &bip->bip_work); | 396 | queue_work(kintegrityd_wq, &bip->bip_work); |
395 | return false; | 397 | return false; |
diff --git a/block/blk-mq-pci.c b/block/blk-mq-pci.c index 0c3354cf3552..76944e3271bf 100644 --- a/block/blk-mq-pci.c +++ b/block/blk-mq-pci.c | |||
@@ -36,12 +36,18 @@ int blk_mq_pci_map_queues(struct blk_mq_tag_set *set, struct pci_dev *pdev) | |||
36 | for (queue = 0; queue < set->nr_hw_queues; queue++) { | 36 | for (queue = 0; queue < set->nr_hw_queues; queue++) { |
37 | mask = pci_irq_get_affinity(pdev, queue); | 37 | mask = pci_irq_get_affinity(pdev, queue); |
38 | if (!mask) | 38 | if (!mask) |
39 | return -EINVAL; | 39 | goto fallback; |
40 | 40 | ||
41 | for_each_cpu(cpu, mask) | 41 | for_each_cpu(cpu, mask) |
42 | set->mq_map[cpu] = queue; | 42 | set->mq_map[cpu] = queue; |
43 | } | 43 | } |
44 | 44 | ||
45 | return 0; | 45 | return 0; |
46 | |||
47 | fallback: | ||
48 | WARN_ON_ONCE(set->nr_hw_queues > 1); | ||
49 | for_each_possible_cpu(cpu) | ||
50 | set->mq_map[cpu] = 0; | ||
51 | return 0; | ||
46 | } | 52 | } |
47 | EXPORT_SYMBOL_GPL(blk_mq_pci_map_queues); | 53 | EXPORT_SYMBOL_GPL(blk_mq_pci_map_queues); |
diff --git a/block/blk-mq.c b/block/blk-mq.c index 211ef367345f..4603b115e234 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c | |||
@@ -360,12 +360,12 @@ struct request *blk_mq_alloc_request(struct request_queue *q, unsigned int op, | |||
360 | return ERR_PTR(ret); | 360 | return ERR_PTR(ret); |
361 | 361 | ||
362 | rq = blk_mq_get_request(q, NULL, op, &alloc_data); | 362 | rq = blk_mq_get_request(q, NULL, op, &alloc_data); |
363 | blk_queue_exit(q); | ||
363 | 364 | ||
364 | if (!rq) | 365 | if (!rq) |
365 | return ERR_PTR(-EWOULDBLOCK); | 366 | return ERR_PTR(-EWOULDBLOCK); |
366 | 367 | ||
367 | blk_mq_put_ctx(alloc_data.ctx); | 368 | blk_mq_put_ctx(alloc_data.ctx); |
368 | blk_queue_exit(q); | ||
369 | 369 | ||
370 | rq->__data_len = 0; | 370 | rq->__data_len = 0; |
371 | rq->__sector = (sector_t) -1; | 371 | rq->__sector = (sector_t) -1; |
@@ -411,12 +411,11 @@ struct request *blk_mq_alloc_request_hctx(struct request_queue *q, | |||
411 | alloc_data.ctx = __blk_mq_get_ctx(q, cpu); | 411 | alloc_data.ctx = __blk_mq_get_ctx(q, cpu); |
412 | 412 | ||
413 | rq = blk_mq_get_request(q, NULL, op, &alloc_data); | 413 | rq = blk_mq_get_request(q, NULL, op, &alloc_data); |
414 | blk_queue_exit(q); | ||
414 | 415 | ||
415 | if (!rq) | 416 | if (!rq) |
416 | return ERR_PTR(-EWOULDBLOCK); | 417 | return ERR_PTR(-EWOULDBLOCK); |
417 | 418 | ||
418 | blk_queue_exit(q); | ||
419 | |||
420 | return rq; | 419 | return rq; |
421 | } | 420 | } |
422 | EXPORT_SYMBOL_GPL(blk_mq_alloc_request_hctx); | 421 | EXPORT_SYMBOL_GPL(blk_mq_alloc_request_hctx); |
@@ -684,8 +683,8 @@ EXPORT_SYMBOL(blk_mq_kick_requeue_list); | |||
684 | void blk_mq_delay_kick_requeue_list(struct request_queue *q, | 683 | void blk_mq_delay_kick_requeue_list(struct request_queue *q, |
685 | unsigned long msecs) | 684 | unsigned long msecs) |
686 | { | 685 | { |
687 | kblockd_schedule_delayed_work(&q->requeue_work, | 686 | kblockd_mod_delayed_work_on(WORK_CPU_UNBOUND, &q->requeue_work, |
688 | msecs_to_jiffies(msecs)); | 687 | msecs_to_jiffies(msecs)); |
689 | } | 688 | } |
690 | EXPORT_SYMBOL(blk_mq_delay_kick_requeue_list); | 689 | EXPORT_SYMBOL(blk_mq_delay_kick_requeue_list); |
691 | 690 | ||
diff --git a/drivers/acpi/acpica/nsxfeval.c b/drivers/acpi/acpica/nsxfeval.c index 538c61677c10..783f4c838aee 100644 --- a/drivers/acpi/acpica/nsxfeval.c +++ b/drivers/acpi/acpica/nsxfeval.c | |||
@@ -100,9 +100,13 @@ acpi_evaluate_object_typed(acpi_handle handle, | |||
100 | free_buffer_on_error = TRUE; | 100 | free_buffer_on_error = TRUE; |
101 | } | 101 | } |
102 | 102 | ||
103 | status = acpi_get_handle(handle, pathname, &target_handle); | 103 | if (pathname) { |
104 | if (ACPI_FAILURE(status)) { | 104 | status = acpi_get_handle(handle, pathname, &target_handle); |
105 | return_ACPI_STATUS(status); | 105 | if (ACPI_FAILURE(status)) { |
106 | return_ACPI_STATUS(status); | ||
107 | } | ||
108 | } else { | ||
109 | target_handle = handle; | ||
106 | } | 110 | } |
107 | 111 | ||
108 | full_pathname = acpi_ns_get_external_pathname(target_handle); | 112 | full_pathname = acpi_ns_get_external_pathname(target_handle); |
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c index 62068a5e814f..ae3d6d152633 100644 --- a/drivers/acpi/ec.c +++ b/drivers/acpi/ec.c | |||
@@ -1741,7 +1741,7 @@ error: | |||
1741 | * functioning ECDT EC first in order to handle the events. | 1741 | * functioning ECDT EC first in order to handle the events. |
1742 | * https://bugzilla.kernel.org/show_bug.cgi?id=115021 | 1742 | * https://bugzilla.kernel.org/show_bug.cgi?id=115021 |
1743 | */ | 1743 | */ |
1744 | int __init acpi_ec_ecdt_start(void) | 1744 | static int __init acpi_ec_ecdt_start(void) |
1745 | { | 1745 | { |
1746 | acpi_handle handle; | 1746 | acpi_handle handle; |
1747 | 1747 | ||
@@ -2003,20 +2003,17 @@ static inline void acpi_ec_query_exit(void) | |||
2003 | int __init acpi_ec_init(void) | 2003 | int __init acpi_ec_init(void) |
2004 | { | 2004 | { |
2005 | int result; | 2005 | int result; |
2006 | int ecdt_fail, dsdt_fail; | ||
2006 | 2007 | ||
2007 | /* register workqueue for _Qxx evaluations */ | 2008 | /* register workqueue for _Qxx evaluations */ |
2008 | result = acpi_ec_query_init(); | 2009 | result = acpi_ec_query_init(); |
2009 | if (result) | 2010 | if (result) |
2010 | goto err_exit; | 2011 | return result; |
2011 | /* Now register the driver for the EC */ | ||
2012 | result = acpi_bus_register_driver(&acpi_ec_driver); | ||
2013 | if (result) | ||
2014 | goto err_exit; | ||
2015 | 2012 | ||
2016 | err_exit: | 2013 | /* Drivers must be started after acpi_ec_query_init() */ |
2017 | if (result) | 2014 | ecdt_fail = acpi_ec_ecdt_start(); |
2018 | acpi_ec_query_exit(); | 2015 | dsdt_fail = acpi_bus_register_driver(&acpi_ec_driver); |
2019 | return result; | 2016 | return ecdt_fail && dsdt_fail ? -ENODEV : 0; |
2020 | } | 2017 | } |
2021 | 2018 | ||
2022 | /* EC driver currently not unloadable */ | 2019 | /* EC driver currently not unloadable */ |
diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h index 58dd7ab3c653..3f5af4d7a739 100644 --- a/drivers/acpi/internal.h +++ b/drivers/acpi/internal.h | |||
@@ -185,7 +185,6 @@ typedef int (*acpi_ec_query_func) (void *data); | |||
185 | int acpi_ec_init(void); | 185 | int acpi_ec_init(void); |
186 | int acpi_ec_ecdt_probe(void); | 186 | int acpi_ec_ecdt_probe(void); |
187 | int acpi_ec_dsdt_probe(void); | 187 | int acpi_ec_dsdt_probe(void); |
188 | int acpi_ec_ecdt_start(void); | ||
189 | void acpi_ec_block_transactions(void); | 188 | void acpi_ec_block_transactions(void); |
190 | void acpi_ec_unblock_transactions(void); | 189 | void acpi_ec_unblock_transactions(void); |
191 | int acpi_ec_add_query_handler(struct acpi_ec *ec, u8 query_bit, | 190 | int acpi_ec_add_query_handler(struct acpi_ec *ec, u8 query_bit, |
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c index 5c8aa9cf62d7..fe3d2a40f311 100644 --- a/drivers/acpi/processor_idle.c +++ b/drivers/acpi/processor_idle.c | |||
@@ -708,8 +708,6 @@ static DEFINE_RAW_SPINLOCK(c3_lock); | |||
708 | static void acpi_idle_enter_bm(struct acpi_processor *pr, | 708 | static void acpi_idle_enter_bm(struct acpi_processor *pr, |
709 | struct acpi_processor_cx *cx, bool timer_bc) | 709 | struct acpi_processor_cx *cx, bool timer_bc) |
710 | { | 710 | { |
711 | acpi_unlazy_tlb(smp_processor_id()); | ||
712 | |||
713 | /* | 711 | /* |
714 | * Must be done before busmaster disable as we might need to | 712 | * Must be done before busmaster disable as we might need to |
715 | * access HPET ! | 713 | * access HPET ! |
diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c index 917c789f953d..476a52c60cf3 100644 --- a/drivers/acpi/property.c +++ b/drivers/acpi/property.c | |||
@@ -1047,7 +1047,7 @@ static struct fwnode_handle *acpi_graph_get_child_prop_value( | |||
1047 | fwnode_for_each_child_node(fwnode, child) { | 1047 | fwnode_for_each_child_node(fwnode, child) { |
1048 | u32 nr; | 1048 | u32 nr; |
1049 | 1049 | ||
1050 | if (!fwnode_property_read_u32(fwnode, prop_name, &nr)) | 1050 | if (fwnode_property_read_u32(child, prop_name, &nr)) |
1051 | continue; | 1051 | continue; |
1052 | 1052 | ||
1053 | if (val == nr) | 1053 | if (val == nr) |
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 33897298f03e..70fd5502c284 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c | |||
@@ -2084,7 +2084,6 @@ int __init acpi_scan_init(void) | |||
2084 | 2084 | ||
2085 | acpi_gpe_apply_masked_gpes(); | 2085 | acpi_gpe_apply_masked_gpes(); |
2086 | acpi_update_all_gpes(); | 2086 | acpi_update_all_gpes(); |
2087 | acpi_ec_ecdt_start(); | ||
2088 | 2087 | ||
2089 | acpi_scan_initialized = true; | 2088 | acpi_scan_initialized = true; |
2090 | 2089 | ||
diff --git a/drivers/acpi/spcr.c b/drivers/acpi/spcr.c index 4ac3e06b41d8..98aa8c808a33 100644 --- a/drivers/acpi/spcr.c +++ b/drivers/acpi/spcr.c | |||
@@ -17,6 +17,16 @@ | |||
17 | #include <linux/serial_core.h> | 17 | #include <linux/serial_core.h> |
18 | 18 | ||
19 | /* | 19 | /* |
20 | * Erratum 44 for QDF2432v1 and QDF2400v1 SoCs describes the BUSY bit as | ||
21 | * occasionally getting stuck as 1. To avoid the potential for a hang, check | ||
22 | * TXFE == 0 instead of BUSY == 1. This may not be suitable for all UART | ||
23 | * implementations, so only do so if an affected platform is detected in | ||
24 | * parse_spcr(). | ||
25 | */ | ||
26 | bool qdf2400_e44_present; | ||
27 | EXPORT_SYMBOL(qdf2400_e44_present); | ||
28 | |||
29 | /* | ||
20 | * Some Qualcomm Datacenter Technologies SoCs have a defective UART BUSY bit. | 30 | * Some Qualcomm Datacenter Technologies SoCs have a defective UART BUSY bit. |
21 | * Detect them by examining the OEM fields in the SPCR header, similiar to PCI | 31 | * Detect them by examining the OEM fields in the SPCR header, similiar to PCI |
22 | * quirk detection in pci_mcfg.c. | 32 | * quirk detection in pci_mcfg.c. |
@@ -147,8 +157,30 @@ int __init parse_spcr(bool earlycon) | |||
147 | goto done; | 157 | goto done; |
148 | } | 158 | } |
149 | 159 | ||
150 | if (qdf2400_erratum_44_present(&table->header)) | 160 | /* |
151 | uart = "qdf2400_e44"; | 161 | * If the E44 erratum is required, then we need to tell the pl011 |
162 | * driver to implement the work-around. | ||
163 | * | ||
164 | * The global variable is used by the probe function when it | ||
165 | * creates the UARTs, whether or not they're used as a console. | ||
166 | * | ||
167 | * If the user specifies "traditional" earlycon, the qdf2400_e44 | ||
168 | * console name matches the EARLYCON_DECLARE() statement, and | ||
169 | * SPCR is not used. Parameter "earlycon" is false. | ||
170 | * | ||
171 | * If the user specifies "SPCR" earlycon, then we need to update | ||
172 | * the console name so that it also says "qdf2400_e44". Parameter | ||
173 | * "earlycon" is true. | ||
174 | * | ||
175 | * For consistency, if we change the console name, then we do it | ||
176 | * for everyone, not just earlycon. | ||
177 | */ | ||
178 | if (qdf2400_erratum_44_present(&table->header)) { | ||
179 | qdf2400_e44_present = true; | ||
180 | if (earlycon) | ||
181 | uart = "qdf2400_e44"; | ||
182 | } | ||
183 | |||
152 | if (xgene_8250_erratum_present(table)) | 184 | if (xgene_8250_erratum_present(table)) |
153 | iotype = "mmio32"; | 185 | iotype = "mmio32"; |
154 | 186 | ||
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c index b9f907eedbf7..bfbe1e154128 100644 --- a/drivers/base/firmware_class.c +++ b/drivers/base/firmware_class.c | |||
@@ -30,7 +30,6 @@ | |||
30 | #include <linux/syscore_ops.h> | 30 | #include <linux/syscore_ops.h> |
31 | #include <linux/reboot.h> | 31 | #include <linux/reboot.h> |
32 | #include <linux/security.h> | 32 | #include <linux/security.h> |
33 | #include <linux/swait.h> | ||
34 | 33 | ||
35 | #include <generated/utsrelease.h> | 34 | #include <generated/utsrelease.h> |
36 | 35 | ||
@@ -112,13 +111,13 @@ static inline long firmware_loading_timeout(void) | |||
112 | * state of the firmware loading. | 111 | * state of the firmware loading. |
113 | */ | 112 | */ |
114 | struct fw_state { | 113 | struct fw_state { |
115 | struct swait_queue_head wq; | 114 | struct completion completion; |
116 | enum fw_status status; | 115 | enum fw_status status; |
117 | }; | 116 | }; |
118 | 117 | ||
119 | static void fw_state_init(struct fw_state *fw_st) | 118 | static void fw_state_init(struct fw_state *fw_st) |
120 | { | 119 | { |
121 | init_swait_queue_head(&fw_st->wq); | 120 | init_completion(&fw_st->completion); |
122 | fw_st->status = FW_STATUS_UNKNOWN; | 121 | fw_st->status = FW_STATUS_UNKNOWN; |
123 | } | 122 | } |
124 | 123 | ||
@@ -131,9 +130,7 @@ static int __fw_state_wait_common(struct fw_state *fw_st, long timeout) | |||
131 | { | 130 | { |
132 | long ret; | 131 | long ret; |
133 | 132 | ||
134 | ret = swait_event_interruptible_timeout(fw_st->wq, | 133 | ret = wait_for_completion_killable_timeout(&fw_st->completion, timeout); |
135 | __fw_state_is_done(READ_ONCE(fw_st->status)), | ||
136 | timeout); | ||
137 | if (ret != 0 && fw_st->status == FW_STATUS_ABORTED) | 134 | if (ret != 0 && fw_st->status == FW_STATUS_ABORTED) |
138 | return -ENOENT; | 135 | return -ENOENT; |
139 | if (!ret) | 136 | if (!ret) |
@@ -148,35 +145,34 @@ static void __fw_state_set(struct fw_state *fw_st, | |||
148 | WRITE_ONCE(fw_st->status, status); | 145 | WRITE_ONCE(fw_st->status, status); |
149 | 146 | ||
150 | if (status == FW_STATUS_DONE || status == FW_STATUS_ABORTED) | 147 | if (status == FW_STATUS_DONE || status == FW_STATUS_ABORTED) |
151 | swake_up(&fw_st->wq); | 148 | complete_all(&fw_st->completion); |
152 | } | 149 | } |
153 | 150 | ||
154 | #define fw_state_start(fw_st) \ | 151 | #define fw_state_start(fw_st) \ |
155 | __fw_state_set(fw_st, FW_STATUS_LOADING) | 152 | __fw_state_set(fw_st, FW_STATUS_LOADING) |
156 | #define fw_state_done(fw_st) \ | 153 | #define fw_state_done(fw_st) \ |
157 | __fw_state_set(fw_st, FW_STATUS_DONE) | 154 | __fw_state_set(fw_st, FW_STATUS_DONE) |
155 | #define fw_state_aborted(fw_st) \ | ||
156 | __fw_state_set(fw_st, FW_STATUS_ABORTED) | ||
158 | #define fw_state_wait(fw_st) \ | 157 | #define fw_state_wait(fw_st) \ |
159 | __fw_state_wait_common(fw_st, MAX_SCHEDULE_TIMEOUT) | 158 | __fw_state_wait_common(fw_st, MAX_SCHEDULE_TIMEOUT) |
160 | 159 | ||
161 | #ifndef CONFIG_FW_LOADER_USER_HELPER | ||
162 | |||
163 | #define fw_state_is_aborted(fw_st) false | ||
164 | |||
165 | #else /* CONFIG_FW_LOADER_USER_HELPER */ | ||
166 | |||
167 | static int __fw_state_check(struct fw_state *fw_st, enum fw_status status) | 160 | static int __fw_state_check(struct fw_state *fw_st, enum fw_status status) |
168 | { | 161 | { |
169 | return fw_st->status == status; | 162 | return fw_st->status == status; |
170 | } | 163 | } |
171 | 164 | ||
165 | #define fw_state_is_aborted(fw_st) \ | ||
166 | __fw_state_check(fw_st, FW_STATUS_ABORTED) | ||
167 | |||
168 | #ifdef CONFIG_FW_LOADER_USER_HELPER | ||
169 | |||
172 | #define fw_state_aborted(fw_st) \ | 170 | #define fw_state_aborted(fw_st) \ |
173 | __fw_state_set(fw_st, FW_STATUS_ABORTED) | 171 | __fw_state_set(fw_st, FW_STATUS_ABORTED) |
174 | #define fw_state_is_done(fw_st) \ | 172 | #define fw_state_is_done(fw_st) \ |
175 | __fw_state_check(fw_st, FW_STATUS_DONE) | 173 | __fw_state_check(fw_st, FW_STATUS_DONE) |
176 | #define fw_state_is_loading(fw_st) \ | 174 | #define fw_state_is_loading(fw_st) \ |
177 | __fw_state_check(fw_st, FW_STATUS_LOADING) | 175 | __fw_state_check(fw_st, FW_STATUS_LOADING) |
178 | #define fw_state_is_aborted(fw_st) \ | ||
179 | __fw_state_check(fw_st, FW_STATUS_ABORTED) | ||
180 | #define fw_state_wait_timeout(fw_st, timeout) \ | 176 | #define fw_state_wait_timeout(fw_st, timeout) \ |
181 | __fw_state_wait_common(fw_st, timeout) | 177 | __fw_state_wait_common(fw_st, timeout) |
182 | 178 | ||
@@ -1200,6 +1196,28 @@ _request_firmware_prepare(struct firmware **firmware_p, const char *name, | |||
1200 | return 1; /* need to load */ | 1196 | return 1; /* need to load */ |
1201 | } | 1197 | } |
1202 | 1198 | ||
1199 | /* | ||
1200 | * Batched requests need only one wake, we need to do this step last due to the | ||
1201 | * fallback mechanism. The buf is protected with kref_get(), and it won't be | ||
1202 | * released until the last user calls release_firmware(). | ||
1203 | * | ||
1204 | * Failed batched requests are possible as well, in such cases we just share | ||
1205 | * the struct firmware_buf and won't release it until all requests are woken | ||
1206 | * and have gone through this same path. | ||
1207 | */ | ||
1208 | static void fw_abort_batch_reqs(struct firmware *fw) | ||
1209 | { | ||
1210 | struct firmware_buf *buf; | ||
1211 | |||
1212 | /* Loaded directly? */ | ||
1213 | if (!fw || !fw->priv) | ||
1214 | return; | ||
1215 | |||
1216 | buf = fw->priv; | ||
1217 | if (!fw_state_is_aborted(&buf->fw_st)) | ||
1218 | fw_state_aborted(&buf->fw_st); | ||
1219 | } | ||
1220 | |||
1203 | /* called from request_firmware() and request_firmware_work_func() */ | 1221 | /* called from request_firmware() and request_firmware_work_func() */ |
1204 | static int | 1222 | static int |
1205 | _request_firmware(const struct firmware **firmware_p, const char *name, | 1223 | _request_firmware(const struct firmware **firmware_p, const char *name, |
@@ -1243,6 +1261,7 @@ _request_firmware(const struct firmware **firmware_p, const char *name, | |||
1243 | 1261 | ||
1244 | out: | 1262 | out: |
1245 | if (ret < 0) { | 1263 | if (ret < 0) { |
1264 | fw_abort_batch_reqs(fw); | ||
1246 | release_firmware(fw); | 1265 | release_firmware(fw); |
1247 | fw = NULL; | 1266 | fw = NULL; |
1248 | } | 1267 | } |
diff --git a/drivers/block/sunvdc.c b/drivers/block/sunvdc.c index 6b16ead1da58..ad9749463d4f 100644 --- a/drivers/block/sunvdc.c +++ b/drivers/block/sunvdc.c | |||
@@ -875,6 +875,56 @@ static void print_version(void) | |||
875 | printk(KERN_INFO "%s", version); | 875 | printk(KERN_INFO "%s", version); |
876 | } | 876 | } |
877 | 877 | ||
878 | struct vdc_check_port_data { | ||
879 | int dev_no; | ||
880 | char *type; | ||
881 | }; | ||
882 | |||
883 | static int vdc_device_probed(struct device *dev, void *arg) | ||
884 | { | ||
885 | struct vio_dev *vdev = to_vio_dev(dev); | ||
886 | struct vdc_check_port_data *port_data; | ||
887 | |||
888 | port_data = (struct vdc_check_port_data *)arg; | ||
889 | |||
890 | if ((vdev->dev_no == port_data->dev_no) && | ||
891 | (!(strcmp((char *)&vdev->type, port_data->type))) && | ||
892 | dev_get_drvdata(dev)) { | ||
893 | /* This device has already been configured | ||
894 | * by vdc_port_probe() | ||
895 | */ | ||
896 | return 1; | ||
897 | } else { | ||
898 | return 0; | ||
899 | } | ||
900 | } | ||
901 | |||
902 | /* Determine whether the VIO device is part of an mpgroup | ||
903 | * by locating all the virtual-device-port nodes associated | ||
904 | * with the parent virtual-device node for the VIO device | ||
905 | * and checking whether any of these nodes are vdc-ports | ||
906 | * which have already been configured. | ||
907 | * | ||
908 | * Returns true if this device is part of an mpgroup and has | ||
909 | * already been probed. | ||
910 | */ | ||
911 | static bool vdc_port_mpgroup_check(struct vio_dev *vdev) | ||
912 | { | ||
913 | struct vdc_check_port_data port_data; | ||
914 | struct device *dev; | ||
915 | |||
916 | port_data.dev_no = vdev->dev_no; | ||
917 | port_data.type = (char *)&vdev->type; | ||
918 | |||
919 | dev = device_find_child(vdev->dev.parent, &port_data, | ||
920 | vdc_device_probed); | ||
921 | |||
922 | if (dev) | ||
923 | return true; | ||
924 | |||
925 | return false; | ||
926 | } | ||
927 | |||
878 | static int vdc_port_probe(struct vio_dev *vdev, const struct vio_device_id *id) | 928 | static int vdc_port_probe(struct vio_dev *vdev, const struct vio_device_id *id) |
879 | { | 929 | { |
880 | struct mdesc_handle *hp; | 930 | struct mdesc_handle *hp; |
@@ -893,6 +943,14 @@ static int vdc_port_probe(struct vio_dev *vdev, const struct vio_device_id *id) | |||
893 | goto err_out_release_mdesc; | 943 | goto err_out_release_mdesc; |
894 | } | 944 | } |
895 | 945 | ||
946 | /* Check if this device is part of an mpgroup */ | ||
947 | if (vdc_port_mpgroup_check(vdev)) { | ||
948 | printk(KERN_WARNING | ||
949 | "VIO: Ignoring extra vdisk port %s", | ||
950 | dev_name(&vdev->dev)); | ||
951 | goto err_out_release_mdesc; | ||
952 | } | ||
953 | |||
896 | port = kzalloc(sizeof(*port), GFP_KERNEL); | 954 | port = kzalloc(sizeof(*port), GFP_KERNEL); |
897 | err = -ENOMEM; | 955 | err = -ENOMEM; |
898 | if (!port) { | 956 | if (!port) { |
@@ -943,6 +1001,9 @@ static int vdc_port_probe(struct vio_dev *vdev, const struct vio_device_id *id) | |||
943 | if (err) | 1001 | if (err) |
944 | goto err_out_free_tx_ring; | 1002 | goto err_out_free_tx_ring; |
945 | 1003 | ||
1004 | /* Note that the device driver_data is used to determine | ||
1005 | * whether the port has been probed. | ||
1006 | */ | ||
946 | dev_set_drvdata(&vdev->dev, port); | 1007 | dev_set_drvdata(&vdev->dev, port); |
947 | 1008 | ||
948 | mdesc_release(hp); | 1009 | mdesc_release(hp); |
diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c index 98e34e4c62b8..2468c28d4771 100644 --- a/drivers/block/xen-blkfront.c +++ b/drivers/block/xen-blkfront.c | |||
@@ -2075,9 +2075,9 @@ static int blkfront_resume(struct xenbus_device *dev) | |||
2075 | /* | 2075 | /* |
2076 | * Get the bios in the request so we can re-queue them. | 2076 | * Get the bios in the request so we can re-queue them. |
2077 | */ | 2077 | */ |
2078 | if (req_op(shadow[i].request) == REQ_OP_FLUSH || | 2078 | if (req_op(shadow[j].request) == REQ_OP_FLUSH || |
2079 | req_op(shadow[i].request) == REQ_OP_DISCARD || | 2079 | req_op(shadow[j].request) == REQ_OP_DISCARD || |
2080 | req_op(shadow[i].request) == REQ_OP_SECURE_ERASE || | 2080 | req_op(shadow[j].request) == REQ_OP_SECURE_ERASE || |
2081 | shadow[j].request->cmd_flags & REQ_FUA) { | 2081 | shadow[j].request->cmd_flags & REQ_FUA) { |
2082 | /* | 2082 | /* |
2083 | * Flush operations don't contain bios, so | 2083 | * Flush operations don't contain bios, so |
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c index 856d5dc02451..3b1b6340ba13 100644 --- a/drivers/block/zram/zram_drv.c +++ b/drivers/block/zram/zram_drv.c | |||
@@ -308,7 +308,7 @@ static ssize_t comp_algorithm_store(struct device *dev, | |||
308 | struct device_attribute *attr, const char *buf, size_t len) | 308 | struct device_attribute *attr, const char *buf, size_t len) |
309 | { | 309 | { |
310 | struct zram *zram = dev_to_zram(dev); | 310 | struct zram *zram = dev_to_zram(dev); |
311 | char compressor[CRYPTO_MAX_ALG_NAME]; | 311 | char compressor[ARRAY_SIZE(zram->compressor)]; |
312 | size_t sz; | 312 | size_t sz; |
313 | 313 | ||
314 | strlcpy(compressor, buf, sizeof(compressor)); | 314 | strlcpy(compressor, buf, sizeof(compressor)); |
@@ -327,7 +327,7 @@ static ssize_t comp_algorithm_store(struct device *dev, | |||
327 | return -EBUSY; | 327 | return -EBUSY; |
328 | } | 328 | } |
329 | 329 | ||
330 | strlcpy(zram->compressor, compressor, sizeof(compressor)); | 330 | strcpy(zram->compressor, compressor); |
331 | up_write(&zram->init_lock); | 331 | up_write(&zram->init_lock); |
332 | return len; | 332 | return len; |
333 | } | 333 | } |
diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig index fcae5ca6ac92..54a67f8a28eb 100644 --- a/drivers/clocksource/Kconfig +++ b/drivers/clocksource/Kconfig | |||
@@ -262,7 +262,7 @@ config CLKSRC_LPC32XX | |||
262 | 262 | ||
263 | config CLKSRC_PISTACHIO | 263 | config CLKSRC_PISTACHIO |
264 | bool "Clocksource for Pistachio SoC" if COMPILE_TEST | 264 | bool "Clocksource for Pistachio SoC" if COMPILE_TEST |
265 | depends on HAS_IOMEM | 265 | depends on GENERIC_CLOCKEVENTS && HAS_IOMEM |
266 | select TIMER_OF | 266 | select TIMER_OF |
267 | help | 267 | help |
268 | Enables the clocksource for the Pistachio SoC. | 268 | Enables the clocksource for the Pistachio SoC. |
diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c index aae87c4c546e..72bbfccef113 100644 --- a/drivers/clocksource/arm_arch_timer.c +++ b/drivers/clocksource/arm_arch_timer.c | |||
@@ -1440,7 +1440,7 @@ static int __init arch_timer_mem_acpi_init(int platform_timer_count) | |||
1440 | * While unlikely, it's theoretically possible that none of the frames | 1440 | * While unlikely, it's theoretically possible that none of the frames |
1441 | * in a timer expose the combination of feature we want. | 1441 | * in a timer expose the combination of feature we want. |
1442 | */ | 1442 | */ |
1443 | for (i = i; i < timer_count; i++) { | 1443 | for (i = 0; i < timer_count; i++) { |
1444 | timer = &timers[i]; | 1444 | timer = &timers[i]; |
1445 | 1445 | ||
1446 | frame = arch_timer_mem_find_best_frame(timer); | 1446 | frame = arch_timer_mem_find_best_frame(timer); |
diff --git a/drivers/clocksource/em_sti.c b/drivers/clocksource/em_sti.c index bc48cbf6a795..269db74a0658 100644 --- a/drivers/clocksource/em_sti.c +++ b/drivers/clocksource/em_sti.c | |||
@@ -305,7 +305,7 @@ static int em_sti_probe(struct platform_device *pdev) | |||
305 | irq = platform_get_irq(pdev, 0); | 305 | irq = platform_get_irq(pdev, 0); |
306 | if (irq < 0) { | 306 | if (irq < 0) { |
307 | dev_err(&pdev->dev, "failed to get irq\n"); | 307 | dev_err(&pdev->dev, "failed to get irq\n"); |
308 | return -EINVAL; | 308 | return irq; |
309 | } | 309 | } |
310 | 310 | ||
311 | /* map memory, let base point to the STI instance */ | 311 | /* map memory, let base point to the STI instance */ |
@@ -314,11 +314,12 @@ static int em_sti_probe(struct platform_device *pdev) | |||
314 | if (IS_ERR(p->base)) | 314 | if (IS_ERR(p->base)) |
315 | return PTR_ERR(p->base); | 315 | return PTR_ERR(p->base); |
316 | 316 | ||
317 | if (devm_request_irq(&pdev->dev, irq, em_sti_interrupt, | 317 | ret = devm_request_irq(&pdev->dev, irq, em_sti_interrupt, |
318 | IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING, | 318 | IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING, |
319 | dev_name(&pdev->dev), p)) { | 319 | dev_name(&pdev->dev), p); |
320 | if (ret) { | ||
320 | dev_err(&pdev->dev, "failed to request low IRQ\n"); | 321 | dev_err(&pdev->dev, "failed to request low IRQ\n"); |
321 | return -ENOENT; | 322 | return ret; |
322 | } | 323 | } |
323 | 324 | ||
324 | /* get hold of clock */ | 325 | /* get hold of clock */ |
diff --git a/drivers/clocksource/timer-of.c b/drivers/clocksource/timer-of.c index d509b500a7b5..4d7aef9d9c15 100644 --- a/drivers/clocksource/timer-of.c +++ b/drivers/clocksource/timer-of.c | |||
@@ -128,9 +128,9 @@ static __init int timer_base_init(struct device_node *np, | |||
128 | const char *name = of_base->name ? of_base->name : np->full_name; | 128 | const char *name = of_base->name ? of_base->name : np->full_name; |
129 | 129 | ||
130 | of_base->base = of_io_request_and_map(np, of_base->index, name); | 130 | of_base->base = of_io_request_and_map(np, of_base->index, name); |
131 | if (!of_base->base) { | 131 | if (IS_ERR(of_base->base)) { |
132 | pr_err("Failed to iomap (%s)\n", name); | 132 | pr_err("Failed to iomap (%s)\n", name); |
133 | return -ENXIO; | 133 | return PTR_ERR(of_base->base); |
134 | } | 134 | } |
135 | 135 | ||
136 | return 0; | 136 | return 0; |
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c index 0566455f233e..65ee4fcace1f 100644 --- a/drivers/cpufreq/intel_pstate.c +++ b/drivers/cpufreq/intel_pstate.c | |||
@@ -1613,8 +1613,7 @@ static inline bool intel_pstate_sample(struct cpudata *cpu, u64 time) | |||
1613 | 1613 | ||
1614 | static inline int32_t get_avg_frequency(struct cpudata *cpu) | 1614 | static inline int32_t get_avg_frequency(struct cpudata *cpu) |
1615 | { | 1615 | { |
1616 | return mul_ext_fp(cpu->sample.core_avg_perf, | 1616 | return mul_ext_fp(cpu->sample.core_avg_perf, cpu_khz); |
1617 | cpu->pstate.max_pstate_physical * cpu->pstate.scaling); | ||
1618 | } | 1617 | } |
1619 | 1618 | ||
1620 | static inline int32_t get_avg_pstate(struct cpudata *cpu) | 1619 | static inline int32_t get_avg_pstate(struct cpudata *cpu) |
diff --git a/drivers/cpuidle/cpuidle-powernv.c b/drivers/cpuidle/cpuidle-powernv.c index 37b0698b7193..42896a67aeae 100644 --- a/drivers/cpuidle/cpuidle-powernv.c +++ b/drivers/cpuidle/cpuidle-powernv.c | |||
@@ -235,6 +235,7 @@ static inline int validate_dt_prop_sizes(const char *prop1, int prop1_len, | |||
235 | return -1; | 235 | return -1; |
236 | } | 236 | } |
237 | 237 | ||
238 | extern u32 pnv_get_supported_cpuidle_states(void); | ||
238 | static int powernv_add_idle_states(void) | 239 | static int powernv_add_idle_states(void) |
239 | { | 240 | { |
240 | struct device_node *power_mgt; | 241 | struct device_node *power_mgt; |
@@ -248,6 +249,8 @@ static int powernv_add_idle_states(void) | |||
248 | const char *names[CPUIDLE_STATE_MAX]; | 249 | const char *names[CPUIDLE_STATE_MAX]; |
249 | u32 has_stop_states = 0; | 250 | u32 has_stop_states = 0; |
250 | int i, rc; | 251 | int i, rc; |
252 | u32 supported_flags = pnv_get_supported_cpuidle_states(); | ||
253 | |||
251 | 254 | ||
252 | /* Currently we have snooze statically defined */ | 255 | /* Currently we have snooze statically defined */ |
253 | 256 | ||
@@ -362,6 +365,13 @@ static int powernv_add_idle_states(void) | |||
362 | for (i = 0; i < dt_idle_states; i++) { | 365 | for (i = 0; i < dt_idle_states; i++) { |
363 | unsigned int exit_latency, target_residency; | 366 | unsigned int exit_latency, target_residency; |
364 | bool stops_timebase = false; | 367 | bool stops_timebase = false; |
368 | |||
369 | /* | ||
370 | * Skip the platform idle state whose flag isn't in | ||
371 | * the supported_cpuidle_states flag mask. | ||
372 | */ | ||
373 | if ((flags[i] & supported_flags) != flags[i]) | ||
374 | continue; | ||
365 | /* | 375 | /* |
366 | * If an idle state has exit latency beyond | 376 | * If an idle state has exit latency beyond |
367 | * POWERNV_THRESHOLD_LATENCY_NS then don't use it | 377 | * POWERNV_THRESHOLD_LATENCY_NS then don't use it |
diff --git a/drivers/crypto/ixp4xx_crypto.c b/drivers/crypto/ixp4xx_crypto.c index 427cbe012729..dadc4a808df5 100644 --- a/drivers/crypto/ixp4xx_crypto.c +++ b/drivers/crypto/ixp4xx_crypto.c | |||
@@ -1073,7 +1073,7 @@ static int aead_perform(struct aead_request *req, int encrypt, | |||
1073 | req_ctx->hmac_virt = dma_pool_alloc(buffer_pool, flags, | 1073 | req_ctx->hmac_virt = dma_pool_alloc(buffer_pool, flags, |
1074 | &crypt->icv_rev_aes); | 1074 | &crypt->icv_rev_aes); |
1075 | if (unlikely(!req_ctx->hmac_virt)) | 1075 | if (unlikely(!req_ctx->hmac_virt)) |
1076 | goto free_buf_src; | 1076 | goto free_buf_dst; |
1077 | if (!encrypt) { | 1077 | if (!encrypt) { |
1078 | scatterwalk_map_and_copy(req_ctx->hmac_virt, | 1078 | scatterwalk_map_and_copy(req_ctx->hmac_virt, |
1079 | req->src, cryptlen, authsize, 0); | 1079 | req->src, cryptlen, authsize, 0); |
@@ -1088,10 +1088,10 @@ static int aead_perform(struct aead_request *req, int encrypt, | |||
1088 | BUG_ON(qmgr_stat_overflow(SEND_QID)); | 1088 | BUG_ON(qmgr_stat_overflow(SEND_QID)); |
1089 | return -EINPROGRESS; | 1089 | return -EINPROGRESS; |
1090 | 1090 | ||
1091 | free_buf_src: | ||
1092 | free_buf_chain(dev, req_ctx->src, crypt->src_buf); | ||
1093 | free_buf_dst: | 1091 | free_buf_dst: |
1094 | free_buf_chain(dev, req_ctx->dst, crypt->dst_buf); | 1092 | free_buf_chain(dev, req_ctx->dst, crypt->dst_buf); |
1093 | free_buf_src: | ||
1094 | free_buf_chain(dev, req_ctx->src, crypt->src_buf); | ||
1095 | crypt->ctl_flags = CTL_FLAG_UNUSED; | 1095 | crypt->ctl_flags = CTL_FLAG_UNUSED; |
1096 | return -ENOMEM; | 1096 | return -ENOMEM; |
1097 | } | 1097 | } |
diff --git a/drivers/dma-buf/sync_file.c b/drivers/dma-buf/sync_file.c index d7e219d2669d..66fb40d0ebdb 100644 --- a/drivers/dma-buf/sync_file.c +++ b/drivers/dma-buf/sync_file.c | |||
@@ -304,7 +304,7 @@ static int sync_file_release(struct inode *inode, struct file *file) | |||
304 | { | 304 | { |
305 | struct sync_file *sync_file = file->private_data; | 305 | struct sync_file *sync_file = file->private_data; |
306 | 306 | ||
307 | if (test_bit(POLL_ENABLED, &sync_file->fence->flags)) | 307 | if (test_bit(POLL_ENABLED, &sync_file->flags)) |
308 | dma_fence_remove_callback(sync_file->fence, &sync_file->cb); | 308 | dma_fence_remove_callback(sync_file->fence, &sync_file->cb); |
309 | dma_fence_put(sync_file->fence); | 309 | dma_fence_put(sync_file->fence); |
310 | kfree(sync_file); | 310 | kfree(sync_file); |
@@ -318,7 +318,8 @@ static unsigned int sync_file_poll(struct file *file, poll_table *wait) | |||
318 | 318 | ||
319 | poll_wait(file, &sync_file->wq, wait); | 319 | poll_wait(file, &sync_file->wq, wait); |
320 | 320 | ||
321 | if (!test_and_set_bit(POLL_ENABLED, &sync_file->fence->flags)) { | 321 | if (list_empty(&sync_file->cb.node) && |
322 | !test_and_set_bit(POLL_ENABLED, &sync_file->flags)) { | ||
322 | if (dma_fence_add_callback(sync_file->fence, &sync_file->cb, | 323 | if (dma_fence_add_callback(sync_file->fence, &sync_file->cb, |
323 | fence_check_cb_func) < 0) | 324 | fence_check_cb_func) < 0) |
324 | wake_up_all(&sync_file->wq); | 325 | wake_up_all(&sync_file->wq); |
diff --git a/drivers/firmware/dmi-sysfs.c b/drivers/firmware/dmi-sysfs.c index ef76e5eecf0b..d5de6ee8466d 100644 --- a/drivers/firmware/dmi-sysfs.c +++ b/drivers/firmware/dmi-sysfs.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include <linux/slab.h> | 25 | #include <linux/slab.h> |
26 | #include <linux/list.h> | 26 | #include <linux/list.h> |
27 | #include <linux/io.h> | 27 | #include <linux/io.h> |
28 | #include <asm/dmi.h> | ||
28 | 29 | ||
29 | #define MAX_ENTRY_TYPE 255 /* Most of these aren't used, but we consider | 30 | #define MAX_ENTRY_TYPE 255 /* Most of these aren't used, but we consider |
30 | the top entry type is only 8 bits */ | 31 | the top entry type is only 8 bits */ |
@@ -380,7 +381,7 @@ static ssize_t dmi_sel_raw_read_phys32(struct dmi_sysfs_entry *entry, | |||
380 | u8 __iomem *mapped; | 381 | u8 __iomem *mapped; |
381 | ssize_t wrote = 0; | 382 | ssize_t wrote = 0; |
382 | 383 | ||
383 | mapped = ioremap(sel->access_method_address, sel->area_length); | 384 | mapped = dmi_remap(sel->access_method_address, sel->area_length); |
384 | if (!mapped) | 385 | if (!mapped) |
385 | return -EIO; | 386 | return -EIO; |
386 | 387 | ||
@@ -390,7 +391,7 @@ static ssize_t dmi_sel_raw_read_phys32(struct dmi_sysfs_entry *entry, | |||
390 | wrote++; | 391 | wrote++; |
391 | } | 392 | } |
392 | 393 | ||
393 | iounmap(mapped); | 394 | dmi_unmap(mapped); |
394 | return wrote; | 395 | return wrote; |
395 | } | 396 | } |
396 | 397 | ||
diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c index 045d6d311bde..69d4d130e055 100644 --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c | |||
@@ -55,6 +55,25 @@ struct efi __read_mostly efi = { | |||
55 | }; | 55 | }; |
56 | EXPORT_SYMBOL(efi); | 56 | EXPORT_SYMBOL(efi); |
57 | 57 | ||
58 | static unsigned long *efi_tables[] = { | ||
59 | &efi.mps, | ||
60 | &efi.acpi, | ||
61 | &efi.acpi20, | ||
62 | &efi.smbios, | ||
63 | &efi.smbios3, | ||
64 | &efi.sal_systab, | ||
65 | &efi.boot_info, | ||
66 | &efi.hcdp, | ||
67 | &efi.uga, | ||
68 | &efi.uv_systab, | ||
69 | &efi.fw_vendor, | ||
70 | &efi.runtime, | ||
71 | &efi.config_table, | ||
72 | &efi.esrt, | ||
73 | &efi.properties_table, | ||
74 | &efi.mem_attr_table, | ||
75 | }; | ||
76 | |||
58 | static bool disable_runtime; | 77 | static bool disable_runtime; |
59 | static int __init setup_noefi(char *arg) | 78 | static int __init setup_noefi(char *arg) |
60 | { | 79 | { |
@@ -855,6 +874,20 @@ int efi_status_to_err(efi_status_t status) | |||
855 | return err; | 874 | return err; |
856 | } | 875 | } |
857 | 876 | ||
877 | bool efi_is_table_address(unsigned long phys_addr) | ||
878 | { | ||
879 | unsigned int i; | ||
880 | |||
881 | if (phys_addr == EFI_INVALID_TABLE_ADDR) | ||
882 | return false; | ||
883 | |||
884 | for (i = 0; i < ARRAY_SIZE(efi_tables); i++) | ||
885 | if (*(efi_tables[i]) == phys_addr) | ||
886 | return true; | ||
887 | |||
888 | return false; | ||
889 | } | ||
890 | |||
858 | #ifdef CONFIG_KEXEC | 891 | #ifdef CONFIG_KEXEC |
859 | static int update_efi_random_seed(struct notifier_block *nb, | 892 | static int update_efi_random_seed(struct notifier_block *nb, |
860 | unsigned long code, void *unused) | 893 | unsigned long code, void *unused) |
diff --git a/drivers/firmware/pcdp.c b/drivers/firmware/pcdp.c index 75273a251603..e83d6aec0c13 100644 --- a/drivers/firmware/pcdp.c +++ b/drivers/firmware/pcdp.c | |||
@@ -95,7 +95,7 @@ efi_setup_pcdp_console(char *cmdline) | |||
95 | if (efi.hcdp == EFI_INVALID_TABLE_ADDR) | 95 | if (efi.hcdp == EFI_INVALID_TABLE_ADDR) |
96 | return -ENODEV; | 96 | return -ENODEV; |
97 | 97 | ||
98 | pcdp = early_ioremap(efi.hcdp, 4096); | 98 | pcdp = early_memremap(efi.hcdp, 4096); |
99 | printk(KERN_INFO "PCDP: v%d at 0x%lx\n", pcdp->rev, efi.hcdp); | 99 | printk(KERN_INFO "PCDP: v%d at 0x%lx\n", pcdp->rev, efi.hcdp); |
100 | 100 | ||
101 | if (strstr(cmdline, "console=hcdp")) { | 101 | if (strstr(cmdline, "console=hcdp")) { |
@@ -131,6 +131,6 @@ efi_setup_pcdp_console(char *cmdline) | |||
131 | } | 131 | } |
132 | 132 | ||
133 | out: | 133 | out: |
134 | early_iounmap(pcdp, 4096); | 134 | early_memunmap(pcdp, 4096); |
135 | return rc; | 135 | return rc; |
136 | } | 136 | } |
diff --git a/drivers/gpio/gpio-mvebu.c b/drivers/gpio/gpio-mvebu.c index e338c3743562..45c65f805fd6 100644 --- a/drivers/gpio/gpio-mvebu.c +++ b/drivers/gpio/gpio-mvebu.c | |||
@@ -557,7 +557,7 @@ static void mvebu_gpio_irq_handler(struct irq_desc *desc) | |||
557 | edge_cause = mvebu_gpio_read_edge_cause(mvchip); | 557 | edge_cause = mvebu_gpio_read_edge_cause(mvchip); |
558 | edge_mask = mvebu_gpio_read_edge_mask(mvchip); | 558 | edge_mask = mvebu_gpio_read_edge_mask(mvchip); |
559 | 559 | ||
560 | cause = (data_in ^ level_mask) | (edge_cause & edge_mask); | 560 | cause = (data_in & level_mask) | (edge_cause & edge_mask); |
561 | 561 | ||
562 | for (i = 0; i < mvchip->chip.ngpio; i++) { | 562 | for (i = 0; i < mvchip->chip.ngpio; i++) { |
563 | int irq; | 563 | int irq; |
diff --git a/drivers/gpio/gpiolib-sysfs.c b/drivers/gpio/gpiolib-sysfs.c index 16fe9742597b..fc80add5fedb 100644 --- a/drivers/gpio/gpiolib-sysfs.c +++ b/drivers/gpio/gpiolib-sysfs.c | |||
@@ -2,6 +2,7 @@ | |||
2 | #include <linux/mutex.h> | 2 | #include <linux/mutex.h> |
3 | #include <linux/device.h> | 3 | #include <linux/device.h> |
4 | #include <linux/sysfs.h> | 4 | #include <linux/sysfs.h> |
5 | #include <linux/gpio.h> | ||
5 | #include <linux/gpio/consumer.h> | 6 | #include <linux/gpio/consumer.h> |
6 | #include <linux/gpio/driver.h> | 7 | #include <linux/gpio/driver.h> |
7 | #include <linux/interrupt.h> | 8 | #include <linux/interrupt.h> |
@@ -432,6 +433,11 @@ static struct attribute *gpiochip_attrs[] = { | |||
432 | }; | 433 | }; |
433 | ATTRIBUTE_GROUPS(gpiochip); | 434 | ATTRIBUTE_GROUPS(gpiochip); |
434 | 435 | ||
436 | static struct gpio_desc *gpio_to_valid_desc(int gpio) | ||
437 | { | ||
438 | return gpio_is_valid(gpio) ? gpio_to_desc(gpio) : NULL; | ||
439 | } | ||
440 | |||
435 | /* | 441 | /* |
436 | * /sys/class/gpio/export ... write-only | 442 | * /sys/class/gpio/export ... write-only |
437 | * integer N ... number of GPIO to export (full access) | 443 | * integer N ... number of GPIO to export (full access) |
@@ -450,7 +456,7 @@ static ssize_t export_store(struct class *class, | |||
450 | if (status < 0) | 456 | if (status < 0) |
451 | goto done; | 457 | goto done; |
452 | 458 | ||
453 | desc = gpio_to_desc(gpio); | 459 | desc = gpio_to_valid_desc(gpio); |
454 | /* reject invalid GPIOs */ | 460 | /* reject invalid GPIOs */ |
455 | if (!desc) { | 461 | if (!desc) { |
456 | pr_warn("%s: invalid GPIO %ld\n", __func__, gpio); | 462 | pr_warn("%s: invalid GPIO %ld\n", __func__, gpio); |
@@ -493,7 +499,7 @@ static ssize_t unexport_store(struct class *class, | |||
493 | if (status < 0) | 499 | if (status < 0) |
494 | goto done; | 500 | goto done; |
495 | 501 | ||
496 | desc = gpio_to_desc(gpio); | 502 | desc = gpio_to_valid_desc(gpio); |
497 | /* reject bogus commands (gpio_unexport ignores them) */ | 503 | /* reject bogus commands (gpio_unexport ignores them) */ |
498 | if (!desc) { | 504 | if (!desc) { |
499 | pr_warn("%s: invalid GPIO %ld\n", __func__, gpio); | 505 | pr_warn("%s: invalid GPIO %ld\n", __func__, gpio); |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c index a6899180b265..c586f44312f9 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c | |||
@@ -244,6 +244,12 @@ struct dma_fence *amdgpu_sync_peek_fence(struct amdgpu_sync *sync, | |||
244 | struct dma_fence *f = e->fence; | 244 | struct dma_fence *f = e->fence; |
245 | struct amd_sched_fence *s_fence = to_amd_sched_fence(f); | 245 | struct amd_sched_fence *s_fence = to_amd_sched_fence(f); |
246 | 246 | ||
247 | if (dma_fence_is_signaled(f)) { | ||
248 | hash_del(&e->node); | ||
249 | dma_fence_put(f); | ||
250 | kmem_cache_free(amdgpu_sync_slab, e); | ||
251 | continue; | ||
252 | } | ||
247 | if (ring && s_fence) { | 253 | if (ring && s_fence) { |
248 | /* For fences from the same ring it is sufficient | 254 | /* For fences from the same ring it is sufficient |
249 | * when they are scheduled. | 255 | * when they are scheduled. |
@@ -256,13 +262,6 @@ struct dma_fence *amdgpu_sync_peek_fence(struct amdgpu_sync *sync, | |||
256 | } | 262 | } |
257 | } | 263 | } |
258 | 264 | ||
259 | if (dma_fence_is_signaled(f)) { | ||
260 | hash_del(&e->node); | ||
261 | dma_fence_put(f); | ||
262 | kmem_cache_free(amdgpu_sync_slab, e); | ||
263 | continue; | ||
264 | } | ||
265 | |||
266 | return f; | 265 | return f; |
267 | } | 266 | } |
268 | 267 | ||
diff --git a/drivers/gpu/drm/bridge/tc358767.c b/drivers/gpu/drm/bridge/tc358767.c index 5c26488e7a2d..0529e500c534 100644 --- a/drivers/gpu/drm/bridge/tc358767.c +++ b/drivers/gpu/drm/bridge/tc358767.c | |||
@@ -1255,7 +1255,7 @@ static int tc_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
1255 | 1255 | ||
1256 | /* port@2 is the output port */ | 1256 | /* port@2 is the output port */ |
1257 | ret = drm_of_find_panel_or_bridge(dev->of_node, 2, 0, &tc->panel, NULL); | 1257 | ret = drm_of_find_panel_or_bridge(dev->of_node, 2, 0, &tc->panel, NULL); |
1258 | if (ret) | 1258 | if (ret && ret != -ENODEV) |
1259 | return ret; | 1259 | return ret; |
1260 | 1260 | ||
1261 | /* Shut down GPIO is optional */ | 1261 | /* Shut down GPIO is optional */ |
diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c index 8dc11064253d..7a61a07ac4de 100644 --- a/drivers/gpu/drm/drm_gem.c +++ b/drivers/gpu/drm/drm_gem.c | |||
@@ -36,6 +36,7 @@ | |||
36 | #include <linux/pagemap.h> | 36 | #include <linux/pagemap.h> |
37 | #include <linux/shmem_fs.h> | 37 | #include <linux/shmem_fs.h> |
38 | #include <linux/dma-buf.h> | 38 | #include <linux/dma-buf.h> |
39 | #include <linux/mem_encrypt.h> | ||
39 | #include <drm/drmP.h> | 40 | #include <drm/drmP.h> |
40 | #include <drm/drm_vma_manager.h> | 41 | #include <drm/drm_vma_manager.h> |
41 | #include <drm/drm_gem.h> | 42 | #include <drm/drm_gem.h> |
@@ -928,6 +929,7 @@ int drm_gem_mmap_obj(struct drm_gem_object *obj, unsigned long obj_size, | |||
928 | vma->vm_ops = dev->driver->gem_vm_ops; | 929 | vma->vm_ops = dev->driver->gem_vm_ops; |
929 | vma->vm_private_data = obj; | 930 | vma->vm_private_data = obj; |
930 | vma->vm_page_prot = pgprot_writecombine(vm_get_page_prot(vma->vm_flags)); | 931 | vma->vm_page_prot = pgprot_writecombine(vm_get_page_prot(vma->vm_flags)); |
932 | vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot); | ||
931 | 933 | ||
932 | /* Take a ref for this mapping of the object, so that the fault | 934 | /* Take a ref for this mapping of the object, so that the fault |
933 | * handler can dereference the mmap offset's pointer to the object. | 935 | * handler can dereference the mmap offset's pointer to the object. |
diff --git a/drivers/gpu/drm/drm_vm.c b/drivers/gpu/drm/drm_vm.c index 1170b3209a12..ed4bcbfd6086 100644 --- a/drivers/gpu/drm/drm_vm.c +++ b/drivers/gpu/drm/drm_vm.c | |||
@@ -40,6 +40,7 @@ | |||
40 | #include <linux/efi.h> | 40 | #include <linux/efi.h> |
41 | #include <linux/slab.h> | 41 | #include <linux/slab.h> |
42 | #endif | 42 | #endif |
43 | #include <linux/mem_encrypt.h> | ||
43 | #include <asm/pgtable.h> | 44 | #include <asm/pgtable.h> |
44 | #include "drm_internal.h" | 45 | #include "drm_internal.h" |
45 | #include "drm_legacy.h" | 46 | #include "drm_legacy.h" |
@@ -58,6 +59,9 @@ static pgprot_t drm_io_prot(struct drm_local_map *map, | |||
58 | { | 59 | { |
59 | pgprot_t tmp = vm_get_page_prot(vma->vm_flags); | 60 | pgprot_t tmp = vm_get_page_prot(vma->vm_flags); |
60 | 61 | ||
62 | /* We don't want graphics memory to be mapped encrypted */ | ||
63 | tmp = pgprot_decrypted(tmp); | ||
64 | |||
61 | #if defined(__i386__) || defined(__x86_64__) || defined(__powerpc__) | 65 | #if defined(__i386__) || defined(__x86_64__) || defined(__powerpc__) |
62 | if (map->type == _DRM_REGISTERS && !(map->flags & _DRM_WRITE_COMBINING)) | 66 | if (map->type == _DRM_REGISTERS && !(map->flags & _DRM_WRITE_COMBINING)) |
63 | tmp = pgprot_noncached(tmp); | 67 | tmp = pgprot_noncached(tmp); |
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c b/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c index 5bd93169dac2..6463fc2c736f 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c | |||
@@ -270,8 +270,8 @@ static int submit_reloc(struct etnaviv_gem_submit *submit, void *stream, | |||
270 | if (ret) | 270 | if (ret) |
271 | return ret; | 271 | return ret; |
272 | 272 | ||
273 | if (r->reloc_offset >= bo->obj->base.size - sizeof(*ptr)) { | 273 | if (r->reloc_offset > bo->obj->base.size - sizeof(*ptr)) { |
274 | DRM_ERROR("relocation %u outside object", i); | 274 | DRM_ERROR("relocation %u outside object\n", i); |
275 | return -EINVAL; | 275 | return -EINVAL; |
276 | } | 276 | } |
277 | 277 | ||
diff --git a/drivers/gpu/drm/exynos/exynos_drm_fb.c b/drivers/gpu/drm/exynos/exynos_drm_fb.c index d48fd7c918f8..73217c281c9a 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_fb.c +++ b/drivers/gpu/drm/exynos/exynos_drm_fb.c | |||
@@ -145,13 +145,19 @@ static struct drm_framebuffer * | |||
145 | exynos_user_fb_create(struct drm_device *dev, struct drm_file *file_priv, | 145 | exynos_user_fb_create(struct drm_device *dev, struct drm_file *file_priv, |
146 | const struct drm_mode_fb_cmd2 *mode_cmd) | 146 | const struct drm_mode_fb_cmd2 *mode_cmd) |
147 | { | 147 | { |
148 | const struct drm_format_info *info = drm_get_format_info(dev, mode_cmd); | ||
148 | struct exynos_drm_gem *exynos_gem[MAX_FB_BUFFER]; | 149 | struct exynos_drm_gem *exynos_gem[MAX_FB_BUFFER]; |
149 | struct drm_gem_object *obj; | 150 | struct drm_gem_object *obj; |
150 | struct drm_framebuffer *fb; | 151 | struct drm_framebuffer *fb; |
151 | int i; | 152 | int i; |
152 | int ret; | 153 | int ret; |
153 | 154 | ||
154 | for (i = 0; i < drm_format_num_planes(mode_cmd->pixel_format); i++) { | 155 | for (i = 0; i < info->num_planes; i++) { |
156 | unsigned int height = (i == 0) ? mode_cmd->height : | ||
157 | DIV_ROUND_UP(mode_cmd->height, info->vsub); | ||
158 | unsigned long size = height * mode_cmd->pitches[i] + | ||
159 | mode_cmd->offsets[i]; | ||
160 | |||
155 | obj = drm_gem_object_lookup(file_priv, mode_cmd->handles[i]); | 161 | obj = drm_gem_object_lookup(file_priv, mode_cmd->handles[i]); |
156 | if (!obj) { | 162 | if (!obj) { |
157 | DRM_ERROR("failed to lookup gem object\n"); | 163 | DRM_ERROR("failed to lookup gem object\n"); |
@@ -160,6 +166,12 @@ exynos_user_fb_create(struct drm_device *dev, struct drm_file *file_priv, | |||
160 | } | 166 | } |
161 | 167 | ||
162 | exynos_gem[i] = to_exynos_gem(obj); | 168 | exynos_gem[i] = to_exynos_gem(obj); |
169 | |||
170 | if (size > exynos_gem[i]->size) { | ||
171 | i++; | ||
172 | ret = -EINVAL; | ||
173 | goto err; | ||
174 | } | ||
163 | } | 175 | } |
164 | 176 | ||
165 | fb = exynos_drm_framebuffer_init(dev, mode_cmd, exynos_gem, i); | 177 | fb = exynos_drm_framebuffer_init(dev, mode_cmd, exynos_gem, i); |
diff --git a/drivers/gpu/drm/i915/gvt/execlist.c b/drivers/gpu/drm/i915/gvt/execlist.c index 700050556242..1648887d3f55 100644 --- a/drivers/gpu/drm/i915/gvt/execlist.c +++ b/drivers/gpu/drm/i915/gvt/execlist.c | |||
@@ -46,6 +46,8 @@ | |||
46 | #define same_context(a, b) (((a)->context_id == (b)->context_id) && \ | 46 | #define same_context(a, b) (((a)->context_id == (b)->context_id) && \ |
47 | ((a)->lrca == (b)->lrca)) | 47 | ((a)->lrca == (b)->lrca)) |
48 | 48 | ||
49 | static void clean_workloads(struct intel_vgpu *vgpu, unsigned long engine_mask); | ||
50 | |||
49 | static int context_switch_events[] = { | 51 | static int context_switch_events[] = { |
50 | [RCS] = RCS_AS_CONTEXT_SWITCH, | 52 | [RCS] = RCS_AS_CONTEXT_SWITCH, |
51 | [BCS] = BCS_AS_CONTEXT_SWITCH, | 53 | [BCS] = BCS_AS_CONTEXT_SWITCH, |
@@ -499,10 +501,10 @@ static void release_shadow_wa_ctx(struct intel_shadow_wa_ctx *wa_ctx) | |||
499 | static int complete_execlist_workload(struct intel_vgpu_workload *workload) | 501 | static int complete_execlist_workload(struct intel_vgpu_workload *workload) |
500 | { | 502 | { |
501 | struct intel_vgpu *vgpu = workload->vgpu; | 503 | struct intel_vgpu *vgpu = workload->vgpu; |
502 | struct intel_vgpu_execlist *execlist = | 504 | int ring_id = workload->ring_id; |
503 | &vgpu->execlist[workload->ring_id]; | 505 | struct intel_vgpu_execlist *execlist = &vgpu->execlist[ring_id]; |
504 | struct intel_vgpu_workload *next_workload; | 506 | struct intel_vgpu_workload *next_workload; |
505 | struct list_head *next = workload_q_head(vgpu, workload->ring_id)->next; | 507 | struct list_head *next = workload_q_head(vgpu, ring_id)->next; |
506 | bool lite_restore = false; | 508 | bool lite_restore = false; |
507 | int ret; | 509 | int ret; |
508 | 510 | ||
@@ -512,10 +514,25 @@ static int complete_execlist_workload(struct intel_vgpu_workload *workload) | |||
512 | release_shadow_batch_buffer(workload); | 514 | release_shadow_batch_buffer(workload); |
513 | release_shadow_wa_ctx(&workload->wa_ctx); | 515 | release_shadow_wa_ctx(&workload->wa_ctx); |
514 | 516 | ||
515 | if (workload->status || vgpu->resetting) | 517 | if (workload->status || (vgpu->resetting_eng & ENGINE_MASK(ring_id))) { |
518 | /* if workload->status is not successful means HW GPU | ||
519 | * has occurred GPU hang or something wrong with i915/GVT, | ||
520 | * and GVT won't inject context switch interrupt to guest. | ||
521 | * So this error is a vGPU hang actually to the guest. | ||
522 | * According to this we should emunlate a vGPU hang. If | ||
523 | * there are pending workloads which are already submitted | ||
524 | * from guest, we should clean them up like HW GPU does. | ||
525 | * | ||
526 | * if it is in middle of engine resetting, the pending | ||
527 | * workloads won't be submitted to HW GPU and will be | ||
528 | * cleaned up during the resetting process later, so doing | ||
529 | * the workload clean up here doesn't have any impact. | ||
530 | **/ | ||
531 | clean_workloads(vgpu, ENGINE_MASK(ring_id)); | ||
516 | goto out; | 532 | goto out; |
533 | } | ||
517 | 534 | ||
518 | if (!list_empty(workload_q_head(vgpu, workload->ring_id))) { | 535 | if (!list_empty(workload_q_head(vgpu, ring_id))) { |
519 | struct execlist_ctx_descriptor_format *this_desc, *next_desc; | 536 | struct execlist_ctx_descriptor_format *this_desc, *next_desc; |
520 | 537 | ||
521 | next_workload = container_of(next, | 538 | next_workload = container_of(next, |
diff --git a/drivers/gpu/drm/i915/gvt/firmware.c b/drivers/gpu/drm/i915/gvt/firmware.c index 5dad9298b2d5..a26c1705430e 100644 --- a/drivers/gpu/drm/i915/gvt/firmware.c +++ b/drivers/gpu/drm/i915/gvt/firmware.c | |||
@@ -72,11 +72,13 @@ static int expose_firmware_sysfs(struct intel_gvt *gvt) | |||
72 | struct intel_gvt_device_info *info = &gvt->device_info; | 72 | struct intel_gvt_device_info *info = &gvt->device_info; |
73 | struct pci_dev *pdev = gvt->dev_priv->drm.pdev; | 73 | struct pci_dev *pdev = gvt->dev_priv->drm.pdev; |
74 | struct intel_gvt_mmio_info *e; | 74 | struct intel_gvt_mmio_info *e; |
75 | struct gvt_mmio_block *block = gvt->mmio.mmio_block; | ||
76 | int num = gvt->mmio.num_mmio_block; | ||
75 | struct gvt_firmware_header *h; | 77 | struct gvt_firmware_header *h; |
76 | void *firmware; | 78 | void *firmware; |
77 | void *p; | 79 | void *p; |
78 | unsigned long size, crc32_start; | 80 | unsigned long size, crc32_start; |
79 | int i; | 81 | int i, j; |
80 | int ret; | 82 | int ret; |
81 | 83 | ||
82 | size = sizeof(*h) + info->mmio_size + info->cfg_space_size; | 84 | size = sizeof(*h) + info->mmio_size + info->cfg_space_size; |
@@ -105,6 +107,13 @@ static int expose_firmware_sysfs(struct intel_gvt *gvt) | |||
105 | hash_for_each(gvt->mmio.mmio_info_table, i, e, node) | 107 | hash_for_each(gvt->mmio.mmio_info_table, i, e, node) |
106 | *(u32 *)(p + e->offset) = I915_READ_NOTRACE(_MMIO(e->offset)); | 108 | *(u32 *)(p + e->offset) = I915_READ_NOTRACE(_MMIO(e->offset)); |
107 | 109 | ||
110 | for (i = 0; i < num; i++, block++) { | ||
111 | for (j = 0; j < block->size; j += 4) | ||
112 | *(u32 *)(p + INTEL_GVT_MMIO_OFFSET(block->offset) + j) = | ||
113 | I915_READ_NOTRACE(_MMIO(INTEL_GVT_MMIO_OFFSET( | ||
114 | block->offset) + j)); | ||
115 | } | ||
116 | |||
108 | memcpy(gvt->firmware.mmio, p, info->mmio_size); | 117 | memcpy(gvt->firmware.mmio, p, info->mmio_size); |
109 | 118 | ||
110 | crc32_start = offsetof(struct gvt_firmware_header, crc32) + 4; | 119 | crc32_start = offsetof(struct gvt_firmware_header, crc32) + 4; |
diff --git a/drivers/gpu/drm/i915/gvt/gvt.h b/drivers/gpu/drm/i915/gvt/gvt.h index 3a74e79eac2f..2964a4d01a66 100644 --- a/drivers/gpu/drm/i915/gvt/gvt.h +++ b/drivers/gpu/drm/i915/gvt/gvt.h | |||
@@ -149,7 +149,7 @@ struct intel_vgpu { | |||
149 | bool active; | 149 | bool active; |
150 | bool pv_notified; | 150 | bool pv_notified; |
151 | bool failsafe; | 151 | bool failsafe; |
152 | bool resetting; | 152 | unsigned int resetting_eng; |
153 | void *sched_data; | 153 | void *sched_data; |
154 | struct vgpu_sched_ctl sched_ctl; | 154 | struct vgpu_sched_ctl sched_ctl; |
155 | 155 | ||
@@ -195,6 +195,15 @@ struct intel_gvt_fence { | |||
195 | unsigned long vgpu_allocated_fence_num; | 195 | unsigned long vgpu_allocated_fence_num; |
196 | }; | 196 | }; |
197 | 197 | ||
198 | /* Special MMIO blocks. */ | ||
199 | struct gvt_mmio_block { | ||
200 | unsigned int device; | ||
201 | i915_reg_t offset; | ||
202 | unsigned int size; | ||
203 | gvt_mmio_func read; | ||
204 | gvt_mmio_func write; | ||
205 | }; | ||
206 | |||
198 | #define INTEL_GVT_MMIO_HASH_BITS 11 | 207 | #define INTEL_GVT_MMIO_HASH_BITS 11 |
199 | 208 | ||
200 | struct intel_gvt_mmio { | 209 | struct intel_gvt_mmio { |
@@ -214,6 +223,9 @@ struct intel_gvt_mmio { | |||
214 | /* This reg could be accessed by unaligned address */ | 223 | /* This reg could be accessed by unaligned address */ |
215 | #define F_UNALIGN (1 << 6) | 224 | #define F_UNALIGN (1 << 6) |
216 | 225 | ||
226 | struct gvt_mmio_block *mmio_block; | ||
227 | unsigned int num_mmio_block; | ||
228 | |||
217 | DECLARE_HASHTABLE(mmio_info_table, INTEL_GVT_MMIO_HASH_BITS); | 229 | DECLARE_HASHTABLE(mmio_info_table, INTEL_GVT_MMIO_HASH_BITS); |
218 | unsigned int num_tracked_mmio; | 230 | unsigned int num_tracked_mmio; |
219 | }; | 231 | }; |
diff --git a/drivers/gpu/drm/i915/gvt/handlers.c b/drivers/gpu/drm/i915/gvt/handlers.c index 17febe830ff6..feed9921b3b3 100644 --- a/drivers/gpu/drm/i915/gvt/handlers.c +++ b/drivers/gpu/drm/i915/gvt/handlers.c | |||
@@ -2857,31 +2857,15 @@ static int init_skl_mmio_info(struct intel_gvt *gvt) | |||
2857 | return 0; | 2857 | return 0; |
2858 | } | 2858 | } |
2859 | 2859 | ||
2860 | /* Special MMIO blocks. */ | ||
2861 | static struct gvt_mmio_block { | ||
2862 | unsigned int device; | ||
2863 | i915_reg_t offset; | ||
2864 | unsigned int size; | ||
2865 | gvt_mmio_func read; | ||
2866 | gvt_mmio_func write; | ||
2867 | } gvt_mmio_blocks[] = { | ||
2868 | {D_SKL_PLUS, _MMIO(CSR_MMIO_START_RANGE), 0x3000, NULL, NULL}, | ||
2869 | {D_ALL, _MMIO(MCHBAR_MIRROR_BASE_SNB), 0x40000, NULL, NULL}, | ||
2870 | {D_ALL, _MMIO(VGT_PVINFO_PAGE), VGT_PVINFO_SIZE, | ||
2871 | pvinfo_mmio_read, pvinfo_mmio_write}, | ||
2872 | {D_ALL, LGC_PALETTE(PIPE_A, 0), 1024, NULL, NULL}, | ||
2873 | {D_ALL, LGC_PALETTE(PIPE_B, 0), 1024, NULL, NULL}, | ||
2874 | {D_ALL, LGC_PALETTE(PIPE_C, 0), 1024, NULL, NULL}, | ||
2875 | }; | ||
2876 | |||
2877 | static struct gvt_mmio_block *find_mmio_block(struct intel_gvt *gvt, | 2860 | static struct gvt_mmio_block *find_mmio_block(struct intel_gvt *gvt, |
2878 | unsigned int offset) | 2861 | unsigned int offset) |
2879 | { | 2862 | { |
2880 | unsigned long device = intel_gvt_get_device_type(gvt); | 2863 | unsigned long device = intel_gvt_get_device_type(gvt); |
2881 | struct gvt_mmio_block *block = gvt_mmio_blocks; | 2864 | struct gvt_mmio_block *block = gvt->mmio.mmio_block; |
2865 | int num = gvt->mmio.num_mmio_block; | ||
2882 | int i; | 2866 | int i; |
2883 | 2867 | ||
2884 | for (i = 0; i < ARRAY_SIZE(gvt_mmio_blocks); i++, block++) { | 2868 | for (i = 0; i < num; i++, block++) { |
2885 | if (!(device & block->device)) | 2869 | if (!(device & block->device)) |
2886 | continue; | 2870 | continue; |
2887 | if (offset >= INTEL_GVT_MMIO_OFFSET(block->offset) && | 2871 | if (offset >= INTEL_GVT_MMIO_OFFSET(block->offset) && |
@@ -2912,6 +2896,17 @@ void intel_gvt_clean_mmio_info(struct intel_gvt *gvt) | |||
2912 | gvt->mmio.mmio_attribute = NULL; | 2896 | gvt->mmio.mmio_attribute = NULL; |
2913 | } | 2897 | } |
2914 | 2898 | ||
2899 | /* Special MMIO blocks. */ | ||
2900 | static struct gvt_mmio_block mmio_blocks[] = { | ||
2901 | {D_SKL_PLUS, _MMIO(CSR_MMIO_START_RANGE), 0x3000, NULL, NULL}, | ||
2902 | {D_ALL, _MMIO(MCHBAR_MIRROR_BASE_SNB), 0x40000, NULL, NULL}, | ||
2903 | {D_ALL, _MMIO(VGT_PVINFO_PAGE), VGT_PVINFO_SIZE, | ||
2904 | pvinfo_mmio_read, pvinfo_mmio_write}, | ||
2905 | {D_ALL, LGC_PALETTE(PIPE_A, 0), 1024, NULL, NULL}, | ||
2906 | {D_ALL, LGC_PALETTE(PIPE_B, 0), 1024, NULL, NULL}, | ||
2907 | {D_ALL, LGC_PALETTE(PIPE_C, 0), 1024, NULL, NULL}, | ||
2908 | }; | ||
2909 | |||
2915 | /** | 2910 | /** |
2916 | * intel_gvt_setup_mmio_info - setup MMIO information table for GVT device | 2911 | * intel_gvt_setup_mmio_info - setup MMIO information table for GVT device |
2917 | * @gvt: GVT device | 2912 | * @gvt: GVT device |
@@ -2951,6 +2946,9 @@ int intel_gvt_setup_mmio_info(struct intel_gvt *gvt) | |||
2951 | goto err; | 2946 | goto err; |
2952 | } | 2947 | } |
2953 | 2948 | ||
2949 | gvt->mmio.mmio_block = mmio_blocks; | ||
2950 | gvt->mmio.num_mmio_block = ARRAY_SIZE(mmio_blocks); | ||
2951 | |||
2954 | gvt_dbg_mmio("traced %u virtual mmio registers\n", | 2952 | gvt_dbg_mmio("traced %u virtual mmio registers\n", |
2955 | gvt->mmio.num_tracked_mmio); | 2953 | gvt->mmio.num_tracked_mmio); |
2956 | return 0; | 2954 | return 0; |
@@ -3030,7 +3028,7 @@ int intel_vgpu_mmio_reg_rw(struct intel_vgpu *vgpu, unsigned int offset, | |||
3030 | gvt_mmio_func func; | 3028 | gvt_mmio_func func; |
3031 | int ret; | 3029 | int ret; |
3032 | 3030 | ||
3033 | if (WARN_ON(bytes > 4)) | 3031 | if (WARN_ON(bytes > 8)) |
3034 | return -EINVAL; | 3032 | return -EINVAL; |
3035 | 3033 | ||
3036 | /* | 3034 | /* |
diff --git a/drivers/gpu/drm/i915/gvt/scheduler.c b/drivers/gpu/drm/i915/gvt/scheduler.c index 4f7057d62d88..22e08eb2d0b7 100644 --- a/drivers/gpu/drm/i915/gvt/scheduler.c +++ b/drivers/gpu/drm/i915/gvt/scheduler.c | |||
@@ -432,7 +432,8 @@ static void complete_current_workload(struct intel_gvt *gvt, int ring_id) | |||
432 | 432 | ||
433 | i915_gem_request_put(fetch_and_zero(&workload->req)); | 433 | i915_gem_request_put(fetch_and_zero(&workload->req)); |
434 | 434 | ||
435 | if (!workload->status && !vgpu->resetting) { | 435 | if (!workload->status && !(vgpu->resetting_eng & |
436 | ENGINE_MASK(ring_id))) { | ||
436 | update_guest_context(workload); | 437 | update_guest_context(workload); |
437 | 438 | ||
438 | for_each_set_bit(event, workload->pending_events, | 439 | for_each_set_bit(event, workload->pending_events, |
diff --git a/drivers/gpu/drm/i915/gvt/vgpu.c b/drivers/gpu/drm/i915/gvt/vgpu.c index 90c14e6e3ea0..3deadcbd5a24 100644 --- a/drivers/gpu/drm/i915/gvt/vgpu.c +++ b/drivers/gpu/drm/i915/gvt/vgpu.c | |||
@@ -480,11 +480,13 @@ void intel_gvt_reset_vgpu_locked(struct intel_vgpu *vgpu, bool dmlr, | |||
480 | { | 480 | { |
481 | struct intel_gvt *gvt = vgpu->gvt; | 481 | struct intel_gvt *gvt = vgpu->gvt; |
482 | struct intel_gvt_workload_scheduler *scheduler = &gvt->scheduler; | 482 | struct intel_gvt_workload_scheduler *scheduler = &gvt->scheduler; |
483 | unsigned int resetting_eng = dmlr ? ALL_ENGINES : engine_mask; | ||
483 | 484 | ||
484 | gvt_dbg_core("------------------------------------------\n"); | 485 | gvt_dbg_core("------------------------------------------\n"); |
485 | gvt_dbg_core("resseting vgpu%d, dmlr %d, engine_mask %08x\n", | 486 | gvt_dbg_core("resseting vgpu%d, dmlr %d, engine_mask %08x\n", |
486 | vgpu->id, dmlr, engine_mask); | 487 | vgpu->id, dmlr, engine_mask); |
487 | vgpu->resetting = true; | 488 | |
489 | vgpu->resetting_eng = resetting_eng; | ||
488 | 490 | ||
489 | intel_vgpu_stop_schedule(vgpu); | 491 | intel_vgpu_stop_schedule(vgpu); |
490 | /* | 492 | /* |
@@ -497,7 +499,7 @@ void intel_gvt_reset_vgpu_locked(struct intel_vgpu *vgpu, bool dmlr, | |||
497 | mutex_lock(&gvt->lock); | 499 | mutex_lock(&gvt->lock); |
498 | } | 500 | } |
499 | 501 | ||
500 | intel_vgpu_reset_execlist(vgpu, dmlr ? ALL_ENGINES : engine_mask); | 502 | intel_vgpu_reset_execlist(vgpu, resetting_eng); |
501 | 503 | ||
502 | /* full GPU reset or device model level reset */ | 504 | /* full GPU reset or device model level reset */ |
503 | if (engine_mask == ALL_ENGINES || dmlr) { | 505 | if (engine_mask == ALL_ENGINES || dmlr) { |
@@ -520,7 +522,7 @@ void intel_gvt_reset_vgpu_locked(struct intel_vgpu *vgpu, bool dmlr, | |||
520 | } | 522 | } |
521 | } | 523 | } |
522 | 524 | ||
523 | vgpu->resetting = false; | 525 | vgpu->resetting_eng = 0; |
524 | gvt_dbg_core("reset vgpu%d done\n", vgpu->id); | 526 | gvt_dbg_core("reset vgpu%d done\n", vgpu->id); |
525 | gvt_dbg_core("------------------------------------------\n"); | 527 | gvt_dbg_core("------------------------------------------\n"); |
526 | } | 528 | } |
diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c index 00d8967c8512..d1bd53b73738 100644 --- a/drivers/gpu/drm/i915/i915_debugfs.c +++ b/drivers/gpu/drm/i915/i915_debugfs.c | |||
@@ -4580,7 +4580,7 @@ static void gen9_sseu_device_status(struct drm_i915_private *dev_priv, | |||
4580 | 4580 | ||
4581 | sseu->slice_mask |= BIT(s); | 4581 | sseu->slice_mask |= BIT(s); |
4582 | 4582 | ||
4583 | if (IS_GEN9_BC(dev_priv)) | 4583 | if (IS_GEN9_BC(dev_priv) || IS_CANNONLAKE(dev_priv)) |
4584 | sseu->subslice_mask = | 4584 | sseu->subslice_mask = |
4585 | INTEL_INFO(dev_priv)->sseu.subslice_mask; | 4585 | INTEL_INFO(dev_priv)->sseu.subslice_mask; |
4586 | 4586 | ||
diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c index 39ed58a21fc1..e1e971ee2ed5 100644 --- a/drivers/gpu/drm/i915/i915_gem_context.c +++ b/drivers/gpu/drm/i915/i915_gem_context.c | |||
@@ -688,19 +688,19 @@ static inline bool skip_rcs_switch(struct i915_hw_ppgtt *ppgtt, | |||
688 | } | 688 | } |
689 | 689 | ||
690 | static bool | 690 | static bool |
691 | needs_pd_load_pre(struct i915_hw_ppgtt *ppgtt, | 691 | needs_pd_load_pre(struct i915_hw_ppgtt *ppgtt, struct intel_engine_cs *engine) |
692 | struct intel_engine_cs *engine, | ||
693 | struct i915_gem_context *to) | ||
694 | { | 692 | { |
693 | struct i915_gem_context *from = engine->legacy_active_context; | ||
694 | |||
695 | if (!ppgtt) | 695 | if (!ppgtt) |
696 | return false; | 696 | return false; |
697 | 697 | ||
698 | /* Always load the ppgtt on first use */ | 698 | /* Always load the ppgtt on first use */ |
699 | if (!engine->legacy_active_context) | 699 | if (!from) |
700 | return true; | 700 | return true; |
701 | 701 | ||
702 | /* Same context without new entries, skip */ | 702 | /* Same context without new entries, skip */ |
703 | if (engine->legacy_active_context == to && | 703 | if ((!from->ppgtt || from->ppgtt == ppgtt) && |
704 | !(intel_engine_flag(engine) & ppgtt->pd_dirty_rings)) | 704 | !(intel_engine_flag(engine) & ppgtt->pd_dirty_rings)) |
705 | return false; | 705 | return false; |
706 | 706 | ||
@@ -744,7 +744,7 @@ static int do_rcs_switch(struct drm_i915_gem_request *req) | |||
744 | if (skip_rcs_switch(ppgtt, engine, to)) | 744 | if (skip_rcs_switch(ppgtt, engine, to)) |
745 | return 0; | 745 | return 0; |
746 | 746 | ||
747 | if (needs_pd_load_pre(ppgtt, engine, to)) { | 747 | if (needs_pd_load_pre(ppgtt, engine)) { |
748 | /* Older GENs and non render rings still want the load first, | 748 | /* Older GENs and non render rings still want the load first, |
749 | * "PP_DCLV followed by PP_DIR_BASE register through Load | 749 | * "PP_DCLV followed by PP_DIR_BASE register through Load |
750 | * Register Immediate commands in Ring Buffer before submitting | 750 | * Register Immediate commands in Ring Buffer before submitting |
@@ -841,7 +841,7 @@ int i915_switch_context(struct drm_i915_gem_request *req) | |||
841 | struct i915_hw_ppgtt *ppgtt = | 841 | struct i915_hw_ppgtt *ppgtt = |
842 | to->ppgtt ?: req->i915->mm.aliasing_ppgtt; | 842 | to->ppgtt ?: req->i915->mm.aliasing_ppgtt; |
843 | 843 | ||
844 | if (needs_pd_load_pre(ppgtt, engine, to)) { | 844 | if (needs_pd_load_pre(ppgtt, engine)) { |
845 | int ret; | 845 | int ret; |
846 | 846 | ||
847 | trace_switch_mm(engine, to); | 847 | trace_switch_mm(engine, to); |
@@ -852,6 +852,7 @@ int i915_switch_context(struct drm_i915_gem_request *req) | |||
852 | ppgtt->pd_dirty_rings &= ~intel_engine_flag(engine); | 852 | ppgtt->pd_dirty_rings &= ~intel_engine_flag(engine); |
853 | } | 853 | } |
854 | 854 | ||
855 | engine->legacy_active_context = to; | ||
855 | return 0; | 856 | return 0; |
856 | } | 857 | } |
857 | 858 | ||
diff --git a/drivers/gpu/drm/i915/i915_gem_render_state.c b/drivers/gpu/drm/i915/i915_gem_render_state.c index 7032c542a9b1..4dd4c2159a92 100644 --- a/drivers/gpu/drm/i915/i915_gem_render_state.c +++ b/drivers/gpu/drm/i915/i915_gem_render_state.c | |||
@@ -242,6 +242,10 @@ int i915_gem_render_state_emit(struct drm_i915_gem_request *req) | |||
242 | goto err_unpin; | 242 | goto err_unpin; |
243 | } | 243 | } |
244 | 244 | ||
245 | ret = req->engine->emit_flush(req, EMIT_INVALIDATE); | ||
246 | if (ret) | ||
247 | goto err_unpin; | ||
248 | |||
245 | ret = req->engine->emit_bb_start(req, | 249 | ret = req->engine->emit_bb_start(req, |
246 | so->batch_offset, so->batch_size, | 250 | so->batch_offset, so->batch_size, |
247 | I915_DISPATCH_SECURE); | 251 | I915_DISPATCH_SECURE); |
diff --git a/drivers/gpu/drm/i915/i915_gem_shrinker.c b/drivers/gpu/drm/i915/i915_gem_shrinker.c index 1032f98add11..77fb39808131 100644 --- a/drivers/gpu/drm/i915/i915_gem_shrinker.c +++ b/drivers/gpu/drm/i915/i915_gem_shrinker.c | |||
@@ -43,16 +43,21 @@ static bool shrinker_lock(struct drm_i915_private *dev_priv, bool *unlock) | |||
43 | return true; | 43 | return true; |
44 | 44 | ||
45 | case MUTEX_TRYLOCK_FAILED: | 45 | case MUTEX_TRYLOCK_FAILED: |
46 | *unlock = false; | ||
47 | preempt_disable(); | ||
46 | do { | 48 | do { |
47 | cpu_relax(); | 49 | cpu_relax(); |
48 | if (mutex_trylock(&dev_priv->drm.struct_mutex)) { | 50 | if (mutex_trylock(&dev_priv->drm.struct_mutex)) { |
49 | case MUTEX_TRYLOCK_SUCCESS: | ||
50 | *unlock = true; | 51 | *unlock = true; |
51 | return true; | 52 | break; |
52 | } | 53 | } |
53 | } while (!need_resched()); | 54 | } while (!need_resched()); |
55 | preempt_enable(); | ||
56 | return *unlock; | ||
54 | 57 | ||
55 | return false; | 58 | case MUTEX_TRYLOCK_SUCCESS: |
59 | *unlock = true; | ||
60 | return true; | ||
56 | } | 61 | } |
57 | 62 | ||
58 | BUG(); | 63 | BUG(); |
diff --git a/drivers/gpu/drm/i915/i915_perf.c b/drivers/gpu/drm/i915/i915_perf.c index 9cd22f83b0cf..f33d90226704 100644 --- a/drivers/gpu/drm/i915/i915_perf.c +++ b/drivers/gpu/drm/i915/i915_perf.c | |||
@@ -1601,11 +1601,11 @@ static int gen8_emit_oa_config(struct drm_i915_gem_request *req) | |||
1601 | u32 *cs; | 1601 | u32 *cs; |
1602 | int i; | 1602 | int i; |
1603 | 1603 | ||
1604 | cs = intel_ring_begin(req, n_flex_regs * 2 + 4); | 1604 | cs = intel_ring_begin(req, ARRAY_SIZE(flex_mmio) * 2 + 4); |
1605 | if (IS_ERR(cs)) | 1605 | if (IS_ERR(cs)) |
1606 | return PTR_ERR(cs); | 1606 | return PTR_ERR(cs); |
1607 | 1607 | ||
1608 | *cs++ = MI_LOAD_REGISTER_IMM(n_flex_regs + 1); | 1608 | *cs++ = MI_LOAD_REGISTER_IMM(ARRAY_SIZE(flex_mmio) + 1); |
1609 | 1609 | ||
1610 | *cs++ = i915_mmio_reg_offset(GEN8_OACTXCONTROL); | 1610 | *cs++ = i915_mmio_reg_offset(GEN8_OACTXCONTROL); |
1611 | *cs++ = (dev_priv->perf.oa.period_exponent << GEN8_OA_TIMER_PERIOD_SHIFT) | | 1611 | *cs++ = (dev_priv->perf.oa.period_exponent << GEN8_OA_TIMER_PERIOD_SHIFT) | |
diff --git a/drivers/gpu/drm/i915/intel_color.c b/drivers/gpu/drm/i915/intel_color.c index 306c6b06b330..17c4ae7e4e7c 100644 --- a/drivers/gpu/drm/i915/intel_color.c +++ b/drivers/gpu/drm/i915/intel_color.c | |||
@@ -398,6 +398,7 @@ static void bdw_load_gamma_lut(struct drm_crtc_state *state, u32 offset) | |||
398 | } | 398 | } |
399 | 399 | ||
400 | /* Program the max register to clamp values > 1.0. */ | 400 | /* Program the max register to clamp values > 1.0. */ |
401 | i = lut_size - 1; | ||
401 | I915_WRITE(PREC_PAL_GC_MAX(pipe, 0), | 402 | I915_WRITE(PREC_PAL_GC_MAX(pipe, 0), |
402 | drm_color_lut_extract(lut[i].red, 16)); | 403 | drm_color_lut_extract(lut[i].red, 16)); |
403 | I915_WRITE(PREC_PAL_GC_MAX(pipe, 1), | 404 | I915_WRITE(PREC_PAL_GC_MAX(pipe, 1), |
diff --git a/drivers/gpu/drm/i915/intel_ddi.c b/drivers/gpu/drm/i915/intel_ddi.c index 9edeaaef77ad..d3b3252a8742 100644 --- a/drivers/gpu/drm/i915/intel_ddi.c +++ b/drivers/gpu/drm/i915/intel_ddi.c | |||
@@ -1762,7 +1762,7 @@ cnl_get_buf_trans_edp(struct drm_i915_private *dev_priv, | |||
1762 | if (dev_priv->vbt.edp.low_vswing) { | 1762 | if (dev_priv->vbt.edp.low_vswing) { |
1763 | if (voltage == VOLTAGE_INFO_0_85V) { | 1763 | if (voltage == VOLTAGE_INFO_0_85V) { |
1764 | *n_entries = ARRAY_SIZE(cnl_ddi_translations_edp_0_85V); | 1764 | *n_entries = ARRAY_SIZE(cnl_ddi_translations_edp_0_85V); |
1765 | return cnl_ddi_translations_dp_0_85V; | 1765 | return cnl_ddi_translations_edp_0_85V; |
1766 | } else if (voltage == VOLTAGE_INFO_0_95V) { | 1766 | } else if (voltage == VOLTAGE_INFO_0_95V) { |
1767 | *n_entries = ARRAY_SIZE(cnl_ddi_translations_edp_0_95V); | 1767 | *n_entries = ARRAY_SIZE(cnl_ddi_translations_edp_0_95V); |
1768 | return cnl_ddi_translations_edp_0_95V; | 1768 | return cnl_ddi_translations_edp_0_95V; |
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index 9471c88d449e..cc484b56eeaa 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c | |||
@@ -3485,6 +3485,13 @@ void intel_prepare_reset(struct drm_i915_private *dev_priv) | |||
3485 | !gpu_reset_clobbers_display(dev_priv)) | 3485 | !gpu_reset_clobbers_display(dev_priv)) |
3486 | return; | 3486 | return; |
3487 | 3487 | ||
3488 | /* We have a modeset vs reset deadlock, defensively unbreak it. | ||
3489 | * | ||
3490 | * FIXME: We can do a _lot_ better, this is just a first iteration. | ||
3491 | */ | ||
3492 | i915_gem_set_wedged(dev_priv); | ||
3493 | DRM_DEBUG_DRIVER("Wedging GPU to avoid deadlocks with pending modeset updates\n"); | ||
3494 | |||
3488 | /* | 3495 | /* |
3489 | * Need mode_config.mutex so that we don't | 3496 | * Need mode_config.mutex so that we don't |
3490 | * trample ongoing ->detect() and whatnot. | 3497 | * trample ongoing ->detect() and whatnot. |
diff --git a/drivers/gpu/drm/i915/intel_lrc.h b/drivers/gpu/drm/i915/intel_lrc.h index 52b3a1fd4059..57ef5833c427 100644 --- a/drivers/gpu/drm/i915/intel_lrc.h +++ b/drivers/gpu/drm/i915/intel_lrc.h | |||
@@ -63,7 +63,6 @@ enum { | |||
63 | }; | 63 | }; |
64 | 64 | ||
65 | /* Logical Rings */ | 65 | /* Logical Rings */ |
66 | void intel_logical_ring_stop(struct intel_engine_cs *engine); | ||
67 | void intel_logical_ring_cleanup(struct intel_engine_cs *engine); | 66 | void intel_logical_ring_cleanup(struct intel_engine_cs *engine); |
68 | int logical_render_ring_init(struct intel_engine_cs *engine); | 67 | int logical_render_ring_init(struct intel_engine_cs *engine); |
69 | int logical_xcs_ring_init(struct intel_engine_cs *engine); | 68 | int logical_xcs_ring_init(struct intel_engine_cs *engine); |
diff --git a/drivers/gpu/drm/i915/intel_panel.c b/drivers/gpu/drm/i915/intel_panel.c index 96c2cbd81869..593349be8b9d 100644 --- a/drivers/gpu/drm/i915/intel_panel.c +++ b/drivers/gpu/drm/i915/intel_panel.c | |||
@@ -469,7 +469,7 @@ static u32 intel_panel_compute_brightness(struct intel_connector *connector, | |||
469 | 469 | ||
470 | if (i915.invert_brightness > 0 || | 470 | if (i915.invert_brightness > 0 || |
471 | dev_priv->quirks & QUIRK_INVERT_BRIGHTNESS) { | 471 | dev_priv->quirks & QUIRK_INVERT_BRIGHTNESS) { |
472 | return panel->backlight.max - val; | 472 | return panel->backlight.max - val + panel->backlight.min; |
473 | } | 473 | } |
474 | 474 | ||
475 | return val; | 475 | return val; |
diff --git a/drivers/gpu/drm/msm/Kconfig b/drivers/gpu/drm/msm/Kconfig index b638d192ce5e..99d39b2aefa6 100644 --- a/drivers/gpu/drm/msm/Kconfig +++ b/drivers/gpu/drm/msm/Kconfig | |||
@@ -5,7 +5,7 @@ config DRM_MSM | |||
5 | depends on ARCH_QCOM || (ARM && COMPILE_TEST) | 5 | depends on ARCH_QCOM || (ARM && COMPILE_TEST) |
6 | depends on OF && COMMON_CLK | 6 | depends on OF && COMMON_CLK |
7 | depends on MMU | 7 | depends on MMU |
8 | select QCOM_MDT_LOADER | 8 | select QCOM_MDT_LOADER if ARCH_QCOM |
9 | select REGULATOR | 9 | select REGULATOR |
10 | select DRM_KMS_HELPER | 10 | select DRM_KMS_HELPER |
11 | select DRM_PANEL | 11 | select DRM_PANEL |
diff --git a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c index b4b54f1c24bc..f9eae03aa1dc 100644 --- a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c +++ b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c | |||
@@ -15,7 +15,7 @@ | |||
15 | #include <linux/cpumask.h> | 15 | #include <linux/cpumask.h> |
16 | #include <linux/qcom_scm.h> | 16 | #include <linux/qcom_scm.h> |
17 | #include <linux/dma-mapping.h> | 17 | #include <linux/dma-mapping.h> |
18 | #include <linux/of_reserved_mem.h> | 18 | #include <linux/of_address.h> |
19 | #include <linux/soc/qcom/mdt_loader.h> | 19 | #include <linux/soc/qcom/mdt_loader.h> |
20 | #include "msm_gem.h" | 20 | #include "msm_gem.h" |
21 | #include "msm_mmu.h" | 21 | #include "msm_mmu.h" |
@@ -26,16 +26,34 @@ static void a5xx_dump(struct msm_gpu *gpu); | |||
26 | 26 | ||
27 | #define GPU_PAS_ID 13 | 27 | #define GPU_PAS_ID 13 |
28 | 28 | ||
29 | #if IS_ENABLED(CONFIG_QCOM_MDT_LOADER) | ||
30 | |||
31 | static int zap_shader_load_mdt(struct device *dev, const char *fwname) | 29 | static int zap_shader_load_mdt(struct device *dev, const char *fwname) |
32 | { | 30 | { |
33 | const struct firmware *fw; | 31 | const struct firmware *fw; |
32 | struct device_node *np; | ||
33 | struct resource r; | ||
34 | phys_addr_t mem_phys; | 34 | phys_addr_t mem_phys; |
35 | ssize_t mem_size; | 35 | ssize_t mem_size; |
36 | void *mem_region = NULL; | 36 | void *mem_region = NULL; |
37 | int ret; | 37 | int ret; |
38 | 38 | ||
39 | if (!IS_ENABLED(CONFIG_ARCH_QCOM)) | ||
40 | return -EINVAL; | ||
41 | |||
42 | np = of_get_child_by_name(dev->of_node, "zap-shader"); | ||
43 | if (!np) | ||
44 | return -ENODEV; | ||
45 | |||
46 | np = of_parse_phandle(np, "memory-region", 0); | ||
47 | if (!np) | ||
48 | return -EINVAL; | ||
49 | |||
50 | ret = of_address_to_resource(np, 0, &r); | ||
51 | if (ret) | ||
52 | return ret; | ||
53 | |||
54 | mem_phys = r.start; | ||
55 | mem_size = resource_size(&r); | ||
56 | |||
39 | /* Request the MDT file for the firmware */ | 57 | /* Request the MDT file for the firmware */ |
40 | ret = request_firmware(&fw, fwname, dev); | 58 | ret = request_firmware(&fw, fwname, dev); |
41 | if (ret) { | 59 | if (ret) { |
@@ -51,7 +69,7 @@ static int zap_shader_load_mdt(struct device *dev, const char *fwname) | |||
51 | } | 69 | } |
52 | 70 | ||
53 | /* Allocate memory for the firmware image */ | 71 | /* Allocate memory for the firmware image */ |
54 | mem_region = dmam_alloc_coherent(dev, mem_size, &mem_phys, GFP_KERNEL); | 72 | mem_region = memremap(mem_phys, mem_size, MEMREMAP_WC); |
55 | if (!mem_region) { | 73 | if (!mem_region) { |
56 | ret = -ENOMEM; | 74 | ret = -ENOMEM; |
57 | goto out; | 75 | goto out; |
@@ -69,16 +87,13 @@ static int zap_shader_load_mdt(struct device *dev, const char *fwname) | |||
69 | DRM_DEV_ERROR(dev, "Unable to authorize the image\n"); | 87 | DRM_DEV_ERROR(dev, "Unable to authorize the image\n"); |
70 | 88 | ||
71 | out: | 89 | out: |
90 | if (mem_region) | ||
91 | memunmap(mem_region); | ||
92 | |||
72 | release_firmware(fw); | 93 | release_firmware(fw); |
73 | 94 | ||
74 | return ret; | 95 | return ret; |
75 | } | 96 | } |
76 | #else | ||
77 | static int zap_shader_load_mdt(struct device *dev, const char *fwname) | ||
78 | { | ||
79 | return -ENODEV; | ||
80 | } | ||
81 | #endif | ||
82 | 97 | ||
83 | static void a5xx_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit, | 98 | static void a5xx_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit, |
84 | struct msm_file_private *ctx) | 99 | struct msm_file_private *ctx) |
@@ -117,12 +132,10 @@ static void a5xx_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit, | |||
117 | gpu->funcs->flush(gpu); | 132 | gpu->funcs->flush(gpu); |
118 | } | 133 | } |
119 | 134 | ||
120 | struct a5xx_hwcg { | 135 | static const struct { |
121 | u32 offset; | 136 | u32 offset; |
122 | u32 value; | 137 | u32 value; |
123 | }; | 138 | } a5xx_hwcg[] = { |
124 | |||
125 | static const struct a5xx_hwcg a530_hwcg[] = { | ||
126 | {REG_A5XX_RBBM_CLOCK_CNTL_SP0, 0x02222222}, | 139 | {REG_A5XX_RBBM_CLOCK_CNTL_SP0, 0x02222222}, |
127 | {REG_A5XX_RBBM_CLOCK_CNTL_SP1, 0x02222222}, | 140 | {REG_A5XX_RBBM_CLOCK_CNTL_SP1, 0x02222222}, |
128 | {REG_A5XX_RBBM_CLOCK_CNTL_SP2, 0x02222222}, | 141 | {REG_A5XX_RBBM_CLOCK_CNTL_SP2, 0x02222222}, |
@@ -217,38 +230,16 @@ static const struct a5xx_hwcg a530_hwcg[] = { | |||
217 | {REG_A5XX_RBBM_CLOCK_DELAY_VFD, 0x00002222} | 230 | {REG_A5XX_RBBM_CLOCK_DELAY_VFD, 0x00002222} |
218 | }; | 231 | }; |
219 | 232 | ||
220 | static const struct { | 233 | void a5xx_set_hwcg(struct msm_gpu *gpu, bool state) |
221 | int (*test)(struct adreno_gpu *gpu); | ||
222 | const struct a5xx_hwcg *regs; | ||
223 | unsigned int count; | ||
224 | } a5xx_hwcg_regs[] = { | ||
225 | { adreno_is_a530, a530_hwcg, ARRAY_SIZE(a530_hwcg), }, | ||
226 | }; | ||
227 | |||
228 | static void _a5xx_enable_hwcg(struct msm_gpu *gpu, | ||
229 | const struct a5xx_hwcg *regs, unsigned int count) | ||
230 | { | 234 | { |
231 | unsigned int i; | 235 | unsigned int i; |
232 | 236 | ||
233 | for (i = 0; i < count; i++) | 237 | for (i = 0; i < ARRAY_SIZE(a5xx_hwcg); i++) |
234 | gpu_write(gpu, regs[i].offset, regs[i].value); | 238 | gpu_write(gpu, a5xx_hwcg[i].offset, |
239 | state ? a5xx_hwcg[i].value : 0); | ||
235 | 240 | ||
236 | gpu_write(gpu, REG_A5XX_RBBM_CLOCK_CNTL, 0xAAA8AA00); | 241 | gpu_write(gpu, REG_A5XX_RBBM_CLOCK_CNTL, state ? 0xAAA8AA00 : 0); |
237 | gpu_write(gpu, REG_A5XX_RBBM_ISDB_CNT, 0x182); | 242 | gpu_write(gpu, REG_A5XX_RBBM_ISDB_CNT, state ? 0x182 : 0x180); |
238 | } | ||
239 | |||
240 | static void a5xx_enable_hwcg(struct msm_gpu *gpu) | ||
241 | { | ||
242 | struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu); | ||
243 | unsigned int i; | ||
244 | |||
245 | for (i = 0; i < ARRAY_SIZE(a5xx_hwcg_regs); i++) { | ||
246 | if (a5xx_hwcg_regs[i].test(adreno_gpu)) { | ||
247 | _a5xx_enable_hwcg(gpu, a5xx_hwcg_regs[i].regs, | ||
248 | a5xx_hwcg_regs[i].count); | ||
249 | return; | ||
250 | } | ||
251 | } | ||
252 | } | 243 | } |
253 | 244 | ||
254 | static int a5xx_me_init(struct msm_gpu *gpu) | 245 | static int a5xx_me_init(struct msm_gpu *gpu) |
@@ -377,45 +368,6 @@ static int a5xx_zap_shader_resume(struct msm_gpu *gpu) | |||
377 | return ret; | 368 | return ret; |
378 | } | 369 | } |
379 | 370 | ||
380 | /* Set up a child device to "own" the zap shader */ | ||
381 | static int a5xx_zap_shader_dev_init(struct device *parent, struct device *dev) | ||
382 | { | ||
383 | struct device_node *node; | ||
384 | int ret; | ||
385 | |||
386 | if (dev->parent) | ||
387 | return 0; | ||
388 | |||
389 | /* Find the sub-node for the zap shader */ | ||
390 | node = of_get_child_by_name(parent->of_node, "zap-shader"); | ||
391 | if (!node) { | ||
392 | DRM_DEV_ERROR(parent, "zap-shader not found in device tree\n"); | ||
393 | return -ENODEV; | ||
394 | } | ||
395 | |||
396 | dev->parent = parent; | ||
397 | dev->of_node = node; | ||
398 | dev_set_name(dev, "adreno_zap_shader"); | ||
399 | |||
400 | ret = device_register(dev); | ||
401 | if (ret) { | ||
402 | DRM_DEV_ERROR(parent, "Couldn't register zap shader device\n"); | ||
403 | goto out; | ||
404 | } | ||
405 | |||
406 | ret = of_reserved_mem_device_init(dev); | ||
407 | if (ret) { | ||
408 | DRM_DEV_ERROR(parent, "Unable to set up the reserved memory\n"); | ||
409 | device_unregister(dev); | ||
410 | } | ||
411 | |||
412 | out: | ||
413 | if (ret) | ||
414 | dev->parent = NULL; | ||
415 | |||
416 | return ret; | ||
417 | } | ||
418 | |||
419 | static int a5xx_zap_shader_init(struct msm_gpu *gpu) | 371 | static int a5xx_zap_shader_init(struct msm_gpu *gpu) |
420 | { | 372 | { |
421 | static bool loaded; | 373 | static bool loaded; |
@@ -444,11 +396,7 @@ static int a5xx_zap_shader_init(struct msm_gpu *gpu) | |||
444 | return -ENODEV; | 396 | return -ENODEV; |
445 | } | 397 | } |
446 | 398 | ||
447 | ret = a5xx_zap_shader_dev_init(&pdev->dev, &a5xx_gpu->zap_dev); | 399 | ret = zap_shader_load_mdt(&pdev->dev, adreno_gpu->info->zapfw); |
448 | |||
449 | if (!ret) | ||
450 | ret = zap_shader_load_mdt(&a5xx_gpu->zap_dev, | ||
451 | adreno_gpu->info->zapfw); | ||
452 | 400 | ||
453 | loaded = !ret; | 401 | loaded = !ret; |
454 | 402 | ||
@@ -545,7 +493,7 @@ static int a5xx_hw_init(struct msm_gpu *gpu) | |||
545 | gpu_write(gpu, REG_A5XX_RBBM_AHB_CNTL1, 0xA6FFFFFF); | 493 | gpu_write(gpu, REG_A5XX_RBBM_AHB_CNTL1, 0xA6FFFFFF); |
546 | 494 | ||
547 | /* Enable HWCG */ | 495 | /* Enable HWCG */ |
548 | a5xx_enable_hwcg(gpu); | 496 | a5xx_set_hwcg(gpu, true); |
549 | 497 | ||
550 | gpu_write(gpu, REG_A5XX_RBBM_AHB_CNTL2, 0x0000003F); | 498 | gpu_write(gpu, REG_A5XX_RBBM_AHB_CNTL2, 0x0000003F); |
551 | 499 | ||
@@ -691,9 +639,6 @@ static void a5xx_destroy(struct msm_gpu *gpu) | |||
691 | 639 | ||
692 | DBG("%s", gpu->name); | 640 | DBG("%s", gpu->name); |
693 | 641 | ||
694 | if (a5xx_gpu->zap_dev.parent) | ||
695 | device_unregister(&a5xx_gpu->zap_dev); | ||
696 | |||
697 | if (a5xx_gpu->pm4_bo) { | 642 | if (a5xx_gpu->pm4_bo) { |
698 | if (a5xx_gpu->pm4_iova) | 643 | if (a5xx_gpu->pm4_iova) |
699 | msm_gem_put_iova(a5xx_gpu->pm4_bo, gpu->aspace); | 644 | msm_gem_put_iova(a5xx_gpu->pm4_bo, gpu->aspace); |
@@ -920,31 +865,30 @@ static const u32 a5xx_registers[] = { | |||
920 | 0x0000, 0x0002, 0x0004, 0x0020, 0x0022, 0x0026, 0x0029, 0x002B, | 865 | 0x0000, 0x0002, 0x0004, 0x0020, 0x0022, 0x0026, 0x0029, 0x002B, |
921 | 0x002E, 0x0035, 0x0038, 0x0042, 0x0044, 0x0044, 0x0047, 0x0095, | 866 | 0x002E, 0x0035, 0x0038, 0x0042, 0x0044, 0x0044, 0x0047, 0x0095, |
922 | 0x0097, 0x00BB, 0x03A0, 0x0464, 0x0469, 0x046F, 0x04D2, 0x04D3, | 867 | 0x0097, 0x00BB, 0x03A0, 0x0464, 0x0469, 0x046F, 0x04D2, 0x04D3, |
923 | 0x04E0, 0x0533, 0x0540, 0x0555, 0xF400, 0xF400, 0xF800, 0xF807, | 868 | 0x04E0, 0x0533, 0x0540, 0x0555, 0x0800, 0x081A, 0x081F, 0x0841, |
924 | 0x0800, 0x081A, 0x081F, 0x0841, 0x0860, 0x0860, 0x0880, 0x08A0, | 869 | 0x0860, 0x0860, 0x0880, 0x08A0, 0x0B00, 0x0B12, 0x0B15, 0x0B28, |
925 | 0x0B00, 0x0B12, 0x0B15, 0x0B28, 0x0B78, 0x0B7F, 0x0BB0, 0x0BBD, | 870 | 0x0B78, 0x0B7F, 0x0BB0, 0x0BBD, 0x0BC0, 0x0BC6, 0x0BD0, 0x0C53, |
926 | 0x0BC0, 0x0BC6, 0x0BD0, 0x0C53, 0x0C60, 0x0C61, 0x0C80, 0x0C82, | 871 | 0x0C60, 0x0C61, 0x0C80, 0x0C82, 0x0C84, 0x0C85, 0x0C90, 0x0C98, |
927 | 0x0C84, 0x0C85, 0x0C90, 0x0C98, 0x0CA0, 0x0CA0, 0x0CB0, 0x0CB2, | 872 | 0x0CA0, 0x0CA0, 0x0CB0, 0x0CB2, 0x2180, 0x2185, 0x2580, 0x2585, |
928 | 0x2180, 0x2185, 0x2580, 0x2585, 0x0CC1, 0x0CC1, 0x0CC4, 0x0CC7, | 873 | 0x0CC1, 0x0CC1, 0x0CC4, 0x0CC7, 0x0CCC, 0x0CCC, 0x0CD0, 0x0CD8, |
929 | 0x0CCC, 0x0CCC, 0x0CD0, 0x0CD8, 0x0CE0, 0x0CE5, 0x0CE8, 0x0CE8, | 874 | 0x0CE0, 0x0CE5, 0x0CE8, 0x0CE8, 0x0CEC, 0x0CF1, 0x0CFB, 0x0D0E, |
930 | 0x0CEC, 0x0CF1, 0x0CFB, 0x0D0E, 0x2100, 0x211E, 0x2140, 0x2145, | 875 | 0x2100, 0x211E, 0x2140, 0x2145, 0x2500, 0x251E, 0x2540, 0x2545, |
931 | 0x2500, 0x251E, 0x2540, 0x2545, 0x0D10, 0x0D17, 0x0D20, 0x0D23, | 876 | 0x0D10, 0x0D17, 0x0D20, 0x0D23, 0x0D30, 0x0D30, 0x20C0, 0x20C0, |
932 | 0x0D30, 0x0D30, 0x20C0, 0x20C0, 0x24C0, 0x24C0, 0x0E40, 0x0E43, | 877 | 0x24C0, 0x24C0, 0x0E40, 0x0E43, 0x0E4A, 0x0E4A, 0x0E50, 0x0E57, |
933 | 0x0E4A, 0x0E4A, 0x0E50, 0x0E57, 0x0E60, 0x0E7C, 0x0E80, 0x0E8E, | 878 | 0x0E60, 0x0E7C, 0x0E80, 0x0E8E, 0x0E90, 0x0E96, 0x0EA0, 0x0EA8, |
934 | 0x0E90, 0x0E96, 0x0EA0, 0x0EA8, 0x0EB0, 0x0EB2, 0xE140, 0xE147, | 879 | 0x0EB0, 0x0EB2, 0xE140, 0xE147, 0xE150, 0xE187, 0xE1A0, 0xE1A9, |
935 | 0xE150, 0xE187, 0xE1A0, 0xE1A9, 0xE1B0, 0xE1B6, 0xE1C0, 0xE1C7, | 880 | 0xE1B0, 0xE1B6, 0xE1C0, 0xE1C7, 0xE1D0, 0xE1D1, 0xE200, 0xE201, |
936 | 0xE1D0, 0xE1D1, 0xE200, 0xE201, 0xE210, 0xE21C, 0xE240, 0xE268, | 881 | 0xE210, 0xE21C, 0xE240, 0xE268, 0xE000, 0xE006, 0xE010, 0xE09A, |
937 | 0xE000, 0xE006, 0xE010, 0xE09A, 0xE0A0, 0xE0A4, 0xE0AA, 0xE0EB, | 882 | 0xE0A0, 0xE0A4, 0xE0AA, 0xE0EB, 0xE100, 0xE105, 0xE380, 0xE38F, |
938 | 0xE100, 0xE105, 0xE380, 0xE38F, 0xE3B0, 0xE3B0, 0xE400, 0xE405, | 883 | 0xE3B0, 0xE3B0, 0xE400, 0xE405, 0xE408, 0xE4E9, 0xE4F0, 0xE4F0, |
939 | 0xE408, 0xE4E9, 0xE4F0, 0xE4F0, 0xE280, 0xE280, 0xE282, 0xE2A3, | 884 | 0xE280, 0xE280, 0xE282, 0xE2A3, 0xE2A5, 0xE2C2, 0xE940, 0xE947, |
940 | 0xE2A5, 0xE2C2, 0xE940, 0xE947, 0xE950, 0xE987, 0xE9A0, 0xE9A9, | 885 | 0xE950, 0xE987, 0xE9A0, 0xE9A9, 0xE9B0, 0xE9B6, 0xE9C0, 0xE9C7, |
941 | 0xE9B0, 0xE9B6, 0xE9C0, 0xE9C7, 0xE9D0, 0xE9D1, 0xEA00, 0xEA01, | 886 | 0xE9D0, 0xE9D1, 0xEA00, 0xEA01, 0xEA10, 0xEA1C, 0xEA40, 0xEA68, |
942 | 0xEA10, 0xEA1C, 0xEA40, 0xEA68, 0xE800, 0xE806, 0xE810, 0xE89A, | 887 | 0xE800, 0xE806, 0xE810, 0xE89A, 0xE8A0, 0xE8A4, 0xE8AA, 0xE8EB, |
943 | 0xE8A0, 0xE8A4, 0xE8AA, 0xE8EB, 0xE900, 0xE905, 0xEB80, 0xEB8F, | 888 | 0xE900, 0xE905, 0xEB80, 0xEB8F, 0xEBB0, 0xEBB0, 0xEC00, 0xEC05, |
944 | 0xEBB0, 0xEBB0, 0xEC00, 0xEC05, 0xEC08, 0xECE9, 0xECF0, 0xECF0, | 889 | 0xEC08, 0xECE9, 0xECF0, 0xECF0, 0xEA80, 0xEA80, 0xEA82, 0xEAA3, |
945 | 0xEA80, 0xEA80, 0xEA82, 0xEAA3, 0xEAA5, 0xEAC2, 0xA800, 0xA8FF, | 890 | 0xEAA5, 0xEAC2, 0xA800, 0xA8FF, 0xAC60, 0xAC60, 0xB000, 0xB97F, |
946 | 0xAC60, 0xAC60, 0xB000, 0xB97F, 0xB9A0, 0xB9BF, | 891 | 0xB9A0, 0xB9BF, ~0 |
947 | ~0 | ||
948 | }; | 892 | }; |
949 | 893 | ||
950 | static void a5xx_dump(struct msm_gpu *gpu) | 894 | static void a5xx_dump(struct msm_gpu *gpu) |
@@ -1020,7 +964,14 @@ static void a5xx_show(struct msm_gpu *gpu, struct seq_file *m) | |||
1020 | { | 964 | { |
1021 | seq_printf(m, "status: %08x\n", | 965 | seq_printf(m, "status: %08x\n", |
1022 | gpu_read(gpu, REG_A5XX_RBBM_STATUS)); | 966 | gpu_read(gpu, REG_A5XX_RBBM_STATUS)); |
967 | |||
968 | /* | ||
969 | * Temporarily disable hardware clock gating before going into | ||
970 | * adreno_show to avoid issues while reading the registers | ||
971 | */ | ||
972 | a5xx_set_hwcg(gpu, false); | ||
1023 | adreno_show(gpu, m); | 973 | adreno_show(gpu, m); |
974 | a5xx_set_hwcg(gpu, true); | ||
1024 | } | 975 | } |
1025 | #endif | 976 | #endif |
1026 | 977 | ||
diff --git a/drivers/gpu/drm/msm/adreno/a5xx_gpu.h b/drivers/gpu/drm/msm/adreno/a5xx_gpu.h index 6638bc85645d..1137092241d5 100644 --- a/drivers/gpu/drm/msm/adreno/a5xx_gpu.h +++ b/drivers/gpu/drm/msm/adreno/a5xx_gpu.h | |||
@@ -36,8 +36,6 @@ struct a5xx_gpu { | |||
36 | uint32_t gpmu_dwords; | 36 | uint32_t gpmu_dwords; |
37 | 37 | ||
38 | uint32_t lm_leakage; | 38 | uint32_t lm_leakage; |
39 | |||
40 | struct device zap_dev; | ||
41 | }; | 39 | }; |
42 | 40 | ||
43 | #define to_a5xx_gpu(x) container_of(x, struct a5xx_gpu, base) | 41 | #define to_a5xx_gpu(x) container_of(x, struct a5xx_gpu, base) |
@@ -59,5 +57,6 @@ static inline int spin_usecs(struct msm_gpu *gpu, uint32_t usecs, | |||
59 | } | 57 | } |
60 | 58 | ||
61 | bool a5xx_idle(struct msm_gpu *gpu); | 59 | bool a5xx_idle(struct msm_gpu *gpu); |
60 | void a5xx_set_hwcg(struct msm_gpu *gpu, bool state); | ||
62 | 61 | ||
63 | #endif /* __A5XX_GPU_H__ */ | 62 | #endif /* __A5XX_GPU_H__ */ |
diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.c b/drivers/gpu/drm/msm/adreno/adreno_gpu.c index f1ab2703674a..7414c6bbd582 100644 --- a/drivers/gpu/drm/msm/adreno/adreno_gpu.c +++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.c | |||
@@ -48,8 +48,15 @@ int adreno_get_param(struct msm_gpu *gpu, uint32_t param, uint64_t *value) | |||
48 | *value = adreno_gpu->base.fast_rate; | 48 | *value = adreno_gpu->base.fast_rate; |
49 | return 0; | 49 | return 0; |
50 | case MSM_PARAM_TIMESTAMP: | 50 | case MSM_PARAM_TIMESTAMP: |
51 | if (adreno_gpu->funcs->get_timestamp) | 51 | if (adreno_gpu->funcs->get_timestamp) { |
52 | return adreno_gpu->funcs->get_timestamp(gpu, value); | 52 | int ret; |
53 | |||
54 | pm_runtime_get_sync(&gpu->pdev->dev); | ||
55 | ret = adreno_gpu->funcs->get_timestamp(gpu, value); | ||
56 | pm_runtime_put_autosuspend(&gpu->pdev->dev); | ||
57 | |||
58 | return ret; | ||
59 | } | ||
53 | return -EINVAL; | 60 | return -EINVAL; |
54 | default: | 61 | default: |
55 | DBG("%s: invalid param: %u", gpu->name, param); | 62 | DBG("%s: invalid param: %u", gpu->name, param); |
diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/dsi_host.c index 9e9c5696bc03..c7b612c3d771 100644 --- a/drivers/gpu/drm/msm/dsi/dsi_host.c +++ b/drivers/gpu/drm/msm/dsi/dsi_host.c | |||
@@ -2137,6 +2137,13 @@ void msm_dsi_host_get_phy_clk_req(struct mipi_dsi_host *host, | |||
2137 | struct msm_dsi_phy_clk_request *clk_req) | 2137 | struct msm_dsi_phy_clk_request *clk_req) |
2138 | { | 2138 | { |
2139 | struct msm_dsi_host *msm_host = to_msm_dsi_host(host); | 2139 | struct msm_dsi_host *msm_host = to_msm_dsi_host(host); |
2140 | int ret; | ||
2141 | |||
2142 | ret = dsi_calc_clk_rate(msm_host); | ||
2143 | if (ret) { | ||
2144 | pr_err("%s: unable to calc clk rate, %d\n", __func__, ret); | ||
2145 | return; | ||
2146 | } | ||
2140 | 2147 | ||
2141 | clk_req->bitclk_rate = msm_host->byte_clk_rate * 8; | 2148 | clk_req->bitclk_rate = msm_host->byte_clk_rate * 8; |
2142 | clk_req->escclk_rate = msm_host->esc_clk_rate; | 2149 | clk_req->escclk_rate = msm_host->esc_clk_rate; |
@@ -2280,7 +2287,6 @@ int msm_dsi_host_set_display_mode(struct mipi_dsi_host *host, | |||
2280 | struct drm_display_mode *mode) | 2287 | struct drm_display_mode *mode) |
2281 | { | 2288 | { |
2282 | struct msm_dsi_host *msm_host = to_msm_dsi_host(host); | 2289 | struct msm_dsi_host *msm_host = to_msm_dsi_host(host); |
2283 | int ret; | ||
2284 | 2290 | ||
2285 | if (msm_host->mode) { | 2291 | if (msm_host->mode) { |
2286 | drm_mode_destroy(msm_host->dev, msm_host->mode); | 2292 | drm_mode_destroy(msm_host->dev, msm_host->mode); |
@@ -2293,12 +2299,6 @@ int msm_dsi_host_set_display_mode(struct mipi_dsi_host *host, | |||
2293 | return -ENOMEM; | 2299 | return -ENOMEM; |
2294 | } | 2300 | } |
2295 | 2301 | ||
2296 | ret = dsi_calc_clk_rate(msm_host); | ||
2297 | if (ret) { | ||
2298 | pr_err("%s: unable to calc clk rate, %d\n", __func__, ret); | ||
2299 | return ret; | ||
2300 | } | ||
2301 | |||
2302 | return 0; | 2302 | return 0; |
2303 | } | 2303 | } |
2304 | 2304 | ||
diff --git a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c index cb5415d6c04b..735a87a699fa 100644 --- a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c +++ b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c | |||
@@ -221,8 +221,8 @@ static void blend_setup(struct drm_crtc *crtc) | |||
221 | struct mdp5_ctl *ctl = mdp5_cstate->ctl; | 221 | struct mdp5_ctl *ctl = mdp5_cstate->ctl; |
222 | uint32_t blend_op, fg_alpha, bg_alpha, ctl_blend_flags = 0; | 222 | uint32_t blend_op, fg_alpha, bg_alpha, ctl_blend_flags = 0; |
223 | unsigned long flags; | 223 | unsigned long flags; |
224 | enum mdp5_pipe stage[STAGE_MAX + 1][MAX_PIPE_STAGE] = { SSPP_NONE }; | 224 | enum mdp5_pipe stage[STAGE_MAX + 1][MAX_PIPE_STAGE] = { { SSPP_NONE } }; |
225 | enum mdp5_pipe r_stage[STAGE_MAX + 1][MAX_PIPE_STAGE] = { SSPP_NONE }; | 225 | enum mdp5_pipe r_stage[STAGE_MAX + 1][MAX_PIPE_STAGE] = { { SSPP_NONE } }; |
226 | int i, plane_cnt = 0; | 226 | int i, plane_cnt = 0; |
227 | bool bg_alpha_enabled = false; | 227 | bool bg_alpha_enabled = false; |
228 | u32 mixer_op_mode = 0; | 228 | u32 mixer_op_mode = 0; |
@@ -753,6 +753,7 @@ static int mdp5_crtc_cursor_set(struct drm_crtc *crtc, | |||
753 | if (!handle) { | 753 | if (!handle) { |
754 | DBG("Cursor off"); | 754 | DBG("Cursor off"); |
755 | cursor_enable = false; | 755 | cursor_enable = false; |
756 | mdp5_enable(mdp5_kms); | ||
756 | goto set_cursor; | 757 | goto set_cursor; |
757 | } | 758 | } |
758 | 759 | ||
@@ -776,6 +777,8 @@ static int mdp5_crtc_cursor_set(struct drm_crtc *crtc, | |||
776 | 777 | ||
777 | get_roi(crtc, &roi_w, &roi_h); | 778 | get_roi(crtc, &roi_w, &roi_h); |
778 | 779 | ||
780 | mdp5_enable(mdp5_kms); | ||
781 | |||
779 | mdp5_write(mdp5_kms, REG_MDP5_LM_CURSOR_STRIDE(lm), stride); | 782 | mdp5_write(mdp5_kms, REG_MDP5_LM_CURSOR_STRIDE(lm), stride); |
780 | mdp5_write(mdp5_kms, REG_MDP5_LM_CURSOR_FORMAT(lm), | 783 | mdp5_write(mdp5_kms, REG_MDP5_LM_CURSOR_FORMAT(lm), |
781 | MDP5_LM_CURSOR_FORMAT_FORMAT(CURSOR_FMT_ARGB8888)); | 784 | MDP5_LM_CURSOR_FORMAT_FORMAT(CURSOR_FMT_ARGB8888)); |
@@ -804,6 +807,7 @@ set_cursor: | |||
804 | crtc_flush(crtc, flush_mask); | 807 | crtc_flush(crtc, flush_mask); |
805 | 808 | ||
806 | end: | 809 | end: |
810 | mdp5_disable(mdp5_kms); | ||
807 | if (old_bo) { | 811 | if (old_bo) { |
808 | drm_flip_work_queue(&mdp5_crtc->unref_cursor_work, old_bo); | 812 | drm_flip_work_queue(&mdp5_crtc->unref_cursor_work, old_bo); |
809 | /* enable vblank to complete cursor work: */ | 813 | /* enable vblank to complete cursor work: */ |
@@ -836,6 +840,8 @@ static int mdp5_crtc_cursor_move(struct drm_crtc *crtc, int x, int y) | |||
836 | 840 | ||
837 | get_roi(crtc, &roi_w, &roi_h); | 841 | get_roi(crtc, &roi_w, &roi_h); |
838 | 842 | ||
843 | mdp5_enable(mdp5_kms); | ||
844 | |||
839 | spin_lock_irqsave(&mdp5_crtc->cursor.lock, flags); | 845 | spin_lock_irqsave(&mdp5_crtc->cursor.lock, flags); |
840 | mdp5_write(mdp5_kms, REG_MDP5_LM_CURSOR_SIZE(lm), | 846 | mdp5_write(mdp5_kms, REG_MDP5_LM_CURSOR_SIZE(lm), |
841 | MDP5_LM_CURSOR_SIZE_ROI_H(roi_h) | | 847 | MDP5_LM_CURSOR_SIZE_ROI_H(roi_h) | |
@@ -847,6 +853,8 @@ static int mdp5_crtc_cursor_move(struct drm_crtc *crtc, int x, int y) | |||
847 | 853 | ||
848 | crtc_flush(crtc, flush_mask); | 854 | crtc_flush(crtc, flush_mask); |
849 | 855 | ||
856 | mdp5_disable(mdp5_kms); | ||
857 | |||
850 | return 0; | 858 | return 0; |
851 | } | 859 | } |
852 | 860 | ||
diff --git a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_encoder.c b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_encoder.c index 97f3294fbfc6..70bef51245af 100644 --- a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_encoder.c +++ b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_encoder.c | |||
@@ -299,7 +299,7 @@ static void mdp5_encoder_enable(struct drm_encoder *encoder) | |||
299 | struct mdp5_interface *intf = mdp5_encoder->intf; | 299 | struct mdp5_interface *intf = mdp5_encoder->intf; |
300 | 300 | ||
301 | if (intf->mode == MDP5_INTF_DSI_MODE_COMMAND) | 301 | if (intf->mode == MDP5_INTF_DSI_MODE_COMMAND) |
302 | mdp5_cmd_encoder_disable(encoder); | 302 | mdp5_cmd_encoder_enable(encoder); |
303 | else | 303 | else |
304 | mdp5_vid_encoder_enable(encoder); | 304 | mdp5_vid_encoder_enable(encoder); |
305 | } | 305 | } |
diff --git a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c index 5d13fa5381ee..1c603aef3c59 100644 --- a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c +++ b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c | |||
@@ -502,7 +502,7 @@ static int get_clk(struct platform_device *pdev, struct clk **clkp, | |||
502 | const char *name, bool mandatory) | 502 | const char *name, bool mandatory) |
503 | { | 503 | { |
504 | struct device *dev = &pdev->dev; | 504 | struct device *dev = &pdev->dev; |
505 | struct clk *clk = devm_clk_get(dev, name); | 505 | struct clk *clk = msm_clk_get(pdev, name); |
506 | if (IS_ERR(clk) && mandatory) { | 506 | if (IS_ERR(clk) && mandatory) { |
507 | dev_err(dev, "failed to get %s (%ld)\n", name, PTR_ERR(clk)); | 507 | dev_err(dev, "failed to get %s (%ld)\n", name, PTR_ERR(clk)); |
508 | return PTR_ERR(clk); | 508 | return PTR_ERR(clk); |
@@ -887,21 +887,21 @@ static int mdp5_init(struct platform_device *pdev, struct drm_device *dev) | |||
887 | } | 887 | } |
888 | 888 | ||
889 | /* mandatory clocks: */ | 889 | /* mandatory clocks: */ |
890 | ret = get_clk(pdev, &mdp5_kms->axi_clk, "bus_clk", true); | 890 | ret = get_clk(pdev, &mdp5_kms->axi_clk, "bus", true); |
891 | if (ret) | 891 | if (ret) |
892 | goto fail; | 892 | goto fail; |
893 | ret = get_clk(pdev, &mdp5_kms->ahb_clk, "iface_clk", true); | 893 | ret = get_clk(pdev, &mdp5_kms->ahb_clk, "iface", true); |
894 | if (ret) | 894 | if (ret) |
895 | goto fail; | 895 | goto fail; |
896 | ret = get_clk(pdev, &mdp5_kms->core_clk, "core_clk", true); | 896 | ret = get_clk(pdev, &mdp5_kms->core_clk, "core", true); |
897 | if (ret) | 897 | if (ret) |
898 | goto fail; | 898 | goto fail; |
899 | ret = get_clk(pdev, &mdp5_kms->vsync_clk, "vsync_clk", true); | 899 | ret = get_clk(pdev, &mdp5_kms->vsync_clk, "vsync", true); |
900 | if (ret) | 900 | if (ret) |
901 | goto fail; | 901 | goto fail; |
902 | 902 | ||
903 | /* optional clocks: */ | 903 | /* optional clocks: */ |
904 | get_clk(pdev, &mdp5_kms->lut_clk, "lut_clk", false); | 904 | get_clk(pdev, &mdp5_kms->lut_clk, "lut", false); |
905 | 905 | ||
906 | /* we need to set a default rate before enabling. Set a safe | 906 | /* we need to set a default rate before enabling. Set a safe |
907 | * rate first, then figure out hw revision, and then set a | 907 | * rate first, then figure out hw revision, and then set a |
diff --git a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c index fe3a4de1a433..61f39c86dd09 100644 --- a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c +++ b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c | |||
@@ -890,8 +890,8 @@ static int mdp5_plane_mode_set(struct drm_plane *plane, | |||
890 | struct mdp5_hw_pipe *right_hwpipe; | 890 | struct mdp5_hw_pipe *right_hwpipe; |
891 | const struct mdp_format *format; | 891 | const struct mdp_format *format; |
892 | uint32_t nplanes, config = 0; | 892 | uint32_t nplanes, config = 0; |
893 | struct phase_step step = { 0 }; | 893 | struct phase_step step = { { 0 } }; |
894 | struct pixel_ext pe = { 0 }; | 894 | struct pixel_ext pe = { { 0 } }; |
895 | uint32_t hdecm = 0, vdecm = 0; | 895 | uint32_t hdecm = 0, vdecm = 0; |
896 | uint32_t pix_format; | 896 | uint32_t pix_format; |
897 | unsigned int rotation; | 897 | unsigned int rotation; |
diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c index 65f35544c1ec..a0c60e738db8 100644 --- a/drivers/gpu/drm/msm/msm_gem.c +++ b/drivers/gpu/drm/msm/msm_gem.c | |||
@@ -383,8 +383,10 @@ int msm_gem_get_iova(struct drm_gem_object *obj, | |||
383 | struct page **pages; | 383 | struct page **pages; |
384 | 384 | ||
385 | vma = add_vma(obj, aspace); | 385 | vma = add_vma(obj, aspace); |
386 | if (IS_ERR(vma)) | 386 | if (IS_ERR(vma)) { |
387 | return PTR_ERR(vma); | 387 | ret = PTR_ERR(vma); |
388 | goto unlock; | ||
389 | } | ||
388 | 390 | ||
389 | pages = get_pages(obj); | 391 | pages = get_pages(obj); |
390 | if (IS_ERR(pages)) { | 392 | if (IS_ERR(pages)) { |
@@ -405,7 +407,7 @@ int msm_gem_get_iova(struct drm_gem_object *obj, | |||
405 | 407 | ||
406 | fail: | 408 | fail: |
407 | del_vma(vma); | 409 | del_vma(vma); |
408 | 410 | unlock: | |
409 | mutex_unlock(&msm_obj->lock); | 411 | mutex_unlock(&msm_obj->lock); |
410 | return ret; | 412 | return ret; |
411 | } | 413 | } |
@@ -928,8 +930,12 @@ static struct drm_gem_object *_msm_gem_new(struct drm_device *dev, | |||
928 | if (use_vram) { | 930 | if (use_vram) { |
929 | struct msm_gem_vma *vma; | 931 | struct msm_gem_vma *vma; |
930 | struct page **pages; | 932 | struct page **pages; |
933 | struct msm_gem_object *msm_obj = to_msm_bo(obj); | ||
934 | |||
935 | mutex_lock(&msm_obj->lock); | ||
931 | 936 | ||
932 | vma = add_vma(obj, NULL); | 937 | vma = add_vma(obj, NULL); |
938 | mutex_unlock(&msm_obj->lock); | ||
933 | if (IS_ERR(vma)) { | 939 | if (IS_ERR(vma)) { |
934 | ret = PTR_ERR(vma); | 940 | ret = PTR_ERR(vma); |
935 | goto fail; | 941 | goto fail; |
diff --git a/drivers/gpu/drm/msm/msm_gem_submit.c b/drivers/gpu/drm/msm/msm_gem_submit.c index 6bfca7470141..8a75c0bd8a78 100644 --- a/drivers/gpu/drm/msm/msm_gem_submit.c +++ b/drivers/gpu/drm/msm/msm_gem_submit.c | |||
@@ -34,8 +34,8 @@ static struct msm_gem_submit *submit_create(struct drm_device *dev, | |||
34 | struct msm_gpu *gpu, uint32_t nr_bos, uint32_t nr_cmds) | 34 | struct msm_gpu *gpu, uint32_t nr_bos, uint32_t nr_cmds) |
35 | { | 35 | { |
36 | struct msm_gem_submit *submit; | 36 | struct msm_gem_submit *submit; |
37 | uint64_t sz = sizeof(*submit) + (nr_bos * sizeof(submit->bos[0])) + | 37 | uint64_t sz = sizeof(*submit) + ((u64)nr_bos * sizeof(submit->bos[0])) + |
38 | (nr_cmds * sizeof(submit->cmd[0])); | 38 | ((u64)nr_cmds * sizeof(submit->cmd[0])); |
39 | 39 | ||
40 | if (sz > SIZE_MAX) | 40 | if (sz > SIZE_MAX) |
41 | return NULL; | 41 | return NULL; |
@@ -451,7 +451,7 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data, | |||
451 | if (ret) | 451 | if (ret) |
452 | goto out; | 452 | goto out; |
453 | 453 | ||
454 | if (!(args->fence & MSM_SUBMIT_NO_IMPLICIT)) { | 454 | if (!(args->flags & MSM_SUBMIT_NO_IMPLICIT)) { |
455 | ret = submit_fence_sync(submit); | 455 | ret = submit_fence_sync(submit); |
456 | if (ret) | 456 | if (ret) |
457 | goto out; | 457 | goto out; |
diff --git a/drivers/gpu/drm/msm/msm_gem_vma.c b/drivers/gpu/drm/msm/msm_gem_vma.c index c36321bc8714..d34e331554f3 100644 --- a/drivers/gpu/drm/msm/msm_gem_vma.c +++ b/drivers/gpu/drm/msm/msm_gem_vma.c | |||
@@ -42,7 +42,7 @@ void | |||
42 | msm_gem_unmap_vma(struct msm_gem_address_space *aspace, | 42 | msm_gem_unmap_vma(struct msm_gem_address_space *aspace, |
43 | struct msm_gem_vma *vma, struct sg_table *sgt) | 43 | struct msm_gem_vma *vma, struct sg_table *sgt) |
44 | { | 44 | { |
45 | if (!vma->iova) | 45 | if (!aspace || !vma->iova) |
46 | return; | 46 | return; |
47 | 47 | ||
48 | if (aspace->mmu) { | 48 | if (aspace->mmu) { |
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/base.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/base.c index c7c84d34d97e..88582af8bd89 100644 --- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/base.c +++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/base.c | |||
@@ -267,6 +267,8 @@ nvkm_disp_oneinit(struct nvkm_engine *engine) | |||
267 | /* Create output path objects for each VBIOS display path. */ | 267 | /* Create output path objects for each VBIOS display path. */ |
268 | i = -1; | 268 | i = -1; |
269 | while ((data = dcb_outp_parse(bios, ++i, &ver, &hdr, &dcbE))) { | 269 | while ((data = dcb_outp_parse(bios, ++i, &ver, &hdr, &dcbE))) { |
270 | if (ver < 0x40) /* No support for chipsets prior to NV50. */ | ||
271 | break; | ||
270 | if (dcbE.type == DCB_OUTPUT_UNUSED) | 272 | if (dcbE.type == DCB_OUTPUT_UNUSED) |
271 | continue; | 273 | continue; |
272 | if (dcbE.type == DCB_OUTPUT_EOL) | 274 | if (dcbE.type == DCB_OUTPUT_EOL) |
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c index 5d450332c2fd..2900f1410d95 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c | |||
@@ -500,7 +500,7 @@ static void vop_line_flag_irq_disable(struct vop *vop) | |||
500 | static int vop_enable(struct drm_crtc *crtc) | 500 | static int vop_enable(struct drm_crtc *crtc) |
501 | { | 501 | { |
502 | struct vop *vop = to_vop(crtc); | 502 | struct vop *vop = to_vop(crtc); |
503 | int ret; | 503 | int ret, i; |
504 | 504 | ||
505 | ret = pm_runtime_get_sync(vop->dev); | 505 | ret = pm_runtime_get_sync(vop->dev); |
506 | if (ret < 0) { | 506 | if (ret < 0) { |
@@ -533,6 +533,20 @@ static int vop_enable(struct drm_crtc *crtc) | |||
533 | } | 533 | } |
534 | 534 | ||
535 | memcpy(vop->regs, vop->regsbak, vop->len); | 535 | memcpy(vop->regs, vop->regsbak, vop->len); |
536 | /* | ||
537 | * We need to make sure that all windows are disabled before we | ||
538 | * enable the crtc. Otherwise we might try to scan from a destroyed | ||
539 | * buffer later. | ||
540 | */ | ||
541 | for (i = 0; i < vop->data->win_size; i++) { | ||
542 | struct vop_win *vop_win = &vop->win[i]; | ||
543 | const struct vop_win_data *win = vop_win->data; | ||
544 | |||
545 | spin_lock(&vop->reg_lock); | ||
546 | VOP_WIN_SET(vop, win, enable, 0); | ||
547 | spin_unlock(&vop->reg_lock); | ||
548 | } | ||
549 | |||
536 | vop_cfg_done(vop); | 550 | vop_cfg_done(vop); |
537 | 551 | ||
538 | /* | 552 | /* |
@@ -566,28 +580,11 @@ err_put_pm_runtime: | |||
566 | static void vop_crtc_disable(struct drm_crtc *crtc) | 580 | static void vop_crtc_disable(struct drm_crtc *crtc) |
567 | { | 581 | { |
568 | struct vop *vop = to_vop(crtc); | 582 | struct vop *vop = to_vop(crtc); |
569 | int i; | ||
570 | 583 | ||
571 | WARN_ON(vop->event); | 584 | WARN_ON(vop->event); |
572 | 585 | ||
573 | rockchip_drm_psr_deactivate(&vop->crtc); | 586 | rockchip_drm_psr_deactivate(&vop->crtc); |
574 | 587 | ||
575 | /* | ||
576 | * We need to make sure that all windows are disabled before we | ||
577 | * disable that crtc. Otherwise we might try to scan from a destroyed | ||
578 | * buffer later. | ||
579 | */ | ||
580 | for (i = 0; i < vop->data->win_size; i++) { | ||
581 | struct vop_win *vop_win = &vop->win[i]; | ||
582 | const struct vop_win_data *win = vop_win->data; | ||
583 | |||
584 | spin_lock(&vop->reg_lock); | ||
585 | VOP_WIN_SET(vop, win, enable, 0); | ||
586 | spin_unlock(&vop->reg_lock); | ||
587 | } | ||
588 | |||
589 | vop_cfg_done(vop); | ||
590 | |||
591 | drm_crtc_vblank_off(crtc); | 588 | drm_crtc_vblank_off(crtc); |
592 | 589 | ||
593 | /* | 590 | /* |
@@ -682,8 +679,10 @@ static int vop_plane_atomic_check(struct drm_plane *plane, | |||
682 | * Src.x1 can be odd when do clip, but yuv plane start point | 679 | * Src.x1 can be odd when do clip, but yuv plane start point |
683 | * need align with 2 pixel. | 680 | * need align with 2 pixel. |
684 | */ | 681 | */ |
685 | if (is_yuv_support(fb->format->format) && ((state->src.x1 >> 16) % 2)) | 682 | if (is_yuv_support(fb->format->format) && ((state->src.x1 >> 16) % 2)) { |
683 | DRM_ERROR("Invalid Source: Yuv format not support odd xpos\n"); | ||
686 | return -EINVAL; | 684 | return -EINVAL; |
685 | } | ||
687 | 686 | ||
688 | return 0; | 687 | return 0; |
689 | } | 688 | } |
@@ -764,7 +763,7 @@ static void vop_plane_atomic_update(struct drm_plane *plane, | |||
764 | spin_lock(&vop->reg_lock); | 763 | spin_lock(&vop->reg_lock); |
765 | 764 | ||
766 | VOP_WIN_SET(vop, win, format, format); | 765 | VOP_WIN_SET(vop, win, format, format); |
767 | VOP_WIN_SET(vop, win, yrgb_vir, fb->pitches[0] >> 2); | 766 | VOP_WIN_SET(vop, win, yrgb_vir, DIV_ROUND_UP(fb->pitches[0], 4)); |
768 | VOP_WIN_SET(vop, win, yrgb_mst, dma_addr); | 767 | VOP_WIN_SET(vop, win, yrgb_mst, dma_addr); |
769 | if (is_yuv_support(fb->format->format)) { | 768 | if (is_yuv_support(fb->format->format)) { |
770 | int hsub = drm_format_horz_chroma_subsampling(fb->format->format); | 769 | int hsub = drm_format_horz_chroma_subsampling(fb->format->format); |
@@ -778,7 +777,7 @@ static void vop_plane_atomic_update(struct drm_plane *plane, | |||
778 | offset += (src->y1 >> 16) * fb->pitches[1] / vsub; | 777 | offset += (src->y1 >> 16) * fb->pitches[1] / vsub; |
779 | 778 | ||
780 | dma_addr = rk_uv_obj->dma_addr + offset + fb->offsets[1]; | 779 | dma_addr = rk_uv_obj->dma_addr + offset + fb->offsets[1]; |
781 | VOP_WIN_SET(vop, win, uv_vir, fb->pitches[1] >> 2); | 780 | VOP_WIN_SET(vop, win, uv_vir, DIV_ROUND_UP(fb->pitches[1], 4)); |
782 | VOP_WIN_SET(vop, win, uv_mst, dma_addr); | 781 | VOP_WIN_SET(vop, win, uv_mst, dma_addr); |
783 | } | 782 | } |
784 | 783 | ||
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.h b/drivers/gpu/drm/rockchip/rockchip_drm_vop.h index 9979fd0c2282..27eefbfcf3d0 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.h +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.h | |||
@@ -282,6 +282,9 @@ static inline uint16_t scl_get_bili_dn_vskip(int src_h, int dst_h, | |||
282 | 282 | ||
283 | act_height = (src_h + vskiplines - 1) / vskiplines; | 283 | act_height = (src_h + vskiplines - 1) / vskiplines; |
284 | 284 | ||
285 | if (act_height == dst_h) | ||
286 | return GET_SCL_FT_BILI_DN(src_h, dst_h) / vskiplines; | ||
287 | |||
285 | return GET_SCL_FT_BILI_DN(act_height, dst_h); | 288 | return GET_SCL_FT_BILI_DN(act_height, dst_h); |
286 | } | 289 | } |
287 | 290 | ||
diff --git a/drivers/gpu/drm/stm/Kconfig b/drivers/gpu/drm/stm/Kconfig index 2c4817fb0890..8fe5b184b4e8 100644 --- a/drivers/gpu/drm/stm/Kconfig +++ b/drivers/gpu/drm/stm/Kconfig | |||
@@ -7,7 +7,6 @@ config DRM_STM | |||
7 | select DRM_PANEL | 7 | select DRM_PANEL |
8 | select VIDEOMODE_HELPERS | 8 | select VIDEOMODE_HELPERS |
9 | select FB_PROVIDE_GET_FB_UNMAPPED_AREA | 9 | select FB_PROVIDE_GET_FB_UNMAPPED_AREA |
10 | default y | ||
11 | 10 | ||
12 | help | 11 | help |
13 | Enable support for the on-chip display controller on | 12 | Enable support for the on-chip display controller on |
diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c b/drivers/gpu/drm/ttm/ttm_bo_vm.c index b442d12f2f7d..84fb009d4eb0 100644 --- a/drivers/gpu/drm/ttm/ttm_bo_vm.c +++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c | |||
@@ -39,6 +39,7 @@ | |||
39 | #include <linux/rbtree.h> | 39 | #include <linux/rbtree.h> |
40 | #include <linux/module.h> | 40 | #include <linux/module.h> |
41 | #include <linux/uaccess.h> | 41 | #include <linux/uaccess.h> |
42 | #include <linux/mem_encrypt.h> | ||
42 | 43 | ||
43 | #define TTM_BO_VM_NUM_PREFAULT 16 | 44 | #define TTM_BO_VM_NUM_PREFAULT 16 |
44 | 45 | ||
@@ -230,9 +231,11 @@ static int ttm_bo_vm_fault(struct vm_fault *vmf) | |||
230 | * first page. | 231 | * first page. |
231 | */ | 232 | */ |
232 | for (i = 0; i < TTM_BO_VM_NUM_PREFAULT; ++i) { | 233 | for (i = 0; i < TTM_BO_VM_NUM_PREFAULT; ++i) { |
233 | if (bo->mem.bus.is_iomem) | 234 | if (bo->mem.bus.is_iomem) { |
235 | /* Iomem should not be marked encrypted */ | ||
236 | cvma.vm_page_prot = pgprot_decrypted(cvma.vm_page_prot); | ||
234 | pfn = bdev->driver->io_mem_pfn(bo, page_offset); | 237 | pfn = bdev->driver->io_mem_pfn(bo, page_offset); |
235 | else { | 238 | } else { |
236 | page = ttm->pages[page_offset]; | 239 | page = ttm->pages[page_offset]; |
237 | if (unlikely(!page && i == 0)) { | 240 | if (unlikely(!page && i == 0)) { |
238 | retval = VM_FAULT_OOM; | 241 | retval = VM_FAULT_OOM; |
diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c index 4a6500362564..92e1690e28de 100644 --- a/drivers/gpu/drm/udl/udl_fb.c +++ b/drivers/gpu/drm/udl/udl_fb.c | |||
@@ -14,6 +14,7 @@ | |||
14 | #include <linux/slab.h> | 14 | #include <linux/slab.h> |
15 | #include <linux/fb.h> | 15 | #include <linux/fb.h> |
16 | #include <linux/dma-buf.h> | 16 | #include <linux/dma-buf.h> |
17 | #include <linux/mem_encrypt.h> | ||
17 | 18 | ||
18 | #include <drm/drmP.h> | 19 | #include <drm/drmP.h> |
19 | #include <drm/drm_crtc.h> | 20 | #include <drm/drm_crtc.h> |
@@ -169,6 +170,9 @@ static int udl_fb_mmap(struct fb_info *info, struct vm_area_struct *vma) | |||
169 | pr_notice("mmap() framebuffer addr:%lu size:%lu\n", | 170 | pr_notice("mmap() framebuffer addr:%lu size:%lu\n", |
170 | pos, size); | 171 | pos, size); |
171 | 172 | ||
173 | /* We don't want the framebuffer to be mapped encrypted */ | ||
174 | vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot); | ||
175 | |||
172 | while (size > 0) { | 176 | while (size > 0) { |
173 | page = vmalloc_to_pfn((void *)pos); | 177 | page = vmalloc_to_pfn((void *)pos); |
174 | if (remap_pfn_range(vma, start, page, PAGE_SIZE, PAGE_SHARED)) | 178 | if (remap_pfn_range(vma, start, page, PAGE_SIZE, PAGE_SHARED)) |
diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c index c2ae819a871c..e87ffb3c31a9 100644 --- a/drivers/idle/intel_idle.c +++ b/drivers/idle/intel_idle.c | |||
@@ -913,16 +913,15 @@ static __cpuidle int intel_idle(struct cpuidle_device *dev, | |||
913 | struct cpuidle_state *state = &drv->states[index]; | 913 | struct cpuidle_state *state = &drv->states[index]; |
914 | unsigned long eax = flg2MWAIT(state->flags); | 914 | unsigned long eax = flg2MWAIT(state->flags); |
915 | unsigned int cstate; | 915 | unsigned int cstate; |
916 | int cpu = smp_processor_id(); | ||
917 | 916 | ||
918 | cstate = (((eax) >> MWAIT_SUBSTATE_SIZE) & MWAIT_CSTATE_MASK) + 1; | 917 | cstate = (((eax) >> MWAIT_SUBSTATE_SIZE) & MWAIT_CSTATE_MASK) + 1; |
919 | 918 | ||
920 | /* | 919 | /* |
921 | * leave_mm() to avoid costly and often unnecessary wakeups | 920 | * NB: if CPUIDLE_FLAG_TLB_FLUSHED is set, this idle transition |
922 | * for flushing the user TLB's associated with the active mm. | 921 | * will probably flush the TLB. It's not guaranteed to flush |
922 | * the TLB, though, so it's not clear that we can do anything | ||
923 | * useful with this knowledge. | ||
923 | */ | 924 | */ |
924 | if (state->flags & CPUIDLE_FLAG_TLB_FLUSHED) | ||
925 | leave_mm(cpu); | ||
926 | 925 | ||
927 | if (!(lapic_timer_reliable_states & (1 << (cstate)))) | 926 | if (!(lapic_timer_reliable_states & (1 << (cstate)))) |
928 | tick_broadcast_enter(); | 927 | tick_broadcast_enter(); |
diff --git a/drivers/iio/accel/bmc150-accel-core.c b/drivers/iio/accel/bmc150-accel-core.c index 6b5d3be283c4..807299dd45eb 100644 --- a/drivers/iio/accel/bmc150-accel-core.c +++ b/drivers/iio/accel/bmc150-accel-core.c | |||
@@ -193,7 +193,6 @@ struct bmc150_accel_data { | |||
193 | struct regmap *regmap; | 193 | struct regmap *regmap; |
194 | int irq; | 194 | int irq; |
195 | struct bmc150_accel_interrupt interrupts[BMC150_ACCEL_INTERRUPTS]; | 195 | struct bmc150_accel_interrupt interrupts[BMC150_ACCEL_INTERRUPTS]; |
196 | atomic_t active_intr; | ||
197 | struct bmc150_accel_trigger triggers[BMC150_ACCEL_TRIGGERS]; | 196 | struct bmc150_accel_trigger triggers[BMC150_ACCEL_TRIGGERS]; |
198 | struct mutex mutex; | 197 | struct mutex mutex; |
199 | u8 fifo_mode, watermark; | 198 | u8 fifo_mode, watermark; |
@@ -493,11 +492,6 @@ static int bmc150_accel_set_interrupt(struct bmc150_accel_data *data, int i, | |||
493 | goto out_fix_power_state; | 492 | goto out_fix_power_state; |
494 | } | 493 | } |
495 | 494 | ||
496 | if (state) | ||
497 | atomic_inc(&data->active_intr); | ||
498 | else | ||
499 | atomic_dec(&data->active_intr); | ||
500 | |||
501 | return 0; | 495 | return 0; |
502 | 496 | ||
503 | out_fix_power_state: | 497 | out_fix_power_state: |
@@ -1710,8 +1704,7 @@ static int bmc150_accel_resume(struct device *dev) | |||
1710 | struct bmc150_accel_data *data = iio_priv(indio_dev); | 1704 | struct bmc150_accel_data *data = iio_priv(indio_dev); |
1711 | 1705 | ||
1712 | mutex_lock(&data->mutex); | 1706 | mutex_lock(&data->mutex); |
1713 | if (atomic_read(&data->active_intr)) | 1707 | bmc150_accel_set_mode(data, BMC150_ACCEL_SLEEP_MODE_NORMAL, 0); |
1714 | bmc150_accel_set_mode(data, BMC150_ACCEL_SLEEP_MODE_NORMAL, 0); | ||
1715 | bmc150_accel_fifo_set_mode(data); | 1708 | bmc150_accel_fifo_set_mode(data); |
1716 | mutex_unlock(&data->mutex); | 1709 | mutex_unlock(&data->mutex); |
1717 | 1710 | ||
diff --git a/drivers/iio/accel/st_accel_core.c b/drivers/iio/accel/st_accel_core.c index 07d1489cd457..e44f62bf9caa 100644 --- a/drivers/iio/accel/st_accel_core.c +++ b/drivers/iio/accel/st_accel_core.c | |||
@@ -166,6 +166,10 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = { | |||
166 | .mask_ihl = 0x02, | 166 | .mask_ihl = 0x02, |
167 | .addr_stat_drdy = ST_SENSORS_DEFAULT_STAT_ADDR, | 167 | .addr_stat_drdy = ST_SENSORS_DEFAULT_STAT_ADDR, |
168 | }, | 168 | }, |
169 | .sim = { | ||
170 | .addr = 0x23, | ||
171 | .value = BIT(0), | ||
172 | }, | ||
169 | .multi_read_bit = true, | 173 | .multi_read_bit = true, |
170 | .bootime = 2, | 174 | .bootime = 2, |
171 | }, | 175 | }, |
@@ -234,6 +238,10 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = { | |||
234 | .mask_od = 0x40, | 238 | .mask_od = 0x40, |
235 | .addr_stat_drdy = ST_SENSORS_DEFAULT_STAT_ADDR, | 239 | .addr_stat_drdy = ST_SENSORS_DEFAULT_STAT_ADDR, |
236 | }, | 240 | }, |
241 | .sim = { | ||
242 | .addr = 0x23, | ||
243 | .value = BIT(0), | ||
244 | }, | ||
237 | .multi_read_bit = true, | 245 | .multi_read_bit = true, |
238 | .bootime = 2, | 246 | .bootime = 2, |
239 | }, | 247 | }, |
@@ -316,6 +324,10 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = { | |||
316 | .en_mask = 0x08, | 324 | .en_mask = 0x08, |
317 | }, | 325 | }, |
318 | }, | 326 | }, |
327 | .sim = { | ||
328 | .addr = 0x24, | ||
329 | .value = BIT(0), | ||
330 | }, | ||
319 | .multi_read_bit = false, | 331 | .multi_read_bit = false, |
320 | .bootime = 2, | 332 | .bootime = 2, |
321 | }, | 333 | }, |
@@ -379,6 +391,10 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = { | |||
379 | .mask_int1 = 0x04, | 391 | .mask_int1 = 0x04, |
380 | .addr_stat_drdy = ST_SENSORS_DEFAULT_STAT_ADDR, | 392 | .addr_stat_drdy = ST_SENSORS_DEFAULT_STAT_ADDR, |
381 | }, | 393 | }, |
394 | .sim = { | ||
395 | .addr = 0x21, | ||
396 | .value = BIT(1), | ||
397 | }, | ||
382 | .multi_read_bit = true, | 398 | .multi_read_bit = true, |
383 | .bootime = 2, /* guess */ | 399 | .bootime = 2, /* guess */ |
384 | }, | 400 | }, |
@@ -437,6 +453,10 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = { | |||
437 | .mask_od = 0x40, | 453 | .mask_od = 0x40, |
438 | .addr_stat_drdy = ST_SENSORS_DEFAULT_STAT_ADDR, | 454 | .addr_stat_drdy = ST_SENSORS_DEFAULT_STAT_ADDR, |
439 | }, | 455 | }, |
456 | .sim = { | ||
457 | .addr = 0x21, | ||
458 | .value = BIT(7), | ||
459 | }, | ||
440 | .multi_read_bit = false, | 460 | .multi_read_bit = false, |
441 | .bootime = 2, /* guess */ | 461 | .bootime = 2, /* guess */ |
442 | }, | 462 | }, |
@@ -499,6 +519,10 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = { | |||
499 | .addr_ihl = 0x22, | 519 | .addr_ihl = 0x22, |
500 | .mask_ihl = 0x80, | 520 | .mask_ihl = 0x80, |
501 | }, | 521 | }, |
522 | .sim = { | ||
523 | .addr = 0x23, | ||
524 | .value = BIT(0), | ||
525 | }, | ||
502 | .multi_read_bit = true, | 526 | .multi_read_bit = true, |
503 | .bootime = 2, | 527 | .bootime = 2, |
504 | }, | 528 | }, |
@@ -547,6 +571,10 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = { | |||
547 | .mask_int1 = 0x04, | 571 | .mask_int1 = 0x04, |
548 | .addr_stat_drdy = ST_SENSORS_DEFAULT_STAT_ADDR, | 572 | .addr_stat_drdy = ST_SENSORS_DEFAULT_STAT_ADDR, |
549 | }, | 573 | }, |
574 | .sim = { | ||
575 | .addr = 0x21, | ||
576 | .value = BIT(1), | ||
577 | }, | ||
550 | .multi_read_bit = false, | 578 | .multi_read_bit = false, |
551 | .bootime = 2, | 579 | .bootime = 2, |
552 | }, | 580 | }, |
@@ -614,6 +642,10 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = { | |||
614 | .mask_ihl = 0x02, | 642 | .mask_ihl = 0x02, |
615 | .addr_stat_drdy = ST_SENSORS_DEFAULT_STAT_ADDR, | 643 | .addr_stat_drdy = ST_SENSORS_DEFAULT_STAT_ADDR, |
616 | }, | 644 | }, |
645 | .sim = { | ||
646 | .addr = 0x23, | ||
647 | .value = BIT(0), | ||
648 | }, | ||
617 | .multi_read_bit = true, | 649 | .multi_read_bit = true, |
618 | .bootime = 2, | 650 | .bootime = 2, |
619 | }, | 651 | }, |
diff --git a/drivers/iio/adc/aspeed_adc.c b/drivers/iio/adc/aspeed_adc.c index e0ea411a0b2d..c02b23d675cb 100644 --- a/drivers/iio/adc/aspeed_adc.c +++ b/drivers/iio/adc/aspeed_adc.c | |||
@@ -22,6 +22,7 @@ | |||
22 | 22 | ||
23 | #include <linux/iio/iio.h> | 23 | #include <linux/iio/iio.h> |
24 | #include <linux/iio/driver.h> | 24 | #include <linux/iio/driver.h> |
25 | #include <linux/iopoll.h> | ||
25 | 26 | ||
26 | #define ASPEED_RESOLUTION_BITS 10 | 27 | #define ASPEED_RESOLUTION_BITS 10 |
27 | #define ASPEED_CLOCKS_PER_SAMPLE 12 | 28 | #define ASPEED_CLOCKS_PER_SAMPLE 12 |
@@ -38,11 +39,17 @@ | |||
38 | 39 | ||
39 | #define ASPEED_ENGINE_ENABLE BIT(0) | 40 | #define ASPEED_ENGINE_ENABLE BIT(0) |
40 | 41 | ||
42 | #define ASPEED_ADC_CTRL_INIT_RDY BIT(8) | ||
43 | |||
44 | #define ASPEED_ADC_INIT_POLLING_TIME 500 | ||
45 | #define ASPEED_ADC_INIT_TIMEOUT 500000 | ||
46 | |||
41 | struct aspeed_adc_model_data { | 47 | struct aspeed_adc_model_data { |
42 | const char *model_name; | 48 | const char *model_name; |
43 | unsigned int min_sampling_rate; // Hz | 49 | unsigned int min_sampling_rate; // Hz |
44 | unsigned int max_sampling_rate; // Hz | 50 | unsigned int max_sampling_rate; // Hz |
45 | unsigned int vref_voltage; // mV | 51 | unsigned int vref_voltage; // mV |
52 | bool wait_init_sequence; | ||
46 | }; | 53 | }; |
47 | 54 | ||
48 | struct aspeed_adc_data { | 55 | struct aspeed_adc_data { |
@@ -211,6 +218,24 @@ static int aspeed_adc_probe(struct platform_device *pdev) | |||
211 | goto scaler_error; | 218 | goto scaler_error; |
212 | } | 219 | } |
213 | 220 | ||
221 | model_data = of_device_get_match_data(&pdev->dev); | ||
222 | |||
223 | if (model_data->wait_init_sequence) { | ||
224 | /* Enable engine in normal mode. */ | ||
225 | writel(ASPEED_OPERATION_MODE_NORMAL | ASPEED_ENGINE_ENABLE, | ||
226 | data->base + ASPEED_REG_ENGINE_CONTROL); | ||
227 | |||
228 | /* Wait for initial sequence complete. */ | ||
229 | ret = readl_poll_timeout(data->base + ASPEED_REG_ENGINE_CONTROL, | ||
230 | adc_engine_control_reg_val, | ||
231 | adc_engine_control_reg_val & | ||
232 | ASPEED_ADC_CTRL_INIT_RDY, | ||
233 | ASPEED_ADC_INIT_POLLING_TIME, | ||
234 | ASPEED_ADC_INIT_TIMEOUT); | ||
235 | if (ret) | ||
236 | goto scaler_error; | ||
237 | } | ||
238 | |||
214 | /* Start all channels in normal mode. */ | 239 | /* Start all channels in normal mode. */ |
215 | ret = clk_prepare_enable(data->clk_scaler->clk); | 240 | ret = clk_prepare_enable(data->clk_scaler->clk); |
216 | if (ret) | 241 | if (ret) |
@@ -274,6 +299,7 @@ static const struct aspeed_adc_model_data ast2500_model_data = { | |||
274 | .vref_voltage = 1800, // mV | 299 | .vref_voltage = 1800, // mV |
275 | .min_sampling_rate = 1, | 300 | .min_sampling_rate = 1, |
276 | .max_sampling_rate = 1000000, | 301 | .max_sampling_rate = 1000000, |
302 | .wait_init_sequence = true, | ||
277 | }; | 303 | }; |
278 | 304 | ||
279 | static const struct of_device_id aspeed_adc_matches[] = { | 305 | static const struct of_device_id aspeed_adc_matches[] = { |
diff --git a/drivers/iio/adc/axp288_adc.c b/drivers/iio/adc/axp288_adc.c index 64799ad7ebad..462a99c13e7a 100644 --- a/drivers/iio/adc/axp288_adc.c +++ b/drivers/iio/adc/axp288_adc.c | |||
@@ -28,6 +28,8 @@ | |||
28 | #include <linux/iio/driver.h> | 28 | #include <linux/iio/driver.h> |
29 | 29 | ||
30 | #define AXP288_ADC_EN_MASK 0xF1 | 30 | #define AXP288_ADC_EN_MASK 0xF1 |
31 | #define AXP288_ADC_TS_PIN_GPADC 0xF2 | ||
32 | #define AXP288_ADC_TS_PIN_ON 0xF3 | ||
31 | 33 | ||
32 | enum axp288_adc_id { | 34 | enum axp288_adc_id { |
33 | AXP288_ADC_TS, | 35 | AXP288_ADC_TS, |
@@ -121,6 +123,26 @@ static int axp288_adc_read_channel(int *val, unsigned long address, | |||
121 | return IIO_VAL_INT; | 123 | return IIO_VAL_INT; |
122 | } | 124 | } |
123 | 125 | ||
126 | static int axp288_adc_set_ts(struct regmap *regmap, unsigned int mode, | ||
127 | unsigned long address) | ||
128 | { | ||
129 | int ret; | ||
130 | |||
131 | /* channels other than GPADC do not need to switch TS pin */ | ||
132 | if (address != AXP288_GP_ADC_H) | ||
133 | return 0; | ||
134 | |||
135 | ret = regmap_write(regmap, AXP288_ADC_TS_PIN_CTRL, mode); | ||
136 | if (ret) | ||
137 | return ret; | ||
138 | |||
139 | /* When switching to the GPADC pin give things some time to settle */ | ||
140 | if (mode == AXP288_ADC_TS_PIN_GPADC) | ||
141 | usleep_range(6000, 10000); | ||
142 | |||
143 | return 0; | ||
144 | } | ||
145 | |||
124 | static int axp288_adc_read_raw(struct iio_dev *indio_dev, | 146 | static int axp288_adc_read_raw(struct iio_dev *indio_dev, |
125 | struct iio_chan_spec const *chan, | 147 | struct iio_chan_spec const *chan, |
126 | int *val, int *val2, long mask) | 148 | int *val, int *val2, long mask) |
@@ -131,7 +153,16 @@ static int axp288_adc_read_raw(struct iio_dev *indio_dev, | |||
131 | mutex_lock(&indio_dev->mlock); | 153 | mutex_lock(&indio_dev->mlock); |
132 | switch (mask) { | 154 | switch (mask) { |
133 | case IIO_CHAN_INFO_RAW: | 155 | case IIO_CHAN_INFO_RAW: |
156 | if (axp288_adc_set_ts(info->regmap, AXP288_ADC_TS_PIN_GPADC, | ||
157 | chan->address)) { | ||
158 | dev_err(&indio_dev->dev, "GPADC mode\n"); | ||
159 | ret = -EINVAL; | ||
160 | break; | ||
161 | } | ||
134 | ret = axp288_adc_read_channel(val, chan->address, info->regmap); | 162 | ret = axp288_adc_read_channel(val, chan->address, info->regmap); |
163 | if (axp288_adc_set_ts(info->regmap, AXP288_ADC_TS_PIN_ON, | ||
164 | chan->address)) | ||
165 | dev_err(&indio_dev->dev, "TS pin restore\n"); | ||
135 | break; | 166 | break; |
136 | default: | 167 | default: |
137 | ret = -EINVAL; | 168 | ret = -EINVAL; |
@@ -141,6 +172,15 @@ static int axp288_adc_read_raw(struct iio_dev *indio_dev, | |||
141 | return ret; | 172 | return ret; |
142 | } | 173 | } |
143 | 174 | ||
175 | static int axp288_adc_set_state(struct regmap *regmap) | ||
176 | { | ||
177 | /* ADC should be always enabled for internal FG to function */ | ||
178 | if (regmap_write(regmap, AXP288_ADC_TS_PIN_CTRL, AXP288_ADC_TS_PIN_ON)) | ||
179 | return -EIO; | ||
180 | |||
181 | return regmap_write(regmap, AXP20X_ADC_EN1, AXP288_ADC_EN_MASK); | ||
182 | } | ||
183 | |||
144 | static const struct iio_info axp288_adc_iio_info = { | 184 | static const struct iio_info axp288_adc_iio_info = { |
145 | .read_raw = &axp288_adc_read_raw, | 185 | .read_raw = &axp288_adc_read_raw, |
146 | .driver_module = THIS_MODULE, | 186 | .driver_module = THIS_MODULE, |
@@ -169,7 +209,7 @@ static int axp288_adc_probe(struct platform_device *pdev) | |||
169 | * Set ADC to enabled state at all time, including system suspend. | 209 | * Set ADC to enabled state at all time, including system suspend. |
170 | * otherwise internal fuel gauge functionality may be affected. | 210 | * otherwise internal fuel gauge functionality may be affected. |
171 | */ | 211 | */ |
172 | ret = regmap_write(info->regmap, AXP20X_ADC_EN1, AXP288_ADC_EN_MASK); | 212 | ret = axp288_adc_set_state(axp20x->regmap); |
173 | if (ret) { | 213 | if (ret) { |
174 | dev_err(&pdev->dev, "unable to enable ADC device\n"); | 214 | dev_err(&pdev->dev, "unable to enable ADC device\n"); |
175 | return ret; | 215 | return ret; |
diff --git a/drivers/iio/adc/sun4i-gpadc-iio.c b/drivers/iio/adc/sun4i-gpadc-iio.c index 81d4c39e414a..137f577d9432 100644 --- a/drivers/iio/adc/sun4i-gpadc-iio.c +++ b/drivers/iio/adc/sun4i-gpadc-iio.c | |||
@@ -256,6 +256,7 @@ static int sun4i_gpadc_read(struct iio_dev *indio_dev, int channel, int *val, | |||
256 | 256 | ||
257 | err: | 257 | err: |
258 | pm_runtime_put_autosuspend(indio_dev->dev.parent); | 258 | pm_runtime_put_autosuspend(indio_dev->dev.parent); |
259 | disable_irq(irq); | ||
259 | mutex_unlock(&info->mutex); | 260 | mutex_unlock(&info->mutex); |
260 | 261 | ||
261 | return ret; | 262 | return ret; |
@@ -365,7 +366,6 @@ static irqreturn_t sun4i_gpadc_temp_data_irq_handler(int irq, void *dev_id) | |||
365 | complete(&info->completion); | 366 | complete(&info->completion); |
366 | 367 | ||
367 | out: | 368 | out: |
368 | disable_irq_nosync(info->temp_data_irq); | ||
369 | return IRQ_HANDLED; | 369 | return IRQ_HANDLED; |
370 | } | 370 | } |
371 | 371 | ||
@@ -380,7 +380,6 @@ static irqreturn_t sun4i_gpadc_fifo_data_irq_handler(int irq, void *dev_id) | |||
380 | complete(&info->completion); | 380 | complete(&info->completion); |
381 | 381 | ||
382 | out: | 382 | out: |
383 | disable_irq_nosync(info->fifo_data_irq); | ||
384 | return IRQ_HANDLED; | 383 | return IRQ_HANDLED; |
385 | } | 384 | } |
386 | 385 | ||
diff --git a/drivers/iio/adc/vf610_adc.c b/drivers/iio/adc/vf610_adc.c index 01fc76f7d660..c168e0db329a 100644 --- a/drivers/iio/adc/vf610_adc.c +++ b/drivers/iio/adc/vf610_adc.c | |||
@@ -77,7 +77,7 @@ | |||
77 | #define VF610_ADC_ADSTS_MASK 0x300 | 77 | #define VF610_ADC_ADSTS_MASK 0x300 |
78 | #define VF610_ADC_ADLPC_EN 0x80 | 78 | #define VF610_ADC_ADLPC_EN 0x80 |
79 | #define VF610_ADC_ADHSC_EN 0x400 | 79 | #define VF610_ADC_ADHSC_EN 0x400 |
80 | #define VF610_ADC_REFSEL_VALT 0x100 | 80 | #define VF610_ADC_REFSEL_VALT 0x800 |
81 | #define VF610_ADC_REFSEL_VBG 0x1000 | 81 | #define VF610_ADC_REFSEL_VBG 0x1000 |
82 | #define VF610_ADC_ADTRG_HARD 0x2000 | 82 | #define VF610_ADC_ADTRG_HARD 0x2000 |
83 | #define VF610_ADC_AVGS_8 0x4000 | 83 | #define VF610_ADC_AVGS_8 0x4000 |
diff --git a/drivers/iio/common/st_sensors/st_sensors_core.c b/drivers/iio/common/st_sensors/st_sensors_core.c index 79c8c7cd70d5..6e6a1ecc99dd 100644 --- a/drivers/iio/common/st_sensors/st_sensors_core.c +++ b/drivers/iio/common/st_sensors/st_sensors_core.c | |||
@@ -550,6 +550,31 @@ out: | |||
550 | } | 550 | } |
551 | EXPORT_SYMBOL(st_sensors_read_info_raw); | 551 | EXPORT_SYMBOL(st_sensors_read_info_raw); |
552 | 552 | ||
553 | static int st_sensors_init_interface_mode(struct iio_dev *indio_dev, | ||
554 | const struct st_sensor_settings *sensor_settings) | ||
555 | { | ||
556 | struct st_sensor_data *sdata = iio_priv(indio_dev); | ||
557 | struct device_node *np = sdata->dev->of_node; | ||
558 | struct st_sensors_platform_data *pdata; | ||
559 | |||
560 | pdata = (struct st_sensors_platform_data *)sdata->dev->platform_data; | ||
561 | if (((np && of_property_read_bool(np, "spi-3wire")) || | ||
562 | (pdata && pdata->spi_3wire)) && sensor_settings->sim.addr) { | ||
563 | int err; | ||
564 | |||
565 | err = sdata->tf->write_byte(&sdata->tb, sdata->dev, | ||
566 | sensor_settings->sim.addr, | ||
567 | sensor_settings->sim.value); | ||
568 | if (err < 0) { | ||
569 | dev_err(&indio_dev->dev, | ||
570 | "failed to init interface mode\n"); | ||
571 | return err; | ||
572 | } | ||
573 | } | ||
574 | |||
575 | return 0; | ||
576 | } | ||
577 | |||
553 | int st_sensors_check_device_support(struct iio_dev *indio_dev, | 578 | int st_sensors_check_device_support(struct iio_dev *indio_dev, |
554 | int num_sensors_list, | 579 | int num_sensors_list, |
555 | const struct st_sensor_settings *sensor_settings) | 580 | const struct st_sensor_settings *sensor_settings) |
@@ -574,6 +599,10 @@ int st_sensors_check_device_support(struct iio_dev *indio_dev, | |||
574 | return -ENODEV; | 599 | return -ENODEV; |
575 | } | 600 | } |
576 | 601 | ||
602 | err = st_sensors_init_interface_mode(indio_dev, &sensor_settings[i]); | ||
603 | if (err < 0) | ||
604 | return err; | ||
605 | |||
577 | if (sensor_settings[i].wai_addr) { | 606 | if (sensor_settings[i].wai_addr) { |
578 | err = sdata->tf->read_byte(&sdata->tb, sdata->dev, | 607 | err = sdata->tf->read_byte(&sdata->tb, sdata->dev, |
579 | sensor_settings[i].wai_addr, &wai); | 608 | sensor_settings[i].wai_addr, &wai); |
diff --git a/drivers/iio/light/tsl2563.c b/drivers/iio/light/tsl2563.c index e7d4ea75e007..7599693f7fe9 100644 --- a/drivers/iio/light/tsl2563.c +++ b/drivers/iio/light/tsl2563.c | |||
@@ -626,7 +626,7 @@ static irqreturn_t tsl2563_event_handler(int irq, void *private) | |||
626 | struct tsl2563_chip *chip = iio_priv(dev_info); | 626 | struct tsl2563_chip *chip = iio_priv(dev_info); |
627 | 627 | ||
628 | iio_push_event(dev_info, | 628 | iio_push_event(dev_info, |
629 | IIO_UNMOD_EVENT_CODE(IIO_LIGHT, | 629 | IIO_UNMOD_EVENT_CODE(IIO_INTENSITY, |
630 | 0, | 630 | 0, |
631 | IIO_EV_TYPE_THRESH, | 631 | IIO_EV_TYPE_THRESH, |
632 | IIO_EV_DIR_EITHER), | 632 | IIO_EV_DIR_EITHER), |
diff --git a/drivers/iio/pressure/st_pressure_core.c b/drivers/iio/pressure/st_pressure_core.c index aa61ec15c139..f1bce05ffa13 100644 --- a/drivers/iio/pressure/st_pressure_core.c +++ b/drivers/iio/pressure/st_pressure_core.c | |||
@@ -456,7 +456,7 @@ static const struct st_sensor_settings st_press_sensors_settings[] = { | |||
456 | .mask_od = 0x40, | 456 | .mask_od = 0x40, |
457 | .addr_stat_drdy = ST_SENSORS_DEFAULT_STAT_ADDR, | 457 | .addr_stat_drdy = ST_SENSORS_DEFAULT_STAT_ADDR, |
458 | }, | 458 | }, |
459 | .multi_read_bit = true, | 459 | .multi_read_bit = false, |
460 | .bootime = 2, | 460 | .bootime = 2, |
461 | }, | 461 | }, |
462 | }; | 462 | }; |
diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c index a5dfab6adf49..221468f77128 100644 --- a/drivers/infiniband/core/device.c +++ b/drivers/infiniband/core/device.c | |||
@@ -537,10 +537,11 @@ void ib_unregister_device(struct ib_device *device) | |||
537 | } | 537 | } |
538 | up_read(&lists_rwsem); | 538 | up_read(&lists_rwsem); |
539 | 539 | ||
540 | mutex_unlock(&device_mutex); | ||
541 | |||
542 | ib_device_unregister_rdmacg(device); | 540 | ib_device_unregister_rdmacg(device); |
543 | ib_device_unregister_sysfs(device); | 541 | ib_device_unregister_sysfs(device); |
542 | |||
543 | mutex_unlock(&device_mutex); | ||
544 | |||
544 | ib_cache_cleanup_one(device); | 545 | ib_cache_cleanup_one(device); |
545 | 546 | ||
546 | ib_security_destroy_port_pkey_list(device); | 547 | ib_security_destroy_port_pkey_list(device); |
diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c index c551d2b275fd..739bd69ef1d4 100644 --- a/drivers/infiniband/core/uverbs_cmd.c +++ b/drivers/infiniband/core/uverbs_cmd.c | |||
@@ -1015,7 +1015,7 @@ static struct ib_ucq_object *create_cq(struct ib_uverbs_file *file, | |||
1015 | cq->uobject = &obj->uobject; | 1015 | cq->uobject = &obj->uobject; |
1016 | cq->comp_handler = ib_uverbs_comp_handler; | 1016 | cq->comp_handler = ib_uverbs_comp_handler; |
1017 | cq->event_handler = ib_uverbs_cq_event_handler; | 1017 | cq->event_handler = ib_uverbs_cq_event_handler; |
1018 | cq->cq_context = &ev_file->ev_queue; | 1018 | cq->cq_context = ev_file ? &ev_file->ev_queue : NULL; |
1019 | atomic_set(&cq->usecnt, 0); | 1019 | atomic_set(&cq->usecnt, 0); |
1020 | 1020 | ||
1021 | obj->uobject.object = cq; | 1021 | obj->uobject.object = cq; |
@@ -1522,6 +1522,7 @@ static int create_qp(struct ib_uverbs_file *file, | |||
1522 | qp->qp_type = attr.qp_type; | 1522 | qp->qp_type = attr.qp_type; |
1523 | atomic_set(&qp->usecnt, 0); | 1523 | atomic_set(&qp->usecnt, 0); |
1524 | atomic_inc(&pd->usecnt); | 1524 | atomic_inc(&pd->usecnt); |
1525 | qp->port = 0; | ||
1525 | if (attr.send_cq) | 1526 | if (attr.send_cq) |
1526 | atomic_inc(&attr.send_cq->usecnt); | 1527 | atomic_inc(&attr.send_cq->usecnt); |
1527 | if (attr.recv_cq) | 1528 | if (attr.recv_cq) |
@@ -1962,8 +1963,9 @@ static int modify_qp(struct ib_uverbs_file *file, | |||
1962 | attr->alt_timeout = cmd->base.alt_timeout; | 1963 | attr->alt_timeout = cmd->base.alt_timeout; |
1963 | attr->rate_limit = cmd->rate_limit; | 1964 | attr->rate_limit = cmd->rate_limit; |
1964 | 1965 | ||
1965 | attr->ah_attr.type = rdma_ah_find_type(qp->device, | 1966 | if (cmd->base.attr_mask & IB_QP_AV) |
1966 | cmd->base.dest.port_num); | 1967 | attr->ah_attr.type = rdma_ah_find_type(qp->device, |
1968 | cmd->base.dest.port_num); | ||
1967 | if (cmd->base.dest.is_global) { | 1969 | if (cmd->base.dest.is_global) { |
1968 | rdma_ah_set_grh(&attr->ah_attr, NULL, | 1970 | rdma_ah_set_grh(&attr->ah_attr, NULL, |
1969 | cmd->base.dest.flow_label, | 1971 | cmd->base.dest.flow_label, |
@@ -1981,8 +1983,9 @@ static int modify_qp(struct ib_uverbs_file *file, | |||
1981 | rdma_ah_set_port_num(&attr->ah_attr, | 1983 | rdma_ah_set_port_num(&attr->ah_attr, |
1982 | cmd->base.dest.port_num); | 1984 | cmd->base.dest.port_num); |
1983 | 1985 | ||
1984 | attr->alt_ah_attr.type = rdma_ah_find_type(qp->device, | 1986 | if (cmd->base.attr_mask & IB_QP_ALT_PATH) |
1985 | cmd->base.dest.port_num); | 1987 | attr->alt_ah_attr.type = |
1988 | rdma_ah_find_type(qp->device, cmd->base.dest.port_num); | ||
1986 | if (cmd->base.alt_dest.is_global) { | 1989 | if (cmd->base.alt_dest.is_global) { |
1987 | rdma_ah_set_grh(&attr->alt_ah_attr, NULL, | 1990 | rdma_ah_set_grh(&attr->alt_ah_attr, NULL, |
1988 | cmd->base.alt_dest.flow_label, | 1991 | cmd->base.alt_dest.flow_label, |
diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c index c023e2c81b8f..5e530d2bee44 100644 --- a/drivers/infiniband/core/uverbs_main.c +++ b/drivers/infiniband/core/uverbs_main.c | |||
@@ -1153,7 +1153,6 @@ static void ib_uverbs_free_hw_resources(struct ib_uverbs_device *uverbs_dev, | |||
1153 | kref_get(&file->ref); | 1153 | kref_get(&file->ref); |
1154 | mutex_unlock(&uverbs_dev->lists_mutex); | 1154 | mutex_unlock(&uverbs_dev->lists_mutex); |
1155 | 1155 | ||
1156 | ib_uverbs_event_handler(&file->event_handler, &event); | ||
1157 | 1156 | ||
1158 | mutex_lock(&file->cleanup_mutex); | 1157 | mutex_lock(&file->cleanup_mutex); |
1159 | ucontext = file->ucontext; | 1158 | ucontext = file->ucontext; |
@@ -1170,6 +1169,7 @@ static void ib_uverbs_free_hw_resources(struct ib_uverbs_device *uverbs_dev, | |||
1170 | * for example due to freeing the resources | 1169 | * for example due to freeing the resources |
1171 | * (e.g mmput). | 1170 | * (e.g mmput). |
1172 | */ | 1171 | */ |
1172 | ib_uverbs_event_handler(&file->event_handler, &event); | ||
1173 | ib_dev->disassociate_ucontext(ucontext); | 1173 | ib_dev->disassociate_ucontext(ucontext); |
1174 | mutex_lock(&file->cleanup_mutex); | 1174 | mutex_lock(&file->cleanup_mutex); |
1175 | ib_uverbs_cleanup_ucontext(file, ucontext, true); | 1175 | ib_uverbs_cleanup_ucontext(file, ucontext, true); |
diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c index 7f8fe443df46..b456e3ca1876 100644 --- a/drivers/infiniband/core/verbs.c +++ b/drivers/infiniband/core/verbs.c | |||
@@ -838,6 +838,7 @@ struct ib_qp *ib_create_qp(struct ib_pd *pd, | |||
838 | spin_lock_init(&qp->mr_lock); | 838 | spin_lock_init(&qp->mr_lock); |
839 | INIT_LIST_HEAD(&qp->rdma_mrs); | 839 | INIT_LIST_HEAD(&qp->rdma_mrs); |
840 | INIT_LIST_HEAD(&qp->sig_mrs); | 840 | INIT_LIST_HEAD(&qp->sig_mrs); |
841 | qp->port = 0; | ||
841 | 842 | ||
842 | if (qp_init_attr->qp_type == IB_QPT_XRC_TGT) | 843 | if (qp_init_attr->qp_type == IB_QPT_XRC_TGT) |
843 | return ib_create_xrc_qp(qp, qp_init_attr); | 844 | return ib_create_xrc_qp(qp, qp_init_attr); |
@@ -1297,7 +1298,11 @@ int ib_modify_qp_with_udata(struct ib_qp *qp, struct ib_qp_attr *attr, | |||
1297 | if (ret) | 1298 | if (ret) |
1298 | return ret; | 1299 | return ret; |
1299 | } | 1300 | } |
1300 | return ib_security_modify_qp(qp, attr, attr_mask, udata); | 1301 | ret = ib_security_modify_qp(qp, attr, attr_mask, udata); |
1302 | if (!ret && (attr_mask & IB_QP_PORT)) | ||
1303 | qp->port = attr->port_num; | ||
1304 | |||
1305 | return ret; | ||
1301 | } | 1306 | } |
1302 | EXPORT_SYMBOL(ib_modify_qp_with_udata); | 1307 | EXPORT_SYMBOL(ib_modify_qp_with_udata); |
1303 | 1308 | ||
diff --git a/drivers/infiniband/hw/cxgb4/mem.c b/drivers/infiniband/hw/cxgb4/mem.c index 5332f06b99ba..c2fba76becd4 100644 --- a/drivers/infiniband/hw/cxgb4/mem.c +++ b/drivers/infiniband/hw/cxgb4/mem.c | |||
@@ -661,7 +661,7 @@ struct ib_mr *c4iw_alloc_mr(struct ib_pd *pd, | |||
661 | rhp = php->rhp; | 661 | rhp = php->rhp; |
662 | 662 | ||
663 | if (mr_type != IB_MR_TYPE_MEM_REG || | 663 | if (mr_type != IB_MR_TYPE_MEM_REG || |
664 | max_num_sg > t4_max_fr_depth(&rhp->rdev.lldi.ulptx_memwrite_dsgl && | 664 | max_num_sg > t4_max_fr_depth(rhp->rdev.lldi.ulptx_memwrite_dsgl && |
665 | use_dsgl)) | 665 | use_dsgl)) |
666 | return ERR_PTR(-EINVAL); | 666 | return ERR_PTR(-EINVAL); |
667 | 667 | ||
diff --git a/drivers/infiniband/hw/hns/hns_roce_ah.c b/drivers/infiniband/hw/hns/hns_roce_ah.c index f78a733a63ec..d545302b8ef8 100644 --- a/drivers/infiniband/hw/hns/hns_roce_ah.c +++ b/drivers/infiniband/hw/hns/hns_roce_ah.c | |||
@@ -64,8 +64,10 @@ struct ib_ah *hns_roce_create_ah(struct ib_pd *ibpd, | |||
64 | } else { | 64 | } else { |
65 | u8 *dmac = rdma_ah_retrieve_dmac(ah_attr); | 65 | u8 *dmac = rdma_ah_retrieve_dmac(ah_attr); |
66 | 66 | ||
67 | if (!dmac) | 67 | if (!dmac) { |
68 | kfree(ah); | ||
68 | return ERR_PTR(-EINVAL); | 69 | return ERR_PTR(-EINVAL); |
70 | } | ||
69 | memcpy(ah->av.mac, dmac, ETH_ALEN); | 71 | memcpy(ah->av.mac, dmac, ETH_ALEN); |
70 | } | 72 | } |
71 | 73 | ||
diff --git a/drivers/infiniband/hw/i40iw/i40iw_ctrl.c b/drivers/infiniband/hw/i40iw/i40iw_ctrl.c index 9ec1ae9a82c9..a49ff2eb6fb3 100644 --- a/drivers/infiniband/hw/i40iw/i40iw_ctrl.c +++ b/drivers/infiniband/hw/i40iw/i40iw_ctrl.c | |||
@@ -130,20 +130,32 @@ static enum i40iw_status_code i40iw_sc_parse_fpm_commit_buf( | |||
130 | u64 base = 0; | 130 | u64 base = 0; |
131 | u32 i, j; | 131 | u32 i, j; |
132 | u32 k = 0; | 132 | u32 k = 0; |
133 | u32 low; | ||
134 | 133 | ||
135 | /* copy base values in obj_info */ | 134 | /* copy base values in obj_info */ |
136 | for (i = I40IW_HMC_IW_QP, j = 0; | 135 | for (i = I40IW_HMC_IW_QP, j = 0; i <= I40IW_HMC_IW_PBLE; i++, j += 8) { |
137 | i <= I40IW_HMC_IW_PBLE; i++, j += 8) { | 136 | if ((i == I40IW_HMC_IW_SRQ) || |
137 | (i == I40IW_HMC_IW_FSIMC) || | ||
138 | (i == I40IW_HMC_IW_FSIAV)) { | ||
139 | info[i].base = 0; | ||
140 | info[i].cnt = 0; | ||
141 | continue; | ||
142 | } | ||
138 | get_64bit_val(buf, j, &temp); | 143 | get_64bit_val(buf, j, &temp); |
139 | info[i].base = RS_64_1(temp, 32) * 512; | 144 | info[i].base = RS_64_1(temp, 32) * 512; |
140 | if (info[i].base > base) { | 145 | if (info[i].base > base) { |
141 | base = info[i].base; | 146 | base = info[i].base; |
142 | k = i; | 147 | k = i; |
143 | } | 148 | } |
144 | low = (u32)(temp); | 149 | if (i == I40IW_HMC_IW_APBVT_ENTRY) { |
145 | if (low) | 150 | info[i].cnt = 1; |
146 | info[i].cnt = low; | 151 | continue; |
152 | } | ||
153 | if (i == I40IW_HMC_IW_QP) | ||
154 | info[i].cnt = (u32)RS_64(temp, I40IW_QUERY_FPM_MAX_QPS); | ||
155 | else if (i == I40IW_HMC_IW_CQ) | ||
156 | info[i].cnt = (u32)RS_64(temp, I40IW_QUERY_FPM_MAX_CQS); | ||
157 | else | ||
158 | info[i].cnt = (u32)(temp); | ||
147 | } | 159 | } |
148 | size = info[k].cnt * info[k].size + info[k].base; | 160 | size = info[k].cnt * info[k].size + info[k].base; |
149 | if (size & 0x1FFFFF) | 161 | if (size & 0x1FFFFF) |
@@ -155,6 +167,31 @@ static enum i40iw_status_code i40iw_sc_parse_fpm_commit_buf( | |||
155 | } | 167 | } |
156 | 168 | ||
157 | /** | 169 | /** |
170 | * i40iw_sc_decode_fpm_query() - Decode a 64 bit value into max count and size | ||
171 | * @buf: ptr to fpm query buffer | ||
172 | * @buf_idx: index into buf | ||
173 | * @info: ptr to i40iw_hmc_obj_info struct | ||
174 | * @rsrc_idx: resource index into info | ||
175 | * | ||
176 | * Decode a 64 bit value from fpm query buffer into max count and size | ||
177 | */ | ||
178 | static u64 i40iw_sc_decode_fpm_query(u64 *buf, | ||
179 | u32 buf_idx, | ||
180 | struct i40iw_hmc_obj_info *obj_info, | ||
181 | u32 rsrc_idx) | ||
182 | { | ||
183 | u64 temp; | ||
184 | u32 size; | ||
185 | |||
186 | get_64bit_val(buf, buf_idx, &temp); | ||
187 | obj_info[rsrc_idx].max_cnt = (u32)temp; | ||
188 | size = (u32)RS_64_1(temp, 32); | ||
189 | obj_info[rsrc_idx].size = LS_64_1(1, size); | ||
190 | |||
191 | return temp; | ||
192 | } | ||
193 | |||
194 | /** | ||
158 | * i40iw_sc_parse_fpm_query_buf() - parses fpm query buffer | 195 | * i40iw_sc_parse_fpm_query_buf() - parses fpm query buffer |
159 | * @buf: ptr to fpm query buffer | 196 | * @buf: ptr to fpm query buffer |
160 | * @info: ptr to i40iw_hmc_obj_info struct | 197 | * @info: ptr to i40iw_hmc_obj_info struct |
@@ -168,9 +205,9 @@ static enum i40iw_status_code i40iw_sc_parse_fpm_query_buf( | |||
168 | struct i40iw_hmc_info *hmc_info, | 205 | struct i40iw_hmc_info *hmc_info, |
169 | struct i40iw_hmc_fpm_misc *hmc_fpm_misc) | 206 | struct i40iw_hmc_fpm_misc *hmc_fpm_misc) |
170 | { | 207 | { |
171 | u64 temp; | ||
172 | struct i40iw_hmc_obj_info *obj_info; | 208 | struct i40iw_hmc_obj_info *obj_info; |
173 | u32 i, j, size; | 209 | u64 temp; |
210 | u32 size; | ||
174 | u16 max_pe_sds; | 211 | u16 max_pe_sds; |
175 | 212 | ||
176 | obj_info = hmc_info->hmc_obj; | 213 | obj_info = hmc_info->hmc_obj; |
@@ -185,41 +222,52 @@ static enum i40iw_status_code i40iw_sc_parse_fpm_query_buf( | |||
185 | hmc_fpm_misc->max_sds = max_pe_sds; | 222 | hmc_fpm_misc->max_sds = max_pe_sds; |
186 | hmc_info->sd_table.sd_cnt = max_pe_sds + hmc_info->first_sd_index; | 223 | hmc_info->sd_table.sd_cnt = max_pe_sds + hmc_info->first_sd_index; |
187 | 224 | ||
188 | for (i = I40IW_HMC_IW_QP, j = 8; | 225 | get_64bit_val(buf, 8, &temp); |
189 | i <= I40IW_HMC_IW_ARP; i++, j += 8) { | 226 | obj_info[I40IW_HMC_IW_QP].max_cnt = (u32)RS_64(temp, I40IW_QUERY_FPM_MAX_QPS); |
190 | get_64bit_val(buf, j, &temp); | 227 | size = (u32)RS_64_1(temp, 32); |
191 | if (i == I40IW_HMC_IW_QP) | 228 | obj_info[I40IW_HMC_IW_QP].size = LS_64_1(1, size); |
192 | obj_info[i].max_cnt = (u32)RS_64(temp, I40IW_QUERY_FPM_MAX_QPS); | ||
193 | else if (i == I40IW_HMC_IW_CQ) | ||
194 | obj_info[i].max_cnt = (u32)RS_64(temp, I40IW_QUERY_FPM_MAX_CQS); | ||
195 | else | ||
196 | obj_info[i].max_cnt = (u32)temp; | ||
197 | 229 | ||
198 | size = (u32)RS_64_1(temp, 32); | 230 | get_64bit_val(buf, 16, &temp); |
199 | obj_info[i].size = ((u64)1 << size); | 231 | obj_info[I40IW_HMC_IW_CQ].max_cnt = (u32)RS_64(temp, I40IW_QUERY_FPM_MAX_CQS); |
200 | } | 232 | size = (u32)RS_64_1(temp, 32); |
201 | for (i = I40IW_HMC_IW_MR, j = 48; | 233 | obj_info[I40IW_HMC_IW_CQ].size = LS_64_1(1, size); |
202 | i <= I40IW_HMC_IW_PBLE; i++, j += 8) { | 234 | |
203 | get_64bit_val(buf, j, &temp); | 235 | i40iw_sc_decode_fpm_query(buf, 32, obj_info, I40IW_HMC_IW_HTE); |
204 | obj_info[i].max_cnt = (u32)temp; | 236 | i40iw_sc_decode_fpm_query(buf, 40, obj_info, I40IW_HMC_IW_ARP); |
205 | size = (u32)RS_64_1(temp, 32); | 237 | |
206 | obj_info[i].size = LS_64_1(1, size); | 238 | obj_info[I40IW_HMC_IW_APBVT_ENTRY].size = 8192; |
207 | } | 239 | obj_info[I40IW_HMC_IW_APBVT_ENTRY].max_cnt = 1; |
240 | |||
241 | i40iw_sc_decode_fpm_query(buf, 48, obj_info, I40IW_HMC_IW_MR); | ||
242 | i40iw_sc_decode_fpm_query(buf, 56, obj_info, I40IW_HMC_IW_XF); | ||
208 | 243 | ||
209 | get_64bit_val(buf, 120, &temp); | ||
210 | hmc_fpm_misc->max_ceqs = (u8)RS_64(temp, I40IW_QUERY_FPM_MAX_CEQS); | ||
211 | get_64bit_val(buf, 120, &temp); | ||
212 | hmc_fpm_misc->ht_multiplier = RS_64(temp, I40IW_QUERY_FPM_HTMULTIPLIER); | ||
213 | get_64bit_val(buf, 120, &temp); | ||
214 | hmc_fpm_misc->timer_bucket = RS_64(temp, I40IW_QUERY_FPM_TIMERBUCKET); | ||
215 | get_64bit_val(buf, 64, &temp); | 244 | get_64bit_val(buf, 64, &temp); |
245 | obj_info[I40IW_HMC_IW_XFFL].max_cnt = (u32)temp; | ||
246 | obj_info[I40IW_HMC_IW_XFFL].size = 4; | ||
216 | hmc_fpm_misc->xf_block_size = RS_64(temp, I40IW_QUERY_FPM_XFBLOCKSIZE); | 247 | hmc_fpm_misc->xf_block_size = RS_64(temp, I40IW_QUERY_FPM_XFBLOCKSIZE); |
217 | if (!hmc_fpm_misc->xf_block_size) | 248 | if (!hmc_fpm_misc->xf_block_size) |
218 | return I40IW_ERR_INVALID_SIZE; | 249 | return I40IW_ERR_INVALID_SIZE; |
250 | |||
251 | i40iw_sc_decode_fpm_query(buf, 72, obj_info, I40IW_HMC_IW_Q1); | ||
252 | |||
219 | get_64bit_val(buf, 80, &temp); | 253 | get_64bit_val(buf, 80, &temp); |
254 | obj_info[I40IW_HMC_IW_Q1FL].max_cnt = (u32)temp; | ||
255 | obj_info[I40IW_HMC_IW_Q1FL].size = 4; | ||
220 | hmc_fpm_misc->q1_block_size = RS_64(temp, I40IW_QUERY_FPM_Q1BLOCKSIZE); | 256 | hmc_fpm_misc->q1_block_size = RS_64(temp, I40IW_QUERY_FPM_Q1BLOCKSIZE); |
221 | if (!hmc_fpm_misc->q1_block_size) | 257 | if (!hmc_fpm_misc->q1_block_size) |
222 | return I40IW_ERR_INVALID_SIZE; | 258 | return I40IW_ERR_INVALID_SIZE; |
259 | |||
260 | i40iw_sc_decode_fpm_query(buf, 88, obj_info, I40IW_HMC_IW_TIMER); | ||
261 | |||
262 | get_64bit_val(buf, 112, &temp); | ||
263 | obj_info[I40IW_HMC_IW_PBLE].max_cnt = (u32)temp; | ||
264 | obj_info[I40IW_HMC_IW_PBLE].size = 8; | ||
265 | |||
266 | get_64bit_val(buf, 120, &temp); | ||
267 | hmc_fpm_misc->max_ceqs = (u8)RS_64(temp, I40IW_QUERY_FPM_MAX_CEQS); | ||
268 | hmc_fpm_misc->ht_multiplier = RS_64(temp, I40IW_QUERY_FPM_HTMULTIPLIER); | ||
269 | hmc_fpm_misc->timer_bucket = RS_64(temp, I40IW_QUERY_FPM_TIMERBUCKET); | ||
270 | |||
223 | return 0; | 271 | return 0; |
224 | } | 272 | } |
225 | 273 | ||
@@ -3392,13 +3440,6 @@ enum i40iw_status_code i40iw_sc_init_iw_hmc(struct i40iw_sc_dev *dev, u8 hmc_fn_ | |||
3392 | hmc_info->sd_table.sd_entry = virt_mem.va; | 3440 | hmc_info->sd_table.sd_entry = virt_mem.va; |
3393 | } | 3441 | } |
3394 | 3442 | ||
3395 | /* fill size of objects which are fixed */ | ||
3396 | hmc_info->hmc_obj[I40IW_HMC_IW_XFFL].size = 4; | ||
3397 | hmc_info->hmc_obj[I40IW_HMC_IW_Q1FL].size = 4; | ||
3398 | hmc_info->hmc_obj[I40IW_HMC_IW_PBLE].size = 8; | ||
3399 | hmc_info->hmc_obj[I40IW_HMC_IW_APBVT_ENTRY].size = 8192; | ||
3400 | hmc_info->hmc_obj[I40IW_HMC_IW_APBVT_ENTRY].max_cnt = 1; | ||
3401 | |||
3402 | return ret_code; | 3443 | return ret_code; |
3403 | } | 3444 | } |
3404 | 3445 | ||
@@ -4840,7 +4881,7 @@ void i40iw_vsi_stats_free(struct i40iw_sc_vsi *vsi) | |||
4840 | { | 4881 | { |
4841 | u8 fcn_id = vsi->fcn_id; | 4882 | u8 fcn_id = vsi->fcn_id; |
4842 | 4883 | ||
4843 | if ((vsi->stats_fcn_id_alloc) && (fcn_id != I40IW_INVALID_FCN_ID)) | 4884 | if (vsi->stats_fcn_id_alloc && fcn_id < I40IW_MAX_STATS_COUNT) |
4844 | vsi->dev->fcn_id_array[fcn_id] = false; | 4885 | vsi->dev->fcn_id_array[fcn_id] = false; |
4845 | i40iw_hw_stats_stop_timer(vsi); | 4886 | i40iw_hw_stats_stop_timer(vsi); |
4846 | } | 4887 | } |
diff --git a/drivers/infiniband/hw/i40iw/i40iw_d.h b/drivers/infiniband/hw/i40iw/i40iw_d.h index a39ac12b6a7e..2ebaadbed379 100644 --- a/drivers/infiniband/hw/i40iw/i40iw_d.h +++ b/drivers/infiniband/hw/i40iw/i40iw_d.h | |||
@@ -1507,8 +1507,8 @@ enum { | |||
1507 | I40IW_CQ0_ALIGNMENT_MASK = (256 - 1), | 1507 | I40IW_CQ0_ALIGNMENT_MASK = (256 - 1), |
1508 | I40IW_HOST_CTX_ALIGNMENT_MASK = (4 - 1), | 1508 | I40IW_HOST_CTX_ALIGNMENT_MASK = (4 - 1), |
1509 | I40IW_SHADOWAREA_MASK = (128 - 1), | 1509 | I40IW_SHADOWAREA_MASK = (128 - 1), |
1510 | I40IW_FPM_QUERY_BUF_ALIGNMENT_MASK = 0, | 1510 | I40IW_FPM_QUERY_BUF_ALIGNMENT_MASK = (4 - 1), |
1511 | I40IW_FPM_COMMIT_BUF_ALIGNMENT_MASK = 0 | 1511 | I40IW_FPM_COMMIT_BUF_ALIGNMENT_MASK = (4 - 1) |
1512 | }; | 1512 | }; |
1513 | 1513 | ||
1514 | enum i40iw_alignment { | 1514 | enum i40iw_alignment { |
diff --git a/drivers/infiniband/hw/i40iw/i40iw_puda.c b/drivers/infiniband/hw/i40iw/i40iw_puda.c index 71050c5d29a0..7f5583d83622 100644 --- a/drivers/infiniband/hw/i40iw/i40iw_puda.c +++ b/drivers/infiniband/hw/i40iw/i40iw_puda.c | |||
@@ -685,7 +685,7 @@ static enum i40iw_status_code i40iw_puda_cq_create(struct i40iw_puda_rsrc *rsrc) | |||
685 | cqsize = rsrc->cq_size * (sizeof(struct i40iw_cqe)); | 685 | cqsize = rsrc->cq_size * (sizeof(struct i40iw_cqe)); |
686 | tsize = cqsize + sizeof(struct i40iw_cq_shadow_area); | 686 | tsize = cqsize + sizeof(struct i40iw_cq_shadow_area); |
687 | ret = i40iw_allocate_dma_mem(dev->hw, &rsrc->cqmem, tsize, | 687 | ret = i40iw_allocate_dma_mem(dev->hw, &rsrc->cqmem, tsize, |
688 | I40IW_CQ0_ALIGNMENT_MASK); | 688 | I40IW_CQ0_ALIGNMENT); |
689 | if (ret) | 689 | if (ret) |
690 | return ret; | 690 | return ret; |
691 | 691 | ||
diff --git a/drivers/infiniband/hw/i40iw/i40iw_status.h b/drivers/infiniband/hw/i40iw/i40iw_status.h index 91c421762f06..f7013f11d808 100644 --- a/drivers/infiniband/hw/i40iw/i40iw_status.h +++ b/drivers/infiniband/hw/i40iw/i40iw_status.h | |||
@@ -62,7 +62,7 @@ enum i40iw_status_code { | |||
62 | I40IW_ERR_INVALID_ALIGNMENT = -23, | 62 | I40IW_ERR_INVALID_ALIGNMENT = -23, |
63 | I40IW_ERR_FLUSHED_QUEUE = -24, | 63 | I40IW_ERR_FLUSHED_QUEUE = -24, |
64 | I40IW_ERR_INVALID_PUSH_PAGE_INDEX = -25, | 64 | I40IW_ERR_INVALID_PUSH_PAGE_INDEX = -25, |
65 | I40IW_ERR_INVALID_IMM_DATA_SIZE = -26, | 65 | I40IW_ERR_INVALID_INLINE_DATA_SIZE = -26, |
66 | I40IW_ERR_TIMEOUT = -27, | 66 | I40IW_ERR_TIMEOUT = -27, |
67 | I40IW_ERR_OPCODE_MISMATCH = -28, | 67 | I40IW_ERR_OPCODE_MISMATCH = -28, |
68 | I40IW_ERR_CQP_COMPL_ERROR = -29, | 68 | I40IW_ERR_CQP_COMPL_ERROR = -29, |
diff --git a/drivers/infiniband/hw/i40iw/i40iw_uk.c b/drivers/infiniband/hw/i40iw/i40iw_uk.c index b0d3a0e8a9b5..1060725d18bc 100644 --- a/drivers/infiniband/hw/i40iw/i40iw_uk.c +++ b/drivers/infiniband/hw/i40iw/i40iw_uk.c | |||
@@ -435,7 +435,7 @@ static enum i40iw_status_code i40iw_inline_rdma_write(struct i40iw_qp_uk *qp, | |||
435 | 435 | ||
436 | op_info = &info->op.inline_rdma_write; | 436 | op_info = &info->op.inline_rdma_write; |
437 | if (op_info->len > I40IW_MAX_INLINE_DATA_SIZE) | 437 | if (op_info->len > I40IW_MAX_INLINE_DATA_SIZE) |
438 | return I40IW_ERR_INVALID_IMM_DATA_SIZE; | 438 | return I40IW_ERR_INVALID_INLINE_DATA_SIZE; |
439 | 439 | ||
440 | ret_code = i40iw_inline_data_size_to_wqesize(op_info->len, &wqe_size); | 440 | ret_code = i40iw_inline_data_size_to_wqesize(op_info->len, &wqe_size); |
441 | if (ret_code) | 441 | if (ret_code) |
@@ -511,7 +511,7 @@ static enum i40iw_status_code i40iw_inline_send(struct i40iw_qp_uk *qp, | |||
511 | 511 | ||
512 | op_info = &info->op.inline_send; | 512 | op_info = &info->op.inline_send; |
513 | if (op_info->len > I40IW_MAX_INLINE_DATA_SIZE) | 513 | if (op_info->len > I40IW_MAX_INLINE_DATA_SIZE) |
514 | return I40IW_ERR_INVALID_IMM_DATA_SIZE; | 514 | return I40IW_ERR_INVALID_INLINE_DATA_SIZE; |
515 | 515 | ||
516 | ret_code = i40iw_inline_data_size_to_wqesize(op_info->len, &wqe_size); | 516 | ret_code = i40iw_inline_data_size_to_wqesize(op_info->len, &wqe_size); |
517 | if (ret_code) | 517 | if (ret_code) |
@@ -784,7 +784,7 @@ static enum i40iw_status_code i40iw_cq_poll_completion(struct i40iw_cq_uk *cq, | |||
784 | get_64bit_val(cqe, 0, &qword0); | 784 | get_64bit_val(cqe, 0, &qword0); |
785 | get_64bit_val(cqe, 16, &qword2); | 785 | get_64bit_val(cqe, 16, &qword2); |
786 | 786 | ||
787 | info->tcp_seq_num = (u8)RS_64(qword0, I40IWCQ_TCPSEQNUM); | 787 | info->tcp_seq_num = (u32)RS_64(qword0, I40IWCQ_TCPSEQNUM); |
788 | 788 | ||
789 | info->qp_id = (u32)RS_64(qword2, I40IWCQ_QPID); | 789 | info->qp_id = (u32)RS_64(qword2, I40IWCQ_QPID); |
790 | 790 | ||
@@ -1187,7 +1187,7 @@ enum i40iw_status_code i40iw_inline_data_size_to_wqesize(u32 data_size, | |||
1187 | u8 *wqe_size) | 1187 | u8 *wqe_size) |
1188 | { | 1188 | { |
1189 | if (data_size > I40IW_MAX_INLINE_DATA_SIZE) | 1189 | if (data_size > I40IW_MAX_INLINE_DATA_SIZE) |
1190 | return I40IW_ERR_INVALID_IMM_DATA_SIZE; | 1190 | return I40IW_ERR_INVALID_INLINE_DATA_SIZE; |
1191 | 1191 | ||
1192 | if (data_size <= 16) | 1192 | if (data_size <= 16) |
1193 | *wqe_size = I40IW_QP_WQE_MIN_SIZE; | 1193 | *wqe_size = I40IW_QP_WQE_MIN_SIZE; |
diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c index a7f2e60085c4..f7fcde1ff0aa 100644 --- a/drivers/infiniband/hw/mlx5/main.c +++ b/drivers/infiniband/hw/mlx5/main.c | |||
@@ -1085,6 +1085,12 @@ static int mlx5_ib_modify_port(struct ib_device *ibdev, u8 port, int mask, | |||
1085 | bool is_ib = (mlx5_ib_port_link_layer(ibdev, port) == | 1085 | bool is_ib = (mlx5_ib_port_link_layer(ibdev, port) == |
1086 | IB_LINK_LAYER_INFINIBAND); | 1086 | IB_LINK_LAYER_INFINIBAND); |
1087 | 1087 | ||
1088 | /* CM layer calls ib_modify_port() regardless of the link layer. For | ||
1089 | * Ethernet ports, qkey violation and Port capabilities are meaningless. | ||
1090 | */ | ||
1091 | if (!is_ib) | ||
1092 | return 0; | ||
1093 | |||
1088 | if (MLX5_CAP_GEN(dev->mdev, ib_virt) && is_ib) { | 1094 | if (MLX5_CAP_GEN(dev->mdev, ib_virt) && is_ib) { |
1089 | change_mask = props->clr_port_cap_mask | props->set_port_cap_mask; | 1095 | change_mask = props->clr_port_cap_mask | props->set_port_cap_mask; |
1090 | value = ~props->clr_port_cap_mask | props->set_port_cap_mask; | 1096 | value = ~props->clr_port_cap_mask | props->set_port_cap_mask; |
diff --git a/drivers/infiniband/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c index 0889ff367c86..f58f8f5f3ebe 100644 --- a/drivers/infiniband/hw/mlx5/qp.c +++ b/drivers/infiniband/hw/mlx5/qp.c | |||
@@ -1238,6 +1238,7 @@ static int create_raw_packet_qp(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp, | |||
1238 | goto err_destroy_tis; | 1238 | goto err_destroy_tis; |
1239 | 1239 | ||
1240 | sq->base.container_mibqp = qp; | 1240 | sq->base.container_mibqp = qp; |
1241 | sq->base.mqp.event = mlx5_ib_qp_event; | ||
1241 | } | 1242 | } |
1242 | 1243 | ||
1243 | if (qp->rq.wqe_cnt) { | 1244 | if (qp->rq.wqe_cnt) { |
diff --git a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_cq.c b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_cq.c index 69bda611d313..90aa326fd7c0 100644 --- a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_cq.c +++ b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_cq.c | |||
@@ -65,13 +65,28 @@ int pvrdma_req_notify_cq(struct ib_cq *ibcq, | |||
65 | struct pvrdma_dev *dev = to_vdev(ibcq->device); | 65 | struct pvrdma_dev *dev = to_vdev(ibcq->device); |
66 | struct pvrdma_cq *cq = to_vcq(ibcq); | 66 | struct pvrdma_cq *cq = to_vcq(ibcq); |
67 | u32 val = cq->cq_handle; | 67 | u32 val = cq->cq_handle; |
68 | unsigned long flags; | ||
69 | int has_data = 0; | ||
68 | 70 | ||
69 | val |= (notify_flags & IB_CQ_SOLICITED_MASK) == IB_CQ_SOLICITED ? | 71 | val |= (notify_flags & IB_CQ_SOLICITED_MASK) == IB_CQ_SOLICITED ? |
70 | PVRDMA_UAR_CQ_ARM_SOL : PVRDMA_UAR_CQ_ARM; | 72 | PVRDMA_UAR_CQ_ARM_SOL : PVRDMA_UAR_CQ_ARM; |
71 | 73 | ||
74 | spin_lock_irqsave(&cq->cq_lock, flags); | ||
75 | |||
72 | pvrdma_write_uar_cq(dev, val); | 76 | pvrdma_write_uar_cq(dev, val); |
73 | 77 | ||
74 | return 0; | 78 | if (notify_flags & IB_CQ_REPORT_MISSED_EVENTS) { |
79 | unsigned int head; | ||
80 | |||
81 | has_data = pvrdma_idx_ring_has_data(&cq->ring_state->rx, | ||
82 | cq->ibcq.cqe, &head); | ||
83 | if (unlikely(has_data == PVRDMA_INVALID_IDX)) | ||
84 | dev_err(&dev->pdev->dev, "CQ ring state invalid\n"); | ||
85 | } | ||
86 | |||
87 | spin_unlock_irqrestore(&cq->cq_lock, flags); | ||
88 | |||
89 | return has_data; | ||
75 | } | 90 | } |
76 | 91 | ||
77 | /** | 92 | /** |
diff --git a/drivers/input/mouse/elan_i2c_core.c b/drivers/input/mouse/elan_i2c_core.c index 3b616cb7c67f..714cf7f9b138 100644 --- a/drivers/input/mouse/elan_i2c_core.c +++ b/drivers/input/mouse/elan_i2c_core.c | |||
@@ -1248,6 +1248,10 @@ static const struct acpi_device_id elan_acpi_id[] = { | |||
1248 | { "ELAN0100", 0 }, | 1248 | { "ELAN0100", 0 }, |
1249 | { "ELAN0600", 0 }, | 1249 | { "ELAN0600", 0 }, |
1250 | { "ELAN0605", 0 }, | 1250 | { "ELAN0605", 0 }, |
1251 | { "ELAN0608", 0 }, | ||
1252 | { "ELAN0605", 0 }, | ||
1253 | { "ELAN0609", 0 }, | ||
1254 | { "ELAN060B", 0 }, | ||
1251 | { "ELAN1000", 0 }, | 1255 | { "ELAN1000", 0 }, |
1252 | { } | 1256 | { } |
1253 | }; | 1257 | }; |
diff --git a/drivers/input/mouse/trackpoint.c b/drivers/input/mouse/trackpoint.c index 922ea02edcc3..20b5b21c1bba 100644 --- a/drivers/input/mouse/trackpoint.c +++ b/drivers/input/mouse/trackpoint.c | |||
@@ -380,8 +380,8 @@ int trackpoint_detect(struct psmouse *psmouse, bool set_properties) | |||
380 | return 0; | 380 | return 0; |
381 | 381 | ||
382 | if (trackpoint_read(ps2dev, TP_EXT_BTN, &button_info)) { | 382 | if (trackpoint_read(ps2dev, TP_EXT_BTN, &button_info)) { |
383 | psmouse_warn(psmouse, "failed to get extended button data\n"); | 383 | psmouse_warn(psmouse, "failed to get extended button data, assuming 3 buttons\n"); |
384 | button_info = 0; | 384 | button_info = 0x33; |
385 | } | 385 | } |
386 | 386 | ||
387 | psmouse->private = kzalloc(sizeof(struct trackpoint_data), GFP_KERNEL); | 387 | psmouse->private = kzalloc(sizeof(struct trackpoint_data), GFP_KERNEL); |
diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c index 354cbd6392cd..4ad7e5e31943 100644 --- a/drivers/iommu/amd_iommu.c +++ b/drivers/iommu/amd_iommu.c | |||
@@ -575,7 +575,7 @@ static void dump_dte_entry(u16 devid) | |||
575 | 575 | ||
576 | static void dump_command(unsigned long phys_addr) | 576 | static void dump_command(unsigned long phys_addr) |
577 | { | 577 | { |
578 | struct iommu_cmd *cmd = phys_to_virt(phys_addr); | 578 | struct iommu_cmd *cmd = iommu_phys_to_virt(phys_addr); |
579 | int i; | 579 | int i; |
580 | 580 | ||
581 | for (i = 0; i < 4; ++i) | 581 | for (i = 0; i < 4; ++i) |
@@ -919,11 +919,13 @@ static void copy_cmd_to_buffer(struct amd_iommu *iommu, | |||
919 | 919 | ||
920 | static void build_completion_wait(struct iommu_cmd *cmd, u64 address) | 920 | static void build_completion_wait(struct iommu_cmd *cmd, u64 address) |
921 | { | 921 | { |
922 | u64 paddr = iommu_virt_to_phys((void *)address); | ||
923 | |||
922 | WARN_ON(address & 0x7ULL); | 924 | WARN_ON(address & 0x7ULL); |
923 | 925 | ||
924 | memset(cmd, 0, sizeof(*cmd)); | 926 | memset(cmd, 0, sizeof(*cmd)); |
925 | cmd->data[0] = lower_32_bits(__pa(address)) | CMD_COMPL_WAIT_STORE_MASK; | 927 | cmd->data[0] = lower_32_bits(paddr) | CMD_COMPL_WAIT_STORE_MASK; |
926 | cmd->data[1] = upper_32_bits(__pa(address)); | 928 | cmd->data[1] = upper_32_bits(paddr); |
927 | cmd->data[2] = 1; | 929 | cmd->data[2] = 1; |
928 | CMD_SET_TYPE(cmd, CMD_COMPL_WAIT); | 930 | CMD_SET_TYPE(cmd, CMD_COMPL_WAIT); |
929 | } | 931 | } |
@@ -1383,7 +1385,7 @@ static bool increase_address_space(struct protection_domain *domain, | |||
1383 | return false; | 1385 | return false; |
1384 | 1386 | ||
1385 | *pte = PM_LEVEL_PDE(domain->mode, | 1387 | *pte = PM_LEVEL_PDE(domain->mode, |
1386 | virt_to_phys(domain->pt_root)); | 1388 | iommu_virt_to_phys(domain->pt_root)); |
1387 | domain->pt_root = pte; | 1389 | domain->pt_root = pte; |
1388 | domain->mode += 1; | 1390 | domain->mode += 1; |
1389 | domain->updated = true; | 1391 | domain->updated = true; |
@@ -1420,7 +1422,7 @@ static u64 *alloc_pte(struct protection_domain *domain, | |||
1420 | if (!page) | 1422 | if (!page) |
1421 | return NULL; | 1423 | return NULL; |
1422 | 1424 | ||
1423 | __npte = PM_LEVEL_PDE(level, virt_to_phys(page)); | 1425 | __npte = PM_LEVEL_PDE(level, iommu_virt_to_phys(page)); |
1424 | 1426 | ||
1425 | /* pte could have been changed somewhere. */ | 1427 | /* pte could have been changed somewhere. */ |
1426 | if (cmpxchg64(pte, __pte, __npte) != __pte) { | 1428 | if (cmpxchg64(pte, __pte, __npte) != __pte) { |
@@ -1536,10 +1538,10 @@ static int iommu_map_page(struct protection_domain *dom, | |||
1536 | return -EBUSY; | 1538 | return -EBUSY; |
1537 | 1539 | ||
1538 | if (count > 1) { | 1540 | if (count > 1) { |
1539 | __pte = PAGE_SIZE_PTE(phys_addr, page_size); | 1541 | __pte = PAGE_SIZE_PTE(__sme_set(phys_addr), page_size); |
1540 | __pte |= PM_LEVEL_ENC(7) | IOMMU_PTE_P | IOMMU_PTE_FC; | 1542 | __pte |= PM_LEVEL_ENC(7) | IOMMU_PTE_P | IOMMU_PTE_FC; |
1541 | } else | 1543 | } else |
1542 | __pte = phys_addr | IOMMU_PTE_P | IOMMU_PTE_FC; | 1544 | __pte = __sme_set(phys_addr) | IOMMU_PTE_P | IOMMU_PTE_FC; |
1543 | 1545 | ||
1544 | if (prot & IOMMU_PROT_IR) | 1546 | if (prot & IOMMU_PROT_IR) |
1545 | __pte |= IOMMU_PTE_IR; | 1547 | __pte |= IOMMU_PTE_IR; |
@@ -1755,7 +1757,7 @@ static void free_gcr3_tbl_level1(u64 *tbl) | |||
1755 | if (!(tbl[i] & GCR3_VALID)) | 1757 | if (!(tbl[i] & GCR3_VALID)) |
1756 | continue; | 1758 | continue; |
1757 | 1759 | ||
1758 | ptr = __va(tbl[i] & PAGE_MASK); | 1760 | ptr = iommu_phys_to_virt(tbl[i] & PAGE_MASK); |
1759 | 1761 | ||
1760 | free_page((unsigned long)ptr); | 1762 | free_page((unsigned long)ptr); |
1761 | } | 1763 | } |
@@ -1770,7 +1772,7 @@ static void free_gcr3_tbl_level2(u64 *tbl) | |||
1770 | if (!(tbl[i] & GCR3_VALID)) | 1772 | if (!(tbl[i] & GCR3_VALID)) |
1771 | continue; | 1773 | continue; |
1772 | 1774 | ||
1773 | ptr = __va(tbl[i] & PAGE_MASK); | 1775 | ptr = iommu_phys_to_virt(tbl[i] & PAGE_MASK); |
1774 | 1776 | ||
1775 | free_gcr3_tbl_level1(ptr); | 1777 | free_gcr3_tbl_level1(ptr); |
1776 | } | 1778 | } |
@@ -2049,7 +2051,7 @@ static void set_dte_entry(u16 devid, struct protection_domain *domain, bool ats) | |||
2049 | u64 flags = 0; | 2051 | u64 flags = 0; |
2050 | 2052 | ||
2051 | if (domain->mode != PAGE_MODE_NONE) | 2053 | if (domain->mode != PAGE_MODE_NONE) |
2052 | pte_root = virt_to_phys(domain->pt_root); | 2054 | pte_root = iommu_virt_to_phys(domain->pt_root); |
2053 | 2055 | ||
2054 | pte_root |= (domain->mode & DEV_ENTRY_MODE_MASK) | 2056 | pte_root |= (domain->mode & DEV_ENTRY_MODE_MASK) |
2055 | << DEV_ENTRY_MODE_SHIFT; | 2057 | << DEV_ENTRY_MODE_SHIFT; |
@@ -2061,7 +2063,7 @@ static void set_dte_entry(u16 devid, struct protection_domain *domain, bool ats) | |||
2061 | flags |= DTE_FLAG_IOTLB; | 2063 | flags |= DTE_FLAG_IOTLB; |
2062 | 2064 | ||
2063 | if (domain->flags & PD_IOMMUV2_MASK) { | 2065 | if (domain->flags & PD_IOMMUV2_MASK) { |
2064 | u64 gcr3 = __pa(domain->gcr3_tbl); | 2066 | u64 gcr3 = iommu_virt_to_phys(domain->gcr3_tbl); |
2065 | u64 glx = domain->glx; | 2067 | u64 glx = domain->glx; |
2066 | u64 tmp; | 2068 | u64 tmp; |
2067 | 2069 | ||
@@ -3606,10 +3608,10 @@ static u64 *__get_gcr3_pte(u64 *root, int level, int pasid, bool alloc) | |||
3606 | if (root == NULL) | 3608 | if (root == NULL) |
3607 | return NULL; | 3609 | return NULL; |
3608 | 3610 | ||
3609 | *pte = __pa(root) | GCR3_VALID; | 3611 | *pte = iommu_virt_to_phys(root) | GCR3_VALID; |
3610 | } | 3612 | } |
3611 | 3613 | ||
3612 | root = __va(*pte & PAGE_MASK); | 3614 | root = iommu_phys_to_virt(*pte & PAGE_MASK); |
3613 | 3615 | ||
3614 | level -= 1; | 3616 | level -= 1; |
3615 | } | 3617 | } |
@@ -3788,7 +3790,7 @@ static void set_dte_irq_entry(u16 devid, struct irq_remap_table *table) | |||
3788 | 3790 | ||
3789 | dte = amd_iommu_dev_table[devid].data[2]; | 3791 | dte = amd_iommu_dev_table[devid].data[2]; |
3790 | dte &= ~DTE_IRQ_PHYS_ADDR_MASK; | 3792 | dte &= ~DTE_IRQ_PHYS_ADDR_MASK; |
3791 | dte |= virt_to_phys(table->table); | 3793 | dte |= iommu_virt_to_phys(table->table); |
3792 | dte |= DTE_IRQ_REMAP_INTCTL; | 3794 | dte |= DTE_IRQ_REMAP_INTCTL; |
3793 | dte |= DTE_IRQ_TABLE_LEN; | 3795 | dte |= DTE_IRQ_TABLE_LEN; |
3794 | dte |= DTE_IRQ_REMAP_ENABLE; | 3796 | dte |= DTE_IRQ_REMAP_ENABLE; |
diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c index 372303700566..2292a6cece76 100644 --- a/drivers/iommu/amd_iommu_init.c +++ b/drivers/iommu/amd_iommu_init.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include <linux/iommu.h> | 30 | #include <linux/iommu.h> |
31 | #include <linux/kmemleak.h> | 31 | #include <linux/kmemleak.h> |
32 | #include <linux/crash_dump.h> | 32 | #include <linux/crash_dump.h> |
33 | #include <linux/mem_encrypt.h> | ||
33 | #include <asm/pci-direct.h> | 34 | #include <asm/pci-direct.h> |
34 | #include <asm/iommu.h> | 35 | #include <asm/iommu.h> |
35 | #include <asm/gart.h> | 36 | #include <asm/gart.h> |
@@ -348,7 +349,7 @@ static void iommu_set_device_table(struct amd_iommu *iommu) | |||
348 | 349 | ||
349 | BUG_ON(iommu->mmio_base == NULL); | 350 | BUG_ON(iommu->mmio_base == NULL); |
350 | 351 | ||
351 | entry = virt_to_phys(amd_iommu_dev_table); | 352 | entry = iommu_virt_to_phys(amd_iommu_dev_table); |
352 | entry |= (dev_table_size >> 12) - 1; | 353 | entry |= (dev_table_size >> 12) - 1; |
353 | memcpy_toio(iommu->mmio_base + MMIO_DEV_TABLE_OFFSET, | 354 | memcpy_toio(iommu->mmio_base + MMIO_DEV_TABLE_OFFSET, |
354 | &entry, sizeof(entry)); | 355 | &entry, sizeof(entry)); |
@@ -606,7 +607,7 @@ static void iommu_enable_command_buffer(struct amd_iommu *iommu) | |||
606 | 607 | ||
607 | BUG_ON(iommu->cmd_buf == NULL); | 608 | BUG_ON(iommu->cmd_buf == NULL); |
608 | 609 | ||
609 | entry = (u64)virt_to_phys(iommu->cmd_buf); | 610 | entry = iommu_virt_to_phys(iommu->cmd_buf); |
610 | entry |= MMIO_CMD_SIZE_512; | 611 | entry |= MMIO_CMD_SIZE_512; |
611 | 612 | ||
612 | memcpy_toio(iommu->mmio_base + MMIO_CMD_BUF_OFFSET, | 613 | memcpy_toio(iommu->mmio_base + MMIO_CMD_BUF_OFFSET, |
@@ -635,7 +636,7 @@ static void iommu_enable_event_buffer(struct amd_iommu *iommu) | |||
635 | 636 | ||
636 | BUG_ON(iommu->evt_buf == NULL); | 637 | BUG_ON(iommu->evt_buf == NULL); |
637 | 638 | ||
638 | entry = (u64)virt_to_phys(iommu->evt_buf) | EVT_LEN_MASK; | 639 | entry = iommu_virt_to_phys(iommu->evt_buf) | EVT_LEN_MASK; |
639 | 640 | ||
640 | memcpy_toio(iommu->mmio_base + MMIO_EVT_BUF_OFFSET, | 641 | memcpy_toio(iommu->mmio_base + MMIO_EVT_BUF_OFFSET, |
641 | &entry, sizeof(entry)); | 642 | &entry, sizeof(entry)); |
@@ -668,7 +669,7 @@ static void iommu_enable_ppr_log(struct amd_iommu *iommu) | |||
668 | if (iommu->ppr_log == NULL) | 669 | if (iommu->ppr_log == NULL) |
669 | return; | 670 | return; |
670 | 671 | ||
671 | entry = (u64)virt_to_phys(iommu->ppr_log) | PPR_LOG_SIZE_512; | 672 | entry = iommu_virt_to_phys(iommu->ppr_log) | PPR_LOG_SIZE_512; |
672 | 673 | ||
673 | memcpy_toio(iommu->mmio_base + MMIO_PPR_LOG_OFFSET, | 674 | memcpy_toio(iommu->mmio_base + MMIO_PPR_LOG_OFFSET, |
674 | &entry, sizeof(entry)); | 675 | &entry, sizeof(entry)); |
@@ -748,10 +749,10 @@ static int iommu_init_ga_log(struct amd_iommu *iommu) | |||
748 | if (!iommu->ga_log_tail) | 749 | if (!iommu->ga_log_tail) |
749 | goto err_out; | 750 | goto err_out; |
750 | 751 | ||
751 | entry = (u64)virt_to_phys(iommu->ga_log) | GA_LOG_SIZE_512; | 752 | entry = iommu_virt_to_phys(iommu->ga_log) | GA_LOG_SIZE_512; |
752 | memcpy_toio(iommu->mmio_base + MMIO_GA_LOG_BASE_OFFSET, | 753 | memcpy_toio(iommu->mmio_base + MMIO_GA_LOG_BASE_OFFSET, |
753 | &entry, sizeof(entry)); | 754 | &entry, sizeof(entry)); |
754 | entry = ((u64)virt_to_phys(iommu->ga_log) & 0xFFFFFFFFFFFFFULL) & ~7ULL; | 755 | entry = (iommu_virt_to_phys(iommu->ga_log) & 0xFFFFFFFFFFFFFULL) & ~7ULL; |
755 | memcpy_toio(iommu->mmio_base + MMIO_GA_LOG_TAIL_OFFSET, | 756 | memcpy_toio(iommu->mmio_base + MMIO_GA_LOG_TAIL_OFFSET, |
756 | &entry, sizeof(entry)); | 757 | &entry, sizeof(entry)); |
757 | writel(0x00, iommu->mmio_base + MMIO_GA_HEAD_OFFSET); | 758 | writel(0x00, iommu->mmio_base + MMIO_GA_HEAD_OFFSET); |
@@ -2564,6 +2565,24 @@ static int __init amd_iommu_init(void) | |||
2564 | return ret; | 2565 | return ret; |
2565 | } | 2566 | } |
2566 | 2567 | ||
2568 | static bool amd_iommu_sme_check(void) | ||
2569 | { | ||
2570 | if (!sme_active() || (boot_cpu_data.x86 != 0x17)) | ||
2571 | return true; | ||
2572 | |||
2573 | /* For Fam17h, a specific level of support is required */ | ||
2574 | if (boot_cpu_data.microcode >= 0x08001205) | ||
2575 | return true; | ||
2576 | |||
2577 | if ((boot_cpu_data.microcode >= 0x08001126) && | ||
2578 | (boot_cpu_data.microcode <= 0x080011ff)) | ||
2579 | return true; | ||
2580 | |||
2581 | pr_notice("AMD-Vi: IOMMU not currently supported when SME is active\n"); | ||
2582 | |||
2583 | return false; | ||
2584 | } | ||
2585 | |||
2567 | /**************************************************************************** | 2586 | /**************************************************************************** |
2568 | * | 2587 | * |
2569 | * Early detect code. This code runs at IOMMU detection time in the DMA | 2588 | * Early detect code. This code runs at IOMMU detection time in the DMA |
@@ -2578,6 +2597,9 @@ int __init amd_iommu_detect(void) | |||
2578 | if (no_iommu || (iommu_detected && !gart_iommu_aperture)) | 2597 | if (no_iommu || (iommu_detected && !gart_iommu_aperture)) |
2579 | return -ENODEV; | 2598 | return -ENODEV; |
2580 | 2599 | ||
2600 | if (!amd_iommu_sme_check()) | ||
2601 | return -ENODEV; | ||
2602 | |||
2581 | ret = iommu_go_to_state(IOMMU_IVRS_DETECTED); | 2603 | ret = iommu_go_to_state(IOMMU_IVRS_DETECTED); |
2582 | if (ret) | 2604 | if (ret) |
2583 | return ret; | 2605 | return ret; |
diff --git a/drivers/iommu/amd_iommu_proto.h b/drivers/iommu/amd_iommu_proto.h index 466260f8a1df..3f12fb2338ea 100644 --- a/drivers/iommu/amd_iommu_proto.h +++ b/drivers/iommu/amd_iommu_proto.h | |||
@@ -87,4 +87,14 @@ static inline bool iommu_feature(struct amd_iommu *iommu, u64 f) | |||
87 | return !!(iommu->features & f); | 87 | return !!(iommu->features & f); |
88 | } | 88 | } |
89 | 89 | ||
90 | static inline u64 iommu_virt_to_phys(void *vaddr) | ||
91 | { | ||
92 | return (u64)__sme_set(virt_to_phys(vaddr)); | ||
93 | } | ||
94 | |||
95 | static inline void *iommu_phys_to_virt(unsigned long paddr) | ||
96 | { | ||
97 | return phys_to_virt(__sme_clr(paddr)); | ||
98 | } | ||
99 | |||
90 | #endif /* _ASM_X86_AMD_IOMMU_PROTO_H */ | 100 | #endif /* _ASM_X86_AMD_IOMMU_PROTO_H */ |
diff --git a/drivers/iommu/amd_iommu_types.h b/drivers/iommu/amd_iommu_types.h index 294a409e283b..8591f43c467c 100644 --- a/drivers/iommu/amd_iommu_types.h +++ b/drivers/iommu/amd_iommu_types.h | |||
@@ -344,7 +344,7 @@ | |||
344 | 344 | ||
345 | #define IOMMU_PAGE_MASK (((1ULL << 52) - 1) & ~0xfffULL) | 345 | #define IOMMU_PAGE_MASK (((1ULL << 52) - 1) & ~0xfffULL) |
346 | #define IOMMU_PTE_PRESENT(pte) ((pte) & IOMMU_PTE_P) | 346 | #define IOMMU_PTE_PRESENT(pte) ((pte) & IOMMU_PTE_P) |
347 | #define IOMMU_PTE_PAGE(pte) (phys_to_virt((pte) & IOMMU_PAGE_MASK)) | 347 | #define IOMMU_PTE_PAGE(pte) (iommu_phys_to_virt((pte) & IOMMU_PAGE_MASK)) |
348 | #define IOMMU_PTE_MODE(pte) (((pte) >> 9) & 0x07) | 348 | #define IOMMU_PTE_MODE(pte) (((pte) >> 9) & 0x07) |
349 | 349 | ||
350 | #define IOMMU_PROT_MASK 0x03 | 350 | #define IOMMU_PROT_MASK 0x03 |
diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c index b97188acc4f1..2d80fa8a0634 100644 --- a/drivers/iommu/arm-smmu.c +++ b/drivers/iommu/arm-smmu.c | |||
@@ -1519,6 +1519,13 @@ static int arm_smmu_add_device(struct device *dev) | |||
1519 | 1519 | ||
1520 | if (using_legacy_binding) { | 1520 | if (using_legacy_binding) { |
1521 | ret = arm_smmu_register_legacy_master(dev, &smmu); | 1521 | ret = arm_smmu_register_legacy_master(dev, &smmu); |
1522 | |||
1523 | /* | ||
1524 | * If dev->iommu_fwspec is initally NULL, arm_smmu_register_legacy_master() | ||
1525 | * will allocate/initialise a new one. Thus we need to update fwspec for | ||
1526 | * later use. | ||
1527 | */ | ||
1528 | fwspec = dev->iommu_fwspec; | ||
1522 | if (ret) | 1529 | if (ret) |
1523 | goto out_free; | 1530 | goto out_free; |
1524 | } else if (fwspec && fwspec->ops == &arm_smmu_ops) { | 1531 | } else if (fwspec && fwspec->ops == &arm_smmu_ops) { |
diff --git a/drivers/irqchip/irq-atmel-aic-common.c b/drivers/irqchip/irq-atmel-aic-common.c index 28b26c80f4cf..072bd227b6c6 100644 --- a/drivers/irqchip/irq-atmel-aic-common.c +++ b/drivers/irqchip/irq-atmel-aic-common.c | |||
@@ -137,14 +137,14 @@ static void __init aic_common_ext_irq_of_init(struct irq_domain *domain) | |||
137 | #define AT91_RTC_IMR 0x28 | 137 | #define AT91_RTC_IMR 0x28 |
138 | #define AT91_RTC_IRQ_MASK 0x1f | 138 | #define AT91_RTC_IRQ_MASK 0x1f |
139 | 139 | ||
140 | void __init aic_common_rtc_irq_fixup(struct device_node *root) | 140 | void __init aic_common_rtc_irq_fixup(void) |
141 | { | 141 | { |
142 | struct device_node *np; | 142 | struct device_node *np; |
143 | void __iomem *regs; | 143 | void __iomem *regs; |
144 | 144 | ||
145 | np = of_find_compatible_node(root, NULL, "atmel,at91rm9200-rtc"); | 145 | np = of_find_compatible_node(NULL, NULL, "atmel,at91rm9200-rtc"); |
146 | if (!np) | 146 | if (!np) |
147 | np = of_find_compatible_node(root, NULL, | 147 | np = of_find_compatible_node(NULL, NULL, |
148 | "atmel,at91sam9x5-rtc"); | 148 | "atmel,at91sam9x5-rtc"); |
149 | 149 | ||
150 | if (!np) | 150 | if (!np) |
@@ -165,7 +165,7 @@ void __init aic_common_rtc_irq_fixup(struct device_node *root) | |||
165 | #define AT91_RTT_ALMIEN (1 << 16) /* Alarm Interrupt Enable */ | 165 | #define AT91_RTT_ALMIEN (1 << 16) /* Alarm Interrupt Enable */ |
166 | #define AT91_RTT_RTTINCIEN (1 << 17) /* Real Time Timer Increment Interrupt Enable */ | 166 | #define AT91_RTT_RTTINCIEN (1 << 17) /* Real Time Timer Increment Interrupt Enable */ |
167 | 167 | ||
168 | void __init aic_common_rtt_irq_fixup(struct device_node *root) | 168 | void __init aic_common_rtt_irq_fixup(void) |
169 | { | 169 | { |
170 | struct device_node *np; | 170 | struct device_node *np; |
171 | void __iomem *regs; | 171 | void __iomem *regs; |
@@ -196,11 +196,10 @@ static void __init aic_common_irq_fixup(const struct of_device_id *matches) | |||
196 | return; | 196 | return; |
197 | 197 | ||
198 | match = of_match_node(matches, root); | 198 | match = of_match_node(matches, root); |
199 | of_node_put(root); | ||
200 | 199 | ||
201 | if (match) { | 200 | if (match) { |
202 | void (*fixup)(struct device_node *) = match->data; | 201 | void (*fixup)(void) = match->data; |
203 | fixup(root); | 202 | fixup(); |
204 | } | 203 | } |
205 | 204 | ||
206 | of_node_put(root); | 205 | of_node_put(root); |
diff --git a/drivers/irqchip/irq-atmel-aic-common.h b/drivers/irqchip/irq-atmel-aic-common.h index af60376d50de..242e62c1851e 100644 --- a/drivers/irqchip/irq-atmel-aic-common.h +++ b/drivers/irqchip/irq-atmel-aic-common.h | |||
@@ -33,8 +33,8 @@ struct irq_domain *__init aic_common_of_init(struct device_node *node, | |||
33 | const char *name, int nirqs, | 33 | const char *name, int nirqs, |
34 | const struct of_device_id *matches); | 34 | const struct of_device_id *matches); |
35 | 35 | ||
36 | void __init aic_common_rtc_irq_fixup(struct device_node *root); | 36 | void __init aic_common_rtc_irq_fixup(void); |
37 | 37 | ||
38 | void __init aic_common_rtt_irq_fixup(struct device_node *root); | 38 | void __init aic_common_rtt_irq_fixup(void); |
39 | 39 | ||
40 | #endif /* __IRQ_ATMEL_AIC_COMMON_H */ | 40 | #endif /* __IRQ_ATMEL_AIC_COMMON_H */ |
diff --git a/drivers/irqchip/irq-atmel-aic.c b/drivers/irqchip/irq-atmel-aic.c index 37f952dd9fc9..bb1ad451392f 100644 --- a/drivers/irqchip/irq-atmel-aic.c +++ b/drivers/irqchip/irq-atmel-aic.c | |||
@@ -209,20 +209,20 @@ static const struct irq_domain_ops aic_irq_ops = { | |||
209 | .xlate = aic_irq_domain_xlate, | 209 | .xlate = aic_irq_domain_xlate, |
210 | }; | 210 | }; |
211 | 211 | ||
212 | static void __init at91rm9200_aic_irq_fixup(struct device_node *root) | 212 | static void __init at91rm9200_aic_irq_fixup(void) |
213 | { | 213 | { |
214 | aic_common_rtc_irq_fixup(root); | 214 | aic_common_rtc_irq_fixup(); |
215 | } | 215 | } |
216 | 216 | ||
217 | static void __init at91sam9260_aic_irq_fixup(struct device_node *root) | 217 | static void __init at91sam9260_aic_irq_fixup(void) |
218 | { | 218 | { |
219 | aic_common_rtt_irq_fixup(root); | 219 | aic_common_rtt_irq_fixup(); |
220 | } | 220 | } |
221 | 221 | ||
222 | static void __init at91sam9g45_aic_irq_fixup(struct device_node *root) | 222 | static void __init at91sam9g45_aic_irq_fixup(void) |
223 | { | 223 | { |
224 | aic_common_rtc_irq_fixup(root); | 224 | aic_common_rtc_irq_fixup(); |
225 | aic_common_rtt_irq_fixup(root); | 225 | aic_common_rtt_irq_fixup(); |
226 | } | 226 | } |
227 | 227 | ||
228 | static const struct of_device_id aic_irq_fixups[] __initconst = { | 228 | static const struct of_device_id aic_irq_fixups[] __initconst = { |
diff --git a/drivers/irqchip/irq-atmel-aic5.c b/drivers/irqchip/irq-atmel-aic5.c index c04ee9a23d09..6acad2ea0fb3 100644 --- a/drivers/irqchip/irq-atmel-aic5.c +++ b/drivers/irqchip/irq-atmel-aic5.c | |||
@@ -305,9 +305,9 @@ static const struct irq_domain_ops aic5_irq_ops = { | |||
305 | .xlate = aic5_irq_domain_xlate, | 305 | .xlate = aic5_irq_domain_xlate, |
306 | }; | 306 | }; |
307 | 307 | ||
308 | static void __init sama5d3_aic_irq_fixup(struct device_node *root) | 308 | static void __init sama5d3_aic_irq_fixup(void) |
309 | { | 309 | { |
310 | aic_common_rtc_irq_fixup(root); | 310 | aic_common_rtc_irq_fixup(); |
311 | } | 311 | } |
312 | 312 | ||
313 | static const struct of_device_id aic5_irq_fixups[] __initconst = { | 313 | static const struct of_device_id aic5_irq_fixups[] __initconst = { |
diff --git a/drivers/irqchip/irq-brcmstb-l2.c b/drivers/irqchip/irq-brcmstb-l2.c index bddf169c4b37..b009b916a292 100644 --- a/drivers/irqchip/irq-brcmstb-l2.c +++ b/drivers/irqchip/irq-brcmstb-l2.c | |||
@@ -189,6 +189,7 @@ static int __init brcmstb_l2_intc_of_init(struct device_node *np, | |||
189 | 189 | ||
190 | ct->chip.irq_suspend = brcmstb_l2_intc_suspend; | 190 | ct->chip.irq_suspend = brcmstb_l2_intc_suspend; |
191 | ct->chip.irq_resume = brcmstb_l2_intc_resume; | 191 | ct->chip.irq_resume = brcmstb_l2_intc_resume; |
192 | ct->chip.irq_pm_shutdown = brcmstb_l2_intc_suspend; | ||
192 | 193 | ||
193 | if (data->can_wake) { | 194 | if (data->can_wake) { |
194 | /* This IRQ chip can wake the system, set all child interrupts | 195 | /* This IRQ chip can wake the system, set all child interrupts |
diff --git a/drivers/irqchip/irq-gic-v3-its-platform-msi.c b/drivers/irqchip/irq-gic-v3-its-platform-msi.c index 249240d9a425..833a90fe33ae 100644 --- a/drivers/irqchip/irq-gic-v3-its-platform-msi.c +++ b/drivers/irqchip/irq-gic-v3-its-platform-msi.c | |||
@@ -43,6 +43,7 @@ static int of_pmsi_get_dev_id(struct irq_domain *domain, struct device *dev, | |||
43 | *dev_id = args.args[0]; | 43 | *dev_id = args.args[0]; |
44 | break; | 44 | break; |
45 | } | 45 | } |
46 | index++; | ||
46 | } while (!ret); | 47 | } while (!ret); |
47 | 48 | ||
48 | return ret; | 49 | return ret; |
diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index 68932873eebc..284738add89b 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c | |||
@@ -1835,7 +1835,7 @@ static int __init its_of_probe(struct device_node *node) | |||
1835 | 1835 | ||
1836 | #define ACPI_GICV3_ITS_MEM_SIZE (SZ_128K) | 1836 | #define ACPI_GICV3_ITS_MEM_SIZE (SZ_128K) |
1837 | 1837 | ||
1838 | #if defined(CONFIG_ACPI_NUMA) && (ACPI_CA_VERSION >= 0x20170531) | 1838 | #ifdef CONFIG_ACPI_NUMA |
1839 | struct its_srat_map { | 1839 | struct its_srat_map { |
1840 | /* numa node id */ | 1840 | /* numa node id */ |
1841 | u32 numa_node; | 1841 | u32 numa_node; |
@@ -1843,7 +1843,7 @@ struct its_srat_map { | |||
1843 | u32 its_id; | 1843 | u32 its_id; |
1844 | }; | 1844 | }; |
1845 | 1845 | ||
1846 | static struct its_srat_map its_srat_maps[MAX_NUMNODES] __initdata; | 1846 | static struct its_srat_map *its_srat_maps __initdata; |
1847 | static int its_in_srat __initdata; | 1847 | static int its_in_srat __initdata; |
1848 | 1848 | ||
1849 | static int __init acpi_get_its_numa_node(u32 its_id) | 1849 | static int __init acpi_get_its_numa_node(u32 its_id) |
@@ -1857,6 +1857,12 @@ static int __init acpi_get_its_numa_node(u32 its_id) | |||
1857 | return NUMA_NO_NODE; | 1857 | return NUMA_NO_NODE; |
1858 | } | 1858 | } |
1859 | 1859 | ||
1860 | static int __init gic_acpi_match_srat_its(struct acpi_subtable_header *header, | ||
1861 | const unsigned long end) | ||
1862 | { | ||
1863 | return 0; | ||
1864 | } | ||
1865 | |||
1860 | static int __init gic_acpi_parse_srat_its(struct acpi_subtable_header *header, | 1866 | static int __init gic_acpi_parse_srat_its(struct acpi_subtable_header *header, |
1861 | const unsigned long end) | 1867 | const unsigned long end) |
1862 | { | 1868 | { |
@@ -1873,12 +1879,6 @@ static int __init gic_acpi_parse_srat_its(struct acpi_subtable_header *header, | |||
1873 | return -EINVAL; | 1879 | return -EINVAL; |
1874 | } | 1880 | } |
1875 | 1881 | ||
1876 | if (its_in_srat >= MAX_NUMNODES) { | ||
1877 | pr_err("SRAT: ITS affinity exceeding max count[%d]\n", | ||
1878 | MAX_NUMNODES); | ||
1879 | return -EINVAL; | ||
1880 | } | ||
1881 | |||
1882 | node = acpi_map_pxm_to_node(its_affinity->proximity_domain); | 1882 | node = acpi_map_pxm_to_node(its_affinity->proximity_domain); |
1883 | 1883 | ||
1884 | if (node == NUMA_NO_NODE || node >= MAX_NUMNODES) { | 1884 | if (node == NUMA_NO_NODE || node >= MAX_NUMNODES) { |
@@ -1897,14 +1897,37 @@ static int __init gic_acpi_parse_srat_its(struct acpi_subtable_header *header, | |||
1897 | 1897 | ||
1898 | static void __init acpi_table_parse_srat_its(void) | 1898 | static void __init acpi_table_parse_srat_its(void) |
1899 | { | 1899 | { |
1900 | int count; | ||
1901 | |||
1902 | count = acpi_table_parse_entries(ACPI_SIG_SRAT, | ||
1903 | sizeof(struct acpi_table_srat), | ||
1904 | ACPI_SRAT_TYPE_GIC_ITS_AFFINITY, | ||
1905 | gic_acpi_match_srat_its, 0); | ||
1906 | if (count <= 0) | ||
1907 | return; | ||
1908 | |||
1909 | its_srat_maps = kmalloc(count * sizeof(struct its_srat_map), | ||
1910 | GFP_KERNEL); | ||
1911 | if (!its_srat_maps) { | ||
1912 | pr_warn("SRAT: Failed to allocate memory for its_srat_maps!\n"); | ||
1913 | return; | ||
1914 | } | ||
1915 | |||
1900 | acpi_table_parse_entries(ACPI_SIG_SRAT, | 1916 | acpi_table_parse_entries(ACPI_SIG_SRAT, |
1901 | sizeof(struct acpi_table_srat), | 1917 | sizeof(struct acpi_table_srat), |
1902 | ACPI_SRAT_TYPE_GIC_ITS_AFFINITY, | 1918 | ACPI_SRAT_TYPE_GIC_ITS_AFFINITY, |
1903 | gic_acpi_parse_srat_its, 0); | 1919 | gic_acpi_parse_srat_its, 0); |
1904 | } | 1920 | } |
1921 | |||
1922 | /* free the its_srat_maps after ITS probing */ | ||
1923 | static void __init acpi_its_srat_maps_free(void) | ||
1924 | { | ||
1925 | kfree(its_srat_maps); | ||
1926 | } | ||
1905 | #else | 1927 | #else |
1906 | static void __init acpi_table_parse_srat_its(void) { } | 1928 | static void __init acpi_table_parse_srat_its(void) { } |
1907 | static int __init acpi_get_its_numa_node(u32 its_id) { return NUMA_NO_NODE; } | 1929 | static int __init acpi_get_its_numa_node(u32 its_id) { return NUMA_NO_NODE; } |
1930 | static void __init acpi_its_srat_maps_free(void) { } | ||
1908 | #endif | 1931 | #endif |
1909 | 1932 | ||
1910 | static int __init gic_acpi_parse_madt_its(struct acpi_subtable_header *header, | 1933 | static int __init gic_acpi_parse_madt_its(struct acpi_subtable_header *header, |
@@ -1951,6 +1974,7 @@ static void __init its_acpi_probe(void) | |||
1951 | acpi_table_parse_srat_its(); | 1974 | acpi_table_parse_srat_its(); |
1952 | acpi_table_parse_madt(ACPI_MADT_TYPE_GENERIC_TRANSLATOR, | 1975 | acpi_table_parse_madt(ACPI_MADT_TYPE_GENERIC_TRANSLATOR, |
1953 | gic_acpi_parse_madt_its, 0); | 1976 | gic_acpi_parse_madt_its, 0); |
1977 | acpi_its_srat_maps_free(); | ||
1954 | } | 1978 | } |
1955 | #else | 1979 | #else |
1956 | static void __init its_acpi_probe(void) { } | 1980 | static void __init its_acpi_probe(void) { } |
diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c index dbffb7ab6203..984c3ecfd22c 100644 --- a/drivers/irqchip/irq-gic-v3.c +++ b/drivers/irqchip/irq-gic-v3.c | |||
@@ -353,6 +353,8 @@ static asmlinkage void __exception_irq_entry gic_handle_irq(struct pt_regs *regs | |||
353 | 353 | ||
354 | if (static_key_true(&supports_deactivate)) | 354 | if (static_key_true(&supports_deactivate)) |
355 | gic_write_eoir(irqnr); | 355 | gic_write_eoir(irqnr); |
356 | else | ||
357 | isb(); | ||
356 | 358 | ||
357 | err = handle_domain_irq(gic_data.domain, irqnr, regs); | 359 | err = handle_domain_irq(gic_data.domain, irqnr, regs); |
358 | if (err) { | 360 | if (err) { |
@@ -640,11 +642,16 @@ static void gic_smp_init(void) | |||
640 | static int gic_set_affinity(struct irq_data *d, const struct cpumask *mask_val, | 642 | static int gic_set_affinity(struct irq_data *d, const struct cpumask *mask_val, |
641 | bool force) | 643 | bool force) |
642 | { | 644 | { |
643 | unsigned int cpu = cpumask_any_and(mask_val, cpu_online_mask); | 645 | unsigned int cpu; |
644 | void __iomem *reg; | 646 | void __iomem *reg; |
645 | int enabled; | 647 | int enabled; |
646 | u64 val; | 648 | u64 val; |
647 | 649 | ||
650 | if (force) | ||
651 | cpu = cpumask_first(mask_val); | ||
652 | else | ||
653 | cpu = cpumask_any_and(mask_val, cpu_online_mask); | ||
654 | |||
648 | if (cpu >= nr_cpu_ids) | 655 | if (cpu >= nr_cpu_ids) |
649 | return -EINVAL; | 656 | return -EINVAL; |
650 | 657 | ||
@@ -831,8 +838,11 @@ static int gic_irq_domain_alloc(struct irq_domain *domain, unsigned int virq, | |||
831 | if (ret) | 838 | if (ret) |
832 | return ret; | 839 | return ret; |
833 | 840 | ||
834 | for (i = 0; i < nr_irqs; i++) | 841 | for (i = 0; i < nr_irqs; i++) { |
835 | gic_irq_domain_map(domain, virq + i, hwirq + i); | 842 | ret = gic_irq_domain_map(domain, virq + i, hwirq + i); |
843 | if (ret) | ||
844 | return ret; | ||
845 | } | ||
836 | 846 | ||
837 | return 0; | 847 | return 0; |
838 | } | 848 | } |
diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c index 1b1df4f770bd..d3e7c43718b8 100644 --- a/drivers/irqchip/irq-gic.c +++ b/drivers/irqchip/irq-gic.c | |||
@@ -361,6 +361,7 @@ static void __exception_irq_entry gic_handle_irq(struct pt_regs *regs) | |||
361 | if (likely(irqnr > 15 && irqnr < 1020)) { | 361 | if (likely(irqnr > 15 && irqnr < 1020)) { |
362 | if (static_key_true(&supports_deactivate)) | 362 | if (static_key_true(&supports_deactivate)) |
363 | writel_relaxed(irqstat, cpu_base + GIC_CPU_EOI); | 363 | writel_relaxed(irqstat, cpu_base + GIC_CPU_EOI); |
364 | isb(); | ||
364 | handle_domain_irq(gic->domain, irqnr, regs); | 365 | handle_domain_irq(gic->domain, irqnr, regs); |
365 | continue; | 366 | continue; |
366 | } | 367 | } |
@@ -401,10 +402,12 @@ static void gic_handle_cascade_irq(struct irq_desc *desc) | |||
401 | goto out; | 402 | goto out; |
402 | 403 | ||
403 | cascade_irq = irq_find_mapping(chip_data->domain, gic_irq); | 404 | cascade_irq = irq_find_mapping(chip_data->domain, gic_irq); |
404 | if (unlikely(gic_irq < 32 || gic_irq > 1020)) | 405 | if (unlikely(gic_irq < 32 || gic_irq > 1020)) { |
405 | handle_bad_irq(desc); | 406 | handle_bad_irq(desc); |
406 | else | 407 | } else { |
408 | isb(); | ||
407 | generic_handle_irq(cascade_irq); | 409 | generic_handle_irq(cascade_irq); |
410 | } | ||
408 | 411 | ||
409 | out: | 412 | out: |
410 | chained_irq_exit(chip, desc); | 413 | chained_irq_exit(chip, desc); |
@@ -1027,8 +1030,11 @@ static int gic_irq_domain_alloc(struct irq_domain *domain, unsigned int virq, | |||
1027 | if (ret) | 1030 | if (ret) |
1028 | return ret; | 1031 | return ret; |
1029 | 1032 | ||
1030 | for (i = 0; i < nr_irqs; i++) | 1033 | for (i = 0; i < nr_irqs; i++) { |
1031 | gic_irq_domain_map(domain, virq + i, hwirq + i); | 1034 | ret = gic_irq_domain_map(domain, virq + i, hwirq + i); |
1035 | if (ret) | ||
1036 | return ret; | ||
1037 | } | ||
1032 | 1038 | ||
1033 | return 0; | 1039 | return 0; |
1034 | } | 1040 | } |
diff --git a/drivers/isdn/mISDN/fsm.c b/drivers/isdn/mISDN/fsm.c index 78fc5d5e9051..92e6570b1143 100644 --- a/drivers/isdn/mISDN/fsm.c +++ b/drivers/isdn/mISDN/fsm.c | |||
@@ -26,7 +26,7 @@ | |||
26 | 26 | ||
27 | #define FSM_TIMER_DEBUG 0 | 27 | #define FSM_TIMER_DEBUG 0 |
28 | 28 | ||
29 | void | 29 | int |
30 | mISDN_FsmNew(struct Fsm *fsm, | 30 | mISDN_FsmNew(struct Fsm *fsm, |
31 | struct FsmNode *fnlist, int fncount) | 31 | struct FsmNode *fnlist, int fncount) |
32 | { | 32 | { |
@@ -34,6 +34,8 @@ mISDN_FsmNew(struct Fsm *fsm, | |||
34 | 34 | ||
35 | fsm->jumpmatrix = kzalloc(sizeof(FSMFNPTR) * fsm->state_count * | 35 | fsm->jumpmatrix = kzalloc(sizeof(FSMFNPTR) * fsm->state_count * |
36 | fsm->event_count, GFP_KERNEL); | 36 | fsm->event_count, GFP_KERNEL); |
37 | if (fsm->jumpmatrix == NULL) | ||
38 | return -ENOMEM; | ||
37 | 39 | ||
38 | for (i = 0; i < fncount; i++) | 40 | for (i = 0; i < fncount; i++) |
39 | if ((fnlist[i].state >= fsm->state_count) || | 41 | if ((fnlist[i].state >= fsm->state_count) || |
@@ -45,6 +47,7 @@ mISDN_FsmNew(struct Fsm *fsm, | |||
45 | } else | 47 | } else |
46 | fsm->jumpmatrix[fsm->state_count * fnlist[i].event + | 48 | fsm->jumpmatrix[fsm->state_count * fnlist[i].event + |
47 | fnlist[i].state] = (FSMFNPTR) fnlist[i].routine; | 49 | fnlist[i].state] = (FSMFNPTR) fnlist[i].routine; |
50 | return 0; | ||
48 | } | 51 | } |
49 | EXPORT_SYMBOL(mISDN_FsmNew); | 52 | EXPORT_SYMBOL(mISDN_FsmNew); |
50 | 53 | ||
diff --git a/drivers/isdn/mISDN/fsm.h b/drivers/isdn/mISDN/fsm.h index 928f5be192c1..e1def8490221 100644 --- a/drivers/isdn/mISDN/fsm.h +++ b/drivers/isdn/mISDN/fsm.h | |||
@@ -55,7 +55,7 @@ struct FsmTimer { | |||
55 | void *arg; | 55 | void *arg; |
56 | }; | 56 | }; |
57 | 57 | ||
58 | extern void mISDN_FsmNew(struct Fsm *, struct FsmNode *, int); | 58 | extern int mISDN_FsmNew(struct Fsm *, struct FsmNode *, int); |
59 | extern void mISDN_FsmFree(struct Fsm *); | 59 | extern void mISDN_FsmFree(struct Fsm *); |
60 | extern int mISDN_FsmEvent(struct FsmInst *, int , void *); | 60 | extern int mISDN_FsmEvent(struct FsmInst *, int , void *); |
61 | extern void mISDN_FsmChangeState(struct FsmInst *, int); | 61 | extern void mISDN_FsmChangeState(struct FsmInst *, int); |
diff --git a/drivers/isdn/mISDN/layer1.c b/drivers/isdn/mISDN/layer1.c index bebc57b72138..3192b0eb3944 100644 --- a/drivers/isdn/mISDN/layer1.c +++ b/drivers/isdn/mISDN/layer1.c | |||
@@ -414,8 +414,7 @@ l1_init(u_int *deb) | |||
414 | l1fsm_s.event_count = L1_EVENT_COUNT; | 414 | l1fsm_s.event_count = L1_EVENT_COUNT; |
415 | l1fsm_s.strEvent = strL1Event; | 415 | l1fsm_s.strEvent = strL1Event; |
416 | l1fsm_s.strState = strL1SState; | 416 | l1fsm_s.strState = strL1SState; |
417 | mISDN_FsmNew(&l1fsm_s, L1SFnList, ARRAY_SIZE(L1SFnList)); | 417 | return mISDN_FsmNew(&l1fsm_s, L1SFnList, ARRAY_SIZE(L1SFnList)); |
418 | return 0; | ||
419 | } | 418 | } |
420 | 419 | ||
421 | void | 420 | void |
diff --git a/drivers/isdn/mISDN/layer2.c b/drivers/isdn/mISDN/layer2.c index 7243a6746f8b..9ff0903a0e89 100644 --- a/drivers/isdn/mISDN/layer2.c +++ b/drivers/isdn/mISDN/layer2.c | |||
@@ -2247,15 +2247,26 @@ static struct Bprotocol X75SLP = { | |||
2247 | int | 2247 | int |
2248 | Isdnl2_Init(u_int *deb) | 2248 | Isdnl2_Init(u_int *deb) |
2249 | { | 2249 | { |
2250 | int res; | ||
2250 | debug = deb; | 2251 | debug = deb; |
2251 | mISDN_register_Bprotocol(&X75SLP); | 2252 | mISDN_register_Bprotocol(&X75SLP); |
2252 | l2fsm.state_count = L2_STATE_COUNT; | 2253 | l2fsm.state_count = L2_STATE_COUNT; |
2253 | l2fsm.event_count = L2_EVENT_COUNT; | 2254 | l2fsm.event_count = L2_EVENT_COUNT; |
2254 | l2fsm.strEvent = strL2Event; | 2255 | l2fsm.strEvent = strL2Event; |
2255 | l2fsm.strState = strL2State; | 2256 | l2fsm.strState = strL2State; |
2256 | mISDN_FsmNew(&l2fsm, L2FnList, ARRAY_SIZE(L2FnList)); | 2257 | res = mISDN_FsmNew(&l2fsm, L2FnList, ARRAY_SIZE(L2FnList)); |
2257 | TEIInit(deb); | 2258 | if (res) |
2259 | goto error; | ||
2260 | res = TEIInit(deb); | ||
2261 | if (res) | ||
2262 | goto error_fsm; | ||
2258 | return 0; | 2263 | return 0; |
2264 | |||
2265 | error_fsm: | ||
2266 | mISDN_FsmFree(&l2fsm); | ||
2267 | error: | ||
2268 | mISDN_unregister_Bprotocol(&X75SLP); | ||
2269 | return res; | ||
2259 | } | 2270 | } |
2260 | 2271 | ||
2261 | void | 2272 | void |
diff --git a/drivers/isdn/mISDN/tei.c b/drivers/isdn/mISDN/tei.c index 908127efccf8..12d9e5f4beb1 100644 --- a/drivers/isdn/mISDN/tei.c +++ b/drivers/isdn/mISDN/tei.c | |||
@@ -1387,23 +1387,37 @@ create_teimanager(struct mISDNdevice *dev) | |||
1387 | 1387 | ||
1388 | int TEIInit(u_int *deb) | 1388 | int TEIInit(u_int *deb) |
1389 | { | 1389 | { |
1390 | int res; | ||
1390 | debug = deb; | 1391 | debug = deb; |
1391 | teifsmu.state_count = TEI_STATE_COUNT; | 1392 | teifsmu.state_count = TEI_STATE_COUNT; |
1392 | teifsmu.event_count = TEI_EVENT_COUNT; | 1393 | teifsmu.event_count = TEI_EVENT_COUNT; |
1393 | teifsmu.strEvent = strTeiEvent; | 1394 | teifsmu.strEvent = strTeiEvent; |
1394 | teifsmu.strState = strTeiState; | 1395 | teifsmu.strState = strTeiState; |
1395 | mISDN_FsmNew(&teifsmu, TeiFnListUser, ARRAY_SIZE(TeiFnListUser)); | 1396 | res = mISDN_FsmNew(&teifsmu, TeiFnListUser, ARRAY_SIZE(TeiFnListUser)); |
1397 | if (res) | ||
1398 | goto error; | ||
1396 | teifsmn.state_count = TEI_STATE_COUNT; | 1399 | teifsmn.state_count = TEI_STATE_COUNT; |
1397 | teifsmn.event_count = TEI_EVENT_COUNT; | 1400 | teifsmn.event_count = TEI_EVENT_COUNT; |
1398 | teifsmn.strEvent = strTeiEvent; | 1401 | teifsmn.strEvent = strTeiEvent; |
1399 | teifsmn.strState = strTeiState; | 1402 | teifsmn.strState = strTeiState; |
1400 | mISDN_FsmNew(&teifsmn, TeiFnListNet, ARRAY_SIZE(TeiFnListNet)); | 1403 | res = mISDN_FsmNew(&teifsmn, TeiFnListNet, ARRAY_SIZE(TeiFnListNet)); |
1404 | if (res) | ||
1405 | goto error_smn; | ||
1401 | deactfsm.state_count = DEACT_STATE_COUNT; | 1406 | deactfsm.state_count = DEACT_STATE_COUNT; |
1402 | deactfsm.event_count = DEACT_EVENT_COUNT; | 1407 | deactfsm.event_count = DEACT_EVENT_COUNT; |
1403 | deactfsm.strEvent = strDeactEvent; | 1408 | deactfsm.strEvent = strDeactEvent; |
1404 | deactfsm.strState = strDeactState; | 1409 | deactfsm.strState = strDeactState; |
1405 | mISDN_FsmNew(&deactfsm, DeactFnList, ARRAY_SIZE(DeactFnList)); | 1410 | res = mISDN_FsmNew(&deactfsm, DeactFnList, ARRAY_SIZE(DeactFnList)); |
1411 | if (res) | ||
1412 | goto error_deact; | ||
1406 | return 0; | 1413 | return 0; |
1414 | |||
1415 | error_deact: | ||
1416 | mISDN_FsmFree(&teifsmn); | ||
1417 | error_smn: | ||
1418 | mISDN_FsmFree(&teifsmu); | ||
1419 | error: | ||
1420 | return res; | ||
1407 | } | 1421 | } |
1408 | 1422 | ||
1409 | void TEIFree(void) | 1423 | void TEIFree(void) |
diff --git a/drivers/md/md.c b/drivers/md/md.c index c99634612fc4..b01e458d31e9 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c | |||
@@ -7996,7 +7996,7 @@ bool md_write_start(struct mddev *mddev, struct bio *bi) | |||
7996 | if (mddev->safemode == 1) | 7996 | if (mddev->safemode == 1) |
7997 | mddev->safemode = 0; | 7997 | mddev->safemode = 0; |
7998 | /* sync_checkers is always 0 when writes_pending is in per-cpu mode */ | 7998 | /* sync_checkers is always 0 when writes_pending is in per-cpu mode */ |
7999 | if (mddev->in_sync || !mddev->sync_checkers) { | 7999 | if (mddev->in_sync || mddev->sync_checkers) { |
8000 | spin_lock(&mddev->lock); | 8000 | spin_lock(&mddev->lock); |
8001 | if (mddev->in_sync) { | 8001 | if (mddev->in_sync) { |
8002 | mddev->in_sync = 0; | 8002 | mddev->in_sync = 0; |
@@ -8656,6 +8656,9 @@ void md_check_recovery(struct mddev *mddev) | |||
8656 | if (mddev_trylock(mddev)) { | 8656 | if (mddev_trylock(mddev)) { |
8657 | int spares = 0; | 8657 | int spares = 0; |
8658 | 8658 | ||
8659 | if (!mddev->external && mddev->safemode == 1) | ||
8660 | mddev->safemode = 0; | ||
8661 | |||
8659 | if (mddev->ro) { | 8662 | if (mddev->ro) { |
8660 | struct md_rdev *rdev; | 8663 | struct md_rdev *rdev; |
8661 | if (!mddev->external && mddev->in_sync) | 8664 | if (!mddev->external && mddev->in_sync) |
diff --git a/drivers/md/raid5-cache.c b/drivers/md/raid5-cache.c index bfa1e907c472..2dcbafa8e66c 100644 --- a/drivers/md/raid5-cache.c +++ b/drivers/md/raid5-cache.c | |||
@@ -236,9 +236,10 @@ struct r5l_io_unit { | |||
236 | bool need_split_bio; | 236 | bool need_split_bio; |
237 | struct bio *split_bio; | 237 | struct bio *split_bio; |
238 | 238 | ||
239 | unsigned int has_flush:1; /* include flush request */ | 239 | unsigned int has_flush:1; /* include flush request */ |
240 | unsigned int has_fua:1; /* include fua request */ | 240 | unsigned int has_fua:1; /* include fua request */ |
241 | unsigned int has_null_flush:1; /* include empty flush request */ | 241 | unsigned int has_null_flush:1; /* include null flush request */ |
242 | unsigned int has_flush_payload:1; /* include flush payload */ | ||
242 | /* | 243 | /* |
243 | * io isn't sent yet, flush/fua request can only be submitted till it's | 244 | * io isn't sent yet, flush/fua request can only be submitted till it's |
244 | * the first IO in running_ios list | 245 | * the first IO in running_ios list |
@@ -571,6 +572,8 @@ static void r5l_log_endio(struct bio *bio) | |||
571 | struct r5l_io_unit *io_deferred; | 572 | struct r5l_io_unit *io_deferred; |
572 | struct r5l_log *log = io->log; | 573 | struct r5l_log *log = io->log; |
573 | unsigned long flags; | 574 | unsigned long flags; |
575 | bool has_null_flush; | ||
576 | bool has_flush_payload; | ||
574 | 577 | ||
575 | if (bio->bi_status) | 578 | if (bio->bi_status) |
576 | md_error(log->rdev->mddev, log->rdev); | 579 | md_error(log->rdev->mddev, log->rdev); |
@@ -580,6 +583,16 @@ static void r5l_log_endio(struct bio *bio) | |||
580 | 583 | ||
581 | spin_lock_irqsave(&log->io_list_lock, flags); | 584 | spin_lock_irqsave(&log->io_list_lock, flags); |
582 | __r5l_set_io_unit_state(io, IO_UNIT_IO_END); | 585 | __r5l_set_io_unit_state(io, IO_UNIT_IO_END); |
586 | |||
587 | /* | ||
588 | * if the io doesn't not have null_flush or flush payload, | ||
589 | * it is not safe to access it after releasing io_list_lock. | ||
590 | * Therefore, it is necessary to check the condition with | ||
591 | * the lock held. | ||
592 | */ | ||
593 | has_null_flush = io->has_null_flush; | ||
594 | has_flush_payload = io->has_flush_payload; | ||
595 | |||
583 | if (log->need_cache_flush && !list_empty(&io->stripe_list)) | 596 | if (log->need_cache_flush && !list_empty(&io->stripe_list)) |
584 | r5l_move_to_end_ios(log); | 597 | r5l_move_to_end_ios(log); |
585 | else | 598 | else |
@@ -600,19 +613,23 @@ static void r5l_log_endio(struct bio *bio) | |||
600 | if (log->need_cache_flush) | 613 | if (log->need_cache_flush) |
601 | md_wakeup_thread(log->rdev->mddev->thread); | 614 | md_wakeup_thread(log->rdev->mddev->thread); |
602 | 615 | ||
603 | if (io->has_null_flush) { | 616 | /* finish flush only io_unit and PAYLOAD_FLUSH only io_unit */ |
617 | if (has_null_flush) { | ||
604 | struct bio *bi; | 618 | struct bio *bi; |
605 | 619 | ||
606 | WARN_ON(bio_list_empty(&io->flush_barriers)); | 620 | WARN_ON(bio_list_empty(&io->flush_barriers)); |
607 | while ((bi = bio_list_pop(&io->flush_barriers)) != NULL) { | 621 | while ((bi = bio_list_pop(&io->flush_barriers)) != NULL) { |
608 | bio_endio(bi); | 622 | bio_endio(bi); |
609 | atomic_dec(&io->pending_stripe); | 623 | if (atomic_dec_and_test(&io->pending_stripe)) { |
624 | __r5l_stripe_write_finished(io); | ||
625 | return; | ||
626 | } | ||
610 | } | 627 | } |
611 | } | 628 | } |
612 | 629 | /* decrease pending_stripe for flush payload */ | |
613 | /* finish flush only io_unit and PAYLOAD_FLUSH only io_unit */ | 630 | if (has_flush_payload) |
614 | if (atomic_read(&io->pending_stripe) == 0) | 631 | if (atomic_dec_and_test(&io->pending_stripe)) |
615 | __r5l_stripe_write_finished(io); | 632 | __r5l_stripe_write_finished(io); |
616 | } | 633 | } |
617 | 634 | ||
618 | static void r5l_do_submit_io(struct r5l_log *log, struct r5l_io_unit *io) | 635 | static void r5l_do_submit_io(struct r5l_log *log, struct r5l_io_unit *io) |
@@ -881,6 +898,11 @@ static void r5l_append_flush_payload(struct r5l_log *log, sector_t sect) | |||
881 | payload->size = cpu_to_le32(sizeof(__le64)); | 898 | payload->size = cpu_to_le32(sizeof(__le64)); |
882 | payload->flush_stripes[0] = cpu_to_le64(sect); | 899 | payload->flush_stripes[0] = cpu_to_le64(sect); |
883 | io->meta_offset += meta_size; | 900 | io->meta_offset += meta_size; |
901 | /* multiple flush payloads count as one pending_stripe */ | ||
902 | if (!io->has_flush_payload) { | ||
903 | io->has_flush_payload = 1; | ||
904 | atomic_inc(&io->pending_stripe); | ||
905 | } | ||
884 | mutex_unlock(&log->io_mutex); | 906 | mutex_unlock(&log->io_mutex); |
885 | } | 907 | } |
886 | 908 | ||
@@ -2540,23 +2562,32 @@ static ssize_t r5c_journal_mode_show(struct mddev *mddev, char *page) | |||
2540 | */ | 2562 | */ |
2541 | int r5c_journal_mode_set(struct mddev *mddev, int mode) | 2563 | int r5c_journal_mode_set(struct mddev *mddev, int mode) |
2542 | { | 2564 | { |
2543 | struct r5conf *conf = mddev->private; | 2565 | struct r5conf *conf; |
2544 | struct r5l_log *log = conf->log; | 2566 | int err; |
2545 | |||
2546 | if (!log) | ||
2547 | return -ENODEV; | ||
2548 | 2567 | ||
2549 | if (mode < R5C_JOURNAL_MODE_WRITE_THROUGH || | 2568 | if (mode < R5C_JOURNAL_MODE_WRITE_THROUGH || |
2550 | mode > R5C_JOURNAL_MODE_WRITE_BACK) | 2569 | mode > R5C_JOURNAL_MODE_WRITE_BACK) |
2551 | return -EINVAL; | 2570 | return -EINVAL; |
2552 | 2571 | ||
2572 | err = mddev_lock(mddev); | ||
2573 | if (err) | ||
2574 | return err; | ||
2575 | conf = mddev->private; | ||
2576 | if (!conf || !conf->log) { | ||
2577 | mddev_unlock(mddev); | ||
2578 | return -ENODEV; | ||
2579 | } | ||
2580 | |||
2553 | if (raid5_calc_degraded(conf) > 0 && | 2581 | if (raid5_calc_degraded(conf) > 0 && |
2554 | mode == R5C_JOURNAL_MODE_WRITE_BACK) | 2582 | mode == R5C_JOURNAL_MODE_WRITE_BACK) { |
2583 | mddev_unlock(mddev); | ||
2555 | return -EINVAL; | 2584 | return -EINVAL; |
2585 | } | ||
2556 | 2586 | ||
2557 | mddev_suspend(mddev); | 2587 | mddev_suspend(mddev); |
2558 | conf->log->r5c_journal_mode = mode; | 2588 | conf->log->r5c_journal_mode = mode; |
2559 | mddev_resume(mddev); | 2589 | mddev_resume(mddev); |
2590 | mddev_unlock(mddev); | ||
2560 | 2591 | ||
2561 | pr_debug("md/raid:%s: setting r5c cache mode to %d: %s\n", | 2592 | pr_debug("md/raid:%s: setting r5c cache mode to %d: %s\n", |
2562 | mdname(mddev), mode, r5c_journal_mode_str[mode]); | 2593 | mdname(mddev), mode, r5c_journal_mode_str[mode]); |
diff --git a/drivers/memory/atmel-ebi.c b/drivers/memory/atmel-ebi.c index 99e644cda4d1..ebf69ff48ae2 100644 --- a/drivers/memory/atmel-ebi.c +++ b/drivers/memory/atmel-ebi.c | |||
@@ -72,7 +72,7 @@ struct atmel_smc_timing_xlate { | |||
72 | { .name = nm, .converter = atmel_smc_cs_conf_set_pulse, .shift = pos} | 72 | { .name = nm, .converter = atmel_smc_cs_conf_set_pulse, .shift = pos} |
73 | 73 | ||
74 | #define ATMEL_SMC_CYCLE_XLATE(nm, pos) \ | 74 | #define ATMEL_SMC_CYCLE_XLATE(nm, pos) \ |
75 | { .name = nm, .converter = atmel_smc_cs_conf_set_setup, .shift = pos} | 75 | { .name = nm, .converter = atmel_smc_cs_conf_set_cycle, .shift = pos} |
76 | 76 | ||
77 | static void at91sam9_ebi_get_config(struct atmel_ebi_dev *ebid, | 77 | static void at91sam9_ebi_get_config(struct atmel_ebi_dev *ebid, |
78 | struct atmel_ebi_dev_config *conf) | 78 | struct atmel_ebi_dev_config *conf) |
@@ -120,12 +120,14 @@ static int atmel_ebi_xslate_smc_timings(struct atmel_ebi_dev *ebid, | |||
120 | if (!ret) { | 120 | if (!ret) { |
121 | required = true; | 121 | required = true; |
122 | ncycles = DIV_ROUND_UP(val, clk_period_ns); | 122 | ncycles = DIV_ROUND_UP(val, clk_period_ns); |
123 | if (ncycles > ATMEL_SMC_MODE_TDF_MAX || | 123 | if (ncycles > ATMEL_SMC_MODE_TDF_MAX) { |
124 | ncycles < ATMEL_SMC_MODE_TDF_MIN) { | ||
125 | ret = -EINVAL; | 124 | ret = -EINVAL; |
126 | goto out; | 125 | goto out; |
127 | } | 126 | } |
128 | 127 | ||
128 | if (ncycles < ATMEL_SMC_MODE_TDF_MIN) | ||
129 | ncycles = ATMEL_SMC_MODE_TDF_MIN; | ||
130 | |||
129 | smcconf->mode |= ATMEL_SMC_MODE_TDF(ncycles); | 131 | smcconf->mode |= ATMEL_SMC_MODE_TDF(ncycles); |
130 | } | 132 | } |
131 | 133 | ||
@@ -263,7 +265,7 @@ static int atmel_ebi_xslate_smc_config(struct atmel_ebi_dev *ebid, | |||
263 | } | 265 | } |
264 | 266 | ||
265 | ret = atmel_ebi_xslate_smc_timings(ebid, np, &conf->smcconf); | 267 | ret = atmel_ebi_xslate_smc_timings(ebid, np, &conf->smcconf); |
266 | if (ret) | 268 | if (ret < 0) |
267 | return -EINVAL; | 269 | return -EINVAL; |
268 | 270 | ||
269 | if ((ret > 0 && !required) || (!ret && required)) { | 271 | if ((ret > 0 && !required) || (!ret && required)) { |
diff --git a/drivers/mfd/atmel-smc.c b/drivers/mfd/atmel-smc.c index 954cf0f66a31..20cc0ea470fa 100644 --- a/drivers/mfd/atmel-smc.c +++ b/drivers/mfd/atmel-smc.c | |||
@@ -206,7 +206,7 @@ EXPORT_SYMBOL_GPL(atmel_smc_cs_conf_set_pulse); | |||
206 | * parameter | 206 | * parameter |
207 | * | 207 | * |
208 | * This function encodes the @ncycles value as described in the datasheet | 208 | * This function encodes the @ncycles value as described in the datasheet |
209 | * (section "SMC Pulse Register"), and then stores the result in the | 209 | * (section "SMC Cycle Register"), and then stores the result in the |
210 | * @conf->setup field at @shift position. | 210 | * @conf->setup field at @shift position. |
211 | * | 211 | * |
212 | * Returns -EINVAL if @shift is invalid, -ERANGE if @ncycles does not fit in | 212 | * Returns -EINVAL if @shift is invalid, -ERANGE if @ncycles does not fit in |
diff --git a/drivers/mfd/da9062-core.c b/drivers/mfd/da9062-core.c index fbe0f245ce8e..fe1811523e4a 100644 --- a/drivers/mfd/da9062-core.c +++ b/drivers/mfd/da9062-core.c | |||
@@ -645,6 +645,9 @@ static const struct regmap_range da9062_aa_readable_ranges[] = { | |||
645 | .range_min = DA9062AA_VLDO1_B, | 645 | .range_min = DA9062AA_VLDO1_B, |
646 | .range_max = DA9062AA_VLDO4_B, | 646 | .range_max = DA9062AA_VLDO4_B, |
647 | }, { | 647 | }, { |
648 | .range_min = DA9062AA_BBAT_CONT, | ||
649 | .range_max = DA9062AA_BBAT_CONT, | ||
650 | }, { | ||
648 | .range_min = DA9062AA_INTERFACE, | 651 | .range_min = DA9062AA_INTERFACE, |
649 | .range_max = DA9062AA_CONFIG_E, | 652 | .range_max = DA9062AA_CONFIG_E, |
650 | }, { | 653 | }, { |
@@ -721,6 +724,9 @@ static const struct regmap_range da9062_aa_writeable_ranges[] = { | |||
721 | .range_min = DA9062AA_VLDO1_B, | 724 | .range_min = DA9062AA_VLDO1_B, |
722 | .range_max = DA9062AA_VLDO4_B, | 725 | .range_max = DA9062AA_VLDO4_B, |
723 | }, { | 726 | }, { |
727 | .range_min = DA9062AA_BBAT_CONT, | ||
728 | .range_max = DA9062AA_BBAT_CONT, | ||
729 | }, { | ||
724 | .range_min = DA9062AA_GP_ID_0, | 730 | .range_min = DA9062AA_GP_ID_0, |
725 | .range_max = DA9062AA_GP_ID_19, | 731 | .range_max = DA9062AA_GP_ID_19, |
726 | }, | 732 | }, |
diff --git a/drivers/misc/mei/pci-me.c b/drivers/misc/mei/pci-me.c index 8621a198a2ce..bac33311f55a 100644 --- a/drivers/misc/mei/pci-me.c +++ b/drivers/misc/mei/pci-me.c | |||
@@ -216,6 +216,12 @@ static int mei_me_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
216 | pci_set_drvdata(pdev, dev); | 216 | pci_set_drvdata(pdev, dev); |
217 | 217 | ||
218 | /* | 218 | /* |
219 | * MEI requires to resume from runtime suspend mode | ||
220 | * in order to perform link reset flow upon system suspend. | ||
221 | */ | ||
222 | pdev->dev_flags |= PCI_DEV_FLAGS_NEEDS_RESUME; | ||
223 | |||
224 | /* | ||
219 | * For not wake-able HW runtime pm framework | 225 | * For not wake-able HW runtime pm framework |
220 | * can't be used on pci device level. | 226 | * can't be used on pci device level. |
221 | * Use domain runtime pm callbacks instead. | 227 | * Use domain runtime pm callbacks instead. |
diff --git a/drivers/misc/mei/pci-txe.c b/drivers/misc/mei/pci-txe.c index f811cd524468..e38a5f144373 100644 --- a/drivers/misc/mei/pci-txe.c +++ b/drivers/misc/mei/pci-txe.c | |||
@@ -138,6 +138,12 @@ static int mei_txe_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
138 | pci_set_drvdata(pdev, dev); | 138 | pci_set_drvdata(pdev, dev); |
139 | 139 | ||
140 | /* | 140 | /* |
141 | * MEI requires to resume from runtime suspend mode | ||
142 | * in order to perform link reset flow upon system suspend. | ||
143 | */ | ||
144 | pdev->dev_flags |= PCI_DEV_FLAGS_NEEDS_RESUME; | ||
145 | |||
146 | /* | ||
141 | * For not wake-able HW runtime pm framework | 147 | * For not wake-able HW runtime pm framework |
142 | * can't be used on pci device level. | 148 | * can't be used on pci device level. |
143 | * Use domain runtime pm callbacks instead. | 149 | * Use domain runtime pm callbacks instead. |
diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c index e5938c791330..f1bbfd389367 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c | |||
@@ -2170,7 +2170,9 @@ static void mmc_blk_remove_req(struct mmc_blk_data *md) | |||
2170 | * from being accepted. | 2170 | * from being accepted. |
2171 | */ | 2171 | */ |
2172 | card = md->queue.card; | 2172 | card = md->queue.card; |
2173 | spin_lock_irq(md->queue.queue->queue_lock); | ||
2173 | queue_flag_set(QUEUE_FLAG_BYPASS, md->queue.queue); | 2174 | queue_flag_set(QUEUE_FLAG_BYPASS, md->queue.queue); |
2175 | spin_unlock_irq(md->queue.queue->queue_lock); | ||
2174 | blk_set_queue_dying(md->queue.queue); | 2176 | blk_set_queue_dying(md->queue.queue); |
2175 | mmc_cleanup_queue(&md->queue); | 2177 | mmc_cleanup_queue(&md->queue); |
2176 | if (md->disk->flags & GENHD_FL_UP) { | 2178 | if (md->disk->flags & GENHD_FL_UP) { |
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index 4ffea14b7eb6..2bae69e39544 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c | |||
@@ -1289,7 +1289,7 @@ out_err: | |||
1289 | static int mmc_select_hs400es(struct mmc_card *card) | 1289 | static int mmc_select_hs400es(struct mmc_card *card) |
1290 | { | 1290 | { |
1291 | struct mmc_host *host = card->host; | 1291 | struct mmc_host *host = card->host; |
1292 | int err = 0; | 1292 | int err = -EINVAL; |
1293 | u8 val; | 1293 | u8 val; |
1294 | 1294 | ||
1295 | if (!(host->caps & MMC_CAP_8_BIT_DATA)) { | 1295 | if (!(host->caps & MMC_CAP_8_BIT_DATA)) { |
diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c index 04ff3c97a535..2ab4788d021f 100644 --- a/drivers/mmc/host/omap_hsmmc.c +++ b/drivers/mmc/host/omap_hsmmc.c | |||
@@ -2086,7 +2086,7 @@ static int omap_hsmmc_probe(struct platform_device *pdev) | |||
2086 | mmc->max_seg_size = mmc->max_req_size; | 2086 | mmc->max_seg_size = mmc->max_req_size; |
2087 | 2087 | ||
2088 | mmc->caps |= MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED | | 2088 | mmc->caps |= MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED | |
2089 | MMC_CAP_WAIT_WHILE_BUSY | MMC_CAP_ERASE; | 2089 | MMC_CAP_WAIT_WHILE_BUSY | MMC_CAP_ERASE | MMC_CAP_CMD23; |
2090 | 2090 | ||
2091 | mmc->caps |= mmc_pdata(host)->caps; | 2091 | mmc->caps |= mmc_pdata(host)->caps; |
2092 | if (mmc->caps & MMC_CAP_8_BIT_DATA) | 2092 | if (mmc->caps & MMC_CAP_8_BIT_DATA) |
diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c index f336a9b85576..9ec8f033ac5f 100644 --- a/drivers/mtd/mtd_blkdevs.c +++ b/drivers/mtd/mtd_blkdevs.c | |||
@@ -113,6 +113,7 @@ static blk_status_t do_blktrans_request(struct mtd_blktrans_ops *tr, | |||
113 | for (; nsect > 0; nsect--, block++, buf += tr->blksize) | 113 | for (; nsect > 0; nsect--, block++, buf += tr->blksize) |
114 | if (tr->writesect(dev, block, buf)) | 114 | if (tr->writesect(dev, block, buf)) |
115 | return BLK_STS_IOERR; | 115 | return BLK_STS_IOERR; |
116 | return BLK_STS_OK; | ||
116 | default: | 117 | default: |
117 | return BLK_STS_IOERR; | 118 | return BLK_STS_IOERR; |
118 | } | 119 | } |
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 9bee6c1c70cc..fc63992ab0e0 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c | |||
@@ -1569,7 +1569,8 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev) | |||
1569 | new_slave->delay = 0; | 1569 | new_slave->delay = 0; |
1570 | new_slave->link_failure_count = 0; | 1570 | new_slave->link_failure_count = 0; |
1571 | 1571 | ||
1572 | if (bond_update_speed_duplex(new_slave)) | 1572 | if (bond_update_speed_duplex(new_slave) && |
1573 | bond_needs_speed_duplex(bond)) | ||
1573 | new_slave->link = BOND_LINK_DOWN; | 1574 | new_slave->link = BOND_LINK_DOWN; |
1574 | 1575 | ||
1575 | new_slave->last_rx = jiffies - | 1576 | new_slave->last_rx = jiffies - |
@@ -2140,11 +2141,13 @@ static void bond_miimon_commit(struct bonding *bond) | |||
2140 | continue; | 2141 | continue; |
2141 | 2142 | ||
2142 | case BOND_LINK_UP: | 2143 | case BOND_LINK_UP: |
2143 | if (bond_update_speed_duplex(slave)) { | 2144 | if (bond_update_speed_duplex(slave) && |
2145 | bond_needs_speed_duplex(bond)) { | ||
2144 | slave->link = BOND_LINK_DOWN; | 2146 | slave->link = BOND_LINK_DOWN; |
2145 | netdev_warn(bond->dev, | 2147 | if (net_ratelimit()) |
2146 | "failed to get link speed/duplex for %s\n", | 2148 | netdev_warn(bond->dev, |
2147 | slave->dev->name); | 2149 | "failed to get link speed/duplex for %s\n", |
2150 | slave->dev->name); | ||
2148 | continue; | 2151 | continue; |
2149 | } | 2152 | } |
2150 | bond_set_slave_link_state(slave, BOND_LINK_UP, | 2153 | bond_set_slave_link_state(slave, BOND_LINK_UP, |
diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c b/drivers/net/ethernet/broadcom/bcmsysport.c index 5333601f855f..dc3052751bc1 100644 --- a/drivers/net/ethernet/broadcom/bcmsysport.c +++ b/drivers/net/ethernet/broadcom/bcmsysport.c | |||
@@ -449,6 +449,10 @@ static void bcm_sysport_get_stats(struct net_device *dev, | |||
449 | p = (char *)&dev->stats; | 449 | p = (char *)&dev->stats; |
450 | else | 450 | else |
451 | p = (char *)priv; | 451 | p = (char *)priv; |
452 | |||
453 | if (priv->is_lite && !bcm_sysport_lite_stat_valid(s->type)) | ||
454 | continue; | ||
455 | |||
452 | p += s->stat_offset; | 456 | p += s->stat_offset; |
453 | data[j] = *(unsigned long *)p; | 457 | data[j] = *(unsigned long *)p; |
454 | j++; | 458 | j++; |
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h index ef4be781fd05..09ea62ee96d3 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h | |||
@@ -529,6 +529,7 @@ enum { /* adapter flags */ | |||
529 | USING_SOFT_PARAMS = (1 << 6), | 529 | USING_SOFT_PARAMS = (1 << 6), |
530 | MASTER_PF = (1 << 7), | 530 | MASTER_PF = (1 << 7), |
531 | FW_OFLD_CONN = (1 << 9), | 531 | FW_OFLD_CONN = (1 << 9), |
532 | ROOT_NO_RELAXED_ORDERING = (1 << 10), | ||
532 | }; | 533 | }; |
533 | 534 | ||
534 | enum { | 535 | enum { |
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c index e403fa18f1b1..33bb8678833a 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | |||
@@ -4654,11 +4654,6 @@ static void print_port_info(const struct net_device *dev) | |||
4654 | dev->name, adap->params.vpd.id, adap->name, buf); | 4654 | dev->name, adap->params.vpd.id, adap->name, buf); |
4655 | } | 4655 | } |
4656 | 4656 | ||
4657 | static void enable_pcie_relaxed_ordering(struct pci_dev *dev) | ||
4658 | { | ||
4659 | pcie_capability_set_word(dev, PCI_EXP_DEVCTL, PCI_EXP_DEVCTL_RELAX_EN); | ||
4660 | } | ||
4661 | |||
4662 | /* | 4657 | /* |
4663 | * Free the following resources: | 4658 | * Free the following resources: |
4664 | * - memory used for tables | 4659 | * - memory used for tables |
@@ -4908,7 +4903,6 @@ static int init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
4908 | } | 4903 | } |
4909 | 4904 | ||
4910 | pci_enable_pcie_error_reporting(pdev); | 4905 | pci_enable_pcie_error_reporting(pdev); |
4911 | enable_pcie_relaxed_ordering(pdev); | ||
4912 | pci_set_master(pdev); | 4906 | pci_set_master(pdev); |
4913 | pci_save_state(pdev); | 4907 | pci_save_state(pdev); |
4914 | 4908 | ||
@@ -4947,6 +4941,23 @@ static int init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
4947 | adapter->msg_enable = DFLT_MSG_ENABLE; | 4941 | adapter->msg_enable = DFLT_MSG_ENABLE; |
4948 | memset(adapter->chan_map, 0xff, sizeof(adapter->chan_map)); | 4942 | memset(adapter->chan_map, 0xff, sizeof(adapter->chan_map)); |
4949 | 4943 | ||
4944 | /* If possible, we use PCIe Relaxed Ordering Attribute to deliver | ||
4945 | * Ingress Packet Data to Free List Buffers in order to allow for | ||
4946 | * chipset performance optimizations between the Root Complex and | ||
4947 | * Memory Controllers. (Messages to the associated Ingress Queue | ||
4948 | * notifying new Packet Placement in the Free Lists Buffers will be | ||
4949 | * send without the Relaxed Ordering Attribute thus guaranteeing that | ||
4950 | * all preceding PCIe Transaction Layer Packets will be processed | ||
4951 | * first.) But some Root Complexes have various issues with Upstream | ||
4952 | * Transaction Layer Packets with the Relaxed Ordering Attribute set. | ||
4953 | * The PCIe devices which under the Root Complexes will be cleared the | ||
4954 | * Relaxed Ordering bit in the configuration space, So we check our | ||
4955 | * PCIe configuration space to see if it's flagged with advice against | ||
4956 | * using Relaxed Ordering. | ||
4957 | */ | ||
4958 | if (!pcie_relaxed_ordering_enabled(pdev)) | ||
4959 | adapter->flags |= ROOT_NO_RELAXED_ORDERING; | ||
4960 | |||
4950 | spin_lock_init(&adapter->stats_lock); | 4961 | spin_lock_init(&adapter->stats_lock); |
4951 | spin_lock_init(&adapter->tid_release_lock); | 4962 | spin_lock_init(&adapter->tid_release_lock); |
4952 | spin_lock_init(&adapter->win0_lock); | 4963 | spin_lock_init(&adapter->win0_lock); |
diff --git a/drivers/net/ethernet/chelsio/cxgb4/sge.c b/drivers/net/ethernet/chelsio/cxgb4/sge.c index ede12209f20b..4ef68f69b58c 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/sge.c +++ b/drivers/net/ethernet/chelsio/cxgb4/sge.c | |||
@@ -2719,6 +2719,7 @@ int t4_sge_alloc_rxq(struct adapter *adap, struct sge_rspq *iq, bool fwevtq, | |||
2719 | struct fw_iq_cmd c; | 2719 | struct fw_iq_cmd c; |
2720 | struct sge *s = &adap->sge; | 2720 | struct sge *s = &adap->sge; |
2721 | struct port_info *pi = netdev_priv(dev); | 2721 | struct port_info *pi = netdev_priv(dev); |
2722 | int relaxed = !(adap->flags & ROOT_NO_RELAXED_ORDERING); | ||
2722 | 2723 | ||
2723 | /* Size needs to be multiple of 16, including status entry. */ | 2724 | /* Size needs to be multiple of 16, including status entry. */ |
2724 | iq->size = roundup(iq->size, 16); | 2725 | iq->size = roundup(iq->size, 16); |
@@ -2772,8 +2773,8 @@ int t4_sge_alloc_rxq(struct adapter *adap, struct sge_rspq *iq, bool fwevtq, | |||
2772 | 2773 | ||
2773 | flsz = fl->size / 8 + s->stat_len / sizeof(struct tx_desc); | 2774 | flsz = fl->size / 8 + s->stat_len / sizeof(struct tx_desc); |
2774 | c.iqns_to_fl0congen |= htonl(FW_IQ_CMD_FL0PACKEN_F | | 2775 | c.iqns_to_fl0congen |= htonl(FW_IQ_CMD_FL0PACKEN_F | |
2775 | FW_IQ_CMD_FL0FETCHRO_F | | 2776 | FW_IQ_CMD_FL0FETCHRO_V(relaxed) | |
2776 | FW_IQ_CMD_FL0DATARO_F | | 2777 | FW_IQ_CMD_FL0DATARO_V(relaxed) | |
2777 | FW_IQ_CMD_FL0PADEN_F); | 2778 | FW_IQ_CMD_FL0PADEN_F); |
2778 | if (cong >= 0) | 2779 | if (cong >= 0) |
2779 | c.iqns_to_fl0congen |= | 2780 | c.iqns_to_fl0congen |= |
diff --git a/drivers/net/ethernet/chelsio/cxgb4vf/adapter.h b/drivers/net/ethernet/chelsio/cxgb4vf/adapter.h index 109bc630408b..08c6ddb84a04 100644 --- a/drivers/net/ethernet/chelsio/cxgb4vf/adapter.h +++ b/drivers/net/ethernet/chelsio/cxgb4vf/adapter.h | |||
@@ -408,6 +408,7 @@ enum { /* adapter flags */ | |||
408 | USING_MSI = (1UL << 1), | 408 | USING_MSI = (1UL << 1), |
409 | USING_MSIX = (1UL << 2), | 409 | USING_MSIX = (1UL << 2), |
410 | QUEUES_BOUND = (1UL << 3), | 410 | QUEUES_BOUND = (1UL << 3), |
411 | ROOT_NO_RELAXED_ORDERING = (1UL << 4), | ||
411 | }; | 412 | }; |
412 | 413 | ||
413 | /* | 414 | /* |
diff --git a/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c b/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c index ac7a150c54e9..2b85b874fd0d 100644 --- a/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c +++ b/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c | |||
@@ -2888,6 +2888,24 @@ static int cxgb4vf_pci_probe(struct pci_dev *pdev, | |||
2888 | */ | 2888 | */ |
2889 | adapter->name = pci_name(pdev); | 2889 | adapter->name = pci_name(pdev); |
2890 | adapter->msg_enable = DFLT_MSG_ENABLE; | 2890 | adapter->msg_enable = DFLT_MSG_ENABLE; |
2891 | |||
2892 | /* If possible, we use PCIe Relaxed Ordering Attribute to deliver | ||
2893 | * Ingress Packet Data to Free List Buffers in order to allow for | ||
2894 | * chipset performance optimizations between the Root Complex and | ||
2895 | * Memory Controllers. (Messages to the associated Ingress Queue | ||
2896 | * notifying new Packet Placement in the Free Lists Buffers will be | ||
2897 | * send without the Relaxed Ordering Attribute thus guaranteeing that | ||
2898 | * all preceding PCIe Transaction Layer Packets will be processed | ||
2899 | * first.) But some Root Complexes have various issues with Upstream | ||
2900 | * Transaction Layer Packets with the Relaxed Ordering Attribute set. | ||
2901 | * The PCIe devices which under the Root Complexes will be cleared the | ||
2902 | * Relaxed Ordering bit in the configuration space, So we check our | ||
2903 | * PCIe configuration space to see if it's flagged with advice against | ||
2904 | * using Relaxed Ordering. | ||
2905 | */ | ||
2906 | if (!pcie_relaxed_ordering_enabled(pdev)) | ||
2907 | adapter->flags |= ROOT_NO_RELAXED_ORDERING; | ||
2908 | |||
2891 | err = adap_init0(adapter); | 2909 | err = adap_init0(adapter); |
2892 | if (err) | 2910 | if (err) |
2893 | goto err_unmap_bar; | 2911 | goto err_unmap_bar; |
diff --git a/drivers/net/ethernet/chelsio/cxgb4vf/sge.c b/drivers/net/ethernet/chelsio/cxgb4vf/sge.c index e37dde2ba97f..05498e7f2840 100644 --- a/drivers/net/ethernet/chelsio/cxgb4vf/sge.c +++ b/drivers/net/ethernet/chelsio/cxgb4vf/sge.c | |||
@@ -2205,6 +2205,7 @@ int t4vf_sge_alloc_rxq(struct adapter *adapter, struct sge_rspq *rspq, | |||
2205 | struct port_info *pi = netdev_priv(dev); | 2205 | struct port_info *pi = netdev_priv(dev); |
2206 | struct fw_iq_cmd cmd, rpl; | 2206 | struct fw_iq_cmd cmd, rpl; |
2207 | int ret, iqandst, flsz = 0; | 2207 | int ret, iqandst, flsz = 0; |
2208 | int relaxed = !(adapter->flags & ROOT_NO_RELAXED_ORDERING); | ||
2208 | 2209 | ||
2209 | /* | 2210 | /* |
2210 | * If we're using MSI interrupts and we're not initializing the | 2211 | * If we're using MSI interrupts and we're not initializing the |
@@ -2300,6 +2301,8 @@ int t4vf_sge_alloc_rxq(struct adapter *adapter, struct sge_rspq *rspq, | |||
2300 | cpu_to_be32( | 2301 | cpu_to_be32( |
2301 | FW_IQ_CMD_FL0HOSTFCMODE_V(SGE_HOSTFCMODE_NONE) | | 2302 | FW_IQ_CMD_FL0HOSTFCMODE_V(SGE_HOSTFCMODE_NONE) | |
2302 | FW_IQ_CMD_FL0PACKEN_F | | 2303 | FW_IQ_CMD_FL0PACKEN_F | |
2304 | FW_IQ_CMD_FL0FETCHRO_V(relaxed) | | ||
2305 | FW_IQ_CMD_FL0DATARO_V(relaxed) | | ||
2303 | FW_IQ_CMD_FL0PADEN_F); | 2306 | FW_IQ_CMD_FL0PADEN_F); |
2304 | 2307 | ||
2305 | /* In T6, for egress queue type FL there is internal overhead | 2308 | /* In T6, for egress queue type FL there is internal overhead |
diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c index 09b9bc17bce9..5fe5cdc51357 100644 --- a/drivers/net/ethernet/mellanox/mlx4/main.c +++ b/drivers/net/ethernet/mellanox/mlx4/main.c | |||
@@ -432,7 +432,7 @@ static int mlx4_dev_cap(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap) | |||
432 | /* Virtual PCI function needs to determine UAR page size from | 432 | /* Virtual PCI function needs to determine UAR page size from |
433 | * firmware. Only master PCI function can set the uar page size | 433 | * firmware. Only master PCI function can set the uar page size |
434 | */ | 434 | */ |
435 | if (enable_4k_uar) | 435 | if (enable_4k_uar || !dev->persist->num_vfs) |
436 | dev->uar_page_shift = DEFAULT_UAR_PAGE_SHIFT; | 436 | dev->uar_page_shift = DEFAULT_UAR_PAGE_SHIFT; |
437 | else | 437 | else |
438 | dev->uar_page_shift = PAGE_SHIFT; | 438 | dev->uar_page_shift = PAGE_SHIFT; |
@@ -2277,7 +2277,7 @@ static int mlx4_init_hca(struct mlx4_dev *dev) | |||
2277 | 2277 | ||
2278 | dev->caps.max_fmr_maps = (1 << (32 - ilog2(dev->caps.num_mpts))) - 1; | 2278 | dev->caps.max_fmr_maps = (1 << (32 - ilog2(dev->caps.num_mpts))) - 1; |
2279 | 2279 | ||
2280 | if (enable_4k_uar) { | 2280 | if (enable_4k_uar || !dev->persist->num_vfs) { |
2281 | init_hca.log_uar_sz = ilog2(dev->caps.num_uars) + | 2281 | init_hca.log_uar_sz = ilog2(dev->caps.num_uars) + |
2282 | PAGE_SHIFT - DEFAULT_UAR_PAGE_SHIFT; | 2282 | PAGE_SHIFT - DEFAULT_UAR_PAGE_SHIFT; |
2283 | init_hca.uar_page_sz = DEFAULT_UAR_PAGE_SHIFT - 12; | 2283 | init_hca.uar_page_sz = DEFAULT_UAR_PAGE_SHIFT - 12; |
diff --git a/drivers/net/ethernet/netronome/nfp/flower/cmsg.c b/drivers/net/ethernet/netronome/nfp/flower/cmsg.c index dd7fa9cf225f..b0837b58c3a1 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/cmsg.c +++ b/drivers/net/ethernet/netronome/nfp/flower/cmsg.c | |||
@@ -115,14 +115,10 @@ nfp_flower_cmsg_portmod_rx(struct nfp_app *app, struct sk_buff *skb) | |||
115 | return; | 115 | return; |
116 | } | 116 | } |
117 | 117 | ||
118 | if (link) { | 118 | if (link) |
119 | netif_carrier_on(netdev); | 119 | netif_carrier_on(netdev); |
120 | rtnl_lock(); | 120 | else |
121 | dev_set_mtu(netdev, be16_to_cpu(msg->mtu)); | ||
122 | rtnl_unlock(); | ||
123 | } else { | ||
124 | netif_carrier_off(netdev); | 121 | netif_carrier_off(netdev); |
125 | } | ||
126 | rcu_read_unlock(); | 122 | rcu_read_unlock(); |
127 | } | 123 | } |
128 | 124 | ||
diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c index 4631ca8b8eb2..9f77ce038a4a 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c +++ b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c | |||
@@ -908,8 +908,7 @@ static int nfp_net_tx(struct sk_buff *skb, struct net_device *netdev) | |||
908 | return NETDEV_TX_OK; | 908 | return NETDEV_TX_OK; |
909 | 909 | ||
910 | err_unmap: | 910 | err_unmap: |
911 | --f; | 911 | while (--f >= 0) { |
912 | while (f >= 0) { | ||
913 | frag = &skb_shinfo(skb)->frags[f]; | 912 | frag = &skb_shinfo(skb)->frags[f]; |
914 | dma_unmap_page(dp->dev, tx_ring->txbufs[wr_idx].dma_addr, | 913 | dma_unmap_page(dp->dev, tx_ring->txbufs[wr_idx].dma_addr, |
915 | skb_frag_size(frag), DMA_TO_DEVICE); | 914 | skb_frag_size(frag), DMA_TO_DEVICE); |
diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic_hw.c b/drivers/net/ethernet/qlogic/netxen/netxen_nic_hw.c index 66ff15d08bad..0a66389c06c2 100644 --- a/drivers/net/ethernet/qlogic/netxen/netxen_nic_hw.c +++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic_hw.c | |||
@@ -2311,7 +2311,7 @@ netxen_md_rdqueue(struct netxen_adapter *adapter, | |||
2311 | loop_cnt++) { | 2311 | loop_cnt++) { |
2312 | NX_WR_DUMP_REG(select_addr, adapter->ahw.pci_base0, queue_id); | 2312 | NX_WR_DUMP_REG(select_addr, adapter->ahw.pci_base0, queue_id); |
2313 | read_addr = queueEntry->read_addr; | 2313 | read_addr = queueEntry->read_addr; |
2314 | for (k = 0; k < read_cnt; k--) { | 2314 | for (k = 0; k < read_cnt; k++) { |
2315 | NX_RD_DUMP_REG(read_addr, adapter->ahw.pci_base0, | 2315 | NX_RD_DUMP_REG(read_addr, adapter->ahw.pci_base0, |
2316 | &read_value); | 2316 | &read_value); |
2317 | *data_buff++ = read_value; | 2317 | *data_buff++ = read_value; |
diff --git a/drivers/net/ethernet/sfc/mcdi_port.c b/drivers/net/ethernet/sfc/mcdi_port.c index c905971c5f3a..990a63d7fcb7 100644 --- a/drivers/net/ethernet/sfc/mcdi_port.c +++ b/drivers/net/ethernet/sfc/mcdi_port.c | |||
@@ -938,7 +938,6 @@ enum efx_stats_action { | |||
938 | static int efx_mcdi_mac_stats(struct efx_nic *efx, | 938 | static int efx_mcdi_mac_stats(struct efx_nic *efx, |
939 | enum efx_stats_action action, int clear) | 939 | enum efx_stats_action action, int clear) |
940 | { | 940 | { |
941 | struct efx_ef10_nic_data *nic_data = efx->nic_data; | ||
942 | MCDI_DECLARE_BUF(inbuf, MC_CMD_MAC_STATS_IN_LEN); | 941 | MCDI_DECLARE_BUF(inbuf, MC_CMD_MAC_STATS_IN_LEN); |
943 | int rc; | 942 | int rc; |
944 | int change = action == EFX_STATS_PULL ? 0 : 1; | 943 | int change = action == EFX_STATS_PULL ? 0 : 1; |
@@ -960,7 +959,12 @@ static int efx_mcdi_mac_stats(struct efx_nic *efx, | |||
960 | MAC_STATS_IN_PERIODIC_NOEVENT, 1, | 959 | MAC_STATS_IN_PERIODIC_NOEVENT, 1, |
961 | MAC_STATS_IN_PERIOD_MS, period); | 960 | MAC_STATS_IN_PERIOD_MS, period); |
962 | MCDI_SET_DWORD(inbuf, MAC_STATS_IN_DMA_LEN, dma_len); | 961 | MCDI_SET_DWORD(inbuf, MAC_STATS_IN_DMA_LEN, dma_len); |
963 | MCDI_SET_DWORD(inbuf, MAC_STATS_IN_PORT_ID, nic_data->vport_id); | 962 | |
963 | if (efx_nic_rev(efx) >= EFX_REV_HUNT_A0) { | ||
964 | struct efx_ef10_nic_data *nic_data = efx->nic_data; | ||
965 | |||
966 | MCDI_SET_DWORD(inbuf, MAC_STATS_IN_PORT_ID, nic_data->vport_id); | ||
967 | } | ||
964 | 968 | ||
965 | rc = efx_mcdi_rpc_quiet(efx, MC_CMD_MAC_STATS, inbuf, sizeof(inbuf), | 969 | rc = efx_mcdi_rpc_quiet(efx, MC_CMD_MAC_STATS, inbuf, sizeof(inbuf), |
966 | NULL, 0, NULL); | 970 | NULL, 0, NULL); |
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c index db157a47000c..72ec711fcba2 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c | |||
@@ -204,6 +204,7 @@ int stmmac_mdio_register(struct net_device *ndev) | |||
204 | struct stmmac_priv *priv = netdev_priv(ndev); | 204 | struct stmmac_priv *priv = netdev_priv(ndev); |
205 | struct stmmac_mdio_bus_data *mdio_bus_data = priv->plat->mdio_bus_data; | 205 | struct stmmac_mdio_bus_data *mdio_bus_data = priv->plat->mdio_bus_data; |
206 | struct device_node *mdio_node = priv->plat->mdio_node; | 206 | struct device_node *mdio_node = priv->plat->mdio_node; |
207 | struct device *dev = ndev->dev.parent; | ||
207 | int addr, found; | 208 | int addr, found; |
208 | 209 | ||
209 | if (!mdio_bus_data) | 210 | if (!mdio_bus_data) |
@@ -237,7 +238,7 @@ int stmmac_mdio_register(struct net_device *ndev) | |||
237 | else | 238 | else |
238 | err = mdiobus_register(new_bus); | 239 | err = mdiobus_register(new_bus); |
239 | if (err != 0) { | 240 | if (err != 0) { |
240 | netdev_err(ndev, "Cannot register the MDIO bus\n"); | 241 | dev_err(dev, "Cannot register the MDIO bus\n"); |
241 | goto bus_register_fail; | 242 | goto bus_register_fail; |
242 | } | 243 | } |
243 | 244 | ||
@@ -285,14 +286,12 @@ int stmmac_mdio_register(struct net_device *ndev) | |||
285 | irq_str = irq_num; | 286 | irq_str = irq_num; |
286 | break; | 287 | break; |
287 | } | 288 | } |
288 | netdev_info(ndev, "PHY ID %08x at %d IRQ %s (%s)%s\n", | 289 | phy_attached_info(phydev); |
289 | phydev->phy_id, addr, irq_str, phydev_name(phydev), | ||
290 | act ? " active" : ""); | ||
291 | found = 1; | 290 | found = 1; |
292 | } | 291 | } |
293 | 292 | ||
294 | if (!found && !mdio_node) { | 293 | if (!found && !mdio_node) { |
295 | netdev_warn(ndev, "No PHY found\n"); | 294 | dev_warn(dev, "No PHY found\n"); |
296 | mdiobus_unregister(new_bus); | 295 | mdiobus_unregister(new_bus); |
297 | mdiobus_free(new_bus); | 296 | mdiobus_free(new_bus); |
298 | return -ENODEV; | 297 | return -ENODEV; |
diff --git a/drivers/net/geneve.c b/drivers/net/geneve.c index de8156c6b292..2bbda71818ad 100644 --- a/drivers/net/geneve.c +++ b/drivers/net/geneve.c | |||
@@ -1091,7 +1091,7 @@ static int geneve_validate(struct nlattr *tb[], struct nlattr *data[], | |||
1091 | if (data[IFLA_GENEVE_ID]) { | 1091 | if (data[IFLA_GENEVE_ID]) { |
1092 | __u32 vni = nla_get_u32(data[IFLA_GENEVE_ID]); | 1092 | __u32 vni = nla_get_u32(data[IFLA_GENEVE_ID]); |
1093 | 1093 | ||
1094 | if (vni >= GENEVE_VID_MASK) | 1094 | if (vni >= GENEVE_N_VID) |
1095 | return -ERANGE; | 1095 | return -ERANGE; |
1096 | } | 1096 | } |
1097 | 1097 | ||
diff --git a/drivers/net/tun.c b/drivers/net/tun.c index 32ad87345f57..0a2c0a42283f 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c | |||
@@ -1879,6 +1879,9 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr) | |||
1879 | 1879 | ||
1880 | err_detach: | 1880 | err_detach: |
1881 | tun_detach_all(dev); | 1881 | tun_detach_all(dev); |
1882 | /* register_netdevice() already called tun_free_netdev() */ | ||
1883 | goto err_free_dev; | ||
1884 | |||
1882 | err_free_flow: | 1885 | err_free_flow: |
1883 | tun_flow_uninit(tun); | 1886 | tun_flow_uninit(tun); |
1884 | security_tun_dev_free_security(tun->security); | 1887 | security_tun_dev_free_security(tun->security); |
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.c index d21258d277ce..f1b60740e020 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.c | |||
@@ -159,8 +159,10 @@ void brcmf_feat_attach(struct brcmf_pub *drvr) | |||
159 | 159 | ||
160 | brcmf_feat_firmware_capabilities(ifp); | 160 | brcmf_feat_firmware_capabilities(ifp); |
161 | memset(&gscan_cfg, 0, sizeof(gscan_cfg)); | 161 | memset(&gscan_cfg, 0, sizeof(gscan_cfg)); |
162 | brcmf_feat_iovar_data_set(ifp, BRCMF_FEAT_GSCAN, "pfn_gscan_cfg", | 162 | if (drvr->bus_if->chip != BRCM_CC_43430_CHIP_ID) |
163 | &gscan_cfg, sizeof(gscan_cfg)); | 163 | brcmf_feat_iovar_data_set(ifp, BRCMF_FEAT_GSCAN, |
164 | "pfn_gscan_cfg", | ||
165 | &gscan_cfg, sizeof(gscan_cfg)); | ||
164 | brcmf_feat_iovar_int_get(ifp, BRCMF_FEAT_PNO, "pfn"); | 166 | brcmf_feat_iovar_int_get(ifp, BRCMF_FEAT_PNO, "pfn"); |
165 | if (drvr->bus_if->wowl_supported) | 167 | if (drvr->bus_if->wowl_supported) |
166 | brcmf_feat_iovar_int_get(ifp, BRCMF_FEAT_WOWL, "wowl"); | 168 | brcmf_feat_iovar_int_get(ifp, BRCMF_FEAT_WOWL, "wowl"); |
diff --git a/drivers/net/wireless/intel/iwlwifi/cfg/9000.c b/drivers/net/wireless/intel/iwlwifi/cfg/9000.c index b4ecd1fe1374..97208ce19f92 100644 --- a/drivers/net/wireless/intel/iwlwifi/cfg/9000.c +++ b/drivers/net/wireless/intel/iwlwifi/cfg/9000.c | |||
@@ -154,7 +154,7 @@ static const struct iwl_tt_params iwl9000_tt_params = { | |||
154 | const struct iwl_cfg iwl9160_2ac_cfg = { | 154 | const struct iwl_cfg iwl9160_2ac_cfg = { |
155 | .name = "Intel(R) Dual Band Wireless AC 9160", | 155 | .name = "Intel(R) Dual Band Wireless AC 9160", |
156 | .fw_name_pre = IWL9260A_FW_PRE, | 156 | .fw_name_pre = IWL9260A_FW_PRE, |
157 | .fw_name_pre_next_step = IWL9260B_FW_PRE, | 157 | .fw_name_pre_b_or_c_step = IWL9260B_FW_PRE, |
158 | IWL_DEVICE_9000, | 158 | IWL_DEVICE_9000, |
159 | .ht_params = &iwl9000_ht_params, | 159 | .ht_params = &iwl9000_ht_params, |
160 | .nvm_ver = IWL9000_NVM_VERSION, | 160 | .nvm_ver = IWL9000_NVM_VERSION, |
@@ -165,7 +165,7 @@ const struct iwl_cfg iwl9160_2ac_cfg = { | |||
165 | const struct iwl_cfg iwl9260_2ac_cfg = { | 165 | const struct iwl_cfg iwl9260_2ac_cfg = { |
166 | .name = "Intel(R) Dual Band Wireless AC 9260", | 166 | .name = "Intel(R) Dual Band Wireless AC 9260", |
167 | .fw_name_pre = IWL9260A_FW_PRE, | 167 | .fw_name_pre = IWL9260A_FW_PRE, |
168 | .fw_name_pre_next_step = IWL9260B_FW_PRE, | 168 | .fw_name_pre_b_or_c_step = IWL9260B_FW_PRE, |
169 | IWL_DEVICE_9000, | 169 | IWL_DEVICE_9000, |
170 | .ht_params = &iwl9000_ht_params, | 170 | .ht_params = &iwl9000_ht_params, |
171 | .nvm_ver = IWL9000_NVM_VERSION, | 171 | .nvm_ver = IWL9000_NVM_VERSION, |
@@ -176,7 +176,7 @@ const struct iwl_cfg iwl9260_2ac_cfg = { | |||
176 | const struct iwl_cfg iwl9270_2ac_cfg = { | 176 | const struct iwl_cfg iwl9270_2ac_cfg = { |
177 | .name = "Intel(R) Dual Band Wireless AC 9270", | 177 | .name = "Intel(R) Dual Band Wireless AC 9270", |
178 | .fw_name_pre = IWL9260A_FW_PRE, | 178 | .fw_name_pre = IWL9260A_FW_PRE, |
179 | .fw_name_pre_next_step = IWL9260B_FW_PRE, | 179 | .fw_name_pre_b_or_c_step = IWL9260B_FW_PRE, |
180 | IWL_DEVICE_9000, | 180 | IWL_DEVICE_9000, |
181 | .ht_params = &iwl9000_ht_params, | 181 | .ht_params = &iwl9000_ht_params, |
182 | .nvm_ver = IWL9000_NVM_VERSION, | 182 | .nvm_ver = IWL9000_NVM_VERSION, |
@@ -186,8 +186,8 @@ const struct iwl_cfg iwl9270_2ac_cfg = { | |||
186 | 186 | ||
187 | const struct iwl_cfg iwl9460_2ac_cfg = { | 187 | const struct iwl_cfg iwl9460_2ac_cfg = { |
188 | .name = "Intel(R) Dual Band Wireless AC 9460", | 188 | .name = "Intel(R) Dual Band Wireless AC 9460", |
189 | .fw_name_pre = IWL9000_FW_PRE, | 189 | .fw_name_pre = IWL9260A_FW_PRE, |
190 | .fw_name_pre_rf_next_step = IWL9000RFB_FW_PRE, | 190 | .fw_name_pre_b_or_c_step = IWL9260B_FW_PRE, |
191 | IWL_DEVICE_9000, | 191 | IWL_DEVICE_9000, |
192 | .ht_params = &iwl9000_ht_params, | 192 | .ht_params = &iwl9000_ht_params, |
193 | .nvm_ver = IWL9000_NVM_VERSION, | 193 | .nvm_ver = IWL9000_NVM_VERSION, |
@@ -198,8 +198,8 @@ const struct iwl_cfg iwl9460_2ac_cfg = { | |||
198 | 198 | ||
199 | const struct iwl_cfg iwl9560_2ac_cfg = { | 199 | const struct iwl_cfg iwl9560_2ac_cfg = { |
200 | .name = "Intel(R) Dual Band Wireless AC 9560", | 200 | .name = "Intel(R) Dual Band Wireless AC 9560", |
201 | .fw_name_pre = IWL9000_FW_PRE, | 201 | .fw_name_pre = IWL9260A_FW_PRE, |
202 | .fw_name_pre_rf_next_step = IWL9000RFB_FW_PRE, | 202 | .fw_name_pre_b_or_c_step = IWL9260B_FW_PRE, |
203 | IWL_DEVICE_9000, | 203 | IWL_DEVICE_9000, |
204 | .ht_params = &iwl9000_ht_params, | 204 | .ht_params = &iwl9000_ht_params, |
205 | .nvm_ver = IWL9000_NVM_VERSION, | 205 | .nvm_ver = IWL9000_NVM_VERSION, |
diff --git a/drivers/net/wireless/intel/iwlwifi/fw/file.h b/drivers/net/wireless/intel/iwlwifi/fw/file.h index 0fa8c473f1e2..c73a6438ce8f 100644 --- a/drivers/net/wireless/intel/iwlwifi/fw/file.h +++ b/drivers/net/wireless/intel/iwlwifi/fw/file.h | |||
@@ -328,6 +328,7 @@ typedef unsigned int __bitwise iwl_ucode_tlv_capa_t; | |||
328 | * @IWL_UCODE_TLV_CAPA_TX_POWER_ACK: reduced TX power API has larger | 328 | * @IWL_UCODE_TLV_CAPA_TX_POWER_ACK: reduced TX power API has larger |
329 | * command size (command version 4) that supports toggling ACK TX | 329 | * command size (command version 4) that supports toggling ACK TX |
330 | * power reduction. | 330 | * power reduction. |
331 | * @IWL_UCODE_TLV_CAPA_MLME_OFFLOAD: supports MLME offload | ||
331 | * | 332 | * |
332 | * @NUM_IWL_UCODE_TLV_CAPA: number of bits used | 333 | * @NUM_IWL_UCODE_TLV_CAPA: number of bits used |
333 | */ | 334 | */ |
@@ -373,6 +374,7 @@ enum iwl_ucode_tlv_capa { | |||
373 | IWL_UCODE_TLV_CAPA_EXTEND_SHARED_MEM_CFG = (__force iwl_ucode_tlv_capa_t)80, | 374 | IWL_UCODE_TLV_CAPA_EXTEND_SHARED_MEM_CFG = (__force iwl_ucode_tlv_capa_t)80, |
374 | IWL_UCODE_TLV_CAPA_LQM_SUPPORT = (__force iwl_ucode_tlv_capa_t)81, | 375 | IWL_UCODE_TLV_CAPA_LQM_SUPPORT = (__force iwl_ucode_tlv_capa_t)81, |
375 | IWL_UCODE_TLV_CAPA_TX_POWER_ACK = (__force iwl_ucode_tlv_capa_t)84, | 376 | IWL_UCODE_TLV_CAPA_TX_POWER_ACK = (__force iwl_ucode_tlv_capa_t)84, |
377 | IWL_UCODE_TLV_CAPA_MLME_OFFLOAD = (__force iwl_ucode_tlv_capa_t)96, | ||
376 | 378 | ||
377 | NUM_IWL_UCODE_TLV_CAPA | 379 | NUM_IWL_UCODE_TLV_CAPA |
378 | #ifdef __CHECKER__ | 380 | #ifdef __CHECKER__ |
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-config.h b/drivers/net/wireless/intel/iwlwifi/iwl-config.h index c52623cb7c2a..d19c74827fbb 100644 --- a/drivers/net/wireless/intel/iwlwifi/iwl-config.h +++ b/drivers/net/wireless/intel/iwlwifi/iwl-config.h | |||
@@ -276,10 +276,10 @@ struct iwl_pwr_tx_backoff { | |||
276 | * @fw_name_pre: Firmware filename prefix. The api version and extension | 276 | * @fw_name_pre: Firmware filename prefix. The api version and extension |
277 | * (.ucode) will be added to filename before loading from disk. The | 277 | * (.ucode) will be added to filename before loading from disk. The |
278 | * filename is constructed as fw_name_pre<api>.ucode. | 278 | * filename is constructed as fw_name_pre<api>.ucode. |
279 | * @fw_name_pre_next_step: same as @fw_name_pre, only for next step | 279 | * @fw_name_pre_b_or_c_step: same as @fw_name_pre, only for b or c steps |
280 | * (if supported) | 280 | * (if supported) |
281 | * @fw_name_pre_rf_next_step: same as @fw_name_pre_next_step, only for rf next | 281 | * @fw_name_pre_rf_next_step: same as @fw_name_pre_b_or_c_step, only for rf |
282 | * step. Supported only in integrated solutions. | 282 | * next step. Supported only in integrated solutions. |
283 | * @ucode_api_max: Highest version of uCode API supported by driver. | 283 | * @ucode_api_max: Highest version of uCode API supported by driver. |
284 | * @ucode_api_min: Lowest version of uCode API supported by driver. | 284 | * @ucode_api_min: Lowest version of uCode API supported by driver. |
285 | * @max_inst_size: The maximal length of the fw inst section | 285 | * @max_inst_size: The maximal length of the fw inst section |
@@ -330,7 +330,7 @@ struct iwl_cfg { | |||
330 | /* params specific to an individual device within a device family */ | 330 | /* params specific to an individual device within a device family */ |
331 | const char *name; | 331 | const char *name; |
332 | const char *fw_name_pre; | 332 | const char *fw_name_pre; |
333 | const char *fw_name_pre_next_step; | 333 | const char *fw_name_pre_b_or_c_step; |
334 | const char *fw_name_pre_rf_next_step; | 334 | const char *fw_name_pre_rf_next_step; |
335 | /* params not likely to change within a device family */ | 335 | /* params not likely to change within a device family */ |
336 | const struct iwl_base_params *base_params; | 336 | const struct iwl_base_params *base_params; |
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-drv.c b/drivers/net/wireless/intel/iwlwifi/iwl-drv.c index 6fdb5921e17f..4e0f86fe0a6f 100644 --- a/drivers/net/wireless/intel/iwlwifi/iwl-drv.c +++ b/drivers/net/wireless/intel/iwlwifi/iwl-drv.c | |||
@@ -216,8 +216,9 @@ static int iwl_request_firmware(struct iwl_drv *drv, bool first) | |||
216 | const char *fw_pre_name; | 216 | const char *fw_pre_name; |
217 | 217 | ||
218 | if (drv->trans->cfg->device_family == IWL_DEVICE_FAMILY_9000 && | 218 | if (drv->trans->cfg->device_family == IWL_DEVICE_FAMILY_9000 && |
219 | CSR_HW_REV_STEP(drv->trans->hw_rev) == SILICON_B_STEP) | 219 | (CSR_HW_REV_STEP(drv->trans->hw_rev) == SILICON_B_STEP || |
220 | fw_pre_name = cfg->fw_name_pre_next_step; | 220 | CSR_HW_REV_STEP(drv->trans->hw_rev) == SILICON_C_STEP)) |
221 | fw_pre_name = cfg->fw_name_pre_b_or_c_step; | ||
221 | else if (drv->trans->cfg->integrated && | 222 | else if (drv->trans->cfg->integrated && |
222 | CSR_HW_RFID_STEP(drv->trans->hw_rf_id) == SILICON_B_STEP && | 223 | CSR_HW_RFID_STEP(drv->trans->hw_rf_id) == SILICON_B_STEP && |
223 | cfg->fw_name_pre_rf_next_step) | 224 | cfg->fw_name_pre_rf_next_step) |
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c b/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c index 5c08f4d40f6a..3ee6767392b6 100644 --- a/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c +++ b/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c | |||
@@ -785,7 +785,8 @@ iwl_parse_nvm_mcc_info(struct device *dev, const struct iwl_cfg *cfg, | |||
785 | int num_of_ch, __le32 *channels, u16 fw_mcc) | 785 | int num_of_ch, __le32 *channels, u16 fw_mcc) |
786 | { | 786 | { |
787 | int ch_idx; | 787 | int ch_idx; |
788 | u16 ch_flags, prev_ch_flags = 0; | 788 | u16 ch_flags; |
789 | u32 reg_rule_flags, prev_reg_rule_flags = 0; | ||
789 | const u8 *nvm_chan = cfg->ext_nvm ? | 790 | const u8 *nvm_chan = cfg->ext_nvm ? |
790 | iwl_ext_nvm_channels : iwl_nvm_channels; | 791 | iwl_ext_nvm_channels : iwl_nvm_channels; |
791 | struct ieee80211_regdomain *regd; | 792 | struct ieee80211_regdomain *regd; |
@@ -834,8 +835,11 @@ iwl_parse_nvm_mcc_info(struct device *dev, const struct iwl_cfg *cfg, | |||
834 | continue; | 835 | continue; |
835 | } | 836 | } |
836 | 837 | ||
838 | reg_rule_flags = iwl_nvm_get_regdom_bw_flags(nvm_chan, ch_idx, | ||
839 | ch_flags, cfg); | ||
840 | |||
837 | /* we can't continue the same rule */ | 841 | /* we can't continue the same rule */ |
838 | if (ch_idx == 0 || prev_ch_flags != ch_flags || | 842 | if (ch_idx == 0 || prev_reg_rule_flags != reg_rule_flags || |
839 | center_freq - prev_center_freq > 20) { | 843 | center_freq - prev_center_freq > 20) { |
840 | valid_rules++; | 844 | valid_rules++; |
841 | new_rule = true; | 845 | new_rule = true; |
@@ -854,18 +858,17 @@ iwl_parse_nvm_mcc_info(struct device *dev, const struct iwl_cfg *cfg, | |||
854 | rule->power_rule.max_eirp = | 858 | rule->power_rule.max_eirp = |
855 | DBM_TO_MBM(IWL_DEFAULT_MAX_TX_POWER); | 859 | DBM_TO_MBM(IWL_DEFAULT_MAX_TX_POWER); |
856 | 860 | ||
857 | rule->flags = iwl_nvm_get_regdom_bw_flags(nvm_chan, ch_idx, | 861 | rule->flags = reg_rule_flags; |
858 | ch_flags, cfg); | ||
859 | 862 | ||
860 | /* rely on auto-calculation to merge BW of contiguous chans */ | 863 | /* rely on auto-calculation to merge BW of contiguous chans */ |
861 | rule->flags |= NL80211_RRF_AUTO_BW; | 864 | rule->flags |= NL80211_RRF_AUTO_BW; |
862 | rule->freq_range.max_bandwidth_khz = 0; | 865 | rule->freq_range.max_bandwidth_khz = 0; |
863 | 866 | ||
864 | prev_ch_flags = ch_flags; | ||
865 | prev_center_freq = center_freq; | 867 | prev_center_freq = center_freq; |
868 | prev_reg_rule_flags = reg_rule_flags; | ||
866 | 869 | ||
867 | IWL_DEBUG_DEV(dev, IWL_DL_LAR, | 870 | IWL_DEBUG_DEV(dev, IWL_DL_LAR, |
868 | "Ch. %d [%sGHz] %s%s%s%s%s%s%s%s%s(0x%02x): Ad-Hoc %ssupported\n", | 871 | "Ch. %d [%sGHz] %s%s%s%s%s%s%s%s%s(0x%02x) reg_flags 0x%x: %s\n", |
869 | center_freq, | 872 | center_freq, |
870 | band == NL80211_BAND_5GHZ ? "5.2" : "2.4", | 873 | band == NL80211_BAND_5GHZ ? "5.2" : "2.4", |
871 | CHECK_AND_PRINT_I(VALID), | 874 | CHECK_AND_PRINT_I(VALID), |
@@ -877,10 +880,10 @@ iwl_parse_nvm_mcc_info(struct device *dev, const struct iwl_cfg *cfg, | |||
877 | CHECK_AND_PRINT_I(160MHZ), | 880 | CHECK_AND_PRINT_I(160MHZ), |
878 | CHECK_AND_PRINT_I(INDOOR_ONLY), | 881 | CHECK_AND_PRINT_I(INDOOR_ONLY), |
879 | CHECK_AND_PRINT_I(GO_CONCURRENT), | 882 | CHECK_AND_PRINT_I(GO_CONCURRENT), |
880 | ch_flags, | 883 | ch_flags, reg_rule_flags, |
881 | ((ch_flags & NVM_CHANNEL_ACTIVE) && | 884 | ((ch_flags & NVM_CHANNEL_ACTIVE) && |
882 | !(ch_flags & NVM_CHANNEL_RADAR)) | 885 | !(ch_flags & NVM_CHANNEL_RADAR)) |
883 | ? "" : "not "); | 886 | ? "Ad-Hoc" : ""); |
884 | } | 887 | } |
885 | 888 | ||
886 | regd->n_reg_rules = valid_rules; | 889 | regd->n_reg_rules = valid_rules; |
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/fw.c b/drivers/net/wireless/intel/iwlwifi/mvm/fw.c index 79e7a7a285dc..82863e9273eb 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/fw.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/fw.c | |||
@@ -1275,8 +1275,10 @@ static int iwl_mvm_sar_get_wgds_table(struct iwl_mvm *mvm) | |||
1275 | 1275 | ||
1276 | entry = &wifi_pkg->package.elements[idx++]; | 1276 | entry = &wifi_pkg->package.elements[idx++]; |
1277 | if ((entry->type != ACPI_TYPE_INTEGER) || | 1277 | if ((entry->type != ACPI_TYPE_INTEGER) || |
1278 | (entry->integer.value > U8_MAX)) | 1278 | (entry->integer.value > U8_MAX)) { |
1279 | return -EINVAL; | 1279 | ret = -EINVAL; |
1280 | goto out_free; | ||
1281 | } | ||
1280 | 1282 | ||
1281 | mvm->geo_profiles[i].values[j] = entry->integer.value; | 1283 | mvm->geo_profiles[i].values[j] = entry->integer.value; |
1282 | } | 1284 | } |
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c index c7b1e58e3384..ce901be5fba8 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c | |||
@@ -2597,8 +2597,18 @@ static void iwl_mvm_purge_deferred_tx_frames(struct iwl_mvm *mvm, | |||
2597 | spin_lock_bh(&mvm_sta->lock); | 2597 | spin_lock_bh(&mvm_sta->lock); |
2598 | for (i = 0; i <= IWL_MAX_TID_COUNT; i++) { | 2598 | for (i = 0; i <= IWL_MAX_TID_COUNT; i++) { |
2599 | tid_data = &mvm_sta->tid_data[i]; | 2599 | tid_data = &mvm_sta->tid_data[i]; |
2600 | while ((skb = __skb_dequeue(&tid_data->deferred_tx_frames))) | 2600 | |
2601 | while ((skb = __skb_dequeue(&tid_data->deferred_tx_frames))) { | ||
2602 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | ||
2603 | |||
2604 | /* | ||
2605 | * The first deferred frame should've stopped the MAC | ||
2606 | * queues, so we should never get a second deferred | ||
2607 | * frame for the RA/TID. | ||
2608 | */ | ||
2609 | iwl_mvm_start_mac_queues(mvm, info->hw_queue); | ||
2601 | ieee80211_free_txskb(mvm->hw, skb); | 2610 | ieee80211_free_txskb(mvm->hw, skb); |
2611 | } | ||
2602 | } | 2612 | } |
2603 | spin_unlock_bh(&mvm_sta->lock); | 2613 | spin_unlock_bh(&mvm_sta->lock); |
2604 | } | 2614 | } |
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/rs.c b/drivers/net/wireless/intel/iwlwifi/mvm/rs.c index 65beca3a457a..8999a1199d60 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/rs.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/rs.c | |||
@@ -1291,7 +1291,7 @@ void iwl_mvm_rs_tx_status(struct iwl_mvm *mvm, struct ieee80211_sta *sta, | |||
1291 | * first index into rate scale table. | 1291 | * first index into rate scale table. |
1292 | */ | 1292 | */ |
1293 | if (info->flags & IEEE80211_TX_STAT_AMPDU) { | 1293 | if (info->flags & IEEE80211_TX_STAT_AMPDU) { |
1294 | rs_collect_tpc_data(mvm, lq_sta, curr_tbl, lq_rate.index, | 1294 | rs_collect_tpc_data(mvm, lq_sta, curr_tbl, tx_resp_rate.index, |
1295 | info->status.ampdu_len, | 1295 | info->status.ampdu_len, |
1296 | info->status.ampdu_ack_len, | 1296 | info->status.ampdu_ack_len, |
1297 | reduced_txp); | 1297 | reduced_txp); |
@@ -1312,7 +1312,7 @@ void iwl_mvm_rs_tx_status(struct iwl_mvm *mvm, struct ieee80211_sta *sta, | |||
1312 | if (info->status.ampdu_ack_len == 0) | 1312 | if (info->status.ampdu_ack_len == 0) |
1313 | info->status.ampdu_len = 1; | 1313 | info->status.ampdu_len = 1; |
1314 | 1314 | ||
1315 | rs_collect_tlc_data(mvm, lq_sta, curr_tbl, lq_rate.index, | 1315 | rs_collect_tlc_data(mvm, lq_sta, curr_tbl, tx_resp_rate.index, |
1316 | info->status.ampdu_len, | 1316 | info->status.ampdu_len, |
1317 | info->status.ampdu_ack_len); | 1317 | info->status.ampdu_ack_len); |
1318 | 1318 | ||
@@ -1348,11 +1348,11 @@ void iwl_mvm_rs_tx_status(struct iwl_mvm *mvm, struct ieee80211_sta *sta, | |||
1348 | continue; | 1348 | continue; |
1349 | 1349 | ||
1350 | rs_collect_tpc_data(mvm, lq_sta, tmp_tbl, | 1350 | rs_collect_tpc_data(mvm, lq_sta, tmp_tbl, |
1351 | lq_rate.index, 1, | 1351 | tx_resp_rate.index, 1, |
1352 | i < retries ? 0 : legacy_success, | 1352 | i < retries ? 0 : legacy_success, |
1353 | reduced_txp); | 1353 | reduced_txp); |
1354 | rs_collect_tlc_data(mvm, lq_sta, tmp_tbl, | 1354 | rs_collect_tlc_data(mvm, lq_sta, tmp_tbl, |
1355 | lq_rate.index, 1, | 1355 | tx_resp_rate.index, 1, |
1356 | i < retries ? 0 : legacy_success); | 1356 | i < retries ? 0 : legacy_success); |
1357 | } | 1357 | } |
1358 | 1358 | ||
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c b/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c index f3e608196369..71c8b800ffa9 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c | |||
@@ -636,9 +636,9 @@ static bool iwl_mvm_reorder(struct iwl_mvm *mvm, | |||
636 | 636 | ||
637 | baid_data = rcu_dereference(mvm->baid_map[baid]); | 637 | baid_data = rcu_dereference(mvm->baid_map[baid]); |
638 | if (!baid_data) { | 638 | if (!baid_data) { |
639 | WARN(!(reorder & IWL_RX_MPDU_REORDER_BA_OLD_SN), | 639 | IWL_DEBUG_RX(mvm, |
640 | "Received baid %d, but no data exists for this BAID\n", | 640 | "Got valid BAID but no baid allocated, bypass the re-ordering buffer. Baid %d reorder 0x%x\n", |
641 | baid); | 641 | baid, reorder); |
642 | return false; | 642 | return false; |
643 | } | 643 | } |
644 | 644 | ||
@@ -759,7 +759,9 @@ static void iwl_mvm_agg_rx_received(struct iwl_mvm *mvm, | |||
759 | 759 | ||
760 | data = rcu_dereference(mvm->baid_map[baid]); | 760 | data = rcu_dereference(mvm->baid_map[baid]); |
761 | if (!data) { | 761 | if (!data) { |
762 | WARN_ON(!(reorder_data & IWL_RX_MPDU_REORDER_BA_OLD_SN)); | 762 | IWL_DEBUG_RX(mvm, |
763 | "Got valid BAID but no baid allocated, bypass the re-ordering buffer. Baid %d reorder 0x%x\n", | ||
764 | baid, reorder_data); | ||
763 | goto out; | 765 | goto out; |
764 | } | 766 | } |
765 | 767 | ||
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/sta.c b/drivers/net/wireless/intel/iwlwifi/mvm/sta.c index ab66b4394dfc..027ee5e72172 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/sta.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/sta.c | |||
@@ -121,7 +121,8 @@ int iwl_mvm_sta_send_to_fw(struct iwl_mvm *mvm, struct ieee80211_sta *sta, | |||
121 | .mac_id_n_color = cpu_to_le32(mvm_sta->mac_id_n_color), | 121 | .mac_id_n_color = cpu_to_le32(mvm_sta->mac_id_n_color), |
122 | .add_modify = update ? 1 : 0, | 122 | .add_modify = update ? 1 : 0, |
123 | .station_flags_msk = cpu_to_le32(STA_FLG_FAT_EN_MSK | | 123 | .station_flags_msk = cpu_to_le32(STA_FLG_FAT_EN_MSK | |
124 | STA_FLG_MIMO_EN_MSK), | 124 | STA_FLG_MIMO_EN_MSK | |
125 | STA_FLG_RTS_MIMO_PROT), | ||
125 | .tid_disable_tx = cpu_to_le16(mvm_sta->tid_disable_agg), | 126 | .tid_disable_tx = cpu_to_le16(mvm_sta->tid_disable_agg), |
126 | }; | 127 | }; |
127 | int ret; | 128 | int ret; |
@@ -290,8 +291,8 @@ static void iwl_mvm_rx_agg_session_expired(unsigned long data) | |||
290 | goto unlock; | 291 | goto unlock; |
291 | 292 | ||
292 | mvm_sta = iwl_mvm_sta_from_mac80211(sta); | 293 | mvm_sta = iwl_mvm_sta_from_mac80211(sta); |
293 | ieee80211_stop_rx_ba_session_offl(mvm_sta->vif, | 294 | ieee80211_rx_ba_timer_expired(mvm_sta->vif, |
294 | sta->addr, ba_data->tid); | 295 | sta->addr, ba_data->tid); |
295 | unlock: | 296 | unlock: |
296 | rcu_read_unlock(); | 297 | rcu_read_unlock(); |
297 | } | 298 | } |
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/tx.c b/drivers/net/wireless/intel/iwlwifi/mvm/tx.c index 60360ed73f26..5fcc9dd6be56 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/tx.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/tx.c | |||
@@ -185,8 +185,14 @@ static u16 iwl_mvm_tx_csum(struct iwl_mvm *mvm, struct sk_buff *skb, | |||
185 | else | 185 | else |
186 | udp_hdr(skb)->check = 0; | 186 | udp_hdr(skb)->check = 0; |
187 | 187 | ||
188 | /* mac header len should include IV, size is in words */ | 188 | /* |
189 | if (info->control.hw_key) | 189 | * mac header len should include IV, size is in words unless |
190 | * the IV is added by the firmware like in WEP. | ||
191 | * In new Tx API, the IV is always added by the firmware. | ||
192 | */ | ||
193 | if (!iwl_mvm_has_new_tx_api(mvm) && info->control.hw_key && | ||
194 | info->control.hw_key->cipher != WLAN_CIPHER_SUITE_WEP40 && | ||
195 | info->control.hw_key->cipher != WLAN_CIPHER_SUITE_WEP104) | ||
190 | mh_len += info->control.hw_key->iv_len; | 196 | mh_len += info->control.hw_key->iv_len; |
191 | mh_len /= 2; | 197 | mh_len /= 2; |
192 | offload_assist |= mh_len << TX_CMD_OFFLD_MH_SIZE; | 198 | offload_assist |= mh_len << TX_CMD_OFFLD_MH_SIZE; |
@@ -1815,6 +1821,8 @@ void iwl_mvm_rx_ba_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb) | |||
1815 | struct iwl_mvm_tid_data *tid_data; | 1821 | struct iwl_mvm_tid_data *tid_data; |
1816 | struct iwl_mvm_sta *mvmsta; | 1822 | struct iwl_mvm_sta *mvmsta; |
1817 | 1823 | ||
1824 | ba_info.flags = IEEE80211_TX_STAT_AMPDU; | ||
1825 | |||
1818 | if (iwl_mvm_has_new_tx_api(mvm)) { | 1826 | if (iwl_mvm_has_new_tx_api(mvm)) { |
1819 | struct iwl_mvm_compressed_ba_notif *ba_res = | 1827 | struct iwl_mvm_compressed_ba_notif *ba_res = |
1820 | (void *)pkt->data; | 1828 | (void *)pkt->data; |
diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/drv.c b/drivers/net/wireless/intel/iwlwifi/pcie/drv.c index f16c1bb9bf94..84f4ba01e14f 100644 --- a/drivers/net/wireless/intel/iwlwifi/pcie/drv.c +++ b/drivers/net/wireless/intel/iwlwifi/pcie/drv.c | |||
@@ -510,9 +510,17 @@ static const struct pci_device_id iwl_hw_card_ids[] = { | |||
510 | 510 | ||
511 | /* 9000 Series */ | 511 | /* 9000 Series */ |
512 | {IWL_PCI_DEVICE(0x271B, 0x0010, iwl9160_2ac_cfg)}, | 512 | {IWL_PCI_DEVICE(0x271B, 0x0010, iwl9160_2ac_cfg)}, |
513 | {IWL_PCI_DEVICE(0x271B, 0x0014, iwl9160_2ac_cfg)}, | ||
514 | {IWL_PCI_DEVICE(0x271B, 0x0210, iwl9160_2ac_cfg)}, | ||
513 | {IWL_PCI_DEVICE(0x2526, 0x0000, iwl9260_2ac_cfg)}, | 515 | {IWL_PCI_DEVICE(0x2526, 0x0000, iwl9260_2ac_cfg)}, |
514 | {IWL_PCI_DEVICE(0x2526, 0x0010, iwl9260_2ac_cfg)}, | 516 | {IWL_PCI_DEVICE(0x2526, 0x0010, iwl9260_2ac_cfg)}, |
517 | {IWL_PCI_DEVICE(0x2526, 0x0014, iwl9260_2ac_cfg)}, | ||
518 | {IWL_PCI_DEVICE(0x2526, 0xA014, iwl9260_2ac_cfg)}, | ||
519 | {IWL_PCI_DEVICE(0x2526, 0x4010, iwl9260_2ac_cfg)}, | ||
520 | {IWL_PCI_DEVICE(0x2526, 0x0210, iwl9260_2ac_cfg)}, | ||
521 | {IWL_PCI_DEVICE(0x2526, 0x0214, iwl9260_2ac_cfg)}, | ||
515 | {IWL_PCI_DEVICE(0x2526, 0x1410, iwl9270_2ac_cfg)}, | 522 | {IWL_PCI_DEVICE(0x2526, 0x1410, iwl9270_2ac_cfg)}, |
523 | {IWL_PCI_DEVICE(0x2526, 0x1610, iwl9270_2ac_cfg)}, | ||
516 | {IWL_PCI_DEVICE(0x9DF0, 0x0A10, iwl9460_2ac_cfg)}, | 524 | {IWL_PCI_DEVICE(0x9DF0, 0x0A10, iwl9460_2ac_cfg)}, |
517 | {IWL_PCI_DEVICE(0x9DF0, 0x0010, iwl9460_2ac_cfg)}, | 525 | {IWL_PCI_DEVICE(0x9DF0, 0x0010, iwl9460_2ac_cfg)}, |
518 | {IWL_PCI_DEVICE(0x9DF0, 0x0210, iwl9460_2ac_cfg)}, | 526 | {IWL_PCI_DEVICE(0x9DF0, 0x0210, iwl9460_2ac_cfg)}, |
@@ -527,10 +535,22 @@ static const struct pci_device_id iwl_hw_card_ids[] = { | |||
527 | {IWL_PCI_DEVICE(0x9DF0, 0x2A10, iwl9460_2ac_cfg)}, | 535 | {IWL_PCI_DEVICE(0x9DF0, 0x2A10, iwl9460_2ac_cfg)}, |
528 | {IWL_PCI_DEVICE(0x30DC, 0x0060, iwl9460_2ac_cfg)}, | 536 | {IWL_PCI_DEVICE(0x30DC, 0x0060, iwl9460_2ac_cfg)}, |
529 | {IWL_PCI_DEVICE(0x2526, 0x0060, iwl9460_2ac_cfg)}, | 537 | {IWL_PCI_DEVICE(0x2526, 0x0060, iwl9460_2ac_cfg)}, |
538 | {IWL_PCI_DEVICE(0x2526, 0x0260, iwl9460_2ac_cfg)}, | ||
539 | {IWL_PCI_DEVICE(0x2526, 0x0064, iwl9460_2ac_cfg)}, | ||
540 | {IWL_PCI_DEVICE(0x2526, 0x00A4, iwl9460_2ac_cfg)}, | ||
541 | {IWL_PCI_DEVICE(0x2526, 0x40A4, iwl9460_2ac_cfg)}, | ||
542 | {IWL_PCI_DEVICE(0x2526, 0x02A4, iwl9460_2ac_cfg)}, | ||
543 | {IWL_PCI_DEVICE(0x2526, 0x00A0, iwl9460_2ac_cfg)}, | ||
544 | {IWL_PCI_DEVICE(0x2526, 0x02A0, iwl9460_2ac_cfg)}, | ||
530 | {IWL_PCI_DEVICE(0x9DF0, 0x0060, iwl9460_2ac_cfg)}, | 545 | {IWL_PCI_DEVICE(0x9DF0, 0x0060, iwl9460_2ac_cfg)}, |
531 | {IWL_PCI_DEVICE(0xA370, 0x0060, iwl9460_2ac_cfg)}, | 546 | {IWL_PCI_DEVICE(0xA370, 0x0060, iwl9460_2ac_cfg)}, |
532 | {IWL_PCI_DEVICE(0x31DC, 0x0060, iwl9460_2ac_cfg)}, | 547 | {IWL_PCI_DEVICE(0x31DC, 0x0060, iwl9460_2ac_cfg)}, |
533 | {IWL_PCI_DEVICE(0x2526, 0x0030, iwl9560_2ac_cfg)}, | 548 | {IWL_PCI_DEVICE(0x2526, 0x0030, iwl9560_2ac_cfg)}, |
549 | {IWL_PCI_DEVICE(0x2526, 0x4030, iwl9560_2ac_cfg)}, | ||
550 | {IWL_PCI_DEVICE(0x2526, 0x0230, iwl9560_2ac_cfg)}, | ||
551 | {IWL_PCI_DEVICE(0x2526, 0x0234, iwl9560_2ac_cfg)}, | ||
552 | {IWL_PCI_DEVICE(0x2526, 0x0238, iwl9560_2ac_cfg)}, | ||
553 | {IWL_PCI_DEVICE(0x2526, 0x023C, iwl9560_2ac_cfg)}, | ||
534 | {IWL_PCI_DEVICE(0x9DF0, 0x0030, iwl9560_2ac_cfg)}, | 554 | {IWL_PCI_DEVICE(0x9DF0, 0x0030, iwl9560_2ac_cfg)}, |
535 | {IWL_PCI_DEVICE(0xA370, 0x0030, iwl9560_2ac_cfg)}, | 555 | {IWL_PCI_DEVICE(0xA370, 0x0030, iwl9560_2ac_cfg)}, |
536 | {IWL_PCI_DEVICE(0x31DC, 0x0030, iwl9560_2ac_cfg)}, | 556 | {IWL_PCI_DEVICE(0x31DC, 0x0030, iwl9560_2ac_cfg)}, |
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index c49f1f8b2e57..37046ac2c441 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c | |||
@@ -336,7 +336,7 @@ static int nvme_get_stream_params(struct nvme_ctrl *ctrl, | |||
336 | 336 | ||
337 | c.directive.opcode = nvme_admin_directive_recv; | 337 | c.directive.opcode = nvme_admin_directive_recv; |
338 | c.directive.nsid = cpu_to_le32(nsid); | 338 | c.directive.nsid = cpu_to_le32(nsid); |
339 | c.directive.numd = cpu_to_le32(sizeof(*s)); | 339 | c.directive.numd = cpu_to_le32((sizeof(*s) >> 2) - 1); |
340 | c.directive.doper = NVME_DIR_RCV_ST_OP_PARAM; | 340 | c.directive.doper = NVME_DIR_RCV_ST_OP_PARAM; |
341 | c.directive.dtype = NVME_DIR_STREAMS; | 341 | c.directive.dtype = NVME_DIR_STREAMS; |
342 | 342 | ||
@@ -1509,7 +1509,7 @@ static void nvme_set_queue_limits(struct nvme_ctrl *ctrl, | |||
1509 | blk_queue_write_cache(q, vwc, vwc); | 1509 | blk_queue_write_cache(q, vwc, vwc); |
1510 | } | 1510 | } |
1511 | 1511 | ||
1512 | static void nvme_configure_apst(struct nvme_ctrl *ctrl) | 1512 | static int nvme_configure_apst(struct nvme_ctrl *ctrl) |
1513 | { | 1513 | { |
1514 | /* | 1514 | /* |
1515 | * APST (Autonomous Power State Transition) lets us program a | 1515 | * APST (Autonomous Power State Transition) lets us program a |
@@ -1538,16 +1538,16 @@ static void nvme_configure_apst(struct nvme_ctrl *ctrl) | |||
1538 | * then don't do anything. | 1538 | * then don't do anything. |
1539 | */ | 1539 | */ |
1540 | if (!ctrl->apsta) | 1540 | if (!ctrl->apsta) |
1541 | return; | 1541 | return 0; |
1542 | 1542 | ||
1543 | if (ctrl->npss > 31) { | 1543 | if (ctrl->npss > 31) { |
1544 | dev_warn(ctrl->device, "NPSS is invalid; not using APST\n"); | 1544 | dev_warn(ctrl->device, "NPSS is invalid; not using APST\n"); |
1545 | return; | 1545 | return 0; |
1546 | } | 1546 | } |
1547 | 1547 | ||
1548 | table = kzalloc(sizeof(*table), GFP_KERNEL); | 1548 | table = kzalloc(sizeof(*table), GFP_KERNEL); |
1549 | if (!table) | 1549 | if (!table) |
1550 | return; | 1550 | return 0; |
1551 | 1551 | ||
1552 | if (!ctrl->apst_enabled || ctrl->ps_max_latency_us == 0) { | 1552 | if (!ctrl->apst_enabled || ctrl->ps_max_latency_us == 0) { |
1553 | /* Turn off APST. */ | 1553 | /* Turn off APST. */ |
@@ -1629,6 +1629,7 @@ static void nvme_configure_apst(struct nvme_ctrl *ctrl) | |||
1629 | dev_err(ctrl->device, "failed to set APST feature (%d)\n", ret); | 1629 | dev_err(ctrl->device, "failed to set APST feature (%d)\n", ret); |
1630 | 1630 | ||
1631 | kfree(table); | 1631 | kfree(table); |
1632 | return ret; | ||
1632 | } | 1633 | } |
1633 | 1634 | ||
1634 | static void nvme_set_latency_tolerance(struct device *dev, s32 val) | 1635 | static void nvme_set_latency_tolerance(struct device *dev, s32 val) |
@@ -1835,13 +1836,16 @@ int nvme_init_identify(struct nvme_ctrl *ctrl) | |||
1835 | * In fabrics we need to verify the cntlid matches the | 1836 | * In fabrics we need to verify the cntlid matches the |
1836 | * admin connect | 1837 | * admin connect |
1837 | */ | 1838 | */ |
1838 | if (ctrl->cntlid != le16_to_cpu(id->cntlid)) | 1839 | if (ctrl->cntlid != le16_to_cpu(id->cntlid)) { |
1839 | ret = -EINVAL; | 1840 | ret = -EINVAL; |
1841 | goto out_free; | ||
1842 | } | ||
1840 | 1843 | ||
1841 | if (!ctrl->opts->discovery_nqn && !ctrl->kas) { | 1844 | if (!ctrl->opts->discovery_nqn && !ctrl->kas) { |
1842 | dev_err(ctrl->device, | 1845 | dev_err(ctrl->device, |
1843 | "keep-alive support is mandatory for fabrics\n"); | 1846 | "keep-alive support is mandatory for fabrics\n"); |
1844 | ret = -EINVAL; | 1847 | ret = -EINVAL; |
1848 | goto out_free; | ||
1845 | } | 1849 | } |
1846 | } else { | 1850 | } else { |
1847 | ctrl->cntlid = le16_to_cpu(id->cntlid); | 1851 | ctrl->cntlid = le16_to_cpu(id->cntlid); |
@@ -1856,11 +1860,20 @@ int nvme_init_identify(struct nvme_ctrl *ctrl) | |||
1856 | else if (!ctrl->apst_enabled && prev_apst_enabled) | 1860 | else if (!ctrl->apst_enabled && prev_apst_enabled) |
1857 | dev_pm_qos_hide_latency_tolerance(ctrl->device); | 1861 | dev_pm_qos_hide_latency_tolerance(ctrl->device); |
1858 | 1862 | ||
1859 | nvme_configure_apst(ctrl); | 1863 | ret = nvme_configure_apst(ctrl); |
1860 | nvme_configure_directives(ctrl); | 1864 | if (ret < 0) |
1865 | return ret; | ||
1866 | |||
1867 | ret = nvme_configure_directives(ctrl); | ||
1868 | if (ret < 0) | ||
1869 | return ret; | ||
1861 | 1870 | ||
1862 | ctrl->identified = true; | 1871 | ctrl->identified = true; |
1863 | 1872 | ||
1873 | return 0; | ||
1874 | |||
1875 | out_free: | ||
1876 | kfree(id); | ||
1864 | return ret; | 1877 | return ret; |
1865 | } | 1878 | } |
1866 | EXPORT_SYMBOL_GPL(nvme_init_identify); | 1879 | EXPORT_SYMBOL_GPL(nvme_init_identify); |
@@ -2004,9 +2017,11 @@ static ssize_t wwid_show(struct device *dev, struct device_attribute *attr, | |||
2004 | if (memchr_inv(ns->eui, 0, sizeof(ns->eui))) | 2017 | if (memchr_inv(ns->eui, 0, sizeof(ns->eui))) |
2005 | return sprintf(buf, "eui.%8phN\n", ns->eui); | 2018 | return sprintf(buf, "eui.%8phN\n", ns->eui); |
2006 | 2019 | ||
2007 | while (ctrl->serial[serial_len - 1] == ' ') | 2020 | while (serial_len > 0 && (ctrl->serial[serial_len - 1] == ' ' || |
2021 | ctrl->serial[serial_len - 1] == '\0')) | ||
2008 | serial_len--; | 2022 | serial_len--; |
2009 | while (ctrl->model[model_len - 1] == ' ') | 2023 | while (model_len > 0 && (ctrl->model[model_len - 1] == ' ' || |
2024 | ctrl->model[model_len - 1] == '\0')) | ||
2010 | model_len--; | 2025 | model_len--; |
2011 | 2026 | ||
2012 | return sprintf(buf, "nvme.%04x-%*phN-%*phN-%08x\n", ctrl->vid, | 2027 | return sprintf(buf, "nvme.%04x-%*phN-%*phN-%08x\n", ctrl->vid, |
diff --git a/drivers/nvme/host/fabrics.c b/drivers/nvme/host/fabrics.c index 2e582a240943..5f5cd306f76d 100644 --- a/drivers/nvme/host/fabrics.c +++ b/drivers/nvme/host/fabrics.c | |||
@@ -794,7 +794,8 @@ static int nvmf_check_allowed_opts(struct nvmf_ctrl_options *opts, | |||
794 | int i; | 794 | int i; |
795 | 795 | ||
796 | for (i = 0; i < ARRAY_SIZE(opt_tokens); i++) { | 796 | for (i = 0; i < ARRAY_SIZE(opt_tokens); i++) { |
797 | if (opt_tokens[i].token & ~allowed_opts) { | 797 | if ((opt_tokens[i].token & opts->mask) && |
798 | (opt_tokens[i].token & ~allowed_opts)) { | ||
798 | pr_warn("invalid parameter '%s'\n", | 799 | pr_warn("invalid parameter '%s'\n", |
799 | opt_tokens[i].pattern); | 800 | opt_tokens[i].pattern); |
800 | } | 801 | } |
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index cd888a47d0fc..925467b31a33 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c | |||
@@ -801,6 +801,7 @@ static inline void nvme_handle_cqe(struct nvme_queue *nvmeq, | |||
801 | return; | 801 | return; |
802 | } | 802 | } |
803 | 803 | ||
804 | nvmeq->cqe_seen = 1; | ||
804 | req = blk_mq_tag_to_rq(*nvmeq->tags, cqe->command_id); | 805 | req = blk_mq_tag_to_rq(*nvmeq->tags, cqe->command_id); |
805 | nvme_end_request(req, cqe->status, cqe->result); | 806 | nvme_end_request(req, cqe->status, cqe->result); |
806 | } | 807 | } |
@@ -830,10 +831,8 @@ static void nvme_process_cq(struct nvme_queue *nvmeq) | |||
830 | consumed++; | 831 | consumed++; |
831 | } | 832 | } |
832 | 833 | ||
833 | if (consumed) { | 834 | if (consumed) |
834 | nvme_ring_cq_doorbell(nvmeq); | 835 | nvme_ring_cq_doorbell(nvmeq); |
835 | nvmeq->cqe_seen = 1; | ||
836 | } | ||
837 | } | 836 | } |
838 | 837 | ||
839 | static irqreturn_t nvme_irq(int irq, void *data) | 838 | static irqreturn_t nvme_irq(int irq, void *data) |
@@ -1558,11 +1557,9 @@ static inline void nvme_release_cmb(struct nvme_dev *dev) | |||
1558 | if (dev->cmb) { | 1557 | if (dev->cmb) { |
1559 | iounmap(dev->cmb); | 1558 | iounmap(dev->cmb); |
1560 | dev->cmb = NULL; | 1559 | dev->cmb = NULL; |
1561 | if (dev->cmbsz) { | 1560 | sysfs_remove_file_from_group(&dev->ctrl.device->kobj, |
1562 | sysfs_remove_file_from_group(&dev->ctrl.device->kobj, | 1561 | &dev_attr_cmb.attr, NULL); |
1563 | &dev_attr_cmb.attr, NULL); | 1562 | dev->cmbsz = 0; |
1564 | dev->cmbsz = 0; | ||
1565 | } | ||
1566 | } | 1563 | } |
1567 | } | 1564 | } |
1568 | 1565 | ||
@@ -1953,16 +1950,14 @@ static int nvme_pci_enable(struct nvme_dev *dev) | |||
1953 | 1950 | ||
1954 | /* | 1951 | /* |
1955 | * CMBs can currently only exist on >=1.2 PCIe devices. We only | 1952 | * CMBs can currently only exist on >=1.2 PCIe devices. We only |
1956 | * populate sysfs if a CMB is implemented. Note that we add the | 1953 | * populate sysfs if a CMB is implemented. Since nvme_dev_attrs_group |
1957 | * CMB attribute to the nvme_ctrl kobj which removes the need to remove | 1954 | * has no name we can pass NULL as final argument to |
1958 | * it on exit. Since nvme_dev_attrs_group has no name we can pass | 1955 | * sysfs_add_file_to_group. |
1959 | * NULL as final argument to sysfs_add_file_to_group. | ||
1960 | */ | 1956 | */ |
1961 | 1957 | ||
1962 | if (readl(dev->bar + NVME_REG_VS) >= NVME_VS(1, 2, 0)) { | 1958 | if (readl(dev->bar + NVME_REG_VS) >= NVME_VS(1, 2, 0)) { |
1963 | dev->cmb = nvme_map_cmb(dev); | 1959 | dev->cmb = nvme_map_cmb(dev); |
1964 | 1960 | if (dev->cmb) { | |
1965 | if (dev->cmbsz) { | ||
1966 | if (sysfs_add_file_to_group(&dev->ctrl.device->kobj, | 1961 | if (sysfs_add_file_to_group(&dev->ctrl.device->kobj, |
1967 | &dev_attr_cmb.attr, NULL)) | 1962 | &dev_attr_cmb.attr, NULL)) |
1968 | dev_warn(dev->ctrl.device, | 1963 | dev_warn(dev->ctrl.device, |
diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c index 2d7a98ab53fb..a53bb6635b83 100644 --- a/drivers/nvme/target/admin-cmd.c +++ b/drivers/nvme/target/admin-cmd.c | |||
@@ -199,12 +199,6 @@ static void nvmet_execute_identify_ctrl(struct nvmet_req *req) | |||
199 | copy_and_pad(id->mn, sizeof(id->mn), model, sizeof(model) - 1); | 199 | copy_and_pad(id->mn, sizeof(id->mn), model, sizeof(model) - 1); |
200 | copy_and_pad(id->fr, sizeof(id->fr), UTS_RELEASE, strlen(UTS_RELEASE)); | 200 | copy_and_pad(id->fr, sizeof(id->fr), UTS_RELEASE, strlen(UTS_RELEASE)); |
201 | 201 | ||
202 | memset(id->mn, ' ', sizeof(id->mn)); | ||
203 | strncpy((char *)id->mn, "Linux", sizeof(id->mn)); | ||
204 | |||
205 | memset(id->fr, ' ', sizeof(id->fr)); | ||
206 | strncpy((char *)id->fr, UTS_RELEASE, sizeof(id->fr)); | ||
207 | |||
208 | id->rab = 6; | 202 | id->rab = 6; |
209 | 203 | ||
210 | /* | 204 | /* |
diff --git a/drivers/nvme/target/fc.c b/drivers/nvme/target/fc.c index 31ca55dfcb1d..309c84aa7595 100644 --- a/drivers/nvme/target/fc.c +++ b/drivers/nvme/target/fc.c | |||
@@ -114,6 +114,11 @@ struct nvmet_fc_tgtport { | |||
114 | struct kref ref; | 114 | struct kref ref; |
115 | }; | 115 | }; |
116 | 116 | ||
117 | struct nvmet_fc_defer_fcp_req { | ||
118 | struct list_head req_list; | ||
119 | struct nvmefc_tgt_fcp_req *fcp_req; | ||
120 | }; | ||
121 | |||
117 | struct nvmet_fc_tgt_queue { | 122 | struct nvmet_fc_tgt_queue { |
118 | bool ninetypercent; | 123 | bool ninetypercent; |
119 | u16 qid; | 124 | u16 qid; |
@@ -132,6 +137,8 @@ struct nvmet_fc_tgt_queue { | |||
132 | struct nvmet_fc_tgt_assoc *assoc; | 137 | struct nvmet_fc_tgt_assoc *assoc; |
133 | struct nvmet_fc_fcp_iod *fod; /* array of fcp_iods */ | 138 | struct nvmet_fc_fcp_iod *fod; /* array of fcp_iods */ |
134 | struct list_head fod_list; | 139 | struct list_head fod_list; |
140 | struct list_head pending_cmd_list; | ||
141 | struct list_head avail_defer_list; | ||
135 | struct workqueue_struct *work_q; | 142 | struct workqueue_struct *work_q; |
136 | struct kref ref; | 143 | struct kref ref; |
137 | } __aligned(sizeof(unsigned long long)); | 144 | } __aligned(sizeof(unsigned long long)); |
@@ -223,6 +230,8 @@ static void nvmet_fc_tgt_q_put(struct nvmet_fc_tgt_queue *queue); | |||
223 | static int nvmet_fc_tgt_q_get(struct nvmet_fc_tgt_queue *queue); | 230 | static int nvmet_fc_tgt_q_get(struct nvmet_fc_tgt_queue *queue); |
224 | static void nvmet_fc_tgtport_put(struct nvmet_fc_tgtport *tgtport); | 231 | static void nvmet_fc_tgtport_put(struct nvmet_fc_tgtport *tgtport); |
225 | static int nvmet_fc_tgtport_get(struct nvmet_fc_tgtport *tgtport); | 232 | static int nvmet_fc_tgtport_get(struct nvmet_fc_tgtport *tgtport); |
233 | static void nvmet_fc_handle_fcp_rqst(struct nvmet_fc_tgtport *tgtport, | ||
234 | struct nvmet_fc_fcp_iod *fod); | ||
226 | 235 | ||
227 | 236 | ||
228 | /* *********************** FC-NVME DMA Handling **************************** */ | 237 | /* *********************** FC-NVME DMA Handling **************************** */ |
@@ -385,7 +394,7 @@ nvmet_fc_free_ls_iodlist(struct nvmet_fc_tgtport *tgtport) | |||
385 | static struct nvmet_fc_ls_iod * | 394 | static struct nvmet_fc_ls_iod * |
386 | nvmet_fc_alloc_ls_iod(struct nvmet_fc_tgtport *tgtport) | 395 | nvmet_fc_alloc_ls_iod(struct nvmet_fc_tgtport *tgtport) |
387 | { | 396 | { |
388 | static struct nvmet_fc_ls_iod *iod; | 397 | struct nvmet_fc_ls_iod *iod; |
389 | unsigned long flags; | 398 | unsigned long flags; |
390 | 399 | ||
391 | spin_lock_irqsave(&tgtport->lock, flags); | 400 | spin_lock_irqsave(&tgtport->lock, flags); |
@@ -462,10 +471,10 @@ nvmet_fc_destroy_fcp_iodlist(struct nvmet_fc_tgtport *tgtport, | |||
462 | static struct nvmet_fc_fcp_iod * | 471 | static struct nvmet_fc_fcp_iod * |
463 | nvmet_fc_alloc_fcp_iod(struct nvmet_fc_tgt_queue *queue) | 472 | nvmet_fc_alloc_fcp_iod(struct nvmet_fc_tgt_queue *queue) |
464 | { | 473 | { |
465 | static struct nvmet_fc_fcp_iod *fod; | 474 | struct nvmet_fc_fcp_iod *fod; |
466 | unsigned long flags; | 475 | |
476 | lockdep_assert_held(&queue->qlock); | ||
467 | 477 | ||
468 | spin_lock_irqsave(&queue->qlock, flags); | ||
469 | fod = list_first_entry_or_null(&queue->fod_list, | 478 | fod = list_first_entry_or_null(&queue->fod_list, |
470 | struct nvmet_fc_fcp_iod, fcp_list); | 479 | struct nvmet_fc_fcp_iod, fcp_list); |
471 | if (fod) { | 480 | if (fod) { |
@@ -477,17 +486,37 @@ nvmet_fc_alloc_fcp_iod(struct nvmet_fc_tgt_queue *queue) | |||
477 | * will "inherit" that reference. | 486 | * will "inherit" that reference. |
478 | */ | 487 | */ |
479 | } | 488 | } |
480 | spin_unlock_irqrestore(&queue->qlock, flags); | ||
481 | return fod; | 489 | return fod; |
482 | } | 490 | } |
483 | 491 | ||
484 | 492 | ||
485 | static void | 493 | static void |
494 | nvmet_fc_queue_fcp_req(struct nvmet_fc_tgtport *tgtport, | ||
495 | struct nvmet_fc_tgt_queue *queue, | ||
496 | struct nvmefc_tgt_fcp_req *fcpreq) | ||
497 | { | ||
498 | struct nvmet_fc_fcp_iod *fod = fcpreq->nvmet_fc_private; | ||
499 | |||
500 | /* | ||
501 | * put all admin cmds on hw queue id 0. All io commands go to | ||
502 | * the respective hw queue based on a modulo basis | ||
503 | */ | ||
504 | fcpreq->hwqid = queue->qid ? | ||
505 | ((queue->qid - 1) % tgtport->ops->max_hw_queues) : 0; | ||
506 | |||
507 | if (tgtport->ops->target_features & NVMET_FCTGTFEAT_CMD_IN_ISR) | ||
508 | queue_work_on(queue->cpu, queue->work_q, &fod->work); | ||
509 | else | ||
510 | nvmet_fc_handle_fcp_rqst(tgtport, fod); | ||
511 | } | ||
512 | |||
513 | static void | ||
486 | nvmet_fc_free_fcp_iod(struct nvmet_fc_tgt_queue *queue, | 514 | nvmet_fc_free_fcp_iod(struct nvmet_fc_tgt_queue *queue, |
487 | struct nvmet_fc_fcp_iod *fod) | 515 | struct nvmet_fc_fcp_iod *fod) |
488 | { | 516 | { |
489 | struct nvmefc_tgt_fcp_req *fcpreq = fod->fcpreq; | 517 | struct nvmefc_tgt_fcp_req *fcpreq = fod->fcpreq; |
490 | struct nvmet_fc_tgtport *tgtport = fod->tgtport; | 518 | struct nvmet_fc_tgtport *tgtport = fod->tgtport; |
519 | struct nvmet_fc_defer_fcp_req *deferfcp; | ||
491 | unsigned long flags; | 520 | unsigned long flags; |
492 | 521 | ||
493 | fc_dma_sync_single_for_cpu(tgtport->dev, fod->rspdma, | 522 | fc_dma_sync_single_for_cpu(tgtport->dev, fod->rspdma, |
@@ -495,21 +524,56 @@ nvmet_fc_free_fcp_iod(struct nvmet_fc_tgt_queue *queue, | |||
495 | 524 | ||
496 | fcpreq->nvmet_fc_private = NULL; | 525 | fcpreq->nvmet_fc_private = NULL; |
497 | 526 | ||
498 | spin_lock_irqsave(&queue->qlock, flags); | ||
499 | list_add_tail(&fod->fcp_list, &fod->queue->fod_list); | ||
500 | fod->active = false; | 527 | fod->active = false; |
501 | fod->abort = false; | 528 | fod->abort = false; |
502 | fod->aborted = false; | 529 | fod->aborted = false; |
503 | fod->writedataactive = false; | 530 | fod->writedataactive = false; |
504 | fod->fcpreq = NULL; | 531 | fod->fcpreq = NULL; |
532 | |||
533 | tgtport->ops->fcp_req_release(&tgtport->fc_target_port, fcpreq); | ||
534 | |||
535 | spin_lock_irqsave(&queue->qlock, flags); | ||
536 | deferfcp = list_first_entry_or_null(&queue->pending_cmd_list, | ||
537 | struct nvmet_fc_defer_fcp_req, req_list); | ||
538 | if (!deferfcp) { | ||
539 | list_add_tail(&fod->fcp_list, &fod->queue->fod_list); | ||
540 | spin_unlock_irqrestore(&queue->qlock, flags); | ||
541 | |||
542 | /* Release reference taken at queue lookup and fod allocation */ | ||
543 | nvmet_fc_tgt_q_put(queue); | ||
544 | return; | ||
545 | } | ||
546 | |||
547 | /* Re-use the fod for the next pending cmd that was deferred */ | ||
548 | list_del(&deferfcp->req_list); | ||
549 | |||
550 | fcpreq = deferfcp->fcp_req; | ||
551 | |||
552 | /* deferfcp can be reused for another IO at a later date */ | ||
553 | list_add_tail(&deferfcp->req_list, &queue->avail_defer_list); | ||
554 | |||
505 | spin_unlock_irqrestore(&queue->qlock, flags); | 555 | spin_unlock_irqrestore(&queue->qlock, flags); |
506 | 556 | ||
557 | /* Save NVME CMD IO in fod */ | ||
558 | memcpy(&fod->cmdiubuf, fcpreq->rspaddr, fcpreq->rsplen); | ||
559 | |||
560 | /* Setup new fcpreq to be processed */ | ||
561 | fcpreq->rspaddr = NULL; | ||
562 | fcpreq->rsplen = 0; | ||
563 | fcpreq->nvmet_fc_private = fod; | ||
564 | fod->fcpreq = fcpreq; | ||
565 | fod->active = true; | ||
566 | |||
567 | /* inform LLDD IO is now being processed */ | ||
568 | tgtport->ops->defer_rcv(&tgtport->fc_target_port, fcpreq); | ||
569 | |||
570 | /* Submit deferred IO for processing */ | ||
571 | nvmet_fc_queue_fcp_req(tgtport, queue, fcpreq); | ||
572 | |||
507 | /* | 573 | /* |
508 | * release the reference taken at queue lookup and fod allocation | 574 | * Leave the queue lookup get reference taken when |
575 | * fod was originally allocated. | ||
509 | */ | 576 | */ |
510 | nvmet_fc_tgt_q_put(queue); | ||
511 | |||
512 | tgtport->ops->fcp_req_release(&tgtport->fc_target_port, fcpreq); | ||
513 | } | 577 | } |
514 | 578 | ||
515 | static int | 579 | static int |
@@ -569,6 +633,8 @@ nvmet_fc_alloc_target_queue(struct nvmet_fc_tgt_assoc *assoc, | |||
569 | queue->port = assoc->tgtport->port; | 633 | queue->port = assoc->tgtport->port; |
570 | queue->cpu = nvmet_fc_queue_to_cpu(assoc->tgtport, qid); | 634 | queue->cpu = nvmet_fc_queue_to_cpu(assoc->tgtport, qid); |
571 | INIT_LIST_HEAD(&queue->fod_list); | 635 | INIT_LIST_HEAD(&queue->fod_list); |
636 | INIT_LIST_HEAD(&queue->avail_defer_list); | ||
637 | INIT_LIST_HEAD(&queue->pending_cmd_list); | ||
572 | atomic_set(&queue->connected, 0); | 638 | atomic_set(&queue->connected, 0); |
573 | atomic_set(&queue->sqtail, 0); | 639 | atomic_set(&queue->sqtail, 0); |
574 | atomic_set(&queue->rsn, 1); | 640 | atomic_set(&queue->rsn, 1); |
@@ -638,6 +704,7 @@ nvmet_fc_delete_target_queue(struct nvmet_fc_tgt_queue *queue) | |||
638 | { | 704 | { |
639 | struct nvmet_fc_tgtport *tgtport = queue->assoc->tgtport; | 705 | struct nvmet_fc_tgtport *tgtport = queue->assoc->tgtport; |
640 | struct nvmet_fc_fcp_iod *fod = queue->fod; | 706 | struct nvmet_fc_fcp_iod *fod = queue->fod; |
707 | struct nvmet_fc_defer_fcp_req *deferfcp, *tempptr; | ||
641 | unsigned long flags; | 708 | unsigned long flags; |
642 | int i, writedataactive; | 709 | int i, writedataactive; |
643 | bool disconnect; | 710 | bool disconnect; |
@@ -666,6 +733,36 @@ nvmet_fc_delete_target_queue(struct nvmet_fc_tgt_queue *queue) | |||
666 | } | 733 | } |
667 | } | 734 | } |
668 | } | 735 | } |
736 | |||
737 | /* Cleanup defer'ed IOs in queue */ | ||
738 | list_for_each_entry_safe(deferfcp, tempptr, &queue->avail_defer_list, | ||
739 | req_list) { | ||
740 | list_del(&deferfcp->req_list); | ||
741 | kfree(deferfcp); | ||
742 | } | ||
743 | |||
744 | for (;;) { | ||
745 | deferfcp = list_first_entry_or_null(&queue->pending_cmd_list, | ||
746 | struct nvmet_fc_defer_fcp_req, req_list); | ||
747 | if (!deferfcp) | ||
748 | break; | ||
749 | |||
750 | list_del(&deferfcp->req_list); | ||
751 | spin_unlock_irqrestore(&queue->qlock, flags); | ||
752 | |||
753 | tgtport->ops->defer_rcv(&tgtport->fc_target_port, | ||
754 | deferfcp->fcp_req); | ||
755 | |||
756 | tgtport->ops->fcp_abort(&tgtport->fc_target_port, | ||
757 | deferfcp->fcp_req); | ||
758 | |||
759 | tgtport->ops->fcp_req_release(&tgtport->fc_target_port, | ||
760 | deferfcp->fcp_req); | ||
761 | |||
762 | kfree(deferfcp); | ||
763 | |||
764 | spin_lock_irqsave(&queue->qlock, flags); | ||
765 | } | ||
669 | spin_unlock_irqrestore(&queue->qlock, flags); | 766 | spin_unlock_irqrestore(&queue->qlock, flags); |
670 | 767 | ||
671 | flush_workqueue(queue->work_q); | 768 | flush_workqueue(queue->work_q); |
@@ -2172,11 +2269,38 @@ nvmet_fc_handle_fcp_rqst_work(struct work_struct *work) | |||
2172 | * Pass a FC-NVME FCP CMD IU received from the FC link to the nvmet-fc | 2269 | * Pass a FC-NVME FCP CMD IU received from the FC link to the nvmet-fc |
2173 | * layer for processing. | 2270 | * layer for processing. |
2174 | * | 2271 | * |
2175 | * The nvmet-fc layer will copy cmd payload to an internal structure for | 2272 | * The nvmet_fc layer allocates a local job structure (struct |
2176 | * processing. As such, upon completion of the routine, the LLDD may | 2273 | * nvmet_fc_fcp_iod) from the queue for the io and copies the |
2177 | * immediately free/reuse the CMD IU buffer passed in the call. | 2274 | * CMD IU buffer to the job structure. As such, on a successful |
2275 | * completion (returns 0), the LLDD may immediately free/reuse | ||
2276 | * the CMD IU buffer passed in the call. | ||
2178 | * | 2277 | * |
2179 | * If this routine returns error, the lldd should abort the exchange. | 2278 | * However, in some circumstances, due to the packetized nature of FC |
2279 | * and the api of the FC LLDD which may issue a hw command to send the | ||
2280 | * response, but the LLDD may not get the hw completion for that command | ||
2281 | * and upcall the nvmet_fc layer before a new command may be | ||
2282 | * asynchronously received - its possible for a command to be received | ||
2283 | * before the LLDD and nvmet_fc have recycled the job structure. It gives | ||
2284 | * the appearance of more commands received than fits in the sq. | ||
2285 | * To alleviate this scenario, a temporary queue is maintained in the | ||
2286 | * transport for pending LLDD requests waiting for a queue job structure. | ||
2287 | * In these "overrun" cases, a temporary queue element is allocated | ||
2288 | * the LLDD request and CMD iu buffer information remembered, and the | ||
2289 | * routine returns a -EOVERFLOW status. Subsequently, when a queue job | ||
2290 | * structure is freed, it is immediately reallocated for anything on the | ||
2291 | * pending request list. The LLDDs defer_rcv() callback is called, | ||
2292 | * informing the LLDD that it may reuse the CMD IU buffer, and the io | ||
2293 | * is then started normally with the transport. | ||
2294 | * | ||
2295 | * The LLDD, when receiving an -EOVERFLOW completion status, is to treat | ||
2296 | * the completion as successful but must not reuse the CMD IU buffer | ||
2297 | * until the LLDD's defer_rcv() callback has been called for the | ||
2298 | * corresponding struct nvmefc_tgt_fcp_req pointer. | ||
2299 | * | ||
2300 | * If there is any other condition in which an error occurs, the | ||
2301 | * transport will return a non-zero status indicating the error. | ||
2302 | * In all cases other than -EOVERFLOW, the transport has not accepted the | ||
2303 | * request and the LLDD should abort the exchange. | ||
2180 | * | 2304 | * |
2181 | * @target_port: pointer to the (registered) target port the FCP CMD IU | 2305 | * @target_port: pointer to the (registered) target port the FCP CMD IU |
2182 | * was received on. | 2306 | * was received on. |
@@ -2194,6 +2318,8 @@ nvmet_fc_rcv_fcp_req(struct nvmet_fc_target_port *target_port, | |||
2194 | struct nvme_fc_cmd_iu *cmdiu = cmdiubuf; | 2318 | struct nvme_fc_cmd_iu *cmdiu = cmdiubuf; |
2195 | struct nvmet_fc_tgt_queue *queue; | 2319 | struct nvmet_fc_tgt_queue *queue; |
2196 | struct nvmet_fc_fcp_iod *fod; | 2320 | struct nvmet_fc_fcp_iod *fod; |
2321 | struct nvmet_fc_defer_fcp_req *deferfcp; | ||
2322 | unsigned long flags; | ||
2197 | 2323 | ||
2198 | /* validate iu, so the connection id can be used to find the queue */ | 2324 | /* validate iu, so the connection id can be used to find the queue */ |
2199 | if ((cmdiubuf_len != sizeof(*cmdiu)) || | 2325 | if ((cmdiubuf_len != sizeof(*cmdiu)) || |
@@ -2214,29 +2340,60 @@ nvmet_fc_rcv_fcp_req(struct nvmet_fc_target_port *target_port, | |||
2214 | * when the fod is freed. | 2340 | * when the fod is freed. |
2215 | */ | 2341 | */ |
2216 | 2342 | ||
2343 | spin_lock_irqsave(&queue->qlock, flags); | ||
2344 | |||
2217 | fod = nvmet_fc_alloc_fcp_iod(queue); | 2345 | fod = nvmet_fc_alloc_fcp_iod(queue); |
2218 | if (!fod) { | 2346 | if (fod) { |
2347 | spin_unlock_irqrestore(&queue->qlock, flags); | ||
2348 | |||
2349 | fcpreq->nvmet_fc_private = fod; | ||
2350 | fod->fcpreq = fcpreq; | ||
2351 | |||
2352 | memcpy(&fod->cmdiubuf, cmdiubuf, cmdiubuf_len); | ||
2353 | |||
2354 | nvmet_fc_queue_fcp_req(tgtport, queue, fcpreq); | ||
2355 | |||
2356 | return 0; | ||
2357 | } | ||
2358 | |||
2359 | if (!tgtport->ops->defer_rcv) { | ||
2360 | spin_unlock_irqrestore(&queue->qlock, flags); | ||
2219 | /* release the queue lookup reference */ | 2361 | /* release the queue lookup reference */ |
2220 | nvmet_fc_tgt_q_put(queue); | 2362 | nvmet_fc_tgt_q_put(queue); |
2221 | return -ENOENT; | 2363 | return -ENOENT; |
2222 | } | 2364 | } |
2223 | 2365 | ||
2224 | fcpreq->nvmet_fc_private = fod; | 2366 | deferfcp = list_first_entry_or_null(&queue->avail_defer_list, |
2225 | fod->fcpreq = fcpreq; | 2367 | struct nvmet_fc_defer_fcp_req, req_list); |
2226 | /* | 2368 | if (deferfcp) { |
2227 | * put all admin cmds on hw queue id 0. All io commands go to | 2369 | /* Just re-use one that was previously allocated */ |
2228 | * the respective hw queue based on a modulo basis | 2370 | list_del(&deferfcp->req_list); |
2229 | */ | 2371 | } else { |
2230 | fcpreq->hwqid = queue->qid ? | 2372 | spin_unlock_irqrestore(&queue->qlock, flags); |
2231 | ((queue->qid - 1) % tgtport->ops->max_hw_queues) : 0; | ||
2232 | memcpy(&fod->cmdiubuf, cmdiubuf, cmdiubuf_len); | ||
2233 | 2373 | ||
2234 | if (tgtport->ops->target_features & NVMET_FCTGTFEAT_CMD_IN_ISR) | 2374 | /* Now we need to dynamically allocate one */ |
2235 | queue_work_on(queue->cpu, queue->work_q, &fod->work); | 2375 | deferfcp = kmalloc(sizeof(*deferfcp), GFP_KERNEL); |
2236 | else | 2376 | if (!deferfcp) { |
2237 | nvmet_fc_handle_fcp_rqst(tgtport, fod); | 2377 | /* release the queue lookup reference */ |
2378 | nvmet_fc_tgt_q_put(queue); | ||
2379 | return -ENOMEM; | ||
2380 | } | ||
2381 | spin_lock_irqsave(&queue->qlock, flags); | ||
2382 | } | ||
2238 | 2383 | ||
2239 | return 0; | 2384 | /* For now, use rspaddr / rsplen to save payload information */ |
2385 | fcpreq->rspaddr = cmdiubuf; | ||
2386 | fcpreq->rsplen = cmdiubuf_len; | ||
2387 | deferfcp->fcp_req = fcpreq; | ||
2388 | |||
2389 | /* defer processing till a fod becomes available */ | ||
2390 | list_add_tail(&deferfcp->req_list, &queue->pending_cmd_list); | ||
2391 | |||
2392 | /* NOTE: the queue lookup reference is still valid */ | ||
2393 | |||
2394 | spin_unlock_irqrestore(&queue->qlock, flags); | ||
2395 | |||
2396 | return -EOVERFLOW; | ||
2240 | } | 2397 | } |
2241 | EXPORT_SYMBOL_GPL(nvmet_fc_rcv_fcp_req); | 2398 | EXPORT_SYMBOL_GPL(nvmet_fc_rcv_fcp_req); |
2242 | 2399 | ||
diff --git a/drivers/of/device.c b/drivers/of/device.c index 28c38c756f92..e0a28ea341fe 100644 --- a/drivers/of/device.c +++ b/drivers/of/device.c | |||
@@ -89,6 +89,7 @@ int of_dma_configure(struct device *dev, struct device_node *np) | |||
89 | bool coherent; | 89 | bool coherent; |
90 | unsigned long offset; | 90 | unsigned long offset; |
91 | const struct iommu_ops *iommu; | 91 | const struct iommu_ops *iommu; |
92 | u64 mask; | ||
92 | 93 | ||
93 | /* | 94 | /* |
94 | * Set default coherent_dma_mask to 32 bit. Drivers are expected to | 95 | * Set default coherent_dma_mask to 32 bit. Drivers are expected to |
@@ -134,10 +135,9 @@ int of_dma_configure(struct device *dev, struct device_node *np) | |||
134 | * Limit coherent and dma mask based on size and default mask | 135 | * Limit coherent and dma mask based on size and default mask |
135 | * set by the driver. | 136 | * set by the driver. |
136 | */ | 137 | */ |
137 | dev->coherent_dma_mask = min(dev->coherent_dma_mask, | 138 | mask = DMA_BIT_MASK(ilog2(dma_addr + size - 1) + 1); |
138 | DMA_BIT_MASK(ilog2(dma_addr + size))); | 139 | dev->coherent_dma_mask &= mask; |
139 | *dev->dma_mask = min((*dev->dma_mask), | 140 | *dev->dma_mask &= mask; |
140 | DMA_BIT_MASK(ilog2(dma_addr + size))); | ||
141 | 141 | ||
142 | coherent = of_dma_is_coherent(np); | 142 | coherent = of_dma_is_coherent(np); |
143 | dev_dbg(dev, "device is%sdma coherent\n", | 143 | dev_dbg(dev, "device is%sdma coherent\n", |
diff --git a/drivers/parisc/dino.c b/drivers/parisc/dino.c index 5c63b920b471..ed92c1254cff 100644 --- a/drivers/parisc/dino.c +++ b/drivers/parisc/dino.c | |||
@@ -956,7 +956,7 @@ static int __init dino_probe(struct parisc_device *dev) | |||
956 | 956 | ||
957 | dino_dev->hba.dev = dev; | 957 | dino_dev->hba.dev = dev; |
958 | dino_dev->hba.base_addr = ioremap_nocache(hpa, 4096); | 958 | dino_dev->hba.base_addr = ioremap_nocache(hpa, 4096); |
959 | dino_dev->hba.lmmio_space_offset = 0; /* CPU addrs == bus addrs */ | 959 | dino_dev->hba.lmmio_space_offset = PCI_F_EXTEND; |
960 | spin_lock_init(&dino_dev->dinosaur_pen); | 960 | spin_lock_init(&dino_dev->dinosaur_pen); |
961 | dino_dev->hba.iommu = ccio_get_iommu(dev); | 961 | dino_dev->hba.iommu = ccio_get_iommu(dev); |
962 | 962 | ||
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index af0cc3456dc1..fdf65a6c13f6 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c | |||
@@ -514,7 +514,7 @@ EXPORT_SYMBOL(pci_find_resource); | |||
514 | */ | 514 | */ |
515 | struct pci_dev *pci_find_pcie_root_port(struct pci_dev *dev) | 515 | struct pci_dev *pci_find_pcie_root_port(struct pci_dev *dev) |
516 | { | 516 | { |
517 | struct pci_dev *bridge, *highest_pcie_bridge = NULL; | 517 | struct pci_dev *bridge, *highest_pcie_bridge = dev; |
518 | 518 | ||
519 | bridge = pci_upstream_bridge(dev); | 519 | bridge = pci_upstream_bridge(dev); |
520 | while (bridge && pci_is_pcie(bridge)) { | 520 | while (bridge && pci_is_pcie(bridge)) { |
@@ -4260,6 +4260,41 @@ int pci_reset_function(struct pci_dev *dev) | |||
4260 | EXPORT_SYMBOL_GPL(pci_reset_function); | 4260 | EXPORT_SYMBOL_GPL(pci_reset_function); |
4261 | 4261 | ||
4262 | /** | 4262 | /** |
4263 | * pci_reset_function_locked - quiesce and reset a PCI device function | ||
4264 | * @dev: PCI device to reset | ||
4265 | * | ||
4266 | * Some devices allow an individual function to be reset without affecting | ||
4267 | * other functions in the same device. The PCI device must be responsive | ||
4268 | * to PCI config space in order to use this function. | ||
4269 | * | ||
4270 | * This function does not just reset the PCI portion of a device, but | ||
4271 | * clears all the state associated with the device. This function differs | ||
4272 | * from __pci_reset_function() in that it saves and restores device state | ||
4273 | * over the reset. It also differs from pci_reset_function() in that it | ||
4274 | * requires the PCI device lock to be held. | ||
4275 | * | ||
4276 | * Returns 0 if the device function was successfully reset or negative if the | ||
4277 | * device doesn't support resetting a single function. | ||
4278 | */ | ||
4279 | int pci_reset_function_locked(struct pci_dev *dev) | ||
4280 | { | ||
4281 | int rc; | ||
4282 | |||
4283 | rc = pci_probe_reset_function(dev); | ||
4284 | if (rc) | ||
4285 | return rc; | ||
4286 | |||
4287 | pci_dev_save_and_disable(dev); | ||
4288 | |||
4289 | rc = __pci_reset_function_locked(dev); | ||
4290 | |||
4291 | pci_dev_restore(dev); | ||
4292 | |||
4293 | return rc; | ||
4294 | } | ||
4295 | EXPORT_SYMBOL_GPL(pci_reset_function_locked); | ||
4296 | |||
4297 | /** | ||
4263 | * pci_try_reset_function - quiesce and reset a PCI device function | 4298 | * pci_try_reset_function - quiesce and reset a PCI device function |
4264 | * @dev: PCI device to reset | 4299 | * @dev: PCI device to reset |
4265 | * | 4300 | * |
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index c31310db0404..e6a917b4acd3 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c | |||
@@ -1762,6 +1762,48 @@ static void pci_configure_extended_tags(struct pci_dev *dev) | |||
1762 | PCI_EXP_DEVCTL_EXT_TAG); | 1762 | PCI_EXP_DEVCTL_EXT_TAG); |
1763 | } | 1763 | } |
1764 | 1764 | ||
1765 | /** | ||
1766 | * pcie_relaxed_ordering_enabled - Probe for PCIe relaxed ordering enable | ||
1767 | * @dev: PCI device to query | ||
1768 | * | ||
1769 | * Returns true if the device has enabled relaxed ordering attribute. | ||
1770 | */ | ||
1771 | bool pcie_relaxed_ordering_enabled(struct pci_dev *dev) | ||
1772 | { | ||
1773 | u16 v; | ||
1774 | |||
1775 | pcie_capability_read_word(dev, PCI_EXP_DEVCTL, &v); | ||
1776 | |||
1777 | return !!(v & PCI_EXP_DEVCTL_RELAX_EN); | ||
1778 | } | ||
1779 | EXPORT_SYMBOL(pcie_relaxed_ordering_enabled); | ||
1780 | |||
1781 | static void pci_configure_relaxed_ordering(struct pci_dev *dev) | ||
1782 | { | ||
1783 | struct pci_dev *root; | ||
1784 | |||
1785 | /* PCI_EXP_DEVICE_RELAX_EN is RsvdP in VFs */ | ||
1786 | if (dev->is_virtfn) | ||
1787 | return; | ||
1788 | |||
1789 | if (!pcie_relaxed_ordering_enabled(dev)) | ||
1790 | return; | ||
1791 | |||
1792 | /* | ||
1793 | * For now, we only deal with Relaxed Ordering issues with Root | ||
1794 | * Ports. Peer-to-Peer DMA is another can of worms. | ||
1795 | */ | ||
1796 | root = pci_find_pcie_root_port(dev); | ||
1797 | if (!root) | ||
1798 | return; | ||
1799 | |||
1800 | if (root->dev_flags & PCI_DEV_FLAGS_NO_RELAXED_ORDERING) { | ||
1801 | pcie_capability_clear_word(dev, PCI_EXP_DEVCTL, | ||
1802 | PCI_EXP_DEVCTL_RELAX_EN); | ||
1803 | dev_info(&dev->dev, "Disable Relaxed Ordering because the Root Port didn't support it\n"); | ||
1804 | } | ||
1805 | } | ||
1806 | |||
1765 | static void pci_configure_device(struct pci_dev *dev) | 1807 | static void pci_configure_device(struct pci_dev *dev) |
1766 | { | 1808 | { |
1767 | struct hotplug_params hpp; | 1809 | struct hotplug_params hpp; |
@@ -1769,6 +1811,7 @@ static void pci_configure_device(struct pci_dev *dev) | |||
1769 | 1811 | ||
1770 | pci_configure_mps(dev); | 1812 | pci_configure_mps(dev); |
1771 | pci_configure_extended_tags(dev); | 1813 | pci_configure_extended_tags(dev); |
1814 | pci_configure_relaxed_ordering(dev); | ||
1772 | 1815 | ||
1773 | memset(&hpp, 0, sizeof(hpp)); | 1816 | memset(&hpp, 0, sizeof(hpp)); |
1774 | ret = pci_get_hp_params(dev, &hpp); | 1817 | ret = pci_get_hp_params(dev, &hpp); |
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index 6967c6b4cf6b..140760403f36 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c | |||
@@ -4016,6 +4016,95 @@ DECLARE_PCI_FIXUP_CLASS_EARLY(0x1797, 0x6869, PCI_CLASS_NOT_DEFINED, 8, | |||
4016 | quirk_tw686x_class); | 4016 | quirk_tw686x_class); |
4017 | 4017 | ||
4018 | /* | 4018 | /* |
4019 | * Some devices have problems with Transaction Layer Packets with the Relaxed | ||
4020 | * Ordering Attribute set. Such devices should mark themselves and other | ||
4021 | * Device Drivers should check before sending TLPs with RO set. | ||
4022 | */ | ||
4023 | static void quirk_relaxedordering_disable(struct pci_dev *dev) | ||
4024 | { | ||
4025 | dev->dev_flags |= PCI_DEV_FLAGS_NO_RELAXED_ORDERING; | ||
4026 | dev_info(&dev->dev, "Disable Relaxed Ordering Attributes to avoid PCIe Completion erratum\n"); | ||
4027 | } | ||
4028 | |||
4029 | /* | ||
4030 | * Intel Xeon processors based on Broadwell/Haswell microarchitecture Root | ||
4031 | * Complex has a Flow Control Credit issue which can cause performance | ||
4032 | * problems with Upstream Transaction Layer Packets with Relaxed Ordering set. | ||
4033 | */ | ||
4034 | DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f01, PCI_CLASS_NOT_DEFINED, 8, | ||
4035 | quirk_relaxedordering_disable); | ||
4036 | DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f02, PCI_CLASS_NOT_DEFINED, 8, | ||
4037 | quirk_relaxedordering_disable); | ||
4038 | DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f03, PCI_CLASS_NOT_DEFINED, 8, | ||
4039 | quirk_relaxedordering_disable); | ||
4040 | DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f04, PCI_CLASS_NOT_DEFINED, 8, | ||
4041 | quirk_relaxedordering_disable); | ||
4042 | DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f05, PCI_CLASS_NOT_DEFINED, 8, | ||
4043 | quirk_relaxedordering_disable); | ||
4044 | DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f06, PCI_CLASS_NOT_DEFINED, 8, | ||
4045 | quirk_relaxedordering_disable); | ||
4046 | DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f07, PCI_CLASS_NOT_DEFINED, 8, | ||
4047 | quirk_relaxedordering_disable); | ||
4048 | DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f08, PCI_CLASS_NOT_DEFINED, 8, | ||
4049 | quirk_relaxedordering_disable); | ||
4050 | DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f09, PCI_CLASS_NOT_DEFINED, 8, | ||
4051 | quirk_relaxedordering_disable); | ||
4052 | DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f0a, PCI_CLASS_NOT_DEFINED, 8, | ||
4053 | quirk_relaxedordering_disable); | ||
4054 | DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f0b, PCI_CLASS_NOT_DEFINED, 8, | ||
4055 | quirk_relaxedordering_disable); | ||
4056 | DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f0c, PCI_CLASS_NOT_DEFINED, 8, | ||
4057 | quirk_relaxedordering_disable); | ||
4058 | DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f0d, PCI_CLASS_NOT_DEFINED, 8, | ||
4059 | quirk_relaxedordering_disable); | ||
4060 | DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f0e, PCI_CLASS_NOT_DEFINED, 8, | ||
4061 | quirk_relaxedordering_disable); | ||
4062 | DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x2f01, PCI_CLASS_NOT_DEFINED, 8, | ||
4063 | quirk_relaxedordering_disable); | ||
4064 | DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x2f02, PCI_CLASS_NOT_DEFINED, 8, | ||
4065 | quirk_relaxedordering_disable); | ||
4066 | DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x2f03, PCI_CLASS_NOT_DEFINED, 8, | ||
4067 | quirk_relaxedordering_disable); | ||
4068 | DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x2f04, PCI_CLASS_NOT_DEFINED, 8, | ||
4069 | quirk_relaxedordering_disable); | ||
4070 | DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x2f05, PCI_CLASS_NOT_DEFINED, 8, | ||
4071 | quirk_relaxedordering_disable); | ||
4072 | DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x2f06, PCI_CLASS_NOT_DEFINED, 8, | ||
4073 | quirk_relaxedordering_disable); | ||
4074 | DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x2f07, PCI_CLASS_NOT_DEFINED, 8, | ||
4075 | quirk_relaxedordering_disable); | ||
4076 | DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x2f08, PCI_CLASS_NOT_DEFINED, 8, | ||
4077 | quirk_relaxedordering_disable); | ||
4078 | DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x2f09, PCI_CLASS_NOT_DEFINED, 8, | ||
4079 | quirk_relaxedordering_disable); | ||
4080 | DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x2f0a, PCI_CLASS_NOT_DEFINED, 8, | ||
4081 | quirk_relaxedordering_disable); | ||
4082 | DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x2f0b, PCI_CLASS_NOT_DEFINED, 8, | ||
4083 | quirk_relaxedordering_disable); | ||
4084 | DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x2f0c, PCI_CLASS_NOT_DEFINED, 8, | ||
4085 | quirk_relaxedordering_disable); | ||
4086 | DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x2f0d, PCI_CLASS_NOT_DEFINED, 8, | ||
4087 | quirk_relaxedordering_disable); | ||
4088 | DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x2f0e, PCI_CLASS_NOT_DEFINED, 8, | ||
4089 | quirk_relaxedordering_disable); | ||
4090 | |||
4091 | /* | ||
4092 | * The AMD ARM A1100 (AKA "SEATTLE") SoC has a bug in its PCIe Root Complex | ||
4093 | * where Upstream Transaction Layer Packets with the Relaxed Ordering | ||
4094 | * Attribute clear are allowed to bypass earlier TLPs with Relaxed Ordering | ||
4095 | * set. This is a violation of the PCIe 3.0 Transaction Ordering Rules | ||
4096 | * outlined in Section 2.4.1 (PCI Express(r) Base Specification Revision 3.0 | ||
4097 | * November 10, 2010). As a result, on this platform we can't use Relaxed | ||
4098 | * Ordering for Upstream TLPs. | ||
4099 | */ | ||
4100 | DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_AMD, 0x1a00, PCI_CLASS_NOT_DEFINED, 8, | ||
4101 | quirk_relaxedordering_disable); | ||
4102 | DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_AMD, 0x1a01, PCI_CLASS_NOT_DEFINED, 8, | ||
4103 | quirk_relaxedordering_disable); | ||
4104 | DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_AMD, 0x1a02, PCI_CLASS_NOT_DEFINED, 8, | ||
4105 | quirk_relaxedordering_disable); | ||
4106 | |||
4107 | /* | ||
4019 | * Per PCIe r3.0, sec 2.2.9, "Completion headers must supply the same | 4108 | * Per PCIe r3.0, sec 2.2.9, "Completion headers must supply the same |
4020 | * values for the Attribute as were supplied in the header of the | 4109 | * values for the Attribute as were supplied in the header of the |
4021 | * corresponding Request, except as explicitly allowed when IDO is used." | 4110 | * corresponding Request, except as explicitly allowed when IDO is used." |
diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c index 4fac49e55d47..4b43aa62fbc7 100644 --- a/drivers/rtc/rtc-ds1307.c +++ b/drivers/rtc/rtc-ds1307.c | |||
@@ -1301,7 +1301,6 @@ static void ds1307_clks_register(struct ds1307 *ds1307) | |||
1301 | static const struct regmap_config regmap_config = { | 1301 | static const struct regmap_config regmap_config = { |
1302 | .reg_bits = 8, | 1302 | .reg_bits = 8, |
1303 | .val_bits = 8, | 1303 | .val_bits = 8, |
1304 | .max_register = 0x12, | ||
1305 | }; | 1304 | }; |
1306 | 1305 | ||
1307 | static int ds1307_probe(struct i2c_client *client, | 1306 | static int ds1307_probe(struct i2c_client *client, |
diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig index f4538d7a3016..d145e0d90227 100644 --- a/drivers/scsi/Kconfig +++ b/drivers/scsi/Kconfig | |||
@@ -47,6 +47,17 @@ config SCSI_NETLINK | |||
47 | default n | 47 | default n |
48 | depends on NET | 48 | depends on NET |
49 | 49 | ||
50 | config SCSI_MQ_DEFAULT | ||
51 | bool "SCSI: use blk-mq I/O path by default" | ||
52 | depends on SCSI | ||
53 | ---help--- | ||
54 | This option enables the new blk-mq based I/O path for SCSI | ||
55 | devices by default. With the option the scsi_mod.use_blk_mq | ||
56 | module/boot option defaults to Y, without it to N, but it can | ||
57 | still be overridden either way. | ||
58 | |||
59 | If unsure say N. | ||
60 | |||
50 | config SCSI_PROC_FS | 61 | config SCSI_PROC_FS |
51 | bool "legacy /proc/scsi/ support" | 62 | bool "legacy /proc/scsi/ support" |
52 | depends on SCSI && PROC_FS | 63 | depends on SCSI && PROC_FS |
diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c index 4591113c49de..a1a2c71e1626 100644 --- a/drivers/scsi/aacraid/aachba.c +++ b/drivers/scsi/aacraid/aachba.c | |||
@@ -549,7 +549,9 @@ static void get_container_name_callback(void *context, struct fib * fibptr) | |||
549 | if ((le32_to_cpu(get_name_reply->status) == CT_OK) | 549 | if ((le32_to_cpu(get_name_reply->status) == CT_OK) |
550 | && (get_name_reply->data[0] != '\0')) { | 550 | && (get_name_reply->data[0] != '\0')) { |
551 | char *sp = get_name_reply->data; | 551 | char *sp = get_name_reply->data; |
552 | sp[sizeof(((struct aac_get_name_resp *)NULL)->data)] = '\0'; | 552 | int data_size = FIELD_SIZEOF(struct aac_get_name_resp, data); |
553 | |||
554 | sp[data_size - 1] = '\0'; | ||
553 | while (*sp == ' ') | 555 | while (*sp == ' ') |
554 | ++sp; | 556 | ++sp; |
555 | if (*sp) { | 557 | if (*sp) { |
@@ -579,12 +581,15 @@ static void get_container_name_callback(void *context, struct fib * fibptr) | |||
579 | static int aac_get_container_name(struct scsi_cmnd * scsicmd) | 581 | static int aac_get_container_name(struct scsi_cmnd * scsicmd) |
580 | { | 582 | { |
581 | int status; | 583 | int status; |
584 | int data_size; | ||
582 | struct aac_get_name *dinfo; | 585 | struct aac_get_name *dinfo; |
583 | struct fib * cmd_fibcontext; | 586 | struct fib * cmd_fibcontext; |
584 | struct aac_dev * dev; | 587 | struct aac_dev * dev; |
585 | 588 | ||
586 | dev = (struct aac_dev *)scsicmd->device->host->hostdata; | 589 | dev = (struct aac_dev *)scsicmd->device->host->hostdata; |
587 | 590 | ||
591 | data_size = FIELD_SIZEOF(struct aac_get_name_resp, data); | ||
592 | |||
588 | cmd_fibcontext = aac_fib_alloc_tag(dev, scsicmd); | 593 | cmd_fibcontext = aac_fib_alloc_tag(dev, scsicmd); |
589 | 594 | ||
590 | aac_fib_init(cmd_fibcontext); | 595 | aac_fib_init(cmd_fibcontext); |
@@ -593,7 +598,7 @@ static int aac_get_container_name(struct scsi_cmnd * scsicmd) | |||
593 | dinfo->command = cpu_to_le32(VM_ContainerConfig); | 598 | dinfo->command = cpu_to_le32(VM_ContainerConfig); |
594 | dinfo->type = cpu_to_le32(CT_READ_NAME); | 599 | dinfo->type = cpu_to_le32(CT_READ_NAME); |
595 | dinfo->cid = cpu_to_le32(scmd_id(scsicmd)); | 600 | dinfo->cid = cpu_to_le32(scmd_id(scsicmd)); |
596 | dinfo->count = cpu_to_le32(sizeof(((struct aac_get_name_resp *)NULL)->data)); | 601 | dinfo->count = cpu_to_le32(data_size - 1); |
597 | 602 | ||
598 | status = aac_fib_send(ContainerCommand, | 603 | status = aac_fib_send(ContainerCommand, |
599 | cmd_fibcontext, | 604 | cmd_fibcontext, |
diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h index d31a9bc2ba69..ee2667e20e42 100644 --- a/drivers/scsi/aacraid/aacraid.h +++ b/drivers/scsi/aacraid/aacraid.h | |||
@@ -2274,7 +2274,7 @@ struct aac_get_name_resp { | |||
2274 | __le32 parm3; | 2274 | __le32 parm3; |
2275 | __le32 parm4; | 2275 | __le32 parm4; |
2276 | __le32 parm5; | 2276 | __le32 parm5; |
2277 | u8 data[16]; | 2277 | u8 data[17]; |
2278 | }; | 2278 | }; |
2279 | 2279 | ||
2280 | #define CT_CID_TO_32BITS_UID 165 | 2280 | #define CT_CID_TO_32BITS_UID 165 |
diff --git a/drivers/scsi/csiostor/csio_hw.c b/drivers/scsi/csiostor/csio_hw.c index 2029ad225121..5be0086142ca 100644 --- a/drivers/scsi/csiostor/csio_hw.c +++ b/drivers/scsi/csiostor/csio_hw.c | |||
@@ -3845,8 +3845,10 @@ csio_hw_start(struct csio_hw *hw) | |||
3845 | 3845 | ||
3846 | if (csio_is_hw_ready(hw)) | 3846 | if (csio_is_hw_ready(hw)) |
3847 | return 0; | 3847 | return 0; |
3848 | else | 3848 | else if (csio_match_state(hw, csio_hws_uninit)) |
3849 | return -EINVAL; | 3849 | return -EINVAL; |
3850 | else | ||
3851 | return -ENODEV; | ||
3850 | } | 3852 | } |
3851 | 3853 | ||
3852 | int | 3854 | int |
diff --git a/drivers/scsi/csiostor/csio_init.c b/drivers/scsi/csiostor/csio_init.c index ea0c31086cc6..dcd074169aa9 100644 --- a/drivers/scsi/csiostor/csio_init.c +++ b/drivers/scsi/csiostor/csio_init.c | |||
@@ -969,10 +969,14 @@ static int csio_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
969 | 969 | ||
970 | pci_set_drvdata(pdev, hw); | 970 | pci_set_drvdata(pdev, hw); |
971 | 971 | ||
972 | if (csio_hw_start(hw) != 0) { | 972 | rv = csio_hw_start(hw); |
973 | dev_err(&pdev->dev, | 973 | if (rv) { |
974 | "Failed to start FW, continuing in debug mode.\n"); | 974 | if (rv == -EINVAL) { |
975 | return 0; | 975 | dev_err(&pdev->dev, |
976 | "Failed to start FW, continuing in debug mode.\n"); | ||
977 | return 0; | ||
978 | } | ||
979 | goto err_lnode_exit; | ||
976 | } | 980 | } |
977 | 981 | ||
978 | sprintf(hw->fwrev_str, "%u.%u.%u.%u\n", | 982 | sprintf(hw->fwrev_str, "%u.%u.%u.%u\n", |
diff --git a/drivers/scsi/cxgbi/cxgb4i/cxgb4i.c b/drivers/scsi/cxgbi/cxgb4i/cxgb4i.c index a69a9ac836f5..1d02cf9fe06c 100644 --- a/drivers/scsi/cxgbi/cxgb4i/cxgb4i.c +++ b/drivers/scsi/cxgbi/cxgb4i/cxgb4i.c | |||
@@ -1635,6 +1635,9 @@ static int init_act_open(struct cxgbi_sock *csk) | |||
1635 | goto rel_resource; | 1635 | goto rel_resource; |
1636 | } | 1636 | } |
1637 | 1637 | ||
1638 | if (!(n->nud_state & NUD_VALID)) | ||
1639 | neigh_event_send(n, NULL); | ||
1640 | |||
1638 | csk->atid = cxgb4_alloc_atid(lldi->tids, csk); | 1641 | csk->atid = cxgb4_alloc_atid(lldi->tids, csk); |
1639 | if (csk->atid < 0) { | 1642 | if (csk->atid < 0) { |
1640 | pr_err("%s, NO atid available.\n", ndev->name); | 1643 | pr_err("%s, NO atid available.\n", ndev->name); |
diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c index b0c68d24db01..da5bdbdcce52 100644 --- a/drivers/scsi/ipr.c +++ b/drivers/scsi/ipr.c | |||
@@ -3351,6 +3351,16 @@ static void ipr_worker_thread(struct work_struct *work) | |||
3351 | return; | 3351 | return; |
3352 | } | 3352 | } |
3353 | 3353 | ||
3354 | if (ioa_cfg->scsi_unblock) { | ||
3355 | ioa_cfg->scsi_unblock = 0; | ||
3356 | ioa_cfg->scsi_blocked = 0; | ||
3357 | spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags); | ||
3358 | scsi_unblock_requests(ioa_cfg->host); | ||
3359 | spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags); | ||
3360 | if (ioa_cfg->scsi_blocked) | ||
3361 | scsi_block_requests(ioa_cfg->host); | ||
3362 | } | ||
3363 | |||
3354 | if (!ioa_cfg->scan_enabled) { | 3364 | if (!ioa_cfg->scan_enabled) { |
3355 | spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags); | 3365 | spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags); |
3356 | return; | 3366 | return; |
@@ -7211,9 +7221,8 @@ static int ipr_ioa_bringdown_done(struct ipr_cmnd *ipr_cmd) | |||
7211 | ENTER; | 7221 | ENTER; |
7212 | if (!ioa_cfg->hrrq[IPR_INIT_HRRQ].removing_ioa) { | 7222 | if (!ioa_cfg->hrrq[IPR_INIT_HRRQ].removing_ioa) { |
7213 | ipr_trace; | 7223 | ipr_trace; |
7214 | spin_unlock_irq(ioa_cfg->host->host_lock); | 7224 | ioa_cfg->scsi_unblock = 1; |
7215 | scsi_unblock_requests(ioa_cfg->host); | 7225 | schedule_work(&ioa_cfg->work_q); |
7216 | spin_lock_irq(ioa_cfg->host->host_lock); | ||
7217 | } | 7226 | } |
7218 | 7227 | ||
7219 | ioa_cfg->in_reset_reload = 0; | 7228 | ioa_cfg->in_reset_reload = 0; |
@@ -7287,13 +7296,7 @@ static int ipr_ioa_reset_done(struct ipr_cmnd *ipr_cmd) | |||
7287 | list_add_tail(&ipr_cmd->queue, &ipr_cmd->hrrq->hrrq_free_q); | 7296 | list_add_tail(&ipr_cmd->queue, &ipr_cmd->hrrq->hrrq_free_q); |
7288 | wake_up_all(&ioa_cfg->reset_wait_q); | 7297 | wake_up_all(&ioa_cfg->reset_wait_q); |
7289 | 7298 | ||
7290 | spin_unlock(ioa_cfg->host->host_lock); | 7299 | ioa_cfg->scsi_unblock = 1; |
7291 | scsi_unblock_requests(ioa_cfg->host); | ||
7292 | spin_lock(ioa_cfg->host->host_lock); | ||
7293 | |||
7294 | if (!ioa_cfg->hrrq[IPR_INIT_HRRQ].allow_cmds) | ||
7295 | scsi_block_requests(ioa_cfg->host); | ||
7296 | |||
7297 | schedule_work(&ioa_cfg->work_q); | 7300 | schedule_work(&ioa_cfg->work_q); |
7298 | LEAVE; | 7301 | LEAVE; |
7299 | return IPR_RC_JOB_RETURN; | 7302 | return IPR_RC_JOB_RETURN; |
@@ -9249,8 +9252,11 @@ static void _ipr_initiate_ioa_reset(struct ipr_ioa_cfg *ioa_cfg, | |||
9249 | spin_unlock(&ioa_cfg->hrrq[i]._lock); | 9252 | spin_unlock(&ioa_cfg->hrrq[i]._lock); |
9250 | } | 9253 | } |
9251 | wmb(); | 9254 | wmb(); |
9252 | if (!ioa_cfg->hrrq[IPR_INIT_HRRQ].removing_ioa) | 9255 | if (!ioa_cfg->hrrq[IPR_INIT_HRRQ].removing_ioa) { |
9256 | ioa_cfg->scsi_unblock = 0; | ||
9257 | ioa_cfg->scsi_blocked = 1; | ||
9253 | scsi_block_requests(ioa_cfg->host); | 9258 | scsi_block_requests(ioa_cfg->host); |
9259 | } | ||
9254 | 9260 | ||
9255 | ipr_cmd = ipr_get_free_ipr_cmnd(ioa_cfg); | 9261 | ipr_cmd = ipr_get_free_ipr_cmnd(ioa_cfg); |
9256 | ioa_cfg->reset_cmd = ipr_cmd; | 9262 | ioa_cfg->reset_cmd = ipr_cmd; |
@@ -9306,9 +9312,8 @@ static void ipr_initiate_ioa_reset(struct ipr_ioa_cfg *ioa_cfg, | |||
9306 | wake_up_all(&ioa_cfg->reset_wait_q); | 9312 | wake_up_all(&ioa_cfg->reset_wait_q); |
9307 | 9313 | ||
9308 | if (!ioa_cfg->hrrq[IPR_INIT_HRRQ].removing_ioa) { | 9314 | if (!ioa_cfg->hrrq[IPR_INIT_HRRQ].removing_ioa) { |
9309 | spin_unlock_irq(ioa_cfg->host->host_lock); | 9315 | ioa_cfg->scsi_unblock = 1; |
9310 | scsi_unblock_requests(ioa_cfg->host); | 9316 | schedule_work(&ioa_cfg->work_q); |
9311 | spin_lock_irq(ioa_cfg->host->host_lock); | ||
9312 | } | 9317 | } |
9313 | return; | 9318 | return; |
9314 | } else { | 9319 | } else { |
diff --git a/drivers/scsi/ipr.h b/drivers/scsi/ipr.h index e98a87a65335..c7f0e9e3cd7d 100644 --- a/drivers/scsi/ipr.h +++ b/drivers/scsi/ipr.h | |||
@@ -1488,6 +1488,8 @@ struct ipr_ioa_cfg { | |||
1488 | u8 cfg_locked:1; | 1488 | u8 cfg_locked:1; |
1489 | u8 clear_isr:1; | 1489 | u8 clear_isr:1; |
1490 | u8 probe_done:1; | 1490 | u8 probe_done:1; |
1491 | u8 scsi_unblock:1; | ||
1492 | u8 scsi_blocked:1; | ||
1491 | 1493 | ||
1492 | u8 revid; | 1494 | u8 revid; |
1493 | 1495 | ||
diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c index 4ed48ed38e79..7ee1a94c0b33 100644 --- a/drivers/scsi/lpfc/lpfc_attr.c +++ b/drivers/scsi/lpfc/lpfc_attr.c | |||
@@ -205,8 +205,10 @@ lpfc_nvme_info_show(struct device *dev, struct device_attribute *attr, | |||
205 | atomic_read(&tgtp->xmt_ls_rsp_error)); | 205 | atomic_read(&tgtp->xmt_ls_rsp_error)); |
206 | 206 | ||
207 | len += snprintf(buf+len, PAGE_SIZE-len, | 207 | len += snprintf(buf+len, PAGE_SIZE-len, |
208 | "FCP: Rcv %08x Release %08x Drop %08x\n", | 208 | "FCP: Rcv %08x Defer %08x Release %08x " |
209 | "Drop %08x\n", | ||
209 | atomic_read(&tgtp->rcv_fcp_cmd_in), | 210 | atomic_read(&tgtp->rcv_fcp_cmd_in), |
211 | atomic_read(&tgtp->rcv_fcp_cmd_defer), | ||
210 | atomic_read(&tgtp->xmt_fcp_release), | 212 | atomic_read(&tgtp->xmt_fcp_release), |
211 | atomic_read(&tgtp->rcv_fcp_cmd_drop)); | 213 | atomic_read(&tgtp->rcv_fcp_cmd_drop)); |
212 | 214 | ||
diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c index 5cc8b0f7d885..744f3f395b64 100644 --- a/drivers/scsi/lpfc/lpfc_debugfs.c +++ b/drivers/scsi/lpfc/lpfc_debugfs.c | |||
@@ -782,8 +782,11 @@ lpfc_debugfs_nvmestat_data(struct lpfc_vport *vport, char *buf, int size) | |||
782 | atomic_read(&tgtp->xmt_ls_rsp_error)); | 782 | atomic_read(&tgtp->xmt_ls_rsp_error)); |
783 | 783 | ||
784 | len += snprintf(buf + len, size - len, | 784 | len += snprintf(buf + len, size - len, |
785 | "FCP: Rcv %08x Drop %08x\n", | 785 | "FCP: Rcv %08x Defer %08x Release %08x " |
786 | "Drop %08x\n", | ||
786 | atomic_read(&tgtp->rcv_fcp_cmd_in), | 787 | atomic_read(&tgtp->rcv_fcp_cmd_in), |
788 | atomic_read(&tgtp->rcv_fcp_cmd_defer), | ||
789 | atomic_read(&tgtp->xmt_fcp_release), | ||
787 | atomic_read(&tgtp->rcv_fcp_cmd_drop)); | 790 | atomic_read(&tgtp->rcv_fcp_cmd_drop)); |
788 | 791 | ||
789 | if (atomic_read(&tgtp->rcv_fcp_cmd_in) != | 792 | if (atomic_read(&tgtp->rcv_fcp_cmd_in) != |
diff --git a/drivers/scsi/lpfc/lpfc_nvmet.c b/drivers/scsi/lpfc/lpfc_nvmet.c index fbeec344c6cc..bbbd0f84160d 100644 --- a/drivers/scsi/lpfc/lpfc_nvmet.c +++ b/drivers/scsi/lpfc/lpfc_nvmet.c | |||
@@ -841,12 +841,31 @@ lpfc_nvmet_xmt_fcp_release(struct nvmet_fc_target_port *tgtport, | |||
841 | lpfc_nvmet_ctxbuf_post(phba, ctxp->ctxbuf); | 841 | lpfc_nvmet_ctxbuf_post(phba, ctxp->ctxbuf); |
842 | } | 842 | } |
843 | 843 | ||
844 | static void | ||
845 | lpfc_nvmet_defer_rcv(struct nvmet_fc_target_port *tgtport, | ||
846 | struct nvmefc_tgt_fcp_req *rsp) | ||
847 | { | ||
848 | struct lpfc_nvmet_tgtport *tgtp; | ||
849 | struct lpfc_nvmet_rcv_ctx *ctxp = | ||
850 | container_of(rsp, struct lpfc_nvmet_rcv_ctx, ctx.fcp_req); | ||
851 | struct rqb_dmabuf *nvmebuf = ctxp->rqb_buffer; | ||
852 | struct lpfc_hba *phba = ctxp->phba; | ||
853 | |||
854 | lpfc_nvmeio_data(phba, "NVMET DEFERRCV: xri x%x sz %d CPU %02x\n", | ||
855 | ctxp->oxid, ctxp->size, smp_processor_id()); | ||
856 | |||
857 | tgtp = phba->targetport->private; | ||
858 | atomic_inc(&tgtp->rcv_fcp_cmd_defer); | ||
859 | lpfc_rq_buf_free(phba, &nvmebuf->hbuf); /* repost */ | ||
860 | } | ||
861 | |||
844 | static struct nvmet_fc_target_template lpfc_tgttemplate = { | 862 | static struct nvmet_fc_target_template lpfc_tgttemplate = { |
845 | .targetport_delete = lpfc_nvmet_targetport_delete, | 863 | .targetport_delete = lpfc_nvmet_targetport_delete, |
846 | .xmt_ls_rsp = lpfc_nvmet_xmt_ls_rsp, | 864 | .xmt_ls_rsp = lpfc_nvmet_xmt_ls_rsp, |
847 | .fcp_op = lpfc_nvmet_xmt_fcp_op, | 865 | .fcp_op = lpfc_nvmet_xmt_fcp_op, |
848 | .fcp_abort = lpfc_nvmet_xmt_fcp_abort, | 866 | .fcp_abort = lpfc_nvmet_xmt_fcp_abort, |
849 | .fcp_req_release = lpfc_nvmet_xmt_fcp_release, | 867 | .fcp_req_release = lpfc_nvmet_xmt_fcp_release, |
868 | .defer_rcv = lpfc_nvmet_defer_rcv, | ||
850 | 869 | ||
851 | .max_hw_queues = 1, | 870 | .max_hw_queues = 1, |
852 | .max_sgl_segments = LPFC_NVMET_DEFAULT_SEGS, | 871 | .max_sgl_segments = LPFC_NVMET_DEFAULT_SEGS, |
@@ -1504,6 +1523,17 @@ lpfc_nvmet_unsol_fcp_buffer(struct lpfc_hba *phba, | |||
1504 | return; | 1523 | return; |
1505 | } | 1524 | } |
1506 | 1525 | ||
1526 | /* Processing of FCP command is deferred */ | ||
1527 | if (rc == -EOVERFLOW) { | ||
1528 | lpfc_nvmeio_data(phba, | ||
1529 | "NVMET RCV BUSY: xri x%x sz %d from %06x\n", | ||
1530 | oxid, size, sid); | ||
1531 | /* defer reposting rcv buffer till .defer_rcv callback */ | ||
1532 | ctxp->rqb_buffer = nvmebuf; | ||
1533 | atomic_inc(&tgtp->rcv_fcp_cmd_out); | ||
1534 | return; | ||
1535 | } | ||
1536 | |||
1507 | atomic_inc(&tgtp->rcv_fcp_cmd_drop); | 1537 | atomic_inc(&tgtp->rcv_fcp_cmd_drop); |
1508 | lpfc_printf_log(phba, KERN_ERR, LOG_NVME_IOERR, | 1538 | lpfc_printf_log(phba, KERN_ERR, LOG_NVME_IOERR, |
1509 | "6159 FCP Drop IO x%x: err x%x: x%x x%x x%x\n", | 1539 | "6159 FCP Drop IO x%x: err x%x: x%x x%x x%x\n", |
diff --git a/drivers/scsi/lpfc/lpfc_nvmet.h b/drivers/scsi/lpfc/lpfc_nvmet.h index e675ef17be08..48a76788b003 100644 --- a/drivers/scsi/lpfc/lpfc_nvmet.h +++ b/drivers/scsi/lpfc/lpfc_nvmet.h | |||
@@ -49,6 +49,7 @@ struct lpfc_nvmet_tgtport { | |||
49 | atomic_t rcv_fcp_cmd_in; | 49 | atomic_t rcv_fcp_cmd_in; |
50 | atomic_t rcv_fcp_cmd_out; | 50 | atomic_t rcv_fcp_cmd_out; |
51 | atomic_t rcv_fcp_cmd_drop; | 51 | atomic_t rcv_fcp_cmd_drop; |
52 | atomic_t rcv_fcp_cmd_defer; | ||
52 | atomic_t xmt_fcp_release; | 53 | atomic_t xmt_fcp_release; |
53 | 54 | ||
54 | /* Stats counters - lpfc_nvmet_xmt_fcp_op */ | 55 | /* Stats counters - lpfc_nvmet_xmt_fcp_op */ |
diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c index 316c3df0c3fd..71c4746341ea 100644 --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c | |||
@@ -6228,8 +6228,8 @@ static int megasas_probe_one(struct pci_dev *pdev, | |||
6228 | fail_start_aen: | 6228 | fail_start_aen: |
6229 | fail_io_attach: | 6229 | fail_io_attach: |
6230 | megasas_mgmt_info.count--; | 6230 | megasas_mgmt_info.count--; |
6231 | megasas_mgmt_info.instance[megasas_mgmt_info.max_index] = NULL; | ||
6232 | megasas_mgmt_info.max_index--; | 6231 | megasas_mgmt_info.max_index--; |
6232 | megasas_mgmt_info.instance[megasas_mgmt_info.max_index] = NULL; | ||
6233 | 6233 | ||
6234 | instance->instancet->disable_intr(instance); | 6234 | instance->instancet->disable_intr(instance); |
6235 | megasas_destroy_irqs(instance); | 6235 | megasas_destroy_irqs(instance); |
diff --git a/drivers/scsi/qla2xxx/qla_tmpl.c b/drivers/scsi/qla2xxx/qla_tmpl.c index 33142610882f..b18646d6057f 100644 --- a/drivers/scsi/qla2xxx/qla_tmpl.c +++ b/drivers/scsi/qla2xxx/qla_tmpl.c | |||
@@ -401,9 +401,6 @@ qla27xx_fwdt_entry_t263(struct scsi_qla_host *vha, | |||
401 | for (i = 0; i < vha->hw->max_req_queues; i++) { | 401 | for (i = 0; i < vha->hw->max_req_queues; i++) { |
402 | struct req_que *req = vha->hw->req_q_map[i]; | 402 | struct req_que *req = vha->hw->req_q_map[i]; |
403 | 403 | ||
404 | if (!test_bit(i, vha->hw->req_qid_map)) | ||
405 | continue; | ||
406 | |||
407 | if (req || !buf) { | 404 | if (req || !buf) { |
408 | length = req ? | 405 | length = req ? |
409 | req->length : REQUEST_ENTRY_CNT_24XX; | 406 | req->length : REQUEST_ENTRY_CNT_24XX; |
@@ -418,9 +415,6 @@ qla27xx_fwdt_entry_t263(struct scsi_qla_host *vha, | |||
418 | for (i = 0; i < vha->hw->max_rsp_queues; i++) { | 415 | for (i = 0; i < vha->hw->max_rsp_queues; i++) { |
419 | struct rsp_que *rsp = vha->hw->rsp_q_map[i]; | 416 | struct rsp_que *rsp = vha->hw->rsp_q_map[i]; |
420 | 417 | ||
421 | if (!test_bit(i, vha->hw->rsp_qid_map)) | ||
422 | continue; | ||
423 | |||
424 | if (rsp || !buf) { | 418 | if (rsp || !buf) { |
425 | length = rsp ? | 419 | length = rsp ? |
426 | rsp->length : RESPONSE_ENTRY_CNT_MQ; | 420 | rsp->length : RESPONSE_ENTRY_CNT_MQ; |
@@ -660,9 +654,6 @@ qla27xx_fwdt_entry_t274(struct scsi_qla_host *vha, | |||
660 | for (i = 0; i < vha->hw->max_req_queues; i++) { | 654 | for (i = 0; i < vha->hw->max_req_queues; i++) { |
661 | struct req_que *req = vha->hw->req_q_map[i]; | 655 | struct req_que *req = vha->hw->req_q_map[i]; |
662 | 656 | ||
663 | if (!test_bit(i, vha->hw->req_qid_map)) | ||
664 | continue; | ||
665 | |||
666 | if (req || !buf) { | 657 | if (req || !buf) { |
667 | qla27xx_insert16(i, buf, len); | 658 | qla27xx_insert16(i, buf, len); |
668 | qla27xx_insert16(1, buf, len); | 659 | qla27xx_insert16(1, buf, len); |
@@ -675,9 +666,6 @@ qla27xx_fwdt_entry_t274(struct scsi_qla_host *vha, | |||
675 | for (i = 0; i < vha->hw->max_rsp_queues; i++) { | 666 | for (i = 0; i < vha->hw->max_rsp_queues; i++) { |
676 | struct rsp_que *rsp = vha->hw->rsp_q_map[i]; | 667 | struct rsp_que *rsp = vha->hw->rsp_q_map[i]; |
677 | 668 | ||
678 | if (!test_bit(i, vha->hw->rsp_qid_map)) | ||
679 | continue; | ||
680 | |||
681 | if (rsp || !buf) { | 669 | if (rsp || !buf) { |
682 | qla27xx_insert16(i, buf, len); | 670 | qla27xx_insert16(i, buf, len); |
683 | qla27xx_insert16(1, buf, len); | 671 | qla27xx_insert16(1, buf, len); |
diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c b/drivers/scsi/qla2xxx/tcm_qla2xxx.c index b20da0d27ad7..3f82ea1b72dc 100644 --- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c +++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c | |||
@@ -500,7 +500,6 @@ static int tcm_qla2xxx_handle_cmd(scsi_qla_host_t *vha, struct qla_tgt_cmd *cmd, | |||
500 | static void tcm_qla2xxx_handle_data_work(struct work_struct *work) | 500 | static void tcm_qla2xxx_handle_data_work(struct work_struct *work) |
501 | { | 501 | { |
502 | struct qla_tgt_cmd *cmd = container_of(work, struct qla_tgt_cmd, work); | 502 | struct qla_tgt_cmd *cmd = container_of(work, struct qla_tgt_cmd, work); |
503 | unsigned long flags; | ||
504 | 503 | ||
505 | /* | 504 | /* |
506 | * Ensure that the complete FCP WRITE payload has been received. | 505 | * Ensure that the complete FCP WRITE payload has been received. |
@@ -508,17 +507,6 @@ static void tcm_qla2xxx_handle_data_work(struct work_struct *work) | |||
508 | */ | 507 | */ |
509 | cmd->cmd_in_wq = 0; | 508 | cmd->cmd_in_wq = 0; |
510 | 509 | ||
511 | spin_lock_irqsave(&cmd->cmd_lock, flags); | ||
512 | cmd->data_work = 1; | ||
513 | if (cmd->aborted) { | ||
514 | cmd->data_work_free = 1; | ||
515 | spin_unlock_irqrestore(&cmd->cmd_lock, flags); | ||
516 | |||
517 | tcm_qla2xxx_free_cmd(cmd); | ||
518 | return; | ||
519 | } | ||
520 | spin_unlock_irqrestore(&cmd->cmd_lock, flags); | ||
521 | |||
522 | cmd->qpair->tgt_counters.qla_core_ret_ctio++; | 510 | cmd->qpair->tgt_counters.qla_core_ret_ctio++; |
523 | if (!cmd->write_data_transferred) { | 511 | if (!cmd->write_data_transferred) { |
524 | /* | 512 | /* |
@@ -765,31 +753,13 @@ static void tcm_qla2xxx_queue_tm_rsp(struct se_cmd *se_cmd) | |||
765 | qlt_xmit_tm_rsp(mcmd); | 753 | qlt_xmit_tm_rsp(mcmd); |
766 | } | 754 | } |
767 | 755 | ||
768 | #define DATA_WORK_NOT_FREE(_cmd) (_cmd->data_work && !_cmd->data_work_free) | ||
769 | static void tcm_qla2xxx_aborted_task(struct se_cmd *se_cmd) | 756 | static void tcm_qla2xxx_aborted_task(struct se_cmd *se_cmd) |
770 | { | 757 | { |
771 | struct qla_tgt_cmd *cmd = container_of(se_cmd, | 758 | struct qla_tgt_cmd *cmd = container_of(se_cmd, |
772 | struct qla_tgt_cmd, se_cmd); | 759 | struct qla_tgt_cmd, se_cmd); |
773 | unsigned long flags; | ||
774 | 760 | ||
775 | if (qlt_abort_cmd(cmd)) | 761 | if (qlt_abort_cmd(cmd)) |
776 | return; | 762 | return; |
777 | |||
778 | spin_lock_irqsave(&cmd->cmd_lock, flags); | ||
779 | if ((cmd->state == QLA_TGT_STATE_NEW)|| | ||
780 | ((cmd->state == QLA_TGT_STATE_DATA_IN) && | ||
781 | DATA_WORK_NOT_FREE(cmd))) { | ||
782 | cmd->data_work_free = 1; | ||
783 | spin_unlock_irqrestore(&cmd->cmd_lock, flags); | ||
784 | /* | ||
785 | * cmd has not reached fw, Use this trigger to free it. | ||
786 | */ | ||
787 | tcm_qla2xxx_free_cmd(cmd); | ||
788 | return; | ||
789 | } | ||
790 | spin_unlock_irqrestore(&cmd->cmd_lock, flags); | ||
791 | return; | ||
792 | |||
793 | } | 763 | } |
794 | 764 | ||
795 | static void tcm_qla2xxx_clear_sess_lookup(struct tcm_qla2xxx_lport *, | 765 | static void tcm_qla2xxx_clear_sess_lookup(struct tcm_qla2xxx_lport *, |
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c index 3d38c6d463b8..1bf274e3b2b6 100644 --- a/drivers/scsi/scsi.c +++ b/drivers/scsi/scsi.c | |||
@@ -800,7 +800,11 @@ MODULE_LICENSE("GPL"); | |||
800 | module_param(scsi_logging_level, int, S_IRUGO|S_IWUSR); | 800 | module_param(scsi_logging_level, int, S_IRUGO|S_IWUSR); |
801 | MODULE_PARM_DESC(scsi_logging_level, "a bit mask of logging levels"); | 801 | MODULE_PARM_DESC(scsi_logging_level, "a bit mask of logging levels"); |
802 | 802 | ||
803 | #ifdef CONFIG_SCSI_MQ_DEFAULT | ||
803 | bool scsi_use_blk_mq = true; | 804 | bool scsi_use_blk_mq = true; |
805 | #else | ||
806 | bool scsi_use_blk_mq = false; | ||
807 | #endif | ||
804 | module_param_named(use_blk_mq, scsi_use_blk_mq, bool, S_IWUSR | S_IRUGO); | 808 | module_param_named(use_blk_mq, scsi_use_blk_mq, bool, S_IWUSR | S_IRUGO); |
805 | 809 | ||
806 | static int __init init_scsi(void) | 810 | static int __init init_scsi(void) |
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index bea36adeee17..e2647f2d4430 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c | |||
@@ -1277,6 +1277,9 @@ static void sd_uninit_command(struct scsi_cmnd *SCpnt) | |||
1277 | { | 1277 | { |
1278 | struct request *rq = SCpnt->request; | 1278 | struct request *rq = SCpnt->request; |
1279 | 1279 | ||
1280 | if (SCpnt->flags & SCMD_ZONE_WRITE_LOCK) | ||
1281 | sd_zbc_write_unlock_zone(SCpnt); | ||
1282 | |||
1280 | if (rq->rq_flags & RQF_SPECIAL_PAYLOAD) | 1283 | if (rq->rq_flags & RQF_SPECIAL_PAYLOAD) |
1281 | __free_page(rq->special_vec.bv_page); | 1284 | __free_page(rq->special_vec.bv_page); |
1282 | 1285 | ||
diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c index 96855df9f49d..8aa54779aac1 100644 --- a/drivers/scsi/sd_zbc.c +++ b/drivers/scsi/sd_zbc.c | |||
@@ -294,6 +294,9 @@ int sd_zbc_write_lock_zone(struct scsi_cmnd *cmd) | |||
294 | test_and_set_bit(zno, sdkp->zones_wlock)) | 294 | test_and_set_bit(zno, sdkp->zones_wlock)) |
295 | return BLKPREP_DEFER; | 295 | return BLKPREP_DEFER; |
296 | 296 | ||
297 | WARN_ON_ONCE(cmd->flags & SCMD_ZONE_WRITE_LOCK); | ||
298 | cmd->flags |= SCMD_ZONE_WRITE_LOCK; | ||
299 | |||
297 | return BLKPREP_OK; | 300 | return BLKPREP_OK; |
298 | } | 301 | } |
299 | 302 | ||
@@ -302,9 +305,10 @@ void sd_zbc_write_unlock_zone(struct scsi_cmnd *cmd) | |||
302 | struct request *rq = cmd->request; | 305 | struct request *rq = cmd->request; |
303 | struct scsi_disk *sdkp = scsi_disk(rq->rq_disk); | 306 | struct scsi_disk *sdkp = scsi_disk(rq->rq_disk); |
304 | 307 | ||
305 | if (sdkp->zones_wlock) { | 308 | if (sdkp->zones_wlock && cmd->flags & SCMD_ZONE_WRITE_LOCK) { |
306 | unsigned int zno = sd_zbc_zone_no(sdkp, blk_rq_pos(rq)); | 309 | unsigned int zno = sd_zbc_zone_no(sdkp, blk_rq_pos(rq)); |
307 | WARN_ON_ONCE(!test_bit(zno, sdkp->zones_wlock)); | 310 | WARN_ON_ONCE(!test_bit(zno, sdkp->zones_wlock)); |
311 | cmd->flags &= ~SCMD_ZONE_WRITE_LOCK; | ||
308 | clear_bit_unlock(zno, sdkp->zones_wlock); | 312 | clear_bit_unlock(zno, sdkp->zones_wlock); |
309 | smp_mb__after_atomic(); | 313 | smp_mb__after_atomic(); |
310 | } | 314 | } |
@@ -335,9 +339,6 @@ void sd_zbc_complete(struct scsi_cmnd *cmd, | |||
335 | case REQ_OP_WRITE_ZEROES: | 339 | case REQ_OP_WRITE_ZEROES: |
336 | case REQ_OP_WRITE_SAME: | 340 | case REQ_OP_WRITE_SAME: |
337 | 341 | ||
338 | /* Unlock the zone */ | ||
339 | sd_zbc_write_unlock_zone(cmd); | ||
340 | |||
341 | if (result && | 342 | if (result && |
342 | sshdr->sense_key == ILLEGAL_REQUEST && | 343 | sshdr->sense_key == ILLEGAL_REQUEST && |
343 | sshdr->asc == 0x21) | 344 | sshdr->asc == 0x21) |
diff --git a/drivers/scsi/ses.c b/drivers/scsi/ses.c index f1cdf32d7514..8927f9f54ad9 100644 --- a/drivers/scsi/ses.c +++ b/drivers/scsi/ses.c | |||
@@ -99,7 +99,7 @@ static int ses_recv_diag(struct scsi_device *sdev, int page_code, | |||
99 | 99 | ||
100 | ret = scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buf, bufflen, | 100 | ret = scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buf, bufflen, |
101 | NULL, SES_TIMEOUT, SES_RETRIES, NULL); | 101 | NULL, SES_TIMEOUT, SES_RETRIES, NULL); |
102 | if (unlikely(!ret)) | 102 | if (unlikely(ret)) |
103 | return ret; | 103 | return ret; |
104 | 104 | ||
105 | recv_page_code = ((unsigned char *)buf)[0]; | 105 | recv_page_code = ((unsigned char *)buf)[0]; |
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c index 8e5013d9cad4..94e402ed30f6 100644 --- a/drivers/scsi/st.c +++ b/drivers/scsi/st.c | |||
@@ -4299,11 +4299,11 @@ static int st_probe(struct device *dev) | |||
4299 | kref_init(&tpnt->kref); | 4299 | kref_init(&tpnt->kref); |
4300 | tpnt->disk = disk; | 4300 | tpnt->disk = disk; |
4301 | disk->private_data = &tpnt->driver; | 4301 | disk->private_data = &tpnt->driver; |
4302 | disk->queue = SDp->request_queue; | ||
4303 | /* SCSI tape doesn't register this gendisk via add_disk(). Manually | 4302 | /* SCSI tape doesn't register this gendisk via add_disk(). Manually |
4304 | * take queue reference that release_disk() expects. */ | 4303 | * take queue reference that release_disk() expects. */ |
4305 | if (!blk_get_queue(disk->queue)) | 4304 | if (!blk_get_queue(SDp->request_queue)) |
4306 | goto out_put_disk; | 4305 | goto out_put_disk; |
4306 | disk->queue = SDp->request_queue; | ||
4307 | tpnt->driver = &st_template; | 4307 | tpnt->driver = &st_template; |
4308 | 4308 | ||
4309 | tpnt->device = SDp; | 4309 | tpnt->device = SDp; |
diff --git a/drivers/sfi/sfi_core.c b/drivers/sfi/sfi_core.c index 296db7a69c27..153b3f3cc795 100644 --- a/drivers/sfi/sfi_core.c +++ b/drivers/sfi/sfi_core.c | |||
@@ -68,6 +68,7 @@ | |||
68 | #include <linux/init.h> | 68 | #include <linux/init.h> |
69 | #include <linux/sfi.h> | 69 | #include <linux/sfi.h> |
70 | #include <linux/slab.h> | 70 | #include <linux/slab.h> |
71 | #include <linux/io.h> | ||
71 | 72 | ||
72 | #include "sfi_core.h" | 73 | #include "sfi_core.h" |
73 | 74 | ||
@@ -86,13 +87,13 @@ static struct sfi_table_simple *syst_va __read_mostly; | |||
86 | /* | 87 | /* |
87 | * FW creates and saves the SFI tables in memory. When these tables get | 88 | * FW creates and saves the SFI tables in memory. When these tables get |
88 | * used, they may need to be mapped to virtual address space, and the mapping | 89 | * used, they may need to be mapped to virtual address space, and the mapping |
89 | * can happen before or after the ioremap() is ready, so a flag is needed | 90 | * can happen before or after the memremap() is ready, so a flag is needed |
90 | * to indicating this | 91 | * to indicating this |
91 | */ | 92 | */ |
92 | static u32 sfi_use_ioremap __read_mostly; | 93 | static u32 sfi_use_memremap __read_mostly; |
93 | 94 | ||
94 | /* | 95 | /* |
95 | * sfi_un/map_memory calls early_ioremap/iounmap which is a __init function | 96 | * sfi_un/map_memory calls early_memremap/memunmap which is a __init function |
96 | * and introduces section mismatch. So use __ref to make it calm. | 97 | * and introduces section mismatch. So use __ref to make it calm. |
97 | */ | 98 | */ |
98 | static void __iomem * __ref sfi_map_memory(u64 phys, u32 size) | 99 | static void __iomem * __ref sfi_map_memory(u64 phys, u32 size) |
@@ -100,10 +101,10 @@ static void __iomem * __ref sfi_map_memory(u64 phys, u32 size) | |||
100 | if (!phys || !size) | 101 | if (!phys || !size) |
101 | return NULL; | 102 | return NULL; |
102 | 103 | ||
103 | if (sfi_use_ioremap) | 104 | if (sfi_use_memremap) |
104 | return ioremap_cache(phys, size); | 105 | return memremap(phys, size, MEMREMAP_WB); |
105 | else | 106 | else |
106 | return early_ioremap(phys, size); | 107 | return early_memremap(phys, size); |
107 | } | 108 | } |
108 | 109 | ||
109 | static void __ref sfi_unmap_memory(void __iomem *virt, u32 size) | 110 | static void __ref sfi_unmap_memory(void __iomem *virt, u32 size) |
@@ -111,10 +112,10 @@ static void __ref sfi_unmap_memory(void __iomem *virt, u32 size) | |||
111 | if (!virt || !size) | 112 | if (!virt || !size) |
112 | return; | 113 | return; |
113 | 114 | ||
114 | if (sfi_use_ioremap) | 115 | if (sfi_use_memremap) |
115 | iounmap(virt); | 116 | memunmap(virt); |
116 | else | 117 | else |
117 | early_iounmap(virt, size); | 118 | early_memunmap(virt, size); |
118 | } | 119 | } |
119 | 120 | ||
120 | static void sfi_print_table_header(unsigned long long pa, | 121 | static void sfi_print_table_header(unsigned long long pa, |
@@ -507,8 +508,8 @@ void __init sfi_init_late(void) | |||
507 | length = syst_va->header.len; | 508 | length = syst_va->header.len; |
508 | sfi_unmap_memory(syst_va, sizeof(struct sfi_table_simple)); | 509 | sfi_unmap_memory(syst_va, sizeof(struct sfi_table_simple)); |
509 | 510 | ||
510 | /* Use ioremap now after it is ready */ | 511 | /* Use memremap now after it is ready */ |
511 | sfi_use_ioremap = 1; | 512 | sfi_use_memremap = 1; |
512 | syst_va = sfi_map_memory(syst_pa, length); | 513 | syst_va = sfi_map_memory(syst_pa, length); |
513 | 514 | ||
514 | sfi_acpi_init(); | 515 | sfi_acpi_init(); |
diff --git a/drivers/soc/imx/gpcv2.c b/drivers/soc/imx/gpcv2.c index 3039072911a5..afc7ecc3c187 100644 --- a/drivers/soc/imx/gpcv2.c +++ b/drivers/soc/imx/gpcv2.c | |||
@@ -200,16 +200,11 @@ static int imx7_pgc_domain_probe(struct platform_device *pdev) | |||
200 | 200 | ||
201 | domain->dev = &pdev->dev; | 201 | domain->dev = &pdev->dev; |
202 | 202 | ||
203 | ret = pm_genpd_init(&domain->genpd, NULL, true); | ||
204 | if (ret) { | ||
205 | dev_err(domain->dev, "Failed to init power domain\n"); | ||
206 | return ret; | ||
207 | } | ||
208 | |||
209 | domain->regulator = devm_regulator_get_optional(domain->dev, "power"); | 203 | domain->regulator = devm_regulator_get_optional(domain->dev, "power"); |
210 | if (IS_ERR(domain->regulator)) { | 204 | if (IS_ERR(domain->regulator)) { |
211 | if (PTR_ERR(domain->regulator) != -ENODEV) { | 205 | if (PTR_ERR(domain->regulator) != -ENODEV) { |
212 | dev_err(domain->dev, "Failed to get domain's regulator\n"); | 206 | if (PTR_ERR(domain->regulator) != -EPROBE_DEFER) |
207 | dev_err(domain->dev, "Failed to get domain's regulator\n"); | ||
213 | return PTR_ERR(domain->regulator); | 208 | return PTR_ERR(domain->regulator); |
214 | } | 209 | } |
215 | } else { | 210 | } else { |
@@ -217,6 +212,12 @@ static int imx7_pgc_domain_probe(struct platform_device *pdev) | |||
217 | domain->voltage, domain->voltage); | 212 | domain->voltage, domain->voltage); |
218 | } | 213 | } |
219 | 214 | ||
215 | ret = pm_genpd_init(&domain->genpd, NULL, true); | ||
216 | if (ret) { | ||
217 | dev_err(domain->dev, "Failed to init power domain\n"); | ||
218 | return ret; | ||
219 | } | ||
220 | |||
220 | ret = of_genpd_add_provider_simple(domain->dev->of_node, | 221 | ret = of_genpd_add_provider_simple(domain->dev->of_node, |
221 | &domain->genpd); | 222 | &domain->genpd); |
222 | if (ret) { | 223 | if (ret) { |
diff --git a/drivers/soc/ti/knav_qmss_queue.c b/drivers/soc/ti/knav_qmss_queue.c index 279e7c5551dd..39225de9d7f1 100644 --- a/drivers/soc/ti/knav_qmss_queue.c +++ b/drivers/soc/ti/knav_qmss_queue.c | |||
@@ -745,6 +745,9 @@ void *knav_pool_create(const char *name, | |||
745 | bool slot_found; | 745 | bool slot_found; |
746 | int ret; | 746 | int ret; |
747 | 747 | ||
748 | if (!kdev) | ||
749 | return ERR_PTR(-EPROBE_DEFER); | ||
750 | |||
748 | if (!kdev->dev) | 751 | if (!kdev->dev) |
749 | return ERR_PTR(-ENODEV); | 752 | return ERR_PTR(-ENODEV); |
750 | 753 | ||
diff --git a/drivers/soc/ti/ti_sci_pm_domains.c b/drivers/soc/ti/ti_sci_pm_domains.c index b0b283810e72..de31b9389e2e 100644 --- a/drivers/soc/ti/ti_sci_pm_domains.c +++ b/drivers/soc/ti/ti_sci_pm_domains.c | |||
@@ -176,6 +176,8 @@ static int ti_sci_pm_domain_probe(struct platform_device *pdev) | |||
176 | 176 | ||
177 | ti_sci_pd->dev = dev; | 177 | ti_sci_pd->dev = dev; |
178 | 178 | ||
179 | ti_sci_pd->pd.name = "ti_sci_pd"; | ||
180 | |||
179 | ti_sci_pd->pd.attach_dev = ti_sci_pd_attach_dev; | 181 | ti_sci_pd->pd.attach_dev = ti_sci_pd_attach_dev; |
180 | ti_sci_pd->pd.detach_dev = ti_sci_pd_detach_dev; | 182 | ti_sci_pd->pd.detach_dev = ti_sci_pd_detach_dev; |
181 | 183 | ||
diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index ca11be21f64b..34ca7823255d 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c | |||
@@ -2396,6 +2396,7 @@ static ssize_t comedi_write(struct file *file, const char __user *buf, | |||
2396 | continue; | 2396 | continue; |
2397 | } | 2397 | } |
2398 | 2398 | ||
2399 | set_current_state(TASK_RUNNING); | ||
2399 | wp = async->buf_write_ptr; | 2400 | wp = async->buf_write_ptr; |
2400 | n1 = min(n, async->prealloc_bufsz - wp); | 2401 | n1 = min(n, async->prealloc_bufsz - wp); |
2401 | n2 = n - n1; | 2402 | n2 = n - n1; |
@@ -2528,6 +2529,8 @@ static ssize_t comedi_read(struct file *file, char __user *buf, size_t nbytes, | |||
2528 | } | 2529 | } |
2529 | continue; | 2530 | continue; |
2530 | } | 2531 | } |
2532 | |||
2533 | set_current_state(TASK_RUNNING); | ||
2531 | rp = async->buf_read_ptr; | 2534 | rp = async->buf_read_ptr; |
2532 | n1 = min(n, async->prealloc_bufsz - rp); | 2535 | n1 = min(n, async->prealloc_bufsz - rp); |
2533 | n2 = n - n1; | 2536 | n2 = n - n1; |
diff --git a/drivers/staging/iio/resolver/ad2s1210.c b/drivers/staging/iio/resolver/ad2s1210.c index a6a8393d6664..3e00df74b18c 100644 --- a/drivers/staging/iio/resolver/ad2s1210.c +++ b/drivers/staging/iio/resolver/ad2s1210.c | |||
@@ -472,7 +472,7 @@ static int ad2s1210_read_raw(struct iio_dev *indio_dev, | |||
472 | long m) | 472 | long m) |
473 | { | 473 | { |
474 | struct ad2s1210_state *st = iio_priv(indio_dev); | 474 | struct ad2s1210_state *st = iio_priv(indio_dev); |
475 | bool negative; | 475 | u16 negative; |
476 | int ret = 0; | 476 | int ret = 0; |
477 | u16 pos; | 477 | u16 pos; |
478 | s16 vel; | 478 | s16 vel; |
diff --git a/drivers/target/iscsi/cxgbit/cxgbit_cm.c b/drivers/target/iscsi/cxgbit/cxgbit_cm.c index e583dd8a418b..d4fa41be80f9 100644 --- a/drivers/target/iscsi/cxgbit/cxgbit_cm.c +++ b/drivers/target/iscsi/cxgbit/cxgbit_cm.c | |||
@@ -1510,11 +1510,13 @@ cxgbit_pass_open_rpl(struct cxgbit_device *cdev, struct sk_buff *skb) | |||
1510 | 1510 | ||
1511 | if (!cnp) { | 1511 | if (!cnp) { |
1512 | pr_info("%s stid %d lookup failure\n", __func__, stid); | 1512 | pr_info("%s stid %d lookup failure\n", __func__, stid); |
1513 | return; | 1513 | goto rel_skb; |
1514 | } | 1514 | } |
1515 | 1515 | ||
1516 | cxgbit_wake_up(&cnp->com.wr_wait, __func__, rpl->status); | 1516 | cxgbit_wake_up(&cnp->com.wr_wait, __func__, rpl->status); |
1517 | cxgbit_put_cnp(cnp); | 1517 | cxgbit_put_cnp(cnp); |
1518 | rel_skb: | ||
1519 | __kfree_skb(skb); | ||
1518 | } | 1520 | } |
1519 | 1521 | ||
1520 | static void | 1522 | static void |
@@ -1530,11 +1532,13 @@ cxgbit_close_listsrv_rpl(struct cxgbit_device *cdev, struct sk_buff *skb) | |||
1530 | 1532 | ||
1531 | if (!cnp) { | 1533 | if (!cnp) { |
1532 | pr_info("%s stid %d lookup failure\n", __func__, stid); | 1534 | pr_info("%s stid %d lookup failure\n", __func__, stid); |
1533 | return; | 1535 | goto rel_skb; |
1534 | } | 1536 | } |
1535 | 1537 | ||
1536 | cxgbit_wake_up(&cnp->com.wr_wait, __func__, rpl->status); | 1538 | cxgbit_wake_up(&cnp->com.wr_wait, __func__, rpl->status); |
1537 | cxgbit_put_cnp(cnp); | 1539 | cxgbit_put_cnp(cnp); |
1540 | rel_skb: | ||
1541 | __kfree_skb(skb); | ||
1538 | } | 1542 | } |
1539 | 1543 | ||
1540 | static void | 1544 | static void |
@@ -1819,12 +1823,16 @@ static void cxgbit_set_tcb_rpl(struct cxgbit_device *cdev, struct sk_buff *skb) | |||
1819 | struct tid_info *t = lldi->tids; | 1823 | struct tid_info *t = lldi->tids; |
1820 | 1824 | ||
1821 | csk = lookup_tid(t, tid); | 1825 | csk = lookup_tid(t, tid); |
1822 | if (unlikely(!csk)) | 1826 | if (unlikely(!csk)) { |
1823 | pr_err("can't find connection for tid %u.\n", tid); | 1827 | pr_err("can't find connection for tid %u.\n", tid); |
1824 | else | 1828 | goto rel_skb; |
1829 | } else { | ||
1825 | cxgbit_wake_up(&csk->com.wr_wait, __func__, rpl->status); | 1830 | cxgbit_wake_up(&csk->com.wr_wait, __func__, rpl->status); |
1831 | } | ||
1826 | 1832 | ||
1827 | cxgbit_put_csk(csk); | 1833 | cxgbit_put_csk(csk); |
1834 | rel_skb: | ||
1835 | __kfree_skb(skb); | ||
1828 | } | 1836 | } |
1829 | 1837 | ||
1830 | static void cxgbit_rx_data(struct cxgbit_device *cdev, struct sk_buff *skb) | 1838 | static void cxgbit_rx_data(struct cxgbit_device *cdev, struct sk_buff *skb) |
diff --git a/drivers/target/iscsi/cxgbit/cxgbit_target.c b/drivers/target/iscsi/cxgbit/cxgbit_target.c index dda13f1af38e..514986b57c2d 100644 --- a/drivers/target/iscsi/cxgbit/cxgbit_target.c +++ b/drivers/target/iscsi/cxgbit/cxgbit_target.c | |||
@@ -827,7 +827,7 @@ cxgbit_put_login_tx(struct iscsi_conn *conn, struct iscsi_login *login, | |||
827 | 827 | ||
828 | static void | 828 | static void |
829 | cxgbit_skb_copy_to_sg(struct sk_buff *skb, struct scatterlist *sg, | 829 | cxgbit_skb_copy_to_sg(struct sk_buff *skb, struct scatterlist *sg, |
830 | unsigned int nents) | 830 | unsigned int nents, u32 skip) |
831 | { | 831 | { |
832 | struct skb_seq_state st; | 832 | struct skb_seq_state st; |
833 | const u8 *buf; | 833 | const u8 *buf; |
@@ -846,7 +846,7 @@ cxgbit_skb_copy_to_sg(struct sk_buff *skb, struct scatterlist *sg, | |||
846 | } | 846 | } |
847 | 847 | ||
848 | consumed += sg_pcopy_from_buffer(sg, nents, (void *)buf, | 848 | consumed += sg_pcopy_from_buffer(sg, nents, (void *)buf, |
849 | buf_len, consumed); | 849 | buf_len, skip + consumed); |
850 | } | 850 | } |
851 | } | 851 | } |
852 | 852 | ||
@@ -912,7 +912,7 @@ cxgbit_handle_immediate_data(struct iscsi_cmd *cmd, struct iscsi_scsi_req *hdr, | |||
912 | struct scatterlist *sg = &cmd->se_cmd.t_data_sg[0]; | 912 | struct scatterlist *sg = &cmd->se_cmd.t_data_sg[0]; |
913 | u32 sg_nents = max(1UL, DIV_ROUND_UP(pdu_cb->dlen, PAGE_SIZE)); | 913 | u32 sg_nents = max(1UL, DIV_ROUND_UP(pdu_cb->dlen, PAGE_SIZE)); |
914 | 914 | ||
915 | cxgbit_skb_copy_to_sg(csk->skb, sg, sg_nents); | 915 | cxgbit_skb_copy_to_sg(csk->skb, sg, sg_nents, 0); |
916 | } | 916 | } |
917 | 917 | ||
918 | cmd->write_data_done += pdu_cb->dlen; | 918 | cmd->write_data_done += pdu_cb->dlen; |
@@ -1069,11 +1069,13 @@ static int cxgbit_handle_iscsi_dataout(struct cxgbit_sock *csk) | |||
1069 | cmd->se_cmd.data_length); | 1069 | cmd->se_cmd.data_length); |
1070 | 1070 | ||
1071 | if (!(pdu_cb->flags & PDUCBF_RX_DATA_DDPD)) { | 1071 | if (!(pdu_cb->flags & PDUCBF_RX_DATA_DDPD)) { |
1072 | u32 skip = data_offset % PAGE_SIZE; | ||
1073 | |||
1072 | sg_off = data_offset / PAGE_SIZE; | 1074 | sg_off = data_offset / PAGE_SIZE; |
1073 | sg_start = &cmd->se_cmd.t_data_sg[sg_off]; | 1075 | sg_start = &cmd->se_cmd.t_data_sg[sg_off]; |
1074 | sg_nents = max(1UL, DIV_ROUND_UP(data_len, PAGE_SIZE)); | 1076 | sg_nents = max(1UL, DIV_ROUND_UP(skip + data_len, PAGE_SIZE)); |
1075 | 1077 | ||
1076 | cxgbit_skb_copy_to_sg(csk->skb, sg_start, sg_nents); | 1078 | cxgbit_skb_copy_to_sg(csk->skb, sg_start, sg_nents, skip); |
1077 | } | 1079 | } |
1078 | 1080 | ||
1079 | check_payload: | 1081 | check_payload: |
diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c index 74e4975dd1b1..5001261f5d69 100644 --- a/drivers/target/iscsi/iscsi_target.c +++ b/drivers/target/iscsi/iscsi_target.c | |||
@@ -418,6 +418,7 @@ int iscsit_reset_np_thread( | |||
418 | return 0; | 418 | return 0; |
419 | } | 419 | } |
420 | np->np_thread_state = ISCSI_NP_THREAD_RESET; | 420 | np->np_thread_state = ISCSI_NP_THREAD_RESET; |
421 | atomic_inc(&np->np_reset_count); | ||
421 | 422 | ||
422 | if (np->np_thread) { | 423 | if (np->np_thread) { |
423 | spin_unlock_bh(&np->np_thread_lock); | 424 | spin_unlock_bh(&np->np_thread_lock); |
@@ -2167,6 +2168,7 @@ iscsit_setup_text_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd, | |||
2167 | cmd->cmd_sn = be32_to_cpu(hdr->cmdsn); | 2168 | cmd->cmd_sn = be32_to_cpu(hdr->cmdsn); |
2168 | cmd->exp_stat_sn = be32_to_cpu(hdr->exp_statsn); | 2169 | cmd->exp_stat_sn = be32_to_cpu(hdr->exp_statsn); |
2169 | cmd->data_direction = DMA_NONE; | 2170 | cmd->data_direction = DMA_NONE; |
2171 | kfree(cmd->text_in_ptr); | ||
2170 | cmd->text_in_ptr = NULL; | 2172 | cmd->text_in_ptr = NULL; |
2171 | 2173 | ||
2172 | return 0; | 2174 | return 0; |
@@ -3487,9 +3489,9 @@ iscsit_build_text_rsp(struct iscsi_cmd *cmd, struct iscsi_conn *conn, | |||
3487 | return text_length; | 3489 | return text_length; |
3488 | 3490 | ||
3489 | if (completed) { | 3491 | if (completed) { |
3490 | hdr->flags |= ISCSI_FLAG_CMD_FINAL; | 3492 | hdr->flags = ISCSI_FLAG_CMD_FINAL; |
3491 | } else { | 3493 | } else { |
3492 | hdr->flags |= ISCSI_FLAG_TEXT_CONTINUE; | 3494 | hdr->flags = ISCSI_FLAG_TEXT_CONTINUE; |
3493 | cmd->read_data_done += text_length; | 3495 | cmd->read_data_done += text_length; |
3494 | if (cmd->targ_xfer_tag == 0xFFFFFFFF) | 3496 | if (cmd->targ_xfer_tag == 0xFFFFFFFF) |
3495 | cmd->targ_xfer_tag = session_get_next_ttt(conn->sess); | 3497 | cmd->targ_xfer_tag = session_get_next_ttt(conn->sess); |
diff --git a/drivers/target/iscsi/iscsi_target_login.c b/drivers/target/iscsi/iscsi_target_login.c index e9bdc8b86e7d..dc13afbd4c88 100644 --- a/drivers/target/iscsi/iscsi_target_login.c +++ b/drivers/target/iscsi/iscsi_target_login.c | |||
@@ -1243,9 +1243,11 @@ static int __iscsi_target_login_thread(struct iscsi_np *np) | |||
1243 | flush_signals(current); | 1243 | flush_signals(current); |
1244 | 1244 | ||
1245 | spin_lock_bh(&np->np_thread_lock); | 1245 | spin_lock_bh(&np->np_thread_lock); |
1246 | if (np->np_thread_state == ISCSI_NP_THREAD_RESET) { | 1246 | if (atomic_dec_if_positive(&np->np_reset_count) >= 0) { |
1247 | np->np_thread_state = ISCSI_NP_THREAD_ACTIVE; | 1247 | np->np_thread_state = ISCSI_NP_THREAD_ACTIVE; |
1248 | spin_unlock_bh(&np->np_thread_lock); | ||
1248 | complete(&np->np_restart_comp); | 1249 | complete(&np->np_restart_comp); |
1250 | return 1; | ||
1249 | } else if (np->np_thread_state == ISCSI_NP_THREAD_SHUTDOWN) { | 1251 | } else if (np->np_thread_state == ISCSI_NP_THREAD_SHUTDOWN) { |
1250 | spin_unlock_bh(&np->np_thread_lock); | 1252 | spin_unlock_bh(&np->np_thread_lock); |
1251 | goto exit; | 1253 | goto exit; |
@@ -1278,7 +1280,8 @@ static int __iscsi_target_login_thread(struct iscsi_np *np) | |||
1278 | goto exit; | 1280 | goto exit; |
1279 | } else if (rc < 0) { | 1281 | } else if (rc < 0) { |
1280 | spin_lock_bh(&np->np_thread_lock); | 1282 | spin_lock_bh(&np->np_thread_lock); |
1281 | if (np->np_thread_state == ISCSI_NP_THREAD_RESET) { | 1283 | if (atomic_dec_if_positive(&np->np_reset_count) >= 0) { |
1284 | np->np_thread_state = ISCSI_NP_THREAD_ACTIVE; | ||
1282 | spin_unlock_bh(&np->np_thread_lock); | 1285 | spin_unlock_bh(&np->np_thread_lock); |
1283 | complete(&np->np_restart_comp); | 1286 | complete(&np->np_restart_comp); |
1284 | iscsit_put_transport(conn->conn_transport); | 1287 | iscsit_put_transport(conn->conn_transport); |
diff --git a/drivers/target/target_core_tpg.c b/drivers/target/target_core_tpg.c index 36913734c6bc..02e8a5d86658 100644 --- a/drivers/target/target_core_tpg.c +++ b/drivers/target/target_core_tpg.c | |||
@@ -364,7 +364,7 @@ void core_tpg_del_initiator_node_acl(struct se_node_acl *acl) | |||
364 | mutex_lock(&tpg->acl_node_mutex); | 364 | mutex_lock(&tpg->acl_node_mutex); |
365 | if (acl->dynamic_node_acl) | 365 | if (acl->dynamic_node_acl) |
366 | acl->dynamic_node_acl = 0; | 366 | acl->dynamic_node_acl = 0; |
367 | list_del(&acl->acl_list); | 367 | list_del_init(&acl->acl_list); |
368 | mutex_unlock(&tpg->acl_node_mutex); | 368 | mutex_unlock(&tpg->acl_node_mutex); |
369 | 369 | ||
370 | target_shutdown_sessions(acl); | 370 | target_shutdown_sessions(acl); |
@@ -548,7 +548,7 @@ int core_tpg_deregister(struct se_portal_group *se_tpg) | |||
548 | * in transport_deregister_session(). | 548 | * in transport_deregister_session(). |
549 | */ | 549 | */ |
550 | list_for_each_entry_safe(nacl, nacl_tmp, &node_list, acl_list) { | 550 | list_for_each_entry_safe(nacl, nacl_tmp, &node_list, acl_list) { |
551 | list_del(&nacl->acl_list); | 551 | list_del_init(&nacl->acl_list); |
552 | 552 | ||
553 | core_tpg_wait_for_nacl_pr_ref(nacl); | 553 | core_tpg_wait_for_nacl_pr_ref(nacl); |
554 | core_free_device_list_for_node(nacl, se_tpg); | 554 | core_free_device_list_for_node(nacl, se_tpg); |
diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index 97fed9a298bd..836d552b0385 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c | |||
@@ -466,7 +466,7 @@ static void target_complete_nacl(struct kref *kref) | |||
466 | } | 466 | } |
467 | 467 | ||
468 | mutex_lock(&se_tpg->acl_node_mutex); | 468 | mutex_lock(&se_tpg->acl_node_mutex); |
469 | list_del(&nacl->acl_list); | 469 | list_del_init(&nacl->acl_list); |
470 | mutex_unlock(&se_tpg->acl_node_mutex); | 470 | mutex_unlock(&se_tpg->acl_node_mutex); |
471 | 471 | ||
472 | core_tpg_wait_for_nacl_pr_ref(nacl); | 472 | core_tpg_wait_for_nacl_pr_ref(nacl); |
@@ -538,7 +538,7 @@ void transport_free_session(struct se_session *se_sess) | |||
538 | spin_unlock_irqrestore(&se_nacl->nacl_sess_lock, flags); | 538 | spin_unlock_irqrestore(&se_nacl->nacl_sess_lock, flags); |
539 | 539 | ||
540 | if (se_nacl->dynamic_stop) | 540 | if (se_nacl->dynamic_stop) |
541 | list_del(&se_nacl->acl_list); | 541 | list_del_init(&se_nacl->acl_list); |
542 | } | 542 | } |
543 | mutex_unlock(&se_tpg->acl_node_mutex); | 543 | mutex_unlock(&se_tpg->acl_node_mutex); |
544 | 544 | ||
diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c index 80ee130f8253..942d094269fb 100644 --- a/drivers/target/target_core_user.c +++ b/drivers/target/target_core_user.c | |||
@@ -563,8 +563,6 @@ static int scatter_data_area(struct tcmu_dev *udev, | |||
563 | block_remaining); | 563 | block_remaining); |
564 | to_offset = get_block_offset_user(udev, dbi, | 564 | to_offset = get_block_offset_user(udev, dbi, |
565 | block_remaining); | 565 | block_remaining); |
566 | offset = DATA_BLOCK_SIZE - block_remaining; | ||
567 | to += offset; | ||
568 | 566 | ||
569 | if (*iov_cnt != 0 && | 567 | if (*iov_cnt != 0 && |
570 | to_offset == iov_tail(*iov)) { | 568 | to_offset == iov_tail(*iov)) { |
@@ -575,8 +573,10 @@ static int scatter_data_area(struct tcmu_dev *udev, | |||
575 | (*iov)->iov_len = copy_bytes; | 573 | (*iov)->iov_len = copy_bytes; |
576 | } | 574 | } |
577 | if (copy_data) { | 575 | if (copy_data) { |
578 | memcpy(to, from + sg->length - sg_remaining, | 576 | offset = DATA_BLOCK_SIZE - block_remaining; |
579 | copy_bytes); | 577 | memcpy(to + offset, |
578 | from + sg->length - sg_remaining, | ||
579 | copy_bytes); | ||
580 | tcmu_flush_dcache_range(to, copy_bytes); | 580 | tcmu_flush_dcache_range(to, copy_bytes); |
581 | } | 581 | } |
582 | sg_remaining -= copy_bytes; | 582 | sg_remaining -= copy_bytes; |
@@ -637,9 +637,8 @@ static void gather_data_area(struct tcmu_dev *udev, struct tcmu_cmd *cmd, | |||
637 | copy_bytes = min_t(size_t, sg_remaining, | 637 | copy_bytes = min_t(size_t, sg_remaining, |
638 | block_remaining); | 638 | block_remaining); |
639 | offset = DATA_BLOCK_SIZE - block_remaining; | 639 | offset = DATA_BLOCK_SIZE - block_remaining; |
640 | from += offset; | ||
641 | tcmu_flush_dcache_range(from, copy_bytes); | 640 | tcmu_flush_dcache_range(from, copy_bytes); |
642 | memcpy(to + sg->length - sg_remaining, from, | 641 | memcpy(to + sg->length - sg_remaining, from + offset, |
643 | copy_bytes); | 642 | copy_bytes); |
644 | 643 | ||
645 | sg_remaining -= copy_bytes; | 644 | sg_remaining -= copy_bytes; |
@@ -1433,6 +1432,8 @@ static int tcmu_update_uio_info(struct tcmu_dev *udev) | |||
1433 | if (udev->dev_config[0]) | 1432 | if (udev->dev_config[0]) |
1434 | snprintf(str + used, size - used, "/%s", udev->dev_config); | 1433 | snprintf(str + used, size - used, "/%s", udev->dev_config); |
1435 | 1434 | ||
1435 | /* If the old string exists, free it */ | ||
1436 | kfree(info->name); | ||
1436 | info->name = str; | 1437 | info->name = str; |
1437 | 1438 | ||
1438 | return 0; | 1439 | return 0; |
diff --git a/drivers/thunderbolt/eeprom.c b/drivers/thunderbolt/eeprom.c index 308b6e17c88a..fe2f00ceafc5 100644 --- a/drivers/thunderbolt/eeprom.c +++ b/drivers/thunderbolt/eeprom.c | |||
@@ -333,6 +333,15 @@ static int tb_drom_parse_entry_port(struct tb_switch *sw, | |||
333 | int res; | 333 | int res; |
334 | enum tb_port_type type; | 334 | enum tb_port_type type; |
335 | 335 | ||
336 | /* | ||
337 | * Some DROMs list more ports than the controller actually has | ||
338 | * so we skip those but allow the parser to continue. | ||
339 | */ | ||
340 | if (header->index > sw->config.max_port_number) { | ||
341 | dev_info_once(&sw->dev, "ignoring unnecessary extra entries in DROM\n"); | ||
342 | return 0; | ||
343 | } | ||
344 | |||
336 | port = &sw->ports[header->index]; | 345 | port = &sw->ports[header->index]; |
337 | port->disabled = header->port_disabled; | 346 | port->disabled = header->port_disabled; |
338 | if (port->disabled) | 347 | if (port->disabled) |
diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c index 284749fb0f6b..a6d5164c33a9 100644 --- a/drivers/tty/pty.c +++ b/drivers/tty/pty.c | |||
@@ -69,13 +69,8 @@ static void pty_close(struct tty_struct *tty, struct file *filp) | |||
69 | #ifdef CONFIG_UNIX98_PTYS | 69 | #ifdef CONFIG_UNIX98_PTYS |
70 | if (tty->driver == ptm_driver) { | 70 | if (tty->driver == ptm_driver) { |
71 | mutex_lock(&devpts_mutex); | 71 | mutex_lock(&devpts_mutex); |
72 | if (tty->link->driver_data) { | 72 | if (tty->link->driver_data) |
73 | struct path *path = tty->link->driver_data; | 73 | devpts_pty_kill(tty->link->driver_data); |
74 | |||
75 | devpts_pty_kill(path->dentry); | ||
76 | path_put(path); | ||
77 | kfree(path); | ||
78 | } | ||
79 | mutex_unlock(&devpts_mutex); | 74 | mutex_unlock(&devpts_mutex); |
80 | } | 75 | } |
81 | #endif | 76 | #endif |
@@ -607,25 +602,24 @@ static inline void legacy_pty_init(void) { } | |||
607 | static struct cdev ptmx_cdev; | 602 | static struct cdev ptmx_cdev; |
608 | 603 | ||
609 | /** | 604 | /** |
610 | * pty_open_peer - open the peer of a pty | 605 | * ptm_open_peer - open the peer of a pty |
611 | * @tty: the peer of the pty being opened | 606 | * @master: the open struct file of the ptmx device node |
607 | * @tty: the master of the pty being opened | ||
608 | * @flags: the flags for open | ||
612 | * | 609 | * |
613 | * Open the cached dentry in tty->link, providing a safe way for userspace | 610 | * Provide a race free way for userspace to open the slave end of a pty |
614 | * to get the slave end of a pty (where they have the master fd and cannot | 611 | * (where they have the master fd and cannot access or trust the mount |
615 | * access or trust the mount namespace /dev/pts was mounted inside). | 612 | * namespace /dev/pts was mounted inside). |
616 | */ | 613 | */ |
617 | static struct file *pty_open_peer(struct tty_struct *tty, int flags) | 614 | int ptm_open_peer(struct file *master, struct tty_struct *tty, int flags) |
618 | { | ||
619 | if (tty->driver->subtype != PTY_TYPE_MASTER) | ||
620 | return ERR_PTR(-EIO); | ||
621 | return dentry_open(tty->link->driver_data, flags, current_cred()); | ||
622 | } | ||
623 | |||
624 | static int pty_get_peer(struct tty_struct *tty, int flags) | ||
625 | { | 615 | { |
626 | int fd = -1; | 616 | int fd = -1; |
627 | struct file *filp = NULL; | 617 | struct file *filp; |
628 | int retval = -EINVAL; | 618 | int retval = -EINVAL; |
619 | struct path path; | ||
620 | |||
621 | if (tty->driver != ptm_driver) | ||
622 | return -EIO; | ||
629 | 623 | ||
630 | fd = get_unused_fd_flags(0); | 624 | fd = get_unused_fd_flags(0); |
631 | if (fd < 0) { | 625 | if (fd < 0) { |
@@ -633,7 +627,16 @@ static int pty_get_peer(struct tty_struct *tty, int flags) | |||
633 | goto err; | 627 | goto err; |
634 | } | 628 | } |
635 | 629 | ||
636 | filp = pty_open_peer(tty, flags); | 630 | /* Compute the slave's path */ |
631 | path.mnt = devpts_mntget(master, tty->driver_data); | ||
632 | if (IS_ERR(path.mnt)) { | ||
633 | retval = PTR_ERR(path.mnt); | ||
634 | goto err_put; | ||
635 | } | ||
636 | path.dentry = tty->link->driver_data; | ||
637 | |||
638 | filp = dentry_open(&path, flags, current_cred()); | ||
639 | mntput(path.mnt); | ||
637 | if (IS_ERR(filp)) { | 640 | if (IS_ERR(filp)) { |
638 | retval = PTR_ERR(filp); | 641 | retval = PTR_ERR(filp); |
639 | goto err_put; | 642 | goto err_put; |
@@ -662,8 +665,6 @@ static int pty_unix98_ioctl(struct tty_struct *tty, | |||
662 | return pty_get_pktmode(tty, (int __user *)arg); | 665 | return pty_get_pktmode(tty, (int __user *)arg); |
663 | case TIOCGPTN: /* Get PT Number */ | 666 | case TIOCGPTN: /* Get PT Number */ |
664 | return put_user(tty->index, (unsigned int __user *)arg); | 667 | return put_user(tty->index, (unsigned int __user *)arg); |
665 | case TIOCGPTPEER: /* Open the other end */ | ||
666 | return pty_get_peer(tty, (int) arg); | ||
667 | case TIOCSIG: /* Send signal to other side of pty */ | 668 | case TIOCSIG: /* Send signal to other side of pty */ |
668 | return pty_signal(tty, (int) arg); | 669 | return pty_signal(tty, (int) arg); |
669 | } | 670 | } |
@@ -791,7 +792,6 @@ static int ptmx_open(struct inode *inode, struct file *filp) | |||
791 | { | 792 | { |
792 | struct pts_fs_info *fsi; | 793 | struct pts_fs_info *fsi; |
793 | struct tty_struct *tty; | 794 | struct tty_struct *tty; |
794 | struct path *pts_path; | ||
795 | struct dentry *dentry; | 795 | struct dentry *dentry; |
796 | int retval; | 796 | int retval; |
797 | int index; | 797 | int index; |
@@ -845,26 +845,16 @@ static int ptmx_open(struct inode *inode, struct file *filp) | |||
845 | retval = PTR_ERR(dentry); | 845 | retval = PTR_ERR(dentry); |
846 | goto err_release; | 846 | goto err_release; |
847 | } | 847 | } |
848 | /* We need to cache a fake path for TIOCGPTPEER. */ | 848 | tty->link->driver_data = dentry; |
849 | pts_path = kmalloc(sizeof(struct path), GFP_KERNEL); | ||
850 | if (!pts_path) | ||
851 | goto err_release; | ||
852 | pts_path->mnt = filp->f_path.mnt; | ||
853 | pts_path->dentry = dentry; | ||
854 | path_get(pts_path); | ||
855 | tty->link->driver_data = pts_path; | ||
856 | 849 | ||
857 | retval = ptm_driver->ops->open(tty, filp); | 850 | retval = ptm_driver->ops->open(tty, filp); |
858 | if (retval) | 851 | if (retval) |
859 | goto err_path_put; | 852 | goto err_release; |
860 | 853 | ||
861 | tty_debug_hangup(tty, "opening (count=%d)\n", tty->count); | 854 | tty_debug_hangup(tty, "opening (count=%d)\n", tty->count); |
862 | 855 | ||
863 | tty_unlock(tty); | 856 | tty_unlock(tty); |
864 | return 0; | 857 | return 0; |
865 | err_path_put: | ||
866 | path_put(pts_path); | ||
867 | kfree(pts_path); | ||
868 | err_release: | 858 | err_release: |
869 | tty_unlock(tty); | 859 | tty_unlock(tty); |
870 | // This will also put-ref the fsi | 860 | // This will also put-ref the fsi |
diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c index b5def356af63..1aab3010fbfa 100644 --- a/drivers/tty/serial/8250/8250_core.c +++ b/drivers/tty/serial/8250/8250_core.c | |||
@@ -1043,13 +1043,24 @@ int serial8250_register_8250_port(struct uart_8250_port *up) | |||
1043 | if (up->dl_write) | 1043 | if (up->dl_write) |
1044 | uart->dl_write = up->dl_write; | 1044 | uart->dl_write = up->dl_write; |
1045 | 1045 | ||
1046 | if (serial8250_isa_config != NULL) | 1046 | if (uart->port.type != PORT_8250_CIR) { |
1047 | serial8250_isa_config(0, &uart->port, | 1047 | if (serial8250_isa_config != NULL) |
1048 | &uart->capabilities); | 1048 | serial8250_isa_config(0, &uart->port, |
1049 | &uart->capabilities); | ||
1050 | |||
1051 | ret = uart_add_one_port(&serial8250_reg, | ||
1052 | &uart->port); | ||
1053 | if (ret == 0) | ||
1054 | ret = uart->port.line; | ||
1055 | } else { | ||
1056 | dev_info(uart->port.dev, | ||
1057 | "skipping CIR port at 0x%lx / 0x%llx, IRQ %d\n", | ||
1058 | uart->port.iobase, | ||
1059 | (unsigned long long)uart->port.mapbase, | ||
1060 | uart->port.irq); | ||
1049 | 1061 | ||
1050 | ret = uart_add_one_port(&serial8250_reg, &uart->port); | 1062 | ret = 0; |
1051 | if (ret == 0) | 1063 | } |
1052 | ret = uart->port.line; | ||
1053 | } | 1064 | } |
1054 | mutex_unlock(&serial_mutex); | 1065 | mutex_unlock(&serial_mutex); |
1055 | 1066 | ||
diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c index 8a857bb34fbb..1888d168a41c 100644 --- a/drivers/tty/serial/amba-pl011.c +++ b/drivers/tty/serial/amba-pl011.c | |||
@@ -142,15 +142,7 @@ static struct vendor_data vendor_sbsa = { | |||
142 | .fixed_options = true, | 142 | .fixed_options = true, |
143 | }; | 143 | }; |
144 | 144 | ||
145 | /* | 145 | #ifdef CONFIG_ACPI_SPCR_TABLE |
146 | * Erratum 44 for QDF2432v1 and QDF2400v1 SoCs describes the BUSY bit as | ||
147 | * occasionally getting stuck as 1. To avoid the potential for a hang, check | ||
148 | * TXFE == 0 instead of BUSY == 1. This may not be suitable for all UART | ||
149 | * implementations, so only do so if an affected platform is detected in | ||
150 | * parse_spcr(). | ||
151 | */ | ||
152 | static bool qdf2400_e44_present = false; | ||
153 | |||
154 | static struct vendor_data vendor_qdt_qdf2400_e44 = { | 146 | static struct vendor_data vendor_qdt_qdf2400_e44 = { |
155 | .reg_offset = pl011_std_offsets, | 147 | .reg_offset = pl011_std_offsets, |
156 | .fr_busy = UART011_FR_TXFE, | 148 | .fr_busy = UART011_FR_TXFE, |
@@ -165,6 +157,7 @@ static struct vendor_data vendor_qdt_qdf2400_e44 = { | |||
165 | .always_enabled = true, | 157 | .always_enabled = true, |
166 | .fixed_options = true, | 158 | .fixed_options = true, |
167 | }; | 159 | }; |
160 | #endif | ||
168 | 161 | ||
169 | static u16 pl011_st_offsets[REG_ARRAY_SIZE] = { | 162 | static u16 pl011_st_offsets[REG_ARRAY_SIZE] = { |
170 | [REG_DR] = UART01x_DR, | 163 | [REG_DR] = UART01x_DR, |
@@ -2375,12 +2368,14 @@ static int __init pl011_console_match(struct console *co, char *name, int idx, | |||
2375 | resource_size_t addr; | 2368 | resource_size_t addr; |
2376 | int i; | 2369 | int i; |
2377 | 2370 | ||
2378 | if (strcmp(name, "qdf2400_e44") == 0) { | 2371 | /* |
2379 | pr_info_once("UART: Working around QDF2400 SoC erratum 44"); | 2372 | * Systems affected by the Qualcomm Technologies QDF2400 E44 erratum |
2380 | qdf2400_e44_present = true; | 2373 | * have a distinct console name, so make sure we check for that. |
2381 | } else if (strcmp(name, "pl011") != 0) { | 2374 | * The actual implementation of the erratum occurs in the probe |
2375 | * function. | ||
2376 | */ | ||
2377 | if ((strcmp(name, "qdf2400_e44") != 0) && (strcmp(name, "pl011") != 0)) | ||
2382 | return -ENODEV; | 2378 | return -ENODEV; |
2383 | } | ||
2384 | 2379 | ||
2385 | if (uart_parse_earlycon(options, &iotype, &addr, &options)) | 2380 | if (uart_parse_earlycon(options, &iotype, &addr, &options)) |
2386 | return -ENODEV; | 2381 | return -ENODEV; |
@@ -2734,11 +2729,17 @@ static int sbsa_uart_probe(struct platform_device *pdev) | |||
2734 | } | 2729 | } |
2735 | uap->port.irq = ret; | 2730 | uap->port.irq = ret; |
2736 | 2731 | ||
2737 | uap->reg_offset = vendor_sbsa.reg_offset; | 2732 | #ifdef CONFIG_ACPI_SPCR_TABLE |
2738 | uap->vendor = qdf2400_e44_present ? | 2733 | if (qdf2400_e44_present) { |
2739 | &vendor_qdt_qdf2400_e44 : &vendor_sbsa; | 2734 | dev_info(&pdev->dev, "working around QDF2400 SoC erratum 44\n"); |
2735 | uap->vendor = &vendor_qdt_qdf2400_e44; | ||
2736 | } else | ||
2737 | #endif | ||
2738 | uap->vendor = &vendor_sbsa; | ||
2739 | |||
2740 | uap->reg_offset = uap->vendor->reg_offset; | ||
2740 | uap->fifosize = 32; | 2741 | uap->fifosize = 32; |
2741 | uap->port.iotype = vendor_sbsa.access_32b ? UPIO_MEM32 : UPIO_MEM; | 2742 | uap->port.iotype = uap->vendor->access_32b ? UPIO_MEM32 : UPIO_MEM; |
2742 | uap->port.ops = &sbsa_uart_pops; | 2743 | uap->port.ops = &sbsa_uart_pops; |
2743 | uap->fixed_baud = baudrate; | 2744 | uap->fixed_baud = baudrate; |
2744 | 2745 | ||
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index 974b13d24401..10c4038c0e8d 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c | |||
@@ -2518,6 +2518,9 @@ long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
2518 | case TIOCSSERIAL: | 2518 | case TIOCSSERIAL: |
2519 | tty_warn_deprecated_flags(p); | 2519 | tty_warn_deprecated_flags(p); |
2520 | break; | 2520 | break; |
2521 | case TIOCGPTPEER: | ||
2522 | /* Special because the struct file is needed */ | ||
2523 | return ptm_open_peer(file, tty, (int)arg); | ||
2521 | default: | 2524 | default: |
2522 | retval = tty_jobctrl_ioctl(tty, real_tty, file, cmd, arg); | 2525 | retval = tty_jobctrl_ioctl(tty, real_tty, file, cmd, arg); |
2523 | if (retval != -ENOIOCTLCMD) | 2526 | if (retval != -ENOIOCTLCMD) |
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index ab1bb3b538ac..7f277b092b5b 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c | |||
@@ -1888,7 +1888,7 @@ void usb_hcd_flush_endpoint(struct usb_device *udev, | |||
1888 | /* No more submits can occur */ | 1888 | /* No more submits can occur */ |
1889 | spin_lock_irq(&hcd_urb_list_lock); | 1889 | spin_lock_irq(&hcd_urb_list_lock); |
1890 | rescan: | 1890 | rescan: |
1891 | list_for_each_entry (urb, &ep->urb_list, urb_list) { | 1891 | list_for_each_entry_reverse(urb, &ep->urb_list, urb_list) { |
1892 | int is_in; | 1892 | int is_in; |
1893 | 1893 | ||
1894 | if (urb->unlinked) | 1894 | if (urb->unlinked) |
@@ -2485,6 +2485,8 @@ void usb_hc_died (struct usb_hcd *hcd) | |||
2485 | } | 2485 | } |
2486 | if (usb_hcd_is_primary_hcd(hcd) && hcd->shared_hcd) { | 2486 | if (usb_hcd_is_primary_hcd(hcd) && hcd->shared_hcd) { |
2487 | hcd = hcd->shared_hcd; | 2487 | hcd = hcd->shared_hcd; |
2488 | clear_bit(HCD_FLAG_RH_RUNNING, &hcd->flags); | ||
2489 | set_bit(HCD_FLAG_DEAD, &hcd->flags); | ||
2488 | if (hcd->rh_registered) { | 2490 | if (hcd->rh_registered) { |
2489 | clear_bit(HCD_FLAG_POLL_RH, &hcd->flags); | 2491 | clear_bit(HCD_FLAG_POLL_RH, &hcd->flags); |
2490 | 2492 | ||
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 6e6797d145dd..822f8c50e423 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c | |||
@@ -4725,7 +4725,8 @@ hub_power_remaining(struct usb_hub *hub) | |||
4725 | static void hub_port_connect(struct usb_hub *hub, int port1, u16 portstatus, | 4725 | static void hub_port_connect(struct usb_hub *hub, int port1, u16 portstatus, |
4726 | u16 portchange) | 4726 | u16 portchange) |
4727 | { | 4727 | { |
4728 | int status, i; | 4728 | int status = -ENODEV; |
4729 | int i; | ||
4729 | unsigned unit_load; | 4730 | unsigned unit_load; |
4730 | struct usb_device *hdev = hub->hdev; | 4731 | struct usb_device *hdev = hub->hdev; |
4731 | struct usb_hcd *hcd = bus_to_hcd(hdev->bus); | 4732 | struct usb_hcd *hcd = bus_to_hcd(hdev->bus); |
@@ -4929,9 +4930,10 @@ loop: | |||
4929 | 4930 | ||
4930 | done: | 4931 | done: |
4931 | hub_port_disable(hub, port1, 1); | 4932 | hub_port_disable(hub, port1, 1); |
4932 | if (hcd->driver->relinquish_port && !hub->hdev->parent) | 4933 | if (hcd->driver->relinquish_port && !hub->hdev->parent) { |
4933 | hcd->driver->relinquish_port(hcd, port1); | 4934 | if (status != -ENOTCONN && status != -ENODEV) |
4934 | 4935 | hcd->driver->relinquish_port(hcd, port1); | |
4936 | } | ||
4935 | } | 4937 | } |
4936 | 4938 | ||
4937 | /* Handle physical or logical connection change events. | 4939 | /* Handle physical or logical connection change events. |
diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c index 3116edfcdc18..574da2b4529c 100644 --- a/drivers/usb/core/quirks.c +++ b/drivers/usb/core/quirks.c | |||
@@ -150,6 +150,9 @@ static const struct usb_device_id usb_quirk_list[] = { | |||
150 | /* appletouch */ | 150 | /* appletouch */ |
151 | { USB_DEVICE(0x05ac, 0x021a), .driver_info = USB_QUIRK_RESET_RESUME }, | 151 | { USB_DEVICE(0x05ac, 0x021a), .driver_info = USB_QUIRK_RESET_RESUME }, |
152 | 152 | ||
153 | /* Genesys Logic hub, internally used by Moshi USB to Ethernet Adapter */ | ||
154 | { USB_DEVICE(0x05e3, 0x0616), .driver_info = USB_QUIRK_NO_LPM }, | ||
155 | |||
153 | /* Avision AV600U */ | 156 | /* Avision AV600U */ |
154 | { USB_DEVICE(0x0638, 0x0a13), .driver_info = | 157 | { USB_DEVICE(0x0638, 0x0a13), .driver_info = |
155 | USB_QUIRK_STRING_FETCH_255 }, | 158 | USB_QUIRK_STRING_FETCH_255 }, |
@@ -249,6 +252,7 @@ static const struct usb_device_id usb_amd_resume_quirk_list[] = { | |||
249 | { USB_DEVICE(0x093a, 0x2500), .driver_info = USB_QUIRK_RESET_RESUME }, | 252 | { USB_DEVICE(0x093a, 0x2500), .driver_info = USB_QUIRK_RESET_RESUME }, |
250 | { USB_DEVICE(0x093a, 0x2510), .driver_info = USB_QUIRK_RESET_RESUME }, | 253 | { USB_DEVICE(0x093a, 0x2510), .driver_info = USB_QUIRK_RESET_RESUME }, |
251 | { USB_DEVICE(0x093a, 0x2521), .driver_info = USB_QUIRK_RESET_RESUME }, | 254 | { USB_DEVICE(0x093a, 0x2521), .driver_info = USB_QUIRK_RESET_RESUME }, |
255 | { USB_DEVICE(0x03f0, 0x2b4a), .driver_info = USB_QUIRK_RESET_RESUME }, | ||
252 | 256 | ||
253 | /* Logitech Optical Mouse M90/M100 */ | 257 | /* Logitech Optical Mouse M90/M100 */ |
254 | { USB_DEVICE(0x046d, 0xc05a), .driver_info = USB_QUIRK_RESET_RESUME }, | 258 | { USB_DEVICE(0x046d, 0xc05a), .driver_info = USB_QUIRK_RESET_RESUME }, |
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 6b299c7b7656..f064f1549333 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c | |||
@@ -896,9 +896,40 @@ static void __dwc3_prepare_one_trb(struct dwc3_ep *dep, struct dwc3_trb *trb, | |||
896 | if (!node) { | 896 | if (!node) { |
897 | trb->ctrl = DWC3_TRBCTL_ISOCHRONOUS_FIRST; | 897 | trb->ctrl = DWC3_TRBCTL_ISOCHRONOUS_FIRST; |
898 | 898 | ||
899 | /* | ||
900 | * USB Specification 2.0 Section 5.9.2 states that: "If | ||
901 | * there is only a single transaction in the microframe, | ||
902 | * only a DATA0 data packet PID is used. If there are | ||
903 | * two transactions per microframe, DATA1 is used for | ||
904 | * the first transaction data packet and DATA0 is used | ||
905 | * for the second transaction data packet. If there are | ||
906 | * three transactions per microframe, DATA2 is used for | ||
907 | * the first transaction data packet, DATA1 is used for | ||
908 | * the second, and DATA0 is used for the third." | ||
909 | * | ||
910 | * IOW, we should satisfy the following cases: | ||
911 | * | ||
912 | * 1) length <= maxpacket | ||
913 | * - DATA0 | ||
914 | * | ||
915 | * 2) maxpacket < length <= (2 * maxpacket) | ||
916 | * - DATA1, DATA0 | ||
917 | * | ||
918 | * 3) (2 * maxpacket) < length <= (3 * maxpacket) | ||
919 | * - DATA2, DATA1, DATA0 | ||
920 | */ | ||
899 | if (speed == USB_SPEED_HIGH) { | 921 | if (speed == USB_SPEED_HIGH) { |
900 | struct usb_ep *ep = &dep->endpoint; | 922 | struct usb_ep *ep = &dep->endpoint; |
901 | trb->size |= DWC3_TRB_SIZE_PCM1(ep->mult - 1); | 923 | unsigned int mult = ep->mult - 1; |
924 | unsigned int maxp = usb_endpoint_maxp(ep->desc); | ||
925 | |||
926 | if (length <= (2 * maxp)) | ||
927 | mult--; | ||
928 | |||
929 | if (length <= maxp) | ||
930 | mult--; | ||
931 | |||
932 | trb->size |= DWC3_TRB_SIZE_PCM1(mult); | ||
902 | } | 933 | } |
903 | } else { | 934 | } else { |
904 | trb->ctrl = DWC3_TRBCTL_ISOCHRONOUS; | 935 | trb->ctrl = DWC3_TRBCTL_ISOCHRONOUS; |
diff --git a/drivers/usb/gadget/udc/renesas_usb3.c b/drivers/usb/gadget/udc/renesas_usb3.c index 62dc9c7798e7..e1de8fe599a3 100644 --- a/drivers/usb/gadget/udc/renesas_usb3.c +++ b/drivers/usb/gadget/udc/renesas_usb3.c | |||
@@ -838,21 +838,32 @@ static struct renesas_usb3_request *usb3_get_request(struct renesas_usb3_ep | |||
838 | return usb3_req; | 838 | return usb3_req; |
839 | } | 839 | } |
840 | 840 | ||
841 | static void usb3_request_done(struct renesas_usb3_ep *usb3_ep, | 841 | static void __usb3_request_done(struct renesas_usb3_ep *usb3_ep, |
842 | struct renesas_usb3_request *usb3_req, int status) | 842 | struct renesas_usb3_request *usb3_req, |
843 | int status) | ||
843 | { | 844 | { |
844 | struct renesas_usb3 *usb3 = usb3_ep_to_usb3(usb3_ep); | 845 | struct renesas_usb3 *usb3 = usb3_ep_to_usb3(usb3_ep); |
845 | unsigned long flags; | ||
846 | 846 | ||
847 | dev_dbg(usb3_to_dev(usb3), "giveback: ep%2d, %u, %u, %d\n", | 847 | dev_dbg(usb3_to_dev(usb3), "giveback: ep%2d, %u, %u, %d\n", |
848 | usb3_ep->num, usb3_req->req.length, usb3_req->req.actual, | 848 | usb3_ep->num, usb3_req->req.length, usb3_req->req.actual, |
849 | status); | 849 | status); |
850 | usb3_req->req.status = status; | 850 | usb3_req->req.status = status; |
851 | spin_lock_irqsave(&usb3->lock, flags); | ||
852 | usb3_ep->started = false; | 851 | usb3_ep->started = false; |
853 | list_del_init(&usb3_req->queue); | 852 | list_del_init(&usb3_req->queue); |
854 | spin_unlock_irqrestore(&usb3->lock, flags); | 853 | spin_unlock(&usb3->lock); |
855 | usb_gadget_giveback_request(&usb3_ep->ep, &usb3_req->req); | 854 | usb_gadget_giveback_request(&usb3_ep->ep, &usb3_req->req); |
855 | spin_lock(&usb3->lock); | ||
856 | } | ||
857 | |||
858 | static void usb3_request_done(struct renesas_usb3_ep *usb3_ep, | ||
859 | struct renesas_usb3_request *usb3_req, int status) | ||
860 | { | ||
861 | struct renesas_usb3 *usb3 = usb3_ep_to_usb3(usb3_ep); | ||
862 | unsigned long flags; | ||
863 | |||
864 | spin_lock_irqsave(&usb3->lock, flags); | ||
865 | __usb3_request_done(usb3_ep, usb3_req, status); | ||
866 | spin_unlock_irqrestore(&usb3->lock, flags); | ||
856 | } | 867 | } |
857 | 868 | ||
858 | static void usb3_irq_epc_pipe0_status_end(struct renesas_usb3 *usb3) | 869 | static void usb3_irq_epc_pipe0_status_end(struct renesas_usb3 *usb3) |
diff --git a/drivers/usb/host/pci-quirks.c b/drivers/usb/host/pci-quirks.c index c8989c62a262..c8f38649f749 100644 --- a/drivers/usb/host/pci-quirks.c +++ b/drivers/usb/host/pci-quirks.c | |||
@@ -98,6 +98,7 @@ enum amd_chipset_gen { | |||
98 | AMD_CHIPSET_HUDSON2, | 98 | AMD_CHIPSET_HUDSON2, |
99 | AMD_CHIPSET_BOLTON, | 99 | AMD_CHIPSET_BOLTON, |
100 | AMD_CHIPSET_YANGTZE, | 100 | AMD_CHIPSET_YANGTZE, |
101 | AMD_CHIPSET_TAISHAN, | ||
101 | AMD_CHIPSET_UNKNOWN, | 102 | AMD_CHIPSET_UNKNOWN, |
102 | }; | 103 | }; |
103 | 104 | ||
@@ -141,6 +142,11 @@ static int amd_chipset_sb_type_init(struct amd_chipset_info *pinfo) | |||
141 | pinfo->sb_type.gen = AMD_CHIPSET_SB700; | 142 | pinfo->sb_type.gen = AMD_CHIPSET_SB700; |
142 | else if (rev >= 0x40 && rev <= 0x4f) | 143 | else if (rev >= 0x40 && rev <= 0x4f) |
143 | pinfo->sb_type.gen = AMD_CHIPSET_SB800; | 144 | pinfo->sb_type.gen = AMD_CHIPSET_SB800; |
145 | } | ||
146 | pinfo->smbus_dev = pci_get_device(PCI_VENDOR_ID_AMD, | ||
147 | 0x145c, NULL); | ||
148 | if (pinfo->smbus_dev) { | ||
149 | pinfo->sb_type.gen = AMD_CHIPSET_TAISHAN; | ||
144 | } else { | 150 | } else { |
145 | pinfo->smbus_dev = pci_get_device(PCI_VENDOR_ID_AMD, | 151 | pinfo->smbus_dev = pci_get_device(PCI_VENDOR_ID_AMD, |
146 | PCI_DEVICE_ID_AMD_HUDSON2_SMBUS, NULL); | 152 | PCI_DEVICE_ID_AMD_HUDSON2_SMBUS, NULL); |
@@ -260,11 +266,12 @@ int usb_hcd_amd_remote_wakeup_quirk(struct pci_dev *pdev) | |||
260 | { | 266 | { |
261 | /* Make sure amd chipset type has already been initialized */ | 267 | /* Make sure amd chipset type has already been initialized */ |
262 | usb_amd_find_chipset_info(); | 268 | usb_amd_find_chipset_info(); |
263 | if (amd_chipset.sb_type.gen != AMD_CHIPSET_YANGTZE) | 269 | if (amd_chipset.sb_type.gen == AMD_CHIPSET_YANGTZE || |
264 | return 0; | 270 | amd_chipset.sb_type.gen == AMD_CHIPSET_TAISHAN) { |
265 | 271 | dev_dbg(&pdev->dev, "QUIRK: Enable AMD remote wakeup fix\n"); | |
266 | dev_dbg(&pdev->dev, "QUIRK: Enable AMD remote wakeup fix\n"); | 272 | return 1; |
267 | return 1; | 273 | } |
274 | return 0; | ||
268 | } | 275 | } |
269 | EXPORT_SYMBOL_GPL(usb_hcd_amd_remote_wakeup_quirk); | 276 | EXPORT_SYMBOL_GPL(usb_hcd_amd_remote_wakeup_quirk); |
270 | 277 | ||
@@ -1150,3 +1157,23 @@ static void quirk_usb_early_handoff(struct pci_dev *pdev) | |||
1150 | } | 1157 | } |
1151 | DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_ANY_ID, PCI_ANY_ID, | 1158 | DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_ANY_ID, PCI_ANY_ID, |
1152 | PCI_CLASS_SERIAL_USB, 8, quirk_usb_early_handoff); | 1159 | PCI_CLASS_SERIAL_USB, 8, quirk_usb_early_handoff); |
1160 | |||
1161 | bool usb_xhci_needs_pci_reset(struct pci_dev *pdev) | ||
1162 | { | ||
1163 | /* | ||
1164 | * Our dear uPD72020{1,2} friend only partially resets when | ||
1165 | * asked to via the XHCI interface, and may end up doing DMA | ||
1166 | * at the wrong addresses, as it keeps the top 32bit of some | ||
1167 | * addresses from its previous programming under obscure | ||
1168 | * circumstances. | ||
1169 | * Give it a good wack at probe time. Unfortunately, this | ||
1170 | * needs to happen before we've had a chance to discover any | ||
1171 | * quirk, or the system will be in a rather bad state. | ||
1172 | */ | ||
1173 | if (pdev->vendor == PCI_VENDOR_ID_RENESAS && | ||
1174 | (pdev->device == 0x0014 || pdev->device == 0x0015)) | ||
1175 | return true; | ||
1176 | |||
1177 | return false; | ||
1178 | } | ||
1179 | EXPORT_SYMBOL_GPL(usb_xhci_needs_pci_reset); | ||
diff --git a/drivers/usb/host/pci-quirks.h b/drivers/usb/host/pci-quirks.h index 655994480198..5582cbafecd4 100644 --- a/drivers/usb/host/pci-quirks.h +++ b/drivers/usb/host/pci-quirks.h | |||
@@ -15,6 +15,7 @@ void usb_asmedia_modifyflowcontrol(struct pci_dev *pdev); | |||
15 | void usb_enable_intel_xhci_ports(struct pci_dev *xhci_pdev); | 15 | void usb_enable_intel_xhci_ports(struct pci_dev *xhci_pdev); |
16 | void usb_disable_xhci_ports(struct pci_dev *xhci_pdev); | 16 | void usb_disable_xhci_ports(struct pci_dev *xhci_pdev); |
17 | void sb800_prefetch(struct device *dev, int on); | 17 | void sb800_prefetch(struct device *dev, int on); |
18 | bool usb_xhci_needs_pci_reset(struct pci_dev *pdev); | ||
18 | #else | 19 | #else |
19 | struct pci_dev; | 20 | struct pci_dev; |
20 | static inline void usb_amd_quirk_pll_disable(void) {} | 21 | static inline void usb_amd_quirk_pll_disable(void) {} |
diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c index 5b0fa553c8bc..8071c8fdd15e 100644 --- a/drivers/usb/host/xhci-pci.c +++ b/drivers/usb/host/xhci-pci.c | |||
@@ -284,6 +284,13 @@ static int xhci_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) | |||
284 | 284 | ||
285 | driver = (struct hc_driver *)id->driver_data; | 285 | driver = (struct hc_driver *)id->driver_data; |
286 | 286 | ||
287 | /* For some HW implementation, a XHCI reset is just not enough... */ | ||
288 | if (usb_xhci_needs_pci_reset(dev)) { | ||
289 | dev_info(&dev->dev, "Resetting\n"); | ||
290 | if (pci_reset_function_locked(dev)) | ||
291 | dev_warn(&dev->dev, "Reset failed"); | ||
292 | } | ||
293 | |||
287 | /* Prevent runtime suspending between USB-2 and USB-3 initialization */ | 294 | /* Prevent runtime suspending between USB-2 and USB-3 initialization */ |
288 | pm_runtime_get_noresume(&dev->dev); | 295 | pm_runtime_get_noresume(&dev->dev); |
289 | 296 | ||
diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c index 76decb8011eb..3344ffd5bb13 100644 --- a/drivers/usb/musb/musb_host.c +++ b/drivers/usb/musb/musb_host.c | |||
@@ -139,6 +139,7 @@ static void musb_h_tx_flush_fifo(struct musb_hw_ep *ep) | |||
139 | "Could not flush host TX%d fifo: csr: %04x\n", | 139 | "Could not flush host TX%d fifo: csr: %04x\n", |
140 | ep->epnum, csr)) | 140 | ep->epnum, csr)) |
141 | return; | 141 | return; |
142 | mdelay(1); | ||
142 | } | 143 | } |
143 | } | 144 | } |
144 | 145 | ||
diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c index 8fb86a5f458e..3d0dd2f97415 100644 --- a/drivers/usb/phy/phy-msm-usb.c +++ b/drivers/usb/phy/phy-msm-usb.c | |||
@@ -197,6 +197,7 @@ struct msm_otg { | |||
197 | struct regulator *v3p3; | 197 | struct regulator *v3p3; |
198 | struct regulator *v1p8; | 198 | struct regulator *v1p8; |
199 | struct regulator *vddcx; | 199 | struct regulator *vddcx; |
200 | struct regulator_bulk_data supplies[3]; | ||
200 | 201 | ||
201 | struct reset_control *phy_rst; | 202 | struct reset_control *phy_rst; |
202 | struct reset_control *link_rst; | 203 | struct reset_control *link_rst; |
@@ -1731,7 +1732,6 @@ static int msm_otg_reboot_notify(struct notifier_block *this, | |||
1731 | 1732 | ||
1732 | static int msm_otg_probe(struct platform_device *pdev) | 1733 | static int msm_otg_probe(struct platform_device *pdev) |
1733 | { | 1734 | { |
1734 | struct regulator_bulk_data regs[3]; | ||
1735 | int ret = 0; | 1735 | int ret = 0; |
1736 | struct device_node *np = pdev->dev.of_node; | 1736 | struct device_node *np = pdev->dev.of_node; |
1737 | struct msm_otg_platform_data *pdata; | 1737 | struct msm_otg_platform_data *pdata; |
@@ -1817,17 +1817,18 @@ static int msm_otg_probe(struct platform_device *pdev) | |||
1817 | return motg->irq; | 1817 | return motg->irq; |
1818 | } | 1818 | } |
1819 | 1819 | ||
1820 | regs[0].supply = "vddcx"; | 1820 | motg->supplies[0].supply = "vddcx"; |
1821 | regs[1].supply = "v3p3"; | 1821 | motg->supplies[1].supply = "v3p3"; |
1822 | regs[2].supply = "v1p8"; | 1822 | motg->supplies[2].supply = "v1p8"; |
1823 | 1823 | ||
1824 | ret = devm_regulator_bulk_get(motg->phy.dev, ARRAY_SIZE(regs), regs); | 1824 | ret = devm_regulator_bulk_get(motg->phy.dev, ARRAY_SIZE(motg->supplies), |
1825 | motg->supplies); | ||
1825 | if (ret) | 1826 | if (ret) |
1826 | return ret; | 1827 | return ret; |
1827 | 1828 | ||
1828 | motg->vddcx = regs[0].consumer; | 1829 | motg->vddcx = motg->supplies[0].consumer; |
1829 | motg->v3p3 = regs[1].consumer; | 1830 | motg->v3p3 = motg->supplies[1].consumer; |
1830 | motg->v1p8 = regs[2].consumer; | 1831 | motg->v1p8 = motg->supplies[2].consumer; |
1831 | 1832 | ||
1832 | clk_set_rate(motg->clk, 60000000); | 1833 | clk_set_rate(motg->clk, 60000000); |
1833 | 1834 | ||
diff --git a/drivers/usb/renesas_usbhs/mod_gadget.c b/drivers/usb/renesas_usbhs/mod_gadget.c index 93fba9033b00..2c8161bcf5b5 100644 --- a/drivers/usb/renesas_usbhs/mod_gadget.c +++ b/drivers/usb/renesas_usbhs/mod_gadget.c | |||
@@ -639,14 +639,11 @@ static int usbhsg_ep_disable(struct usb_ep *ep) | |||
639 | struct usbhsg_uep *uep = usbhsg_ep_to_uep(ep); | 639 | struct usbhsg_uep *uep = usbhsg_ep_to_uep(ep); |
640 | struct usbhs_pipe *pipe; | 640 | struct usbhs_pipe *pipe; |
641 | unsigned long flags; | 641 | unsigned long flags; |
642 | int ret = 0; | ||
643 | 642 | ||
644 | spin_lock_irqsave(&uep->lock, flags); | 643 | spin_lock_irqsave(&uep->lock, flags); |
645 | pipe = usbhsg_uep_to_pipe(uep); | 644 | pipe = usbhsg_uep_to_pipe(uep); |
646 | if (!pipe) { | 645 | if (!pipe) |
647 | ret = -EINVAL; | ||
648 | goto out; | 646 | goto out; |
649 | } | ||
650 | 647 | ||
651 | usbhsg_pipe_disable(uep); | 648 | usbhsg_pipe_disable(uep); |
652 | usbhs_pipe_free(pipe); | 649 | usbhs_pipe_free(pipe); |
diff --git a/drivers/usb/renesas_usbhs/rcar3.c b/drivers/usb/renesas_usbhs/rcar3.c index d544b331c9f2..02b67abfc2a1 100644 --- a/drivers/usb/renesas_usbhs/rcar3.c +++ b/drivers/usb/renesas_usbhs/rcar3.c | |||
@@ -20,9 +20,13 @@ | |||
20 | /* Low Power Status register (LPSTS) */ | 20 | /* Low Power Status register (LPSTS) */ |
21 | #define LPSTS_SUSPM 0x4000 | 21 | #define LPSTS_SUSPM 0x4000 |
22 | 22 | ||
23 | /* USB General control register 2 (UGCTRL2), bit[31:6] should be 0 */ | 23 | /* |
24 | * USB General control register 2 (UGCTRL2) | ||
25 | * Remarks: bit[31:11] and bit[9:6] should be 0 | ||
26 | */ | ||
24 | #define UGCTRL2_RESERVED_3 0x00000001 /* bit[3:0] should be B'0001 */ | 27 | #define UGCTRL2_RESERVED_3 0x00000001 /* bit[3:0] should be B'0001 */ |
25 | #define UGCTRL2_USB0SEL_OTG 0x00000030 | 28 | #define UGCTRL2_USB0SEL_OTG 0x00000030 |
29 | #define UGCTRL2_VBUSSEL 0x00000400 | ||
26 | 30 | ||
27 | static void usbhs_write32(struct usbhs_priv *priv, u32 reg, u32 data) | 31 | static void usbhs_write32(struct usbhs_priv *priv, u32 reg, u32 data) |
28 | { | 32 | { |
@@ -34,7 +38,8 @@ static int usbhs_rcar3_power_ctrl(struct platform_device *pdev, | |||
34 | { | 38 | { |
35 | struct usbhs_priv *priv = usbhs_pdev_to_priv(pdev); | 39 | struct usbhs_priv *priv = usbhs_pdev_to_priv(pdev); |
36 | 40 | ||
37 | usbhs_write32(priv, UGCTRL2, UGCTRL2_RESERVED_3 | UGCTRL2_USB0SEL_OTG); | 41 | usbhs_write32(priv, UGCTRL2, UGCTRL2_RESERVED_3 | UGCTRL2_USB0SEL_OTG | |
42 | UGCTRL2_VBUSSEL); | ||
38 | 43 | ||
39 | if (enable) { | 44 | if (enable) { |
40 | usbhs_bset(priv, LPSTS, LPSTS_SUSPM, LPSTS_SUSPM); | 45 | usbhs_bset(priv, LPSTS, LPSTS_SUSPM, LPSTS_SUSPM); |
diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c index f64e914a8985..2d945c9f975c 100644 --- a/drivers/usb/serial/cp210x.c +++ b/drivers/usb/serial/cp210x.c | |||
@@ -142,6 +142,7 @@ static const struct usb_device_id id_table[] = { | |||
142 | { USB_DEVICE(0x10C4, 0x8998) }, /* KCF Technologies PRN */ | 142 | { USB_DEVICE(0x10C4, 0x8998) }, /* KCF Technologies PRN */ |
143 | { USB_DEVICE(0x10C4, 0x8A2A) }, /* HubZ dual ZigBee and Z-Wave dongle */ | 143 | { USB_DEVICE(0x10C4, 0x8A2A) }, /* HubZ dual ZigBee and Z-Wave dongle */ |
144 | { USB_DEVICE(0x10C4, 0x8A5E) }, /* CEL EM3588 ZigBee USB Stick Long Range */ | 144 | { USB_DEVICE(0x10C4, 0x8A5E) }, /* CEL EM3588 ZigBee USB Stick Long Range */ |
145 | { USB_DEVICE(0x10C4, 0x8B34) }, /* Qivicon ZigBee USB Radio Stick */ | ||
145 | { USB_DEVICE(0x10C4, 0xEA60) }, /* Silicon Labs factory default */ | 146 | { USB_DEVICE(0x10C4, 0xEA60) }, /* Silicon Labs factory default */ |
146 | { USB_DEVICE(0x10C4, 0xEA61) }, /* Silicon Labs factory default */ | 147 | { USB_DEVICE(0x10C4, 0xEA61) }, /* Silicon Labs factory default */ |
147 | { USB_DEVICE(0x10C4, 0xEA70) }, /* Silicon Labs factory default */ | 148 | { USB_DEVICE(0x10C4, 0xEA70) }, /* Silicon Labs factory default */ |
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c index ebe51f11105d..fe123153b1a5 100644 --- a/drivers/usb/serial/option.c +++ b/drivers/usb/serial/option.c | |||
@@ -2025,6 +2025,8 @@ static const struct usb_device_id option_ids[] = { | |||
2025 | { USB_DEVICE_INTERFACE_CLASS(0x2001, 0x7d04, 0xff) }, /* D-Link DWM-158 */ | 2025 | { USB_DEVICE_INTERFACE_CLASS(0x2001, 0x7d04, 0xff) }, /* D-Link DWM-158 */ |
2026 | { USB_DEVICE_INTERFACE_CLASS(0x2001, 0x7e19, 0xff), /* D-Link DWM-221 B1 */ | 2026 | { USB_DEVICE_INTERFACE_CLASS(0x2001, 0x7e19, 0xff), /* D-Link DWM-221 B1 */ |
2027 | .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, | 2027 | .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, |
2028 | { USB_DEVICE_INTERFACE_CLASS(0x2001, 0x7e35, 0xff), /* D-Link DWM-222 */ | ||
2029 | .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, | ||
2028 | { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x3e01, 0xff, 0xff, 0xff) }, /* D-Link DWM-152/C1 */ | 2030 | { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x3e01, 0xff, 0xff, 0xff) }, /* D-Link DWM-152/C1 */ |
2029 | { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x3e02, 0xff, 0xff, 0xff) }, /* D-Link DWM-156/C1 */ | 2031 | { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x3e02, 0xff, 0xff, 0xff) }, /* D-Link DWM-156/C1 */ |
2030 | { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x7e11, 0xff, 0xff, 0xff) }, /* D-Link DWM-156/A3 */ | 2032 | { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x7e11, 0xff, 0xff, 0xff) }, /* D-Link DWM-156/A3 */ |
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c index c9ebefd8f35f..a585b477415d 100644 --- a/drivers/usb/serial/pl2303.c +++ b/drivers/usb/serial/pl2303.c | |||
@@ -52,6 +52,8 @@ static const struct usb_device_id id_table[] = { | |||
52 | { USB_DEVICE(IODATA_VENDOR_ID, IODATA_PRODUCT_ID_RSAQ5) }, | 52 | { USB_DEVICE(IODATA_VENDOR_ID, IODATA_PRODUCT_ID_RSAQ5) }, |
53 | { USB_DEVICE(ATEN_VENDOR_ID, ATEN_PRODUCT_ID), | 53 | { USB_DEVICE(ATEN_VENDOR_ID, ATEN_PRODUCT_ID), |
54 | .driver_info = PL2303_QUIRK_ENDPOINT_HACK }, | 54 | .driver_info = PL2303_QUIRK_ENDPOINT_HACK }, |
55 | { USB_DEVICE(ATEN_VENDOR_ID, ATEN_PRODUCT_UC485), | ||
56 | .driver_info = PL2303_QUIRK_ENDPOINT_HACK }, | ||
55 | { USB_DEVICE(ATEN_VENDOR_ID, ATEN_PRODUCT_ID2) }, | 57 | { USB_DEVICE(ATEN_VENDOR_ID, ATEN_PRODUCT_ID2) }, |
56 | { USB_DEVICE(ATEN_VENDOR_ID2, ATEN_PRODUCT_ID) }, | 58 | { USB_DEVICE(ATEN_VENDOR_ID2, ATEN_PRODUCT_ID) }, |
57 | { USB_DEVICE(ELCOM_VENDOR_ID, ELCOM_PRODUCT_ID) }, | 59 | { USB_DEVICE(ELCOM_VENDOR_ID, ELCOM_PRODUCT_ID) }, |
diff --git a/drivers/usb/serial/pl2303.h b/drivers/usb/serial/pl2303.h index 09d9be88209e..3b5a15d1dc0d 100644 --- a/drivers/usb/serial/pl2303.h +++ b/drivers/usb/serial/pl2303.h | |||
@@ -27,6 +27,7 @@ | |||
27 | #define ATEN_VENDOR_ID 0x0557 | 27 | #define ATEN_VENDOR_ID 0x0557 |
28 | #define ATEN_VENDOR_ID2 0x0547 | 28 | #define ATEN_VENDOR_ID2 0x0547 |
29 | #define ATEN_PRODUCT_ID 0x2008 | 29 | #define ATEN_PRODUCT_ID 0x2008 |
30 | #define ATEN_PRODUCT_UC485 0x2021 | ||
30 | #define ATEN_PRODUCT_ID2 0x2118 | 31 | #define ATEN_PRODUCT_ID2 0x2118 |
31 | 32 | ||
32 | #define IODATA_VENDOR_ID 0x04bb | 33 | #define IODATA_VENDOR_ID 0x04bb |
diff --git a/drivers/usb/storage/unusual_uas.h b/drivers/usb/storage/unusual_uas.h index cbea9f329e71..cde115359793 100644 --- a/drivers/usb/storage/unusual_uas.h +++ b/drivers/usb/storage/unusual_uas.h | |||
@@ -124,9 +124,9 @@ UNUSUAL_DEV(0x0bc2, 0xab2a, 0x0000, 0x9999, | |||
124 | /* Reported-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> */ | 124 | /* Reported-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> */ |
125 | UNUSUAL_DEV(0x13fd, 0x3940, 0x0000, 0x9999, | 125 | UNUSUAL_DEV(0x13fd, 0x3940, 0x0000, 0x9999, |
126 | "Initio Corporation", | 126 | "Initio Corporation", |
127 | "", | 127 | "INIC-3069", |
128 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, | 128 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, |
129 | US_FL_NO_ATA_1X), | 129 | US_FL_NO_ATA_1X | US_FL_IGNORE_RESIDUE), |
130 | 130 | ||
131 | /* Reported-by: Tom Arild Naess <tanaess@gmail.com> */ | 131 | /* Reported-by: Tom Arild Naess <tanaess@gmail.com> */ |
132 | UNUSUAL_DEV(0x152d, 0x0539, 0x0000, 0x9999, | 132 | UNUSUAL_DEV(0x152d, 0x0539, 0x0000, 0x9999, |
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c index 06615934fed1..0dceb9fa3a06 100644 --- a/drivers/usb/storage/usb.c +++ b/drivers/usb/storage/usb.c | |||
@@ -315,6 +315,7 @@ static int usb_stor_control_thread(void * __us) | |||
315 | { | 315 | { |
316 | struct us_data *us = (struct us_data *)__us; | 316 | struct us_data *us = (struct us_data *)__us; |
317 | struct Scsi_Host *host = us_to_host(us); | 317 | struct Scsi_Host *host = us_to_host(us); |
318 | struct scsi_cmnd *srb; | ||
318 | 319 | ||
319 | for (;;) { | 320 | for (;;) { |
320 | usb_stor_dbg(us, "*** thread sleeping\n"); | 321 | usb_stor_dbg(us, "*** thread sleeping\n"); |
@@ -330,6 +331,7 @@ static int usb_stor_control_thread(void * __us) | |||
330 | scsi_lock(host); | 331 | scsi_lock(host); |
331 | 332 | ||
332 | /* When we are called with no command pending, we're done */ | 333 | /* When we are called with no command pending, we're done */ |
334 | srb = us->srb; | ||
333 | if (us->srb == NULL) { | 335 | if (us->srb == NULL) { |
334 | scsi_unlock(host); | 336 | scsi_unlock(host); |
335 | mutex_unlock(&us->dev_mutex); | 337 | mutex_unlock(&us->dev_mutex); |
@@ -398,14 +400,11 @@ static int usb_stor_control_thread(void * __us) | |||
398 | /* lock access to the state */ | 400 | /* lock access to the state */ |
399 | scsi_lock(host); | 401 | scsi_lock(host); |
400 | 402 | ||
401 | /* indicate that the command is done */ | 403 | /* was the command aborted? */ |
402 | if (us->srb->result != DID_ABORT << 16) { | 404 | if (us->srb->result == DID_ABORT << 16) { |
403 | usb_stor_dbg(us, "scsi cmd done, result=0x%x\n", | ||
404 | us->srb->result); | ||
405 | us->srb->scsi_done(us->srb); | ||
406 | } else { | ||
407 | SkipForAbort: | 405 | SkipForAbort: |
408 | usb_stor_dbg(us, "scsi command aborted\n"); | 406 | usb_stor_dbg(us, "scsi command aborted\n"); |
407 | srb = NULL; /* Don't call srb->scsi_done() */ | ||
409 | } | 408 | } |
410 | 409 | ||
411 | /* | 410 | /* |
@@ -429,6 +428,13 @@ SkipForAbort: | |||
429 | 428 | ||
430 | /* unlock the device pointers */ | 429 | /* unlock the device pointers */ |
431 | mutex_unlock(&us->dev_mutex); | 430 | mutex_unlock(&us->dev_mutex); |
431 | |||
432 | /* now that the locks are released, notify the SCSI core */ | ||
433 | if (srb) { | ||
434 | usb_stor_dbg(us, "scsi cmd done, result=0x%x\n", | ||
435 | srb->result); | ||
436 | srb->scsi_done(srb); | ||
437 | } | ||
432 | } /* for (;;) */ | 438 | } /* for (;;) */ |
433 | 439 | ||
434 | /* Wait until we are told to stop */ | 440 | /* Wait until we are told to stop */ |
diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c index 7a42238db446..25e862c487f6 100644 --- a/drivers/video/fbdev/core/fbmem.c +++ b/drivers/video/fbdev/core/fbmem.c | |||
@@ -32,6 +32,7 @@ | |||
32 | #include <linux/device.h> | 32 | #include <linux/device.h> |
33 | #include <linux/efi.h> | 33 | #include <linux/efi.h> |
34 | #include <linux/fb.h> | 34 | #include <linux/fb.h> |
35 | #include <linux/mem_encrypt.h> | ||
35 | 36 | ||
36 | #include <asm/fb.h> | 37 | #include <asm/fb.h> |
37 | 38 | ||
@@ -1396,6 +1397,12 @@ fb_mmap(struct file *file, struct vm_area_struct * vma) | |||
1396 | mutex_lock(&info->mm_lock); | 1397 | mutex_lock(&info->mm_lock); |
1397 | if (fb->fb_mmap) { | 1398 | if (fb->fb_mmap) { |
1398 | int res; | 1399 | int res; |
1400 | |||
1401 | /* | ||
1402 | * The framebuffer needs to be accessed decrypted, be sure | ||
1403 | * SME protection is removed ahead of the call | ||
1404 | */ | ||
1405 | vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot); | ||
1399 | res = fb->fb_mmap(info, vma); | 1406 | res = fb->fb_mmap(info, vma); |
1400 | mutex_unlock(&info->mm_lock); | 1407 | mutex_unlock(&info->mm_lock); |
1401 | return res; | 1408 | return res; |
@@ -1421,6 +1428,11 @@ fb_mmap(struct file *file, struct vm_area_struct * vma) | |||
1421 | mutex_unlock(&info->mm_lock); | 1428 | mutex_unlock(&info->mm_lock); |
1422 | 1429 | ||
1423 | vma->vm_page_prot = vm_get_page_prot(vma->vm_flags); | 1430 | vma->vm_page_prot = vm_get_page_prot(vma->vm_flags); |
1431 | /* | ||
1432 | * The framebuffer needs to be accessed decrypted, be sure | ||
1433 | * SME protection is removed | ||
1434 | */ | ||
1435 | vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot); | ||
1424 | fb_pgprotect(file, vma, start); | 1436 | fb_pgprotect(file, vma, start); |
1425 | 1437 | ||
1426 | return vm_iomap_memory(vma, start, len); | 1438 | return vm_iomap_memory(vma, start, len); |
diff --git a/drivers/video/fbdev/efifb.c b/drivers/video/fbdev/efifb.c index ff01bed7112f..1e784adb89b1 100644 --- a/drivers/video/fbdev/efifb.c +++ b/drivers/video/fbdev/efifb.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <asm/efi.h> | 17 | #include <asm/efi.h> |
18 | 18 | ||
19 | static bool request_mem_succeeded = false; | 19 | static bool request_mem_succeeded = false; |
20 | static bool nowc = false; | ||
20 | 21 | ||
21 | static struct fb_var_screeninfo efifb_defined = { | 22 | static struct fb_var_screeninfo efifb_defined = { |
22 | .activate = FB_ACTIVATE_NOW, | 23 | .activate = FB_ACTIVATE_NOW, |
@@ -99,6 +100,8 @@ static int efifb_setup(char *options) | |||
99 | screen_info.lfb_height = simple_strtoul(this_opt+7, NULL, 0); | 100 | screen_info.lfb_height = simple_strtoul(this_opt+7, NULL, 0); |
100 | else if (!strncmp(this_opt, "width:", 6)) | 101 | else if (!strncmp(this_opt, "width:", 6)) |
101 | screen_info.lfb_width = simple_strtoul(this_opt+6, NULL, 0); | 102 | screen_info.lfb_width = simple_strtoul(this_opt+6, NULL, 0); |
103 | else if (!strcmp(this_opt, "nowc")) | ||
104 | nowc = true; | ||
102 | } | 105 | } |
103 | } | 106 | } |
104 | 107 | ||
@@ -255,7 +258,10 @@ static int efifb_probe(struct platform_device *dev) | |||
255 | info->apertures->ranges[0].base = efifb_fix.smem_start; | 258 | info->apertures->ranges[0].base = efifb_fix.smem_start; |
256 | info->apertures->ranges[0].size = size_remap; | 259 | info->apertures->ranges[0].size = size_remap; |
257 | 260 | ||
258 | info->screen_base = ioremap_wc(efifb_fix.smem_start, efifb_fix.smem_len); | 261 | if (nowc) |
262 | info->screen_base = ioremap(efifb_fix.smem_start, efifb_fix.smem_len); | ||
263 | else | ||
264 | info->screen_base = ioremap_wc(efifb_fix.smem_start, efifb_fix.smem_len); | ||
259 | if (!info->screen_base) { | 265 | if (!info->screen_base) { |
260 | pr_err("efifb: abort, cannot ioremap video memory 0x%x @ 0x%lx\n", | 266 | pr_err("efifb: abort, cannot ioremap video memory 0x%x @ 0x%lx\n", |
261 | efifb_fix.smem_len, efifb_fix.smem_start); | 267 | efifb_fix.smem_len, efifb_fix.smem_start); |
diff --git a/drivers/video/fbdev/imxfb.c b/drivers/video/fbdev/imxfb.c index c166e0725be5..ba82f97fb42b 100644 --- a/drivers/video/fbdev/imxfb.c +++ b/drivers/video/fbdev/imxfb.c | |||
@@ -1073,20 +1073,16 @@ static int imxfb_remove(struct platform_device *pdev) | |||
1073 | imxfb_disable_controller(fbi); | 1073 | imxfb_disable_controller(fbi); |
1074 | 1074 | ||
1075 | unregister_framebuffer(info); | 1075 | unregister_framebuffer(info); |
1076 | 1076 | fb_dealloc_cmap(&info->cmap); | |
1077 | pdata = dev_get_platdata(&pdev->dev); | 1077 | pdata = dev_get_platdata(&pdev->dev); |
1078 | if (pdata && pdata->exit) | 1078 | if (pdata && pdata->exit) |
1079 | pdata->exit(fbi->pdev); | 1079 | pdata->exit(fbi->pdev); |
1080 | |||
1081 | fb_dealloc_cmap(&info->cmap); | ||
1082 | kfree(info->pseudo_palette); | ||
1083 | framebuffer_release(info); | ||
1084 | |||
1085 | dma_free_wc(&pdev->dev, fbi->map_size, info->screen_base, | 1080 | dma_free_wc(&pdev->dev, fbi->map_size, info->screen_base, |
1086 | fbi->map_dma); | 1081 | fbi->map_dma); |
1087 | |||
1088 | iounmap(fbi->regs); | 1082 | iounmap(fbi->regs); |
1089 | release_mem_region(res->start, resource_size(res)); | 1083 | release_mem_region(res->start, resource_size(res)); |
1084 | kfree(info->pseudo_palette); | ||
1085 | framebuffer_release(info); | ||
1090 | 1086 | ||
1091 | return 0; | 1087 | return 0; |
1092 | } | 1088 | } |
diff --git a/drivers/video/fbdev/omap2/omapfb/dss/core.c b/drivers/video/fbdev/omap2/omapfb/dss/core.c index eecf695c16f4..09e5bb013d28 100644 --- a/drivers/video/fbdev/omap2/omapfb/dss/core.c +++ b/drivers/video/fbdev/omap2/omapfb/dss/core.c | |||
@@ -193,7 +193,6 @@ static struct notifier_block omap_dss_pm_notif_block = { | |||
193 | 193 | ||
194 | static int __init omap_dss_probe(struct platform_device *pdev) | 194 | static int __init omap_dss_probe(struct platform_device *pdev) |
195 | { | 195 | { |
196 | struct omap_dss_board_info *pdata = pdev->dev.platform_data; | ||
197 | int r; | 196 | int r; |
198 | 197 | ||
199 | core.pdev = pdev; | 198 | core.pdev = pdev; |
diff --git a/drivers/xen/Makefile b/drivers/xen/Makefile index 8feab810aed9..7f188b8d0c67 100644 --- a/drivers/xen/Makefile +++ b/drivers/xen/Makefile | |||
@@ -7,9 +7,6 @@ obj-y += xenbus/ | |||
7 | nostackp := $(call cc-option, -fno-stack-protector) | 7 | nostackp := $(call cc-option, -fno-stack-protector) |
8 | CFLAGS_features.o := $(nostackp) | 8 | CFLAGS_features.o := $(nostackp) |
9 | 9 | ||
10 | CFLAGS_efi.o += -fshort-wchar | ||
11 | LDFLAGS += $(call ld-option, --no-wchar-size-warning) | ||
12 | |||
13 | dom0-$(CONFIG_ARM64) += arm-device.o | 10 | dom0-$(CONFIG_ARM64) += arm-device.o |
14 | dom0-$(CONFIG_PCI) += pci.o | 11 | dom0-$(CONFIG_PCI) += pci.o |
15 | dom0-$(CONFIG_USB_SUPPORT) += dbgp.o | 12 | dom0-$(CONFIG_USB_SUPPORT) += dbgp.o |
diff --git a/drivers/xen/biomerge.c b/drivers/xen/biomerge.c index 4da69dbf7dca..1bdd02a6d6ac 100644 --- a/drivers/xen/biomerge.c +++ b/drivers/xen/biomerge.c | |||
@@ -10,8 +10,7 @@ bool xen_biovec_phys_mergeable(const struct bio_vec *vec1, | |||
10 | unsigned long bfn1 = pfn_to_bfn(page_to_pfn(vec1->bv_page)); | 10 | unsigned long bfn1 = pfn_to_bfn(page_to_pfn(vec1->bv_page)); |
11 | unsigned long bfn2 = pfn_to_bfn(page_to_pfn(vec2->bv_page)); | 11 | unsigned long bfn2 = pfn_to_bfn(page_to_pfn(vec2->bv_page)); |
12 | 12 | ||
13 | return __BIOVEC_PHYS_MERGEABLE(vec1, vec2) && | 13 | return bfn1 + PFN_DOWN(vec1->bv_offset + vec1->bv_len) == bfn2; |
14 | ((bfn1 == bfn2) || ((bfn1+1) == bfn2)); | ||
15 | #else | 14 | #else |
16 | /* | 15 | /* |
17 | * XXX: Add support for merging bio_vec when using different page | 16 | * XXX: Add support for merging bio_vec when using different page |
diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c index bae1f5d36c26..2d43118077e4 100644 --- a/drivers/xen/events/events_base.c +++ b/drivers/xen/events/events_base.c | |||
@@ -574,7 +574,7 @@ static void shutdown_pirq(struct irq_data *data) | |||
574 | 574 | ||
575 | static void enable_pirq(struct irq_data *data) | 575 | static void enable_pirq(struct irq_data *data) |
576 | { | 576 | { |
577 | startup_pirq(data); | 577 | enable_dynirq(data); |
578 | } | 578 | } |
579 | 579 | ||
580 | static void disable_pirq(struct irq_data *data) | 580 | static void disable_pirq(struct irq_data *data) |
diff --git a/drivers/xen/xenbus/xenbus_xs.c b/drivers/xen/xenbus/xenbus_xs.c index e46080214955..3e59590c7254 100644 --- a/drivers/xen/xenbus/xenbus_xs.c +++ b/drivers/xen/xenbus/xenbus_xs.c | |||
@@ -857,6 +857,8 @@ static int xenwatch_thread(void *unused) | |||
857 | struct list_head *ent; | 857 | struct list_head *ent; |
858 | struct xs_watch_event *event; | 858 | struct xs_watch_event *event; |
859 | 859 | ||
860 | xenwatch_pid = current->pid; | ||
861 | |||
860 | for (;;) { | 862 | for (;;) { |
861 | wait_event_interruptible(watch_events_waitq, | 863 | wait_event_interruptible(watch_events_waitq, |
862 | !list_empty(&watch_events)); | 864 | !list_empty(&watch_events)); |
@@ -925,7 +927,6 @@ int xs_init(void) | |||
925 | task = kthread_run(xenwatch_thread, NULL, "xenwatch"); | 927 | task = kthread_run(xenwatch_thread, NULL, "xenwatch"); |
926 | if (IS_ERR(task)) | 928 | if (IS_ERR(task)) |
927 | return PTR_ERR(task); | 929 | return PTR_ERR(task); |
928 | xenwatch_pid = task->pid; | ||
929 | 930 | ||
930 | /* shutdown watches for kexec boot */ | 931 | /* shutdown watches for kexec boot */ |
931 | xs_reset_watches(); | 932 | xs_reset_watches(); |
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index 879ff9c7ffd0..6466153f2bf0 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c | |||
@@ -664,8 +664,7 @@ static unsigned long randomize_stack_top(unsigned long stack_top) | |||
664 | { | 664 | { |
665 | unsigned long random_variable = 0; | 665 | unsigned long random_variable = 0; |
666 | 666 | ||
667 | if ((current->flags & PF_RANDOMIZE) && | 667 | if (current->flags & PF_RANDOMIZE) { |
668 | !(current->personality & ADDR_NO_RANDOMIZE)) { | ||
669 | random_variable = get_random_long(); | 668 | random_variable = get_random_long(); |
670 | random_variable &= STACK_RND_MASK; | 669 | random_variable &= STACK_RND_MASK; |
671 | random_variable <<= PAGE_SHIFT; | 670 | random_variable <<= PAGE_SHIFT; |
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 080e2ebb8aa0..f45b61fe9a9a 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c | |||
@@ -3516,7 +3516,7 @@ static blk_status_t wait_dev_flush(struct btrfs_device *device) | |||
3516 | struct bio *bio = device->flush_bio; | 3516 | struct bio *bio = device->flush_bio; |
3517 | 3517 | ||
3518 | if (!device->flush_bio_sent) | 3518 | if (!device->flush_bio_sent) |
3519 | return 0; | 3519 | return BLK_STS_OK; |
3520 | 3520 | ||
3521 | device->flush_bio_sent = 0; | 3521 | device->flush_bio_sent = 0; |
3522 | wait_for_completion_io(&device->flush_wait); | 3522 | wait_for_completion_io(&device->flush_wait); |
@@ -3563,7 +3563,7 @@ static int barrier_all_devices(struct btrfs_fs_info *info) | |||
3563 | continue; | 3563 | continue; |
3564 | 3564 | ||
3565 | write_dev_flush(dev); | 3565 | write_dev_flush(dev); |
3566 | dev->last_flush_error = 0; | 3566 | dev->last_flush_error = BLK_STS_OK; |
3567 | } | 3567 | } |
3568 | 3568 | ||
3569 | /* wait for all the barriers */ | 3569 | /* wait for all the barriers */ |
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 95c212037095..24bcd5cd9cf2 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -7924,11 +7924,12 @@ err: | |||
7924 | return ret; | 7924 | return ret; |
7925 | } | 7925 | } |
7926 | 7926 | ||
7927 | static inline int submit_dio_repair_bio(struct inode *inode, struct bio *bio, | 7927 | static inline blk_status_t submit_dio_repair_bio(struct inode *inode, |
7928 | int mirror_num) | 7928 | struct bio *bio, |
7929 | int mirror_num) | ||
7929 | { | 7930 | { |
7930 | struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); | 7931 | struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); |
7931 | int ret; | 7932 | blk_status_t ret; |
7932 | 7933 | ||
7933 | BUG_ON(bio_op(bio) == REQ_OP_WRITE); | 7934 | BUG_ON(bio_op(bio) == REQ_OP_WRITE); |
7934 | 7935 | ||
@@ -7980,10 +7981,10 @@ static int btrfs_check_dio_repairable(struct inode *inode, | |||
7980 | return 1; | 7981 | return 1; |
7981 | } | 7982 | } |
7982 | 7983 | ||
7983 | static int dio_read_error(struct inode *inode, struct bio *failed_bio, | 7984 | static blk_status_t dio_read_error(struct inode *inode, struct bio *failed_bio, |
7984 | struct page *page, unsigned int pgoff, | 7985 | struct page *page, unsigned int pgoff, |
7985 | u64 start, u64 end, int failed_mirror, | 7986 | u64 start, u64 end, int failed_mirror, |
7986 | bio_end_io_t *repair_endio, void *repair_arg) | 7987 | bio_end_io_t *repair_endio, void *repair_arg) |
7987 | { | 7988 | { |
7988 | struct io_failure_record *failrec; | 7989 | struct io_failure_record *failrec; |
7989 | struct extent_io_tree *io_tree = &BTRFS_I(inode)->io_tree; | 7990 | struct extent_io_tree *io_tree = &BTRFS_I(inode)->io_tree; |
@@ -7993,18 +7994,19 @@ static int dio_read_error(struct inode *inode, struct bio *failed_bio, | |||
7993 | int read_mode = 0; | 7994 | int read_mode = 0; |
7994 | int segs; | 7995 | int segs; |
7995 | int ret; | 7996 | int ret; |
7997 | blk_status_t status; | ||
7996 | 7998 | ||
7997 | BUG_ON(bio_op(failed_bio) == REQ_OP_WRITE); | 7999 | BUG_ON(bio_op(failed_bio) == REQ_OP_WRITE); |
7998 | 8000 | ||
7999 | ret = btrfs_get_io_failure_record(inode, start, end, &failrec); | 8001 | ret = btrfs_get_io_failure_record(inode, start, end, &failrec); |
8000 | if (ret) | 8002 | if (ret) |
8001 | return ret; | 8003 | return errno_to_blk_status(ret); |
8002 | 8004 | ||
8003 | ret = btrfs_check_dio_repairable(inode, failed_bio, failrec, | 8005 | ret = btrfs_check_dio_repairable(inode, failed_bio, failrec, |
8004 | failed_mirror); | 8006 | failed_mirror); |
8005 | if (!ret) { | 8007 | if (!ret) { |
8006 | free_io_failure(failure_tree, io_tree, failrec); | 8008 | free_io_failure(failure_tree, io_tree, failrec); |
8007 | return -EIO; | 8009 | return BLK_STS_IOERR; |
8008 | } | 8010 | } |
8009 | 8011 | ||
8010 | segs = bio_segments(failed_bio); | 8012 | segs = bio_segments(failed_bio); |
@@ -8022,13 +8024,13 @@ static int dio_read_error(struct inode *inode, struct bio *failed_bio, | |||
8022 | "Repair DIO Read Error: submitting new dio read[%#x] to this_mirror=%d, in_validation=%d\n", | 8024 | "Repair DIO Read Error: submitting new dio read[%#x] to this_mirror=%d, in_validation=%d\n", |
8023 | read_mode, failrec->this_mirror, failrec->in_validation); | 8025 | read_mode, failrec->this_mirror, failrec->in_validation); |
8024 | 8026 | ||
8025 | ret = submit_dio_repair_bio(inode, bio, failrec->this_mirror); | 8027 | status = submit_dio_repair_bio(inode, bio, failrec->this_mirror); |
8026 | if (ret) { | 8028 | if (status) { |
8027 | free_io_failure(failure_tree, io_tree, failrec); | 8029 | free_io_failure(failure_tree, io_tree, failrec); |
8028 | bio_put(bio); | 8030 | bio_put(bio); |
8029 | } | 8031 | } |
8030 | 8032 | ||
8031 | return ret; | 8033 | return status; |
8032 | } | 8034 | } |
8033 | 8035 | ||
8034 | struct btrfs_retry_complete { | 8036 | struct btrfs_retry_complete { |
@@ -8065,8 +8067,8 @@ end: | |||
8065 | bio_put(bio); | 8067 | bio_put(bio); |
8066 | } | 8068 | } |
8067 | 8069 | ||
8068 | static int __btrfs_correct_data_nocsum(struct inode *inode, | 8070 | static blk_status_t __btrfs_correct_data_nocsum(struct inode *inode, |
8069 | struct btrfs_io_bio *io_bio) | 8071 | struct btrfs_io_bio *io_bio) |
8070 | { | 8072 | { |
8071 | struct btrfs_fs_info *fs_info; | 8073 | struct btrfs_fs_info *fs_info; |
8072 | struct bio_vec bvec; | 8074 | struct bio_vec bvec; |
@@ -8076,8 +8078,8 @@ static int __btrfs_correct_data_nocsum(struct inode *inode, | |||
8076 | unsigned int pgoff; | 8078 | unsigned int pgoff; |
8077 | u32 sectorsize; | 8079 | u32 sectorsize; |
8078 | int nr_sectors; | 8080 | int nr_sectors; |
8079 | int ret; | 8081 | blk_status_t ret; |
8080 | int err = 0; | 8082 | blk_status_t err = BLK_STS_OK; |
8081 | 8083 | ||
8082 | fs_info = BTRFS_I(inode)->root->fs_info; | 8084 | fs_info = BTRFS_I(inode)->root->fs_info; |
8083 | sectorsize = fs_info->sectorsize; | 8085 | sectorsize = fs_info->sectorsize; |
@@ -8183,11 +8185,12 @@ static blk_status_t __btrfs_subio_endio_read(struct inode *inode, | |||
8183 | int csum_pos; | 8185 | int csum_pos; |
8184 | bool uptodate = (err == 0); | 8186 | bool uptodate = (err == 0); |
8185 | int ret; | 8187 | int ret; |
8188 | blk_status_t status; | ||
8186 | 8189 | ||
8187 | fs_info = BTRFS_I(inode)->root->fs_info; | 8190 | fs_info = BTRFS_I(inode)->root->fs_info; |
8188 | sectorsize = fs_info->sectorsize; | 8191 | sectorsize = fs_info->sectorsize; |
8189 | 8192 | ||
8190 | err = 0; | 8193 | err = BLK_STS_OK; |
8191 | start = io_bio->logical; | 8194 | start = io_bio->logical; |
8192 | done.inode = inode; | 8195 | done.inode = inode; |
8193 | io_bio->bio.bi_iter = io_bio->iter; | 8196 | io_bio->bio.bi_iter = io_bio->iter; |
@@ -8209,12 +8212,12 @@ try_again: | |||
8209 | done.start = start; | 8212 | done.start = start; |
8210 | init_completion(&done.done); | 8213 | init_completion(&done.done); |
8211 | 8214 | ||
8212 | ret = dio_read_error(inode, &io_bio->bio, bvec.bv_page, | 8215 | status = dio_read_error(inode, &io_bio->bio, bvec.bv_page, |
8213 | pgoff, start, start + sectorsize - 1, | 8216 | pgoff, start, start + sectorsize - 1, |
8214 | io_bio->mirror_num, | 8217 | io_bio->mirror_num, btrfs_retry_endio, |
8215 | btrfs_retry_endio, &done); | 8218 | &done); |
8216 | if (ret) { | 8219 | if (status) { |
8217 | err = errno_to_blk_status(ret); | 8220 | err = status; |
8218 | goto next; | 8221 | goto next; |
8219 | } | 8222 | } |
8220 | 8223 | ||
@@ -8250,7 +8253,7 @@ static blk_status_t btrfs_subio_endio_read(struct inode *inode, | |||
8250 | if (unlikely(err)) | 8253 | if (unlikely(err)) |
8251 | return __btrfs_correct_data_nocsum(inode, io_bio); | 8254 | return __btrfs_correct_data_nocsum(inode, io_bio); |
8252 | else | 8255 | else |
8253 | return 0; | 8256 | return BLK_STS_OK; |
8254 | } else { | 8257 | } else { |
8255 | return __btrfs_subio_endio_read(inode, io_bio, err); | 8258 | return __btrfs_subio_endio_read(inode, io_bio, err); |
8256 | } | 8259 | } |
@@ -8423,9 +8426,9 @@ static inline blk_status_t btrfs_lookup_and_bind_dio_csum(struct inode *inode, | |||
8423 | return 0; | 8426 | return 0; |
8424 | } | 8427 | } |
8425 | 8428 | ||
8426 | static inline int __btrfs_submit_dio_bio(struct bio *bio, struct inode *inode, | 8429 | static inline blk_status_t |
8427 | u64 file_offset, int skip_sum, | 8430 | __btrfs_submit_dio_bio(struct bio *bio, struct inode *inode, u64 file_offset, |
8428 | int async_submit) | 8431 | int skip_sum, int async_submit) |
8429 | { | 8432 | { |
8430 | struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); | 8433 | struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); |
8431 | struct btrfs_dio_private *dip = bio->bi_private; | 8434 | struct btrfs_dio_private *dip = bio->bi_private; |
@@ -8488,6 +8491,7 @@ static int btrfs_submit_direct_hook(struct btrfs_dio_private *dip, | |||
8488 | int clone_offset = 0; | 8491 | int clone_offset = 0; |
8489 | int clone_len; | 8492 | int clone_len; |
8490 | int ret; | 8493 | int ret; |
8494 | blk_status_t status; | ||
8491 | 8495 | ||
8492 | map_length = orig_bio->bi_iter.bi_size; | 8496 | map_length = orig_bio->bi_iter.bi_size; |
8493 | submit_len = map_length; | 8497 | submit_len = map_length; |
@@ -8537,9 +8541,9 @@ static int btrfs_submit_direct_hook(struct btrfs_dio_private *dip, | |||
8537 | */ | 8541 | */ |
8538 | atomic_inc(&dip->pending_bios); | 8542 | atomic_inc(&dip->pending_bios); |
8539 | 8543 | ||
8540 | ret = __btrfs_submit_dio_bio(bio, inode, file_offset, skip_sum, | 8544 | status = __btrfs_submit_dio_bio(bio, inode, file_offset, skip_sum, |
8541 | async_submit); | 8545 | async_submit); |
8542 | if (ret) { | 8546 | if (status) { |
8543 | bio_put(bio); | 8547 | bio_put(bio); |
8544 | atomic_dec(&dip->pending_bios); | 8548 | atomic_dec(&dip->pending_bios); |
8545 | goto out_err; | 8549 | goto out_err; |
@@ -8557,9 +8561,9 @@ static int btrfs_submit_direct_hook(struct btrfs_dio_private *dip, | |||
8557 | } while (submit_len > 0); | 8561 | } while (submit_len > 0); |
8558 | 8562 | ||
8559 | submit: | 8563 | submit: |
8560 | ret = __btrfs_submit_dio_bio(bio, inode, file_offset, skip_sum, | 8564 | status = __btrfs_submit_dio_bio(bio, inode, file_offset, skip_sum, |
8561 | async_submit); | 8565 | async_submit); |
8562 | if (!ret) | 8566 | if (!status) |
8563 | return 0; | 8567 | return 0; |
8564 | 8568 | ||
8565 | bio_put(bio); | 8569 | bio_put(bio); |
diff --git a/fs/btrfs/raid56.c b/fs/btrfs/raid56.c index 208638384cd2..2cf6ba40f7c4 100644 --- a/fs/btrfs/raid56.c +++ b/fs/btrfs/raid56.c | |||
@@ -905,7 +905,7 @@ static void raid_write_end_io(struct bio *bio) | |||
905 | if (!atomic_dec_and_test(&rbio->stripes_pending)) | 905 | if (!atomic_dec_and_test(&rbio->stripes_pending)) |
906 | return; | 906 | return; |
907 | 907 | ||
908 | err = 0; | 908 | err = BLK_STS_OK; |
909 | 909 | ||
910 | /* OK, we have read all the stripes we need to. */ | 910 | /* OK, we have read all the stripes we need to. */ |
911 | max_errors = (rbio->operation == BTRFS_RBIO_PARITY_SCRUB) ? | 911 | max_errors = (rbio->operation == BTRFS_RBIO_PARITY_SCRUB) ? |
@@ -1324,7 +1324,7 @@ write_data: | |||
1324 | return; | 1324 | return; |
1325 | 1325 | ||
1326 | cleanup: | 1326 | cleanup: |
1327 | rbio_orig_end_io(rbio, -EIO); | 1327 | rbio_orig_end_io(rbio, BLK_STS_IOERR); |
1328 | } | 1328 | } |
1329 | 1329 | ||
1330 | /* | 1330 | /* |
@@ -1475,7 +1475,7 @@ static void raid_rmw_end_io(struct bio *bio) | |||
1475 | 1475 | ||
1476 | cleanup: | 1476 | cleanup: |
1477 | 1477 | ||
1478 | rbio_orig_end_io(rbio, -EIO); | 1478 | rbio_orig_end_io(rbio, BLK_STS_IOERR); |
1479 | } | 1479 | } |
1480 | 1480 | ||
1481 | static void async_rmw_stripe(struct btrfs_raid_bio *rbio) | 1481 | static void async_rmw_stripe(struct btrfs_raid_bio *rbio) |
@@ -1579,7 +1579,7 @@ static int raid56_rmw_stripe(struct btrfs_raid_bio *rbio) | |||
1579 | return 0; | 1579 | return 0; |
1580 | 1580 | ||
1581 | cleanup: | 1581 | cleanup: |
1582 | rbio_orig_end_io(rbio, -EIO); | 1582 | rbio_orig_end_io(rbio, BLK_STS_IOERR); |
1583 | return -EIO; | 1583 | return -EIO; |
1584 | 1584 | ||
1585 | finish: | 1585 | finish: |
@@ -1795,12 +1795,12 @@ static void __raid_recover_end_io(struct btrfs_raid_bio *rbio) | |||
1795 | void **pointers; | 1795 | void **pointers; |
1796 | int faila = -1, failb = -1; | 1796 | int faila = -1, failb = -1; |
1797 | struct page *page; | 1797 | struct page *page; |
1798 | int err; | 1798 | blk_status_t err; |
1799 | int i; | 1799 | int i; |
1800 | 1800 | ||
1801 | pointers = kcalloc(rbio->real_stripes, sizeof(void *), GFP_NOFS); | 1801 | pointers = kcalloc(rbio->real_stripes, sizeof(void *), GFP_NOFS); |
1802 | if (!pointers) { | 1802 | if (!pointers) { |
1803 | err = -ENOMEM; | 1803 | err = BLK_STS_RESOURCE; |
1804 | goto cleanup_io; | 1804 | goto cleanup_io; |
1805 | } | 1805 | } |
1806 | 1806 | ||
@@ -1856,7 +1856,7 @@ static void __raid_recover_end_io(struct btrfs_raid_bio *rbio) | |||
1856 | * a bad data or Q stripe. | 1856 | * a bad data or Q stripe. |
1857 | * TODO, we should redo the xor here. | 1857 | * TODO, we should redo the xor here. |
1858 | */ | 1858 | */ |
1859 | err = -EIO; | 1859 | err = BLK_STS_IOERR; |
1860 | goto cleanup; | 1860 | goto cleanup; |
1861 | } | 1861 | } |
1862 | /* | 1862 | /* |
@@ -1882,7 +1882,7 @@ static void __raid_recover_end_io(struct btrfs_raid_bio *rbio) | |||
1882 | if (rbio->bbio->raid_map[failb] == RAID6_Q_STRIPE) { | 1882 | if (rbio->bbio->raid_map[failb] == RAID6_Q_STRIPE) { |
1883 | if (rbio->bbio->raid_map[faila] == | 1883 | if (rbio->bbio->raid_map[faila] == |
1884 | RAID5_P_STRIPE) { | 1884 | RAID5_P_STRIPE) { |
1885 | err = -EIO; | 1885 | err = BLK_STS_IOERR; |
1886 | goto cleanup; | 1886 | goto cleanup; |
1887 | } | 1887 | } |
1888 | /* | 1888 | /* |
@@ -1954,13 +1954,13 @@ pstripe: | |||
1954 | } | 1954 | } |
1955 | } | 1955 | } |
1956 | 1956 | ||
1957 | err = 0; | 1957 | err = BLK_STS_OK; |
1958 | cleanup: | 1958 | cleanup: |
1959 | kfree(pointers); | 1959 | kfree(pointers); |
1960 | 1960 | ||
1961 | cleanup_io: | 1961 | cleanup_io: |
1962 | if (rbio->operation == BTRFS_RBIO_READ_REBUILD) { | 1962 | if (rbio->operation == BTRFS_RBIO_READ_REBUILD) { |
1963 | if (err == 0) | 1963 | if (err == BLK_STS_OK) |
1964 | cache_rbio_pages(rbio); | 1964 | cache_rbio_pages(rbio); |
1965 | else | 1965 | else |
1966 | clear_bit(RBIO_CACHE_READY_BIT, &rbio->flags); | 1966 | clear_bit(RBIO_CACHE_READY_BIT, &rbio->flags); |
@@ -1968,7 +1968,7 @@ cleanup_io: | |||
1968 | rbio_orig_end_io(rbio, err); | 1968 | rbio_orig_end_io(rbio, err); |
1969 | } else if (rbio->operation == BTRFS_RBIO_REBUILD_MISSING) { | 1969 | } else if (rbio->operation == BTRFS_RBIO_REBUILD_MISSING) { |
1970 | rbio_orig_end_io(rbio, err); | 1970 | rbio_orig_end_io(rbio, err); |
1971 | } else if (err == 0) { | 1971 | } else if (err == BLK_STS_OK) { |
1972 | rbio->faila = -1; | 1972 | rbio->faila = -1; |
1973 | rbio->failb = -1; | 1973 | rbio->failb = -1; |
1974 | 1974 | ||
@@ -2005,7 +2005,7 @@ static void raid_recover_end_io(struct bio *bio) | |||
2005 | return; | 2005 | return; |
2006 | 2006 | ||
2007 | if (atomic_read(&rbio->error) > rbio->bbio->max_errors) | 2007 | if (atomic_read(&rbio->error) > rbio->bbio->max_errors) |
2008 | rbio_orig_end_io(rbio, -EIO); | 2008 | rbio_orig_end_io(rbio, BLK_STS_IOERR); |
2009 | else | 2009 | else |
2010 | __raid_recover_end_io(rbio); | 2010 | __raid_recover_end_io(rbio); |
2011 | } | 2011 | } |
@@ -2104,7 +2104,7 @@ out: | |||
2104 | cleanup: | 2104 | cleanup: |
2105 | if (rbio->operation == BTRFS_RBIO_READ_REBUILD || | 2105 | if (rbio->operation == BTRFS_RBIO_READ_REBUILD || |
2106 | rbio->operation == BTRFS_RBIO_REBUILD_MISSING) | 2106 | rbio->operation == BTRFS_RBIO_REBUILD_MISSING) |
2107 | rbio_orig_end_io(rbio, -EIO); | 2107 | rbio_orig_end_io(rbio, BLK_STS_IOERR); |
2108 | return -EIO; | 2108 | return -EIO; |
2109 | } | 2109 | } |
2110 | 2110 | ||
@@ -2431,7 +2431,7 @@ submit_write: | |||
2431 | nr_data = bio_list_size(&bio_list); | 2431 | nr_data = bio_list_size(&bio_list); |
2432 | if (!nr_data) { | 2432 | if (!nr_data) { |
2433 | /* Every parity is right */ | 2433 | /* Every parity is right */ |
2434 | rbio_orig_end_io(rbio, 0); | 2434 | rbio_orig_end_io(rbio, BLK_STS_OK); |
2435 | return; | 2435 | return; |
2436 | } | 2436 | } |
2437 | 2437 | ||
@@ -2451,7 +2451,7 @@ submit_write: | |||
2451 | return; | 2451 | return; |
2452 | 2452 | ||
2453 | cleanup: | 2453 | cleanup: |
2454 | rbio_orig_end_io(rbio, -EIO); | 2454 | rbio_orig_end_io(rbio, BLK_STS_IOERR); |
2455 | } | 2455 | } |
2456 | 2456 | ||
2457 | static inline int is_data_stripe(struct btrfs_raid_bio *rbio, int stripe) | 2457 | static inline int is_data_stripe(struct btrfs_raid_bio *rbio, int stripe) |
@@ -2519,7 +2519,7 @@ static void validate_rbio_for_parity_scrub(struct btrfs_raid_bio *rbio) | |||
2519 | return; | 2519 | return; |
2520 | 2520 | ||
2521 | cleanup: | 2521 | cleanup: |
2522 | rbio_orig_end_io(rbio, -EIO); | 2522 | rbio_orig_end_io(rbio, BLK_STS_IOERR); |
2523 | } | 2523 | } |
2524 | 2524 | ||
2525 | /* | 2525 | /* |
@@ -2633,7 +2633,7 @@ static void raid56_parity_scrub_stripe(struct btrfs_raid_bio *rbio) | |||
2633 | return; | 2633 | return; |
2634 | 2634 | ||
2635 | cleanup: | 2635 | cleanup: |
2636 | rbio_orig_end_io(rbio, -EIO); | 2636 | rbio_orig_end_io(rbio, BLK_STS_IOERR); |
2637 | return; | 2637 | return; |
2638 | 2638 | ||
2639 | finish: | 2639 | finish: |
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index e8b9a269fdde..bd679bc7a1a9 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c | |||
@@ -6212,8 +6212,8 @@ static void bbio_error(struct btrfs_bio *bbio, struct bio *bio, u64 logical) | |||
6212 | } | 6212 | } |
6213 | } | 6213 | } |
6214 | 6214 | ||
6215 | int btrfs_map_bio(struct btrfs_fs_info *fs_info, struct bio *bio, | 6215 | blk_status_t btrfs_map_bio(struct btrfs_fs_info *fs_info, struct bio *bio, |
6216 | int mirror_num, int async_submit) | 6216 | int mirror_num, int async_submit) |
6217 | { | 6217 | { |
6218 | struct btrfs_device *dev; | 6218 | struct btrfs_device *dev; |
6219 | struct bio *first_bio = bio; | 6219 | struct bio *first_bio = bio; |
@@ -6233,7 +6233,7 @@ int btrfs_map_bio(struct btrfs_fs_info *fs_info, struct bio *bio, | |||
6233 | &map_length, &bbio, mirror_num, 1); | 6233 | &map_length, &bbio, mirror_num, 1); |
6234 | if (ret) { | 6234 | if (ret) { |
6235 | btrfs_bio_counter_dec(fs_info); | 6235 | btrfs_bio_counter_dec(fs_info); |
6236 | return ret; | 6236 | return errno_to_blk_status(ret); |
6237 | } | 6237 | } |
6238 | 6238 | ||
6239 | total_devs = bbio->num_stripes; | 6239 | total_devs = bbio->num_stripes; |
@@ -6256,7 +6256,7 @@ int btrfs_map_bio(struct btrfs_fs_info *fs_info, struct bio *bio, | |||
6256 | } | 6256 | } |
6257 | 6257 | ||
6258 | btrfs_bio_counter_dec(fs_info); | 6258 | btrfs_bio_counter_dec(fs_info); |
6259 | return ret; | 6259 | return errno_to_blk_status(ret); |
6260 | } | 6260 | } |
6261 | 6261 | ||
6262 | if (map_length < length) { | 6262 | if (map_length < length) { |
@@ -6283,7 +6283,7 @@ int btrfs_map_bio(struct btrfs_fs_info *fs_info, struct bio *bio, | |||
6283 | dev_nr, async_submit); | 6283 | dev_nr, async_submit); |
6284 | } | 6284 | } |
6285 | btrfs_bio_counter_dec(fs_info); | 6285 | btrfs_bio_counter_dec(fs_info); |
6286 | return 0; | 6286 | return BLK_STS_OK; |
6287 | } | 6287 | } |
6288 | 6288 | ||
6289 | struct btrfs_device *btrfs_find_device(struct btrfs_fs_info *fs_info, u64 devid, | 6289 | struct btrfs_device *btrfs_find_device(struct btrfs_fs_info *fs_info, u64 devid, |
diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h index 6f45fd60d15a..93277fc60930 100644 --- a/fs/btrfs/volumes.h +++ b/fs/btrfs/volumes.h | |||
@@ -74,7 +74,7 @@ struct btrfs_device { | |||
74 | int missing; | 74 | int missing; |
75 | int can_discard; | 75 | int can_discard; |
76 | int is_tgtdev_for_dev_replace; | 76 | int is_tgtdev_for_dev_replace; |
77 | int last_flush_error; | 77 | blk_status_t last_flush_error; |
78 | int flush_bio_sent; | 78 | int flush_bio_sent; |
79 | 79 | ||
80 | #ifdef __BTRFS_NEED_DEVICE_DATA_ORDERED | 80 | #ifdef __BTRFS_NEED_DEVICE_DATA_ORDERED |
@@ -416,8 +416,8 @@ int btrfs_alloc_chunk(struct btrfs_trans_handle *trans, | |||
416 | struct btrfs_fs_info *fs_info, u64 type); | 416 | struct btrfs_fs_info *fs_info, u64 type); |
417 | void btrfs_mapping_init(struct btrfs_mapping_tree *tree); | 417 | void btrfs_mapping_init(struct btrfs_mapping_tree *tree); |
418 | void btrfs_mapping_tree_free(struct btrfs_mapping_tree *tree); | 418 | void btrfs_mapping_tree_free(struct btrfs_mapping_tree *tree); |
419 | int btrfs_map_bio(struct btrfs_fs_info *fs_info, struct bio *bio, | 419 | blk_status_t btrfs_map_bio(struct btrfs_fs_info *fs_info, struct bio *bio, |
420 | int mirror_num, int async_submit); | 420 | int mirror_num, int async_submit); |
421 | int btrfs_open_devices(struct btrfs_fs_devices *fs_devices, | 421 | int btrfs_open_devices(struct btrfs_fs_devices *fs_devices, |
422 | fmode_t flags, void *holder); | 422 | fmode_t flags, void *holder); |
423 | int btrfs_scan_one_device(const char *path, fmode_t flags, void *holder, | 423 | int btrfs_scan_one_device(const char *path, fmode_t flags, void *holder, |
diff --git a/fs/devpts/inode.c b/fs/devpts/inode.c index 108df2e3602c..7eae33ffa3fc 100644 --- a/fs/devpts/inode.c +++ b/fs/devpts/inode.c | |||
@@ -133,6 +133,50 @@ static inline struct pts_fs_info *DEVPTS_SB(struct super_block *sb) | |||
133 | return sb->s_fs_info; | 133 | return sb->s_fs_info; |
134 | } | 134 | } |
135 | 135 | ||
136 | static int devpts_ptmx_path(struct path *path) | ||
137 | { | ||
138 | struct super_block *sb; | ||
139 | int err; | ||
140 | |||
141 | /* Has the devpts filesystem already been found? */ | ||
142 | if (path->mnt->mnt_sb->s_magic == DEVPTS_SUPER_MAGIC) | ||
143 | return 0; | ||
144 | |||
145 | /* Is a devpts filesystem at "pts" in the same directory? */ | ||
146 | err = path_pts(path); | ||
147 | if (err) | ||
148 | return err; | ||
149 | |||
150 | /* Is the path the root of a devpts filesystem? */ | ||
151 | sb = path->mnt->mnt_sb; | ||
152 | if ((sb->s_magic != DEVPTS_SUPER_MAGIC) || | ||
153 | (path->mnt->mnt_root != sb->s_root)) | ||
154 | return -ENODEV; | ||
155 | |||
156 | return 0; | ||
157 | } | ||
158 | |||
159 | struct vfsmount *devpts_mntget(struct file *filp, struct pts_fs_info *fsi) | ||
160 | { | ||
161 | struct path path; | ||
162 | int err; | ||
163 | |||
164 | path = filp->f_path; | ||
165 | path_get(&path); | ||
166 | |||
167 | err = devpts_ptmx_path(&path); | ||
168 | dput(path.dentry); | ||
169 | if (err) { | ||
170 | mntput(path.mnt); | ||
171 | path.mnt = ERR_PTR(err); | ||
172 | } | ||
173 | if (DEVPTS_SB(path.mnt->mnt_sb) != fsi) { | ||
174 | mntput(path.mnt); | ||
175 | path.mnt = ERR_PTR(-ENODEV); | ||
176 | } | ||
177 | return path.mnt; | ||
178 | } | ||
179 | |||
136 | struct pts_fs_info *devpts_acquire(struct file *filp) | 180 | struct pts_fs_info *devpts_acquire(struct file *filp) |
137 | { | 181 | { |
138 | struct pts_fs_info *result; | 182 | struct pts_fs_info *result; |
@@ -143,27 +187,16 @@ struct pts_fs_info *devpts_acquire(struct file *filp) | |||
143 | path = filp->f_path; | 187 | path = filp->f_path; |
144 | path_get(&path); | 188 | path_get(&path); |
145 | 189 | ||
146 | /* Has the devpts filesystem already been found? */ | 190 | err = devpts_ptmx_path(&path); |
147 | sb = path.mnt->mnt_sb; | 191 | if (err) { |
148 | if (sb->s_magic != DEVPTS_SUPER_MAGIC) { | 192 | result = ERR_PTR(err); |
149 | /* Is a devpts filesystem at "pts" in the same directory? */ | 193 | goto out; |
150 | err = path_pts(&path); | ||
151 | if (err) { | ||
152 | result = ERR_PTR(err); | ||
153 | goto out; | ||
154 | } | ||
155 | |||
156 | /* Is the path the root of a devpts filesystem? */ | ||
157 | result = ERR_PTR(-ENODEV); | ||
158 | sb = path.mnt->mnt_sb; | ||
159 | if ((sb->s_magic != DEVPTS_SUPER_MAGIC) || | ||
160 | (path.mnt->mnt_root != sb->s_root)) | ||
161 | goto out; | ||
162 | } | 194 | } |
163 | 195 | ||
164 | /* | 196 | /* |
165 | * pty code needs to hold extra references in case of last /dev/tty close | 197 | * pty code needs to hold extra references in case of last /dev/tty close |
166 | */ | 198 | */ |
199 | sb = path.mnt->mnt_sb; | ||
167 | atomic_inc(&sb->s_active); | 200 | atomic_inc(&sb->s_active); |
168 | result = DEVPTS_SB(sb); | 201 | result = DEVPTS_SB(sb); |
169 | 202 | ||
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index 5a1052627a81..701085620cd8 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c | |||
@@ -2300,7 +2300,7 @@ static int ext4_mb_seq_groups_show(struct seq_file *seq, void *v) | |||
2300 | EXT4_MAX_BLOCK_LOG_SIZE); | 2300 | EXT4_MAX_BLOCK_LOG_SIZE); |
2301 | struct sg { | 2301 | struct sg { |
2302 | struct ext4_group_info info; | 2302 | struct ext4_group_info info; |
2303 | ext4_grpblk_t counters[blocksize_bits + 2]; | 2303 | ext4_grpblk_t counters[EXT4_MAX_BLOCK_LOG_SIZE + 2]; |
2304 | } sg; | 2304 | } sg; |
2305 | 2305 | ||
2306 | group--; | 2306 | group--; |
@@ -2309,6 +2309,9 @@ static int ext4_mb_seq_groups_show(struct seq_file *seq, void *v) | |||
2309 | " 2^0 2^1 2^2 2^3 2^4 2^5 2^6 " | 2309 | " 2^0 2^1 2^2 2^3 2^4 2^5 2^6 " |
2310 | " 2^7 2^8 2^9 2^10 2^11 2^12 2^13 ]\n"); | 2310 | " 2^7 2^8 2^9 2^10 2^11 2^12 2^13 ]\n"); |
2311 | 2311 | ||
2312 | i = (blocksize_bits + 2) * sizeof(sg.info.bb_counters[0]) + | ||
2313 | sizeof(struct ext4_group_info); | ||
2314 | |||
2312 | grinfo = ext4_get_group_info(sb, group); | 2315 | grinfo = ext4_get_group_info(sb, group); |
2313 | /* Load the group info in memory only if not already loaded. */ | 2316 | /* Load the group info in memory only if not already loaded. */ |
2314 | if (unlikely(EXT4_MB_GRP_NEED_INIT(grinfo))) { | 2317 | if (unlikely(EXT4_MB_GRP_NEED_INIT(grinfo))) { |
@@ -2320,7 +2323,7 @@ static int ext4_mb_seq_groups_show(struct seq_file *seq, void *v) | |||
2320 | buddy_loaded = 1; | 2323 | buddy_loaded = 1; |
2321 | } | 2324 | } |
2322 | 2325 | ||
2323 | memcpy(&sg, ext4_get_group_info(sb, group), sizeof(sg)); | 2326 | memcpy(&sg, ext4_get_group_info(sb, group), i); |
2324 | 2327 | ||
2325 | if (buddy_loaded) | 2328 | if (buddy_loaded) |
2326 | ext4_mb_unload_buddy(&e4b); | 2329 | ext4_mb_unload_buddy(&e4b); |
diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c index 82a5af9f6668..3dd970168448 100644 --- a/fs/ext4/xattr.c +++ b/fs/ext4/xattr.c | |||
@@ -1543,7 +1543,7 @@ static int ext4_xattr_set_entry(struct ext4_xattr_info *i, | |||
1543 | /* Clear padding bytes. */ | 1543 | /* Clear padding bytes. */ |
1544 | memset(val + i->value_len, 0, new_size - i->value_len); | 1544 | memset(val + i->value_len, 0, new_size - i->value_len); |
1545 | } | 1545 | } |
1546 | return 0; | 1546 | goto update_hash; |
1547 | } | 1547 | } |
1548 | 1548 | ||
1549 | /* Compute min_offs and last. */ | 1549 | /* Compute min_offs and last. */ |
@@ -1707,6 +1707,7 @@ static int ext4_xattr_set_entry(struct ext4_xattr_info *i, | |||
1707 | here->e_value_size = cpu_to_le32(i->value_len); | 1707 | here->e_value_size = cpu_to_le32(i->value_len); |
1708 | } | 1708 | } |
1709 | 1709 | ||
1710 | update_hash: | ||
1710 | if (i->value) { | 1711 | if (i->value) { |
1711 | __le32 hash = 0; | 1712 | __le32 hash = 0; |
1712 | 1713 | ||
@@ -1725,7 +1726,8 @@ static int ext4_xattr_set_entry(struct ext4_xattr_info *i, | |||
1725 | here->e_name_len, | 1726 | here->e_name_len, |
1726 | &crc32c_hash, 1); | 1727 | &crc32c_hash, 1); |
1727 | } else if (is_block) { | 1728 | } else if (is_block) { |
1728 | __le32 *value = s->base + min_offs - new_size; | 1729 | __le32 *value = s->base + le16_to_cpu( |
1730 | here->e_value_offs); | ||
1729 | 1731 | ||
1730 | hash = ext4_xattr_hash_entry(here->e_name, | 1732 | hash = ext4_xattr_hash_entry(here->e_name, |
1731 | here->e_name_len, value, | 1733 | here->e_name_len, value, |
diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 3ee4fdc3da9e..ab60051be6e5 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c | |||
@@ -46,7 +46,7 @@ struct fuse_file *fuse_file_alloc(struct fuse_conn *fc) | |||
46 | { | 46 | { |
47 | struct fuse_file *ff; | 47 | struct fuse_file *ff; |
48 | 48 | ||
49 | ff = kmalloc(sizeof(struct fuse_file), GFP_KERNEL); | 49 | ff = kzalloc(sizeof(struct fuse_file), GFP_KERNEL); |
50 | if (unlikely(!ff)) | 50 | if (unlikely(!ff)) |
51 | return NULL; | 51 | return NULL; |
52 | 52 | ||
@@ -609,7 +609,7 @@ static void fuse_aio_complete_req(struct fuse_conn *fc, struct fuse_req *req) | |||
609 | struct fuse_io_priv *io = req->io; | 609 | struct fuse_io_priv *io = req->io; |
610 | ssize_t pos = -1; | 610 | ssize_t pos = -1; |
611 | 611 | ||
612 | fuse_release_user_pages(req, !io->write); | 612 | fuse_release_user_pages(req, io->should_dirty); |
613 | 613 | ||
614 | if (io->write) { | 614 | if (io->write) { |
615 | if (req->misc.write.in.size != req->misc.write.out.size) | 615 | if (req->misc.write.in.size != req->misc.write.out.size) |
@@ -1316,7 +1316,6 @@ ssize_t fuse_direct_io(struct fuse_io_priv *io, struct iov_iter *iter, | |||
1316 | loff_t *ppos, int flags) | 1316 | loff_t *ppos, int flags) |
1317 | { | 1317 | { |
1318 | int write = flags & FUSE_DIO_WRITE; | 1318 | int write = flags & FUSE_DIO_WRITE; |
1319 | bool should_dirty = !write && iter_is_iovec(iter); | ||
1320 | int cuse = flags & FUSE_DIO_CUSE; | 1319 | int cuse = flags & FUSE_DIO_CUSE; |
1321 | struct file *file = io->file; | 1320 | struct file *file = io->file; |
1322 | struct inode *inode = file->f_mapping->host; | 1321 | struct inode *inode = file->f_mapping->host; |
@@ -1346,6 +1345,7 @@ ssize_t fuse_direct_io(struct fuse_io_priv *io, struct iov_iter *iter, | |||
1346 | inode_unlock(inode); | 1345 | inode_unlock(inode); |
1347 | } | 1346 | } |
1348 | 1347 | ||
1348 | io->should_dirty = !write && iter_is_iovec(iter); | ||
1349 | while (count) { | 1349 | while (count) { |
1350 | size_t nres; | 1350 | size_t nres; |
1351 | fl_owner_t owner = current->files; | 1351 | fl_owner_t owner = current->files; |
@@ -1360,7 +1360,7 @@ ssize_t fuse_direct_io(struct fuse_io_priv *io, struct iov_iter *iter, | |||
1360 | nres = fuse_send_read(req, io, pos, nbytes, owner); | 1360 | nres = fuse_send_read(req, io, pos, nbytes, owner); |
1361 | 1361 | ||
1362 | if (!io->async) | 1362 | if (!io->async) |
1363 | fuse_release_user_pages(req, should_dirty); | 1363 | fuse_release_user_pages(req, io->should_dirty); |
1364 | if (req->out.h.error) { | 1364 | if (req->out.h.error) { |
1365 | err = req->out.h.error; | 1365 | err = req->out.h.error; |
1366 | break; | 1366 | break; |
@@ -1669,6 +1669,7 @@ err_nofile: | |||
1669 | err_free: | 1669 | err_free: |
1670 | fuse_request_free(req); | 1670 | fuse_request_free(req); |
1671 | err: | 1671 | err: |
1672 | mapping_set_error(page->mapping, error); | ||
1672 | end_page_writeback(page); | 1673 | end_page_writeback(page); |
1673 | return error; | 1674 | return error; |
1674 | } | 1675 | } |
diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index 1bd7ffdad593..bd4d2a3e1ec1 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h | |||
@@ -249,6 +249,7 @@ struct fuse_io_priv { | |||
249 | size_t size; | 249 | size_t size; |
250 | __u64 offset; | 250 | __u64 offset; |
251 | bool write; | 251 | bool write; |
252 | bool should_dirty; | ||
252 | int err; | 253 | int err; |
253 | struct kiocb *iocb; | 254 | struct kiocb *iocb; |
254 | struct file *file; | 255 | struct file *file; |
diff --git a/fs/iomap.c b/fs/iomap.c index 039266128b7f..59cc98ad7577 100644 --- a/fs/iomap.c +++ b/fs/iomap.c | |||
@@ -278,7 +278,7 @@ iomap_dirty_actor(struct inode *inode, loff_t pos, loff_t length, void *data, | |||
278 | unsigned long bytes; /* Bytes to write to page */ | 278 | unsigned long bytes; /* Bytes to write to page */ |
279 | 279 | ||
280 | offset = (pos & (PAGE_SIZE - 1)); | 280 | offset = (pos & (PAGE_SIZE - 1)); |
281 | bytes = min_t(unsigned long, PAGE_SIZE - offset, length); | 281 | bytes = min_t(loff_t, PAGE_SIZE - offset, length); |
282 | 282 | ||
283 | rpage = __iomap_read_page(inode, pos); | 283 | rpage = __iomap_read_page(inode, pos); |
284 | if (IS_ERR(rpage)) | 284 | if (IS_ERR(rpage)) |
@@ -373,7 +373,7 @@ iomap_zero_range_actor(struct inode *inode, loff_t pos, loff_t count, | |||
373 | unsigned offset, bytes; | 373 | unsigned offset, bytes; |
374 | 374 | ||
375 | offset = pos & (PAGE_SIZE - 1); /* Within page */ | 375 | offset = pos & (PAGE_SIZE - 1); /* Within page */ |
376 | bytes = min_t(unsigned, PAGE_SIZE - offset, count); | 376 | bytes = min_t(loff_t, PAGE_SIZE - offset, count); |
377 | 377 | ||
378 | if (IS_DAX(inode)) | 378 | if (IS_DAX(inode)) |
379 | status = iomap_dax_zero(pos, offset, bytes, iomap); | 379 | status = iomap_dax_zero(pos, offset, bytes, iomap); |
diff --git a/fs/nfs/Kconfig b/fs/nfs/Kconfig index 69d02cf8cf37..5f93cfacb3d1 100644 --- a/fs/nfs/Kconfig +++ b/fs/nfs/Kconfig | |||
@@ -121,6 +121,7 @@ config PNFS_FILE_LAYOUT | |||
121 | config PNFS_BLOCK | 121 | config PNFS_BLOCK |
122 | tristate | 122 | tristate |
123 | depends on NFS_V4_1 && BLK_DEV_DM | 123 | depends on NFS_V4_1 && BLK_DEV_DM |
124 | depends on 64BIT || LBDAF | ||
124 | default NFS_V4 | 125 | default NFS_V4 |
125 | 126 | ||
126 | config PNFS_FLEXFILE_LAYOUT | 127 | config PNFS_FLEXFILE_LAYOUT |
diff --git a/fs/nfs/flexfilelayout/flexfilelayoutdev.c b/fs/nfs/flexfilelayout/flexfilelayoutdev.c index 6df7a0cf5660..f32c58bbe556 100644 --- a/fs/nfs/flexfilelayout/flexfilelayoutdev.c +++ b/fs/nfs/flexfilelayout/flexfilelayoutdev.c | |||
@@ -32,6 +32,7 @@ void nfs4_ff_layout_free_deviceid(struct nfs4_ff_layout_ds *mirror_ds) | |||
32 | { | 32 | { |
33 | nfs4_print_deviceid(&mirror_ds->id_node.deviceid); | 33 | nfs4_print_deviceid(&mirror_ds->id_node.deviceid); |
34 | nfs4_pnfs_ds_put(mirror_ds->ds); | 34 | nfs4_pnfs_ds_put(mirror_ds->ds); |
35 | kfree(mirror_ds->ds_versions); | ||
35 | kfree_rcu(mirror_ds, id_node.rcu); | 36 | kfree_rcu(mirror_ds, id_node.rcu); |
36 | } | 37 | } |
37 | 38 | ||
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index ffd2e712595d..d90132642340 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c | |||
@@ -2553,9 +2553,8 @@ static int nfs41_check_open_stateid(struct nfs4_state *state) | |||
2553 | clear_bit(NFS_O_RDWR_STATE, &state->flags); | 2553 | clear_bit(NFS_O_RDWR_STATE, &state->flags); |
2554 | clear_bit(NFS_OPEN_STATE, &state->flags); | 2554 | clear_bit(NFS_OPEN_STATE, &state->flags); |
2555 | stateid->type = NFS4_INVALID_STATEID_TYPE; | 2555 | stateid->type = NFS4_INVALID_STATEID_TYPE; |
2556 | } | ||
2557 | if (status != NFS_OK) | ||
2558 | return status; | 2556 | return status; |
2557 | } | ||
2559 | if (nfs_open_stateid_recover_openmode(state)) | 2558 | if (nfs_open_stateid_recover_openmode(state)) |
2560 | return -NFS4ERR_OPENMODE; | 2559 | return -NFS4ERR_OPENMODE; |
2561 | return NFS_OK; | 2560 | return NFS_OK; |
diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c index 8a428498d6b2..509a61668d90 100644 --- a/fs/proc/meminfo.c +++ b/fs/proc/meminfo.c | |||
@@ -106,13 +106,13 @@ static int meminfo_proc_show(struct seq_file *m, void *v) | |||
106 | global_node_page_state(NR_FILE_MAPPED)); | 106 | global_node_page_state(NR_FILE_MAPPED)); |
107 | show_val_kb(m, "Shmem: ", i.sharedram); | 107 | show_val_kb(m, "Shmem: ", i.sharedram); |
108 | show_val_kb(m, "Slab: ", | 108 | show_val_kb(m, "Slab: ", |
109 | global_page_state(NR_SLAB_RECLAIMABLE) + | 109 | global_node_page_state(NR_SLAB_RECLAIMABLE) + |
110 | global_page_state(NR_SLAB_UNRECLAIMABLE)); | 110 | global_node_page_state(NR_SLAB_UNRECLAIMABLE)); |
111 | 111 | ||
112 | show_val_kb(m, "SReclaimable: ", | 112 | show_val_kb(m, "SReclaimable: ", |
113 | global_page_state(NR_SLAB_RECLAIMABLE)); | 113 | global_node_page_state(NR_SLAB_RECLAIMABLE)); |
114 | show_val_kb(m, "SUnreclaim: ", | 114 | show_val_kb(m, "SUnreclaim: ", |
115 | global_page_state(NR_SLAB_UNRECLAIMABLE)); | 115 | global_node_page_state(NR_SLAB_UNRECLAIMABLE)); |
116 | seq_printf(m, "KernelStack: %8lu kB\n", | 116 | seq_printf(m, "KernelStack: %8lu kB\n", |
117 | global_page_state(NR_KERNEL_STACK_KB)); | 117 | global_page_state(NR_KERNEL_STACK_KB)); |
118 | show_val_kb(m, "PageTables: ", | 118 | show_val_kb(m, "PageTables: ", |
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index b836fd61ed87..fe8f3265e877 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c | |||
@@ -16,9 +16,10 @@ | |||
16 | #include <linux/mmu_notifier.h> | 16 | #include <linux/mmu_notifier.h> |
17 | #include <linux/page_idle.h> | 17 | #include <linux/page_idle.h> |
18 | #include <linux/shmem_fs.h> | 18 | #include <linux/shmem_fs.h> |
19 | #include <linux/uaccess.h> | ||
19 | 20 | ||
20 | #include <asm/elf.h> | 21 | #include <asm/elf.h> |
21 | #include <linux/uaccess.h> | 22 | #include <asm/tlb.h> |
22 | #include <asm/tlbflush.h> | 23 | #include <asm/tlbflush.h> |
23 | #include "internal.h" | 24 | #include "internal.h" |
24 | 25 | ||
@@ -1008,6 +1009,7 @@ static ssize_t clear_refs_write(struct file *file, const char __user *buf, | |||
1008 | struct mm_struct *mm; | 1009 | struct mm_struct *mm; |
1009 | struct vm_area_struct *vma; | 1010 | struct vm_area_struct *vma; |
1010 | enum clear_refs_types type; | 1011 | enum clear_refs_types type; |
1012 | struct mmu_gather tlb; | ||
1011 | int itype; | 1013 | int itype; |
1012 | int rv; | 1014 | int rv; |
1013 | 1015 | ||
@@ -1054,6 +1056,7 @@ static ssize_t clear_refs_write(struct file *file, const char __user *buf, | |||
1054 | } | 1056 | } |
1055 | 1057 | ||
1056 | down_read(&mm->mmap_sem); | 1058 | down_read(&mm->mmap_sem); |
1059 | tlb_gather_mmu(&tlb, mm, 0, -1); | ||
1057 | if (type == CLEAR_REFS_SOFT_DIRTY) { | 1060 | if (type == CLEAR_REFS_SOFT_DIRTY) { |
1058 | for (vma = mm->mmap; vma; vma = vma->vm_next) { | 1061 | for (vma = mm->mmap; vma; vma = vma->vm_next) { |
1059 | if (!(vma->vm_flags & VM_SOFTDIRTY)) | 1062 | if (!(vma->vm_flags & VM_SOFTDIRTY)) |
@@ -1075,7 +1078,7 @@ static ssize_t clear_refs_write(struct file *file, const char __user *buf, | |||
1075 | walk_page_range(0, mm->highest_vm_end, &clear_refs_walk); | 1078 | walk_page_range(0, mm->highest_vm_end, &clear_refs_walk); |
1076 | if (type == CLEAR_REFS_SOFT_DIRTY) | 1079 | if (type == CLEAR_REFS_SOFT_DIRTY) |
1077 | mmu_notifier_invalidate_range_end(mm, 0, -1); | 1080 | mmu_notifier_invalidate_range_end(mm, 0, -1); |
1078 | flush_tlb_mm(mm); | 1081 | tlb_finish_mmu(&tlb, 0, -1); |
1079 | up_read(&mm->mmap_sem); | 1082 | up_read(&mm->mmap_sem); |
1080 | out_mm: | 1083 | out_mm: |
1081 | mmput(mm); | 1084 | mmput(mm); |
diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c index 53a17496c5c5..566e6ef99f07 100644 --- a/fs/quota/dquot.c +++ b/fs/quota/dquot.c | |||
@@ -1124,6 +1124,10 @@ void dquot_free_reserved_space(struct dquot *dquot, qsize_t number) | |||
1124 | WARN_ON_ONCE(1); | 1124 | WARN_ON_ONCE(1); |
1125 | dquot->dq_dqb.dqb_rsvspace = 0; | 1125 | dquot->dq_dqb.dqb_rsvspace = 0; |
1126 | } | 1126 | } |
1127 | if (dquot->dq_dqb.dqb_curspace + dquot->dq_dqb.dqb_rsvspace <= | ||
1128 | dquot->dq_dqb.dqb_bsoftlimit) | ||
1129 | dquot->dq_dqb.dqb_btime = (time64_t) 0; | ||
1130 | clear_bit(DQ_BLKS_B, &dquot->dq_flags); | ||
1127 | } | 1131 | } |
1128 | 1132 | ||
1129 | static void dquot_decr_inodes(struct dquot *dquot, qsize_t number) | 1133 | static void dquot_decr_inodes(struct dquot *dquot, qsize_t number) |
@@ -1145,7 +1149,8 @@ static void dquot_decr_space(struct dquot *dquot, qsize_t number) | |||
1145 | dquot->dq_dqb.dqb_curspace -= number; | 1149 | dquot->dq_dqb.dqb_curspace -= number; |
1146 | else | 1150 | else |
1147 | dquot->dq_dqb.dqb_curspace = 0; | 1151 | dquot->dq_dqb.dqb_curspace = 0; |
1148 | if (dquot->dq_dqb.dqb_curspace <= dquot->dq_dqb.dqb_bsoftlimit) | 1152 | if (dquot->dq_dqb.dqb_curspace + dquot->dq_dqb.dqb_rsvspace <= |
1153 | dquot->dq_dqb.dqb_bsoftlimit) | ||
1149 | dquot->dq_dqb.dqb_btime = (time64_t) 0; | 1154 | dquot->dq_dqb.dqb_btime = (time64_t) 0; |
1150 | clear_bit(DQ_BLKS_B, &dquot->dq_flags); | 1155 | clear_bit(DQ_BLKS_B, &dquot->dq_flags); |
1151 | } | 1156 | } |
@@ -1381,14 +1386,18 @@ static int info_idq_free(struct dquot *dquot, qsize_t inodes) | |||
1381 | 1386 | ||
1382 | static int info_bdq_free(struct dquot *dquot, qsize_t space) | 1387 | static int info_bdq_free(struct dquot *dquot, qsize_t space) |
1383 | { | 1388 | { |
1389 | qsize_t tspace; | ||
1390 | |||
1391 | tspace = dquot->dq_dqb.dqb_curspace + dquot->dq_dqb.dqb_rsvspace; | ||
1392 | |||
1384 | if (test_bit(DQ_FAKE_B, &dquot->dq_flags) || | 1393 | if (test_bit(DQ_FAKE_B, &dquot->dq_flags) || |
1385 | dquot->dq_dqb.dqb_curspace <= dquot->dq_dqb.dqb_bsoftlimit) | 1394 | tspace <= dquot->dq_dqb.dqb_bsoftlimit) |
1386 | return QUOTA_NL_NOWARN; | 1395 | return QUOTA_NL_NOWARN; |
1387 | 1396 | ||
1388 | if (dquot->dq_dqb.dqb_curspace - space <= dquot->dq_dqb.dqb_bsoftlimit) | 1397 | if (tspace - space <= dquot->dq_dqb.dqb_bsoftlimit) |
1389 | return QUOTA_NL_BSOFTBELOW; | 1398 | return QUOTA_NL_BSOFTBELOW; |
1390 | if (dquot->dq_dqb.dqb_curspace >= dquot->dq_dqb.dqb_bhardlimit && | 1399 | if (tspace >= dquot->dq_dqb.dqb_bhardlimit && |
1391 | dquot->dq_dqb.dqb_curspace - space < dquot->dq_dqb.dqb_bhardlimit) | 1400 | tspace - space < dquot->dq_dqb.dqb_bhardlimit) |
1392 | return QUOTA_NL_BHARDBELOW; | 1401 | return QUOTA_NL_BHARDBELOW; |
1393 | return QUOTA_NL_NOWARN; | 1402 | return QUOTA_NL_NOWARN; |
1394 | } | 1403 | } |
@@ -2681,7 +2690,7 @@ static int do_set_dqblk(struct dquot *dquot, struct qc_dqblk *di) | |||
2681 | 2690 | ||
2682 | if (check_blim) { | 2691 | if (check_blim) { |
2683 | if (!dm->dqb_bsoftlimit || | 2692 | if (!dm->dqb_bsoftlimit || |
2684 | dm->dqb_curspace < dm->dqb_bsoftlimit) { | 2693 | dm->dqb_curspace + dm->dqb_rsvspace < dm->dqb_bsoftlimit) { |
2685 | dm->dqb_btime = 0; | 2694 | dm->dqb_btime = 0; |
2686 | clear_bit(DQ_BLKS_B, &dquot->dq_flags); | 2695 | clear_bit(DQ_BLKS_B, &dquot->dq_flags); |
2687 | } else if (!(di->d_fieldmask & QC_SPC_TIMER)) | 2696 | } else if (!(di->d_fieldmask & QC_SPC_TIMER)) |
diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c index 06ea26b8c996..b0d5897bc4e6 100644 --- a/fs/userfaultfd.c +++ b/fs/userfaultfd.c | |||
@@ -1600,7 +1600,7 @@ static int userfaultfd_copy(struct userfaultfd_ctx *ctx, | |||
1600 | uffdio_copy.len); | 1600 | uffdio_copy.len); |
1601 | mmput(ctx->mm); | 1601 | mmput(ctx->mm); |
1602 | } else { | 1602 | } else { |
1603 | return -ENOSPC; | 1603 | return -ESRCH; |
1604 | } | 1604 | } |
1605 | if (unlikely(put_user(ret, &user_uffdio_copy->copy))) | 1605 | if (unlikely(put_user(ret, &user_uffdio_copy->copy))) |
1606 | return -EFAULT; | 1606 | return -EFAULT; |
@@ -1647,7 +1647,7 @@ static int userfaultfd_zeropage(struct userfaultfd_ctx *ctx, | |||
1647 | uffdio_zeropage.range.len); | 1647 | uffdio_zeropage.range.len); |
1648 | mmput(ctx->mm); | 1648 | mmput(ctx->mm); |
1649 | } else { | 1649 | } else { |
1650 | return -ENOSPC; | 1650 | return -ESRCH; |
1651 | } | 1651 | } |
1652 | if (unlikely(put_user(ret, &user_uffdio_zeropage->zeropage))) | 1652 | if (unlikely(put_user(ret, &user_uffdio_zeropage->zeropage))) |
1653 | return -EFAULT; | 1653 | return -EFAULT; |
diff --git a/fs/xfs/libxfs/xfs_ialloc.c b/fs/xfs/libxfs/xfs_ialloc.c index ffd5a15d1bb6..abf5beaae907 100644 --- a/fs/xfs/libxfs/xfs_ialloc.c +++ b/fs/xfs/libxfs/xfs_ialloc.c | |||
@@ -1246,13 +1246,13 @@ xfs_dialloc_ag_inobt( | |||
1246 | 1246 | ||
1247 | /* free inodes to the left? */ | 1247 | /* free inodes to the left? */ |
1248 | if (useleft && trec.ir_freecount) { | 1248 | if (useleft && trec.ir_freecount) { |
1249 | rec = trec; | ||
1250 | xfs_btree_del_cursor(cur, XFS_BTREE_NOERROR); | 1249 | xfs_btree_del_cursor(cur, XFS_BTREE_NOERROR); |
1251 | cur = tcur; | 1250 | cur = tcur; |
1252 | 1251 | ||
1253 | pag->pagl_leftrec = trec.ir_startino; | 1252 | pag->pagl_leftrec = trec.ir_startino; |
1254 | pag->pagl_rightrec = rec.ir_startino; | 1253 | pag->pagl_rightrec = rec.ir_startino; |
1255 | pag->pagl_pagino = pagino; | 1254 | pag->pagl_pagino = pagino; |
1255 | rec = trec; | ||
1256 | goto alloc_inode; | 1256 | goto alloc_inode; |
1257 | } | 1257 | } |
1258 | 1258 | ||
diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index 0053bcf2b10a..4ebd0bafc914 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c | |||
@@ -749,9 +749,20 @@ xfs_log_mount_finish( | |||
749 | return 0; | 749 | return 0; |
750 | } | 750 | } |
751 | 751 | ||
752 | /* | ||
753 | * During the second phase of log recovery, we need iget and | ||
754 | * iput to behave like they do for an active filesystem. | ||
755 | * xfs_fs_drop_inode needs to be able to prevent the deletion | ||
756 | * of inodes before we're done replaying log items on those | ||
757 | * inodes. Turn it off immediately after recovery finishes | ||
758 | * so that we don't leak the quota inodes if subsequent mount | ||
759 | * activities fail. | ||
760 | */ | ||
761 | mp->m_super->s_flags |= MS_ACTIVE; | ||
752 | error = xlog_recover_finish(mp->m_log); | 762 | error = xlog_recover_finish(mp->m_log); |
753 | if (!error) | 763 | if (!error) |
754 | xfs_log_work_queue(mp); | 764 | xfs_log_work_queue(mp); |
765 | mp->m_super->s_flags &= ~MS_ACTIVE; | ||
755 | 766 | ||
756 | return error; | 767 | return error; |
757 | } | 768 | } |
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c index 40d4e8b4e193..ea7d4b4e50d0 100644 --- a/fs/xfs/xfs_mount.c +++ b/fs/xfs/xfs_mount.c | |||
@@ -945,15 +945,6 @@ xfs_mountfs( | |||
945 | } | 945 | } |
946 | 946 | ||
947 | /* | 947 | /* |
948 | * During the second phase of log recovery, we need iget and | ||
949 | * iput to behave like they do for an active filesystem. | ||
950 | * xfs_fs_drop_inode needs to be able to prevent the deletion | ||
951 | * of inodes before we're done replaying log items on those | ||
952 | * inodes. | ||
953 | */ | ||
954 | mp->m_super->s_flags |= MS_ACTIVE; | ||
955 | |||
956 | /* | ||
957 | * Finish recovering the file system. This part needed to be delayed | 948 | * Finish recovering the file system. This part needed to be delayed |
958 | * until after the root and real-time bitmap inodes were consistently | 949 | * until after the root and real-time bitmap inodes were consistently |
959 | * read in. | 950 | * read in. |
@@ -1028,12 +1019,13 @@ xfs_mountfs( | |||
1028 | out_quota: | 1019 | out_quota: |
1029 | xfs_qm_unmount_quotas(mp); | 1020 | xfs_qm_unmount_quotas(mp); |
1030 | out_rtunmount: | 1021 | out_rtunmount: |
1031 | mp->m_super->s_flags &= ~MS_ACTIVE; | ||
1032 | xfs_rtunmount_inodes(mp); | 1022 | xfs_rtunmount_inodes(mp); |
1033 | out_rele_rip: | 1023 | out_rele_rip: |
1034 | IRELE(rip); | 1024 | IRELE(rip); |
1035 | cancel_delayed_work_sync(&mp->m_reclaim_work); | 1025 | cancel_delayed_work_sync(&mp->m_reclaim_work); |
1036 | xfs_reclaim_inodes(mp, SYNC_WAIT); | 1026 | xfs_reclaim_inodes(mp, SYNC_WAIT); |
1027 | /* Clean out dquots that might be in memory after quotacheck. */ | ||
1028 | xfs_qm_unmount(mp); | ||
1037 | out_log_dealloc: | 1029 | out_log_dealloc: |
1038 | mp->m_flags |= XFS_MOUNT_UNMOUNTING; | 1030 | mp->m_flags |= XFS_MOUNT_UNMOUNTING; |
1039 | xfs_log_mount_cancel(mp); | 1031 | xfs_log_mount_cancel(mp); |
diff --git a/include/asm-generic/early_ioremap.h b/include/asm-generic/early_ioremap.h index 734ad4db388c..2edef8d7fa6b 100644 --- a/include/asm-generic/early_ioremap.h +++ b/include/asm-generic/early_ioremap.h | |||
@@ -13,6 +13,8 @@ extern void *early_memremap(resource_size_t phys_addr, | |||
13 | unsigned long size); | 13 | unsigned long size); |
14 | extern void *early_memremap_ro(resource_size_t phys_addr, | 14 | extern void *early_memremap_ro(resource_size_t phys_addr, |
15 | unsigned long size); | 15 | unsigned long size); |
16 | extern void *early_memremap_prot(resource_size_t phys_addr, | ||
17 | unsigned long size, unsigned long prot_val); | ||
16 | extern void early_iounmap(void __iomem *addr, unsigned long size); | 18 | extern void early_iounmap(void __iomem *addr, unsigned long size); |
17 | extern void early_memunmap(void *addr, unsigned long size); | 19 | extern void early_memunmap(void *addr, unsigned long size); |
18 | 20 | ||
diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h index 7dfa767dc680..4d7bb98f4134 100644 --- a/include/asm-generic/pgtable.h +++ b/include/asm-generic/pgtable.h | |||
@@ -583,6 +583,18 @@ static inline void ptep_modify_prot_commit(struct mm_struct *mm, | |||
583 | #endif /* CONFIG_MMU */ | 583 | #endif /* CONFIG_MMU */ |
584 | 584 | ||
585 | /* | 585 | /* |
586 | * No-op macros that just return the current protection value. Defined here | ||
587 | * because these macros can be used used even if CONFIG_MMU is not defined. | ||
588 | */ | ||
589 | #ifndef pgprot_encrypted | ||
590 | #define pgprot_encrypted(prot) (prot) | ||
591 | #endif | ||
592 | |||
593 | #ifndef pgprot_decrypted | ||
594 | #define pgprot_decrypted(prot) (prot) | ||
595 | #endif | ||
596 | |||
597 | /* | ||
586 | * A facility to provide lazy MMU batching. This allows PTE updates and | 598 | * A facility to provide lazy MMU batching. This allows PTE updates and |
587 | * page invalidations to be delayed until a call to leave lazy MMU mode | 599 | * page invalidations to be delayed until a call to leave lazy MMU mode |
588 | * is issued. Some architectures may benefit from doing this, and it is | 600 | * is issued. Some architectures may benefit from doing this, and it is |
diff --git a/include/asm-generic/tlb.h b/include/asm-generic/tlb.h index 8afa4335e5b2..faddde44de8c 100644 --- a/include/asm-generic/tlb.h +++ b/include/asm-generic/tlb.h | |||
@@ -112,10 +112,11 @@ struct mmu_gather { | |||
112 | 112 | ||
113 | #define HAVE_GENERIC_MMU_GATHER | 113 | #define HAVE_GENERIC_MMU_GATHER |
114 | 114 | ||
115 | void tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, unsigned long start, unsigned long end); | 115 | void arch_tlb_gather_mmu(struct mmu_gather *tlb, |
116 | struct mm_struct *mm, unsigned long start, unsigned long end); | ||
116 | void tlb_flush_mmu(struct mmu_gather *tlb); | 117 | void tlb_flush_mmu(struct mmu_gather *tlb); |
117 | void tlb_finish_mmu(struct mmu_gather *tlb, unsigned long start, | 118 | void arch_tlb_finish_mmu(struct mmu_gather *tlb, |
118 | unsigned long end); | 119 | unsigned long start, unsigned long end, bool force); |
119 | extern bool __tlb_remove_page_size(struct mmu_gather *tlb, struct page *page, | 120 | extern bool __tlb_remove_page_size(struct mmu_gather *tlb, struct page *page, |
120 | int page_size); | 121 | int page_size); |
121 | 122 | ||
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h index da0be9a8d1de..9623d78f8494 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h | |||
@@ -60,6 +60,22 @@ | |||
60 | #define ALIGN_FUNCTION() . = ALIGN(8) | 60 | #define ALIGN_FUNCTION() . = ALIGN(8) |
61 | 61 | ||
62 | /* | 62 | /* |
63 | * LD_DEAD_CODE_DATA_ELIMINATION option enables -fdata-sections, which | ||
64 | * generates .data.identifier sections, which need to be pulled in with | ||
65 | * .data. We don't want to pull in .data..other sections, which Linux | ||
66 | * has defined. Same for text and bss. | ||
67 | */ | ||
68 | #ifdef CONFIG_LD_DEAD_CODE_DATA_ELIMINATION | ||
69 | #define TEXT_MAIN .text .text.[0-9a-zA-Z_]* | ||
70 | #define DATA_MAIN .data .data.[0-9a-zA-Z_]* | ||
71 | #define BSS_MAIN .bss .bss.[0-9a-zA-Z_]* | ||
72 | #else | ||
73 | #define TEXT_MAIN .text | ||
74 | #define DATA_MAIN .data | ||
75 | #define BSS_MAIN .bss | ||
76 | #endif | ||
77 | |||
78 | /* | ||
63 | * Align to a 32 byte boundary equal to the | 79 | * Align to a 32 byte boundary equal to the |
64 | * alignment gcc 4.5 uses for a struct | 80 | * alignment gcc 4.5 uses for a struct |
65 | */ | 81 | */ |
@@ -198,12 +214,9 @@ | |||
198 | 214 | ||
199 | /* | 215 | /* |
200 | * .data section | 216 | * .data section |
201 | * LD_DEAD_CODE_DATA_ELIMINATION option enables -fdata-sections generates | ||
202 | * .data.identifier which needs to be pulled in with .data, but don't want to | ||
203 | * pull in .data..stuff which has its own requirements. Same for bss. | ||
204 | */ | 217 | */ |
205 | #define DATA_DATA \ | 218 | #define DATA_DATA \ |
206 | *(.data .data.[0-9a-zA-Z_]*) \ | 219 | *(DATA_MAIN) \ |
207 | *(.ref.data) \ | 220 | *(.ref.data) \ |
208 | *(.data..shared_aligned) /* percpu related */ \ | 221 | *(.data..shared_aligned) /* percpu related */ \ |
209 | MEM_KEEP(init.data) \ | 222 | MEM_KEEP(init.data) \ |
@@ -434,16 +447,17 @@ | |||
434 | VMLINUX_SYMBOL(__security_initcall_end) = .; \ | 447 | VMLINUX_SYMBOL(__security_initcall_end) = .; \ |
435 | } | 448 | } |
436 | 449 | ||
437 | /* .text section. Map to function alignment to avoid address changes | 450 | /* |
451 | * .text section. Map to function alignment to avoid address changes | ||
438 | * during second ld run in second ld pass when generating System.map | 452 | * during second ld run in second ld pass when generating System.map |
439 | * LD_DEAD_CODE_DATA_ELIMINATION option enables -ffunction-sections generates | 453 | * |
440 | * .text.identifier which needs to be pulled in with .text , but some | 454 | * TEXT_MAIN here will match .text.fixup and .text.unlikely if dead |
441 | * architectures define .text.foo which is not intended to be pulled in here. | 455 | * code elimination is enabled, so these sections should be converted |
442 | * Those enabling LD_DEAD_CODE_DATA_ELIMINATION must ensure they don't have | 456 | * to use ".." first. |
443 | * conflicting section names, and must pull in .text.[0-9a-zA-Z_]* */ | 457 | */ |
444 | #define TEXT_TEXT \ | 458 | #define TEXT_TEXT \ |
445 | ALIGN_FUNCTION(); \ | 459 | ALIGN_FUNCTION(); \ |
446 | *(.text.hot .text .text.fixup .text.unlikely) \ | 460 | *(.text.hot TEXT_MAIN .text.fixup .text.unlikely) \ |
447 | *(.ref.text) \ | 461 | *(.ref.text) \ |
448 | MEM_KEEP(init.text) \ | 462 | MEM_KEEP(init.text) \ |
449 | MEM_KEEP(exit.text) \ | 463 | MEM_KEEP(exit.text) \ |
@@ -613,7 +627,7 @@ | |||
613 | BSS_FIRST_SECTIONS \ | 627 | BSS_FIRST_SECTIONS \ |
614 | *(.bss..page_aligned) \ | 628 | *(.bss..page_aligned) \ |
615 | *(.dynbss) \ | 629 | *(.dynbss) \ |
616 | *(.bss .bss.[0-9a-zA-Z_]*) \ | 630 | *(BSS_MAIN) \ |
617 | *(COMMON) \ | 631 | *(COMMON) \ |
618 | } | 632 | } |
619 | 633 | ||
diff --git a/include/linux/acpi.h b/include/linux/acpi.h index c749eef1daa1..27b4b6615263 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h | |||
@@ -1209,6 +1209,7 @@ static inline bool acpi_has_watchdog(void) { return false; } | |||
1209 | #endif | 1209 | #endif |
1210 | 1210 | ||
1211 | #ifdef CONFIG_ACPI_SPCR_TABLE | 1211 | #ifdef CONFIG_ACPI_SPCR_TABLE |
1212 | extern bool qdf2400_e44_present; | ||
1212 | int parse_spcr(bool earlycon); | 1213 | int parse_spcr(bool earlycon); |
1213 | #else | 1214 | #else |
1214 | static inline int parse_spcr(bool earlycon) { return 0; } | 1215 | static inline int parse_spcr(bool earlycon) { return 0; } |
diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h index bdb80c4aef6e..71b86a5d3061 100644 --- a/include/linux/compiler-gcc.h +++ b/include/linux/compiler-gcc.h | |||
@@ -166,6 +166,8 @@ | |||
166 | 166 | ||
167 | #if GCC_VERSION >= 40100 | 167 | #if GCC_VERSION >= 40100 |
168 | # define __compiletime_object_size(obj) __builtin_object_size(obj, 0) | 168 | # define __compiletime_object_size(obj) __builtin_object_size(obj, 0) |
169 | |||
170 | #define __nostackprotector __attribute__((__optimize__("no-stack-protector"))) | ||
169 | #endif | 171 | #endif |
170 | 172 | ||
171 | #if GCC_VERSION >= 40300 | 173 | #if GCC_VERSION >= 40300 |
diff --git a/include/linux/compiler.h b/include/linux/compiler.h index eca8ad75e28b..43cac547f773 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h | |||
@@ -475,6 +475,10 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s | |||
475 | #define __visible | 475 | #define __visible |
476 | #endif | 476 | #endif |
477 | 477 | ||
478 | #ifndef __nostackprotector | ||
479 | # define __nostackprotector | ||
480 | #endif | ||
481 | |||
478 | /* | 482 | /* |
479 | * Assume alignment of return value. | 483 | * Assume alignment of return value. |
480 | */ | 484 | */ |
diff --git a/include/linux/devpts_fs.h b/include/linux/devpts_fs.h index 277ab9af9ac2..100cb4343763 100644 --- a/include/linux/devpts_fs.h +++ b/include/linux/devpts_fs.h | |||
@@ -19,6 +19,7 @@ | |||
19 | 19 | ||
20 | struct pts_fs_info; | 20 | struct pts_fs_info; |
21 | 21 | ||
22 | struct vfsmount *devpts_mntget(struct file *, struct pts_fs_info *); | ||
22 | struct pts_fs_info *devpts_acquire(struct file *); | 23 | struct pts_fs_info *devpts_acquire(struct file *); |
23 | void devpts_release(struct pts_fs_info *); | 24 | void devpts_release(struct pts_fs_info *); |
24 | 25 | ||
@@ -32,6 +33,15 @@ void *devpts_get_priv(struct dentry *); | |||
32 | /* unlink */ | 33 | /* unlink */ |
33 | void devpts_pty_kill(struct dentry *); | 34 | void devpts_pty_kill(struct dentry *); |
34 | 35 | ||
36 | /* in pty.c */ | ||
37 | int ptm_open_peer(struct file *master, struct tty_struct *tty, int flags); | ||
38 | |||
39 | #else | ||
40 | static inline int | ||
41 | ptm_open_peer(struct file *master, struct tty_struct *tty, int flags) | ||
42 | { | ||
43 | return -EIO; | ||
44 | } | ||
35 | #endif | 45 | #endif |
36 | 46 | ||
37 | 47 | ||
diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h index 03c0196a6f24..2189c79cde5d 100644 --- a/include/linux/dma-mapping.h +++ b/include/linux/dma-mapping.h | |||
@@ -10,6 +10,7 @@ | |||
10 | #include <linux/scatterlist.h> | 10 | #include <linux/scatterlist.h> |
11 | #include <linux/kmemcheck.h> | 11 | #include <linux/kmemcheck.h> |
12 | #include <linux/bug.h> | 12 | #include <linux/bug.h> |
13 | #include <linux/mem_encrypt.h> | ||
13 | 14 | ||
14 | /** | 15 | /** |
15 | * List of possible attributes associated with a DMA mapping. The semantics | 16 | * List of possible attributes associated with a DMA mapping. The semantics |
@@ -572,6 +573,12 @@ static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr) | |||
572 | return 0; | 573 | return 0; |
573 | } | 574 | } |
574 | 575 | ||
576 | static inline void dma_check_mask(struct device *dev, u64 mask) | ||
577 | { | ||
578 | if (sme_active() && (mask < (((u64)sme_get_me_mask() << 1) - 1))) | ||
579 | dev_warn(dev, "SME is active, device will require DMA bounce buffers\n"); | ||
580 | } | ||
581 | |||
575 | static inline int dma_supported(struct device *dev, u64 mask) | 582 | static inline int dma_supported(struct device *dev, u64 mask) |
576 | { | 583 | { |
577 | const struct dma_map_ops *ops = get_dma_ops(dev); | 584 | const struct dma_map_ops *ops = get_dma_ops(dev); |
@@ -588,6 +595,9 @@ static inline int dma_set_mask(struct device *dev, u64 mask) | |||
588 | { | 595 | { |
589 | if (!dev->dma_mask || !dma_supported(dev, mask)) | 596 | if (!dev->dma_mask || !dma_supported(dev, mask)) |
590 | return -EIO; | 597 | return -EIO; |
598 | |||
599 | dma_check_mask(dev, mask); | ||
600 | |||
591 | *dev->dma_mask = mask; | 601 | *dev->dma_mask = mask; |
592 | return 0; | 602 | return 0; |
593 | } | 603 | } |
@@ -607,6 +617,9 @@ static inline int dma_set_coherent_mask(struct device *dev, u64 mask) | |||
607 | { | 617 | { |
608 | if (!dma_supported(dev, mask)) | 618 | if (!dma_supported(dev, mask)) |
609 | return -EIO; | 619 | return -EIO; |
620 | |||
621 | dma_check_mask(dev, mask); | ||
622 | |||
610 | dev->coherent_dma_mask = mask; | 623 | dev->coherent_dma_mask = mask; |
611 | return 0; | 624 | return 0; |
612 | } | 625 | } |
diff --git a/include/linux/efi.h b/include/linux/efi.h index 8269bcb8ccf7..4e47f78430be 100644 --- a/include/linux/efi.h +++ b/include/linux/efi.h | |||
@@ -985,7 +985,7 @@ static inline void efi_esrt_init(void) { } | |||
985 | extern int efi_config_parse_tables(void *config_tables, int count, int sz, | 985 | extern int efi_config_parse_tables(void *config_tables, int count, int sz, |
986 | efi_config_table_type_t *arch_tables); | 986 | efi_config_table_type_t *arch_tables); |
987 | extern u64 efi_get_iobase (void); | 987 | extern u64 efi_get_iobase (void); |
988 | extern u32 efi_mem_type (unsigned long phys_addr); | 988 | extern int efi_mem_type(unsigned long phys_addr); |
989 | extern u64 efi_mem_attributes (unsigned long phys_addr); | 989 | extern u64 efi_mem_attributes (unsigned long phys_addr); |
990 | extern u64 efi_mem_attribute (unsigned long phys_addr, unsigned long size); | 990 | extern u64 efi_mem_attribute (unsigned long phys_addr, unsigned long size); |
991 | extern int __init efi_uart_console_only (void); | 991 | extern int __init efi_uart_console_only (void); |
@@ -1091,6 +1091,8 @@ static inline bool efi_enabled(int feature) | |||
1091 | return test_bit(feature, &efi.flags) != 0; | 1091 | return test_bit(feature, &efi.flags) != 0; |
1092 | } | 1092 | } |
1093 | extern void efi_reboot(enum reboot_mode reboot_mode, const char *__unused); | 1093 | extern void efi_reboot(enum reboot_mode reboot_mode, const char *__unused); |
1094 | |||
1095 | extern bool efi_is_table_address(unsigned long phys_addr); | ||
1094 | #else | 1096 | #else |
1095 | static inline bool efi_enabled(int feature) | 1097 | static inline bool efi_enabled(int feature) |
1096 | { | 1098 | { |
@@ -1104,6 +1106,11 @@ efi_capsule_pending(int *reset_type) | |||
1104 | { | 1106 | { |
1105 | return false; | 1107 | return false; |
1106 | } | 1108 | } |
1109 | |||
1110 | static inline bool efi_is_table_address(unsigned long phys_addr) | ||
1111 | { | ||
1112 | return false; | ||
1113 | } | ||
1107 | #endif | 1114 | #endif |
1108 | 1115 | ||
1109 | extern int efi_status_to_err(efi_status_t status); | 1116 | extern int efi_status_to_err(efi_status_t status); |
diff --git a/include/linux/iio/common/st_sensors.h b/include/linux/iio/common/st_sensors.h index 497f2b3a5a62..97f1b465d04f 100644 --- a/include/linux/iio/common/st_sensors.h +++ b/include/linux/iio/common/st_sensors.h | |||
@@ -105,6 +105,11 @@ struct st_sensor_fullscale { | |||
105 | struct st_sensor_fullscale_avl fs_avl[ST_SENSORS_FULLSCALE_AVL_MAX]; | 105 | struct st_sensor_fullscale_avl fs_avl[ST_SENSORS_FULLSCALE_AVL_MAX]; |
106 | }; | 106 | }; |
107 | 107 | ||
108 | struct st_sensor_sim { | ||
109 | u8 addr; | ||
110 | u8 value; | ||
111 | }; | ||
112 | |||
108 | /** | 113 | /** |
109 | * struct st_sensor_bdu - ST sensor device block data update | 114 | * struct st_sensor_bdu - ST sensor device block data update |
110 | * @addr: address of the register. | 115 | * @addr: address of the register. |
@@ -197,6 +202,7 @@ struct st_sensor_transfer_function { | |||
197 | * @bdu: Block data update register. | 202 | * @bdu: Block data update register. |
198 | * @das: Data Alignment Selection register. | 203 | * @das: Data Alignment Selection register. |
199 | * @drdy_irq: Data ready register of the sensor. | 204 | * @drdy_irq: Data ready register of the sensor. |
205 | * @sim: SPI serial interface mode register of the sensor. | ||
200 | * @multi_read_bit: Use or not particular bit for [I2C/SPI] multi-read. | 206 | * @multi_read_bit: Use or not particular bit for [I2C/SPI] multi-read. |
201 | * @bootime: samples to discard when sensor passing from power-down to power-up. | 207 | * @bootime: samples to discard when sensor passing from power-down to power-up. |
202 | */ | 208 | */ |
@@ -213,6 +219,7 @@ struct st_sensor_settings { | |||
213 | struct st_sensor_bdu bdu; | 219 | struct st_sensor_bdu bdu; |
214 | struct st_sensor_das das; | 220 | struct st_sensor_das das; |
215 | struct st_sensor_data_ready_irq drdy_irq; | 221 | struct st_sensor_data_ready_irq drdy_irq; |
222 | struct st_sensor_sim sim; | ||
216 | bool multi_read_bit; | 223 | bool multi_read_bit; |
217 | unsigned int bootime; | 224 | unsigned int bootime; |
218 | }; | 225 | }; |
diff --git a/include/linux/io.h b/include/linux/io.h index 2195d9ea4aaa..32e30e8fb9db 100644 --- a/include/linux/io.h +++ b/include/linux/io.h | |||
@@ -157,6 +157,8 @@ enum { | |||
157 | MEMREMAP_WB = 1 << 0, | 157 | MEMREMAP_WB = 1 << 0, |
158 | MEMREMAP_WT = 1 << 1, | 158 | MEMREMAP_WT = 1 << 1, |
159 | MEMREMAP_WC = 1 << 2, | 159 | MEMREMAP_WC = 1 << 2, |
160 | MEMREMAP_ENC = 1 << 3, | ||
161 | MEMREMAP_DEC = 1 << 4, | ||
160 | }; | 162 | }; |
161 | 163 | ||
162 | void *memremap(resource_size_t offset, size_t size, unsigned long flags); | 164 | void *memremap(resource_size_t offset, size_t size, unsigned long flags); |
diff --git a/include/linux/kexec.h b/include/linux/kexec.h index dd056fab9e35..2b7590f5483a 100644 --- a/include/linux/kexec.h +++ b/include/linux/kexec.h | |||
@@ -327,6 +327,14 @@ static inline void *boot_phys_to_virt(unsigned long entry) | |||
327 | return phys_to_virt(boot_phys_to_phys(entry)); | 327 | return phys_to_virt(boot_phys_to_phys(entry)); |
328 | } | 328 | } |
329 | 329 | ||
330 | #ifndef arch_kexec_post_alloc_pages | ||
331 | static inline int arch_kexec_post_alloc_pages(void *vaddr, unsigned int pages, gfp_t gfp) { return 0; } | ||
332 | #endif | ||
333 | |||
334 | #ifndef arch_kexec_pre_free_pages | ||
335 | static inline void arch_kexec_pre_free_pages(void *vaddr, unsigned int pages) { } | ||
336 | #endif | ||
337 | |||
330 | #else /* !CONFIG_KEXEC_CORE */ | 338 | #else /* !CONFIG_KEXEC_CORE */ |
331 | struct pt_regs; | 339 | struct pt_regs; |
332 | struct task_struct; | 340 | struct task_struct; |
diff --git a/include/linux/mem_encrypt.h b/include/linux/mem_encrypt.h new file mode 100644 index 000000000000..1255f09f5e42 --- /dev/null +++ b/include/linux/mem_encrypt.h | |||
@@ -0,0 +1,48 @@ | |||
1 | /* | ||
2 | * AMD Memory Encryption Support | ||
3 | * | ||
4 | * Copyright (C) 2016 Advanced Micro Devices, Inc. | ||
5 | * | ||
6 | * Author: Tom Lendacky <thomas.lendacky@amd.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License version 2 as | ||
10 | * published by the Free Software Foundation. | ||
11 | */ | ||
12 | |||
13 | #ifndef __MEM_ENCRYPT_H__ | ||
14 | #define __MEM_ENCRYPT_H__ | ||
15 | |||
16 | #ifndef __ASSEMBLY__ | ||
17 | |||
18 | #ifdef CONFIG_ARCH_HAS_MEM_ENCRYPT | ||
19 | |||
20 | #include <asm/mem_encrypt.h> | ||
21 | |||
22 | #else /* !CONFIG_ARCH_HAS_MEM_ENCRYPT */ | ||
23 | |||
24 | #define sme_me_mask 0UL | ||
25 | |||
26 | #endif /* CONFIG_ARCH_HAS_MEM_ENCRYPT */ | ||
27 | |||
28 | static inline bool sme_active(void) | ||
29 | { | ||
30 | return !!sme_me_mask; | ||
31 | } | ||
32 | |||
33 | static inline unsigned long sme_get_me_mask(void) | ||
34 | { | ||
35 | return sme_me_mask; | ||
36 | } | ||
37 | |||
38 | /* | ||
39 | * The __sme_set() and __sme_clr() macros are useful for adding or removing | ||
40 | * the encryption mask from a value (e.g. when dealing with pagetable | ||
41 | * entries). | ||
42 | */ | ||
43 | #define __sme_set(x) ((unsigned long)(x) | sme_me_mask) | ||
44 | #define __sme_clr(x) ((unsigned long)(x) & ~sme_me_mask) | ||
45 | |||
46 | #endif /* __ASSEMBLY__ */ | ||
47 | |||
48 | #endif /* __MEM_ENCRYPT_H__ */ | ||
diff --git a/include/linux/memblock.h b/include/linux/memblock.h index 77d427974f57..bae11c7e7bf3 100644 --- a/include/linux/memblock.h +++ b/include/linux/memblock.h | |||
@@ -61,6 +61,7 @@ extern int memblock_debug; | |||
61 | #ifdef CONFIG_ARCH_DISCARD_MEMBLOCK | 61 | #ifdef CONFIG_ARCH_DISCARD_MEMBLOCK |
62 | #define __init_memblock __meminit | 62 | #define __init_memblock __meminit |
63 | #define __initdata_memblock __meminitdata | 63 | #define __initdata_memblock __meminitdata |
64 | void memblock_discard(void); | ||
64 | #else | 65 | #else |
65 | #define __init_memblock | 66 | #define __init_memblock |
66 | #define __initdata_memblock | 67 | #define __initdata_memblock |
@@ -74,8 +75,6 @@ phys_addr_t memblock_find_in_range_node(phys_addr_t size, phys_addr_t align, | |||
74 | int nid, ulong flags); | 75 | int nid, ulong flags); |
75 | phys_addr_t memblock_find_in_range(phys_addr_t start, phys_addr_t end, | 76 | phys_addr_t memblock_find_in_range(phys_addr_t start, phys_addr_t end, |
76 | phys_addr_t size, phys_addr_t align); | 77 | phys_addr_t size, phys_addr_t align); |
77 | phys_addr_t get_allocated_memblock_reserved_regions_info(phys_addr_t *addr); | ||
78 | phys_addr_t get_allocated_memblock_memory_regions_info(phys_addr_t *addr); | ||
79 | void memblock_allow_resize(void); | 78 | void memblock_allow_resize(void); |
80 | int memblock_add_node(phys_addr_t base, phys_addr_t size, int nid); | 79 | int memblock_add_node(phys_addr_t base, phys_addr_t size, int nid); |
81 | int memblock_add(phys_addr_t base, phys_addr_t size); | 80 | int memblock_add(phys_addr_t base, phys_addr_t size); |
@@ -110,6 +109,9 @@ void __next_mem_range_rev(u64 *idx, int nid, ulong flags, | |||
110 | void __next_reserved_mem_region(u64 *idx, phys_addr_t *out_start, | 109 | void __next_reserved_mem_region(u64 *idx, phys_addr_t *out_start, |
111 | phys_addr_t *out_end); | 110 | phys_addr_t *out_end); |
112 | 111 | ||
112 | void __memblock_free_early(phys_addr_t base, phys_addr_t size); | ||
113 | void __memblock_free_late(phys_addr_t base, phys_addr_t size); | ||
114 | |||
113 | /** | 115 | /** |
114 | * for_each_mem_range - iterate through memblock areas from type_a and not | 116 | * for_each_mem_range - iterate through memblock areas from type_a and not |
115 | * included in type_b. Or just type_a if type_b is NULL. | 117 | * included in type_b. Or just type_a if type_b is NULL. |
diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 3914e3dd6168..9b15a4bcfa77 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h | |||
@@ -484,7 +484,8 @@ bool mem_cgroup_oom_synchronize(bool wait); | |||
484 | extern int do_swap_account; | 484 | extern int do_swap_account; |
485 | #endif | 485 | #endif |
486 | 486 | ||
487 | void lock_page_memcg(struct page *page); | 487 | struct mem_cgroup *lock_page_memcg(struct page *page); |
488 | void __unlock_page_memcg(struct mem_cgroup *memcg); | ||
488 | void unlock_page_memcg(struct page *page); | 489 | void unlock_page_memcg(struct page *page); |
489 | 490 | ||
490 | static inline unsigned long memcg_page_state(struct mem_cgroup *memcg, | 491 | static inline unsigned long memcg_page_state(struct mem_cgroup *memcg, |
@@ -809,7 +810,12 @@ mem_cgroup_print_oom_info(struct mem_cgroup *memcg, struct task_struct *p) | |||
809 | { | 810 | { |
810 | } | 811 | } |
811 | 812 | ||
812 | static inline void lock_page_memcg(struct page *page) | 813 | static inline struct mem_cgroup *lock_page_memcg(struct page *page) |
814 | { | ||
815 | return NULL; | ||
816 | } | ||
817 | |||
818 | static inline void __unlock_page_memcg(struct mem_cgroup *memcg) | ||
813 | { | 819 | { |
814 | } | 820 | } |
815 | 821 | ||
diff --git a/include/linux/mm_inline.h b/include/linux/mm_inline.h index e030a68ead7e..25438b2b6f22 100644 --- a/include/linux/mm_inline.h +++ b/include/linux/mm_inline.h | |||
@@ -126,4 +126,10 @@ static __always_inline enum lru_list page_lru(struct page *page) | |||
126 | 126 | ||
127 | #define lru_to_page(head) (list_entry((head)->prev, struct page, lru)) | 127 | #define lru_to_page(head) (list_entry((head)->prev, struct page, lru)) |
128 | 128 | ||
129 | #ifdef arch_unmap_kpfn | ||
130 | extern void arch_unmap_kpfn(unsigned long pfn); | ||
131 | #else | ||
132 | static __always_inline void arch_unmap_kpfn(unsigned long pfn) { } | ||
133 | #endif | ||
134 | |||
129 | #endif | 135 | #endif |
diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h index 7f384bb62d8e..3cadee0a3508 100644 --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h | |||
@@ -487,14 +487,12 @@ struct mm_struct { | |||
487 | /* numa_scan_seq prevents two threads setting pte_numa */ | 487 | /* numa_scan_seq prevents two threads setting pte_numa */ |
488 | int numa_scan_seq; | 488 | int numa_scan_seq; |
489 | #endif | 489 | #endif |
490 | #if defined(CONFIG_NUMA_BALANCING) || defined(CONFIG_COMPACTION) | ||
491 | /* | 490 | /* |
492 | * An operation with batched TLB flushing is going on. Anything that | 491 | * An operation with batched TLB flushing is going on. Anything that |
493 | * can move process memory needs to flush the TLB when moving a | 492 | * can move process memory needs to flush the TLB when moving a |
494 | * PROT_NONE or PROT_NUMA mapped page. | 493 | * PROT_NONE or PROT_NUMA mapped page. |
495 | */ | 494 | */ |
496 | bool tlb_flush_pending; | 495 | atomic_t tlb_flush_pending; |
497 | #endif | ||
498 | #ifdef CONFIG_ARCH_WANT_BATCHED_UNMAP_TLB_FLUSH | 496 | #ifdef CONFIG_ARCH_WANT_BATCHED_UNMAP_TLB_FLUSH |
499 | /* See flush_tlb_batched_pending() */ | 497 | /* See flush_tlb_batched_pending() */ |
500 | bool tlb_flush_batched; | 498 | bool tlb_flush_batched; |
@@ -522,46 +520,60 @@ static inline cpumask_t *mm_cpumask(struct mm_struct *mm) | |||
522 | return mm->cpu_vm_mask_var; | 520 | return mm->cpu_vm_mask_var; |
523 | } | 521 | } |
524 | 522 | ||
525 | #if defined(CONFIG_NUMA_BALANCING) || defined(CONFIG_COMPACTION) | 523 | struct mmu_gather; |
524 | extern void tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, | ||
525 | unsigned long start, unsigned long end); | ||
526 | extern void tlb_finish_mmu(struct mmu_gather *tlb, | ||
527 | unsigned long start, unsigned long end); | ||
528 | |||
526 | /* | 529 | /* |
527 | * Memory barriers to keep this state in sync are graciously provided by | 530 | * Memory barriers to keep this state in sync are graciously provided by |
528 | * the page table locks, outside of which no page table modifications happen. | 531 | * the page table locks, outside of which no page table modifications happen. |
529 | * The barriers below prevent the compiler from re-ordering the instructions | 532 | * The barriers are used to ensure the order between tlb_flush_pending updates, |
530 | * around the memory barriers that are already present in the code. | 533 | * which happen while the lock is not taken, and the PTE updates, which happen |
534 | * while the lock is taken, are serialized. | ||
531 | */ | 535 | */ |
532 | static inline bool mm_tlb_flush_pending(struct mm_struct *mm) | 536 | static inline bool mm_tlb_flush_pending(struct mm_struct *mm) |
533 | { | 537 | { |
534 | barrier(); | 538 | return atomic_read(&mm->tlb_flush_pending) > 0; |
535 | return mm->tlb_flush_pending; | 539 | } |
540 | |||
541 | /* | ||
542 | * Returns true if there are two above TLB batching threads in parallel. | ||
543 | */ | ||
544 | static inline bool mm_tlb_flush_nested(struct mm_struct *mm) | ||
545 | { | ||
546 | return atomic_read(&mm->tlb_flush_pending) > 1; | ||
547 | } | ||
548 | |||
549 | static inline void init_tlb_flush_pending(struct mm_struct *mm) | ||
550 | { | ||
551 | atomic_set(&mm->tlb_flush_pending, 0); | ||
536 | } | 552 | } |
537 | static inline void set_tlb_flush_pending(struct mm_struct *mm) | 553 | |
554 | static inline void inc_tlb_flush_pending(struct mm_struct *mm) | ||
538 | { | 555 | { |
539 | mm->tlb_flush_pending = true; | 556 | atomic_inc(&mm->tlb_flush_pending); |
540 | 557 | ||
541 | /* | 558 | /* |
542 | * Guarantee that the tlb_flush_pending store does not leak into the | 559 | * Guarantee that the tlb_flush_pending increase does not leak into the |
543 | * critical section updating the page tables | 560 | * critical section updating the page tables |
544 | */ | 561 | */ |
545 | smp_mb__before_spinlock(); | 562 | smp_mb__before_spinlock(); |
546 | } | 563 | } |
564 | |||
547 | /* Clearing is done after a TLB flush, which also provides a barrier. */ | 565 | /* Clearing is done after a TLB flush, which also provides a barrier. */ |
548 | static inline void clear_tlb_flush_pending(struct mm_struct *mm) | 566 | static inline void dec_tlb_flush_pending(struct mm_struct *mm) |
549 | { | ||
550 | barrier(); | ||
551 | mm->tlb_flush_pending = false; | ||
552 | } | ||
553 | #else | ||
554 | static inline bool mm_tlb_flush_pending(struct mm_struct *mm) | ||
555 | { | ||
556 | return false; | ||
557 | } | ||
558 | static inline void set_tlb_flush_pending(struct mm_struct *mm) | ||
559 | { | ||
560 | } | ||
561 | static inline void clear_tlb_flush_pending(struct mm_struct *mm) | ||
562 | { | 567 | { |
568 | /* | ||
569 | * Guarantee that the tlb_flush_pending does not not leak into the | ||
570 | * critical section, since we must order the PTE change and changes to | ||
571 | * the pending TLB flush indication. We could have relied on TLB flush | ||
572 | * as a memory barrier, but this behavior is not clearly documented. | ||
573 | */ | ||
574 | smp_mb__before_atomic(); | ||
575 | atomic_dec(&mm->tlb_flush_pending); | ||
563 | } | 576 | } |
564 | #endif | ||
565 | 577 | ||
566 | struct vm_fault; | 578 | struct vm_fault; |
567 | 579 | ||
diff --git a/include/linux/net.h b/include/linux/net.h index dda2cc939a53..ebeb48c92005 100644 --- a/include/linux/net.h +++ b/include/linux/net.h | |||
@@ -37,7 +37,7 @@ struct net; | |||
37 | 37 | ||
38 | /* Historically, SOCKWQ_ASYNC_NOSPACE & SOCKWQ_ASYNC_WAITDATA were located | 38 | /* Historically, SOCKWQ_ASYNC_NOSPACE & SOCKWQ_ASYNC_WAITDATA were located |
39 | * in sock->flags, but moved into sk->sk_wq->flags to be RCU protected. | 39 | * in sock->flags, but moved into sk->sk_wq->flags to be RCU protected. |
40 | * Eventually all flags will be in sk->sk_wq_flags. | 40 | * Eventually all flags will be in sk->sk_wq->flags. |
41 | */ | 41 | */ |
42 | #define SOCKWQ_ASYNC_NOSPACE 0 | 42 | #define SOCKWQ_ASYNC_NOSPACE 0 |
43 | #define SOCKWQ_ASYNC_WAITDATA 1 | 43 | #define SOCKWQ_ASYNC_WAITDATA 1 |
diff --git a/include/linux/nmi.h b/include/linux/nmi.h index 8aa01fd859fb..a36abe2da13e 100644 --- a/include/linux/nmi.h +++ b/include/linux/nmi.h | |||
@@ -168,6 +168,14 @@ extern int sysctl_hardlockup_all_cpu_backtrace; | |||
168 | #define sysctl_softlockup_all_cpu_backtrace 0 | 168 | #define sysctl_softlockup_all_cpu_backtrace 0 |
169 | #define sysctl_hardlockup_all_cpu_backtrace 0 | 169 | #define sysctl_hardlockup_all_cpu_backtrace 0 |
170 | #endif | 170 | #endif |
171 | |||
172 | #if defined(CONFIG_HARDLOCKUP_CHECK_TIMESTAMP) && \ | ||
173 | defined(CONFIG_HARDLOCKUP_DETECTOR) | ||
174 | void watchdog_update_hrtimer_threshold(u64 period); | ||
175 | #else | ||
176 | static inline void watchdog_update_hrtimer_threshold(u64 period) { } | ||
177 | #endif | ||
178 | |||
171 | extern bool is_hardlockup(void); | 179 | extern bool is_hardlockup(void); |
172 | struct ctl_table; | 180 | struct ctl_table; |
173 | extern int proc_watchdog(struct ctl_table *, int , | 181 | extern int proc_watchdog(struct ctl_table *, int , |
diff --git a/include/linux/nvme-fc-driver.h b/include/linux/nvme-fc-driver.h index 6c8c5d8041b7..2591878c1d48 100644 --- a/include/linux/nvme-fc-driver.h +++ b/include/linux/nvme-fc-driver.h | |||
@@ -346,6 +346,11 @@ struct nvme_fc_remote_port { | |||
346 | * indicating an FC transport Aborted status. | 346 | * indicating an FC transport Aborted status. |
347 | * Entrypoint is Mandatory. | 347 | * Entrypoint is Mandatory. |
348 | * | 348 | * |
349 | * @defer_rcv: Called by the transport to signal the LLLD that it has | ||
350 | * begun processing of a previously received NVME CMD IU. The LLDD | ||
351 | * is now free to re-use the rcv buffer associated with the | ||
352 | * nvmefc_tgt_fcp_req. | ||
353 | * | ||
349 | * @max_hw_queues: indicates the maximum number of hw queues the LLDD | 354 | * @max_hw_queues: indicates the maximum number of hw queues the LLDD |
350 | * supports for cpu affinitization. | 355 | * supports for cpu affinitization. |
351 | * Value is Mandatory. Must be at least 1. | 356 | * Value is Mandatory. Must be at least 1. |
@@ -846,6 +851,8 @@ struct nvmet_fc_target_template { | |||
846 | struct nvmefc_tgt_fcp_req *fcpreq); | 851 | struct nvmefc_tgt_fcp_req *fcpreq); |
847 | void (*fcp_req_release)(struct nvmet_fc_target_port *tgtport, | 852 | void (*fcp_req_release)(struct nvmet_fc_target_port *tgtport, |
848 | struct nvmefc_tgt_fcp_req *fcpreq); | 853 | struct nvmefc_tgt_fcp_req *fcpreq); |
854 | void (*defer_rcv)(struct nvmet_fc_target_port *tgtport, | ||
855 | struct nvmefc_tgt_fcp_req *fcpreq); | ||
849 | 856 | ||
850 | u32 max_hw_queues; | 857 | u32 max_hw_queues; |
851 | u16 max_sgl_segments; | 858 | u16 max_sgl_segments; |
diff --git a/include/linux/oom.h b/include/linux/oom.h index 8a266e2be5a6..76aac4ce39bc 100644 --- a/include/linux/oom.h +++ b/include/linux/oom.h | |||
@@ -6,6 +6,8 @@ | |||
6 | #include <linux/types.h> | 6 | #include <linux/types.h> |
7 | #include <linux/nodemask.h> | 7 | #include <linux/nodemask.h> |
8 | #include <uapi/linux/oom.h> | 8 | #include <uapi/linux/oom.h> |
9 | #include <linux/sched/coredump.h> /* MMF_* */ | ||
10 | #include <linux/mm.h> /* VM_FAULT* */ | ||
9 | 11 | ||
10 | struct zonelist; | 12 | struct zonelist; |
11 | struct notifier_block; | 13 | struct notifier_block; |
@@ -63,6 +65,26 @@ static inline bool tsk_is_oom_victim(struct task_struct * tsk) | |||
63 | return tsk->signal->oom_mm; | 65 | return tsk->signal->oom_mm; |
64 | } | 66 | } |
65 | 67 | ||
68 | /* | ||
69 | * Checks whether a page fault on the given mm is still reliable. | ||
70 | * This is no longer true if the oom reaper started to reap the | ||
71 | * address space which is reflected by MMF_UNSTABLE flag set in | ||
72 | * the mm. At that moment any !shared mapping would lose the content | ||
73 | * and could cause a memory corruption (zero pages instead of the | ||
74 | * original content). | ||
75 | * | ||
76 | * User should call this before establishing a page table entry for | ||
77 | * a !shared mapping and under the proper page table lock. | ||
78 | * | ||
79 | * Return 0 when the PF is safe VM_FAULT_SIGBUS otherwise. | ||
80 | */ | ||
81 | static inline int check_stable_address_space(struct mm_struct *mm) | ||
82 | { | ||
83 | if (unlikely(test_bit(MMF_UNSTABLE, &mm->flags))) | ||
84 | return VM_FAULT_SIGBUS; | ||
85 | return 0; | ||
86 | } | ||
87 | |||
66 | extern unsigned long oom_badness(struct task_struct *p, | 88 | extern unsigned long oom_badness(struct task_struct *p, |
67 | struct mem_cgroup *memcg, const nodemask_t *nodemask, | 89 | struct mem_cgroup *memcg, const nodemask_t *nodemask, |
68 | unsigned long totalpages); | 90 | unsigned long totalpages); |
diff --git a/include/linux/pci.h b/include/linux/pci.h index 4869e66dd659..f958d0732af6 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h | |||
@@ -188,6 +188,8 @@ enum pci_dev_flags { | |||
188 | * the direct_complete optimization. | 188 | * the direct_complete optimization. |
189 | */ | 189 | */ |
190 | PCI_DEV_FLAGS_NEEDS_RESUME = (__force pci_dev_flags_t) (1 << 11), | 190 | PCI_DEV_FLAGS_NEEDS_RESUME = (__force pci_dev_flags_t) (1 << 11), |
191 | /* Don't use Relaxed Ordering for TLPs directed at this device */ | ||
192 | PCI_DEV_FLAGS_NO_RELAXED_ORDERING = (__force pci_dev_flags_t) (1 << 12), | ||
191 | }; | 193 | }; |
192 | 194 | ||
193 | enum pci_irq_reroute_variant { | 195 | enum pci_irq_reroute_variant { |
@@ -1067,6 +1069,7 @@ void pcie_flr(struct pci_dev *dev); | |||
1067 | int __pci_reset_function(struct pci_dev *dev); | 1069 | int __pci_reset_function(struct pci_dev *dev); |
1068 | int __pci_reset_function_locked(struct pci_dev *dev); | 1070 | int __pci_reset_function_locked(struct pci_dev *dev); |
1069 | int pci_reset_function(struct pci_dev *dev); | 1071 | int pci_reset_function(struct pci_dev *dev); |
1072 | int pci_reset_function_locked(struct pci_dev *dev); | ||
1070 | int pci_try_reset_function(struct pci_dev *dev); | 1073 | int pci_try_reset_function(struct pci_dev *dev); |
1071 | int pci_probe_reset_slot(struct pci_slot *slot); | 1074 | int pci_probe_reset_slot(struct pci_slot *slot); |
1072 | int pci_reset_slot(struct pci_slot *slot); | 1075 | int pci_reset_slot(struct pci_slot *slot); |
@@ -1125,6 +1128,7 @@ bool pci_check_pme_status(struct pci_dev *dev); | |||
1125 | void pci_pme_wakeup_bus(struct pci_bus *bus); | 1128 | void pci_pme_wakeup_bus(struct pci_bus *bus); |
1126 | void pci_d3cold_enable(struct pci_dev *dev); | 1129 | void pci_d3cold_enable(struct pci_dev *dev); |
1127 | void pci_d3cold_disable(struct pci_dev *dev); | 1130 | void pci_d3cold_disable(struct pci_dev *dev); |
1131 | bool pcie_relaxed_ordering_enabled(struct pci_dev *dev); | ||
1128 | 1132 | ||
1129 | /* PCI Virtual Channel */ | 1133 | /* PCI Virtual Channel */ |
1130 | int pci_save_vc_state(struct pci_dev *dev); | 1134 | int pci_save_vc_state(struct pci_dev *dev); |
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h index a3b873fc59e4..b14095bcf4bb 100644 --- a/include/linux/perf_event.h +++ b/include/linux/perf_event.h | |||
@@ -310,8 +310,8 @@ struct pmu { | |||
310 | * Notification that the event was mapped or unmapped. Called | 310 | * Notification that the event was mapped or unmapped. Called |
311 | * in the context of the mapping task. | 311 | * in the context of the mapping task. |
312 | */ | 312 | */ |
313 | void (*event_mapped) (struct perf_event *event); /*optional*/ | 313 | void (*event_mapped) (struct perf_event *event, struct mm_struct *mm); /* optional */ |
314 | void (*event_unmapped) (struct perf_event *event); /*optional*/ | 314 | void (*event_unmapped) (struct perf_event *event, struct mm_struct *mm); /* optional */ |
315 | 315 | ||
316 | /* | 316 | /* |
317 | * Flags for ->add()/->del()/ ->start()/->stop(). There are | 317 | * Flags for ->add()/->del()/ ->start()/->stop(). There are |
diff --git a/include/linux/pid.h b/include/linux/pid.h index 4d179316e431..719582744a2e 100644 --- a/include/linux/pid.h +++ b/include/linux/pid.h | |||
@@ -8,7 +8,9 @@ enum pid_type | |||
8 | PIDTYPE_PID, | 8 | PIDTYPE_PID, |
9 | PIDTYPE_PGID, | 9 | PIDTYPE_PGID, |
10 | PIDTYPE_SID, | 10 | PIDTYPE_SID, |
11 | PIDTYPE_MAX | 11 | PIDTYPE_MAX, |
12 | /* only valid to __task_pid_nr_ns() */ | ||
13 | __PIDTYPE_TGID | ||
12 | }; | 14 | }; |
13 | 15 | ||
14 | /* | 16 | /* |
diff --git a/include/linux/platform_data/st_sensors_pdata.h b/include/linux/platform_data/st_sensors_pdata.h index 79b0e4cdb814..f8274b0c6888 100644 --- a/include/linux/platform_data/st_sensors_pdata.h +++ b/include/linux/platform_data/st_sensors_pdata.h | |||
@@ -17,10 +17,12 @@ | |||
17 | * Available only for accelerometer and pressure sensors. | 17 | * Available only for accelerometer and pressure sensors. |
18 | * Accelerometer DRDY on LSM330 available only on pin 1 (see datasheet). | 18 | * Accelerometer DRDY on LSM330 available only on pin 1 (see datasheet). |
19 | * @open_drain: set the interrupt line to be open drain if possible. | 19 | * @open_drain: set the interrupt line to be open drain if possible. |
20 | * @spi_3wire: enable spi-3wire mode. | ||
20 | */ | 21 | */ |
21 | struct st_sensors_platform_data { | 22 | struct st_sensors_platform_data { |
22 | u8 drdy_int_pin; | 23 | u8 drdy_int_pin; |
23 | bool open_drain; | 24 | bool open_drain; |
25 | bool spi_3wire; | ||
24 | }; | 26 | }; |
25 | 27 | ||
26 | #endif /* ST_SENSORS_PDATA_H */ | 28 | #endif /* ST_SENSORS_PDATA_H */ |
diff --git a/include/linux/ptr_ring.h b/include/linux/ptr_ring.h index d8c97ec8a8e6..37b4bb2545b3 100644 --- a/include/linux/ptr_ring.h +++ b/include/linux/ptr_ring.h | |||
@@ -436,9 +436,9 @@ static inline int ptr_ring_consume_batched_bh(struct ptr_ring *r, | |||
436 | __PTR_RING_PEEK_CALL_v; \ | 436 | __PTR_RING_PEEK_CALL_v; \ |
437 | }) | 437 | }) |
438 | 438 | ||
439 | static inline void **__ptr_ring_init_queue_alloc(int size, gfp_t gfp) | 439 | static inline void **__ptr_ring_init_queue_alloc(unsigned int size, gfp_t gfp) |
440 | { | 440 | { |
441 | return kzalloc(ALIGN(size * sizeof(void *), SMP_CACHE_BYTES), gfp); | 441 | return kcalloc(size, sizeof(void *), gfp); |
442 | } | 442 | } |
443 | 443 | ||
444 | static inline void __ptr_ring_set_size(struct ptr_ring *r, int size) | 444 | static inline void __ptr_ring_set_size(struct ptr_ring *r, int size) |
@@ -582,7 +582,8 @@ static inline int ptr_ring_resize(struct ptr_ring *r, int size, gfp_t gfp, | |||
582 | * In particular if you consume ring in interrupt or BH context, you must | 582 | * In particular if you consume ring in interrupt or BH context, you must |
583 | * disable interrupts/BH when doing so. | 583 | * disable interrupts/BH when doing so. |
584 | */ | 584 | */ |
585 | static inline int ptr_ring_resize_multiple(struct ptr_ring **rings, int nrings, | 585 | static inline int ptr_ring_resize_multiple(struct ptr_ring **rings, |
586 | unsigned int nrings, | ||
586 | int size, | 587 | int size, |
587 | gfp_t gfp, void (*destroy)(void *)) | 588 | gfp_t gfp, void (*destroy)(void *)) |
588 | { | 589 | { |
@@ -590,7 +591,7 @@ static inline int ptr_ring_resize_multiple(struct ptr_ring **rings, int nrings, | |||
590 | void ***queues; | 591 | void ***queues; |
591 | int i; | 592 | int i; |
592 | 593 | ||
593 | queues = kmalloc(nrings * sizeof *queues, gfp); | 594 | queues = kmalloc_array(nrings, sizeof(*queues), gfp); |
594 | if (!queues) | 595 | if (!queues) |
595 | goto noqueues; | 596 | goto noqueues; |
596 | 597 | ||
diff --git a/include/linux/sched.h b/include/linux/sched.h index 8337e2db0bb2..c05ac5f5aa03 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h | |||
@@ -1163,13 +1163,6 @@ static inline pid_t task_tgid_nr(struct task_struct *tsk) | |||
1163 | return tsk->tgid; | 1163 | return tsk->tgid; |
1164 | } | 1164 | } |
1165 | 1165 | ||
1166 | extern pid_t task_tgid_nr_ns(struct task_struct *tsk, struct pid_namespace *ns); | ||
1167 | |||
1168 | static inline pid_t task_tgid_vnr(struct task_struct *tsk) | ||
1169 | { | ||
1170 | return pid_vnr(task_tgid(tsk)); | ||
1171 | } | ||
1172 | |||
1173 | /** | 1166 | /** |
1174 | * pid_alive - check that a task structure is not stale | 1167 | * pid_alive - check that a task structure is not stale |
1175 | * @p: Task structure to be checked. | 1168 | * @p: Task structure to be checked. |
@@ -1185,23 +1178,6 @@ static inline int pid_alive(const struct task_struct *p) | |||
1185 | return p->pids[PIDTYPE_PID].pid != NULL; | 1178 | return p->pids[PIDTYPE_PID].pid != NULL; |
1186 | } | 1179 | } |
1187 | 1180 | ||
1188 | static inline pid_t task_ppid_nr_ns(const struct task_struct *tsk, struct pid_namespace *ns) | ||
1189 | { | ||
1190 | pid_t pid = 0; | ||
1191 | |||
1192 | rcu_read_lock(); | ||
1193 | if (pid_alive(tsk)) | ||
1194 | pid = task_tgid_nr_ns(rcu_dereference(tsk->real_parent), ns); | ||
1195 | rcu_read_unlock(); | ||
1196 | |||
1197 | return pid; | ||
1198 | } | ||
1199 | |||
1200 | static inline pid_t task_ppid_nr(const struct task_struct *tsk) | ||
1201 | { | ||
1202 | return task_ppid_nr_ns(tsk, &init_pid_ns); | ||
1203 | } | ||
1204 | |||
1205 | static inline pid_t task_pgrp_nr_ns(struct task_struct *tsk, struct pid_namespace *ns) | 1181 | static inline pid_t task_pgrp_nr_ns(struct task_struct *tsk, struct pid_namespace *ns) |
1206 | { | 1182 | { |
1207 | return __task_pid_nr_ns(tsk, PIDTYPE_PGID, ns); | 1183 | return __task_pid_nr_ns(tsk, PIDTYPE_PGID, ns); |
@@ -1223,6 +1199,33 @@ static inline pid_t task_session_vnr(struct task_struct *tsk) | |||
1223 | return __task_pid_nr_ns(tsk, PIDTYPE_SID, NULL); | 1199 | return __task_pid_nr_ns(tsk, PIDTYPE_SID, NULL); |
1224 | } | 1200 | } |
1225 | 1201 | ||
1202 | static inline pid_t task_tgid_nr_ns(struct task_struct *tsk, struct pid_namespace *ns) | ||
1203 | { | ||
1204 | return __task_pid_nr_ns(tsk, __PIDTYPE_TGID, ns); | ||
1205 | } | ||
1206 | |||
1207 | static inline pid_t task_tgid_vnr(struct task_struct *tsk) | ||
1208 | { | ||
1209 | return __task_pid_nr_ns(tsk, __PIDTYPE_TGID, NULL); | ||
1210 | } | ||
1211 | |||
1212 | static inline pid_t task_ppid_nr_ns(const struct task_struct *tsk, struct pid_namespace *ns) | ||
1213 | { | ||
1214 | pid_t pid = 0; | ||
1215 | |||
1216 | rcu_read_lock(); | ||
1217 | if (pid_alive(tsk)) | ||
1218 | pid = task_tgid_nr_ns(rcu_dereference(tsk->real_parent), ns); | ||
1219 | rcu_read_unlock(); | ||
1220 | |||
1221 | return pid; | ||
1222 | } | ||
1223 | |||
1224 | static inline pid_t task_ppid_nr(const struct task_struct *tsk) | ||
1225 | { | ||
1226 | return task_ppid_nr_ns(tsk, &init_pid_ns); | ||
1227 | } | ||
1228 | |||
1226 | /* Obsolete, do not use: */ | 1229 | /* Obsolete, do not use: */ |
1227 | static inline pid_t task_pgrp_nr(struct task_struct *tsk) | 1230 | static inline pid_t task_pgrp_nr(struct task_struct *tsk) |
1228 | { | 1231 | { |
diff --git a/include/linux/skb_array.h b/include/linux/skb_array.h index 35226cd4efb0..8621ffdeecbf 100644 --- a/include/linux/skb_array.h +++ b/include/linux/skb_array.h | |||
@@ -193,7 +193,8 @@ static inline int skb_array_resize(struct skb_array *a, int size, gfp_t gfp) | |||
193 | } | 193 | } |
194 | 194 | ||
195 | static inline int skb_array_resize_multiple(struct skb_array **rings, | 195 | static inline int skb_array_resize_multiple(struct skb_array **rings, |
196 | int nrings, int size, gfp_t gfp) | 196 | int nrings, unsigned int size, |
197 | gfp_t gfp) | ||
197 | { | 198 | { |
198 | BUILD_BUG_ON(offsetof(struct skb_array, ring)); | 199 | BUILD_BUG_ON(offsetof(struct skb_array, ring)); |
199 | return ptr_ring_resize_multiple((struct ptr_ring **)rings, | 200 | return ptr_ring_resize_multiple((struct ptr_ring **)rings, |
diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h index 4ee479f2f355..15e7160751a8 100644 --- a/include/linux/swiotlb.h +++ b/include/linux/swiotlb.h | |||
@@ -35,6 +35,7 @@ int swiotlb_init_with_tbl(char *tlb, unsigned long nslabs, int verbose); | |||
35 | extern unsigned long swiotlb_nr_tbl(void); | 35 | extern unsigned long swiotlb_nr_tbl(void); |
36 | unsigned long swiotlb_size_or_default(void); | 36 | unsigned long swiotlb_size_or_default(void); |
37 | extern int swiotlb_late_init_with_tbl(char *tlb, unsigned long nslabs); | 37 | extern int swiotlb_late_init_with_tbl(char *tlb, unsigned long nslabs); |
38 | extern void __init swiotlb_update_mem_attributes(void); | ||
38 | 39 | ||
39 | /* | 40 | /* |
40 | * Enumeration for sync targets | 41 | * Enumeration for sync targets |
diff --git a/include/linux/sync_file.h b/include/linux/sync_file.h index 5726107963b2..0ad87c434ae6 100644 --- a/include/linux/sync_file.h +++ b/include/linux/sync_file.h | |||
@@ -43,12 +43,13 @@ struct sync_file { | |||
43 | #endif | 43 | #endif |
44 | 44 | ||
45 | wait_queue_head_t wq; | 45 | wait_queue_head_t wq; |
46 | unsigned long flags; | ||
46 | 47 | ||
47 | struct dma_fence *fence; | 48 | struct dma_fence *fence; |
48 | struct dma_fence_cb cb; | 49 | struct dma_fence_cb cb; |
49 | }; | 50 | }; |
50 | 51 | ||
51 | #define POLL_ENABLED DMA_FENCE_FLAG_USER_BITS | 52 | #define POLL_ENABLED 0 |
52 | 53 | ||
53 | struct sync_file *sync_file_create(struct dma_fence *fence); | 54 | struct sync_file *sync_file_create(struct dma_fence *fence); |
54 | struct dma_fence *sync_file_get_fence(int fd); | 55 | struct dma_fence *sync_file_get_fence(int fd); |
diff --git a/include/linux/wait.h b/include/linux/wait.h index 5b74e36c0ca8..dc19880c02f5 100644 --- a/include/linux/wait.h +++ b/include/linux/wait.h | |||
@@ -757,6 +757,43 @@ extern int do_wait_intr_irq(wait_queue_head_t *, wait_queue_entry_t *); | |||
757 | __ret; \ | 757 | __ret; \ |
758 | }) | 758 | }) |
759 | 759 | ||
760 | #define __wait_event_killable_timeout(wq_head, condition, timeout) \ | ||
761 | ___wait_event(wq_head, ___wait_cond_timeout(condition), \ | ||
762 | TASK_KILLABLE, 0, timeout, \ | ||
763 | __ret = schedule_timeout(__ret)) | ||
764 | |||
765 | /** | ||
766 | * wait_event_killable_timeout - sleep until a condition gets true or a timeout elapses | ||
767 | * @wq_head: the waitqueue to wait on | ||
768 | * @condition: a C expression for the event to wait for | ||
769 | * @timeout: timeout, in jiffies | ||
770 | * | ||
771 | * The process is put to sleep (TASK_KILLABLE) until the | ||
772 | * @condition evaluates to true or a kill signal is received. | ||
773 | * The @condition is checked each time the waitqueue @wq_head is woken up. | ||
774 | * | ||
775 | * wake_up() has to be called after changing any variable that could | ||
776 | * change the result of the wait condition. | ||
777 | * | ||
778 | * Returns: | ||
779 | * 0 if the @condition evaluated to %false after the @timeout elapsed, | ||
780 | * 1 if the @condition evaluated to %true after the @timeout elapsed, | ||
781 | * the remaining jiffies (at least 1) if the @condition evaluated | ||
782 | * to %true before the @timeout elapsed, or -%ERESTARTSYS if it was | ||
783 | * interrupted by a kill signal. | ||
784 | * | ||
785 | * Only kill signals interrupt this process. | ||
786 | */ | ||
787 | #define wait_event_killable_timeout(wq_head, condition, timeout) \ | ||
788 | ({ \ | ||
789 | long __ret = timeout; \ | ||
790 | might_sleep(); \ | ||
791 | if (!___wait_cond_timeout(condition)) \ | ||
792 | __ret = __wait_event_killable_timeout(wq_head, \ | ||
793 | condition, timeout); \ | ||
794 | __ret; \ | ||
795 | }) | ||
796 | |||
760 | 797 | ||
761 | #define __wait_event_lock_irq(wq_head, condition, lock, cmd) \ | 798 | #define __wait_event_lock_irq(wq_head, condition, lock, cmd) \ |
762 | (void)___wait_event(wq_head, condition, TASK_UNINTERRUPTIBLE, 0, 0, \ | 799 | (void)___wait_event(wq_head, condition, TASK_UNINTERRUPTIBLE, 0, 0, \ |
diff --git a/include/net/addrconf.h b/include/net/addrconf.h index 6df79e96a780..f44ff2476758 100644 --- a/include/net/addrconf.h +++ b/include/net/addrconf.h | |||
@@ -336,6 +336,16 @@ static inline void in6_dev_put(struct inet6_dev *idev) | |||
336 | in6_dev_finish_destroy(idev); | 336 | in6_dev_finish_destroy(idev); |
337 | } | 337 | } |
338 | 338 | ||
339 | static inline void in6_dev_put_clear(struct inet6_dev **pidev) | ||
340 | { | ||
341 | struct inet6_dev *idev = *pidev; | ||
342 | |||
343 | if (idev) { | ||
344 | in6_dev_put(idev); | ||
345 | *pidev = NULL; | ||
346 | } | ||
347 | } | ||
348 | |||
339 | static inline void __in6_dev_put(struct inet6_dev *idev) | 349 | static inline void __in6_dev_put(struct inet6_dev *idev) |
340 | { | 350 | { |
341 | refcount_dec(&idev->refcnt); | 351 | refcount_dec(&idev->refcnt); |
diff --git a/include/net/bonding.h b/include/net/bonding.h index b00508d22e0a..b2e68657a216 100644 --- a/include/net/bonding.h +++ b/include/net/bonding.h | |||
@@ -277,6 +277,11 @@ static inline bool bond_is_lb(const struct bonding *bond) | |||
277 | BOND_MODE(bond) == BOND_MODE_ALB; | 277 | BOND_MODE(bond) == BOND_MODE_ALB; |
278 | } | 278 | } |
279 | 279 | ||
280 | static inline bool bond_needs_speed_duplex(const struct bonding *bond) | ||
281 | { | ||
282 | return BOND_MODE(bond) == BOND_MODE_8023AD || bond_is_lb(bond); | ||
283 | } | ||
284 | |||
280 | static inline bool bond_is_nondyn_tlb(const struct bonding *bond) | 285 | static inline bool bond_is_nondyn_tlb(const struct bonding *bond) |
281 | { | 286 | { |
282 | return (BOND_MODE(bond) == BOND_MODE_TLB) && | 287 | return (BOND_MODE(bond) == BOND_MODE_TLB) && |
diff --git a/include/net/busy_poll.h b/include/net/busy_poll.h index 8ffd434676b7..71c72a939bf8 100644 --- a/include/net/busy_poll.h +++ b/include/net/busy_poll.h | |||
@@ -29,18 +29,18 @@ | |||
29 | #include <linux/sched/signal.h> | 29 | #include <linux/sched/signal.h> |
30 | #include <net/ip.h> | 30 | #include <net/ip.h> |
31 | 31 | ||
32 | #ifdef CONFIG_NET_RX_BUSY_POLL | ||
33 | |||
34 | struct napi_struct; | ||
35 | extern unsigned int sysctl_net_busy_read __read_mostly; | ||
36 | extern unsigned int sysctl_net_busy_poll __read_mostly; | ||
37 | |||
38 | /* 0 - Reserved to indicate value not set | 32 | /* 0 - Reserved to indicate value not set |
39 | * 1..NR_CPUS - Reserved for sender_cpu | 33 | * 1..NR_CPUS - Reserved for sender_cpu |
40 | * NR_CPUS+1..~0 - Region available for NAPI IDs | 34 | * NR_CPUS+1..~0 - Region available for NAPI IDs |
41 | */ | 35 | */ |
42 | #define MIN_NAPI_ID ((unsigned int)(NR_CPUS + 1)) | 36 | #define MIN_NAPI_ID ((unsigned int)(NR_CPUS + 1)) |
43 | 37 | ||
38 | #ifdef CONFIG_NET_RX_BUSY_POLL | ||
39 | |||
40 | struct napi_struct; | ||
41 | extern unsigned int sysctl_net_busy_read __read_mostly; | ||
42 | extern unsigned int sysctl_net_busy_poll __read_mostly; | ||
43 | |||
44 | static inline bool net_busy_loop_on(void) | 44 | static inline bool net_busy_loop_on(void) |
45 | { | 45 | { |
46 | return sysctl_net_busy_poll; | 46 | return sysctl_net_busy_poll; |
diff --git a/include/net/ip.h b/include/net/ip.h index 821cedcc8e73..0cf7f5a65fe6 100644 --- a/include/net/ip.h +++ b/include/net/ip.h | |||
@@ -352,7 +352,7 @@ static inline unsigned int ip_dst_mtu_maybe_forward(const struct dst_entry *dst, | |||
352 | !forwarding) | 352 | !forwarding) |
353 | return dst_mtu(dst); | 353 | return dst_mtu(dst); |
354 | 354 | ||
355 | return min(dst->dev->mtu, IP_MAX_MTU); | 355 | return min(READ_ONCE(dst->dev->mtu), IP_MAX_MTU); |
356 | } | 356 | } |
357 | 357 | ||
358 | static inline unsigned int ip_skb_dst_mtu(struct sock *sk, | 358 | static inline unsigned int ip_skb_dst_mtu(struct sock *sk, |
@@ -364,7 +364,7 @@ static inline unsigned int ip_skb_dst_mtu(struct sock *sk, | |||
364 | return ip_dst_mtu_maybe_forward(skb_dst(skb), forwarding); | 364 | return ip_dst_mtu_maybe_forward(skb_dst(skb), forwarding); |
365 | } | 365 | } |
366 | 366 | ||
367 | return min(skb_dst(skb)->dev->mtu, IP_MAX_MTU); | 367 | return min(READ_ONCE(skb_dst(skb)->dev->mtu), IP_MAX_MTU); |
368 | } | 368 | } |
369 | 369 | ||
370 | u32 ip_idents_reserve(u32 hash, int segs); | 370 | u32 ip_idents_reserve(u32 hash, int segs); |
diff --git a/include/net/mac80211.h b/include/net/mac80211.h index b2b5419467cc..f8149ca192b4 100644 --- a/include/net/mac80211.h +++ b/include/net/mac80211.h | |||
@@ -5499,6 +5499,21 @@ static inline void ieee80211_stop_rx_ba_session_offl(struct ieee80211_vif *vif, | |||
5499 | ieee80211_manage_rx_ba_offl(vif, addr, tid + IEEE80211_NUM_TIDS); | 5499 | ieee80211_manage_rx_ba_offl(vif, addr, tid + IEEE80211_NUM_TIDS); |
5500 | } | 5500 | } |
5501 | 5501 | ||
5502 | /** | ||
5503 | * ieee80211_rx_ba_timer_expired - stop a Rx BA session due to timeout | ||
5504 | * | ||
5505 | * Some device drivers do not offload AddBa/DelBa negotiation, but handle rx | ||
5506 | * buffer reording internally, and therefore also handle the session timer. | ||
5507 | * | ||
5508 | * Trigger the timeout flow, which sends a DelBa. | ||
5509 | * | ||
5510 | * @vif: &struct ieee80211_vif pointer from the add_interface callback | ||
5511 | * @addr: station mac address | ||
5512 | * @tid: the rx tid | ||
5513 | */ | ||
5514 | void ieee80211_rx_ba_timer_expired(struct ieee80211_vif *vif, | ||
5515 | const u8 *addr, unsigned int tid); | ||
5516 | |||
5502 | /* Rate control API */ | 5517 | /* Rate control API */ |
5503 | 5518 | ||
5504 | /** | 5519 | /** |
diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h index 1c123e2b2415..67f815e5d525 100644 --- a/include/net/sch_generic.h +++ b/include/net/sch_generic.h | |||
@@ -806,8 +806,11 @@ static inline struct Qdisc *qdisc_replace(struct Qdisc *sch, struct Qdisc *new, | |||
806 | old = *pold; | 806 | old = *pold; |
807 | *pold = new; | 807 | *pold = new; |
808 | if (old != NULL) { | 808 | if (old != NULL) { |
809 | qdisc_tree_reduce_backlog(old, old->q.qlen, old->qstats.backlog); | 809 | unsigned int qlen = old->q.qlen; |
810 | unsigned int backlog = old->qstats.backlog; | ||
811 | |||
810 | qdisc_reset(old); | 812 | qdisc_reset(old); |
813 | qdisc_tree_reduce_backlog(old, qlen, backlog); | ||
811 | } | 814 | } |
812 | sch_tree_unlock(sch); | 815 | sch_tree_unlock(sch); |
813 | 816 | ||
diff --git a/include/net/sock.h b/include/net/sock.h index 7c0632c7e870..aeeec62992ca 100644 --- a/include/net/sock.h +++ b/include/net/sock.h | |||
@@ -507,9 +507,7 @@ int sk_set_peek_off(struct sock *sk, int val); | |||
507 | static inline int sk_peek_offset(struct sock *sk, int flags) | 507 | static inline int sk_peek_offset(struct sock *sk, int flags) |
508 | { | 508 | { |
509 | if (unlikely(flags & MSG_PEEK)) { | 509 | if (unlikely(flags & MSG_PEEK)) { |
510 | s32 off = READ_ONCE(sk->sk_peek_off); | 510 | return READ_ONCE(sk->sk_peek_off); |
511 | if (off >= 0) | ||
512 | return off; | ||
513 | } | 511 | } |
514 | 512 | ||
515 | return 0; | 513 | return 0; |
diff --git a/include/net/udp.h b/include/net/udp.h index cc8036987dcb..586de4b811b5 100644 --- a/include/net/udp.h +++ b/include/net/udp.h | |||
@@ -366,12 +366,13 @@ static inline bool udp_skb_is_linear(struct sk_buff *skb) | |||
366 | static inline int copy_linear_skb(struct sk_buff *skb, int len, int off, | 366 | static inline int copy_linear_skb(struct sk_buff *skb, int len, int off, |
367 | struct iov_iter *to) | 367 | struct iov_iter *to) |
368 | { | 368 | { |
369 | int n, copy = len - off; | 369 | int n; |
370 | 370 | ||
371 | n = copy_to_iter(skb->data + off, copy, to); | 371 | n = copy_to_iter(skb->data + off, len, to); |
372 | if (n == copy) | 372 | if (n == len) |
373 | return 0; | 373 | return 0; |
374 | 374 | ||
375 | iov_iter_revert(to, n); | ||
375 | return -EFAULT; | 376 | return -EFAULT; |
376 | } | 377 | } |
377 | 378 | ||
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index b5732432bb29..88c32aba32f7 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h | |||
@@ -1683,6 +1683,7 @@ struct ib_qp { | |||
1683 | enum ib_qp_type qp_type; | 1683 | enum ib_qp_type qp_type; |
1684 | struct ib_rwq_ind_table *rwq_ind_tbl; | 1684 | struct ib_rwq_ind_table *rwq_ind_tbl; |
1685 | struct ib_qp_security *qp_sec; | 1685 | struct ib_qp_security *qp_sec; |
1686 | u8 port; | ||
1686 | }; | 1687 | }; |
1687 | 1688 | ||
1688 | struct ib_mr { | 1689 | struct ib_mr { |
diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h index a1266d318c85..6af198d8120b 100644 --- a/include/scsi/scsi_cmnd.h +++ b/include/scsi/scsi_cmnd.h | |||
@@ -57,6 +57,7 @@ struct scsi_pointer { | |||
57 | /* for scmd->flags */ | 57 | /* for scmd->flags */ |
58 | #define SCMD_TAGGED (1 << 0) | 58 | #define SCMD_TAGGED (1 << 0) |
59 | #define SCMD_UNCHECKED_ISA_DMA (1 << 1) | 59 | #define SCMD_UNCHECKED_ISA_DMA (1 << 1) |
60 | #define SCMD_ZONE_WRITE_LOCK (1 << 2) | ||
60 | 61 | ||
61 | struct scsi_cmnd { | 62 | struct scsi_cmnd { |
62 | struct scsi_request req; | 63 | struct scsi_request req; |
diff --git a/include/target/iscsi/iscsi_target_core.h b/include/target/iscsi/iscsi_target_core.h index 0ca1fb08805b..fb87d32f5e51 100644 --- a/include/target/iscsi/iscsi_target_core.h +++ b/include/target/iscsi/iscsi_target_core.h | |||
@@ -786,6 +786,7 @@ struct iscsi_np { | |||
786 | int np_sock_type; | 786 | int np_sock_type; |
787 | enum np_thread_state_table np_thread_state; | 787 | enum np_thread_state_table np_thread_state; |
788 | bool enabled; | 788 | bool enabled; |
789 | atomic_t np_reset_count; | ||
789 | enum iscsi_timer_flags_table np_login_timer_flags; | 790 | enum iscsi_timer_flags_table np_login_timer_flags; |
790 | u32 np_exports; | 791 | u32 np_exports; |
791 | enum np_flags_table np_flags; | 792 | enum np_flags_table np_flags; |
diff --git a/include/uapi/drm/msm_drm.h b/include/uapi/drm/msm_drm.h index 26c54f6d595d..ad4eb2863e70 100644 --- a/include/uapi/drm/msm_drm.h +++ b/include/uapi/drm/msm_drm.h | |||
@@ -171,7 +171,7 @@ struct drm_msm_gem_submit_cmd { | |||
171 | __u32 size; /* in, cmdstream size */ | 171 | __u32 size; /* in, cmdstream size */ |
172 | __u32 pad; | 172 | __u32 pad; |
173 | __u32 nr_relocs; /* in, number of submit_reloc's */ | 173 | __u32 nr_relocs; /* in, number of submit_reloc's */ |
174 | __u64 __user relocs; /* in, ptr to array of submit_reloc's */ | 174 | __u64 relocs; /* in, ptr to array of submit_reloc's */ |
175 | }; | 175 | }; |
176 | 176 | ||
177 | /* Each buffer referenced elsewhere in the cmdstream submit (ie. the | 177 | /* Each buffer referenced elsewhere in the cmdstream submit (ie. the |
@@ -215,8 +215,8 @@ struct drm_msm_gem_submit { | |||
215 | __u32 fence; /* out */ | 215 | __u32 fence; /* out */ |
216 | __u32 nr_bos; /* in, number of submit_bo's */ | 216 | __u32 nr_bos; /* in, number of submit_bo's */ |
217 | __u32 nr_cmds; /* in, number of submit_cmd's */ | 217 | __u32 nr_cmds; /* in, number of submit_cmd's */ |
218 | __u64 __user bos; /* in, ptr to array of submit_bo's */ | 218 | __u64 bos; /* in, ptr to array of submit_bo's */ |
219 | __u64 __user cmds; /* in, ptr to array of submit_cmd's */ | 219 | __u64 cmds; /* in, ptr to array of submit_cmd's */ |
220 | __s32 fence_fd; /* in/out fence fd (see MSM_SUBMIT_FENCE_FD_IN/OUT) */ | 220 | __s32 fence_fd; /* in/out fence fd (see MSM_SUBMIT_FENCE_FD_IN/OUT) */ |
221 | }; | 221 | }; |
222 | 222 | ||
diff --git a/init/main.c b/init/main.c index 052481fbe363..9789ab7fe85e 100644 --- a/init/main.c +++ b/init/main.c | |||
@@ -488,6 +488,8 @@ void __init __weak thread_stack_cache_init(void) | |||
488 | } | 488 | } |
489 | #endif | 489 | #endif |
490 | 490 | ||
491 | void __init __weak mem_encrypt_init(void) { } | ||
492 | |||
491 | /* | 493 | /* |
492 | * Set up kernel memory allocators | 494 | * Set up kernel memory allocators |
493 | */ | 495 | */ |
@@ -641,6 +643,14 @@ asmlinkage __visible void __init start_kernel(void) | |||
641 | */ | 643 | */ |
642 | locking_selftest(); | 644 | locking_selftest(); |
643 | 645 | ||
646 | /* | ||
647 | * This needs to be called before any devices perform DMA | ||
648 | * operations that might use the SWIOTLB bounce buffers. It will | ||
649 | * mark the bounce buffers as decrypted so that their usage will | ||
650 | * not cause "plain-text" data to be decrypted when accessed. | ||
651 | */ | ||
652 | mem_encrypt_init(); | ||
653 | |||
644 | #ifdef CONFIG_BLK_DEV_INITRD | 654 | #ifdef CONFIG_BLK_DEV_INITRD |
645 | if (initrd_start && !initrd_below_start_ok && | 655 | if (initrd_start && !initrd_below_start_ok && |
646 | page_to_pfn(virt_to_page((void *)initrd_start)) < min_low_pfn) { | 656 | page_to_pfn(virt_to_page((void *)initrd_start)) < min_low_pfn) { |
diff --git a/kernel/audit_watch.c b/kernel/audit_watch.c index 62d686d96581..9eb8b3511636 100644 --- a/kernel/audit_watch.c +++ b/kernel/audit_watch.c | |||
@@ -66,7 +66,7 @@ static struct fsnotify_group *audit_watch_group; | |||
66 | 66 | ||
67 | /* fsnotify events we care about. */ | 67 | /* fsnotify events we care about. */ |
68 | #define AUDIT_FS_WATCH (FS_MOVE | FS_CREATE | FS_DELETE | FS_DELETE_SELF |\ | 68 | #define AUDIT_FS_WATCH (FS_MOVE | FS_CREATE | FS_DELETE | FS_DELETE_SELF |\ |
69 | FS_MOVE_SELF | FS_EVENT_ON_CHILD) | 69 | FS_MOVE_SELF | FS_EVENT_ON_CHILD | FS_UNMOUNT) |
70 | 70 | ||
71 | static void audit_free_parent(struct audit_parent *parent) | 71 | static void audit_free_parent(struct audit_parent *parent) |
72 | { | 72 | { |
@@ -457,13 +457,15 @@ void audit_remove_watch_rule(struct audit_krule *krule) | |||
457 | list_del(&krule->rlist); | 457 | list_del(&krule->rlist); |
458 | 458 | ||
459 | if (list_empty(&watch->rules)) { | 459 | if (list_empty(&watch->rules)) { |
460 | /* | ||
461 | * audit_remove_watch() drops our reference to 'parent' which | ||
462 | * can get freed. Grab our own reference to be safe. | ||
463 | */ | ||
464 | audit_get_parent(parent); | ||
460 | audit_remove_watch(watch); | 465 | audit_remove_watch(watch); |
461 | 466 | if (list_empty(&parent->watches)) | |
462 | if (list_empty(&parent->watches)) { | ||
463 | audit_get_parent(parent); | ||
464 | fsnotify_destroy_mark(&parent->mark, audit_watch_group); | 467 | fsnotify_destroy_mark(&parent->mark, audit_watch_group); |
465 | audit_put_parent(parent); | 468 | audit_put_parent(parent); |
466 | } | ||
467 | } | 469 | } |
468 | } | 470 | } |
469 | 471 | ||
diff --git a/kernel/events/core.c b/kernel/events/core.c index 426c2ffba16d..ee20d4c546b5 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c | |||
@@ -2217,6 +2217,33 @@ static int group_can_go_on(struct perf_event *event, | |||
2217 | return can_add_hw; | 2217 | return can_add_hw; |
2218 | } | 2218 | } |
2219 | 2219 | ||
2220 | /* | ||
2221 | * Complement to update_event_times(). This computes the tstamp_* values to | ||
2222 | * continue 'enabled' state from @now, and effectively discards the time | ||
2223 | * between the prior tstamp_stopped and now (as we were in the OFF state, or | ||
2224 | * just switched (context) time base). | ||
2225 | * | ||
2226 | * This further assumes '@event->state == INACTIVE' (we just came from OFF) and | ||
2227 | * cannot have been scheduled in yet. And going into INACTIVE state means | ||
2228 | * '@event->tstamp_stopped = @now'. | ||
2229 | * | ||
2230 | * Thus given the rules of update_event_times(): | ||
2231 | * | ||
2232 | * total_time_enabled = tstamp_stopped - tstamp_enabled | ||
2233 | * total_time_running = tstamp_stopped - tstamp_running | ||
2234 | * | ||
2235 | * We can insert 'tstamp_stopped == now' and reverse them to compute new | ||
2236 | * tstamp_* values. | ||
2237 | */ | ||
2238 | static void __perf_event_enable_time(struct perf_event *event, u64 now) | ||
2239 | { | ||
2240 | WARN_ON_ONCE(event->state != PERF_EVENT_STATE_INACTIVE); | ||
2241 | |||
2242 | event->tstamp_stopped = now; | ||
2243 | event->tstamp_enabled = now - event->total_time_enabled; | ||
2244 | event->tstamp_running = now - event->total_time_running; | ||
2245 | } | ||
2246 | |||
2220 | static void add_event_to_ctx(struct perf_event *event, | 2247 | static void add_event_to_ctx(struct perf_event *event, |
2221 | struct perf_event_context *ctx) | 2248 | struct perf_event_context *ctx) |
2222 | { | 2249 | { |
@@ -2224,9 +2251,12 @@ static void add_event_to_ctx(struct perf_event *event, | |||
2224 | 2251 | ||
2225 | list_add_event(event, ctx); | 2252 | list_add_event(event, ctx); |
2226 | perf_group_attach(event); | 2253 | perf_group_attach(event); |
2227 | event->tstamp_enabled = tstamp; | 2254 | /* |
2228 | event->tstamp_running = tstamp; | 2255 | * We can be called with event->state == STATE_OFF when we create with |
2229 | event->tstamp_stopped = tstamp; | 2256 | * .disabled = 1. In that case the IOC_ENABLE will call this function. |
2257 | */ | ||
2258 | if (event->state == PERF_EVENT_STATE_INACTIVE) | ||
2259 | __perf_event_enable_time(event, tstamp); | ||
2230 | } | 2260 | } |
2231 | 2261 | ||
2232 | static void ctx_sched_out(struct perf_event_context *ctx, | 2262 | static void ctx_sched_out(struct perf_event_context *ctx, |
@@ -2471,10 +2501,11 @@ static void __perf_event_mark_enabled(struct perf_event *event) | |||
2471 | u64 tstamp = perf_event_time(event); | 2501 | u64 tstamp = perf_event_time(event); |
2472 | 2502 | ||
2473 | event->state = PERF_EVENT_STATE_INACTIVE; | 2503 | event->state = PERF_EVENT_STATE_INACTIVE; |
2474 | event->tstamp_enabled = tstamp - event->total_time_enabled; | 2504 | __perf_event_enable_time(event, tstamp); |
2475 | list_for_each_entry(sub, &event->sibling_list, group_entry) { | 2505 | list_for_each_entry(sub, &event->sibling_list, group_entry) { |
2506 | /* XXX should not be > INACTIVE if event isn't */ | ||
2476 | if (sub->state >= PERF_EVENT_STATE_INACTIVE) | 2507 | if (sub->state >= PERF_EVENT_STATE_INACTIVE) |
2477 | sub->tstamp_enabled = tstamp - sub->total_time_enabled; | 2508 | __perf_event_enable_time(sub, tstamp); |
2478 | } | 2509 | } |
2479 | } | 2510 | } |
2480 | 2511 | ||
@@ -5090,7 +5121,7 @@ static void perf_mmap_open(struct vm_area_struct *vma) | |||
5090 | atomic_inc(&event->rb->aux_mmap_count); | 5121 | atomic_inc(&event->rb->aux_mmap_count); |
5091 | 5122 | ||
5092 | if (event->pmu->event_mapped) | 5123 | if (event->pmu->event_mapped) |
5093 | event->pmu->event_mapped(event); | 5124 | event->pmu->event_mapped(event, vma->vm_mm); |
5094 | } | 5125 | } |
5095 | 5126 | ||
5096 | static void perf_pmu_output_stop(struct perf_event *event); | 5127 | static void perf_pmu_output_stop(struct perf_event *event); |
@@ -5113,7 +5144,7 @@ static void perf_mmap_close(struct vm_area_struct *vma) | |||
5113 | unsigned long size = perf_data_size(rb); | 5144 | unsigned long size = perf_data_size(rb); |
5114 | 5145 | ||
5115 | if (event->pmu->event_unmapped) | 5146 | if (event->pmu->event_unmapped) |
5116 | event->pmu->event_unmapped(event); | 5147 | event->pmu->event_unmapped(event, vma->vm_mm); |
5117 | 5148 | ||
5118 | /* | 5149 | /* |
5119 | * rb->aux_mmap_count will always drop before rb->mmap_count and | 5150 | * rb->aux_mmap_count will always drop before rb->mmap_count and |
@@ -5411,7 +5442,7 @@ aux_unlock: | |||
5411 | vma->vm_ops = &perf_mmap_vmops; | 5442 | vma->vm_ops = &perf_mmap_vmops; |
5412 | 5443 | ||
5413 | if (event->pmu->event_mapped) | 5444 | if (event->pmu->event_mapped) |
5414 | event->pmu->event_mapped(event); | 5445 | event->pmu->event_mapped(event, vma->vm_mm); |
5415 | 5446 | ||
5416 | return ret; | 5447 | return ret; |
5417 | } | 5448 | } |
diff --git a/kernel/fork.c b/kernel/fork.c index 17921b0390b4..e075b7780421 100644 --- a/kernel/fork.c +++ b/kernel/fork.c | |||
@@ -807,7 +807,7 @@ static struct mm_struct *mm_init(struct mm_struct *mm, struct task_struct *p, | |||
807 | mm_init_aio(mm); | 807 | mm_init_aio(mm); |
808 | mm_init_owner(mm, p); | 808 | mm_init_owner(mm, p); |
809 | mmu_notifier_mm_init(mm); | 809 | mmu_notifier_mm_init(mm); |
810 | clear_tlb_flush_pending(mm); | 810 | init_tlb_flush_pending(mm); |
811 | #if defined(CONFIG_TRANSPARENT_HUGEPAGE) && !USE_SPLIT_PMD_PTLOCKS | 811 | #if defined(CONFIG_TRANSPARENT_HUGEPAGE) && !USE_SPLIT_PMD_PTLOCKS |
812 | mm->pmd_huge_pte = NULL; | 812 | mm->pmd_huge_pte = NULL; |
813 | #endif | 813 | #endif |
diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c index a3cc37c0c85e..3675c6004f2a 100644 --- a/kernel/irq/chip.c +++ b/kernel/irq/chip.c | |||
@@ -1000,7 +1000,7 @@ EXPORT_SYMBOL_GPL(irq_set_chip_and_handler_name); | |||
1000 | 1000 | ||
1001 | void irq_modify_status(unsigned int irq, unsigned long clr, unsigned long set) | 1001 | void irq_modify_status(unsigned int irq, unsigned long clr, unsigned long set) |
1002 | { | 1002 | { |
1003 | unsigned long flags; | 1003 | unsigned long flags, trigger, tmp; |
1004 | struct irq_desc *desc = irq_get_desc_lock(irq, &flags, 0); | 1004 | struct irq_desc *desc = irq_get_desc_lock(irq, &flags, 0); |
1005 | 1005 | ||
1006 | if (!desc) | 1006 | if (!desc) |
@@ -1014,6 +1014,8 @@ void irq_modify_status(unsigned int irq, unsigned long clr, unsigned long set) | |||
1014 | 1014 | ||
1015 | irq_settings_clr_and_set(desc, clr, set); | 1015 | irq_settings_clr_and_set(desc, clr, set); |
1016 | 1016 | ||
1017 | trigger = irqd_get_trigger_type(&desc->irq_data); | ||
1018 | |||
1017 | irqd_clear(&desc->irq_data, IRQD_NO_BALANCING | IRQD_PER_CPU | | 1019 | irqd_clear(&desc->irq_data, IRQD_NO_BALANCING | IRQD_PER_CPU | |
1018 | IRQD_TRIGGER_MASK | IRQD_LEVEL | IRQD_MOVE_PCNTXT); | 1020 | IRQD_TRIGGER_MASK | IRQD_LEVEL | IRQD_MOVE_PCNTXT); |
1019 | if (irq_settings_has_no_balance_set(desc)) | 1021 | if (irq_settings_has_no_balance_set(desc)) |
@@ -1025,7 +1027,11 @@ void irq_modify_status(unsigned int irq, unsigned long clr, unsigned long set) | |||
1025 | if (irq_settings_is_level(desc)) | 1027 | if (irq_settings_is_level(desc)) |
1026 | irqd_set(&desc->irq_data, IRQD_LEVEL); | 1028 | irqd_set(&desc->irq_data, IRQD_LEVEL); |
1027 | 1029 | ||
1028 | irqd_set(&desc->irq_data, irq_settings_get_trigger_mask(desc)); | 1030 | tmp = irq_settings_get_trigger_mask(desc); |
1031 | if (tmp != IRQ_TYPE_NONE) | ||
1032 | trigger = tmp; | ||
1033 | |||
1034 | irqd_set(&desc->irq_data, trigger); | ||
1029 | 1035 | ||
1030 | irq_put_desc_unlock(desc, flags); | 1036 | irq_put_desc_unlock(desc, flags); |
1031 | } | 1037 | } |
diff --git a/kernel/irq/ipi.c b/kernel/irq/ipi.c index 1a9abc1c8ea0..259a22aa9934 100644 --- a/kernel/irq/ipi.c +++ b/kernel/irq/ipi.c | |||
@@ -165,7 +165,7 @@ irq_hw_number_t ipi_get_hwirq(unsigned int irq, unsigned int cpu) | |||
165 | struct irq_data *data = irq_get_irq_data(irq); | 165 | struct irq_data *data = irq_get_irq_data(irq); |
166 | struct cpumask *ipimask = data ? irq_data_get_affinity_mask(data) : NULL; | 166 | struct cpumask *ipimask = data ? irq_data_get_affinity_mask(data) : NULL; |
167 | 167 | ||
168 | if (!data || !ipimask || cpu > nr_cpu_ids) | 168 | if (!data || !ipimask || cpu >= nr_cpu_ids) |
169 | return INVALID_HWIRQ; | 169 | return INVALID_HWIRQ; |
170 | 170 | ||
171 | if (!cpumask_test_cpu(cpu, ipimask)) | 171 | if (!cpumask_test_cpu(cpu, ipimask)) |
@@ -195,7 +195,7 @@ static int ipi_send_verify(struct irq_chip *chip, struct irq_data *data, | |||
195 | if (!chip->ipi_send_single && !chip->ipi_send_mask) | 195 | if (!chip->ipi_send_single && !chip->ipi_send_mask) |
196 | return -EINVAL; | 196 | return -EINVAL; |
197 | 197 | ||
198 | if (cpu > nr_cpu_ids) | 198 | if (cpu >= nr_cpu_ids) |
199 | return -EINVAL; | 199 | return -EINVAL; |
200 | 200 | ||
201 | if (dest) { | 201 | if (dest) { |
diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c index 1ae7c41c33c1..20fef1a38602 100644 --- a/kernel/kexec_core.c +++ b/kernel/kexec_core.c | |||
@@ -301,7 +301,7 @@ static struct page *kimage_alloc_pages(gfp_t gfp_mask, unsigned int order) | |||
301 | { | 301 | { |
302 | struct page *pages; | 302 | struct page *pages; |
303 | 303 | ||
304 | pages = alloc_pages(gfp_mask, order); | 304 | pages = alloc_pages(gfp_mask & ~__GFP_ZERO, order); |
305 | if (pages) { | 305 | if (pages) { |
306 | unsigned int count, i; | 306 | unsigned int count, i; |
307 | 307 | ||
@@ -310,6 +310,13 @@ static struct page *kimage_alloc_pages(gfp_t gfp_mask, unsigned int order) | |||
310 | count = 1 << order; | 310 | count = 1 << order; |
311 | for (i = 0; i < count; i++) | 311 | for (i = 0; i < count; i++) |
312 | SetPageReserved(pages + i); | 312 | SetPageReserved(pages + i); |
313 | |||
314 | arch_kexec_post_alloc_pages(page_address(pages), count, | ||
315 | gfp_mask); | ||
316 | |||
317 | if (gfp_mask & __GFP_ZERO) | ||
318 | for (i = 0; i < count; i++) | ||
319 | clear_highpage(pages + i); | ||
313 | } | 320 | } |
314 | 321 | ||
315 | return pages; | 322 | return pages; |
@@ -321,6 +328,9 @@ static void kimage_free_pages(struct page *page) | |||
321 | 328 | ||
322 | order = page_private(page); | 329 | order = page_private(page); |
323 | count = 1 << order; | 330 | count = 1 << order; |
331 | |||
332 | arch_kexec_pre_free_pages(page_address(page), count); | ||
333 | |||
324 | for (i = 0; i < count; i++) | 334 | for (i = 0; i < count; i++) |
325 | ClearPageReserved(page + i); | 335 | ClearPageReserved(page + i); |
326 | __free_pages(page, order); | 336 | __free_pages(page, order); |
diff --git a/kernel/kmod.c b/kernel/kmod.c index 6d016c5d97c8..2f37acde640b 100644 --- a/kernel/kmod.c +++ b/kernel/kmod.c | |||
@@ -71,6 +71,18 @@ static atomic_t kmod_concurrent_max = ATOMIC_INIT(MAX_KMOD_CONCURRENT); | |||
71 | static DECLARE_WAIT_QUEUE_HEAD(kmod_wq); | 71 | static DECLARE_WAIT_QUEUE_HEAD(kmod_wq); |
72 | 72 | ||
73 | /* | 73 | /* |
74 | * This is a restriction on having *all* MAX_KMOD_CONCURRENT threads | ||
75 | * running at the same time without returning. When this happens we | ||
76 | * believe you've somehow ended up with a recursive module dependency | ||
77 | * creating a loop. | ||
78 | * | ||
79 | * We have no option but to fail. | ||
80 | * | ||
81 | * Userspace should proactively try to detect and prevent these. | ||
82 | */ | ||
83 | #define MAX_KMOD_ALL_BUSY_TIMEOUT 5 | ||
84 | |||
85 | /* | ||
74 | modprobe_path is set via /proc/sys. | 86 | modprobe_path is set via /proc/sys. |
75 | */ | 87 | */ |
76 | char modprobe_path[KMOD_PATH_LEN] = "/sbin/modprobe"; | 88 | char modprobe_path[KMOD_PATH_LEN] = "/sbin/modprobe"; |
@@ -167,8 +179,17 @@ int __request_module(bool wait, const char *fmt, ...) | |||
167 | pr_warn_ratelimited("request_module: kmod_concurrent_max (%u) close to 0 (max_modprobes: %u), for module %s, throttling...", | 179 | pr_warn_ratelimited("request_module: kmod_concurrent_max (%u) close to 0 (max_modprobes: %u), for module %s, throttling...", |
168 | atomic_read(&kmod_concurrent_max), | 180 | atomic_read(&kmod_concurrent_max), |
169 | MAX_KMOD_CONCURRENT, module_name); | 181 | MAX_KMOD_CONCURRENT, module_name); |
170 | wait_event_interruptible(kmod_wq, | 182 | ret = wait_event_killable_timeout(kmod_wq, |
171 | atomic_dec_if_positive(&kmod_concurrent_max) >= 0); | 183 | atomic_dec_if_positive(&kmod_concurrent_max) >= 0, |
184 | MAX_KMOD_ALL_BUSY_TIMEOUT * HZ); | ||
185 | if (!ret) { | ||
186 | pr_warn_ratelimited("request_module: modprobe %s cannot be processed, kmod busy with %d threads for more than %d seconds now", | ||
187 | module_name, MAX_KMOD_CONCURRENT, MAX_KMOD_ALL_BUSY_TIMEOUT); | ||
188 | return -ETIME; | ||
189 | } else if (ret == -ERESTARTSYS) { | ||
190 | pr_warn_ratelimited("request_module: sigkill sent for modprobe %s, giving up", module_name); | ||
191 | return ret; | ||
192 | } | ||
172 | } | 193 | } |
173 | 194 | ||
174 | trace_module_request(module_name, wait, _RET_IP_); | 195 | trace_module_request(module_name, wait, _RET_IP_); |
diff --git a/kernel/memremap.c b/kernel/memremap.c index 124bed776532..9afdc434fb49 100644 --- a/kernel/memremap.c +++ b/kernel/memremap.c | |||
@@ -34,13 +34,24 @@ static void *arch_memremap_wb(resource_size_t offset, unsigned long size) | |||
34 | } | 34 | } |
35 | #endif | 35 | #endif |
36 | 36 | ||
37 | static void *try_ram_remap(resource_size_t offset, size_t size) | 37 | #ifndef arch_memremap_can_ram_remap |
38 | static bool arch_memremap_can_ram_remap(resource_size_t offset, size_t size, | ||
39 | unsigned long flags) | ||
40 | { | ||
41 | return true; | ||
42 | } | ||
43 | #endif | ||
44 | |||
45 | static void *try_ram_remap(resource_size_t offset, size_t size, | ||
46 | unsigned long flags) | ||
38 | { | 47 | { |
39 | unsigned long pfn = PHYS_PFN(offset); | 48 | unsigned long pfn = PHYS_PFN(offset); |
40 | 49 | ||
41 | /* In the simple case just return the existing linear address */ | 50 | /* In the simple case just return the existing linear address */ |
42 | if (pfn_valid(pfn) && !PageHighMem(pfn_to_page(pfn))) | 51 | if (pfn_valid(pfn) && !PageHighMem(pfn_to_page(pfn)) && |
52 | arch_memremap_can_ram_remap(offset, size, flags)) | ||
43 | return __va(offset); | 53 | return __va(offset); |
54 | |||
44 | return NULL; /* fallback to arch_memremap_wb */ | 55 | return NULL; /* fallback to arch_memremap_wb */ |
45 | } | 56 | } |
46 | 57 | ||
@@ -48,7 +59,8 @@ static void *try_ram_remap(resource_size_t offset, size_t size) | |||
48 | * memremap() - remap an iomem_resource as cacheable memory | 59 | * memremap() - remap an iomem_resource as cacheable memory |
49 | * @offset: iomem resource start address | 60 | * @offset: iomem resource start address |
50 | * @size: size of remap | 61 | * @size: size of remap |
51 | * @flags: any of MEMREMAP_WB, MEMREMAP_WT and MEMREMAP_WC | 62 | * @flags: any of MEMREMAP_WB, MEMREMAP_WT, MEMREMAP_WC, |
63 | * MEMREMAP_ENC, MEMREMAP_DEC | ||
52 | * | 64 | * |
53 | * memremap() is "ioremap" for cases where it is known that the resource | 65 | * memremap() is "ioremap" for cases where it is known that the resource |
54 | * being mapped does not have i/o side effects and the __iomem | 66 | * being mapped does not have i/o side effects and the __iomem |
@@ -95,7 +107,7 @@ void *memremap(resource_size_t offset, size_t size, unsigned long flags) | |||
95 | * the requested range is potentially in System RAM. | 107 | * the requested range is potentially in System RAM. |
96 | */ | 108 | */ |
97 | if (is_ram == REGION_INTERSECTS) | 109 | if (is_ram == REGION_INTERSECTS) |
98 | addr = try_ram_remap(offset, size); | 110 | addr = try_ram_remap(offset, size, flags); |
99 | if (!addr) | 111 | if (!addr) |
100 | addr = arch_memremap_wb(offset, size); | 112 | addr = arch_memremap_wb(offset, size); |
101 | } | 113 | } |
diff --git a/kernel/pid.c b/kernel/pid.c index c69c30d827e5..020dedbdf066 100644 --- a/kernel/pid.c +++ b/kernel/pid.c | |||
@@ -527,8 +527,11 @@ pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type, | |||
527 | if (!ns) | 527 | if (!ns) |
528 | ns = task_active_pid_ns(current); | 528 | ns = task_active_pid_ns(current); |
529 | if (likely(pid_alive(task))) { | 529 | if (likely(pid_alive(task))) { |
530 | if (type != PIDTYPE_PID) | 530 | if (type != PIDTYPE_PID) { |
531 | if (type == __PIDTYPE_TGID) | ||
532 | type = PIDTYPE_PID; | ||
531 | task = task->group_leader; | 533 | task = task->group_leader; |
534 | } | ||
532 | nr = pid_nr_ns(rcu_dereference(task->pids[type].pid), ns); | 535 | nr = pid_nr_ns(rcu_dereference(task->pids[type].pid), ns); |
533 | } | 536 | } |
534 | rcu_read_unlock(); | 537 | rcu_read_unlock(); |
@@ -537,12 +540,6 @@ pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type, | |||
537 | } | 540 | } |
538 | EXPORT_SYMBOL(__task_pid_nr_ns); | 541 | EXPORT_SYMBOL(__task_pid_nr_ns); |
539 | 542 | ||
540 | pid_t task_tgid_nr_ns(struct task_struct *tsk, struct pid_namespace *ns) | ||
541 | { | ||
542 | return pid_nr_ns(task_tgid(tsk), ns); | ||
543 | } | ||
544 | EXPORT_SYMBOL(task_tgid_nr_ns); | ||
545 | |||
546 | struct pid_namespace *task_active_pid_ns(struct task_struct *tsk) | 543 | struct pid_namespace *task_active_pid_ns(struct task_struct *tsk) |
547 | { | 544 | { |
548 | return ns_of_pid(task_pid(tsk)); | 545 | return ns_of_pid(task_pid(tsk)); |
diff --git a/kernel/power/snapshot.c b/kernel/power/snapshot.c index 222317721c5a..0972a8e09d08 100644 --- a/kernel/power/snapshot.c +++ b/kernel/power/snapshot.c | |||
@@ -1650,7 +1650,7 @@ static unsigned long minimum_image_size(unsigned long saveable) | |||
1650 | { | 1650 | { |
1651 | unsigned long size; | 1651 | unsigned long size; |
1652 | 1652 | ||
1653 | size = global_page_state(NR_SLAB_RECLAIMABLE) | 1653 | size = global_node_page_state(NR_SLAB_RECLAIMABLE) |
1654 | + global_node_page_state(NR_ACTIVE_ANON) | 1654 | + global_node_page_state(NR_ACTIVE_ANON) |
1655 | + global_node_page_state(NR_INACTIVE_ANON) | 1655 | + global_node_page_state(NR_INACTIVE_ANON) |
1656 | + global_node_page_state(NR_ACTIVE_FILE) | 1656 | + global_node_page_state(NR_ACTIVE_FILE) |
diff --git a/kernel/signal.c b/kernel/signal.c index 7e33f8c583e6..ed804a470dcd 100644 --- a/kernel/signal.c +++ b/kernel/signal.c | |||
@@ -1194,7 +1194,11 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t) | |||
1194 | recalc_sigpending_and_wake(t); | 1194 | recalc_sigpending_and_wake(t); |
1195 | } | 1195 | } |
1196 | } | 1196 | } |
1197 | if (action->sa.sa_handler == SIG_DFL) | 1197 | /* |
1198 | * Don't clear SIGNAL_UNKILLABLE for traced tasks, users won't expect | ||
1199 | * debugging to leave init killable. | ||
1200 | */ | ||
1201 | if (action->sa.sa_handler == SIG_DFL && !t->ptrace) | ||
1198 | t->signal->flags &= ~SIGNAL_UNKILLABLE; | 1202 | t->signal->flags &= ~SIGNAL_UNKILLABLE; |
1199 | ret = specific_send_sig_info(sig, info, t); | 1203 | ret = specific_send_sig_info(sig, info, t); |
1200 | spin_unlock_irqrestore(&t->sighand->siglock, flags); | 1204 | spin_unlock_irqrestore(&t->sighand->siglock, flags); |
diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c index 37385193a608..dc498b605d5d 100644 --- a/kernel/trace/bpf_trace.c +++ b/kernel/trace/bpf_trace.c | |||
@@ -204,10 +204,36 @@ BPF_CALL_5(bpf_trace_printk, char *, fmt, u32, fmt_size, u64, arg1, | |||
204 | fmt_cnt++; | 204 | fmt_cnt++; |
205 | } | 205 | } |
206 | 206 | ||
207 | return __trace_printk(1/* fake ip will not be printed */, fmt, | 207 | /* Horrid workaround for getting va_list handling working with different |
208 | mod[0] == 2 ? arg1 : mod[0] == 1 ? (long) arg1 : (u32) arg1, | 208 | * argument type combinations generically for 32 and 64 bit archs. |
209 | mod[1] == 2 ? arg2 : mod[1] == 1 ? (long) arg2 : (u32) arg2, | 209 | */ |
210 | mod[2] == 2 ? arg3 : mod[2] == 1 ? (long) arg3 : (u32) arg3); | 210 | #define __BPF_TP_EMIT() __BPF_ARG3_TP() |
211 | #define __BPF_TP(...) \ | ||
212 | __trace_printk(1 /* Fake ip will not be printed. */, \ | ||
213 | fmt, ##__VA_ARGS__) | ||
214 | |||
215 | #define __BPF_ARG1_TP(...) \ | ||
216 | ((mod[0] == 2 || (mod[0] == 1 && __BITS_PER_LONG == 64)) \ | ||
217 | ? __BPF_TP(arg1, ##__VA_ARGS__) \ | ||
218 | : ((mod[0] == 1 || (mod[0] == 0 && __BITS_PER_LONG == 32)) \ | ||
219 | ? __BPF_TP((long)arg1, ##__VA_ARGS__) \ | ||
220 | : __BPF_TP((u32)arg1, ##__VA_ARGS__))) | ||
221 | |||
222 | #define __BPF_ARG2_TP(...) \ | ||
223 | ((mod[1] == 2 || (mod[1] == 1 && __BITS_PER_LONG == 64)) \ | ||
224 | ? __BPF_ARG1_TP(arg2, ##__VA_ARGS__) \ | ||
225 | : ((mod[1] == 1 || (mod[1] == 0 && __BITS_PER_LONG == 32)) \ | ||
226 | ? __BPF_ARG1_TP((long)arg2, ##__VA_ARGS__) \ | ||
227 | : __BPF_ARG1_TP((u32)arg2, ##__VA_ARGS__))) | ||
228 | |||
229 | #define __BPF_ARG3_TP(...) \ | ||
230 | ((mod[2] == 2 || (mod[2] == 1 && __BITS_PER_LONG == 64)) \ | ||
231 | ? __BPF_ARG2_TP(arg3, ##__VA_ARGS__) \ | ||
232 | : ((mod[2] == 1 || (mod[2] == 0 && __BITS_PER_LONG == 32)) \ | ||
233 | ? __BPF_ARG2_TP((long)arg3, ##__VA_ARGS__) \ | ||
234 | : __BPF_ARG2_TP((u32)arg3, ##__VA_ARGS__))) | ||
235 | |||
236 | return __BPF_TP_EMIT(); | ||
211 | } | 237 | } |
212 | 238 | ||
213 | static const struct bpf_func_proto bpf_trace_printk_proto = { | 239 | static const struct bpf_func_proto bpf_trace_printk_proto = { |
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index 02004ae91860..96cea88fa00f 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c | |||
@@ -889,6 +889,10 @@ static int profile_graph_entry(struct ftrace_graph_ent *trace) | |||
889 | 889 | ||
890 | function_profile_call(trace->func, 0, NULL, NULL); | 890 | function_profile_call(trace->func, 0, NULL, NULL); |
891 | 891 | ||
892 | /* If function graph is shutting down, ret_stack can be NULL */ | ||
893 | if (!current->ret_stack) | ||
894 | return 0; | ||
895 | |||
892 | if (index >= 0 && index < FTRACE_RETFUNC_DEPTH) | 896 | if (index >= 0 && index < FTRACE_RETFUNC_DEPTH) |
893 | current->ret_stack[index].subtime = 0; | 897 | current->ret_stack[index].subtime = 0; |
894 | 898 | ||
diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c index 529cc50d7243..81279c6602ff 100644 --- a/kernel/trace/ring_buffer.c +++ b/kernel/trace/ring_buffer.c | |||
@@ -4386,15 +4386,19 @@ EXPORT_SYMBOL_GPL(ring_buffer_swap_cpu); | |||
4386 | * the page that was allocated, with the read page of the buffer. | 4386 | * the page that was allocated, with the read page of the buffer. |
4387 | * | 4387 | * |
4388 | * Returns: | 4388 | * Returns: |
4389 | * The page allocated, or NULL on error. | 4389 | * The page allocated, or ERR_PTR |
4390 | */ | 4390 | */ |
4391 | void *ring_buffer_alloc_read_page(struct ring_buffer *buffer, int cpu) | 4391 | void *ring_buffer_alloc_read_page(struct ring_buffer *buffer, int cpu) |
4392 | { | 4392 | { |
4393 | struct ring_buffer_per_cpu *cpu_buffer = buffer->buffers[cpu]; | 4393 | struct ring_buffer_per_cpu *cpu_buffer; |
4394 | struct buffer_data_page *bpage = NULL; | 4394 | struct buffer_data_page *bpage = NULL; |
4395 | unsigned long flags; | 4395 | unsigned long flags; |
4396 | struct page *page; | 4396 | struct page *page; |
4397 | 4397 | ||
4398 | if (!cpumask_test_cpu(cpu, buffer->cpumask)) | ||
4399 | return ERR_PTR(-ENODEV); | ||
4400 | |||
4401 | cpu_buffer = buffer->buffers[cpu]; | ||
4398 | local_irq_save(flags); | 4402 | local_irq_save(flags); |
4399 | arch_spin_lock(&cpu_buffer->lock); | 4403 | arch_spin_lock(&cpu_buffer->lock); |
4400 | 4404 | ||
@@ -4412,7 +4416,7 @@ void *ring_buffer_alloc_read_page(struct ring_buffer *buffer, int cpu) | |||
4412 | page = alloc_pages_node(cpu_to_node(cpu), | 4416 | page = alloc_pages_node(cpu_to_node(cpu), |
4413 | GFP_KERNEL | __GFP_NORETRY, 0); | 4417 | GFP_KERNEL | __GFP_NORETRY, 0); |
4414 | if (!page) | 4418 | if (!page) |
4415 | return NULL; | 4419 | return ERR_PTR(-ENOMEM); |
4416 | 4420 | ||
4417 | bpage = page_address(page); | 4421 | bpage = page_address(page); |
4418 | 4422 | ||
@@ -4467,8 +4471,8 @@ EXPORT_SYMBOL_GPL(ring_buffer_free_read_page); | |||
4467 | * | 4471 | * |
4468 | * for example: | 4472 | * for example: |
4469 | * rpage = ring_buffer_alloc_read_page(buffer, cpu); | 4473 | * rpage = ring_buffer_alloc_read_page(buffer, cpu); |
4470 | * if (!rpage) | 4474 | * if (IS_ERR(rpage)) |
4471 | * return error; | 4475 | * return PTR_ERR(rpage); |
4472 | * ret = ring_buffer_read_page(buffer, &rpage, len, cpu, 0); | 4476 | * ret = ring_buffer_read_page(buffer, &rpage, len, cpu, 0); |
4473 | * if (ret >= 0) | 4477 | * if (ret >= 0) |
4474 | * process_page(rpage, ret); | 4478 | * process_page(rpage, ret); |
diff --git a/kernel/trace/ring_buffer_benchmark.c b/kernel/trace/ring_buffer_benchmark.c index 9fbcaf567886..68ee79afe31c 100644 --- a/kernel/trace/ring_buffer_benchmark.c +++ b/kernel/trace/ring_buffer_benchmark.c | |||
@@ -113,7 +113,7 @@ static enum event_status read_page(int cpu) | |||
113 | int i; | 113 | int i; |
114 | 114 | ||
115 | bpage = ring_buffer_alloc_read_page(buffer, cpu); | 115 | bpage = ring_buffer_alloc_read_page(buffer, cpu); |
116 | if (!bpage) | 116 | if (IS_ERR(bpage)) |
117 | return EVENT_DROPPED; | 117 | return EVENT_DROPPED; |
118 | 118 | ||
119 | ret = ring_buffer_read_page(buffer, &bpage, PAGE_SIZE, cpu, 1); | 119 | ret = ring_buffer_read_page(buffer, &bpage, PAGE_SIZE, cpu, 1); |
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 42b9355033d4..44004d8aa3b3 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c | |||
@@ -6598,7 +6598,7 @@ tracing_buffers_read(struct file *filp, char __user *ubuf, | |||
6598 | { | 6598 | { |
6599 | struct ftrace_buffer_info *info = filp->private_data; | 6599 | struct ftrace_buffer_info *info = filp->private_data; |
6600 | struct trace_iterator *iter = &info->iter; | 6600 | struct trace_iterator *iter = &info->iter; |
6601 | ssize_t ret; | 6601 | ssize_t ret = 0; |
6602 | ssize_t size; | 6602 | ssize_t size; |
6603 | 6603 | ||
6604 | if (!count) | 6604 | if (!count) |
@@ -6612,10 +6612,15 @@ tracing_buffers_read(struct file *filp, char __user *ubuf, | |||
6612 | if (!info->spare) { | 6612 | if (!info->spare) { |
6613 | info->spare = ring_buffer_alloc_read_page(iter->trace_buffer->buffer, | 6613 | info->spare = ring_buffer_alloc_read_page(iter->trace_buffer->buffer, |
6614 | iter->cpu_file); | 6614 | iter->cpu_file); |
6615 | info->spare_cpu = iter->cpu_file; | 6615 | if (IS_ERR(info->spare)) { |
6616 | ret = PTR_ERR(info->spare); | ||
6617 | info->spare = NULL; | ||
6618 | } else { | ||
6619 | info->spare_cpu = iter->cpu_file; | ||
6620 | } | ||
6616 | } | 6621 | } |
6617 | if (!info->spare) | 6622 | if (!info->spare) |
6618 | return -ENOMEM; | 6623 | return ret; |
6619 | 6624 | ||
6620 | /* Do we have previous read data to read? */ | 6625 | /* Do we have previous read data to read? */ |
6621 | if (info->read < PAGE_SIZE) | 6626 | if (info->read < PAGE_SIZE) |
@@ -6790,8 +6795,9 @@ tracing_buffers_splice_read(struct file *file, loff_t *ppos, | |||
6790 | ref->ref = 1; | 6795 | ref->ref = 1; |
6791 | ref->buffer = iter->trace_buffer->buffer; | 6796 | ref->buffer = iter->trace_buffer->buffer; |
6792 | ref->page = ring_buffer_alloc_read_page(ref->buffer, iter->cpu_file); | 6797 | ref->page = ring_buffer_alloc_read_page(ref->buffer, iter->cpu_file); |
6793 | if (!ref->page) { | 6798 | if (IS_ERR(ref->page)) { |
6794 | ret = -ENOMEM; | 6799 | ret = PTR_ERR(ref->page); |
6800 | ref->page = NULL; | ||
6795 | kfree(ref); | 6801 | kfree(ref); |
6796 | break; | 6802 | break; |
6797 | } | 6803 | } |
@@ -8293,6 +8299,7 @@ __init static int tracer_alloc_buffers(void) | |||
8293 | if (ret < 0) | 8299 | if (ret < 0) |
8294 | goto out_free_cpumask; | 8300 | goto out_free_cpumask; |
8295 | /* Used for event triggers */ | 8301 | /* Used for event triggers */ |
8302 | ret = -ENOMEM; | ||
8296 | temp_buffer = ring_buffer_alloc(PAGE_SIZE, RB_FL_OVERWRITE); | 8303 | temp_buffer = ring_buffer_alloc(PAGE_SIZE, RB_FL_OVERWRITE); |
8297 | if (!temp_buffer) | 8304 | if (!temp_buffer) |
8298 | goto out_rm_hp_state; | 8305 | goto out_rm_hp_state; |
@@ -8407,4 +8414,4 @@ __init static int clear_boot_tracer(void) | |||
8407 | } | 8414 | } |
8408 | 8415 | ||
8409 | fs_initcall(tracer_init_tracefs); | 8416 | fs_initcall(tracer_init_tracefs); |
8410 | late_initcall(clear_boot_tracer); | 8417 | late_initcall_sync(clear_boot_tracer); |
diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c index 59a411ff60c7..181e139a8057 100644 --- a/kernel/trace/trace_events_filter.c +++ b/kernel/trace/trace_events_filter.c | |||
@@ -1959,6 +1959,10 @@ static int create_filter(struct trace_event_call *call, | |||
1959 | if (err && set_str) | 1959 | if (err && set_str) |
1960 | append_filter_err(ps, filter); | 1960 | append_filter_err(ps, filter); |
1961 | } | 1961 | } |
1962 | if (err && !set_str) { | ||
1963 | free_event_filter(filter); | ||
1964 | filter = NULL; | ||
1965 | } | ||
1962 | create_filter_finish(ps); | 1966 | create_filter_finish(ps); |
1963 | 1967 | ||
1964 | *filterp = filter; | 1968 | *filterp = filter; |
diff --git a/kernel/trace/tracing_map.c b/kernel/trace/tracing_map.c index 0a689bbb78ef..305039b122fa 100644 --- a/kernel/trace/tracing_map.c +++ b/kernel/trace/tracing_map.c | |||
@@ -221,16 +221,19 @@ void tracing_map_array_free(struct tracing_map_array *a) | |||
221 | if (!a) | 221 | if (!a) |
222 | return; | 222 | return; |
223 | 223 | ||
224 | if (!a->pages) { | 224 | if (!a->pages) |
225 | kfree(a); | 225 | goto free; |
226 | return; | ||
227 | } | ||
228 | 226 | ||
229 | for (i = 0; i < a->n_pages; i++) { | 227 | for (i = 0; i < a->n_pages; i++) { |
230 | if (!a->pages[i]) | 228 | if (!a->pages[i]) |
231 | break; | 229 | break; |
232 | free_page((unsigned long)a->pages[i]); | 230 | free_page((unsigned long)a->pages[i]); |
233 | } | 231 | } |
232 | |||
233 | kfree(a->pages); | ||
234 | |||
235 | free: | ||
236 | kfree(a); | ||
234 | } | 237 | } |
235 | 238 | ||
236 | struct tracing_map_array *tracing_map_array_alloc(unsigned int n_elts, | 239 | struct tracing_map_array *tracing_map_array_alloc(unsigned int n_elts, |
diff --git a/kernel/watchdog.c b/kernel/watchdog.c index 06d3389bca0d..f5d52024f6b7 100644 --- a/kernel/watchdog.c +++ b/kernel/watchdog.c | |||
@@ -240,6 +240,7 @@ static void set_sample_period(void) | |||
240 | * hardlockup detector generates a warning | 240 | * hardlockup detector generates a warning |
241 | */ | 241 | */ |
242 | sample_period = get_softlockup_thresh() * ((u64)NSEC_PER_SEC / 5); | 242 | sample_period = get_softlockup_thresh() * ((u64)NSEC_PER_SEC / 5); |
243 | watchdog_update_hrtimer_threshold(sample_period); | ||
243 | } | 244 | } |
244 | 245 | ||
245 | /* Commands for resetting the watchdog */ | 246 | /* Commands for resetting the watchdog */ |
diff --git a/kernel/watchdog_hld.c b/kernel/watchdog_hld.c index 295a0d84934c..3a09ea1b1d3d 100644 --- a/kernel/watchdog_hld.c +++ b/kernel/watchdog_hld.c | |||
@@ -37,6 +37,62 @@ void arch_touch_nmi_watchdog(void) | |||
37 | } | 37 | } |
38 | EXPORT_SYMBOL(arch_touch_nmi_watchdog); | 38 | EXPORT_SYMBOL(arch_touch_nmi_watchdog); |
39 | 39 | ||
40 | #ifdef CONFIG_HARDLOCKUP_CHECK_TIMESTAMP | ||
41 | static DEFINE_PER_CPU(ktime_t, last_timestamp); | ||
42 | static DEFINE_PER_CPU(unsigned int, nmi_rearmed); | ||
43 | static ktime_t watchdog_hrtimer_sample_threshold __read_mostly; | ||
44 | |||
45 | void watchdog_update_hrtimer_threshold(u64 period) | ||
46 | { | ||
47 | /* | ||
48 | * The hrtimer runs with a period of (watchdog_threshold * 2) / 5 | ||
49 | * | ||
50 | * So it runs effectively with 2.5 times the rate of the NMI | ||
51 | * watchdog. That means the hrtimer should fire 2-3 times before | ||
52 | * the NMI watchdog expires. The NMI watchdog on x86 is based on | ||
53 | * unhalted CPU cycles, so if Turbo-Mode is enabled the CPU cycles | ||
54 | * might run way faster than expected and the NMI fires in a | ||
55 | * smaller period than the one deduced from the nominal CPU | ||
56 | * frequency. Depending on the Turbo-Mode factor this might be fast | ||
57 | * enough to get the NMI period smaller than the hrtimer watchdog | ||
58 | * period and trigger false positives. | ||
59 | * | ||
60 | * The sample threshold is used to check in the NMI handler whether | ||
61 | * the minimum time between two NMI samples has elapsed. That | ||
62 | * prevents false positives. | ||
63 | * | ||
64 | * Set this to 4/5 of the actual watchdog threshold period so the | ||
65 | * hrtimer is guaranteed to fire at least once within the real | ||
66 | * watchdog threshold. | ||
67 | */ | ||
68 | watchdog_hrtimer_sample_threshold = period * 2; | ||
69 | } | ||
70 | |||
71 | static bool watchdog_check_timestamp(void) | ||
72 | { | ||
73 | ktime_t delta, now = ktime_get_mono_fast_ns(); | ||
74 | |||
75 | delta = now - __this_cpu_read(last_timestamp); | ||
76 | if (delta < watchdog_hrtimer_sample_threshold) { | ||
77 | /* | ||
78 | * If ktime is jiffies based, a stalled timer would prevent | ||
79 | * jiffies from being incremented and the filter would look | ||
80 | * at a stale timestamp and never trigger. | ||
81 | */ | ||
82 | if (__this_cpu_inc_return(nmi_rearmed) < 10) | ||
83 | return false; | ||
84 | } | ||
85 | __this_cpu_write(nmi_rearmed, 0); | ||
86 | __this_cpu_write(last_timestamp, now); | ||
87 | return true; | ||
88 | } | ||
89 | #else | ||
90 | static inline bool watchdog_check_timestamp(void) | ||
91 | { | ||
92 | return true; | ||
93 | } | ||
94 | #endif | ||
95 | |||
40 | static struct perf_event_attr wd_hw_attr = { | 96 | static struct perf_event_attr wd_hw_attr = { |
41 | .type = PERF_TYPE_HARDWARE, | 97 | .type = PERF_TYPE_HARDWARE, |
42 | .config = PERF_COUNT_HW_CPU_CYCLES, | 98 | .config = PERF_COUNT_HW_CPU_CYCLES, |
@@ -61,6 +117,9 @@ static void watchdog_overflow_callback(struct perf_event *event, | |||
61 | return; | 117 | return; |
62 | } | 118 | } |
63 | 119 | ||
120 | if (!watchdog_check_timestamp()) | ||
121 | return; | ||
122 | |||
64 | /* check for a hardlockup | 123 | /* check for a hardlockup |
65 | * This is done by making sure our timer interrupt | 124 | * This is done by making sure our timer interrupt |
66 | * is incrementing. The timer interrupt should have | 125 | * is incrementing. The timer interrupt should have |
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 98fe715522e8..c617b9d1d6cb 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug | |||
@@ -798,6 +798,13 @@ config HARDLOCKUP_DETECTOR_PERF | |||
798 | select SOFTLOCKUP_DETECTOR | 798 | select SOFTLOCKUP_DETECTOR |
799 | 799 | ||
800 | # | 800 | # |
801 | # Enables a timestamp based low pass filter to compensate for perf based | ||
802 | # hard lockup detection which runs too fast due to turbo modes. | ||
803 | # | ||
804 | config HARDLOCKUP_CHECK_TIMESTAMP | ||
805 | bool | ||
806 | |||
807 | # | ||
801 | # arch/ can define HAVE_HARDLOCKUP_DETECTOR_ARCH to provide their own hard | 808 | # arch/ can define HAVE_HARDLOCKUP_DETECTOR_ARCH to provide their own hard |
802 | # lockup detector rather than the perf based detector. | 809 | # lockup detector rather than the perf based detector. |
803 | # | 810 | # |
diff --git a/lib/fault-inject.c b/lib/fault-inject.c index 7d315fdb9f13..cf7b129b0b2b 100644 --- a/lib/fault-inject.c +++ b/lib/fault-inject.c | |||
@@ -110,10 +110,12 @@ bool should_fail(struct fault_attr *attr, ssize_t size) | |||
110 | if (in_task()) { | 110 | if (in_task()) { |
111 | unsigned int fail_nth = READ_ONCE(current->fail_nth); | 111 | unsigned int fail_nth = READ_ONCE(current->fail_nth); |
112 | 112 | ||
113 | if (fail_nth && !WRITE_ONCE(current->fail_nth, fail_nth - 1)) | 113 | if (fail_nth) { |
114 | goto fail; | 114 | if (!WRITE_ONCE(current->fail_nth, fail_nth - 1)) |
115 | goto fail; | ||
115 | 116 | ||
116 | return false; | 117 | return false; |
118 | } | ||
117 | } | 119 | } |
118 | 120 | ||
119 | /* No need to check any other properties if the probability is 0 */ | 121 | /* No need to check any other properties if the probability is 0 */ |
diff --git a/lib/swiotlb.c b/lib/swiotlb.c index a8d74a733a38..8c6c83ef57a4 100644 --- a/lib/swiotlb.c +++ b/lib/swiotlb.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include <linux/highmem.h> | 30 | #include <linux/highmem.h> |
31 | #include <linux/gfp.h> | 31 | #include <linux/gfp.h> |
32 | #include <linux/scatterlist.h> | 32 | #include <linux/scatterlist.h> |
33 | #include <linux/mem_encrypt.h> | ||
33 | 34 | ||
34 | #include <asm/io.h> | 35 | #include <asm/io.h> |
35 | #include <asm/dma.h> | 36 | #include <asm/dma.h> |
@@ -155,6 +156,15 @@ unsigned long swiotlb_size_or_default(void) | |||
155 | return size ? size : (IO_TLB_DEFAULT_SIZE); | 156 | return size ? size : (IO_TLB_DEFAULT_SIZE); |
156 | } | 157 | } |
157 | 158 | ||
159 | void __weak swiotlb_set_mem_attributes(void *vaddr, unsigned long size) { } | ||
160 | |||
161 | /* For swiotlb, clear memory encryption mask from dma addresses */ | ||
162 | static dma_addr_t swiotlb_phys_to_dma(struct device *hwdev, | ||
163 | phys_addr_t address) | ||
164 | { | ||
165 | return __sme_clr(phys_to_dma(hwdev, address)); | ||
166 | } | ||
167 | |||
158 | /* Note that this doesn't work with highmem page */ | 168 | /* Note that this doesn't work with highmem page */ |
159 | static dma_addr_t swiotlb_virt_to_bus(struct device *hwdev, | 169 | static dma_addr_t swiotlb_virt_to_bus(struct device *hwdev, |
160 | volatile void *address) | 170 | volatile void *address) |
@@ -183,6 +193,31 @@ void swiotlb_print_info(void) | |||
183 | bytes >> 20, vstart, vend - 1); | 193 | bytes >> 20, vstart, vend - 1); |
184 | } | 194 | } |
185 | 195 | ||
196 | /* | ||
197 | * Early SWIOTLB allocation may be too early to allow an architecture to | ||
198 | * perform the desired operations. This function allows the architecture to | ||
199 | * call SWIOTLB when the operations are possible. It needs to be called | ||
200 | * before the SWIOTLB memory is used. | ||
201 | */ | ||
202 | void __init swiotlb_update_mem_attributes(void) | ||
203 | { | ||
204 | void *vaddr; | ||
205 | unsigned long bytes; | ||
206 | |||
207 | if (no_iotlb_memory || late_alloc) | ||
208 | return; | ||
209 | |||
210 | vaddr = phys_to_virt(io_tlb_start); | ||
211 | bytes = PAGE_ALIGN(io_tlb_nslabs << IO_TLB_SHIFT); | ||
212 | swiotlb_set_mem_attributes(vaddr, bytes); | ||
213 | memset(vaddr, 0, bytes); | ||
214 | |||
215 | vaddr = phys_to_virt(io_tlb_overflow_buffer); | ||
216 | bytes = PAGE_ALIGN(io_tlb_overflow); | ||
217 | swiotlb_set_mem_attributes(vaddr, bytes); | ||
218 | memset(vaddr, 0, bytes); | ||
219 | } | ||
220 | |||
186 | int __init swiotlb_init_with_tbl(char *tlb, unsigned long nslabs, int verbose) | 221 | int __init swiotlb_init_with_tbl(char *tlb, unsigned long nslabs, int verbose) |
187 | { | 222 | { |
188 | void *v_overflow_buffer; | 223 | void *v_overflow_buffer; |
@@ -320,6 +355,7 @@ swiotlb_late_init_with_tbl(char *tlb, unsigned long nslabs) | |||
320 | io_tlb_start = virt_to_phys(tlb); | 355 | io_tlb_start = virt_to_phys(tlb); |
321 | io_tlb_end = io_tlb_start + bytes; | 356 | io_tlb_end = io_tlb_start + bytes; |
322 | 357 | ||
358 | swiotlb_set_mem_attributes(tlb, bytes); | ||
323 | memset(tlb, 0, bytes); | 359 | memset(tlb, 0, bytes); |
324 | 360 | ||
325 | /* | 361 | /* |
@@ -330,6 +366,8 @@ swiotlb_late_init_with_tbl(char *tlb, unsigned long nslabs) | |||
330 | if (!v_overflow_buffer) | 366 | if (!v_overflow_buffer) |
331 | goto cleanup2; | 367 | goto cleanup2; |
332 | 368 | ||
369 | swiotlb_set_mem_attributes(v_overflow_buffer, io_tlb_overflow); | ||
370 | memset(v_overflow_buffer, 0, io_tlb_overflow); | ||
333 | io_tlb_overflow_buffer = virt_to_phys(v_overflow_buffer); | 371 | io_tlb_overflow_buffer = virt_to_phys(v_overflow_buffer); |
334 | 372 | ||
335 | /* | 373 | /* |
@@ -469,6 +507,9 @@ phys_addr_t swiotlb_tbl_map_single(struct device *hwdev, | |||
469 | if (no_iotlb_memory) | 507 | if (no_iotlb_memory) |
470 | panic("Can not allocate SWIOTLB buffer earlier and can't now provide you with the DMA bounce buffer"); | 508 | panic("Can not allocate SWIOTLB buffer earlier and can't now provide you with the DMA bounce buffer"); |
471 | 509 | ||
510 | if (sme_active()) | ||
511 | pr_warn_once("SME is active and system is using DMA bounce buffers\n"); | ||
512 | |||
472 | mask = dma_get_seg_boundary(hwdev); | 513 | mask = dma_get_seg_boundary(hwdev); |
473 | 514 | ||
474 | tbl_dma_addr &= mask; | 515 | tbl_dma_addr &= mask; |
@@ -581,7 +622,7 @@ map_single(struct device *hwdev, phys_addr_t phys, size_t size, | |||
581 | return SWIOTLB_MAP_ERROR; | 622 | return SWIOTLB_MAP_ERROR; |
582 | } | 623 | } |
583 | 624 | ||
584 | start_dma_addr = phys_to_dma(hwdev, io_tlb_start); | 625 | start_dma_addr = swiotlb_phys_to_dma(hwdev, io_tlb_start); |
585 | return swiotlb_tbl_map_single(hwdev, start_dma_addr, phys, size, | 626 | return swiotlb_tbl_map_single(hwdev, start_dma_addr, phys, size, |
586 | dir, attrs); | 627 | dir, attrs); |
587 | } | 628 | } |
@@ -702,7 +743,7 @@ swiotlb_alloc_coherent(struct device *hwdev, size_t size, | |||
702 | goto err_warn; | 743 | goto err_warn; |
703 | 744 | ||
704 | ret = phys_to_virt(paddr); | 745 | ret = phys_to_virt(paddr); |
705 | dev_addr = phys_to_dma(hwdev, paddr); | 746 | dev_addr = swiotlb_phys_to_dma(hwdev, paddr); |
706 | 747 | ||
707 | /* Confirm address can be DMA'd by device */ | 748 | /* Confirm address can be DMA'd by device */ |
708 | if (dev_addr + size - 1 > dma_mask) { | 749 | if (dev_addr + size - 1 > dma_mask) { |
@@ -812,10 +853,10 @@ dma_addr_t swiotlb_map_page(struct device *dev, struct page *page, | |||
812 | map = map_single(dev, phys, size, dir, attrs); | 853 | map = map_single(dev, phys, size, dir, attrs); |
813 | if (map == SWIOTLB_MAP_ERROR) { | 854 | if (map == SWIOTLB_MAP_ERROR) { |
814 | swiotlb_full(dev, size, dir, 1); | 855 | swiotlb_full(dev, size, dir, 1); |
815 | return phys_to_dma(dev, io_tlb_overflow_buffer); | 856 | return swiotlb_phys_to_dma(dev, io_tlb_overflow_buffer); |
816 | } | 857 | } |
817 | 858 | ||
818 | dev_addr = phys_to_dma(dev, map); | 859 | dev_addr = swiotlb_phys_to_dma(dev, map); |
819 | 860 | ||
820 | /* Ensure that the address returned is DMA'ble */ | 861 | /* Ensure that the address returned is DMA'ble */ |
821 | if (dma_capable(dev, dev_addr, size)) | 862 | if (dma_capable(dev, dev_addr, size)) |
@@ -824,7 +865,7 @@ dma_addr_t swiotlb_map_page(struct device *dev, struct page *page, | |||
824 | attrs |= DMA_ATTR_SKIP_CPU_SYNC; | 865 | attrs |= DMA_ATTR_SKIP_CPU_SYNC; |
825 | swiotlb_tbl_unmap_single(dev, map, size, dir, attrs); | 866 | swiotlb_tbl_unmap_single(dev, map, size, dir, attrs); |
826 | 867 | ||
827 | return phys_to_dma(dev, io_tlb_overflow_buffer); | 868 | return swiotlb_phys_to_dma(dev, io_tlb_overflow_buffer); |
828 | } | 869 | } |
829 | EXPORT_SYMBOL_GPL(swiotlb_map_page); | 870 | EXPORT_SYMBOL_GPL(swiotlb_map_page); |
830 | 871 | ||
@@ -958,7 +999,7 @@ swiotlb_map_sg_attrs(struct device *hwdev, struct scatterlist *sgl, int nelems, | |||
958 | sg_dma_len(sgl) = 0; | 999 | sg_dma_len(sgl) = 0; |
959 | return 0; | 1000 | return 0; |
960 | } | 1001 | } |
961 | sg->dma_address = phys_to_dma(hwdev, map); | 1002 | sg->dma_address = swiotlb_phys_to_dma(hwdev, map); |
962 | } else | 1003 | } else |
963 | sg->dma_address = dev_addr; | 1004 | sg->dma_address = dev_addr; |
964 | sg_dma_len(sg) = sg->length; | 1005 | sg_dma_len(sg) = sg->length; |
@@ -1026,7 +1067,7 @@ EXPORT_SYMBOL(swiotlb_sync_sg_for_device); | |||
1026 | int | 1067 | int |
1027 | swiotlb_dma_mapping_error(struct device *hwdev, dma_addr_t dma_addr) | 1068 | swiotlb_dma_mapping_error(struct device *hwdev, dma_addr_t dma_addr) |
1028 | { | 1069 | { |
1029 | return (dma_addr == phys_to_dma(hwdev, io_tlb_overflow_buffer)); | 1070 | return (dma_addr == swiotlb_phys_to_dma(hwdev, io_tlb_overflow_buffer)); |
1030 | } | 1071 | } |
1031 | EXPORT_SYMBOL(swiotlb_dma_mapping_error); | 1072 | EXPORT_SYMBOL(swiotlb_dma_mapping_error); |
1032 | 1073 | ||
@@ -1039,6 +1080,6 @@ EXPORT_SYMBOL(swiotlb_dma_mapping_error); | |||
1039 | int | 1080 | int |
1040 | swiotlb_dma_supported(struct device *hwdev, u64 mask) | 1081 | swiotlb_dma_supported(struct device *hwdev, u64 mask) |
1041 | { | 1082 | { |
1042 | return phys_to_dma(hwdev, io_tlb_end - 1) <= mask; | 1083 | return swiotlb_phys_to_dma(hwdev, io_tlb_end - 1) <= mask; |
1043 | } | 1084 | } |
1044 | EXPORT_SYMBOL(swiotlb_dma_supported); | 1085 | EXPORT_SYMBOL(swiotlb_dma_supported); |
diff --git a/lib/test_kmod.c b/lib/test_kmod.c index 6c1d678bcf8b..ff9148969b92 100644 --- a/lib/test_kmod.c +++ b/lib/test_kmod.c | |||
@@ -485,7 +485,7 @@ static ssize_t config_show(struct device *dev, | |||
485 | config->test_driver); | 485 | config->test_driver); |
486 | else | 486 | else |
487 | len += snprintf(buf+len, PAGE_SIZE - len, | 487 | len += snprintf(buf+len, PAGE_SIZE - len, |
488 | "driver:\tEMTPY\n"); | 488 | "driver:\tEMPTY\n"); |
489 | 489 | ||
490 | if (config->test_fs) | 490 | if (config->test_fs) |
491 | len += snprintf(buf+len, PAGE_SIZE - len, | 491 | len += snprintf(buf+len, PAGE_SIZE - len, |
@@ -493,7 +493,7 @@ static ssize_t config_show(struct device *dev, | |||
493 | config->test_fs); | 493 | config->test_fs); |
494 | else | 494 | else |
495 | len += snprintf(buf+len, PAGE_SIZE - len, | 495 | len += snprintf(buf+len, PAGE_SIZE - len, |
496 | "fs:\tEMTPY\n"); | 496 | "fs:\tEMPTY\n"); |
497 | 497 | ||
498 | mutex_unlock(&test_dev->config_mutex); | 498 | mutex_unlock(&test_dev->config_mutex); |
499 | 499 | ||
@@ -746,11 +746,11 @@ static int trigger_config_run_type(struct kmod_test_device *test_dev, | |||
746 | strlen(test_str)); | 746 | strlen(test_str)); |
747 | break; | 747 | break; |
748 | case TEST_KMOD_FS_TYPE: | 748 | case TEST_KMOD_FS_TYPE: |
749 | break; | ||
750 | kfree_const(config->test_fs); | 749 | kfree_const(config->test_fs); |
751 | config->test_driver = NULL; | 750 | config->test_driver = NULL; |
752 | copied = config_copy_test_fs(config, test_str, | 751 | copied = config_copy_test_fs(config, test_str, |
753 | strlen(test_str)); | 752 | strlen(test_str)); |
753 | break; | ||
754 | default: | 754 | default: |
755 | mutex_unlock(&test_dev->config_mutex); | 755 | mutex_unlock(&test_dev->config_mutex); |
756 | return -EINVAL; | 756 | return -EINVAL; |
@@ -880,10 +880,10 @@ static int test_dev_config_update_uint_sync(struct kmod_test_device *test_dev, | |||
880 | int (*test_sync)(struct kmod_test_device *test_dev)) | 880 | int (*test_sync)(struct kmod_test_device *test_dev)) |
881 | { | 881 | { |
882 | int ret; | 882 | int ret; |
883 | long new; | 883 | unsigned long new; |
884 | unsigned int old_val; | 884 | unsigned int old_val; |
885 | 885 | ||
886 | ret = kstrtol(buf, 10, &new); | 886 | ret = kstrtoul(buf, 10, &new); |
887 | if (ret) | 887 | if (ret) |
888 | return ret; | 888 | return ret; |
889 | 889 | ||
@@ -918,9 +918,9 @@ static int test_dev_config_update_uint_range(struct kmod_test_device *test_dev, | |||
918 | unsigned int max) | 918 | unsigned int max) |
919 | { | 919 | { |
920 | int ret; | 920 | int ret; |
921 | long new; | 921 | unsigned long new; |
922 | 922 | ||
923 | ret = kstrtol(buf, 10, &new); | 923 | ret = kstrtoul(buf, 10, &new); |
924 | if (ret) | 924 | if (ret) |
925 | return ret; | 925 | return ret; |
926 | 926 | ||
@@ -1146,7 +1146,7 @@ static struct kmod_test_device *register_test_dev_kmod(void) | |||
1146 | struct kmod_test_device *test_dev = NULL; | 1146 | struct kmod_test_device *test_dev = NULL; |
1147 | int ret; | 1147 | int ret; |
1148 | 1148 | ||
1149 | mutex_unlock(®_dev_mutex); | 1149 | mutex_lock(®_dev_mutex); |
1150 | 1150 | ||
1151 | /* int should suffice for number of devices, test for wrap */ | 1151 | /* int should suffice for number of devices, test for wrap */ |
1152 | if (unlikely(num_test_devs + 1) < 0) { | 1152 | if (unlikely(num_test_devs + 1) < 0) { |
diff --git a/mm/balloon_compaction.c b/mm/balloon_compaction.c index 9075aa54e955..b06d9fe23a28 100644 --- a/mm/balloon_compaction.c +++ b/mm/balloon_compaction.c | |||
@@ -24,7 +24,7 @@ struct page *balloon_page_enqueue(struct balloon_dev_info *b_dev_info) | |||
24 | { | 24 | { |
25 | unsigned long flags; | 25 | unsigned long flags; |
26 | struct page *page = alloc_page(balloon_mapping_gfp_mask() | | 26 | struct page *page = alloc_page(balloon_mapping_gfp_mask() | |
27 | __GFP_NOMEMALLOC | __GFP_NORETRY | __GFP_ZERO); | 27 | __GFP_NOMEMALLOC | __GFP_NORETRY); |
28 | if (!page) | 28 | if (!page) |
29 | return NULL; | 29 | return NULL; |
30 | 30 | ||
diff --git a/mm/cma_debug.c b/mm/cma_debug.c index 595b757bef72..c03ccbc405a0 100644 --- a/mm/cma_debug.c +++ b/mm/cma_debug.c | |||
@@ -167,7 +167,7 @@ static void cma_debugfs_add_one(struct cma *cma, int idx) | |||
167 | char name[16]; | 167 | char name[16]; |
168 | int u32s; | 168 | int u32s; |
169 | 169 | ||
170 | sprintf(name, "cma-%s", cma->name); | 170 | scnprintf(name, sizeof(name), "cma-%s", cma->name); |
171 | 171 | ||
172 | tmp = debugfs_create_dir(name, cma_debugfs_root); | 172 | tmp = debugfs_create_dir(name, cma_debugfs_root); |
173 | 173 | ||
diff --git a/mm/debug.c b/mm/debug.c index db1cd26d8752..5715448ab0b5 100644 --- a/mm/debug.c +++ b/mm/debug.c | |||
@@ -124,9 +124,7 @@ void dump_mm(const struct mm_struct *mm) | |||
124 | #ifdef CONFIG_NUMA_BALANCING | 124 | #ifdef CONFIG_NUMA_BALANCING |
125 | "numa_next_scan %lu numa_scan_offset %lu numa_scan_seq %d\n" | 125 | "numa_next_scan %lu numa_scan_offset %lu numa_scan_seq %d\n" |
126 | #endif | 126 | #endif |
127 | #if defined(CONFIG_NUMA_BALANCING) || defined(CONFIG_COMPACTION) | ||
128 | "tlb_flush_pending %d\n" | 127 | "tlb_flush_pending %d\n" |
129 | #endif | ||
130 | "def_flags: %#lx(%pGv)\n", | 128 | "def_flags: %#lx(%pGv)\n", |
131 | 129 | ||
132 | mm, mm->mmap, mm->vmacache_seqnum, mm->task_size, | 130 | mm, mm->mmap, mm->vmacache_seqnum, mm->task_size, |
@@ -158,9 +156,7 @@ void dump_mm(const struct mm_struct *mm) | |||
158 | #ifdef CONFIG_NUMA_BALANCING | 156 | #ifdef CONFIG_NUMA_BALANCING |
159 | mm->numa_next_scan, mm->numa_scan_offset, mm->numa_scan_seq, | 157 | mm->numa_next_scan, mm->numa_scan_offset, mm->numa_scan_seq, |
160 | #endif | 158 | #endif |
161 | #if defined(CONFIG_NUMA_BALANCING) || defined(CONFIG_COMPACTION) | 159 | atomic_read(&mm->tlb_flush_pending), |
162 | mm->tlb_flush_pending, | ||
163 | #endif | ||
164 | mm->def_flags, &mm->def_flags | 160 | mm->def_flags, &mm->def_flags |
165 | ); | 161 | ); |
166 | } | 162 | } |
diff --git a/mm/early_ioremap.c b/mm/early_ioremap.c index 6d5717bd7197..b1dd4a948fc0 100644 --- a/mm/early_ioremap.c +++ b/mm/early_ioremap.c | |||
@@ -30,6 +30,13 @@ early_param("early_ioremap_debug", early_ioremap_debug_setup); | |||
30 | 30 | ||
31 | static int after_paging_init __initdata; | 31 | static int after_paging_init __initdata; |
32 | 32 | ||
33 | pgprot_t __init __weak early_memremap_pgprot_adjust(resource_size_t phys_addr, | ||
34 | unsigned long size, | ||
35 | pgprot_t prot) | ||
36 | { | ||
37 | return prot; | ||
38 | } | ||
39 | |||
33 | void __init __weak early_ioremap_shutdown(void) | 40 | void __init __weak early_ioremap_shutdown(void) |
34 | { | 41 | { |
35 | } | 42 | } |
@@ -215,14 +222,29 @@ early_ioremap(resource_size_t phys_addr, unsigned long size) | |||
215 | void __init * | 222 | void __init * |
216 | early_memremap(resource_size_t phys_addr, unsigned long size) | 223 | early_memremap(resource_size_t phys_addr, unsigned long size) |
217 | { | 224 | { |
218 | return (__force void *)__early_ioremap(phys_addr, size, | 225 | pgprot_t prot = early_memremap_pgprot_adjust(phys_addr, size, |
219 | FIXMAP_PAGE_NORMAL); | 226 | FIXMAP_PAGE_NORMAL); |
227 | |||
228 | return (__force void *)__early_ioremap(phys_addr, size, prot); | ||
220 | } | 229 | } |
221 | #ifdef FIXMAP_PAGE_RO | 230 | #ifdef FIXMAP_PAGE_RO |
222 | void __init * | 231 | void __init * |
223 | early_memremap_ro(resource_size_t phys_addr, unsigned long size) | 232 | early_memremap_ro(resource_size_t phys_addr, unsigned long size) |
224 | { | 233 | { |
225 | return (__force void *)__early_ioremap(phys_addr, size, FIXMAP_PAGE_RO); | 234 | pgprot_t prot = early_memremap_pgprot_adjust(phys_addr, size, |
235 | FIXMAP_PAGE_RO); | ||
236 | |||
237 | return (__force void *)__early_ioremap(phys_addr, size, prot); | ||
238 | } | ||
239 | #endif | ||
240 | |||
241 | #ifdef CONFIG_ARCH_USE_MEMREMAP_PROT | ||
242 | void __init * | ||
243 | early_memremap_prot(resource_size_t phys_addr, unsigned long size, | ||
244 | unsigned long prot_val) | ||
245 | { | ||
246 | return (__force void *)__early_ioremap(phys_addr, size, | ||
247 | __pgprot(prot_val)); | ||
226 | } | 248 | } |
227 | #endif | 249 | #endif |
228 | 250 | ||
diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 86975dec0ba1..90731e3b7e58 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c | |||
@@ -32,6 +32,7 @@ | |||
32 | #include <linux/userfaultfd_k.h> | 32 | #include <linux/userfaultfd_k.h> |
33 | #include <linux/page_idle.h> | 33 | #include <linux/page_idle.h> |
34 | #include <linux/shmem_fs.h> | 34 | #include <linux/shmem_fs.h> |
35 | #include <linux/oom.h> | ||
35 | 36 | ||
36 | #include <asm/tlb.h> | 37 | #include <asm/tlb.h> |
37 | #include <asm/pgalloc.h> | 38 | #include <asm/pgalloc.h> |
@@ -550,6 +551,7 @@ static int __do_huge_pmd_anonymous_page(struct vm_fault *vmf, struct page *page, | |||
550 | struct mem_cgroup *memcg; | 551 | struct mem_cgroup *memcg; |
551 | pgtable_t pgtable; | 552 | pgtable_t pgtable; |
552 | unsigned long haddr = vmf->address & HPAGE_PMD_MASK; | 553 | unsigned long haddr = vmf->address & HPAGE_PMD_MASK; |
554 | int ret = 0; | ||
553 | 555 | ||
554 | VM_BUG_ON_PAGE(!PageCompound(page), page); | 556 | VM_BUG_ON_PAGE(!PageCompound(page), page); |
555 | 557 | ||
@@ -561,9 +563,8 @@ static int __do_huge_pmd_anonymous_page(struct vm_fault *vmf, struct page *page, | |||
561 | 563 | ||
562 | pgtable = pte_alloc_one(vma->vm_mm, haddr); | 564 | pgtable = pte_alloc_one(vma->vm_mm, haddr); |
563 | if (unlikely(!pgtable)) { | 565 | if (unlikely(!pgtable)) { |
564 | mem_cgroup_cancel_charge(page, memcg, true); | 566 | ret = VM_FAULT_OOM; |
565 | put_page(page); | 567 | goto release; |
566 | return VM_FAULT_OOM; | ||
567 | } | 568 | } |
568 | 569 | ||
569 | clear_huge_page(page, haddr, HPAGE_PMD_NR); | 570 | clear_huge_page(page, haddr, HPAGE_PMD_NR); |
@@ -576,13 +577,14 @@ static int __do_huge_pmd_anonymous_page(struct vm_fault *vmf, struct page *page, | |||
576 | 577 | ||
577 | vmf->ptl = pmd_lock(vma->vm_mm, vmf->pmd); | 578 | vmf->ptl = pmd_lock(vma->vm_mm, vmf->pmd); |
578 | if (unlikely(!pmd_none(*vmf->pmd))) { | 579 | if (unlikely(!pmd_none(*vmf->pmd))) { |
579 | spin_unlock(vmf->ptl); | 580 | goto unlock_release; |
580 | mem_cgroup_cancel_charge(page, memcg, true); | ||
581 | put_page(page); | ||
582 | pte_free(vma->vm_mm, pgtable); | ||
583 | } else { | 581 | } else { |
584 | pmd_t entry; | 582 | pmd_t entry; |
585 | 583 | ||
584 | ret = check_stable_address_space(vma->vm_mm); | ||
585 | if (ret) | ||
586 | goto unlock_release; | ||
587 | |||
586 | /* Deliver the page fault to userland */ | 588 | /* Deliver the page fault to userland */ |
587 | if (userfaultfd_missing(vma)) { | 589 | if (userfaultfd_missing(vma)) { |
588 | int ret; | 590 | int ret; |
@@ -610,6 +612,15 @@ static int __do_huge_pmd_anonymous_page(struct vm_fault *vmf, struct page *page, | |||
610 | } | 612 | } |
611 | 613 | ||
612 | return 0; | 614 | return 0; |
615 | unlock_release: | ||
616 | spin_unlock(vmf->ptl); | ||
617 | release: | ||
618 | if (pgtable) | ||
619 | pte_free(vma->vm_mm, pgtable); | ||
620 | mem_cgroup_cancel_charge(page, memcg, true); | ||
621 | put_page(page); | ||
622 | return ret; | ||
623 | |||
613 | } | 624 | } |
614 | 625 | ||
615 | /* | 626 | /* |
@@ -688,7 +699,10 @@ int do_huge_pmd_anonymous_page(struct vm_fault *vmf) | |||
688 | ret = 0; | 699 | ret = 0; |
689 | set = false; | 700 | set = false; |
690 | if (pmd_none(*vmf->pmd)) { | 701 | if (pmd_none(*vmf->pmd)) { |
691 | if (userfaultfd_missing(vma)) { | 702 | ret = check_stable_address_space(vma->vm_mm); |
703 | if (ret) { | ||
704 | spin_unlock(vmf->ptl); | ||
705 | } else if (userfaultfd_missing(vma)) { | ||
692 | spin_unlock(vmf->ptl); | 706 | spin_unlock(vmf->ptl); |
693 | ret = handle_userfault(vmf, VM_UFFD_MISSING); | 707 | ret = handle_userfault(vmf, VM_UFFD_MISSING); |
694 | VM_BUG_ON(ret & VM_FAULT_FALLBACK); | 708 | VM_BUG_ON(ret & VM_FAULT_FALLBACK); |
@@ -1496,6 +1510,13 @@ int do_huge_pmd_numa_page(struct vm_fault *vmf, pmd_t pmd) | |||
1496 | } | 1510 | } |
1497 | 1511 | ||
1498 | /* | 1512 | /* |
1513 | * The page_table_lock above provides a memory barrier | ||
1514 | * with change_protection_range. | ||
1515 | */ | ||
1516 | if (mm_tlb_flush_pending(vma->vm_mm)) | ||
1517 | flush_tlb_range(vma, haddr, haddr + HPAGE_PMD_SIZE); | ||
1518 | |||
1519 | /* | ||
1499 | * Migrate the THP to the requested node, returns with page unlocked | 1520 | * Migrate the THP to the requested node, returns with page unlocked |
1500 | * and access rights restored. | 1521 | * and access rights restored. |
1501 | */ | 1522 | */ |
diff --git a/mm/hugetlb.c b/mm/hugetlb.c index a1a0ac0ad6f6..31e207cb399b 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c | |||
@@ -4062,9 +4062,9 @@ out: | |||
4062 | return ret; | 4062 | return ret; |
4063 | out_release_unlock: | 4063 | out_release_unlock: |
4064 | spin_unlock(ptl); | 4064 | spin_unlock(ptl); |
4065 | out_release_nounlock: | ||
4066 | if (vm_shared) | 4065 | if (vm_shared) |
4067 | unlock_page(page); | 4066 | unlock_page(page); |
4067 | out_release_nounlock: | ||
4068 | put_page(page); | 4068 | put_page(page); |
4069 | goto out; | 4069 | goto out; |
4070 | } | 4070 | } |
@@ -1038,7 +1038,8 @@ static int write_protect_page(struct vm_area_struct *vma, struct page *page, | |||
1038 | goto out_unlock; | 1038 | goto out_unlock; |
1039 | 1039 | ||
1040 | if (pte_write(*pvmw.pte) || pte_dirty(*pvmw.pte) || | 1040 | if (pte_write(*pvmw.pte) || pte_dirty(*pvmw.pte) || |
1041 | (pte_protnone(*pvmw.pte) && pte_savedwrite(*pvmw.pte))) { | 1041 | (pte_protnone(*pvmw.pte) && pte_savedwrite(*pvmw.pte)) || |
1042 | mm_tlb_flush_pending(mm)) { | ||
1042 | pte_t entry; | 1043 | pte_t entry; |
1043 | 1044 | ||
1044 | swapped = PageSwapCache(page); | 1045 | swapped = PageSwapCache(page); |
diff --git a/mm/memblock.c b/mm/memblock.c index 2cb25fe4452c..bf14aea6ab70 100644 --- a/mm/memblock.c +++ b/mm/memblock.c | |||
@@ -285,31 +285,27 @@ static void __init_memblock memblock_remove_region(struct memblock_type *type, u | |||
285 | } | 285 | } |
286 | 286 | ||
287 | #ifdef CONFIG_ARCH_DISCARD_MEMBLOCK | 287 | #ifdef CONFIG_ARCH_DISCARD_MEMBLOCK |
288 | 288 | /** | |
289 | phys_addr_t __init_memblock get_allocated_memblock_reserved_regions_info( | 289 | * Discard memory and reserved arrays if they were allocated |
290 | phys_addr_t *addr) | 290 | */ |
291 | { | 291 | void __init memblock_discard(void) |
292 | if (memblock.reserved.regions == memblock_reserved_init_regions) | ||
293 | return 0; | ||
294 | |||
295 | *addr = __pa(memblock.reserved.regions); | ||
296 | |||
297 | return PAGE_ALIGN(sizeof(struct memblock_region) * | ||
298 | memblock.reserved.max); | ||
299 | } | ||
300 | |||
301 | phys_addr_t __init_memblock get_allocated_memblock_memory_regions_info( | ||
302 | phys_addr_t *addr) | ||
303 | { | 292 | { |
304 | if (memblock.memory.regions == memblock_memory_init_regions) | 293 | phys_addr_t addr, size; |
305 | return 0; | ||
306 | 294 | ||
307 | *addr = __pa(memblock.memory.regions); | 295 | if (memblock.reserved.regions != memblock_reserved_init_regions) { |
296 | addr = __pa(memblock.reserved.regions); | ||
297 | size = PAGE_ALIGN(sizeof(struct memblock_region) * | ||
298 | memblock.reserved.max); | ||
299 | __memblock_free_late(addr, size); | ||
300 | } | ||
308 | 301 | ||
309 | return PAGE_ALIGN(sizeof(struct memblock_region) * | 302 | if (memblock.memory.regions == memblock_memory_init_regions) { |
310 | memblock.memory.max); | 303 | addr = __pa(memblock.memory.regions); |
304 | size = PAGE_ALIGN(sizeof(struct memblock_region) * | ||
305 | memblock.memory.max); | ||
306 | __memblock_free_late(addr, size); | ||
307 | } | ||
311 | } | 308 | } |
312 | |||
313 | #endif | 309 | #endif |
314 | 310 | ||
315 | /** | 311 | /** |
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 3df3c04d73ab..e09741af816f 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c | |||
@@ -1611,9 +1611,13 @@ cleanup: | |||
1611 | * @page: the page | 1611 | * @page: the page |
1612 | * | 1612 | * |
1613 | * This function protects unlocked LRU pages from being moved to | 1613 | * This function protects unlocked LRU pages from being moved to |
1614 | * another cgroup and stabilizes their page->mem_cgroup binding. | 1614 | * another cgroup. |
1615 | * | ||
1616 | * It ensures lifetime of the returned memcg. Caller is responsible | ||
1617 | * for the lifetime of the page; __unlock_page_memcg() is available | ||
1618 | * when @page might get freed inside the locked section. | ||
1615 | */ | 1619 | */ |
1616 | void lock_page_memcg(struct page *page) | 1620 | struct mem_cgroup *lock_page_memcg(struct page *page) |
1617 | { | 1621 | { |
1618 | struct mem_cgroup *memcg; | 1622 | struct mem_cgroup *memcg; |
1619 | unsigned long flags; | 1623 | unsigned long flags; |
@@ -1622,18 +1626,24 @@ void lock_page_memcg(struct page *page) | |||
1622 | * The RCU lock is held throughout the transaction. The fast | 1626 | * The RCU lock is held throughout the transaction. The fast |
1623 | * path can get away without acquiring the memcg->move_lock | 1627 | * path can get away without acquiring the memcg->move_lock |
1624 | * because page moving starts with an RCU grace period. | 1628 | * because page moving starts with an RCU grace period. |
1625 | */ | 1629 | * |
1630 | * The RCU lock also protects the memcg from being freed when | ||
1631 | * the page state that is going to change is the only thing | ||
1632 | * preventing the page itself from being freed. E.g. writeback | ||
1633 | * doesn't hold a page reference and relies on PG_writeback to | ||
1634 | * keep off truncation, migration and so forth. | ||
1635 | */ | ||
1626 | rcu_read_lock(); | 1636 | rcu_read_lock(); |
1627 | 1637 | ||
1628 | if (mem_cgroup_disabled()) | 1638 | if (mem_cgroup_disabled()) |
1629 | return; | 1639 | return NULL; |
1630 | again: | 1640 | again: |
1631 | memcg = page->mem_cgroup; | 1641 | memcg = page->mem_cgroup; |
1632 | if (unlikely(!memcg)) | 1642 | if (unlikely(!memcg)) |
1633 | return; | 1643 | return NULL; |
1634 | 1644 | ||
1635 | if (atomic_read(&memcg->moving_account) <= 0) | 1645 | if (atomic_read(&memcg->moving_account) <= 0) |
1636 | return; | 1646 | return memcg; |
1637 | 1647 | ||
1638 | spin_lock_irqsave(&memcg->move_lock, flags); | 1648 | spin_lock_irqsave(&memcg->move_lock, flags); |
1639 | if (memcg != page->mem_cgroup) { | 1649 | if (memcg != page->mem_cgroup) { |
@@ -1649,18 +1659,18 @@ again: | |||
1649 | memcg->move_lock_task = current; | 1659 | memcg->move_lock_task = current; |
1650 | memcg->move_lock_flags = flags; | 1660 | memcg->move_lock_flags = flags; |
1651 | 1661 | ||
1652 | return; | 1662 | return memcg; |
1653 | } | 1663 | } |
1654 | EXPORT_SYMBOL(lock_page_memcg); | 1664 | EXPORT_SYMBOL(lock_page_memcg); |
1655 | 1665 | ||
1656 | /** | 1666 | /** |
1657 | * unlock_page_memcg - unlock a page->mem_cgroup binding | 1667 | * __unlock_page_memcg - unlock and unpin a memcg |
1658 | * @page: the page | 1668 | * @memcg: the memcg |
1669 | * | ||
1670 | * Unlock and unpin a memcg returned by lock_page_memcg(). | ||
1659 | */ | 1671 | */ |
1660 | void unlock_page_memcg(struct page *page) | 1672 | void __unlock_page_memcg(struct mem_cgroup *memcg) |
1661 | { | 1673 | { |
1662 | struct mem_cgroup *memcg = page->mem_cgroup; | ||
1663 | |||
1664 | if (memcg && memcg->move_lock_task == current) { | 1674 | if (memcg && memcg->move_lock_task == current) { |
1665 | unsigned long flags = memcg->move_lock_flags; | 1675 | unsigned long flags = memcg->move_lock_flags; |
1666 | 1676 | ||
@@ -1672,6 +1682,15 @@ void unlock_page_memcg(struct page *page) | |||
1672 | 1682 | ||
1673 | rcu_read_unlock(); | 1683 | rcu_read_unlock(); |
1674 | } | 1684 | } |
1685 | |||
1686 | /** | ||
1687 | * unlock_page_memcg - unlock a page->mem_cgroup binding | ||
1688 | * @page: the page | ||
1689 | */ | ||
1690 | void unlock_page_memcg(struct page *page) | ||
1691 | { | ||
1692 | __unlock_page_memcg(page->mem_cgroup); | ||
1693 | } | ||
1675 | EXPORT_SYMBOL(unlock_page_memcg); | 1694 | EXPORT_SYMBOL(unlock_page_memcg); |
1676 | 1695 | ||
1677 | /* | 1696 | /* |
diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 1cd3b3569af8..88366626c0b7 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c | |||
@@ -1146,6 +1146,8 @@ int memory_failure(unsigned long pfn, int trapno, int flags) | |||
1146 | return 0; | 1146 | return 0; |
1147 | } | 1147 | } |
1148 | 1148 | ||
1149 | arch_unmap_kpfn(pfn); | ||
1150 | |||
1149 | orig_head = hpage = compound_head(p); | 1151 | orig_head = hpage = compound_head(p); |
1150 | num_poisoned_pages_inc(); | 1152 | num_poisoned_pages_inc(); |
1151 | 1153 | ||
diff --git a/mm/memory.c b/mm/memory.c index f65beaad319b..fe2fba27ded2 100644 --- a/mm/memory.c +++ b/mm/memory.c | |||
@@ -68,6 +68,7 @@ | |||
68 | #include <linux/debugfs.h> | 68 | #include <linux/debugfs.h> |
69 | #include <linux/userfaultfd_k.h> | 69 | #include <linux/userfaultfd_k.h> |
70 | #include <linux/dax.h> | 70 | #include <linux/dax.h> |
71 | #include <linux/oom.h> | ||
71 | 72 | ||
72 | #include <asm/io.h> | 73 | #include <asm/io.h> |
73 | #include <asm/mmu_context.h> | 74 | #include <asm/mmu_context.h> |
@@ -215,12 +216,8 @@ static bool tlb_next_batch(struct mmu_gather *tlb) | |||
215 | return true; | 216 | return true; |
216 | } | 217 | } |
217 | 218 | ||
218 | /* tlb_gather_mmu | 219 | void arch_tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, |
219 | * Called to initialize an (on-stack) mmu_gather structure for page-table | 220 | unsigned long start, unsigned long end) |
220 | * tear-down from @mm. The @fullmm argument is used when @mm is without | ||
221 | * users and we're going to destroy the full address space (exit/execve). | ||
222 | */ | ||
223 | void tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, unsigned long start, unsigned long end) | ||
224 | { | 221 | { |
225 | tlb->mm = mm; | 222 | tlb->mm = mm; |
226 | 223 | ||
@@ -275,10 +272,14 @@ void tlb_flush_mmu(struct mmu_gather *tlb) | |||
275 | * Called at the end of the shootdown operation to free up any resources | 272 | * Called at the end of the shootdown operation to free up any resources |
276 | * that were required. | 273 | * that were required. |
277 | */ | 274 | */ |
278 | void tlb_finish_mmu(struct mmu_gather *tlb, unsigned long start, unsigned long end) | 275 | void arch_tlb_finish_mmu(struct mmu_gather *tlb, |
276 | unsigned long start, unsigned long end, bool force) | ||
279 | { | 277 | { |
280 | struct mmu_gather_batch *batch, *next; | 278 | struct mmu_gather_batch *batch, *next; |
281 | 279 | ||
280 | if (force) | ||
281 | __tlb_adjust_range(tlb, start, end - start); | ||
282 | |||
282 | tlb_flush_mmu(tlb); | 283 | tlb_flush_mmu(tlb); |
283 | 284 | ||
284 | /* keep the page table cache within bounds */ | 285 | /* keep the page table cache within bounds */ |
@@ -398,6 +399,34 @@ void tlb_remove_table(struct mmu_gather *tlb, void *table) | |||
398 | 399 | ||
399 | #endif /* CONFIG_HAVE_RCU_TABLE_FREE */ | 400 | #endif /* CONFIG_HAVE_RCU_TABLE_FREE */ |
400 | 401 | ||
402 | /* tlb_gather_mmu | ||
403 | * Called to initialize an (on-stack) mmu_gather structure for page-table | ||
404 | * tear-down from @mm. The @fullmm argument is used when @mm is without | ||
405 | * users and we're going to destroy the full address space (exit/execve). | ||
406 | */ | ||
407 | void tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, | ||
408 | unsigned long start, unsigned long end) | ||
409 | { | ||
410 | arch_tlb_gather_mmu(tlb, mm, start, end); | ||
411 | inc_tlb_flush_pending(tlb->mm); | ||
412 | } | ||
413 | |||
414 | void tlb_finish_mmu(struct mmu_gather *tlb, | ||
415 | unsigned long start, unsigned long end) | ||
416 | { | ||
417 | /* | ||
418 | * If there are parallel threads are doing PTE changes on same range | ||
419 | * under non-exclusive lock(e.g., mmap_sem read-side) but defer TLB | ||
420 | * flush by batching, a thread has stable TLB entry can fail to flush | ||
421 | * the TLB by observing pte_none|!pte_dirty, for example so flush TLB | ||
422 | * forcefully if we detect parallel PTE batching threads. | ||
423 | */ | ||
424 | bool force = mm_tlb_flush_nested(tlb->mm); | ||
425 | |||
426 | arch_tlb_finish_mmu(tlb, start, end, force); | ||
427 | dec_tlb_flush_pending(tlb->mm); | ||
428 | } | ||
429 | |||
401 | /* | 430 | /* |
402 | * Note: this doesn't free the actual pages themselves. That | 431 | * Note: this doesn't free the actual pages themselves. That |
403 | * has been handled earlier when unmapping all the memory regions. | 432 | * has been handled earlier when unmapping all the memory regions. |
@@ -2865,6 +2894,7 @@ static int do_anonymous_page(struct vm_fault *vmf) | |||
2865 | struct vm_area_struct *vma = vmf->vma; | 2894 | struct vm_area_struct *vma = vmf->vma; |
2866 | struct mem_cgroup *memcg; | 2895 | struct mem_cgroup *memcg; |
2867 | struct page *page; | 2896 | struct page *page; |
2897 | int ret = 0; | ||
2868 | pte_t entry; | 2898 | pte_t entry; |
2869 | 2899 | ||
2870 | /* File mapping without ->vm_ops ? */ | 2900 | /* File mapping without ->vm_ops ? */ |
@@ -2897,6 +2927,9 @@ static int do_anonymous_page(struct vm_fault *vmf) | |||
2897 | vmf->address, &vmf->ptl); | 2927 | vmf->address, &vmf->ptl); |
2898 | if (!pte_none(*vmf->pte)) | 2928 | if (!pte_none(*vmf->pte)) |
2899 | goto unlock; | 2929 | goto unlock; |
2930 | ret = check_stable_address_space(vma->vm_mm); | ||
2931 | if (ret) | ||
2932 | goto unlock; | ||
2900 | /* Deliver the page fault to userland, check inside PT lock */ | 2933 | /* Deliver the page fault to userland, check inside PT lock */ |
2901 | if (userfaultfd_missing(vma)) { | 2934 | if (userfaultfd_missing(vma)) { |
2902 | pte_unmap_unlock(vmf->pte, vmf->ptl); | 2935 | pte_unmap_unlock(vmf->pte, vmf->ptl); |
@@ -2931,6 +2964,10 @@ static int do_anonymous_page(struct vm_fault *vmf) | |||
2931 | if (!pte_none(*vmf->pte)) | 2964 | if (!pte_none(*vmf->pte)) |
2932 | goto release; | 2965 | goto release; |
2933 | 2966 | ||
2967 | ret = check_stable_address_space(vma->vm_mm); | ||
2968 | if (ret) | ||
2969 | goto release; | ||
2970 | |||
2934 | /* Deliver the page fault to userland, check inside PT lock */ | 2971 | /* Deliver the page fault to userland, check inside PT lock */ |
2935 | if (userfaultfd_missing(vma)) { | 2972 | if (userfaultfd_missing(vma)) { |
2936 | pte_unmap_unlock(vmf->pte, vmf->ptl); | 2973 | pte_unmap_unlock(vmf->pte, vmf->ptl); |
@@ -2950,7 +2987,7 @@ setpte: | |||
2950 | update_mmu_cache(vma, vmf->address, vmf->pte); | 2987 | update_mmu_cache(vma, vmf->address, vmf->pte); |
2951 | unlock: | 2988 | unlock: |
2952 | pte_unmap_unlock(vmf->pte, vmf->ptl); | 2989 | pte_unmap_unlock(vmf->pte, vmf->ptl); |
2953 | return 0; | 2990 | return ret; |
2954 | release: | 2991 | release: |
2955 | mem_cgroup_cancel_charge(page, memcg, false); | 2992 | mem_cgroup_cancel_charge(page, memcg, false); |
2956 | put_page(page); | 2993 | put_page(page); |
@@ -3224,7 +3261,7 @@ int alloc_set_pte(struct vm_fault *vmf, struct mem_cgroup *memcg, | |||
3224 | int finish_fault(struct vm_fault *vmf) | 3261 | int finish_fault(struct vm_fault *vmf) |
3225 | { | 3262 | { |
3226 | struct page *page; | 3263 | struct page *page; |
3227 | int ret; | 3264 | int ret = 0; |
3228 | 3265 | ||
3229 | /* Did we COW the page? */ | 3266 | /* Did we COW the page? */ |
3230 | if ((vmf->flags & FAULT_FLAG_WRITE) && | 3267 | if ((vmf->flags & FAULT_FLAG_WRITE) && |
@@ -3232,7 +3269,15 @@ int finish_fault(struct vm_fault *vmf) | |||
3232 | page = vmf->cow_page; | 3269 | page = vmf->cow_page; |
3233 | else | 3270 | else |
3234 | page = vmf->page; | 3271 | page = vmf->page; |
3235 | ret = alloc_set_pte(vmf, vmf->memcg, page); | 3272 | |
3273 | /* | ||
3274 | * check even for read faults because we might have lost our CoWed | ||
3275 | * page | ||
3276 | */ | ||
3277 | if (!(vmf->vma->vm_flags & VM_SHARED)) | ||
3278 | ret = check_stable_address_space(vmf->vma->vm_mm); | ||
3279 | if (!ret) | ||
3280 | ret = alloc_set_pte(vmf, vmf->memcg, page); | ||
3236 | if (vmf->pte) | 3281 | if (vmf->pte) |
3237 | pte_unmap_unlock(vmf->pte, vmf->ptl); | 3282 | pte_unmap_unlock(vmf->pte, vmf->ptl); |
3238 | return ret; | 3283 | return ret; |
@@ -3872,19 +3917,6 @@ int handle_mm_fault(struct vm_area_struct *vma, unsigned long address, | |||
3872 | mem_cgroup_oom_synchronize(false); | 3917 | mem_cgroup_oom_synchronize(false); |
3873 | } | 3918 | } |
3874 | 3919 | ||
3875 | /* | ||
3876 | * This mm has been already reaped by the oom reaper and so the | ||
3877 | * refault cannot be trusted in general. Anonymous refaults would | ||
3878 | * lose data and give a zero page instead e.g. This is especially | ||
3879 | * problem for use_mm() because regular tasks will just die and | ||
3880 | * the corrupted data will not be visible anywhere while kthread | ||
3881 | * will outlive the oom victim and potentially propagate the date | ||
3882 | * further. | ||
3883 | */ | ||
3884 | if (unlikely((current->flags & PF_KTHREAD) && !(ret & VM_FAULT_ERROR) | ||
3885 | && test_bit(MMF_UNSTABLE, &vma->vm_mm->flags))) | ||
3886 | ret = VM_FAULT_SIGBUS; | ||
3887 | |||
3888 | return ret; | 3920 | return ret; |
3889 | } | 3921 | } |
3890 | EXPORT_SYMBOL_GPL(handle_mm_fault); | 3922 | EXPORT_SYMBOL_GPL(handle_mm_fault); |
diff --git a/mm/mempolicy.c b/mm/mempolicy.c index d911fa5cb2a7..618ab125228b 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c | |||
@@ -861,11 +861,6 @@ static long do_get_mempolicy(int *policy, nodemask_t *nmask, | |||
861 | *policy |= (pol->flags & MPOL_MODE_FLAGS); | 861 | *policy |= (pol->flags & MPOL_MODE_FLAGS); |
862 | } | 862 | } |
863 | 863 | ||
864 | if (vma) { | ||
865 | up_read(¤t->mm->mmap_sem); | ||
866 | vma = NULL; | ||
867 | } | ||
868 | |||
869 | err = 0; | 864 | err = 0; |
870 | if (nmask) { | 865 | if (nmask) { |
871 | if (mpol_store_user_nodemask(pol)) { | 866 | if (mpol_store_user_nodemask(pol)) { |
diff --git a/mm/migrate.c b/mm/migrate.c index 627671551873..e84eeb4e4356 100644 --- a/mm/migrate.c +++ b/mm/migrate.c | |||
@@ -41,6 +41,7 @@ | |||
41 | #include <linux/page_idle.h> | 41 | #include <linux/page_idle.h> |
42 | #include <linux/page_owner.h> | 42 | #include <linux/page_owner.h> |
43 | #include <linux/sched/mm.h> | 43 | #include <linux/sched/mm.h> |
44 | #include <linux/ptrace.h> | ||
44 | 45 | ||
45 | #include <asm/tlbflush.h> | 46 | #include <asm/tlbflush.h> |
46 | 47 | ||
@@ -1652,7 +1653,6 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages, | |||
1652 | const int __user *, nodes, | 1653 | const int __user *, nodes, |
1653 | int __user *, status, int, flags) | 1654 | int __user *, status, int, flags) |
1654 | { | 1655 | { |
1655 | const struct cred *cred = current_cred(), *tcred; | ||
1656 | struct task_struct *task; | 1656 | struct task_struct *task; |
1657 | struct mm_struct *mm; | 1657 | struct mm_struct *mm; |
1658 | int err; | 1658 | int err; |
@@ -1676,14 +1676,9 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages, | |||
1676 | 1676 | ||
1677 | /* | 1677 | /* |
1678 | * Check if this process has the right to modify the specified | 1678 | * Check if this process has the right to modify the specified |
1679 | * process. The right exists if the process has administrative | 1679 | * process. Use the regular "ptrace_may_access()" checks. |
1680 | * capabilities, superuser privileges or the same | ||
1681 | * userid as the target process. | ||
1682 | */ | 1680 | */ |
1683 | tcred = __task_cred(task); | 1681 | if (!ptrace_may_access(task, PTRACE_MODE_READ_REALCREDS)) { |
1684 | if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) && | ||
1685 | !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) && | ||
1686 | !capable(CAP_SYS_NICE)) { | ||
1687 | rcu_read_unlock(); | 1682 | rcu_read_unlock(); |
1688 | err = -EPERM; | 1683 | err = -EPERM; |
1689 | goto out; | 1684 | goto out; |
@@ -1937,12 +1932,6 @@ int migrate_misplaced_transhuge_page(struct mm_struct *mm, | |||
1937 | put_page(new_page); | 1932 | put_page(new_page); |
1938 | goto out_fail; | 1933 | goto out_fail; |
1939 | } | 1934 | } |
1940 | /* | ||
1941 | * We are not sure a pending tlb flush here is for a huge page | ||
1942 | * mapping or not. Hence use the tlb range variant | ||
1943 | */ | ||
1944 | if (mm_tlb_flush_pending(mm)) | ||
1945 | flush_tlb_range(vma, mmun_start, mmun_end); | ||
1946 | 1935 | ||
1947 | /* Prepare a page as a migration target */ | 1936 | /* Prepare a page as a migration target */ |
1948 | __SetPageLocked(new_page); | 1937 | __SetPageLocked(new_page); |
diff --git a/mm/mprotect.c b/mm/mprotect.c index 4180ad8cc9c5..bd0f409922cb 100644 --- a/mm/mprotect.c +++ b/mm/mprotect.c | |||
@@ -244,7 +244,7 @@ static unsigned long change_protection_range(struct vm_area_struct *vma, | |||
244 | BUG_ON(addr >= end); | 244 | BUG_ON(addr >= end); |
245 | pgd = pgd_offset(mm, addr); | 245 | pgd = pgd_offset(mm, addr); |
246 | flush_cache_range(vma, addr, end); | 246 | flush_cache_range(vma, addr, end); |
247 | set_tlb_flush_pending(mm); | 247 | inc_tlb_flush_pending(mm); |
248 | do { | 248 | do { |
249 | next = pgd_addr_end(addr, end); | 249 | next = pgd_addr_end(addr, end); |
250 | if (pgd_none_or_clear_bad(pgd)) | 250 | if (pgd_none_or_clear_bad(pgd)) |
@@ -256,7 +256,7 @@ static unsigned long change_protection_range(struct vm_area_struct *vma, | |||
256 | /* Only flush the TLB if we actually modified any entries: */ | 256 | /* Only flush the TLB if we actually modified any entries: */ |
257 | if (pages) | 257 | if (pages) |
258 | flush_tlb_range(vma, start, end); | 258 | flush_tlb_range(vma, start, end); |
259 | clear_tlb_flush_pending(mm); | 259 | dec_tlb_flush_pending(mm); |
260 | 260 | ||
261 | return pages; | 261 | return pages; |
262 | } | 262 | } |
diff --git a/mm/nobootmem.c b/mm/nobootmem.c index 36454d0f96ee..3637809a18d0 100644 --- a/mm/nobootmem.c +++ b/mm/nobootmem.c | |||
@@ -146,22 +146,6 @@ static unsigned long __init free_low_memory_core_early(void) | |||
146 | NULL) | 146 | NULL) |
147 | count += __free_memory_core(start, end); | 147 | count += __free_memory_core(start, end); |
148 | 148 | ||
149 | #ifdef CONFIG_ARCH_DISCARD_MEMBLOCK | ||
150 | { | ||
151 | phys_addr_t size; | ||
152 | |||
153 | /* Free memblock.reserved array if it was allocated */ | ||
154 | size = get_allocated_memblock_reserved_regions_info(&start); | ||
155 | if (size) | ||
156 | count += __free_memory_core(start, start + size); | ||
157 | |||
158 | /* Free memblock.memory array if it was allocated */ | ||
159 | size = get_allocated_memblock_memory_regions_info(&start); | ||
160 | if (size) | ||
161 | count += __free_memory_core(start, start + size); | ||
162 | } | ||
163 | #endif | ||
164 | |||
165 | return count; | 149 | return count; |
166 | } | 150 | } |
167 | 151 | ||
diff --git a/mm/page-writeback.c b/mm/page-writeback.c index 96e93b214d31..bf050ab025b7 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c | |||
@@ -2724,9 +2724,12 @@ EXPORT_SYMBOL(clear_page_dirty_for_io); | |||
2724 | int test_clear_page_writeback(struct page *page) | 2724 | int test_clear_page_writeback(struct page *page) |
2725 | { | 2725 | { |
2726 | struct address_space *mapping = page_mapping(page); | 2726 | struct address_space *mapping = page_mapping(page); |
2727 | struct mem_cgroup *memcg; | ||
2728 | struct lruvec *lruvec; | ||
2727 | int ret; | 2729 | int ret; |
2728 | 2730 | ||
2729 | lock_page_memcg(page); | 2731 | memcg = lock_page_memcg(page); |
2732 | lruvec = mem_cgroup_page_lruvec(page, page_pgdat(page)); | ||
2730 | if (mapping && mapping_use_writeback_tags(mapping)) { | 2733 | if (mapping && mapping_use_writeback_tags(mapping)) { |
2731 | struct inode *inode = mapping->host; | 2734 | struct inode *inode = mapping->host; |
2732 | struct backing_dev_info *bdi = inode_to_bdi(inode); | 2735 | struct backing_dev_info *bdi = inode_to_bdi(inode); |
@@ -2754,12 +2757,18 @@ int test_clear_page_writeback(struct page *page) | |||
2754 | } else { | 2757 | } else { |
2755 | ret = TestClearPageWriteback(page); | 2758 | ret = TestClearPageWriteback(page); |
2756 | } | 2759 | } |
2760 | /* | ||
2761 | * NOTE: Page might be free now! Writeback doesn't hold a page | ||
2762 | * reference on its own, it relies on truncation to wait for | ||
2763 | * the clearing of PG_writeback. The below can only access | ||
2764 | * page state that is static across allocation cycles. | ||
2765 | */ | ||
2757 | if (ret) { | 2766 | if (ret) { |
2758 | dec_lruvec_page_state(page, NR_WRITEBACK); | 2767 | dec_lruvec_state(lruvec, NR_WRITEBACK); |
2759 | dec_zone_page_state(page, NR_ZONE_WRITE_PENDING); | 2768 | dec_zone_page_state(page, NR_ZONE_WRITE_PENDING); |
2760 | inc_node_page_state(page, NR_WRITTEN); | 2769 | inc_node_page_state(page, NR_WRITTEN); |
2761 | } | 2770 | } |
2762 | unlock_page_memcg(page); | 2771 | __unlock_page_memcg(memcg); |
2763 | return ret; | 2772 | return ret; |
2764 | } | 2773 | } |
2765 | 2774 | ||
diff --git a/mm/page_alloc.c b/mm/page_alloc.c index fc32aa81f359..1bad301820c7 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c | |||
@@ -1584,6 +1584,10 @@ void __init page_alloc_init_late(void) | |||
1584 | /* Reinit limits that are based on free pages after the kernel is up */ | 1584 | /* Reinit limits that are based on free pages after the kernel is up */ |
1585 | files_maxfiles_init(); | 1585 | files_maxfiles_init(); |
1586 | #endif | 1586 | #endif |
1587 | #ifdef CONFIG_ARCH_DISCARD_MEMBLOCK | ||
1588 | /* Discard memblock private memory */ | ||
1589 | memblock_discard(); | ||
1590 | #endif | ||
1587 | 1591 | ||
1588 | for_each_populated_zone(zone) | 1592 | for_each_populated_zone(zone) |
1589 | set_zone_contiguous(zone); | 1593 | set_zone_contiguous(zone); |
@@ -4458,8 +4462,9 @@ long si_mem_available(void) | |||
4458 | * Part of the reclaimable slab consists of items that are in use, | 4462 | * Part of the reclaimable slab consists of items that are in use, |
4459 | * and cannot be freed. Cap this estimate at the low watermark. | 4463 | * and cannot be freed. Cap this estimate at the low watermark. |
4460 | */ | 4464 | */ |
4461 | available += global_page_state(NR_SLAB_RECLAIMABLE) - | 4465 | available += global_node_page_state(NR_SLAB_RECLAIMABLE) - |
4462 | min(global_page_state(NR_SLAB_RECLAIMABLE) / 2, wmark_low); | 4466 | min(global_node_page_state(NR_SLAB_RECLAIMABLE) / 2, |
4467 | wmark_low); | ||
4463 | 4468 | ||
4464 | if (available < 0) | 4469 | if (available < 0) |
4465 | available = 0; | 4470 | available = 0; |
@@ -4602,8 +4607,8 @@ void show_free_areas(unsigned int filter, nodemask_t *nodemask) | |||
4602 | global_node_page_state(NR_FILE_DIRTY), | 4607 | global_node_page_state(NR_FILE_DIRTY), |
4603 | global_node_page_state(NR_WRITEBACK), | 4608 | global_node_page_state(NR_WRITEBACK), |
4604 | global_node_page_state(NR_UNSTABLE_NFS), | 4609 | global_node_page_state(NR_UNSTABLE_NFS), |
4605 | global_page_state(NR_SLAB_RECLAIMABLE), | 4610 | global_node_page_state(NR_SLAB_RECLAIMABLE), |
4606 | global_page_state(NR_SLAB_UNRECLAIMABLE), | 4611 | global_node_page_state(NR_SLAB_UNRECLAIMABLE), |
4607 | global_node_page_state(NR_FILE_MAPPED), | 4612 | global_node_page_state(NR_FILE_MAPPED), |
4608 | global_node_page_state(NR_SHMEM), | 4613 | global_node_page_state(NR_SHMEM), |
4609 | global_page_state(NR_PAGETABLE), | 4614 | global_page_state(NR_PAGETABLE), |
@@ -7668,7 +7673,7 @@ int alloc_contig_range(unsigned long start, unsigned long end, | |||
7668 | 7673 | ||
7669 | /* Make sure the range is really isolated. */ | 7674 | /* Make sure the range is really isolated. */ |
7670 | if (test_pages_isolated(outer_start, end, false)) { | 7675 | if (test_pages_isolated(outer_start, end, false)) { |
7671 | pr_info("%s: [%lx, %lx) PFNs busy\n", | 7676 | pr_info_ratelimited("%s: [%lx, %lx) PFNs busy\n", |
7672 | __func__, outer_start, end); | 7677 | __func__, outer_start, end); |
7673 | ret = -EBUSY; | 7678 | ret = -EBUSY; |
7674 | goto done; | 7679 | goto done; |
@@ -888,10 +888,10 @@ static bool page_mkclean_one(struct page *page, struct vm_area_struct *vma, | |||
888 | .flags = PVMW_SYNC, | 888 | .flags = PVMW_SYNC, |
889 | }; | 889 | }; |
890 | int *cleaned = arg; | 890 | int *cleaned = arg; |
891 | bool invalidation_needed = false; | ||
891 | 892 | ||
892 | while (page_vma_mapped_walk(&pvmw)) { | 893 | while (page_vma_mapped_walk(&pvmw)) { |
893 | int ret = 0; | 894 | int ret = 0; |
894 | address = pvmw.address; | ||
895 | if (pvmw.pte) { | 895 | if (pvmw.pte) { |
896 | pte_t entry; | 896 | pte_t entry; |
897 | pte_t *pte = pvmw.pte; | 897 | pte_t *pte = pvmw.pte; |
@@ -899,11 +899,11 @@ static bool page_mkclean_one(struct page *page, struct vm_area_struct *vma, | |||
899 | if (!pte_dirty(*pte) && !pte_write(*pte)) | 899 | if (!pte_dirty(*pte) && !pte_write(*pte)) |
900 | continue; | 900 | continue; |
901 | 901 | ||
902 | flush_cache_page(vma, address, pte_pfn(*pte)); | 902 | flush_cache_page(vma, pvmw.address, pte_pfn(*pte)); |
903 | entry = ptep_clear_flush(vma, address, pte); | 903 | entry = ptep_clear_flush(vma, pvmw.address, pte); |
904 | entry = pte_wrprotect(entry); | 904 | entry = pte_wrprotect(entry); |
905 | entry = pte_mkclean(entry); | 905 | entry = pte_mkclean(entry); |
906 | set_pte_at(vma->vm_mm, address, pte, entry); | 906 | set_pte_at(vma->vm_mm, pvmw.address, pte, entry); |
907 | ret = 1; | 907 | ret = 1; |
908 | } else { | 908 | } else { |
909 | #ifdef CONFIG_TRANSPARENT_HUGE_PAGECACHE | 909 | #ifdef CONFIG_TRANSPARENT_HUGE_PAGECACHE |
@@ -913,11 +913,11 @@ static bool page_mkclean_one(struct page *page, struct vm_area_struct *vma, | |||
913 | if (!pmd_dirty(*pmd) && !pmd_write(*pmd)) | 913 | if (!pmd_dirty(*pmd) && !pmd_write(*pmd)) |
914 | continue; | 914 | continue; |
915 | 915 | ||
916 | flush_cache_page(vma, address, page_to_pfn(page)); | 916 | flush_cache_page(vma, pvmw.address, page_to_pfn(page)); |
917 | entry = pmdp_huge_clear_flush(vma, address, pmd); | 917 | entry = pmdp_huge_clear_flush(vma, pvmw.address, pmd); |
918 | entry = pmd_wrprotect(entry); | 918 | entry = pmd_wrprotect(entry); |
919 | entry = pmd_mkclean(entry); | 919 | entry = pmd_mkclean(entry); |
920 | set_pmd_at(vma->vm_mm, address, pmd, entry); | 920 | set_pmd_at(vma->vm_mm, pvmw.address, pmd, entry); |
921 | ret = 1; | 921 | ret = 1; |
922 | #else | 922 | #else |
923 | /* unexpected pmd-mapped page? */ | 923 | /* unexpected pmd-mapped page? */ |
@@ -926,11 +926,16 @@ static bool page_mkclean_one(struct page *page, struct vm_area_struct *vma, | |||
926 | } | 926 | } |
927 | 927 | ||
928 | if (ret) { | 928 | if (ret) { |
929 | mmu_notifier_invalidate_page(vma->vm_mm, address); | ||
930 | (*cleaned)++; | 929 | (*cleaned)++; |
930 | invalidation_needed = true; | ||
931 | } | 931 | } |
932 | } | 932 | } |
933 | 933 | ||
934 | if (invalidation_needed) { | ||
935 | mmu_notifier_invalidate_range(vma->vm_mm, address, | ||
936 | address + (1UL << compound_order(page))); | ||
937 | } | ||
938 | |||
934 | return true; | 939 | return true; |
935 | } | 940 | } |
936 | 941 | ||
@@ -1323,7 +1328,7 @@ static bool try_to_unmap_one(struct page *page, struct vm_area_struct *vma, | |||
1323 | }; | 1328 | }; |
1324 | pte_t pteval; | 1329 | pte_t pteval; |
1325 | struct page *subpage; | 1330 | struct page *subpage; |
1326 | bool ret = true; | 1331 | bool ret = true, invalidation_needed = false; |
1327 | enum ttu_flags flags = (enum ttu_flags)arg; | 1332 | enum ttu_flags flags = (enum ttu_flags)arg; |
1328 | 1333 | ||
1329 | /* munlock has nothing to gain from examining un-locked vmas */ | 1334 | /* munlock has nothing to gain from examining un-locked vmas */ |
@@ -1363,11 +1368,9 @@ static bool try_to_unmap_one(struct page *page, struct vm_area_struct *vma, | |||
1363 | VM_BUG_ON_PAGE(!pvmw.pte, page); | 1368 | VM_BUG_ON_PAGE(!pvmw.pte, page); |
1364 | 1369 | ||
1365 | subpage = page - page_to_pfn(page) + pte_pfn(*pvmw.pte); | 1370 | subpage = page - page_to_pfn(page) + pte_pfn(*pvmw.pte); |
1366 | address = pvmw.address; | ||
1367 | |||
1368 | 1371 | ||
1369 | if (!(flags & TTU_IGNORE_ACCESS)) { | 1372 | if (!(flags & TTU_IGNORE_ACCESS)) { |
1370 | if (ptep_clear_flush_young_notify(vma, address, | 1373 | if (ptep_clear_flush_young_notify(vma, pvmw.address, |
1371 | pvmw.pte)) { | 1374 | pvmw.pte)) { |
1372 | ret = false; | 1375 | ret = false; |
1373 | page_vma_mapped_walk_done(&pvmw); | 1376 | page_vma_mapped_walk_done(&pvmw); |
@@ -1376,7 +1379,7 @@ static bool try_to_unmap_one(struct page *page, struct vm_area_struct *vma, | |||
1376 | } | 1379 | } |
1377 | 1380 | ||
1378 | /* Nuke the page table entry. */ | 1381 | /* Nuke the page table entry. */ |
1379 | flush_cache_page(vma, address, pte_pfn(*pvmw.pte)); | 1382 | flush_cache_page(vma, pvmw.address, pte_pfn(*pvmw.pte)); |
1380 | if (should_defer_flush(mm, flags)) { | 1383 | if (should_defer_flush(mm, flags)) { |
1381 | /* | 1384 | /* |
1382 | * We clear the PTE but do not flush so potentially | 1385 | * We clear the PTE but do not flush so potentially |
@@ -1386,11 +1389,12 @@ static bool try_to_unmap_one(struct page *page, struct vm_area_struct *vma, | |||
1386 | * transition on a cached TLB entry is written through | 1389 | * transition on a cached TLB entry is written through |
1387 | * and traps if the PTE is unmapped. | 1390 | * and traps if the PTE is unmapped. |
1388 | */ | 1391 | */ |
1389 | pteval = ptep_get_and_clear(mm, address, pvmw.pte); | 1392 | pteval = ptep_get_and_clear(mm, pvmw.address, |
1393 | pvmw.pte); | ||
1390 | 1394 | ||
1391 | set_tlb_ubc_flush_pending(mm, pte_dirty(pteval)); | 1395 | set_tlb_ubc_flush_pending(mm, pte_dirty(pteval)); |
1392 | } else { | 1396 | } else { |
1393 | pteval = ptep_clear_flush(vma, address, pvmw.pte); | 1397 | pteval = ptep_clear_flush(vma, pvmw.address, pvmw.pte); |
1394 | } | 1398 | } |
1395 | 1399 | ||
1396 | /* Move the dirty bit to the page. Now the pte is gone. */ | 1400 | /* Move the dirty bit to the page. Now the pte is gone. */ |
@@ -1405,12 +1409,12 @@ static bool try_to_unmap_one(struct page *page, struct vm_area_struct *vma, | |||
1405 | if (PageHuge(page)) { | 1409 | if (PageHuge(page)) { |
1406 | int nr = 1 << compound_order(page); | 1410 | int nr = 1 << compound_order(page); |
1407 | hugetlb_count_sub(nr, mm); | 1411 | hugetlb_count_sub(nr, mm); |
1408 | set_huge_swap_pte_at(mm, address, | 1412 | set_huge_swap_pte_at(mm, pvmw.address, |
1409 | pvmw.pte, pteval, | 1413 | pvmw.pte, pteval, |
1410 | vma_mmu_pagesize(vma)); | 1414 | vma_mmu_pagesize(vma)); |
1411 | } else { | 1415 | } else { |
1412 | dec_mm_counter(mm, mm_counter(page)); | 1416 | dec_mm_counter(mm, mm_counter(page)); |
1413 | set_pte_at(mm, address, pvmw.pte, pteval); | 1417 | set_pte_at(mm, pvmw.address, pvmw.pte, pteval); |
1414 | } | 1418 | } |
1415 | 1419 | ||
1416 | } else if (pte_unused(pteval)) { | 1420 | } else if (pte_unused(pteval)) { |
@@ -1434,7 +1438,7 @@ static bool try_to_unmap_one(struct page *page, struct vm_area_struct *vma, | |||
1434 | swp_pte = swp_entry_to_pte(entry); | 1438 | swp_pte = swp_entry_to_pte(entry); |
1435 | if (pte_soft_dirty(pteval)) | 1439 | if (pte_soft_dirty(pteval)) |
1436 | swp_pte = pte_swp_mksoft_dirty(swp_pte); | 1440 | swp_pte = pte_swp_mksoft_dirty(swp_pte); |
1437 | set_pte_at(mm, address, pvmw.pte, swp_pte); | 1441 | set_pte_at(mm, pvmw.address, pvmw.pte, swp_pte); |
1438 | } else if (PageAnon(page)) { | 1442 | } else if (PageAnon(page)) { |
1439 | swp_entry_t entry = { .val = page_private(subpage) }; | 1443 | swp_entry_t entry = { .val = page_private(subpage) }; |
1440 | pte_t swp_pte; | 1444 | pte_t swp_pte; |
@@ -1460,7 +1464,7 @@ static bool try_to_unmap_one(struct page *page, struct vm_area_struct *vma, | |||
1460 | * If the page was redirtied, it cannot be | 1464 | * If the page was redirtied, it cannot be |
1461 | * discarded. Remap the page to page table. | 1465 | * discarded. Remap the page to page table. |
1462 | */ | 1466 | */ |
1463 | set_pte_at(mm, address, pvmw.pte, pteval); | 1467 | set_pte_at(mm, pvmw.address, pvmw.pte, pteval); |
1464 | SetPageSwapBacked(page); | 1468 | SetPageSwapBacked(page); |
1465 | ret = false; | 1469 | ret = false; |
1466 | page_vma_mapped_walk_done(&pvmw); | 1470 | page_vma_mapped_walk_done(&pvmw); |
@@ -1468,7 +1472,7 @@ static bool try_to_unmap_one(struct page *page, struct vm_area_struct *vma, | |||
1468 | } | 1472 | } |
1469 | 1473 | ||
1470 | if (swap_duplicate(entry) < 0) { | 1474 | if (swap_duplicate(entry) < 0) { |
1471 | set_pte_at(mm, address, pvmw.pte, pteval); | 1475 | set_pte_at(mm, pvmw.address, pvmw.pte, pteval); |
1472 | ret = false; | 1476 | ret = false; |
1473 | page_vma_mapped_walk_done(&pvmw); | 1477 | page_vma_mapped_walk_done(&pvmw); |
1474 | break; | 1478 | break; |
@@ -1484,14 +1488,18 @@ static bool try_to_unmap_one(struct page *page, struct vm_area_struct *vma, | |||
1484 | swp_pte = swp_entry_to_pte(entry); | 1488 | swp_pte = swp_entry_to_pte(entry); |
1485 | if (pte_soft_dirty(pteval)) | 1489 | if (pte_soft_dirty(pteval)) |
1486 | swp_pte = pte_swp_mksoft_dirty(swp_pte); | 1490 | swp_pte = pte_swp_mksoft_dirty(swp_pte); |
1487 | set_pte_at(mm, address, pvmw.pte, swp_pte); | 1491 | set_pte_at(mm, pvmw.address, pvmw.pte, swp_pte); |
1488 | } else | 1492 | } else |
1489 | dec_mm_counter(mm, mm_counter_file(page)); | 1493 | dec_mm_counter(mm, mm_counter_file(page)); |
1490 | discard: | 1494 | discard: |
1491 | page_remove_rmap(subpage, PageHuge(page)); | 1495 | page_remove_rmap(subpage, PageHuge(page)); |
1492 | put_page(page); | 1496 | put_page(page); |
1493 | mmu_notifier_invalidate_page(mm, address); | 1497 | invalidation_needed = true; |
1494 | } | 1498 | } |
1499 | |||
1500 | if (invalidation_needed) | ||
1501 | mmu_notifier_invalidate_range(mm, address, | ||
1502 | address + (1UL << compound_order(page))); | ||
1495 | return ret; | 1503 | return ret; |
1496 | } | 1504 | } |
1497 | 1505 | ||
diff --git a/mm/shmem.c b/mm/shmem.c index b0aa6075d164..6540e5982444 100644 --- a/mm/shmem.c +++ b/mm/shmem.c | |||
@@ -1022,7 +1022,11 @@ static int shmem_setattr(struct dentry *dentry, struct iattr *attr) | |||
1022 | */ | 1022 | */ |
1023 | if (IS_ENABLED(CONFIG_TRANSPARENT_HUGE_PAGECACHE)) { | 1023 | if (IS_ENABLED(CONFIG_TRANSPARENT_HUGE_PAGECACHE)) { |
1024 | spin_lock(&sbinfo->shrinklist_lock); | 1024 | spin_lock(&sbinfo->shrinklist_lock); |
1025 | if (list_empty(&info->shrinklist)) { | 1025 | /* |
1026 | * _careful to defend against unlocked access to | ||
1027 | * ->shrink_list in shmem_unused_huge_shrink() | ||
1028 | */ | ||
1029 | if (list_empty_careful(&info->shrinklist)) { | ||
1026 | list_add_tail(&info->shrinklist, | 1030 | list_add_tail(&info->shrinklist, |
1027 | &sbinfo->shrinklist); | 1031 | &sbinfo->shrinklist); |
1028 | sbinfo->shrinklist_len++; | 1032 | sbinfo->shrinklist_len++; |
@@ -1817,7 +1821,11 @@ alloc_nohuge: page = shmem_alloc_and_acct_page(gfp, info, sbinfo, | |||
1817 | * to shrink under memory pressure. | 1821 | * to shrink under memory pressure. |
1818 | */ | 1822 | */ |
1819 | spin_lock(&sbinfo->shrinklist_lock); | 1823 | spin_lock(&sbinfo->shrinklist_lock); |
1820 | if (list_empty(&info->shrinklist)) { | 1824 | /* |
1825 | * _careful to defend against unlocked access to | ||
1826 | * ->shrink_list in shmem_unused_huge_shrink() | ||
1827 | */ | ||
1828 | if (list_empty_careful(&info->shrinklist)) { | ||
1821 | list_add_tail(&info->shrinklist, | 1829 | list_add_tail(&info->shrinklist, |
1822 | &sbinfo->shrinklist); | 1830 | &sbinfo->shrinklist); |
1823 | sbinfo->shrinklist_len++; | 1831 | sbinfo->shrinklist_len++; |
@@ -5642,13 +5642,14 @@ static void sysfs_slab_remove_workfn(struct work_struct *work) | |||
5642 | * A cache is never shut down before deactivation is | 5642 | * A cache is never shut down before deactivation is |
5643 | * complete, so no need to worry about synchronization. | 5643 | * complete, so no need to worry about synchronization. |
5644 | */ | 5644 | */ |
5645 | return; | 5645 | goto out; |
5646 | 5646 | ||
5647 | #ifdef CONFIG_MEMCG | 5647 | #ifdef CONFIG_MEMCG |
5648 | kset_unregister(s->memcg_kset); | 5648 | kset_unregister(s->memcg_kset); |
5649 | #endif | 5649 | #endif |
5650 | kobject_uevent(&s->kobj, KOBJ_REMOVE); | 5650 | kobject_uevent(&s->kobj, KOBJ_REMOVE); |
5651 | kobject_del(&s->kobj); | 5651 | kobject_del(&s->kobj); |
5652 | out: | ||
5652 | kobject_put(&s->kobj); | 5653 | kobject_put(&s->kobj); |
5653 | } | 5654 | } |
5654 | 5655 | ||
@@ -633,7 +633,7 @@ int __vm_enough_memory(struct mm_struct *mm, long pages, int cap_sys_admin) | |||
633 | * which are reclaimable, under pressure. The dentry | 633 | * which are reclaimable, under pressure. The dentry |
634 | * cache and most inode caches should fall into this | 634 | * cache and most inode caches should fall into this |
635 | */ | 635 | */ |
636 | free += global_page_state(NR_SLAB_RECLAIMABLE); | 636 | free += global_node_page_state(NR_SLAB_RECLAIMABLE); |
637 | 637 | ||
638 | /* | 638 | /* |
639 | * Leave reserved pages. The pages are not for anonymous pages. | 639 | * Leave reserved pages. The pages are not for anonymous pages. |
diff --git a/mm/vmalloc.c b/mm/vmalloc.c index 8698c1c86c4d..a47e3894c775 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c | |||
@@ -1671,7 +1671,10 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask, | |||
1671 | struct page **pages; | 1671 | struct page **pages; |
1672 | unsigned int nr_pages, array_size, i; | 1672 | unsigned int nr_pages, array_size, i; |
1673 | const gfp_t nested_gfp = (gfp_mask & GFP_RECLAIM_MASK) | __GFP_ZERO; | 1673 | const gfp_t nested_gfp = (gfp_mask & GFP_RECLAIM_MASK) | __GFP_ZERO; |
1674 | const gfp_t alloc_mask = gfp_mask | __GFP_HIGHMEM | __GFP_NOWARN; | 1674 | const gfp_t alloc_mask = gfp_mask | __GFP_NOWARN; |
1675 | const gfp_t highmem_mask = (gfp_mask & (GFP_DMA | GFP_DMA32)) ? | ||
1676 | 0 : | ||
1677 | __GFP_HIGHMEM; | ||
1675 | 1678 | ||
1676 | nr_pages = get_vm_area_size(area) >> PAGE_SHIFT; | 1679 | nr_pages = get_vm_area_size(area) >> PAGE_SHIFT; |
1677 | array_size = (nr_pages * sizeof(struct page *)); | 1680 | array_size = (nr_pages * sizeof(struct page *)); |
@@ -1679,7 +1682,7 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask, | |||
1679 | area->nr_pages = nr_pages; | 1682 | area->nr_pages = nr_pages; |
1680 | /* Please note that the recursion is strictly bounded. */ | 1683 | /* Please note that the recursion is strictly bounded. */ |
1681 | if (array_size > PAGE_SIZE) { | 1684 | if (array_size > PAGE_SIZE) { |
1682 | pages = __vmalloc_node(array_size, 1, nested_gfp|__GFP_HIGHMEM, | 1685 | pages = __vmalloc_node(array_size, 1, nested_gfp|highmem_mask, |
1683 | PAGE_KERNEL, node, area->caller); | 1686 | PAGE_KERNEL, node, area->caller); |
1684 | } else { | 1687 | } else { |
1685 | pages = kmalloc_node(array_size, nested_gfp, node); | 1688 | pages = kmalloc_node(array_size, nested_gfp, node); |
@@ -1700,9 +1703,9 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask, | |||
1700 | } | 1703 | } |
1701 | 1704 | ||
1702 | if (node == NUMA_NO_NODE) | 1705 | if (node == NUMA_NO_NODE) |
1703 | page = alloc_page(alloc_mask); | 1706 | page = alloc_page(alloc_mask|highmem_mask); |
1704 | else | 1707 | else |
1705 | page = alloc_pages_node(node, alloc_mask, 0); | 1708 | page = alloc_pages_node(node, alloc_mask|highmem_mask, 0); |
1706 | 1709 | ||
1707 | if (unlikely(!page)) { | 1710 | if (unlikely(!page)) { |
1708 | /* Successfully allocated i pages, free them in __vunmap() */ | 1711 | /* Successfully allocated i pages, free them in __vunmap() */ |
@@ -1710,7 +1713,7 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask, | |||
1710 | goto fail; | 1713 | goto fail; |
1711 | } | 1714 | } |
1712 | area->pages[i] = page; | 1715 | area->pages[i] = page; |
1713 | if (gfpflags_allow_blocking(gfp_mask)) | 1716 | if (gfpflags_allow_blocking(gfp_mask|highmem_mask)) |
1714 | cond_resched(); | 1717 | cond_resched(); |
1715 | } | 1718 | } |
1716 | 1719 | ||
diff --git a/net/core/datagram.c b/net/core/datagram.c index ee5647bd91b3..a21ca8dee5ea 100644 --- a/net/core/datagram.c +++ b/net/core/datagram.c | |||
@@ -169,14 +169,20 @@ struct sk_buff *__skb_try_recv_from_queue(struct sock *sk, | |||
169 | int *peeked, int *off, int *err, | 169 | int *peeked, int *off, int *err, |
170 | struct sk_buff **last) | 170 | struct sk_buff **last) |
171 | { | 171 | { |
172 | bool peek_at_off = false; | ||
172 | struct sk_buff *skb; | 173 | struct sk_buff *skb; |
173 | int _off = *off; | 174 | int _off = 0; |
175 | |||
176 | if (unlikely(flags & MSG_PEEK && *off >= 0)) { | ||
177 | peek_at_off = true; | ||
178 | _off = *off; | ||
179 | } | ||
174 | 180 | ||
175 | *last = queue->prev; | 181 | *last = queue->prev; |
176 | skb_queue_walk(queue, skb) { | 182 | skb_queue_walk(queue, skb) { |
177 | if (flags & MSG_PEEK) { | 183 | if (flags & MSG_PEEK) { |
178 | if (_off >= skb->len && (skb->len || _off || | 184 | if (peek_at_off && _off >= skb->len && |
179 | skb->peeked)) { | 185 | (_off || skb->peeked)) { |
180 | _off -= skb->len; | 186 | _off -= skb->len; |
181 | continue; | 187 | continue; |
182 | } | 188 | } |
diff --git a/net/core/filter.c b/net/core/filter.c index f44fc22fd45a..6280a602604c 100644 --- a/net/core/filter.c +++ b/net/core/filter.c | |||
@@ -3505,6 +3505,7 @@ static u32 bpf_convert_ctx_access(enum bpf_access_type type, | |||
3505 | bpf_target_off(struct sk_buff, tc_index, 2, | 3505 | bpf_target_off(struct sk_buff, tc_index, 2, |
3506 | target_size)); | 3506 | target_size)); |
3507 | #else | 3507 | #else |
3508 | *target_size = 2; | ||
3508 | if (type == BPF_WRITE) | 3509 | if (type == BPF_WRITE) |
3509 | *insn++ = BPF_MOV64_REG(si->dst_reg, si->dst_reg); | 3510 | *insn++ = BPF_MOV64_REG(si->dst_reg, si->dst_reg); |
3510 | else | 3511 | else |
@@ -3520,6 +3521,7 @@ static u32 bpf_convert_ctx_access(enum bpf_access_type type, | |||
3520 | *insn++ = BPF_JMP_IMM(BPF_JGE, si->dst_reg, MIN_NAPI_ID, 1); | 3521 | *insn++ = BPF_JMP_IMM(BPF_JGE, si->dst_reg, MIN_NAPI_ID, 1); |
3521 | *insn++ = BPF_MOV64_IMM(si->dst_reg, 0); | 3522 | *insn++ = BPF_MOV64_IMM(si->dst_reg, 0); |
3522 | #else | 3523 | #else |
3524 | *target_size = 4; | ||
3523 | *insn++ = BPF_MOV64_IMM(si->dst_reg, 0); | 3525 | *insn++ = BPF_MOV64_IMM(si->dst_reg, 0); |
3524 | #endif | 3526 | #endif |
3525 | break; | 3527 | break; |
diff --git a/net/dccp/proto.c b/net/dccp/proto.c index 9fe25bf63296..b68168fcc06a 100644 --- a/net/dccp/proto.c +++ b/net/dccp/proto.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <net/checksum.h> | 24 | #include <net/checksum.h> |
25 | 25 | ||
26 | #include <net/inet_sock.h> | 26 | #include <net/inet_sock.h> |
27 | #include <net/inet_common.h> | ||
27 | #include <net/sock.h> | 28 | #include <net/sock.h> |
28 | #include <net/xfrm.h> | 29 | #include <net/xfrm.h> |
29 | 30 | ||
@@ -170,6 +171,15 @@ const char *dccp_packet_name(const int type) | |||
170 | 171 | ||
171 | EXPORT_SYMBOL_GPL(dccp_packet_name); | 172 | EXPORT_SYMBOL_GPL(dccp_packet_name); |
172 | 173 | ||
174 | static void dccp_sk_destruct(struct sock *sk) | ||
175 | { | ||
176 | struct dccp_sock *dp = dccp_sk(sk); | ||
177 | |||
178 | ccid_hc_tx_delete(dp->dccps_hc_tx_ccid, sk); | ||
179 | dp->dccps_hc_tx_ccid = NULL; | ||
180 | inet_sock_destruct(sk); | ||
181 | } | ||
182 | |||
173 | int dccp_init_sock(struct sock *sk, const __u8 ctl_sock_initialized) | 183 | int dccp_init_sock(struct sock *sk, const __u8 ctl_sock_initialized) |
174 | { | 184 | { |
175 | struct dccp_sock *dp = dccp_sk(sk); | 185 | struct dccp_sock *dp = dccp_sk(sk); |
@@ -179,6 +189,7 @@ int dccp_init_sock(struct sock *sk, const __u8 ctl_sock_initialized) | |||
179 | icsk->icsk_syn_retries = sysctl_dccp_request_retries; | 189 | icsk->icsk_syn_retries = sysctl_dccp_request_retries; |
180 | sk->sk_state = DCCP_CLOSED; | 190 | sk->sk_state = DCCP_CLOSED; |
181 | sk->sk_write_space = dccp_write_space; | 191 | sk->sk_write_space = dccp_write_space; |
192 | sk->sk_destruct = dccp_sk_destruct; | ||
182 | icsk->icsk_sync_mss = dccp_sync_mss; | 193 | icsk->icsk_sync_mss = dccp_sync_mss; |
183 | dp->dccps_mss_cache = 536; | 194 | dp->dccps_mss_cache = 536; |
184 | dp->dccps_rate_last = jiffies; | 195 | dp->dccps_rate_last = jiffies; |
@@ -201,10 +212,7 @@ void dccp_destroy_sock(struct sock *sk) | |||
201 | { | 212 | { |
202 | struct dccp_sock *dp = dccp_sk(sk); | 213 | struct dccp_sock *dp = dccp_sk(sk); |
203 | 214 | ||
204 | /* | 215 | __skb_queue_purge(&sk->sk_write_queue); |
205 | * DCCP doesn't use sk_write_queue, just sk_send_head | ||
206 | * for retransmissions | ||
207 | */ | ||
208 | if (sk->sk_send_head != NULL) { | 216 | if (sk->sk_send_head != NULL) { |
209 | kfree_skb(sk->sk_send_head); | 217 | kfree_skb(sk->sk_send_head); |
210 | sk->sk_send_head = NULL; | 218 | sk->sk_send_head = NULL; |
@@ -222,8 +230,7 @@ void dccp_destroy_sock(struct sock *sk) | |||
222 | dp->dccps_hc_rx_ackvec = NULL; | 230 | dp->dccps_hc_rx_ackvec = NULL; |
223 | } | 231 | } |
224 | ccid_hc_rx_delete(dp->dccps_hc_rx_ccid, sk); | 232 | ccid_hc_rx_delete(dp->dccps_hc_rx_ccid, sk); |
225 | ccid_hc_tx_delete(dp->dccps_hc_tx_ccid, sk); | 233 | dp->dccps_hc_rx_ccid = NULL; |
226 | dp->dccps_hc_rx_ccid = dp->dccps_hc_tx_ccid = NULL; | ||
227 | 234 | ||
228 | /* clean up feature negotiation state */ | 235 | /* clean up feature negotiation state */ |
229 | dccp_feat_list_purge(&dp->dccps_featneg); | 236 | dccp_feat_list_purge(&dp->dccps_featneg); |
diff --git a/net/dsa/tag_ksz.c b/net/dsa/tag_ksz.c index fab41de8e983..de66ca8e6201 100644 --- a/net/dsa/tag_ksz.c +++ b/net/dsa/tag_ksz.c | |||
@@ -42,6 +42,9 @@ static struct sk_buff *ksz_xmit(struct sk_buff *skb, struct net_device *dev) | |||
42 | padlen = (skb->len >= ETH_ZLEN) ? 0 : ETH_ZLEN - skb->len; | 42 | padlen = (skb->len >= ETH_ZLEN) ? 0 : ETH_ZLEN - skb->len; |
43 | 43 | ||
44 | if (skb_tailroom(skb) >= padlen + KSZ_INGRESS_TAG_LEN) { | 44 | if (skb_tailroom(skb) >= padlen + KSZ_INGRESS_TAG_LEN) { |
45 | if (skb_put_padto(skb, skb->len + padlen)) | ||
46 | return NULL; | ||
47 | |||
45 | nskb = skb; | 48 | nskb = skb; |
46 | } else { | 49 | } else { |
47 | nskb = alloc_skb(NET_IP_ALIGN + skb->len + | 50 | nskb = alloc_skb(NET_IP_ALIGN + skb->len + |
@@ -56,13 +59,15 @@ static struct sk_buff *ksz_xmit(struct sk_buff *skb, struct net_device *dev) | |||
56 | skb_set_transport_header(nskb, | 59 | skb_set_transport_header(nskb, |
57 | skb_transport_header(skb) - skb->head); | 60 | skb_transport_header(skb) - skb->head); |
58 | skb_copy_and_csum_dev(skb, skb_put(nskb, skb->len)); | 61 | skb_copy_and_csum_dev(skb, skb_put(nskb, skb->len)); |
62 | |||
63 | if (skb_put_padto(nskb, nskb->len + padlen)) { | ||
64 | kfree_skb(nskb); | ||
65 | return NULL; | ||
66 | } | ||
67 | |||
59 | kfree_skb(skb); | 68 | kfree_skb(skb); |
60 | } | 69 | } |
61 | 70 | ||
62 | /* skb is freed when it fails */ | ||
63 | if (skb_put_padto(nskb, nskb->len + padlen)) | ||
64 | return NULL; | ||
65 | |||
66 | tag = skb_put(nskb, KSZ_INGRESS_TAG_LEN); | 71 | tag = skb_put(nskb, KSZ_INGRESS_TAG_LEN); |
67 | tag[0] = 0; | 72 | tag[0] = 0; |
68 | tag[1] = 1 << p->dp->index; /* destination port */ | 73 | tag[1] = 1 << p->dp->index; /* destination port */ |
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index 76c2077c3f5b..2e548eca3489 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c | |||
@@ -1731,6 +1731,13 @@ static __net_init int inet_init_net(struct net *net) | |||
1731 | net->ipv4.sysctl_ip_prot_sock = PROT_SOCK; | 1731 | net->ipv4.sysctl_ip_prot_sock = PROT_SOCK; |
1732 | #endif | 1732 | #endif |
1733 | 1733 | ||
1734 | /* Some igmp sysctl, whose values are always used */ | ||
1735 | net->ipv4.sysctl_igmp_max_memberships = 20; | ||
1736 | net->ipv4.sysctl_igmp_max_msf = 10; | ||
1737 | /* IGMP reports for link-local multicast groups are enabled by default */ | ||
1738 | net->ipv4.sysctl_igmp_llm_reports = 1; | ||
1739 | net->ipv4.sysctl_igmp_qrv = 2; | ||
1740 | |||
1734 | return 0; | 1741 | return 0; |
1735 | } | 1742 | } |
1736 | 1743 | ||
diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c index b8d18171cca3..ec3a9ce281a6 100644 --- a/net/ipv4/fib_semantics.c +++ b/net/ipv4/fib_semantics.c | |||
@@ -1083,15 +1083,17 @@ struct fib_info *fib_create_info(struct fib_config *cfg, | |||
1083 | fi = kzalloc(sizeof(*fi)+nhs*sizeof(struct fib_nh), GFP_KERNEL); | 1083 | fi = kzalloc(sizeof(*fi)+nhs*sizeof(struct fib_nh), GFP_KERNEL); |
1084 | if (!fi) | 1084 | if (!fi) |
1085 | goto failure; | 1085 | goto failure; |
1086 | fib_info_cnt++; | ||
1087 | if (cfg->fc_mx) { | 1086 | if (cfg->fc_mx) { |
1088 | fi->fib_metrics = kzalloc(sizeof(*fi->fib_metrics), GFP_KERNEL); | 1087 | fi->fib_metrics = kzalloc(sizeof(*fi->fib_metrics), GFP_KERNEL); |
1089 | if (!fi->fib_metrics) | 1088 | if (unlikely(!fi->fib_metrics)) { |
1090 | goto failure; | 1089 | kfree(fi); |
1090 | return ERR_PTR(err); | ||
1091 | } | ||
1091 | atomic_set(&fi->fib_metrics->refcnt, 1); | 1092 | atomic_set(&fi->fib_metrics->refcnt, 1); |
1092 | } else | 1093 | } else { |
1093 | fi->fib_metrics = (struct dst_metrics *)&dst_default_metrics; | 1094 | fi->fib_metrics = (struct dst_metrics *)&dst_default_metrics; |
1094 | 1095 | } | |
1096 | fib_info_cnt++; | ||
1095 | fi->fib_net = net; | 1097 | fi->fib_net = net; |
1096 | fi->fib_protocol = cfg->fc_protocol; | 1098 | fi->fib_protocol = cfg->fc_protocol; |
1097 | fi->fib_scope = cfg->fc_scope; | 1099 | fi->fib_scope = cfg->fc_scope; |
diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c index 28f14afd0dd3..caf2f1101d02 100644 --- a/net/ipv4/igmp.c +++ b/net/ipv4/igmp.c | |||
@@ -1007,10 +1007,18 @@ int igmp_rcv(struct sk_buff *skb) | |||
1007 | { | 1007 | { |
1008 | /* This basically follows the spec line by line -- see RFC1112 */ | 1008 | /* This basically follows the spec line by line -- see RFC1112 */ |
1009 | struct igmphdr *ih; | 1009 | struct igmphdr *ih; |
1010 | struct in_device *in_dev = __in_dev_get_rcu(skb->dev); | 1010 | struct net_device *dev = skb->dev; |
1011 | struct in_device *in_dev; | ||
1011 | int len = skb->len; | 1012 | int len = skb->len; |
1012 | bool dropped = true; | 1013 | bool dropped = true; |
1013 | 1014 | ||
1015 | if (netif_is_l3_master(dev)) { | ||
1016 | dev = dev_get_by_index_rcu(dev_net(dev), IPCB(skb)->iif); | ||
1017 | if (!dev) | ||
1018 | goto drop; | ||
1019 | } | ||
1020 | |||
1021 | in_dev = __in_dev_get_rcu(dev); | ||
1014 | if (!in_dev) | 1022 | if (!in_dev) |
1015 | goto drop; | 1023 | goto drop; |
1016 | 1024 | ||
@@ -2974,12 +2982,6 @@ static int __net_init igmp_net_init(struct net *net) | |||
2974 | goto out_sock; | 2982 | goto out_sock; |
2975 | } | 2983 | } |
2976 | 2984 | ||
2977 | /* Sysctl initialization */ | ||
2978 | net->ipv4.sysctl_igmp_max_memberships = 20; | ||
2979 | net->ipv4.sysctl_igmp_max_msf = 10; | ||
2980 | /* IGMP reports for link-local multicast groups are enabled by default */ | ||
2981 | net->ipv4.sysctl_igmp_llm_reports = 1; | ||
2982 | net->ipv4.sysctl_igmp_qrv = 2; | ||
2983 | return 0; | 2985 | return 0; |
2984 | 2986 | ||
2985 | out_sock: | 2987 | out_sock: |
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c index 50c74cd890bc..e153c40c2436 100644 --- a/net/ipv4/ip_output.c +++ b/net/ipv4/ip_output.c | |||
@@ -965,11 +965,12 @@ static int __ip_append_data(struct sock *sk, | |||
965 | csummode = CHECKSUM_PARTIAL; | 965 | csummode = CHECKSUM_PARTIAL; |
966 | 966 | ||
967 | cork->length += length; | 967 | cork->length += length; |
968 | if ((((length + (skb ? skb->len : fragheaderlen)) > mtu) || | 968 | if ((skb && skb_is_gso(skb)) || |
969 | (skb && skb_is_gso(skb))) && | 969 | (((length + (skb ? skb->len : fragheaderlen)) > mtu) && |
970 | (skb_queue_len(queue) <= 1) && | ||
970 | (sk->sk_protocol == IPPROTO_UDP) && | 971 | (sk->sk_protocol == IPPROTO_UDP) && |
971 | (rt->dst.dev->features & NETIF_F_UFO) && !dst_xfrm(&rt->dst) && | 972 | (rt->dst.dev->features & NETIF_F_UFO) && !dst_xfrm(&rt->dst) && |
972 | (sk->sk_type == SOCK_DGRAM) && !sk->sk_no_check_tx) { | 973 | (sk->sk_type == SOCK_DGRAM) && !sk->sk_no_check_tx)) { |
973 | err = ip_ufo_append_data(sk, queue, getfrag, from, length, | 974 | err = ip_ufo_append_data(sk, queue, getfrag, from, length, |
974 | hh_len, fragheaderlen, transhdrlen, | 975 | hh_len, fragheaderlen, transhdrlen, |
975 | maxfraglen, flags); | 976 | maxfraglen, flags); |
@@ -1288,6 +1289,7 @@ ssize_t ip_append_page(struct sock *sk, struct flowi4 *fl4, struct page *page, | |||
1288 | return -EINVAL; | 1289 | return -EINVAL; |
1289 | 1290 | ||
1290 | if ((size + skb->len > mtu) && | 1291 | if ((size + skb->len > mtu) && |
1292 | (skb_queue_len(&sk->sk_write_queue) == 1) && | ||
1291 | (sk->sk_protocol == IPPROTO_UDP) && | 1293 | (sk->sk_protocol == IPPROTO_UDP) && |
1292 | (rt->dst.dev->features & NETIF_F_UFO)) { | 1294 | (rt->dst.dev->features & NETIF_F_UFO)) { |
1293 | if (skb->ip_summed != CHECKSUM_PARTIAL) | 1295 | if (skb->ip_summed != CHECKSUM_PARTIAL) |
diff --git a/net/ipv4/route.c b/net/ipv4/route.c index 0383e66f59bc..2331de20ca50 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c | |||
@@ -1267,7 +1267,7 @@ static unsigned int ipv4_mtu(const struct dst_entry *dst) | |||
1267 | if (mtu) | 1267 | if (mtu) |
1268 | return mtu; | 1268 | return mtu; |
1269 | 1269 | ||
1270 | mtu = dst->dev->mtu; | 1270 | mtu = READ_ONCE(dst->dev->mtu); |
1271 | 1271 | ||
1272 | if (unlikely(dst_metric_locked(dst, RTAX_MTU))) { | 1272 | if (unlikely(dst_metric_locked(dst, RTAX_MTU))) { |
1273 | if (rt->rt_uses_gateway && mtu > 576) | 1273 | if (rt->rt_uses_gateway && mtu > 576) |
@@ -2750,26 +2750,34 @@ static int inet_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh, | |||
2750 | err = 0; | 2750 | err = 0; |
2751 | if (IS_ERR(rt)) | 2751 | if (IS_ERR(rt)) |
2752 | err = PTR_ERR(rt); | 2752 | err = PTR_ERR(rt); |
2753 | else | ||
2754 | skb_dst_set(skb, &rt->dst); | ||
2753 | } | 2755 | } |
2754 | 2756 | ||
2755 | if (err) | 2757 | if (err) |
2756 | goto errout_free; | 2758 | goto errout_free; |
2757 | 2759 | ||
2758 | skb_dst_set(skb, &rt->dst); | ||
2759 | if (rtm->rtm_flags & RTM_F_NOTIFY) | 2760 | if (rtm->rtm_flags & RTM_F_NOTIFY) |
2760 | rt->rt_flags |= RTCF_NOTIFY; | 2761 | rt->rt_flags |= RTCF_NOTIFY; |
2761 | 2762 | ||
2762 | if (rtm->rtm_flags & RTM_F_LOOKUP_TABLE) | 2763 | if (rtm->rtm_flags & RTM_F_LOOKUP_TABLE) |
2763 | table_id = rt->rt_table_id; | 2764 | table_id = rt->rt_table_id; |
2764 | 2765 | ||
2765 | if (rtm->rtm_flags & RTM_F_FIB_MATCH) | 2766 | if (rtm->rtm_flags & RTM_F_FIB_MATCH) { |
2767 | if (!res.fi) { | ||
2768 | err = fib_props[res.type].error; | ||
2769 | if (!err) | ||
2770 | err = -EHOSTUNREACH; | ||
2771 | goto errout_free; | ||
2772 | } | ||
2766 | err = fib_dump_info(skb, NETLINK_CB(in_skb).portid, | 2773 | err = fib_dump_info(skb, NETLINK_CB(in_skb).portid, |
2767 | nlh->nlmsg_seq, RTM_NEWROUTE, table_id, | 2774 | nlh->nlmsg_seq, RTM_NEWROUTE, table_id, |
2768 | rt->rt_type, res.prefix, res.prefixlen, | 2775 | rt->rt_type, res.prefix, res.prefixlen, |
2769 | fl4.flowi4_tos, res.fi, 0); | 2776 | fl4.flowi4_tos, res.fi, 0); |
2770 | else | 2777 | } else { |
2771 | err = rt_fill_info(net, dst, src, table_id, &fl4, skb, | 2778 | err = rt_fill_info(net, dst, src, table_id, &fl4, skb, |
2772 | NETLINK_CB(in_skb).portid, nlh->nlmsg_seq); | 2779 | NETLINK_CB(in_skb).portid, nlh->nlmsg_seq); |
2780 | } | ||
2773 | if (err < 0) | 2781 | if (err < 0) |
2774 | goto errout_free; | 2782 | goto errout_free; |
2775 | 2783 | ||
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 53de1424c13c..bab7f0493098 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c | |||
@@ -3009,8 +3009,7 @@ void tcp_rearm_rto(struct sock *sk) | |||
3009 | /* delta_us may not be positive if the socket is locked | 3009 | /* delta_us may not be positive if the socket is locked |
3010 | * when the retrans timer fires and is rescheduled. | 3010 | * when the retrans timer fires and is rescheduled. |
3011 | */ | 3011 | */ |
3012 | if (delta_us > 0) | 3012 | rto = usecs_to_jiffies(max_t(int, delta_us, 1)); |
3013 | rto = usecs_to_jiffies(delta_us); | ||
3014 | } | 3013 | } |
3015 | inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS, rto, | 3014 | inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS, rto, |
3016 | TCP_RTO_MAX); | 3015 | TCP_RTO_MAX); |
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index a20e7f03d5f7..e9252c7df809 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c | |||
@@ -1722,6 +1722,8 @@ process: | |||
1722 | */ | 1722 | */ |
1723 | sock_hold(sk); | 1723 | sock_hold(sk); |
1724 | refcounted = true; | 1724 | refcounted = true; |
1725 | if (tcp_filter(sk, skb)) | ||
1726 | goto discard_and_relse; | ||
1725 | nsk = tcp_check_req(sk, skb, req, false); | 1727 | nsk = tcp_check_req(sk, skb, req, false); |
1726 | if (!nsk) { | 1728 | if (!nsk) { |
1727 | reqsk_put(req); | 1729 | reqsk_put(req); |
@@ -1729,8 +1731,6 @@ process: | |||
1729 | } | 1731 | } |
1730 | if (nsk == sk) { | 1732 | if (nsk == sk) { |
1731 | reqsk_put(req); | 1733 | reqsk_put(req); |
1732 | } else if (tcp_filter(sk, skb)) { | ||
1733 | goto discard_and_relse; | ||
1734 | } else if (tcp_child_process(sk, nsk, skb)) { | 1734 | } else if (tcp_child_process(sk, nsk, skb)) { |
1735 | tcp_v4_send_reset(nsk, skb); | 1735 | tcp_v4_send_reset(nsk, skb); |
1736 | goto discard_and_relse; | 1736 | goto discard_and_relse; |
diff --git a/net/ipv4/tcp_ulp.c b/net/ipv4/tcp_ulp.c index 2417f55374c5..6bb9e14c710a 100644 --- a/net/ipv4/tcp_ulp.c +++ b/net/ipv4/tcp_ulp.c | |||
@@ -122,14 +122,14 @@ int tcp_set_ulp(struct sock *sk, const char *name) | |||
122 | 122 | ||
123 | ulp_ops = __tcp_ulp_find_autoload(name); | 123 | ulp_ops = __tcp_ulp_find_autoload(name); |
124 | if (!ulp_ops) | 124 | if (!ulp_ops) |
125 | err = -ENOENT; | 125 | return -ENOENT; |
126 | else | ||
127 | err = ulp_ops->init(sk); | ||
128 | 126 | ||
129 | if (err) | 127 | err = ulp_ops->init(sk); |
130 | goto out; | 128 | if (err) { |
129 | module_put(ulp_ops->owner); | ||
130 | return err; | ||
131 | } | ||
131 | 132 | ||
132 | icsk->icsk_ulp_ops = ulp_ops; | 133 | icsk->icsk_ulp_ops = ulp_ops; |
133 | out: | 134 | return 0; |
134 | return err; | ||
135 | } | 135 | } |
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index e6276fa3750b..cd1d044a7fa5 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c | |||
@@ -802,7 +802,7 @@ static int udp_send_skb(struct sk_buff *skb, struct flowi4 *fl4) | |||
802 | if (is_udplite) /* UDP-Lite */ | 802 | if (is_udplite) /* UDP-Lite */ |
803 | csum = udplite_csum(skb); | 803 | csum = udplite_csum(skb); |
804 | 804 | ||
805 | else if (sk->sk_no_check_tx) { /* UDP csum disabled */ | 805 | else if (sk->sk_no_check_tx && !skb_is_gso(skb)) { /* UDP csum off */ |
806 | 806 | ||
807 | skb->ip_summed = CHECKSUM_NONE; | 807 | skb->ip_summed = CHECKSUM_NONE; |
808 | goto send; | 808 | goto send; |
@@ -1574,7 +1574,8 @@ int udp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int noblock, | |||
1574 | return ip_recv_error(sk, msg, len, addr_len); | 1574 | return ip_recv_error(sk, msg, len, addr_len); |
1575 | 1575 | ||
1576 | try_again: | 1576 | try_again: |
1577 | peeking = off = sk_peek_offset(sk, flags); | 1577 | peeking = flags & MSG_PEEK; |
1578 | off = sk_peek_offset(sk, flags); | ||
1578 | skb = __skb_recv_udp(sk, flags, noblock, &peeked, &off, &err); | 1579 | skb = __skb_recv_udp(sk, flags, noblock, &peeked, &off, &err); |
1579 | if (!skb) | 1580 | if (!skb) |
1580 | return err; | 1581 | return err; |
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c index ebb299cf72b7..5cc0ea038198 100644 --- a/net/ipv6/ip6_fib.c +++ b/net/ipv6/ip6_fib.c | |||
@@ -914,6 +914,8 @@ add: | |||
914 | } | 914 | } |
915 | nsiblings = iter->rt6i_nsiblings; | 915 | nsiblings = iter->rt6i_nsiblings; |
916 | fib6_purge_rt(iter, fn, info->nl_net); | 916 | fib6_purge_rt(iter, fn, info->nl_net); |
917 | if (fn->rr_ptr == iter) | ||
918 | fn->rr_ptr = NULL; | ||
917 | rt6_release(iter); | 919 | rt6_release(iter); |
918 | 920 | ||
919 | if (nsiblings) { | 921 | if (nsiblings) { |
@@ -926,6 +928,8 @@ add: | |||
926 | if (rt6_qualify_for_ecmp(iter)) { | 928 | if (rt6_qualify_for_ecmp(iter)) { |
927 | *ins = iter->dst.rt6_next; | 929 | *ins = iter->dst.rt6_next; |
928 | fib6_purge_rt(iter, fn, info->nl_net); | 930 | fib6_purge_rt(iter, fn, info->nl_net); |
931 | if (fn->rr_ptr == iter) | ||
932 | fn->rr_ptr = NULL; | ||
929 | rt6_release(iter); | 933 | rt6_release(iter); |
930 | nsiblings--; | 934 | nsiblings--; |
931 | } else { | 935 | } else { |
@@ -1014,7 +1018,7 @@ int fib6_add(struct fib6_node *root, struct rt6_info *rt, | |||
1014 | /* Create subtree root node */ | 1018 | /* Create subtree root node */ |
1015 | sfn = node_alloc(); | 1019 | sfn = node_alloc(); |
1016 | if (!sfn) | 1020 | if (!sfn) |
1017 | goto st_failure; | 1021 | goto failure; |
1018 | 1022 | ||
1019 | sfn->leaf = info->nl_net->ipv6.ip6_null_entry; | 1023 | sfn->leaf = info->nl_net->ipv6.ip6_null_entry; |
1020 | atomic_inc(&info->nl_net->ipv6.ip6_null_entry->rt6i_ref); | 1024 | atomic_inc(&info->nl_net->ipv6.ip6_null_entry->rt6i_ref); |
@@ -1031,12 +1035,12 @@ int fib6_add(struct fib6_node *root, struct rt6_info *rt, | |||
1031 | 1035 | ||
1032 | if (IS_ERR(sn)) { | 1036 | if (IS_ERR(sn)) { |
1033 | /* If it is failed, discard just allocated | 1037 | /* If it is failed, discard just allocated |
1034 | root, and then (in st_failure) stale node | 1038 | root, and then (in failure) stale node |
1035 | in main tree. | 1039 | in main tree. |
1036 | */ | 1040 | */ |
1037 | node_free(sfn); | 1041 | node_free(sfn); |
1038 | err = PTR_ERR(sn); | 1042 | err = PTR_ERR(sn); |
1039 | goto st_failure; | 1043 | goto failure; |
1040 | } | 1044 | } |
1041 | 1045 | ||
1042 | /* Now link new subtree to main tree */ | 1046 | /* Now link new subtree to main tree */ |
@@ -1051,7 +1055,7 @@ int fib6_add(struct fib6_node *root, struct rt6_info *rt, | |||
1051 | 1055 | ||
1052 | if (IS_ERR(sn)) { | 1056 | if (IS_ERR(sn)) { |
1053 | err = PTR_ERR(sn); | 1057 | err = PTR_ERR(sn); |
1054 | goto st_failure; | 1058 | goto failure; |
1055 | } | 1059 | } |
1056 | } | 1060 | } |
1057 | 1061 | ||
@@ -1092,18 +1096,17 @@ out: | |||
1092 | atomic_inc(&pn->leaf->rt6i_ref); | 1096 | atomic_inc(&pn->leaf->rt6i_ref); |
1093 | } | 1097 | } |
1094 | #endif | 1098 | #endif |
1095 | /* Always release dst as dst->__refcnt is guaranteed | 1099 | goto failure; |
1096 | * to be taken before entering this function | ||
1097 | */ | ||
1098 | dst_release_immediate(&rt->dst); | ||
1099 | } | 1100 | } |
1100 | return err; | 1101 | return err; |
1101 | 1102 | ||
1102 | #ifdef CONFIG_IPV6_SUBTREES | 1103 | failure: |
1103 | /* Subtree creation failed, probably main tree node | 1104 | /* fn->leaf could be NULL if fn is an intermediate node and we |
1104 | is orphan. If it is, shoot it. | 1105 | * failed to add the new route to it in both subtree creation |
1106 | * failure and fib6_add_rt2node() failure case. | ||
1107 | * In both cases, fib6_repair_tree() should be called to fix | ||
1108 | * fn->leaf. | ||
1105 | */ | 1109 | */ |
1106 | st_failure: | ||
1107 | if (fn && !(fn->fn_flags & (RTN_RTINFO|RTN_ROOT))) | 1110 | if (fn && !(fn->fn_flags & (RTN_RTINFO|RTN_ROOT))) |
1108 | fib6_repair_tree(info->nl_net, fn); | 1111 | fib6_repair_tree(info->nl_net, fn); |
1109 | /* Always release dst as dst->__refcnt is guaranteed | 1112 | /* Always release dst as dst->__refcnt is guaranteed |
@@ -1111,7 +1114,6 @@ st_failure: | |||
1111 | */ | 1114 | */ |
1112 | dst_release_immediate(&rt->dst); | 1115 | dst_release_immediate(&rt->dst); |
1113 | return err; | 1116 | return err; |
1114 | #endif | ||
1115 | } | 1117 | } |
1116 | 1118 | ||
1117 | /* | 1119 | /* |
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c index 162efba0d0cd..2dfe50d8d609 100644 --- a/net/ipv6/ip6_output.c +++ b/net/ipv6/ip6_output.c | |||
@@ -1381,11 +1381,12 @@ emsgsize: | |||
1381 | */ | 1381 | */ |
1382 | 1382 | ||
1383 | cork->length += length; | 1383 | cork->length += length; |
1384 | if ((((length + (skb ? skb->len : headersize)) > mtu) || | 1384 | if ((skb && skb_is_gso(skb)) || |
1385 | (skb && skb_is_gso(skb))) && | 1385 | (((length + (skb ? skb->len : headersize)) > mtu) && |
1386 | (skb_queue_len(queue) <= 1) && | ||
1386 | (sk->sk_protocol == IPPROTO_UDP) && | 1387 | (sk->sk_protocol == IPPROTO_UDP) && |
1387 | (rt->dst.dev->features & NETIF_F_UFO) && !dst_xfrm(&rt->dst) && | 1388 | (rt->dst.dev->features & NETIF_F_UFO) && !dst_xfrm(&rt->dst) && |
1388 | (sk->sk_type == SOCK_DGRAM) && !udp_get_no_check6_tx(sk)) { | 1389 | (sk->sk_type == SOCK_DGRAM) && !udp_get_no_check6_tx(sk))) { |
1389 | err = ip6_ufo_append_data(sk, queue, getfrag, from, length, | 1390 | err = ip6_ufo_append_data(sk, queue, getfrag, from, length, |
1390 | hh_len, fragheaderlen, exthdrlen, | 1391 | hh_len, fragheaderlen, exthdrlen, |
1391 | transhdrlen, mtu, flags, fl6); | 1392 | transhdrlen, mtu, flags, fl6); |
diff --git a/net/ipv6/route.c b/net/ipv6/route.c index a640fbcba15d..94d6a13d47f0 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c | |||
@@ -417,14 +417,11 @@ static void ip6_dst_ifdown(struct dst_entry *dst, struct net_device *dev, | |||
417 | struct net_device *loopback_dev = | 417 | struct net_device *loopback_dev = |
418 | dev_net(dev)->loopback_dev; | 418 | dev_net(dev)->loopback_dev; |
419 | 419 | ||
420 | if (dev != loopback_dev) { | 420 | if (idev && idev->dev != loopback_dev) { |
421 | if (idev && idev->dev == dev) { | 421 | struct inet6_dev *loopback_idev = in6_dev_get(loopback_dev); |
422 | struct inet6_dev *loopback_idev = | 422 | if (loopback_idev) { |
423 | in6_dev_get(loopback_dev); | 423 | rt->rt6i_idev = loopback_idev; |
424 | if (loopback_idev) { | 424 | in6_dev_put(idev); |
425 | rt->rt6i_idev = loopback_idev; | ||
426 | in6_dev_put(idev); | ||
427 | } | ||
428 | } | 425 | } |
429 | } | 426 | } |
430 | } | 427 | } |
@@ -3724,10 +3721,10 @@ static int ip6_route_dev_notify(struct notifier_block *this, | |||
3724 | /* NETDEV_UNREGISTER could be fired for multiple times by | 3721 | /* NETDEV_UNREGISTER could be fired for multiple times by |
3725 | * netdev_wait_allrefs(). Make sure we only call this once. | 3722 | * netdev_wait_allrefs(). Make sure we only call this once. |
3726 | */ | 3723 | */ |
3727 | in6_dev_put(net->ipv6.ip6_null_entry->rt6i_idev); | 3724 | in6_dev_put_clear(&net->ipv6.ip6_null_entry->rt6i_idev); |
3728 | #ifdef CONFIG_IPV6_MULTIPLE_TABLES | 3725 | #ifdef CONFIG_IPV6_MULTIPLE_TABLES |
3729 | in6_dev_put(net->ipv6.ip6_prohibit_entry->rt6i_idev); | 3726 | in6_dev_put_clear(&net->ipv6.ip6_prohibit_entry->rt6i_idev); |
3730 | in6_dev_put(net->ipv6.ip6_blk_hole_entry->rt6i_idev); | 3727 | in6_dev_put_clear(&net->ipv6.ip6_blk_hole_entry->rt6i_idev); |
3731 | #endif | 3728 | #endif |
3732 | } | 3729 | } |
3733 | 3730 | ||
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index 2521690d62d6..206210125fd7 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c | |||
@@ -1456,6 +1456,8 @@ process: | |||
1456 | } | 1456 | } |
1457 | sock_hold(sk); | 1457 | sock_hold(sk); |
1458 | refcounted = true; | 1458 | refcounted = true; |
1459 | if (tcp_filter(sk, skb)) | ||
1460 | goto discard_and_relse; | ||
1459 | nsk = tcp_check_req(sk, skb, req, false); | 1461 | nsk = tcp_check_req(sk, skb, req, false); |
1460 | if (!nsk) { | 1462 | if (!nsk) { |
1461 | reqsk_put(req); | 1463 | reqsk_put(req); |
@@ -1464,8 +1466,6 @@ process: | |||
1464 | if (nsk == sk) { | 1466 | if (nsk == sk) { |
1465 | reqsk_put(req); | 1467 | reqsk_put(req); |
1466 | tcp_v6_restore_cb(skb); | 1468 | tcp_v6_restore_cb(skb); |
1467 | } else if (tcp_filter(sk, skb)) { | ||
1468 | goto discard_and_relse; | ||
1469 | } else if (tcp_child_process(sk, nsk, skb)) { | 1469 | } else if (tcp_child_process(sk, nsk, skb)) { |
1470 | tcp_v6_send_reset(nsk, skb); | 1470 | tcp_v6_send_reset(nsk, skb); |
1471 | goto discard_and_relse; | 1471 | goto discard_and_relse; |
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c index 578142b7ca3e..20039c8501eb 100644 --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c | |||
@@ -362,7 +362,8 @@ int udpv6_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, | |||
362 | return ipv6_recv_rxpmtu(sk, msg, len, addr_len); | 362 | return ipv6_recv_rxpmtu(sk, msg, len, addr_len); |
363 | 363 | ||
364 | try_again: | 364 | try_again: |
365 | peeking = off = sk_peek_offset(sk, flags); | 365 | peeking = flags & MSG_PEEK; |
366 | off = sk_peek_offset(sk, flags); | ||
366 | skb = __skb_recv_udp(sk, flags, noblock, &peeked, &off, &err); | 367 | skb = __skb_recv_udp(sk, flags, noblock, &peeked, &off, &err); |
367 | if (!skb) | 368 | if (!skb) |
368 | return err; | 369 | return err; |
diff --git a/net/irda/af_irda.c b/net/irda/af_irda.c index 2e6990f8b80b..23fa7c8b09a5 100644 --- a/net/irda/af_irda.c +++ b/net/irda/af_irda.c | |||
@@ -2213,7 +2213,7 @@ static int irda_getsockopt(struct socket *sock, int level, int optname, | |||
2213 | { | 2213 | { |
2214 | struct sock *sk = sock->sk; | 2214 | struct sock *sk = sock->sk; |
2215 | struct irda_sock *self = irda_sk(sk); | 2215 | struct irda_sock *self = irda_sk(sk); |
2216 | struct irda_device_list list; | 2216 | struct irda_device_list list = { 0 }; |
2217 | struct irda_device_info *discoveries; | 2217 | struct irda_device_info *discoveries; |
2218 | struct irda_ias_set * ias_opt; /* IAS get/query params */ | 2218 | struct irda_ias_set * ias_opt; /* IAS get/query params */ |
2219 | struct ias_object * ias_obj; /* Object in IAS */ | 2219 | struct ias_object * ias_obj; /* Object in IAS */ |
diff --git a/net/key/af_key.c b/net/key/af_key.c index ca9d3ae665e7..98f4d8211b9a 100644 --- a/net/key/af_key.c +++ b/net/key/af_key.c | |||
@@ -228,7 +228,7 @@ static int pfkey_broadcast_one(struct sk_buff *skb, struct sk_buff **skb2, | |||
228 | #define BROADCAST_ONE 1 | 228 | #define BROADCAST_ONE 1 |
229 | #define BROADCAST_REGISTERED 2 | 229 | #define BROADCAST_REGISTERED 2 |
230 | #define BROADCAST_PROMISC_ONLY 4 | 230 | #define BROADCAST_PROMISC_ONLY 4 |
231 | static int pfkey_broadcast(struct sk_buff *skb, | 231 | static int pfkey_broadcast(struct sk_buff *skb, gfp_t allocation, |
232 | int broadcast_flags, struct sock *one_sk, | 232 | int broadcast_flags, struct sock *one_sk, |
233 | struct net *net) | 233 | struct net *net) |
234 | { | 234 | { |
@@ -278,7 +278,7 @@ static int pfkey_broadcast(struct sk_buff *skb, | |||
278 | rcu_read_unlock(); | 278 | rcu_read_unlock(); |
279 | 279 | ||
280 | if (one_sk != NULL) | 280 | if (one_sk != NULL) |
281 | err = pfkey_broadcast_one(skb, &skb2, GFP_KERNEL, one_sk); | 281 | err = pfkey_broadcast_one(skb, &skb2, allocation, one_sk); |
282 | 282 | ||
283 | kfree_skb(skb2); | 283 | kfree_skb(skb2); |
284 | kfree_skb(skb); | 284 | kfree_skb(skb); |
@@ -311,7 +311,7 @@ static int pfkey_do_dump(struct pfkey_sock *pfk) | |||
311 | hdr = (struct sadb_msg *) pfk->dump.skb->data; | 311 | hdr = (struct sadb_msg *) pfk->dump.skb->data; |
312 | hdr->sadb_msg_seq = 0; | 312 | hdr->sadb_msg_seq = 0; |
313 | hdr->sadb_msg_errno = rc; | 313 | hdr->sadb_msg_errno = rc; |
314 | pfkey_broadcast(pfk->dump.skb, BROADCAST_ONE, | 314 | pfkey_broadcast(pfk->dump.skb, GFP_ATOMIC, BROADCAST_ONE, |
315 | &pfk->sk, sock_net(&pfk->sk)); | 315 | &pfk->sk, sock_net(&pfk->sk)); |
316 | pfk->dump.skb = NULL; | 316 | pfk->dump.skb = NULL; |
317 | } | 317 | } |
@@ -355,7 +355,7 @@ static int pfkey_error(const struct sadb_msg *orig, int err, struct sock *sk) | |||
355 | hdr->sadb_msg_len = (sizeof(struct sadb_msg) / | 355 | hdr->sadb_msg_len = (sizeof(struct sadb_msg) / |
356 | sizeof(uint64_t)); | 356 | sizeof(uint64_t)); |
357 | 357 | ||
358 | pfkey_broadcast(skb, BROADCAST_ONE, sk, sock_net(sk)); | 358 | pfkey_broadcast(skb, GFP_KERNEL, BROADCAST_ONE, sk, sock_net(sk)); |
359 | 359 | ||
360 | return 0; | 360 | return 0; |
361 | } | 361 | } |
@@ -1389,7 +1389,7 @@ static int pfkey_getspi(struct sock *sk, struct sk_buff *skb, const struct sadb_ | |||
1389 | 1389 | ||
1390 | xfrm_state_put(x); | 1390 | xfrm_state_put(x); |
1391 | 1391 | ||
1392 | pfkey_broadcast(resp_skb, BROADCAST_ONE, sk, net); | 1392 | pfkey_broadcast(resp_skb, GFP_KERNEL, BROADCAST_ONE, sk, net); |
1393 | 1393 | ||
1394 | return 0; | 1394 | return 0; |
1395 | } | 1395 | } |
@@ -1476,7 +1476,7 @@ static int key_notify_sa(struct xfrm_state *x, const struct km_event *c) | |||
1476 | hdr->sadb_msg_seq = c->seq; | 1476 | hdr->sadb_msg_seq = c->seq; |
1477 | hdr->sadb_msg_pid = c->portid; | 1477 | hdr->sadb_msg_pid = c->portid; |
1478 | 1478 | ||
1479 | pfkey_broadcast(skb, BROADCAST_ALL, NULL, xs_net(x)); | 1479 | pfkey_broadcast(skb, GFP_ATOMIC, BROADCAST_ALL, NULL, xs_net(x)); |
1480 | 1480 | ||
1481 | return 0; | 1481 | return 0; |
1482 | } | 1482 | } |
@@ -1589,7 +1589,7 @@ static int pfkey_get(struct sock *sk, struct sk_buff *skb, const struct sadb_msg | |||
1589 | out_hdr->sadb_msg_reserved = 0; | 1589 | out_hdr->sadb_msg_reserved = 0; |
1590 | out_hdr->sadb_msg_seq = hdr->sadb_msg_seq; | 1590 | out_hdr->sadb_msg_seq = hdr->sadb_msg_seq; |
1591 | out_hdr->sadb_msg_pid = hdr->sadb_msg_pid; | 1591 | out_hdr->sadb_msg_pid = hdr->sadb_msg_pid; |
1592 | pfkey_broadcast(out_skb, BROADCAST_ONE, sk, sock_net(sk)); | 1592 | pfkey_broadcast(out_skb, GFP_ATOMIC, BROADCAST_ONE, sk, sock_net(sk)); |
1593 | 1593 | ||
1594 | return 0; | 1594 | return 0; |
1595 | } | 1595 | } |
@@ -1694,8 +1694,8 @@ static int pfkey_register(struct sock *sk, struct sk_buff *skb, const struct sad | |||
1694 | return -ENOBUFS; | 1694 | return -ENOBUFS; |
1695 | } | 1695 | } |
1696 | 1696 | ||
1697 | pfkey_broadcast(supp_skb, BROADCAST_REGISTERED, sk, sock_net(sk)); | 1697 | pfkey_broadcast(supp_skb, GFP_KERNEL, BROADCAST_REGISTERED, sk, |
1698 | 1698 | sock_net(sk)); | |
1699 | return 0; | 1699 | return 0; |
1700 | } | 1700 | } |
1701 | 1701 | ||
@@ -1712,7 +1712,8 @@ static int unicast_flush_resp(struct sock *sk, const struct sadb_msg *ihdr) | |||
1712 | hdr->sadb_msg_errno = (uint8_t) 0; | 1712 | hdr->sadb_msg_errno = (uint8_t) 0; |
1713 | hdr->sadb_msg_len = (sizeof(struct sadb_msg) / sizeof(uint64_t)); | 1713 | hdr->sadb_msg_len = (sizeof(struct sadb_msg) / sizeof(uint64_t)); |
1714 | 1714 | ||
1715 | return pfkey_broadcast(skb, BROADCAST_ONE, sk, sock_net(sk)); | 1715 | return pfkey_broadcast(skb, GFP_ATOMIC, BROADCAST_ONE, sk, |
1716 | sock_net(sk)); | ||
1716 | } | 1717 | } |
1717 | 1718 | ||
1718 | static int key_notify_sa_flush(const struct km_event *c) | 1719 | static int key_notify_sa_flush(const struct km_event *c) |
@@ -1733,7 +1734,7 @@ static int key_notify_sa_flush(const struct km_event *c) | |||
1733 | hdr->sadb_msg_len = (sizeof(struct sadb_msg) / sizeof(uint64_t)); | 1734 | hdr->sadb_msg_len = (sizeof(struct sadb_msg) / sizeof(uint64_t)); |
1734 | hdr->sadb_msg_reserved = 0; | 1735 | hdr->sadb_msg_reserved = 0; |
1735 | 1736 | ||
1736 | pfkey_broadcast(skb, BROADCAST_ALL, NULL, c->net); | 1737 | pfkey_broadcast(skb, GFP_ATOMIC, BROADCAST_ALL, NULL, c->net); |
1737 | 1738 | ||
1738 | return 0; | 1739 | return 0; |
1739 | } | 1740 | } |
@@ -1790,7 +1791,7 @@ static int dump_sa(struct xfrm_state *x, int count, void *ptr) | |||
1790 | out_hdr->sadb_msg_pid = pfk->dump.msg_portid; | 1791 | out_hdr->sadb_msg_pid = pfk->dump.msg_portid; |
1791 | 1792 | ||
1792 | if (pfk->dump.skb) | 1793 | if (pfk->dump.skb) |
1793 | pfkey_broadcast(pfk->dump.skb, BROADCAST_ONE, | 1794 | pfkey_broadcast(pfk->dump.skb, GFP_ATOMIC, BROADCAST_ONE, |
1794 | &pfk->sk, sock_net(&pfk->sk)); | 1795 | &pfk->sk, sock_net(&pfk->sk)); |
1795 | pfk->dump.skb = out_skb; | 1796 | pfk->dump.skb = out_skb; |
1796 | 1797 | ||
@@ -1878,7 +1879,7 @@ static int pfkey_promisc(struct sock *sk, struct sk_buff *skb, const struct sadb | |||
1878 | new_hdr->sadb_msg_errno = 0; | 1879 | new_hdr->sadb_msg_errno = 0; |
1879 | } | 1880 | } |
1880 | 1881 | ||
1881 | pfkey_broadcast(skb, BROADCAST_ALL, NULL, sock_net(sk)); | 1882 | pfkey_broadcast(skb, GFP_KERNEL, BROADCAST_ALL, NULL, sock_net(sk)); |
1882 | return 0; | 1883 | return 0; |
1883 | } | 1884 | } |
1884 | 1885 | ||
@@ -2206,7 +2207,7 @@ static int key_notify_policy(struct xfrm_policy *xp, int dir, const struct km_ev | |||
2206 | out_hdr->sadb_msg_errno = 0; | 2207 | out_hdr->sadb_msg_errno = 0; |
2207 | out_hdr->sadb_msg_seq = c->seq; | 2208 | out_hdr->sadb_msg_seq = c->seq; |
2208 | out_hdr->sadb_msg_pid = c->portid; | 2209 | out_hdr->sadb_msg_pid = c->portid; |
2209 | pfkey_broadcast(out_skb, BROADCAST_ALL, NULL, xp_net(xp)); | 2210 | pfkey_broadcast(out_skb, GFP_ATOMIC, BROADCAST_ALL, NULL, xp_net(xp)); |
2210 | return 0; | 2211 | return 0; |
2211 | 2212 | ||
2212 | } | 2213 | } |
@@ -2426,7 +2427,7 @@ static int key_pol_get_resp(struct sock *sk, struct xfrm_policy *xp, const struc | |||
2426 | out_hdr->sadb_msg_errno = 0; | 2427 | out_hdr->sadb_msg_errno = 0; |
2427 | out_hdr->sadb_msg_seq = hdr->sadb_msg_seq; | 2428 | out_hdr->sadb_msg_seq = hdr->sadb_msg_seq; |
2428 | out_hdr->sadb_msg_pid = hdr->sadb_msg_pid; | 2429 | out_hdr->sadb_msg_pid = hdr->sadb_msg_pid; |
2429 | pfkey_broadcast(out_skb, BROADCAST_ONE, sk, xp_net(xp)); | 2430 | pfkey_broadcast(out_skb, GFP_ATOMIC, BROADCAST_ONE, sk, xp_net(xp)); |
2430 | err = 0; | 2431 | err = 0; |
2431 | 2432 | ||
2432 | out: | 2433 | out: |
@@ -2682,7 +2683,7 @@ static int dump_sp(struct xfrm_policy *xp, int dir, int count, void *ptr) | |||
2682 | out_hdr->sadb_msg_pid = pfk->dump.msg_portid; | 2683 | out_hdr->sadb_msg_pid = pfk->dump.msg_portid; |
2683 | 2684 | ||
2684 | if (pfk->dump.skb) | 2685 | if (pfk->dump.skb) |
2685 | pfkey_broadcast(pfk->dump.skb, BROADCAST_ONE, | 2686 | pfkey_broadcast(pfk->dump.skb, GFP_ATOMIC, BROADCAST_ONE, |
2686 | &pfk->sk, sock_net(&pfk->sk)); | 2687 | &pfk->sk, sock_net(&pfk->sk)); |
2687 | pfk->dump.skb = out_skb; | 2688 | pfk->dump.skb = out_skb; |
2688 | 2689 | ||
@@ -2739,7 +2740,7 @@ static int key_notify_policy_flush(const struct km_event *c) | |||
2739 | hdr->sadb_msg_satype = SADB_SATYPE_UNSPEC; | 2740 | hdr->sadb_msg_satype = SADB_SATYPE_UNSPEC; |
2740 | hdr->sadb_msg_len = (sizeof(struct sadb_msg) / sizeof(uint64_t)); | 2741 | hdr->sadb_msg_len = (sizeof(struct sadb_msg) / sizeof(uint64_t)); |
2741 | hdr->sadb_msg_reserved = 0; | 2742 | hdr->sadb_msg_reserved = 0; |
2742 | pfkey_broadcast(skb_out, BROADCAST_ALL, NULL, c->net); | 2743 | pfkey_broadcast(skb_out, GFP_ATOMIC, BROADCAST_ALL, NULL, c->net); |
2743 | return 0; | 2744 | return 0; |
2744 | 2745 | ||
2745 | } | 2746 | } |
@@ -2803,7 +2804,7 @@ static int pfkey_process(struct sock *sk, struct sk_buff *skb, const struct sadb | |||
2803 | void *ext_hdrs[SADB_EXT_MAX]; | 2804 | void *ext_hdrs[SADB_EXT_MAX]; |
2804 | int err; | 2805 | int err; |
2805 | 2806 | ||
2806 | pfkey_broadcast(skb_clone(skb, GFP_KERNEL), | 2807 | pfkey_broadcast(skb_clone(skb, GFP_KERNEL), GFP_KERNEL, |
2807 | BROADCAST_PROMISC_ONLY, NULL, sock_net(sk)); | 2808 | BROADCAST_PROMISC_ONLY, NULL, sock_net(sk)); |
2808 | 2809 | ||
2809 | memset(ext_hdrs, 0, sizeof(ext_hdrs)); | 2810 | memset(ext_hdrs, 0, sizeof(ext_hdrs)); |
@@ -3024,7 +3025,8 @@ static int key_notify_sa_expire(struct xfrm_state *x, const struct km_event *c) | |||
3024 | out_hdr->sadb_msg_seq = 0; | 3025 | out_hdr->sadb_msg_seq = 0; |
3025 | out_hdr->sadb_msg_pid = 0; | 3026 | out_hdr->sadb_msg_pid = 0; |
3026 | 3027 | ||
3027 | pfkey_broadcast(out_skb, BROADCAST_REGISTERED, NULL, xs_net(x)); | 3028 | pfkey_broadcast(out_skb, GFP_ATOMIC, BROADCAST_REGISTERED, NULL, |
3029 | xs_net(x)); | ||
3028 | return 0; | 3030 | return 0; |
3029 | } | 3031 | } |
3030 | 3032 | ||
@@ -3212,7 +3214,8 @@ static int pfkey_send_acquire(struct xfrm_state *x, struct xfrm_tmpl *t, struct | |||
3212 | xfrm_ctx->ctx_len); | 3214 | xfrm_ctx->ctx_len); |
3213 | } | 3215 | } |
3214 | 3216 | ||
3215 | return pfkey_broadcast(skb, BROADCAST_REGISTERED, NULL, xs_net(x)); | 3217 | return pfkey_broadcast(skb, GFP_ATOMIC, BROADCAST_REGISTERED, NULL, |
3218 | xs_net(x)); | ||
3216 | } | 3219 | } |
3217 | 3220 | ||
3218 | static struct xfrm_policy *pfkey_compile_policy(struct sock *sk, int opt, | 3221 | static struct xfrm_policy *pfkey_compile_policy(struct sock *sk, int opt, |
@@ -3408,7 +3411,8 @@ static int pfkey_send_new_mapping(struct xfrm_state *x, xfrm_address_t *ipaddr, | |||
3408 | n_port->sadb_x_nat_t_port_port = sport; | 3411 | n_port->sadb_x_nat_t_port_port = sport; |
3409 | n_port->sadb_x_nat_t_port_reserved = 0; | 3412 | n_port->sadb_x_nat_t_port_reserved = 0; |
3410 | 3413 | ||
3411 | return pfkey_broadcast(skb, BROADCAST_REGISTERED, NULL, xs_net(x)); | 3414 | return pfkey_broadcast(skb, GFP_ATOMIC, BROADCAST_REGISTERED, NULL, |
3415 | xs_net(x)); | ||
3412 | } | 3416 | } |
3413 | 3417 | ||
3414 | #ifdef CONFIG_NET_KEY_MIGRATE | 3418 | #ifdef CONFIG_NET_KEY_MIGRATE |
@@ -3599,7 +3603,7 @@ static int pfkey_send_migrate(const struct xfrm_selector *sel, u8 dir, u8 type, | |||
3599 | } | 3603 | } |
3600 | 3604 | ||
3601 | /* broadcast migrate message to sockets */ | 3605 | /* broadcast migrate message to sockets */ |
3602 | pfkey_broadcast(skb, BROADCAST_ALL, NULL, &init_net); | 3606 | pfkey_broadcast(skb, GFP_ATOMIC, BROADCAST_ALL, NULL, &init_net); |
3603 | 3607 | ||
3604 | return 0; | 3608 | return 0; |
3605 | 3609 | ||
diff --git a/net/mac80211/agg-rx.c b/net/mac80211/agg-rx.c index 8708cbe8af5b..2b36eff5d97e 100644 --- a/net/mac80211/agg-rx.c +++ b/net/mac80211/agg-rx.c | |||
@@ -7,7 +7,7 @@ | |||
7 | * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz> | 7 | * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz> |
8 | * Copyright 2007, Michael Wu <flamingice@sourmilk.net> | 8 | * Copyright 2007, Michael Wu <flamingice@sourmilk.net> |
9 | * Copyright 2007-2010, Intel Corporation | 9 | * Copyright 2007-2010, Intel Corporation |
10 | * Copyright(c) 2015 Intel Deutschland GmbH | 10 | * Copyright(c) 2015-2017 Intel Deutschland GmbH |
11 | * | 11 | * |
12 | * This program is free software; you can redistribute it and/or modify | 12 | * This program is free software; you can redistribute it and/or modify |
13 | * it under the terms of the GNU General Public License version 2 as | 13 | * it under the terms of the GNU General Public License version 2 as |
@@ -466,3 +466,23 @@ void ieee80211_manage_rx_ba_offl(struct ieee80211_vif *vif, | |||
466 | rcu_read_unlock(); | 466 | rcu_read_unlock(); |
467 | } | 467 | } |
468 | EXPORT_SYMBOL(ieee80211_manage_rx_ba_offl); | 468 | EXPORT_SYMBOL(ieee80211_manage_rx_ba_offl); |
469 | |||
470 | void ieee80211_rx_ba_timer_expired(struct ieee80211_vif *vif, | ||
471 | const u8 *addr, unsigned int tid) | ||
472 | { | ||
473 | struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif); | ||
474 | struct ieee80211_local *local = sdata->local; | ||
475 | struct sta_info *sta; | ||
476 | |||
477 | rcu_read_lock(); | ||
478 | sta = sta_info_get_bss(sdata, addr); | ||
479 | if (!sta) | ||
480 | goto unlock; | ||
481 | |||
482 | set_bit(tid, sta->ampdu_mlme.tid_rx_timer_expired); | ||
483 | ieee80211_queue_work(&local->hw, &sta->ampdu_mlme.work); | ||
484 | |||
485 | unlock: | ||
486 | rcu_read_unlock(); | ||
487 | } | ||
488 | EXPORT_SYMBOL(ieee80211_rx_ba_timer_expired); | ||
diff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c index e4610676299b..a54a556fcdb5 100644 --- a/net/openvswitch/actions.c +++ b/net/openvswitch/actions.c | |||
@@ -1337,6 +1337,7 @@ int ovs_execute_actions(struct datapath *dp, struct sk_buff *skb, | |||
1337 | goto out; | 1337 | goto out; |
1338 | } | 1338 | } |
1339 | 1339 | ||
1340 | OVS_CB(skb)->acts_origlen = acts->orig_len; | ||
1340 | err = do_execute_actions(dp, skb, key, | 1341 | err = do_execute_actions(dp, skb, key, |
1341 | acts->actions, acts->actions_len); | 1342 | acts->actions, acts->actions_len); |
1342 | 1343 | ||
diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c index 45fe8c8a884d..6b44fe405282 100644 --- a/net/openvswitch/datapath.c +++ b/net/openvswitch/datapath.c | |||
@@ -381,7 +381,7 @@ static int queue_gso_packets(struct datapath *dp, struct sk_buff *skb, | |||
381 | } | 381 | } |
382 | 382 | ||
383 | static size_t upcall_msg_size(const struct dp_upcall_info *upcall_info, | 383 | static size_t upcall_msg_size(const struct dp_upcall_info *upcall_info, |
384 | unsigned int hdrlen) | 384 | unsigned int hdrlen, int actions_attrlen) |
385 | { | 385 | { |
386 | size_t size = NLMSG_ALIGN(sizeof(struct ovs_header)) | 386 | size_t size = NLMSG_ALIGN(sizeof(struct ovs_header)) |
387 | + nla_total_size(hdrlen) /* OVS_PACKET_ATTR_PACKET */ | 387 | + nla_total_size(hdrlen) /* OVS_PACKET_ATTR_PACKET */ |
@@ -398,7 +398,7 @@ static size_t upcall_msg_size(const struct dp_upcall_info *upcall_info, | |||
398 | 398 | ||
399 | /* OVS_PACKET_ATTR_ACTIONS */ | 399 | /* OVS_PACKET_ATTR_ACTIONS */ |
400 | if (upcall_info->actions_len) | 400 | if (upcall_info->actions_len) |
401 | size += nla_total_size(upcall_info->actions_len); | 401 | size += nla_total_size(actions_attrlen); |
402 | 402 | ||
403 | /* OVS_PACKET_ATTR_MRU */ | 403 | /* OVS_PACKET_ATTR_MRU */ |
404 | if (upcall_info->mru) | 404 | if (upcall_info->mru) |
@@ -465,7 +465,8 @@ static int queue_userspace_packet(struct datapath *dp, struct sk_buff *skb, | |||
465 | else | 465 | else |
466 | hlen = skb->len; | 466 | hlen = skb->len; |
467 | 467 | ||
468 | len = upcall_msg_size(upcall_info, hlen - cutlen); | 468 | len = upcall_msg_size(upcall_info, hlen - cutlen, |
469 | OVS_CB(skb)->acts_origlen); | ||
469 | user_skb = genlmsg_new(len, GFP_ATOMIC); | 470 | user_skb = genlmsg_new(len, GFP_ATOMIC); |
470 | if (!user_skb) { | 471 | if (!user_skb) { |
471 | err = -ENOMEM; | 472 | err = -ENOMEM; |
diff --git a/net/openvswitch/datapath.h b/net/openvswitch/datapath.h index 5d8dcd88815f..480600649d0b 100644 --- a/net/openvswitch/datapath.h +++ b/net/openvswitch/datapath.h | |||
@@ -99,11 +99,13 @@ struct datapath { | |||
99 | * when a packet is received by OVS. | 99 | * when a packet is received by OVS. |
100 | * @mru: The maximum received fragement size; 0 if the packet is not | 100 | * @mru: The maximum received fragement size; 0 if the packet is not |
101 | * fragmented. | 101 | * fragmented. |
102 | * @acts_origlen: The netlink size of the flow actions applied to this skb. | ||
102 | * @cutlen: The number of bytes from the packet end to be removed. | 103 | * @cutlen: The number of bytes from the packet end to be removed. |
103 | */ | 104 | */ |
104 | struct ovs_skb_cb { | 105 | struct ovs_skb_cb { |
105 | struct vport *input_vport; | 106 | struct vport *input_vport; |
106 | u16 mru; | 107 | u16 mru; |
108 | u16 acts_origlen; | ||
107 | u32 cutlen; | 109 | u32 cutlen; |
108 | }; | 110 | }; |
109 | #define OVS_CB(skb) ((struct ovs_skb_cb *)(skb)->cb) | 111 | #define OVS_CB(skb) ((struct ovs_skb_cb *)(skb)->cb) |
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index 0615c2a950fa..008a45ca3112 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c | |||
@@ -3700,14 +3700,19 @@ packet_setsockopt(struct socket *sock, int level, int optname, char __user *optv | |||
3700 | 3700 | ||
3701 | if (optlen != sizeof(val)) | 3701 | if (optlen != sizeof(val)) |
3702 | return -EINVAL; | 3702 | return -EINVAL; |
3703 | if (po->rx_ring.pg_vec || po->tx_ring.pg_vec) | ||
3704 | return -EBUSY; | ||
3705 | if (copy_from_user(&val, optval, sizeof(val))) | 3703 | if (copy_from_user(&val, optval, sizeof(val))) |
3706 | return -EFAULT; | 3704 | return -EFAULT; |
3707 | if (val > INT_MAX) | 3705 | if (val > INT_MAX) |
3708 | return -EINVAL; | 3706 | return -EINVAL; |
3709 | po->tp_reserve = val; | 3707 | lock_sock(sk); |
3710 | return 0; | 3708 | if (po->rx_ring.pg_vec || po->tx_ring.pg_vec) { |
3709 | ret = -EBUSY; | ||
3710 | } else { | ||
3711 | po->tp_reserve = val; | ||
3712 | ret = 0; | ||
3713 | } | ||
3714 | release_sock(sk); | ||
3715 | return ret; | ||
3711 | } | 3716 | } |
3712 | case PACKET_LOSS: | 3717 | case PACKET_LOSS: |
3713 | { | 3718 | { |
diff --git a/net/rxrpc/call_accept.c b/net/rxrpc/call_accept.c index dd30d74824b0..ec3383f97d4c 100644 --- a/net/rxrpc/call_accept.c +++ b/net/rxrpc/call_accept.c | |||
@@ -223,6 +223,7 @@ void rxrpc_discard_prealloc(struct rxrpc_sock *rx) | |||
223 | tail = b->call_backlog_tail; | 223 | tail = b->call_backlog_tail; |
224 | while (CIRC_CNT(head, tail, size) > 0) { | 224 | while (CIRC_CNT(head, tail, size) > 0) { |
225 | struct rxrpc_call *call = b->call_backlog[tail]; | 225 | struct rxrpc_call *call = b->call_backlog[tail]; |
226 | call->socket = rx; | ||
226 | if (rx->discard_new_call) { | 227 | if (rx->discard_new_call) { |
227 | _debug("discard %lx", call->user_call_ID); | 228 | _debug("discard %lx", call->user_call_ID); |
228 | rx->discard_new_call(call, call->user_call_ID); | 229 | rx->discard_new_call(call, call->user_call_ID); |
diff --git a/net/sched/act_ipt.c b/net/sched/act_ipt.c index 94ba5cfab860..541707802a23 100644 --- a/net/sched/act_ipt.c +++ b/net/sched/act_ipt.c | |||
@@ -41,6 +41,7 @@ static int ipt_init_target(struct net *net, struct xt_entry_target *t, | |||
41 | { | 41 | { |
42 | struct xt_tgchk_param par; | 42 | struct xt_tgchk_param par; |
43 | struct xt_target *target; | 43 | struct xt_target *target; |
44 | struct ipt_entry e = {}; | ||
44 | int ret = 0; | 45 | int ret = 0; |
45 | 46 | ||
46 | target = xt_request_find_target(AF_INET, t->u.user.name, | 47 | target = xt_request_find_target(AF_INET, t->u.user.name, |
@@ -49,9 +50,10 @@ static int ipt_init_target(struct net *net, struct xt_entry_target *t, | |||
49 | return PTR_ERR(target); | 50 | return PTR_ERR(target); |
50 | 51 | ||
51 | t->u.kernel.target = target; | 52 | t->u.kernel.target = target; |
53 | memset(&par, 0, sizeof(par)); | ||
52 | par.net = net; | 54 | par.net = net; |
53 | par.table = table; | 55 | par.table = table; |
54 | par.entryinfo = NULL; | 56 | par.entryinfo = &e; |
55 | par.target = target; | 57 | par.target = target; |
56 | par.targinfo = t->data; | 58 | par.targinfo = t->data; |
57 | par.hook_mask = hook; | 59 | par.hook_mask = hook; |
diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c index 39da0c5801c9..9fd44c221347 100644 --- a/net/sched/cls_api.c +++ b/net/sched/cls_api.c | |||
@@ -205,7 +205,7 @@ static void tcf_chain_flush(struct tcf_chain *chain) | |||
205 | { | 205 | { |
206 | struct tcf_proto *tp; | 206 | struct tcf_proto *tp; |
207 | 207 | ||
208 | if (*chain->p_filter_chain) | 208 | if (chain->p_filter_chain) |
209 | RCU_INIT_POINTER(*chain->p_filter_chain, NULL); | 209 | RCU_INIT_POINTER(*chain->p_filter_chain, NULL); |
210 | while ((tp = rtnl_dereference(chain->filter_chain)) != NULL) { | 210 | while ((tp = rtnl_dereference(chain->filter_chain)) != NULL) { |
211 | RCU_INIT_POINTER(chain->filter_chain, tp->next); | 211 | RCU_INIT_POINTER(chain->filter_chain, tp->next); |
diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c index bd24a550e0f9..a3fa144b8648 100644 --- a/net/sched/sch_api.c +++ b/net/sched/sch_api.c | |||
@@ -286,9 +286,6 @@ static struct Qdisc *qdisc_match_from_root(struct Qdisc *root, u32 handle) | |||
286 | void qdisc_hash_add(struct Qdisc *q, bool invisible) | 286 | void qdisc_hash_add(struct Qdisc *q, bool invisible) |
287 | { | 287 | { |
288 | if ((q->parent != TC_H_ROOT) && !(q->flags & TCQ_F_INGRESS)) { | 288 | if ((q->parent != TC_H_ROOT) && !(q->flags & TCQ_F_INGRESS)) { |
289 | struct Qdisc *root = qdisc_dev(q)->qdisc; | ||
290 | |||
291 | WARN_ON_ONCE(root == &noop_qdisc); | ||
292 | ASSERT_RTNL(); | 289 | ASSERT_RTNL(); |
293 | hash_add_rcu(qdisc_dev(q)->qdisc_hash, &q->hash, q->handle); | 290 | hash_add_rcu(qdisc_dev(q)->qdisc_hash, &q->hash, q->handle); |
294 | if (invisible) | 291 | if (invisible) |
diff --git a/net/sched/sch_atm.c b/net/sched/sch_atm.c index 572fe2584e48..c403c87aff7a 100644 --- a/net/sched/sch_atm.c +++ b/net/sched/sch_atm.c | |||
@@ -572,8 +572,10 @@ static void atm_tc_destroy(struct Qdisc *sch) | |||
572 | struct atm_flow_data *flow, *tmp; | 572 | struct atm_flow_data *flow, *tmp; |
573 | 573 | ||
574 | pr_debug("atm_tc_destroy(sch %p,[qdisc %p])\n", sch, p); | 574 | pr_debug("atm_tc_destroy(sch %p,[qdisc %p])\n", sch, p); |
575 | list_for_each_entry(flow, &p->flows, list) | 575 | list_for_each_entry(flow, &p->flows, list) { |
576 | tcf_block_put(flow->block); | 576 | tcf_block_put(flow->block); |
577 | flow->block = NULL; | ||
578 | } | ||
577 | 579 | ||
578 | list_for_each_entry_safe(flow, tmp, &p->flows, list) { | 580 | list_for_each_entry_safe(flow, tmp, &p->flows, list) { |
579 | if (flow->ref > 1) | 581 | if (flow->ref > 1) |
diff --git a/net/sched/sch_cbq.c b/net/sched/sch_cbq.c index 481036f6b54e..780db43300b1 100644 --- a/net/sched/sch_cbq.c +++ b/net/sched/sch_cbq.c | |||
@@ -1431,8 +1431,10 @@ static void cbq_destroy(struct Qdisc *sch) | |||
1431 | * be bound to classes which have been destroyed already. --TGR '04 | 1431 | * be bound to classes which have been destroyed already. --TGR '04 |
1432 | */ | 1432 | */ |
1433 | for (h = 0; h < q->clhash.hashsize; h++) { | 1433 | for (h = 0; h < q->clhash.hashsize; h++) { |
1434 | hlist_for_each_entry(cl, &q->clhash.hash[h], common.hnode) | 1434 | hlist_for_each_entry(cl, &q->clhash.hash[h], common.hnode) { |
1435 | tcf_block_put(cl->block); | 1435 | tcf_block_put(cl->block); |
1436 | cl->block = NULL; | ||
1437 | } | ||
1436 | } | 1438 | } |
1437 | for (h = 0; h < q->clhash.hashsize; h++) { | 1439 | for (h = 0; h < q->clhash.hashsize; h++) { |
1438 | hlist_for_each_entry_safe(cl, next, &q->clhash.hash[h], | 1440 | hlist_for_each_entry_safe(cl, next, &q->clhash.hash[h], |
diff --git a/net/sched/sch_hfsc.c b/net/sched/sch_hfsc.c index b52f74610dc7..fd15200f8627 100644 --- a/net/sched/sch_hfsc.c +++ b/net/sched/sch_hfsc.c | |||
@@ -1428,6 +1428,10 @@ hfsc_init_qdisc(struct Qdisc *sch, struct nlattr *opt) | |||
1428 | return err; | 1428 | return err; |
1429 | q->eligible = RB_ROOT; | 1429 | q->eligible = RB_ROOT; |
1430 | 1430 | ||
1431 | err = tcf_block_get(&q->root.block, &q->root.filter_list); | ||
1432 | if (err) | ||
1433 | goto err_tcf; | ||
1434 | |||
1431 | q->root.cl_common.classid = sch->handle; | 1435 | q->root.cl_common.classid = sch->handle; |
1432 | q->root.refcnt = 1; | 1436 | q->root.refcnt = 1; |
1433 | q->root.sched = q; | 1437 | q->root.sched = q; |
@@ -1447,6 +1451,10 @@ hfsc_init_qdisc(struct Qdisc *sch, struct nlattr *opt) | |||
1447 | qdisc_watchdog_init(&q->watchdog, sch); | 1451 | qdisc_watchdog_init(&q->watchdog, sch); |
1448 | 1452 | ||
1449 | return 0; | 1453 | return 0; |
1454 | |||
1455 | err_tcf: | ||
1456 | qdisc_class_hash_destroy(&q->clhash); | ||
1457 | return err; | ||
1450 | } | 1458 | } |
1451 | 1459 | ||
1452 | static int | 1460 | static int |
@@ -1522,8 +1530,10 @@ hfsc_destroy_qdisc(struct Qdisc *sch) | |||
1522 | unsigned int i; | 1530 | unsigned int i; |
1523 | 1531 | ||
1524 | for (i = 0; i < q->clhash.hashsize; i++) { | 1532 | for (i = 0; i < q->clhash.hashsize; i++) { |
1525 | hlist_for_each_entry(cl, &q->clhash.hash[i], cl_common.hnode) | 1533 | hlist_for_each_entry(cl, &q->clhash.hash[i], cl_common.hnode) { |
1526 | tcf_block_put(cl->block); | 1534 | tcf_block_put(cl->block); |
1535 | cl->block = NULL; | ||
1536 | } | ||
1527 | } | 1537 | } |
1528 | for (i = 0; i < q->clhash.hashsize; i++) { | 1538 | for (i = 0; i < q->clhash.hashsize; i++) { |
1529 | hlist_for_each_entry_safe(cl, next, &q->clhash.hash[i], | 1539 | hlist_for_each_entry_safe(cl, next, &q->clhash.hash[i], |
diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c index 203286ab4427..5d65ec5207e9 100644 --- a/net/sched/sch_htb.c +++ b/net/sched/sch_htb.c | |||
@@ -1258,8 +1258,10 @@ static void htb_destroy(struct Qdisc *sch) | |||
1258 | tcf_block_put(q->block); | 1258 | tcf_block_put(q->block); |
1259 | 1259 | ||
1260 | for (i = 0; i < q->clhash.hashsize; i++) { | 1260 | for (i = 0; i < q->clhash.hashsize; i++) { |
1261 | hlist_for_each_entry(cl, &q->clhash.hash[i], common.hnode) | 1261 | hlist_for_each_entry(cl, &q->clhash.hash[i], common.hnode) { |
1262 | tcf_block_put(cl->block); | 1262 | tcf_block_put(cl->block); |
1263 | cl->block = NULL; | ||
1264 | } | ||
1263 | } | 1265 | } |
1264 | for (i = 0; i < q->clhash.hashsize; i++) { | 1266 | for (i = 0; i < q->clhash.hashsize; i++) { |
1265 | hlist_for_each_entry_safe(cl, next, &q->clhash.hash[i], | 1267 | hlist_for_each_entry_safe(cl, next, &q->clhash.hash[i], |
diff --git a/net/sched/sch_sfq.c b/net/sched/sch_sfq.c index f80ea2cc5f1f..82469ef9655e 100644 --- a/net/sched/sch_sfq.c +++ b/net/sched/sch_sfq.c | |||
@@ -437,6 +437,7 @@ congestion_drop: | |||
437 | qdisc_drop(head, sch, to_free); | 437 | qdisc_drop(head, sch, to_free); |
438 | 438 | ||
439 | slot_queue_add(slot, skb); | 439 | slot_queue_add(slot, skb); |
440 | qdisc_tree_reduce_backlog(sch, 0, delta); | ||
440 | return NET_XMIT_CN; | 441 | return NET_XMIT_CN; |
441 | } | 442 | } |
442 | 443 | ||
@@ -468,8 +469,10 @@ enqueue: | |||
468 | /* Return Congestion Notification only if we dropped a packet | 469 | /* Return Congestion Notification only if we dropped a packet |
469 | * from this flow. | 470 | * from this flow. |
470 | */ | 471 | */ |
471 | if (qlen != slot->qlen) | 472 | if (qlen != slot->qlen) { |
473 | qdisc_tree_reduce_backlog(sch, 0, dropped - qdisc_pkt_len(skb)); | ||
472 | return NET_XMIT_CN; | 474 | return NET_XMIT_CN; |
475 | } | ||
473 | 476 | ||
474 | /* As we dropped a packet, better let upper stack know this */ | 477 | /* As we dropped a packet, better let upper stack know this */ |
475 | qdisc_tree_reduce_backlog(sch, 1, dropped); | 478 | qdisc_tree_reduce_backlog(sch, 1, dropped); |
diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c index 2a186b201ad2..a4b6ffb61495 100644 --- a/net/sctp/ipv6.c +++ b/net/sctp/ipv6.c | |||
@@ -512,7 +512,9 @@ static void sctp_v6_to_addr(union sctp_addr *addr, struct in6_addr *saddr, | |||
512 | { | 512 | { |
513 | addr->sa.sa_family = AF_INET6; | 513 | addr->sa.sa_family = AF_INET6; |
514 | addr->v6.sin6_port = port; | 514 | addr->v6.sin6_port = port; |
515 | addr->v6.sin6_flowinfo = 0; | ||
515 | addr->v6.sin6_addr = *saddr; | 516 | addr->v6.sin6_addr = *saddr; |
517 | addr->v6.sin6_scope_id = 0; | ||
516 | } | 518 | } |
517 | 519 | ||
518 | /* Compare addresses exactly. | 520 | /* Compare addresses exactly. |
diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c index d174ee3254ee..767e0537dde5 100644 --- a/net/tipc/bearer.c +++ b/net/tipc/bearer.c | |||
@@ -596,7 +596,7 @@ static int tipc_l2_rcv_msg(struct sk_buff *skb, struct net_device *dev, | |||
596 | rcu_read_lock(); | 596 | rcu_read_lock(); |
597 | b = rcu_dereference_rtnl(dev->tipc_ptr); | 597 | b = rcu_dereference_rtnl(dev->tipc_ptr); |
598 | if (likely(b && test_bit(0, &b->up) && | 598 | if (likely(b && test_bit(0, &b->up) && |
599 | (skb->pkt_type <= PACKET_BROADCAST))) { | 599 | (skb->pkt_type <= PACKET_MULTICAST))) { |
600 | skb->next = NULL; | 600 | skb->next = NULL; |
601 | tipc_rcv(dev_net(dev), skb, b); | 601 | tipc_rcv(dev_net(dev), skb, b); |
602 | rcu_read_unlock(); | 602 | rcu_read_unlock(); |
diff --git a/net/tipc/msg.c b/net/tipc/msg.c index ab3087687a32..dcd90e6fa7c3 100644 --- a/net/tipc/msg.c +++ b/net/tipc/msg.c | |||
@@ -513,6 +513,7 @@ bool tipc_msg_reverse(u32 own_node, struct sk_buff **skb, int err) | |||
513 | 513 | ||
514 | /* Now reverse the concerned fields */ | 514 | /* Now reverse the concerned fields */ |
515 | msg_set_errcode(hdr, err); | 515 | msg_set_errcode(hdr, err); |
516 | msg_set_non_seq(hdr, 0); | ||
516 | msg_set_origport(hdr, msg_destport(&ohdr)); | 517 | msg_set_origport(hdr, msg_destport(&ohdr)); |
517 | msg_set_destport(hdr, msg_origport(&ohdr)); | 518 | msg_set_destport(hdr, msg_origport(&ohdr)); |
518 | msg_set_destnode(hdr, msg_prevnode(&ohdr)); | 519 | msg_set_destnode(hdr, msg_prevnode(&ohdr)); |
diff --git a/net/tipc/netlink_compat.c b/net/tipc/netlink_compat.c index 9bfe886ab330..750949dfc1d7 100644 --- a/net/tipc/netlink_compat.c +++ b/net/tipc/netlink_compat.c | |||
@@ -258,13 +258,15 @@ static int tipc_nl_compat_dumpit(struct tipc_nl_compat_cmd_dump *cmd, | |||
258 | arg = nlmsg_new(0, GFP_KERNEL); | 258 | arg = nlmsg_new(0, GFP_KERNEL); |
259 | if (!arg) { | 259 | if (!arg) { |
260 | kfree_skb(msg->rep); | 260 | kfree_skb(msg->rep); |
261 | msg->rep = NULL; | ||
261 | return -ENOMEM; | 262 | return -ENOMEM; |
262 | } | 263 | } |
263 | 264 | ||
264 | err = __tipc_nl_compat_dumpit(cmd, msg, arg); | 265 | err = __tipc_nl_compat_dumpit(cmd, msg, arg); |
265 | if (err) | 266 | if (err) { |
266 | kfree_skb(msg->rep); | 267 | kfree_skb(msg->rep); |
267 | 268 | msg->rep = NULL; | |
269 | } | ||
268 | kfree_skb(arg); | 270 | kfree_skb(arg); |
269 | 271 | ||
270 | return err; | 272 | return err; |
diff --git a/net/tipc/node.c b/net/tipc/node.c index aeef8011ac7d..9b4dcb6a16b5 100644 --- a/net/tipc/node.c +++ b/net/tipc/node.c | |||
@@ -1455,10 +1455,8 @@ static bool tipc_node_check_state(struct tipc_node *n, struct sk_buff *skb, | |||
1455 | /* Initiate synch mode if applicable */ | 1455 | /* Initiate synch mode if applicable */ |
1456 | if ((usr == TUNNEL_PROTOCOL) && (mtyp == SYNCH_MSG) && (oseqno == 1)) { | 1456 | if ((usr == TUNNEL_PROTOCOL) && (mtyp == SYNCH_MSG) && (oseqno == 1)) { |
1457 | syncpt = iseqno + exp_pkts - 1; | 1457 | syncpt = iseqno + exp_pkts - 1; |
1458 | if (!tipc_link_is_up(l)) { | 1458 | if (!tipc_link_is_up(l)) |
1459 | tipc_link_fsm_evt(l, LINK_ESTABLISH_EVT); | ||
1460 | __tipc_node_link_up(n, bearer_id, xmitq); | 1459 | __tipc_node_link_up(n, bearer_id, xmitq); |
1461 | } | ||
1462 | if (n->state == SELF_UP_PEER_UP) { | 1460 | if (n->state == SELF_UP_PEER_UP) { |
1463 | n->sync_point = syncpt; | 1461 | n->sync_point = syncpt; |
1464 | tipc_link_fsm_evt(l, LINK_SYNCH_BEGIN_EVT); | 1462 | tipc_link_fsm_evt(l, LINK_SYNCH_BEGIN_EVT); |
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index 7b52a380d710..be8982b4f8c0 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c | |||
@@ -2304,10 +2304,7 @@ static int unix_stream_read_generic(struct unix_stream_read_state *state, | |||
2304 | */ | 2304 | */ |
2305 | mutex_lock(&u->iolock); | 2305 | mutex_lock(&u->iolock); |
2306 | 2306 | ||
2307 | if (flags & MSG_PEEK) | 2307 | skip = max(sk_peek_offset(sk, flags), 0); |
2308 | skip = sk_peek_offset(sk, flags); | ||
2309 | else | ||
2310 | skip = 0; | ||
2311 | 2308 | ||
2312 | do { | 2309 | do { |
2313 | int chunk; | 2310 | int chunk; |
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index dd8e2dde0b34..9ffd3dda3889 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include | |||
@@ -85,8 +85,8 @@ TMPOUT := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/) | |||
85 | 85 | ||
86 | # try-run | 86 | # try-run |
87 | # Usage: option = $(call try-run, $(CC)...-o "$$TMP",option-ok,otherwise) | 87 | # Usage: option = $(call try-run, $(CC)...-o "$$TMP",option-ok,otherwise) |
88 | # Exit code chooses option. "$$TMP" is can be used as temporary file and | 88 | # Exit code chooses option. "$$TMP" serves as a temporary file and is |
89 | # is automatically cleaned up. | 89 | # automatically cleaned up. |
90 | try-run = $(shell set -e; \ | 90 | try-run = $(shell set -e; \ |
91 | TMP="$(TMPOUT).$$$$.tmp"; \ | 91 | TMP="$(TMPOUT).$$$$.tmp"; \ |
92 | TMPO="$(TMPOUT).$$$$.o"; \ | 92 | TMPO="$(TMPOUT).$$$$.o"; \ |
@@ -261,7 +261,6 @@ make-cmd = $(call escsq,$(subst \#,\\\#,$(subst $$,$$$$,$(cmd_$(1))))) | |||
261 | any-prereq = $(filter-out $(PHONY),$?) $(filter-out $(PHONY) $(wildcard $^),$^) | 261 | any-prereq = $(filter-out $(PHONY),$?) $(filter-out $(PHONY) $(wildcard $^),$^) |
262 | 262 | ||
263 | # Execute command if command has changed or prerequisite(s) are updated. | 263 | # Execute command if command has changed or prerequisite(s) are updated. |
264 | # | ||
265 | if_changed = $(if $(strip $(any-prereq) $(arg-check)), \ | 264 | if_changed = $(if $(strip $(any-prereq) $(arg-check)), \ |
266 | @set -e; \ | 265 | @set -e; \ |
267 | $(echo-cmd) $(cmd_$(1)); \ | 266 | $(echo-cmd) $(cmd_$(1)); \ |
@@ -315,7 +314,7 @@ if_changed_rule = $(if $(strip $(any-prereq) $(arg-check) ), \ | |||
315 | $(rule_$(1)), @:) | 314 | $(rule_$(1)), @:) |
316 | 315 | ||
317 | ### | 316 | ### |
318 | # why - tell why a a target got build | 317 | # why - tell why a target got built |
319 | # enabled by make V=2 | 318 | # enabled by make V=2 |
320 | # Output (listed in the order they are checked): | 319 | # Output (listed in the order they are checked): |
321 | # (1) - due to target is PHONY | 320 | # (1) - due to target is PHONY |
diff --git a/scripts/Makefile.asm-generic b/scripts/Makefile.asm-generic index 95f7d8090152..a6c8c1780855 100644 --- a/scripts/Makefile.asm-generic +++ b/scripts/Makefile.asm-generic | |||
@@ -1,9 +1,9 @@ | |||
1 | # include/asm-generic contains a lot of files that are used | 1 | # include/asm-generic contains a lot of files that are used |
2 | # verbatim by several architectures. | 2 | # verbatim by several architectures. |
3 | # | 3 | # |
4 | # This Makefile reads the file arch/$(SRCARCH)/include/asm/Kbuild | 4 | # This Makefile reads the file arch/$(SRCARCH)/include/$(src)/Kbuild |
5 | # and for each file listed in this file with generic-y creates | 5 | # and for each file listed in this file with generic-y creates |
6 | # a small wrapper file in $(obj) (arch/$(SRCARCH)/include/generated/asm) | 6 | # a small wrapper file in $(obj) (arch/$(SRCARCH)/include/generated/$(src)) |
7 | 7 | ||
8 | kbuild-file := $(srctree)/arch/$(SRCARCH)/include/$(src)/Kbuild | 8 | kbuild-file := $(srctree)/arch/$(SRCARCH)/include/$(src)/Kbuild |
9 | -include $(kbuild-file) | 9 | -include $(kbuild-file) |
diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 4a9a2cec0a1b..f6152c70f7f4 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build | |||
@@ -229,8 +229,8 @@ ifeq ("$(origin RECORDMCOUNT_WARN)", "command line") | |||
229 | endif | 229 | endif |
230 | # Due to recursion, we must skip empty.o. | 230 | # Due to recursion, we must skip empty.o. |
231 | # The empty.o file is created in the make process in order to determine | 231 | # The empty.o file is created in the make process in order to determine |
232 | # the target endianness and word size. It is made before all other C | 232 | # the target endianness and word size. It is made before all other C |
233 | # files, including recordmcount. | 233 | # files, including recordmcount. |
234 | sub_cmd_record_mcount = \ | 234 | sub_cmd_record_mcount = \ |
235 | if [ $(@) != "scripts/mod/empty.o" ]; then \ | 235 | if [ $(@) != "scripts/mod/empty.o" ]; then \ |
236 | $(objtree)/scripts/recordmcount $(RECORDMCOUNT_FLAGS) "$(@)"; \ | 236 | $(objtree)/scripts/recordmcount $(RECORDMCOUNT_FLAGS) "$(@)"; \ |
@@ -245,13 +245,13 @@ sub_cmd_record_mcount = set -e ; perl $(srctree)/scripts/recordmcount.pl "$(ARCH | |||
245 | "$(LD)" "$(NM)" "$(RM)" "$(MV)" \ | 245 | "$(LD)" "$(NM)" "$(RM)" "$(MV)" \ |
246 | "$(if $(part-of-module),1,0)" "$(@)"; | 246 | "$(if $(part-of-module),1,0)" "$(@)"; |
247 | recordmcount_source := $(srctree)/scripts/recordmcount.pl | 247 | recordmcount_source := $(srctree)/scripts/recordmcount.pl |
248 | endif | 248 | endif # BUILD_C_RECORDMCOUNT |
249 | cmd_record_mcount = \ | 249 | cmd_record_mcount = \ |
250 | if [ "$(findstring $(CC_FLAGS_FTRACE),$(_c_flags))" = \ | 250 | if [ "$(findstring $(CC_FLAGS_FTRACE),$(_c_flags))" = \ |
251 | "$(CC_FLAGS_FTRACE)" ]; then \ | 251 | "$(CC_FLAGS_FTRACE)" ]; then \ |
252 | $(sub_cmd_record_mcount) \ | 252 | $(sub_cmd_record_mcount) \ |
253 | fi; | 253 | fi; |
254 | endif | 254 | endif # CONFIG_FTRACE_MCOUNT_RECORD |
255 | 255 | ||
256 | ifdef CONFIG_STACK_VALIDATION | 256 | ifdef CONFIG_STACK_VALIDATION |
257 | ifneq ($(SKIP_STACK_VALIDATION),1) | 257 | ifneq ($(SKIP_STACK_VALIDATION),1) |
diff --git a/scripts/Makefile.dtbinst b/scripts/Makefile.dtbinst index 34614a48b717..993fb85982df 100644 --- a/scripts/Makefile.dtbinst +++ b/scripts/Makefile.dtbinst | |||
@@ -14,7 +14,7 @@ src := $(obj) | |||
14 | PHONY := __dtbs_install | 14 | PHONY := __dtbs_install |
15 | __dtbs_install: | 15 | __dtbs_install: |
16 | 16 | ||
17 | export dtbinst-root ?= $(obj) | 17 | export dtbinst_root ?= $(obj) |
18 | 18 | ||
19 | include include/config/auto.conf | 19 | include include/config/auto.conf |
20 | include scripts/Kbuild.include | 20 | include scripts/Kbuild.include |
@@ -27,7 +27,7 @@ dtbinst-dirs := $(dts-dirs) | |||
27 | quiet_cmd_dtb_install = INSTALL $< | 27 | quiet_cmd_dtb_install = INSTALL $< |
28 | cmd_dtb_install = mkdir -p $(2); cp $< $(2) | 28 | cmd_dtb_install = mkdir -p $(2); cp $< $(2) |
29 | 29 | ||
30 | install-dir = $(patsubst $(dtbinst-root)%,$(INSTALL_DTBS_PATH)%,$(obj)) | 30 | install-dir = $(patsubst $(dtbinst_root)%,$(INSTALL_DTBS_PATH)%,$(obj)) |
31 | 31 | ||
32 | $(dtbinst-files): %.dtb: $(obj)/%.dtb | 32 | $(dtbinst-files): %.dtb: $(obj)/%.dtb |
33 | $(call cmd,dtb_install,$(install-dir)) | 33 | $(call cmd,dtb_install,$(install-dir)) |
diff --git a/scripts/basic/Makefile b/scripts/basic/Makefile index ec10d9345bc2..0372b33febe5 100644 --- a/scripts/basic/Makefile +++ b/scripts/basic/Makefile | |||
@@ -1,5 +1,5 @@ | |||
1 | ### | 1 | ### |
2 | # Makefile.basic lists the most basic programs used during the build process. | 2 | # This Makefile lists the most basic programs used during the build process. |
3 | # The programs listed herein are what are needed to do the basic stuff, | 3 | # The programs listed herein are what are needed to do the basic stuff, |
4 | # such as fix file dependencies. | 4 | # such as fix file dependencies. |
5 | # This initial step is needed to avoid files to be recompiled | 5 | # This initial step is needed to avoid files to be recompiled |
diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c index fff818b92acb..bbf62cb1f819 100644 --- a/scripts/basic/fixdep.c +++ b/scripts/basic/fixdep.c | |||
@@ -25,7 +25,7 @@ | |||
25 | * | 25 | * |
26 | * So we play the same trick that "mkdep" played before. We replace | 26 | * So we play the same trick that "mkdep" played before. We replace |
27 | * the dependency on autoconf.h by a dependency on every config | 27 | * the dependency on autoconf.h by a dependency on every config |
28 | * option which is mentioned in any of the listed prequisites. | 28 | * option which is mentioned in any of the listed prerequisites. |
29 | * | 29 | * |
30 | * kconfig populates a tree in include/config/ with an empty file | 30 | * kconfig populates a tree in include/config/ with an empty file |
31 | * for each config symbol and when the configuration is updated | 31 | * for each config symbol and when the configuration is updated |
@@ -34,7 +34,7 @@ | |||
34 | * the config symbols are rebuilt. | 34 | * the config symbols are rebuilt. |
35 | * | 35 | * |
36 | * So if the user changes his CONFIG_HIS_DRIVER option, only the objects | 36 | * So if the user changes his CONFIG_HIS_DRIVER option, only the objects |
37 | * which depend on "include/linux/config/his/driver.h" will be rebuilt, | 37 | * which depend on "include/config/his/driver.h" will be rebuilt, |
38 | * so most likely only his driver ;-) | 38 | * so most likely only his driver ;-) |
39 | * | 39 | * |
40 | * The idea above dates, by the way, back to Michael E Chastain, AFAIK. | 40 | * The idea above dates, by the way, back to Michael E Chastain, AFAIK. |
@@ -75,7 +75,7 @@ | |||
75 | * and then basically copies the .<target>.d file to stdout, in the | 75 | * and then basically copies the .<target>.d file to stdout, in the |
76 | * process filtering out the dependency on autoconf.h and adding | 76 | * process filtering out the dependency on autoconf.h and adding |
77 | * dependencies on include/config/my/option.h for every | 77 | * dependencies on include/config/my/option.h for every |
78 | * CONFIG_MY_OPTION encountered in any of the prequisites. | 78 | * CONFIG_MY_OPTION encountered in any of the prerequisites. |
79 | * | 79 | * |
80 | * It will also filter out all the dependencies on *.ver. We need | 80 | * It will also filter out all the dependencies on *.ver. We need |
81 | * to make sure that the generated version checksum are globally up | 81 | * to make sure that the generated version checksum are globally up |
diff --git a/sound/core/seq/Kconfig b/sound/core/seq/Kconfig index a536760a94c2..45c1336c6597 100644 --- a/sound/core/seq/Kconfig +++ b/sound/core/seq/Kconfig | |||
@@ -47,10 +47,10 @@ config SND_SEQ_HRTIMER_DEFAULT | |||
47 | timer. | 47 | timer. |
48 | 48 | ||
49 | config SND_SEQ_MIDI_EVENT | 49 | config SND_SEQ_MIDI_EVENT |
50 | def_tristate SND_RAWMIDI | 50 | tristate |
51 | 51 | ||
52 | config SND_SEQ_MIDI | 52 | config SND_SEQ_MIDI |
53 | tristate | 53 | def_tristate SND_RAWMIDI |
54 | select SND_SEQ_MIDI_EVENT | 54 | select SND_SEQ_MIDI_EVENT |
55 | 55 | ||
56 | config SND_SEQ_MIDI_EMUL | 56 | config SND_SEQ_MIDI_EMUL |
diff --git a/sound/core/seq/seq_clientmgr.c b/sound/core/seq/seq_clientmgr.c index 272c55fe17c8..ea2d0ae85bd3 100644 --- a/sound/core/seq/seq_clientmgr.c +++ b/sound/core/seq/seq_clientmgr.c | |||
@@ -1502,16 +1502,11 @@ static int snd_seq_ioctl_unsubscribe_port(struct snd_seq_client *client, | |||
1502 | static int snd_seq_ioctl_create_queue(struct snd_seq_client *client, void *arg) | 1502 | static int snd_seq_ioctl_create_queue(struct snd_seq_client *client, void *arg) |
1503 | { | 1503 | { |
1504 | struct snd_seq_queue_info *info = arg; | 1504 | struct snd_seq_queue_info *info = arg; |
1505 | int result; | ||
1506 | struct snd_seq_queue *q; | 1505 | struct snd_seq_queue *q; |
1507 | 1506 | ||
1508 | result = snd_seq_queue_alloc(client->number, info->locked, info->flags); | 1507 | q = snd_seq_queue_alloc(client->number, info->locked, info->flags); |
1509 | if (result < 0) | 1508 | if (IS_ERR(q)) |
1510 | return result; | 1509 | return PTR_ERR(q); |
1511 | |||
1512 | q = queueptr(result); | ||
1513 | if (q == NULL) | ||
1514 | return -EINVAL; | ||
1515 | 1510 | ||
1516 | info->queue = q->queue; | 1511 | info->queue = q->queue; |
1517 | info->locked = q->locked; | 1512 | info->locked = q->locked; |
@@ -1521,7 +1516,7 @@ static int snd_seq_ioctl_create_queue(struct snd_seq_client *client, void *arg) | |||
1521 | if (!info->name[0]) | 1516 | if (!info->name[0]) |
1522 | snprintf(info->name, sizeof(info->name), "Queue-%d", q->queue); | 1517 | snprintf(info->name, sizeof(info->name), "Queue-%d", q->queue); |
1523 | strlcpy(q->name, info->name, sizeof(q->name)); | 1518 | strlcpy(q->name, info->name, sizeof(q->name)); |
1524 | queuefree(q); | 1519 | snd_use_lock_free(&q->use_lock); |
1525 | 1520 | ||
1526 | return 0; | 1521 | return 0; |
1527 | } | 1522 | } |
diff --git a/sound/core/seq/seq_queue.c b/sound/core/seq/seq_queue.c index 450c5187eecb..79e0c5604ef8 100644 --- a/sound/core/seq/seq_queue.c +++ b/sound/core/seq/seq_queue.c | |||
@@ -184,22 +184,26 @@ void __exit snd_seq_queues_delete(void) | |||
184 | static void queue_use(struct snd_seq_queue *queue, int client, int use); | 184 | static void queue_use(struct snd_seq_queue *queue, int client, int use); |
185 | 185 | ||
186 | /* allocate a new queue - | 186 | /* allocate a new queue - |
187 | * return queue index value or negative value for error | 187 | * return pointer to new queue or ERR_PTR(-errno) for error |
188 | * The new queue's use_lock is set to 1. It is the caller's responsibility to | ||
189 | * call snd_use_lock_free(&q->use_lock). | ||
188 | */ | 190 | */ |
189 | int snd_seq_queue_alloc(int client, int locked, unsigned int info_flags) | 191 | struct snd_seq_queue *snd_seq_queue_alloc(int client, int locked, unsigned int info_flags) |
190 | { | 192 | { |
191 | struct snd_seq_queue *q; | 193 | struct snd_seq_queue *q; |
192 | 194 | ||
193 | q = queue_new(client, locked); | 195 | q = queue_new(client, locked); |
194 | if (q == NULL) | 196 | if (q == NULL) |
195 | return -ENOMEM; | 197 | return ERR_PTR(-ENOMEM); |
196 | q->info_flags = info_flags; | 198 | q->info_flags = info_flags; |
197 | queue_use(q, client, 1); | 199 | queue_use(q, client, 1); |
200 | snd_use_lock_use(&q->use_lock); | ||
198 | if (queue_list_add(q) < 0) { | 201 | if (queue_list_add(q) < 0) { |
202 | snd_use_lock_free(&q->use_lock); | ||
199 | queue_delete(q); | 203 | queue_delete(q); |
200 | return -ENOMEM; | 204 | return ERR_PTR(-ENOMEM); |
201 | } | 205 | } |
202 | return q->queue; | 206 | return q; |
203 | } | 207 | } |
204 | 208 | ||
205 | /* delete a queue - queue must be owned by the client */ | 209 | /* delete a queue - queue must be owned by the client */ |
diff --git a/sound/core/seq/seq_queue.h b/sound/core/seq/seq_queue.h index 30c8111477f6..719093489a2c 100644 --- a/sound/core/seq/seq_queue.h +++ b/sound/core/seq/seq_queue.h | |||
@@ -71,7 +71,7 @@ void snd_seq_queues_delete(void); | |||
71 | 71 | ||
72 | 72 | ||
73 | /* create new queue (constructor) */ | 73 | /* create new queue (constructor) */ |
74 | int snd_seq_queue_alloc(int client, int locked, unsigned int flags); | 74 | struct snd_seq_queue *snd_seq_queue_alloc(int client, int locked, unsigned int flags); |
75 | 75 | ||
76 | /* delete queue (destructor) */ | 76 | /* delete queue (destructor) */ |
77 | int snd_seq_queue_delete(int client, int queueid); | 77 | int snd_seq_queue_delete(int client, int queueid); |
diff --git a/sound/pci/emu10k1/emufx.c b/sound/pci/emu10k1/emufx.c index dc585959ca32..a2b56b188be4 100644 --- a/sound/pci/emu10k1/emufx.c +++ b/sound/pci/emu10k1/emufx.c | |||
@@ -698,10 +698,18 @@ static int copy_gctl(struct snd_emu10k1 *emu, | |||
698 | { | 698 | { |
699 | struct snd_emu10k1_fx8010_control_old_gpr __user *octl; | 699 | struct snd_emu10k1_fx8010_control_old_gpr __user *octl; |
700 | 700 | ||
701 | if (emu->support_tlv) | 701 | if (emu->support_tlv) { |
702 | return copy_from_user(gctl, &_gctl[idx], sizeof(*gctl)); | 702 | if (in_kernel) |
703 | memcpy(gctl, (void *)&_gctl[idx], sizeof(*gctl)); | ||
704 | else if (copy_from_user(gctl, &_gctl[idx], sizeof(*gctl))) | ||
705 | return -EFAULT; | ||
706 | return 0; | ||
707 | } | ||
708 | |||
703 | octl = (struct snd_emu10k1_fx8010_control_old_gpr __user *)_gctl; | 709 | octl = (struct snd_emu10k1_fx8010_control_old_gpr __user *)_gctl; |
704 | if (copy_from_user(gctl, &octl[idx], sizeof(*octl))) | 710 | if (in_kernel) |
711 | memcpy(gctl, (void *)&octl[idx], sizeof(*octl)); | ||
712 | else if (copy_from_user(gctl, &octl[idx], sizeof(*octl))) | ||
705 | return -EFAULT; | 713 | return -EFAULT; |
706 | gctl->tlv = NULL; | 714 | gctl->tlv = NULL; |
707 | return 0; | 715 | return 0; |
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index a91a9ef00c40..217bb582aff1 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c | |||
@@ -6647,7 +6647,6 @@ static const struct snd_hda_pin_quirk alc269_pin_fixup_tbl[] = { | |||
6647 | SND_HDA_PIN_QUIRK(0x10ec0299, 0x1028, "Dell", ALC269_FIXUP_DELL4_MIC_NO_PRESENCE, | 6647 | SND_HDA_PIN_QUIRK(0x10ec0299, 0x1028, "Dell", ALC269_FIXUP_DELL4_MIC_NO_PRESENCE, |
6648 | ALC225_STANDARD_PINS, | 6648 | ALC225_STANDARD_PINS, |
6649 | {0x12, 0xb7a60130}, | 6649 | {0x12, 0xb7a60130}, |
6650 | {0x13, 0xb8a61140}, | ||
6651 | {0x17, 0x90170110}), | 6650 | {0x17, 0x90170110}), |
6652 | {} | 6651 | {} |
6653 | }; | 6652 | }; |
diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c index 082736c539bc..e630813c5008 100644 --- a/sound/usb/mixer.c +++ b/sound/usb/mixer.c | |||
@@ -542,6 +542,8 @@ int snd_usb_mixer_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag, | |||
542 | 542 | ||
543 | if (size < sizeof(scale)) | 543 | if (size < sizeof(scale)) |
544 | return -ENOMEM; | 544 | return -ENOMEM; |
545 | if (cval->min_mute) | ||
546 | scale[0] = SNDRV_CTL_TLVT_DB_MINMAX_MUTE; | ||
545 | scale[2] = cval->dBmin; | 547 | scale[2] = cval->dBmin; |
546 | scale[3] = cval->dBmax; | 548 | scale[3] = cval->dBmax; |
547 | if (copy_to_user(_tlv, scale, sizeof(scale))) | 549 | if (copy_to_user(_tlv, scale, sizeof(scale))) |
diff --git a/sound/usb/mixer.h b/sound/usb/mixer.h index 3417ef347e40..2b4b067646ab 100644 --- a/sound/usb/mixer.h +++ b/sound/usb/mixer.h | |||
@@ -64,6 +64,7 @@ struct usb_mixer_elem_info { | |||
64 | int cached; | 64 | int cached; |
65 | int cache_val[MAX_CHANNELS]; | 65 | int cache_val[MAX_CHANNELS]; |
66 | u8 initialized; | 66 | u8 initialized; |
67 | u8 min_mute; | ||
67 | void *private_data; | 68 | void *private_data; |
68 | }; | 69 | }; |
69 | 70 | ||
diff --git a/sound/usb/mixer_quirks.c b/sound/usb/mixer_quirks.c index e3d1dec48ee4..e1e7ce9ab217 100644 --- a/sound/usb/mixer_quirks.c +++ b/sound/usb/mixer_quirks.c | |||
@@ -1878,6 +1878,12 @@ void snd_usb_mixer_fu_apply_quirk(struct usb_mixer_interface *mixer, | |||
1878 | if (unitid == 7 && cval->control == UAC_FU_VOLUME) | 1878 | if (unitid == 7 && cval->control == UAC_FU_VOLUME) |
1879 | snd_dragonfly_quirk_db_scale(mixer, cval, kctl); | 1879 | snd_dragonfly_quirk_db_scale(mixer, cval, kctl); |
1880 | break; | 1880 | break; |
1881 | /* lowest playback value is muted on C-Media devices */ | ||
1882 | case USB_ID(0x0d8c, 0x000c): | ||
1883 | case USB_ID(0x0d8c, 0x0014): | ||
1884 | if (strstr(kctl->id.name, "Playback")) | ||
1885 | cval->min_mute = 1; | ||
1886 | break; | ||
1881 | } | 1887 | } |
1882 | } | 1888 | } |
1883 | 1889 | ||
diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c index d7b0b0a3a2db..6a03f9697039 100644 --- a/sound/usb/quirks.c +++ b/sound/usb/quirks.c | |||
@@ -1142,6 +1142,7 @@ bool snd_usb_get_sample_rate_quirk(struct snd_usb_audio *chip) | |||
1142 | case USB_ID(0x0556, 0x0014): /* Phoenix Audio TMX320VC */ | 1142 | case USB_ID(0x0556, 0x0014): /* Phoenix Audio TMX320VC */ |
1143 | case USB_ID(0x05A3, 0x9420): /* ELP HD USB Camera */ | 1143 | case USB_ID(0x05A3, 0x9420): /* ELP HD USB Camera */ |
1144 | case USB_ID(0x074D, 0x3553): /* Outlaw RR2150 (Micronas UAC3553B) */ | 1144 | case USB_ID(0x074D, 0x3553): /* Outlaw RR2150 (Micronas UAC3553B) */ |
1145 | case USB_ID(0x1395, 0x740a): /* Sennheiser DECT */ | ||
1145 | case USB_ID(0x1901, 0x0191): /* GE B850V3 CP2114 audio interface */ | 1146 | case USB_ID(0x1901, 0x0191): /* GE B850V3 CP2114 audio interface */ |
1146 | case USB_ID(0x1de7, 0x0013): /* Phoenix Audio MT202exe */ | 1147 | case USB_ID(0x1de7, 0x0013): /* Phoenix Audio MT202exe */ |
1147 | case USB_ID(0x1de7, 0x0014): /* Phoenix Audio TMX320 */ | 1148 | case USB_ID(0x1de7, 0x0014): /* Phoenix Audio TMX320 */ |
@@ -1374,6 +1375,10 @@ u64 snd_usb_interface_dsd_format_quirks(struct snd_usb_audio *chip, | |||
1374 | } | 1375 | } |
1375 | } | 1376 | } |
1376 | break; | 1377 | break; |
1378 | case USB_ID(0x16d0, 0x0a23): | ||
1379 | if (fp->altsetting == 2) | ||
1380 | return SNDRV_PCM_FMTBIT_DSD_U32_BE; | ||
1381 | break; | ||
1377 | 1382 | ||
1378 | default: | 1383 | default: |
1379 | break; | 1384 | break; |
diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c index 1a2c07eb7795..8c67a90dbd82 100644 --- a/tools/lib/bpf/libbpf.c +++ b/tools/lib/bpf/libbpf.c | |||
@@ -879,7 +879,8 @@ bpf_object__create_maps(struct bpf_object *obj) | |||
879 | size_t j; | 879 | size_t j; |
880 | int err = *pfd; | 880 | int err = *pfd; |
881 | 881 | ||
882 | pr_warning("failed to create map: %s\n", | 882 | pr_warning("failed to create map (name: '%s'): %s\n", |
883 | obj->maps[i].name, | ||
883 | strerror(errno)); | 884 | strerror(errno)); |
884 | for (j = 0; j < i; j++) | 885 | for (j = 0; j < i; j++) |
885 | zclose(obj->maps[j].fd); | 886 | zclose(obj->maps[j].fd); |
diff --git a/tools/testing/selftests/futex/Makefile b/tools/testing/selftests/futex/Makefile index e2fbb890aef9..7c647f619d63 100644 --- a/tools/testing/selftests/futex/Makefile +++ b/tools/testing/selftests/futex/Makefile | |||
@@ -14,7 +14,7 @@ all: | |||
14 | done | 14 | done |
15 | 15 | ||
16 | override define RUN_TESTS | 16 | override define RUN_TESTS |
17 | @if [ `dirname $(OUTPUT)` = $(PWD) ]; then ./run.sh; fi | 17 | $(OUTPUT)/run.sh |
18 | endef | 18 | endef |
19 | 19 | ||
20 | override define INSTALL_RULE | 20 | override define INSTALL_RULE |
diff --git a/tools/testing/selftests/kmod/kmod.sh b/tools/testing/selftests/kmod/kmod.sh index 8cecae9a8bca..7956ea3be667 100644..100755 --- a/tools/testing/selftests/kmod/kmod.sh +++ b/tools/testing/selftests/kmod/kmod.sh | |||
@@ -473,8 +473,8 @@ usage() | |||
473 | echo " all Runs all tests (default)" | 473 | echo " all Runs all tests (default)" |
474 | echo " -t Run test ID the number amount of times is recommended" | 474 | echo " -t Run test ID the number amount of times is recommended" |
475 | echo " -w Watch test ID run until it runs into an error" | 475 | echo " -w Watch test ID run until it runs into an error" |
476 | echo " -c Run test ID once" | 476 | echo " -s Run test ID once" |
477 | echo " -s Run test ID x test-count number of times" | 477 | echo " -c Run test ID x test-count number of times" |
478 | echo " -l List all test ID list" | 478 | echo " -l List all test ID list" |
479 | echo " -h|--help Help" | 479 | echo " -h|--help Help" |
480 | echo | 480 | echo |
diff --git a/tools/testing/selftests/sysctl/sysctl.sh b/tools/testing/selftests/sysctl/sysctl.sh index ec232c3cfcaa..ec232c3cfcaa 100644..100755 --- a/tools/testing/selftests/sysctl/sysctl.sh +++ b/tools/testing/selftests/sysctl/sysctl.sh | |||
diff --git a/tools/testing/selftests/timers/freq-step.c b/tools/testing/selftests/timers/freq-step.c index e8c61830825a..22312eb4c941 100644 --- a/tools/testing/selftests/timers/freq-step.c +++ b/tools/testing/selftests/timers/freq-step.c | |||
@@ -229,10 +229,9 @@ static void init_test(void) | |||
229 | printf("CLOCK_MONOTONIC_RAW+CLOCK_MONOTONIC precision: %.0f ns\t\t", | 229 | printf("CLOCK_MONOTONIC_RAW+CLOCK_MONOTONIC precision: %.0f ns\t\t", |
230 | 1e9 * precision); | 230 | 1e9 * precision); |
231 | 231 | ||
232 | if (precision > MAX_PRECISION) { | 232 | if (precision > MAX_PRECISION) |
233 | printf("[SKIP]\n"); | 233 | ksft_exit_skip("precision: %.0f ns > MAX_PRECISION: %.0f ns\n", |
234 | ksft_exit_skip(); | 234 | 1e9 * precision, 1e9 * MAX_PRECISION); |
235 | } | ||
236 | 235 | ||
237 | printf("[OK]\n"); | 236 | printf("[OK]\n"); |
238 | srand(ts.tv_sec ^ ts.tv_nsec); | 237 | srand(ts.tv_sec ^ ts.tv_nsec); |