LCOV - code coverage report
Current view: top level - arch/x86/kernel - crash_dump_64.c (source / functions) Hit Total Coverage
Test: combined.info Lines: 0 21 0.0 %
Date: 2022-03-28 16:04:14 Functions: 0 4 0.0 %
Branches: 0 12 0.0 %

           Branch data     Line data    Source code
       1                 :            : // SPDX-License-Identifier: GPL-2.0
       2                 :            : /*
       3                 :            :  *      Memory preserving reboot related code.
       4                 :            :  *
       5                 :            :  *      Created by: Hariprasad Nellitheertha (hari@in.ibm.com)
       6                 :            :  *      Copyright (C) IBM Corporation, 2004. All rights reserved
       7                 :            :  */
       8                 :            : 
       9                 :            : #include <linux/errno.h>
      10                 :            : #include <linux/crash_dump.h>
      11                 :            : #include <linux/uaccess.h>
      12                 :            : #include <linux/io.h>
      13                 :            : 
      14                 :          0 : static ssize_t __copy_oldmem_page(unsigned long pfn, char *buf, size_t csize,
      15                 :            :                                   unsigned long offset, int userbuf,
      16                 :            :                                   bool encrypted)
      17                 :            : {
      18                 :          0 :         void  *vaddr;
      19                 :            : 
      20         [ #  # ]:          0 :         if (!csize)
      21                 :            :                 return 0;
      22                 :            : 
      23         [ #  # ]:          0 :         if (encrypted)
      24                 :          0 :                 vaddr = (__force void *)ioremap_encrypted(pfn << PAGE_SHIFT, PAGE_SIZE);
      25                 :            :         else
      26                 :          0 :                 vaddr = (__force void *)ioremap_cache(pfn << PAGE_SHIFT, PAGE_SIZE);
      27                 :            : 
      28         [ #  # ]:          0 :         if (!vaddr)
      29                 :            :                 return -ENOMEM;
      30                 :            : 
      31         [ #  # ]:          0 :         if (userbuf) {
      32   [ #  #  #  # ]:          0 :                 if (copy_to_user((void __user *)buf, vaddr + offset, csize)) {
      33                 :          0 :                         iounmap((void __iomem *)vaddr);
      34                 :          0 :                         return -EFAULT;
      35                 :            :                 }
      36                 :            :         } else
      37                 :          0 :                 memcpy(buf, vaddr + offset, csize);
      38                 :            : 
      39                 :          0 :         set_iounmap_nonlazy();
      40                 :          0 :         iounmap((void __iomem *)vaddr);
      41                 :          0 :         return csize;
      42                 :            : }
      43                 :            : 
      44                 :            : /**
      45                 :            :  * copy_oldmem_page - copy one page of memory
      46                 :            :  * @pfn: page frame number to be copied
      47                 :            :  * @buf: target memory address for the copy; this can be in kernel address
      48                 :            :  *      space or user address space (see @userbuf)
      49                 :            :  * @csize: number of bytes to copy
      50                 :            :  * @offset: offset in bytes into the page (based on pfn) to begin the copy
      51                 :            :  * @userbuf: if set, @buf is in user address space, use copy_to_user(),
      52                 :            :  *      otherwise @buf is in kernel address space, use memcpy().
      53                 :            :  *
      54                 :            :  * Copy a page from the old kernel's memory. For this page, there is no pte
      55                 :            :  * mapped in the current kernel. We stitch up a pte, similar to kmap_atomic.
      56                 :            :  */
      57                 :          0 : ssize_t copy_oldmem_page(unsigned long pfn, char *buf, size_t csize,
      58                 :            :                          unsigned long offset, int userbuf)
      59                 :            : {
      60                 :          0 :         return __copy_oldmem_page(pfn, buf, csize, offset, userbuf, false);
      61                 :            : }
      62                 :            : 
      63                 :            : /**
      64                 :            :  * copy_oldmem_page_encrypted - same as copy_oldmem_page() above but ioremap the
      65                 :            :  * memory with the encryption mask set to accommodate kdump on SME-enabled
      66                 :            :  * machines.
      67                 :            :  */
      68                 :          0 : ssize_t copy_oldmem_page_encrypted(unsigned long pfn, char *buf, size_t csize,
      69                 :            :                                    unsigned long offset, int userbuf)
      70                 :            : {
      71                 :          0 :         return __copy_oldmem_page(pfn, buf, csize, offset, userbuf, true);
      72                 :            : }
      73                 :            : 
      74                 :          0 : ssize_t elfcorehdr_read(char *buf, size_t count, u64 *ppos)
      75                 :            : {
      76                 :          0 :         return read_from_oldmem(buf, count, ppos, 0, sev_active());
      77                 :            : }

Generated by: LCOV version 1.14