CC: [email protected] BCC: [email protected] CC: [email protected] TO: Jane Chu <[email protected]> CC: Dan Williams <[email protected]> CC: Christoph Hellwig <[email protected]>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm.git libnvdimm-for-next head: e4628f04a31a3c3e03364a16bbfac0f07ad02b40 commit: 39702cf7885c0806576fd3d04450394467db60b4 [6/7] x86/mce: relocate set{clear}_mce_nospec() functions :::::: branch date: 10 hours ago :::::: commit date: 10 hours ago config: i386-randconfig-m021 (https://download.01.org/0day-ci/archive/20220514/[email protected]/config) compiler: gcc-11 (Debian 11.2.0-20) 11.2.0 If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <[email protected]> Reported-by: Dan Carpenter <[email protected]> New smatch warnings: arch/x86/mm/pat/set_memory.c:1943 set_mce_nospec() warn: should 'pfn << 12' be a 64 bit type? Old smatch warnings: arch/x86/mm/pat/set_memory.c:2335 kernel_map_pages_in_pgd() warn: bitwise AND condition is false here vim +1943 arch/x86/mm/pat/set_memory.c 75cbade8ea3127 arch/x86/mm/pageattr.c Arjan van de Ven 2008-01-30 1927 39702cf7885c08 arch/x86/mm/pat/set_memory.c Jane Chu 2022-04-22 1928 /* 39702cf7885c08 arch/x86/mm/pat/set_memory.c Jane Chu 2022-04-22 1929 * Prevent speculative access to the page by either unmapping 39702cf7885c08 arch/x86/mm/pat/set_memory.c Jane Chu 2022-04-22 1930 * it (if we do not require access to any part of the page) or 39702cf7885c08 arch/x86/mm/pat/set_memory.c Jane Chu 2022-04-22 1931 * marking it uncacheable (if we want to try to retrieve data 39702cf7885c08 arch/x86/mm/pat/set_memory.c Jane Chu 2022-04-22 1932 * from non-poisoned lines in the page). 39702cf7885c08 arch/x86/mm/pat/set_memory.c Jane Chu 2022-04-22 1933 */ 39702cf7885c08 arch/x86/mm/pat/set_memory.c Jane Chu 2022-04-22 1934 int set_mce_nospec(unsigned long pfn, bool unmap) 39702cf7885c08 arch/x86/mm/pat/set_memory.c Jane Chu 2022-04-22 1935 { 39702cf7885c08 arch/x86/mm/pat/set_memory.c Jane Chu 2022-04-22 1936 unsigned long decoy_addr; 39702cf7885c08 arch/x86/mm/pat/set_memory.c Jane Chu 2022-04-22 1937 int rc; 39702cf7885c08 arch/x86/mm/pat/set_memory.c Jane Chu 2022-04-22 1938 39702cf7885c08 arch/x86/mm/pat/set_memory.c Jane Chu 2022-04-22 1939 if (!IS_ENABLED(CONFIG_64BIT)) 39702cf7885c08 arch/x86/mm/pat/set_memory.c Jane Chu 2022-04-22 1940 return 0; 39702cf7885c08 arch/x86/mm/pat/set_memory.c Jane Chu 2022-04-22 1941 39702cf7885c08 arch/x86/mm/pat/set_memory.c Jane Chu 2022-04-22 1942 /* SGX pages are not in the 1:1 map */ 39702cf7885c08 arch/x86/mm/pat/set_memory.c Jane Chu 2022-04-22 @1943 if (arch_is_platform_page(pfn << PAGE_SHIFT)) 39702cf7885c08 arch/x86/mm/pat/set_memory.c Jane Chu 2022-04-22 1944 return 0; 39702cf7885c08 arch/x86/mm/pat/set_memory.c Jane Chu 2022-04-22 1945 /* 39702cf7885c08 arch/x86/mm/pat/set_memory.c Jane Chu 2022-04-22 1946 * We would like to just call: 39702cf7885c08 arch/x86/mm/pat/set_memory.c Jane Chu 2022-04-22 1947 * set_memory_XX((unsigned long)pfn_to_kaddr(pfn), 1); 39702cf7885c08 arch/x86/mm/pat/set_memory.c Jane Chu 2022-04-22 1948 * but doing that would radically increase the odds of a 39702cf7885c08 arch/x86/mm/pat/set_memory.c Jane Chu 2022-04-22 1949 * speculative access to the poison page because we'd have 39702cf7885c08 arch/x86/mm/pat/set_memory.c Jane Chu 2022-04-22 1950 * the virtual address of the kernel 1:1 mapping sitting 39702cf7885c08 arch/x86/mm/pat/set_memory.c Jane Chu 2022-04-22 1951 * around in registers. 39702cf7885c08 arch/x86/mm/pat/set_memory.c Jane Chu 2022-04-22 1952 * Instead we get tricky. We create a non-canonical address 39702cf7885c08 arch/x86/mm/pat/set_memory.c Jane Chu 2022-04-22 1953 * that looks just like the one we want, but has bit 63 flipped. 39702cf7885c08 arch/x86/mm/pat/set_memory.c Jane Chu 2022-04-22 1954 * This relies on set_memory_XX() properly sanitizing any __pa() 39702cf7885c08 arch/x86/mm/pat/set_memory.c Jane Chu 2022-04-22 1955 * results with __PHYSICAL_MASK or PTE_PFN_MASK. 39702cf7885c08 arch/x86/mm/pat/set_memory.c Jane Chu 2022-04-22 1956 */ 39702cf7885c08 arch/x86/mm/pat/set_memory.c Jane Chu 2022-04-22 1957 decoy_addr = (pfn << PAGE_SHIFT) + (PAGE_OFFSET ^ BIT(63)); 39702cf7885c08 arch/x86/mm/pat/set_memory.c Jane Chu 2022-04-22 1958 39702cf7885c08 arch/x86/mm/pat/set_memory.c Jane Chu 2022-04-22 1959 if (unmap) 39702cf7885c08 arch/x86/mm/pat/set_memory.c Jane Chu 2022-04-22 1960 rc = set_memory_np(decoy_addr, 1); 39702cf7885c08 arch/x86/mm/pat/set_memory.c Jane Chu 2022-04-22 1961 else 39702cf7885c08 arch/x86/mm/pat/set_memory.c Jane Chu 2022-04-22 1962 rc = set_memory_uc(decoy_addr, 1); 39702cf7885c08 arch/x86/mm/pat/set_memory.c Jane Chu 2022-04-22 1963 if (rc) 39702cf7885c08 arch/x86/mm/pat/set_memory.c Jane Chu 2022-04-22 1964 pr_warn("Could not invalidate pfn=0x%lx from 1:1 map\n", pfn); 39702cf7885c08 arch/x86/mm/pat/set_memory.c Jane Chu 2022-04-22 1965 return rc; 39702cf7885c08 arch/x86/mm/pat/set_memory.c Jane Chu 2022-04-22 1966 } 39702cf7885c08 arch/x86/mm/pat/set_memory.c Jane Chu 2022-04-22 1967 -- 0-DAY CI Kernel Test Service https://01.org/lkp _______________________________________________ kbuild mailing list -- [email protected] To unsubscribe send an email to [email protected]
