.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * tboot.c: main implementation of helper functions used by kernel for |
---|
3 | 4 | * runtime support of Intel(R) Trusted Execution Technology |
---|
4 | 5 | * |
---|
5 | 6 | * Copyright (c) 2006-2009, Intel Corporation |
---|
6 | | - * |
---|
7 | | - * This program is free software; you can redistribute it and/or modify it |
---|
8 | | - * under the terms and conditions of the GNU General Public License, |
---|
9 | | - * version 2, as published by the Free Software Foundation. |
---|
10 | | - * |
---|
11 | | - * This program is distributed in the hope it will be useful, but WITHOUT |
---|
12 | | - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
---|
13 | | - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
---|
14 | | - * more details. |
---|
15 | | - * |
---|
16 | | - * You should have received a copy of the GNU General Public License along with |
---|
17 | | - * this program; if not, write to the Free Software Foundation, Inc., |
---|
18 | | - * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. |
---|
19 | | - * |
---|
20 | 7 | */ |
---|
21 | 8 | |
---|
22 | | -#include <linux/dma_remapping.h> |
---|
| 9 | +#include <linux/intel-iommu.h> |
---|
23 | 10 | #include <linux/init_task.h> |
---|
24 | 11 | #include <linux/spinlock.h> |
---|
25 | 12 | #include <linux/export.h> |
---|
.. | .. |
---|
36 | 23 | #include <asm/realmode.h> |
---|
37 | 24 | #include <asm/processor.h> |
---|
38 | 25 | #include <asm/bootparam.h> |
---|
39 | | -#include <asm/pgtable.h> |
---|
40 | 26 | #include <asm/pgalloc.h> |
---|
41 | 27 | #include <asm/swiotlb.h> |
---|
42 | 28 | #include <asm/fixmap.h> |
---|
.. | .. |
---|
48 | 34 | #include "../realmode/rm/wakeup.h" |
---|
49 | 35 | |
---|
50 | 36 | /* Global pointer to shared data; NULL means no measured launch. */ |
---|
51 | | -struct tboot *tboot __read_mostly; |
---|
52 | | -EXPORT_SYMBOL(tboot); |
---|
| 37 | +static struct tboot *tboot __read_mostly; |
---|
53 | 38 | |
---|
54 | 39 | /* timeout for APs (in secs) to enter wait-for-SIPI state during shutdown */ |
---|
55 | 40 | #define AP_WAIT_TIMEOUT 1 |
---|
.. | .. |
---|
58 | 43 | #define pr_fmt(fmt) "tboot: " fmt |
---|
59 | 44 | |
---|
60 | 45 | static u8 tboot_uuid[16] __initdata = TBOOT_UUID; |
---|
| 46 | + |
---|
| 47 | +bool tboot_enabled(void) |
---|
| 48 | +{ |
---|
| 49 | + return tboot != NULL; |
---|
| 50 | +} |
---|
61 | 51 | |
---|
62 | 52 | void __init tboot_probe(void) |
---|
63 | 53 | { |
---|
.. | .. |
---|
70 | 60 | */ |
---|
71 | 61 | if (!e820__mapped_any(boot_params.tboot_addr, |
---|
72 | 62 | boot_params.tboot_addr, E820_TYPE_RESERVED)) { |
---|
73 | | - pr_warning("non-0 tboot_addr but it is not of type E820_TYPE_RESERVED\n"); |
---|
| 63 | + pr_warn("non-0 tboot_addr but it is not of type E820_TYPE_RESERVED\n"); |
---|
74 | 64 | return; |
---|
75 | 65 | } |
---|
76 | 66 | |
---|
.. | .. |
---|
78 | 68 | set_fixmap(FIX_TBOOT_BASE, boot_params.tboot_addr); |
---|
79 | 69 | tboot = (struct tboot *)fix_to_virt(FIX_TBOOT_BASE); |
---|
80 | 70 | if (memcmp(&tboot_uuid, &tboot->uuid, sizeof(tboot->uuid))) { |
---|
81 | | - pr_warning("tboot at 0x%llx is invalid\n", |
---|
82 | | - boot_params.tboot_addr); |
---|
| 71 | + pr_warn("tboot at 0x%llx is invalid\n", boot_params.tboot_addr); |
---|
83 | 72 | tboot = NULL; |
---|
84 | 73 | return; |
---|
85 | 74 | } |
---|
86 | 75 | if (tboot->version < 5) { |
---|
87 | | - pr_warning("tboot version is invalid: %u\n", tboot->version); |
---|
| 76 | + pr_warn("tboot version is invalid: %u\n", tboot->version); |
---|
88 | 77 | tboot = NULL; |
---|
89 | 78 | return; |
---|
90 | 79 | } |
---|
.. | .. |
---|
104 | 93 | .pgd = swapper_pg_dir, |
---|
105 | 94 | .mm_users = ATOMIC_INIT(2), |
---|
106 | 95 | .mm_count = ATOMIC_INIT(1), |
---|
107 | | - .mmap_sem = __RWSEM_INITIALIZER(init_mm.mmap_sem), |
---|
| 96 | + .write_protect_seq = SEQCNT_ZERO(tboot_mm.write_protect_seq), |
---|
| 97 | + MMAP_LOCK_INITIALIZER(init_mm) |
---|
108 | 98 | .page_table_lock = __SPIN_LOCK_UNLOCKED(init_mm.page_table_lock), |
---|
109 | 99 | .mmlist = LIST_HEAD_INIT(init_mm.mmlist), |
---|
110 | 100 | }; |
---|
.. | .. |
---|
302 | 292 | |
---|
303 | 293 | if (sleep_state >= ACPI_S_STATE_COUNT || |
---|
304 | 294 | acpi_shutdown_map[sleep_state] == -1) { |
---|
305 | | - pr_warning("unsupported sleep state 0x%x\n", sleep_state); |
---|
| 295 | + pr_warn("unsupported sleep state 0x%x\n", sleep_state); |
---|
306 | 296 | return -1; |
---|
307 | 297 | } |
---|
308 | 298 | |
---|
.. | .. |
---|
315 | 305 | if (!tboot_enabled()) |
---|
316 | 306 | return 0; |
---|
317 | 307 | |
---|
318 | | - pr_warning("tboot is not able to suspend on platforms with reduced hardware sleep (ACPIv5)"); |
---|
| 308 | + pr_warn("tboot is not able to suspend on platforms with reduced hardware sleep (ACPIv5)"); |
---|
319 | 309 | return -ENODEV; |
---|
320 | 310 | } |
---|
321 | 311 | |
---|
.. | .. |
---|
333 | 323 | } |
---|
334 | 324 | |
---|
335 | 325 | if (timeout) |
---|
336 | | - pr_warning("tboot wait for APs timeout\n"); |
---|
| 326 | + pr_warn("tboot wait for APs timeout\n"); |
---|
337 | 327 | |
---|
338 | 328 | return !(atomic_read((atomic_t *)&tboot->num_in_wfs) == num_aps); |
---|
339 | 329 | } |
---|
.. | .. |
---|
368 | 358 | void *kbuf; |
---|
369 | 359 | int ret = -EFAULT; |
---|
370 | 360 | |
---|
371 | | - log_base = ioremap_nocache(TBOOT_SERIAL_LOG_ADDR, TBOOT_SERIAL_LOG_SIZE); |
---|
| 361 | + log_base = ioremap(TBOOT_SERIAL_LOG_ADDR, TBOOT_SERIAL_LOG_SIZE); |
---|
372 | 362 | if (!log_base) |
---|
373 | 363 | return ret; |
---|
374 | 364 | |
---|
.. | .. |
---|
525 | 515 | if (!tboot_enabled()) |
---|
526 | 516 | return 0; |
---|
527 | 517 | |
---|
528 | | - if (intel_iommu_tboot_noforce) |
---|
529 | | - return 1; |
---|
530 | | - |
---|
531 | | - if (no_iommu || swiotlb || dmar_disabled) |
---|
532 | | - pr_warning("Forcing Intel-IOMMU to enabled\n"); |
---|
| 518 | + if (no_iommu || dmar_disabled) |
---|
| 519 | + pr_warn("Forcing Intel-IOMMU to enabled\n"); |
---|
533 | 520 | |
---|
534 | 521 | dmar_disabled = 0; |
---|
535 | | -#ifdef CONFIG_SWIOTLB |
---|
536 | | - swiotlb = 0; |
---|
537 | | -#endif |
---|
538 | 522 | no_iommu = 0; |
---|
539 | 523 | |
---|
540 | 524 | return 1; |
---|