aboutsummaryrefslogtreecommitdiffstats
path: root/fs/proc/vmcore.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/proc/vmcore.c')
-rw-r--r--fs/proc/vmcore.c34
1 files changed, 28 insertions, 6 deletions
diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c
index cbde728f8ac6..91ae16fbd7d5 100644
--- a/fs/proc/vmcore.c
+++ b/fs/proc/vmcore.c
@@ -24,6 +24,8 @@
24#include <linux/vmalloc.h> 24#include <linux/vmalloc.h>
25#include <linux/pagemap.h> 25#include <linux/pagemap.h>
26#include <linux/uaccess.h> 26#include <linux/uaccess.h>
27#include <linux/mem_encrypt.h>
28#include <asm/pgtable.h>
27#include <asm/io.h> 29#include <asm/io.h>
28#include "internal.h" 30#include "internal.h"
29 31
@@ -98,7 +100,8 @@ static int pfn_is_ram(unsigned long pfn)
98 100
99/* Reads a page from the oldmem device from given offset. */ 101/* Reads a page from the oldmem device from given offset. */
100static ssize_t read_from_oldmem(char *buf, size_t count, 102static ssize_t read_from_oldmem(char *buf, size_t count,
101 u64 *ppos, int userbuf) 103 u64 *ppos, int userbuf,
104 bool encrypted)
102{ 105{
103 unsigned long pfn, offset; 106 unsigned long pfn, offset;
104 size_t nr_bytes; 107 size_t nr_bytes;
@@ -120,8 +123,15 @@ static ssize_t read_from_oldmem(char *buf, size_t count,
120 if (pfn_is_ram(pfn) == 0) 123 if (pfn_is_ram(pfn) == 0)
121 memset(buf, 0, nr_bytes); 124 memset(buf, 0, nr_bytes);
122 else { 125 else {
123 tmp = copy_oldmem_page(pfn, buf, nr_bytes, 126 if (encrypted)
124 offset, userbuf); 127 tmp = copy_oldmem_page_encrypted(pfn, buf,
128 nr_bytes,
129 offset,
130 userbuf);
131 else
132 tmp = copy_oldmem_page(pfn, buf, nr_bytes,
133 offset, userbuf);
134
125 if (tmp < 0) 135 if (tmp < 0)
126 return tmp; 136 return tmp;
127 } 137 }
@@ -155,7 +165,7 @@ void __weak elfcorehdr_free(unsigned long long addr)
155 */ 165 */
156ssize_t __weak elfcorehdr_read(char *buf, size_t count, u64 *ppos) 166ssize_t __weak elfcorehdr_read(char *buf, size_t count, u64 *ppos)
157{ 167{
158 return read_from_oldmem(buf, count, ppos, 0); 168 return read_from_oldmem(buf, count, ppos, 0, false);
159} 169}
160 170
161/* 171/*
@@ -163,7 +173,7 @@ ssize_t __weak elfcorehdr_read(char *buf, size_t count, u64 *ppos)
163 */ 173 */
164ssize_t __weak elfcorehdr_read_notes(char *buf, size_t count, u64 *ppos) 174ssize_t __weak elfcorehdr_read_notes(char *buf, size_t count, u64 *ppos)
165{ 175{
166 return read_from_oldmem(buf, count, ppos, 0); 176 return read_from_oldmem(buf, count, ppos, 0, sme_active());
167} 177}
168 178
169/* 179/*
@@ -173,10 +183,21 @@ int __weak remap_oldmem_pfn_range(struct vm_area_struct *vma,
173 unsigned long from, unsigned long pfn, 183 unsigned long from, unsigned long pfn,
174 unsigned long size, pgprot_t prot) 184 unsigned long size, pgprot_t prot)
175{ 185{
186 prot = pgprot_encrypted(prot);
176 return remap_pfn_range(vma, from, pfn, size, prot); 187 return remap_pfn_range(vma, from, pfn, size, prot);
177} 188}
178 189
179/* 190/*
191 * Architectures which support memory encryption override this.
192 */
193ssize_t __weak
194copy_oldmem_page_encrypted(unsigned long pfn, char *buf, size_t csize,
195 unsigned long offset, int userbuf)
196{
197 return copy_oldmem_page(pfn, buf, csize, offset, userbuf);
198}
199
200/*
180 * Copy to either kernel or user space 201 * Copy to either kernel or user space
181 */ 202 */
182static int copy_to(void *target, void *src, size_t size, int userbuf) 203static int copy_to(void *target, void *src, size_t size, int userbuf)
@@ -351,7 +372,8 @@ static ssize_t __read_vmcore(char *buffer, size_t buflen, loff_t *fpos,
351 m->offset + m->size - *fpos, 372 m->offset + m->size - *fpos,
352 buflen); 373 buflen);
353 start = m->paddr + *fpos - m->offset; 374 start = m->paddr + *fpos - m->offset;
354 tmp = read_from_oldmem(buffer, tsz, &start, userbuf); 375 tmp = read_from_oldmem(buffer, tsz, &start,
376 userbuf, sme_active());
355 if (tmp < 0) 377 if (tmp < 0)
356 return tmp; 378 return tmp;
357 buflen -= tsz; 379 buflen -= tsz;