Skip to content

Commit e82f206

Browse files
committed
Merge remote-tracking branch 'tip/x86/cc' into hyperv-next
2 parents 7117dcc + e9d1d2b commit e82f206

40 files changed

+310
-129
lines changed

arch/Kconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,6 +1234,9 @@ config RELR
12341234
config ARCH_HAS_MEM_ENCRYPT
12351235
bool
12361236

1237+
config ARCH_HAS_CC_PLATFORM
1238+
bool
1239+
12371240
config HAVE_SPARSE_SYSCALL_NR
12381241
bool
12391242
help

arch/powerpc/include/asm/mem_encrypt.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@
1010

1111
#include <asm/svm.h>
1212

13-
static inline bool mem_encrypt_active(void)
14-
{
15-
return is_secure_guest();
16-
}
17-
1813
static inline bool force_dma_unencrypted(struct device *dev)
1914
{
2015
return is_secure_guest();

arch/powerpc/platforms/pseries/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ config PPC_SVM
159159
select SWIOTLB
160160
select ARCH_HAS_MEM_ENCRYPT
161161
select ARCH_HAS_FORCE_DMA_UNENCRYPTED
162+
select ARCH_HAS_CC_PLATFORM
162163
help
163164
There are certain POWER platforms which support secure guests using
164165
the Protected Execution Facility, with the help of an Ultravisor

arch/powerpc/platforms/pseries/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,5 @@ obj-$(CONFIG_FA_DUMP) += rtas-fadump.o
3131

3232
obj-$(CONFIG_SUSPEND) += suspend.o
3333
obj-$(CONFIG_PPC_VAS) += vas.o
34+
35+
obj-$(CONFIG_ARCH_HAS_CC_PLATFORM) += cc_platform.o
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// SPDX-License-Identifier: GPL-2.0-only
2+
/*
3+
* Confidential Computing Platform Capability checks
4+
*
5+
* Copyright (C) 2021 Advanced Micro Devices, Inc.
6+
*
7+
* Author: Tom Lendacky <[email protected]>
8+
*/
9+
10+
#include <linux/export.h>
11+
#include <linux/cc_platform.h>
12+
13+
#include <asm/machdep.h>
14+
#include <asm/svm.h>
15+
16+
bool cc_platform_has(enum cc_attr attr)
17+
{
18+
switch (attr) {
19+
case CC_ATTR_MEM_ENCRYPT:
20+
return is_secure_guest();
21+
22+
default:
23+
return false;
24+
}
25+
}
26+
EXPORT_SYMBOL_GPL(cc_platform_has);

arch/powerpc/platforms/pseries/svm.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include <linux/mm.h>
1010
#include <linux/memblock.h>
11+
#include <linux/cc_platform.h>
1112
#include <asm/machdep.h>
1213
#include <asm/svm.h>
1314
#include <asm/swiotlb.h>
@@ -63,7 +64,7 @@ void __init svm_swiotlb_init(void)
6364

6465
int set_memory_encrypted(unsigned long addr, int numpages)
6566
{
66-
if (!mem_encrypt_active())
67+
if (!cc_platform_has(CC_ATTR_MEM_ENCRYPT))
6768
return 0;
6869

6970
if (!PAGE_ALIGNED(addr))
@@ -76,7 +77,7 @@ int set_memory_encrypted(unsigned long addr, int numpages)
7677

7778
int set_memory_decrypted(unsigned long addr, int numpages)
7879
{
79-
if (!mem_encrypt_active())
80+
if (!cc_platform_has(CC_ATTR_MEM_ENCRYPT))
8081
return 0;
8182

8283
if (!PAGE_ALIGNED(addr))

arch/s390/include/asm/mem_encrypt.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
#ifndef __ASSEMBLY__
66

7-
static inline bool mem_encrypt_active(void) { return false; }
8-
97
int set_memory_encrypted(unsigned long addr, int numpages);
108
int set_memory_decrypted(unsigned long addr, int numpages);
119

arch/x86/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1518,6 +1518,7 @@ config AMD_MEM_ENCRYPT
15181518
select ARCH_HAS_FORCE_DMA_UNENCRYPTED
15191519
select INSTRUCTION_DECODER
15201520
select ARCH_HAS_RESTRICTED_VIRTIO_MEMORY_ACCESS
1521+
select ARCH_HAS_CC_PLATFORM
15211522
help
15221523
Say yes to enable support for the encryption of system memory.
15231524
This requires an AMD processor that supports Secure Memory

arch/x86/include/asm/io.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,13 +391,21 @@ extern void arch_io_free_memtype_wc(resource_size_t start, resource_size_t size)
391391
#define arch_io_reserve_memtype_wc arch_io_reserve_memtype_wc
392392
#endif
393393

394+
#ifdef CONFIG_AMD_MEM_ENCRYPT
394395
extern bool arch_memremap_can_ram_remap(resource_size_t offset,
395396
unsigned long size,
396397
unsigned long flags);
397398
#define arch_memremap_can_ram_remap arch_memremap_can_ram_remap
398399

399400
extern bool phys_mem_access_encrypted(unsigned long phys_addr,
400401
unsigned long size);
402+
#else
403+
static inline bool phys_mem_access_encrypted(unsigned long phys_addr,
404+
unsigned long size)
405+
{
406+
return true;
407+
}
408+
#endif
401409

402410
/**
403411
* iosubmit_cmds512 - copy data to single MMIO location, in 512-bit units

arch/x86/include/asm/kexec.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ relocate_kernel(unsigned long indirection_page,
129129
unsigned long page_list,
130130
unsigned long start_address,
131131
unsigned int preserve_context,
132-
unsigned int sme_active);
132+
unsigned int host_mem_enc_active);
133133
#endif
134134

135135
#define ARCH_HAS_KIMAGE_ARCH

0 commit comments

Comments
 (0)