Skip to content

Commit 2e5fc47

Browse files
author
Ingo Molnar
committed
Merge branch 'x86/sev' into x86/boot, to resolve conflicts and to pick up dependent tree
We are going to queue up a number of patches that depend on fresh changes in x86/sev - merge in that branch to reduce the number of conflicts going forward. Also resolve a current conflict with x86/sev. Conflicts: arch/x86/include/asm/coco.h Signed-off-by: Ingo Molnar <mingo@kernel.org>
2 parents 29cd855 + ee8ff87 commit 2e5fc47

File tree

43 files changed

+2602
-287
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+2602
-287
lines changed

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3320,9 +3320,7 @@
33203320

33213321
mem_encrypt= [X86-64] AMD Secure Memory Encryption (SME) control
33223322
Valid arguments: on, off
3323-
Default (depends on kernel configuration option):
3324-
on (CONFIG_AMD_MEM_ENCRYPT_ACTIVE_BY_DEFAULT=y)
3325-
off (CONFIG_AMD_MEM_ENCRYPT_ACTIVE_BY_DEFAULT=n)
3323+
Default: off
33263324
mem_encrypt=on: Activate SME
33273325
mem_encrypt=off: Do not activate SME
33283326

Documentation/arch/x86/amd-memory-encryption.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,14 @@ The state of SME in the Linux kernel can be documented as follows:
8787
kernel is non-zero).
8888

8989
SME can also be enabled and activated in the BIOS. If SME is enabled and
90-
activated in the BIOS, then all memory accesses will be encrypted and it will
91-
not be necessary to activate the Linux memory encryption support. If the BIOS
92-
merely enables SME (sets bit 23 of the MSR_AMD64_SYSCFG), then Linux can activate
93-
memory encryption by default (CONFIG_AMD_MEM_ENCRYPT_ACTIVE_BY_DEFAULT=y) or
94-
by supplying mem_encrypt=on on the kernel command line. However, if BIOS does
95-
not enable SME, then Linux will not be able to activate memory encryption, even
96-
if configured to do so by default or the mem_encrypt=on command line parameter
97-
is specified.
90+
activated in the BIOS, then all memory accesses will be encrypted and it
91+
will not be necessary to activate the Linux memory encryption support.
92+
93+
If the BIOS merely enables SME (sets bit 23 of the MSR_AMD64_SYSCFG),
94+
then memory encryption can be enabled by supplying mem_encrypt=on on the
95+
kernel command line. However, if BIOS does not enable SME, then Linux
96+
will not be able to activate memory encryption, even if configured to do
97+
so by default or the mem_encrypt=on command line parameter is specified.
9898

9999
Secure Nested Paging (SNP)
100100
==========================

Documentation/virt/coco/sev-guest.rst

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,23 @@ counter (e.g. counter overflow), then -EIO will be returned.
6767
};
6868
};
6969

70+
The host ioctls are issued to a file descriptor of the /dev/sev device.
71+
The ioctl accepts the command ID/input structure documented below.
72+
73+
::
74+
75+
struct sev_issue_cmd {
76+
/* Command ID */
77+
__u32 cmd;
78+
79+
/* Command request structure */
80+
__u64 data;
81+
82+
/* Firmware error code on failure (see psp-sev.h) */
83+
__u32 error;
84+
};
85+
86+
7087
2.1 SNP_GET_REPORT
7188
------------------
7289

@@ -124,6 +141,41 @@ be updated with the expected value.
124141

125142
See GHCB specification for further detail on how to parse the certificate blob.
126143

144+
2.4 SNP_PLATFORM_STATUS
145+
-----------------------
146+
:Technology: sev-snp
147+
:Type: hypervisor ioctl cmd
148+
:Parameters (out): struct sev_user_data_snp_status
149+
:Returns (out): 0 on success, -negative on error
150+
151+
The SNP_PLATFORM_STATUS command is used to query the SNP platform status. The
152+
status includes API major, minor version and more. See the SEV-SNP
153+
specification for further details.
154+
155+
2.5 SNP_COMMIT
156+
--------------
157+
:Technology: sev-snp
158+
:Type: hypervisor ioctl cmd
159+
:Returns (out): 0 on success, -negative on error
160+
161+
SNP_COMMIT is used to commit the currently installed firmware using the
162+
SEV-SNP firmware SNP_COMMIT command. This prevents roll-back to a previously
163+
committed firmware version. This will also update the reported TCB to match
164+
that of the currently installed firmware.
165+
166+
2.6 SNP_SET_CONFIG
167+
------------------
168+
:Technology: sev-snp
169+
:Type: hypervisor ioctl cmd
170+
:Parameters (in): struct sev_user_data_snp_config
171+
:Returns (out): 0 on success, -negative on error
172+
173+
SNP_SET_CONFIG is used to set the system-wide configuration such as
174+
reported TCB version in the attestation report. The command is similar
175+
to SNP_CONFIG command defined in the SEV-SNP spec. The current values of
176+
the firmware parameters affected by this command can be queried via
177+
SNP_PLATFORM_STATUS.
178+
127179
3. SEV-SNP CPUID Enforcement
128180
============================
129181

arch/x86/Kbuild

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,7 @@ obj-y += net/
2828

2929
obj-$(CONFIG_KEXEC_FILE) += purgatory/
3030

31+
obj-y += virt/svm/
32+
3133
# for cleaning
3234
subdir- += boot tools

arch/x86/Kconfig

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1539,19 +1539,6 @@ config AMD_MEM_ENCRYPT
15391539
This requires an AMD processor that supports Secure Memory
15401540
Encryption (SME).
15411541

1542-
config AMD_MEM_ENCRYPT_ACTIVE_BY_DEFAULT
1543-
bool "Activate AMD Secure Memory Encryption (SME) by default"
1544-
depends on AMD_MEM_ENCRYPT
1545-
help
1546-
Say yes to have system memory encrypted by default if running on
1547-
an AMD processor that supports Secure Memory Encryption (SME).
1548-
1549-
If set to Y, then the encryption of system memory can be
1550-
deactivated with the mem_encrypt=off command line option.
1551-
1552-
If set to N, then the encryption of system memory can be
1553-
activated with the mem_encrypt=on command line option.
1554-
15551542
# Common NUMA Features
15561543
config NUMA
15571544
bool "NUMA Memory Allocation and Scheduler Support"

arch/x86/boot/compressed/sev.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,10 @@ void do_boot_stage2_vc(struct pt_regs *regs, unsigned long exit_code)
304304
if (result != ES_OK)
305305
goto finish;
306306

307+
result = vc_check_opcode_bytes(&ctxt, exit_code);
308+
if (result != ES_OK)
309+
goto finish;
310+
307311
switch (exit_code) {
308312
case SVM_EXIT_RDTSC:
309313
case SVM_EXIT_RDTSCP:

arch/x86/coco/core.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include <asm/processor.h>
1515

1616
enum cc_vendor cc_vendor __ro_after_init = CC_VENDOR_NONE;
17-
static u64 cc_mask __ro_after_init;
17+
u64 cc_mask __ro_after_init;
1818

1919
static bool noinstr intel_cc_platform_has(enum cc_attr attr)
2020
{
@@ -148,8 +148,3 @@ u64 cc_mkdec(u64 val)
148148
}
149149
}
150150
EXPORT_SYMBOL_GPL(cc_mkdec);
151-
152-
__init void cc_set_mask(u64 mask)
153-
{
154-
cc_mask = mask;
155-
}

arch/x86/include/asm/asm.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,20 @@
113113

114114
#endif
115115

116+
#ifndef __ASSEMBLY__
117+
#ifndef __pic__
118+
static __always_inline __pure void *rip_rel_ptr(void *p)
119+
{
120+
asm("leaq %c1(%%rip), %0" : "=r"(p) : "i"(p));
121+
122+
return p;
123+
}
124+
#define RIP_REL_REF(var) (*(typeof(&(var)))rip_rel_ptr(&(var)))
125+
#else
126+
#define RIP_REL_REF(var) (var)
127+
#endif
128+
#endif
129+
116130
/*
117131
* Macros to generate condition code outputs from inline assembly,
118132
* The output operand must be type "bool".

arch/x86/include/asm/coco.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#ifndef _ASM_X86_COCO_H
33
#define _ASM_X86_COCO_H
44

5+
#include <asm/asm.h>
56
#include <asm/types.h>
67

78
enum cc_vendor {
@@ -10,9 +11,14 @@ enum cc_vendor {
1011
CC_VENDOR_INTEL,
1112
};
1213

14+
extern u64 cc_mask;
1315
#ifdef CONFIG_ARCH_HAS_CC_PLATFORM
1416
extern enum cc_vendor cc_vendor;
15-
void cc_set_mask(u64 mask);
17+
static inline void cc_set_mask(u64 mask)
18+
{
19+
RIP_REL_REF(cc_mask) = mask;
20+
}
21+
1622
u64 cc_mkenc(u64 val);
1723
u64 cc_mkdec(u64 val);
1824
#else

arch/x86/include/asm/cpufeatures.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,7 @@
440440
#define X86_FEATURE_SEV (19*32+ 1) /* AMD Secure Encrypted Virtualization */
441441
#define X86_FEATURE_VM_PAGE_FLUSH (19*32+ 2) /* "" VM Page Flush MSR is supported */
442442
#define X86_FEATURE_SEV_ES (19*32+ 3) /* AMD Secure Encrypted Virtualization - Encrypted State */
443+
#define X86_FEATURE_SEV_SNP (19*32+ 4) /* AMD Secure Encrypted Virtualization - Secure Nested Paging */
443444
#define X86_FEATURE_V_TSC_AUX (19*32+ 9) /* "" Virtual TSC_AUX */
444445
#define X86_FEATURE_SME_COHERENT (19*32+10) /* "" AMD hardware-enforced cache coherency */
445446
#define X86_FEATURE_DEBUG_SWAP (19*32+14) /* AMD SEV-ES full debug state swap support */

0 commit comments

Comments
 (0)