x86/boot/compressed/64: Add stage1 #VC handler
[linux-2.6-microblaze.git] / arch / x86 / boot / compressed / sev-es.c
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * AMD Encrypted Register State Support
4  *
5  * Author: Joerg Roedel <jroedel@suse.de>
6  */
7
8 /*
9  * misc.h needs to be first because it knows how to include the other kernel
10  * headers in the pre-decompression code in a way that does not break
11  * compilation.
12  */
13 #include "misc.h"
14
15 #include <asm/sev-es.h>
16 #include <asm/msr-index.h>
17 #include <asm/ptrace.h>
18 #include <asm/svm.h>
19
20 static inline u64 sev_es_rd_ghcb_msr(void)
21 {
22         unsigned long low, high;
23
24         asm volatile("rdmsr" : "=a" (low), "=d" (high) :
25                         "c" (MSR_AMD64_SEV_ES_GHCB));
26
27         return ((high << 32) | low);
28 }
29
30 static inline void sev_es_wr_ghcb_msr(u64 val)
31 {
32         u32 low, high;
33
34         low  = val & 0xffffffffUL;
35         high = val >> 32;
36
37         asm volatile("wrmsr" : : "c" (MSR_AMD64_SEV_ES_GHCB),
38                         "a"(low), "d" (high) : "memory");
39 }
40
41 #undef __init
42 #define __init
43
44 /* Include code for early handlers */
45 #include "../../kernel/sev-es-shared.c"