[PATCH 2/2] misc: amd-sp: introduce the AMD Secure Processor device

2017-01-19 Thread Brijesh Singh
The CCP device is part of the AMD Secure Processor. In order to expand the usage of the AMD Secure Processor, create a framework that allows functional components of the AMD Secure Processor to be initialized and handled appropriately. Signed-off-by: Brijesh Singh Signed-off-by: Tom Lendacky

[PATCH 0/2] Introduce AMD Secure Processor device

2017-01-19 Thread Brijesh Singh
Trusted Execution Environment (TEE) services provided by PSP device. http://marc.info/?l=linux-mm&m=147190938124206&w=2 Brijesh Singh (2): crypto: move CCP device driver to misc misc: amd-sp: introduce the AMD Secure Processor device drivers/crypto/Kconfig

Re: [PATCH 1/2] crypto: move CCP device driver to misc

2017-01-19 Thread Brijesh Singh
Hi Greg, On 01/19/2017 12:18 PM, Greg KH wrote: On Thu, Jan 19, 2017 at 01:08:01PM -0500, Brijesh Singh wrote: The CCP device is part of the AMD Secure Processor, which is not dedicated solely to crypto. Move the CCP device driver to the misc directory in prepration for expanding the usage of

Re: [PATCH 0/2] Introduce AMD Secure Processor device

2017-01-19 Thread Brijesh Singh
Hi Greg, On 01/19/2017 12:21 PM, Greg KH wrote: On Thu, Jan 19, 2017 at 01:07:50PM -0500, Brijesh Singh wrote: The CCP device (drivers/crypto/ccp/ccp.ko) is part of AMD Secure Processor, which is not dedicated solely to crypto. The AMD Secure Processor includes CCP and PSP (Platform Secure

Re: [PATCH 0/2] Introduce AMD Secure Processor device

2017-01-20 Thread Brijesh Singh
On 01/20/2017 02:45 AM, Greg KH wrote: On Thu, Jan 19, 2017 at 02:03:12PM -0600, Brijesh Singh wrote: Hi Greg, On 01/19/2017 12:21 PM, Greg KH wrote: On Thu, Jan 19, 2017 at 01:07:50PM -0500, Brijesh Singh wrote: The CCP device (drivers/crypto/ccp/ccp.ko) is part of AMD Secure Processor

[RFC PATCH v2 11/32] x86: Unroll string I/O when SEV is active

2017-03-02 Thread Brijesh Singh
From: Tom Lendacky Secure Encrypted Virtualization (SEV) does not support string I/O, so unroll the string I/O operation into a loop operating on one element at a time. Signed-off-by: Tom Lendacky --- arch/x86/include/asm/io.h | 26 ++ 1 file changed, 22 insertions(+)

[RFC PATCH v2 19/32] crypto: ccp: Introduce the AMD Secure Processor device

2017-03-02 Thread Brijesh Singh
The CCP device is part of the AMD Secure Processor. In order to expand the usage of the AMD Secure Processor, create a framework that allows functional components of the AMD Secure Processor to be initialized and handled appropriately. Signed-off-by: Brijesh Singh Signed-off-by: Tom Lendacky

[RFC PATCH v2 07/32] x86/efi: Access EFI data as encrypted when SEV is active

2017-03-02 Thread Brijesh Singh
From: Tom Lendacky EFI data is encrypted when the kernel is run under SEV. Update the page table references to be sure the EFI memory areas are accessed encrypted. Signed-off-by: Tom Lendacky Signed-off-by: Brijesh Singh --- arch/x86/platform/efi/efi_64.c | 15 ++- 1 file

[RFC PATCH v2 09/32] x86: Change early_ioremap to early_memremap for BOOT data

2017-03-02 Thread Brijesh Singh
From: Tom Lendacky In order to map BOOT data with the proper encryption bit, the early_ioremap() function calls are changed to early_memremap() calls. This allows the proper access for both SME and SEV. Signed-off-by: Tom Lendacky --- arch/x86/kernel/acpi/boot.c |4 ++-- arch/x86/kernel/mp

[RFC PATCH v2 08/32] x86: Use PAGE_KERNEL protection for ioremap of memory page

2017-03-02 Thread Brijesh Singh
From: Tom Lendacky In order for memory pages to be properly mapped when SEV is active, we need to use the PAGE_KERNEL protection attribute as the base protection. This will insure that memory mapping of, e.g. ACPI tables, receives the proper mapping attributes. Signed-off-by: Tom Lendacky ---

[RFC PATCH v2 02/32] x86: Secure Encrypted Virtualization (SEV) support

2017-03-02 Thread Brijesh Singh
From: Tom Lendacky Provide support for Secure Encyrpted Virtualization (SEV). This initial support defines a flag that is used by the kernel to determine if it is running with SEV active. Signed-off-by: Tom Lendacky --- arch/x86/include/asm/mem_encrypt.h | 14 +- arch/x86/mm/mem_

[RFC PATCH v2 04/32] KVM: SVM: Add SEV feature definitions to KVM

2017-03-02 Thread Brijesh Singh
From: Tom Lendacky Define a new KVM CPU feature for Secure Encrypted Virtualization (SEV). The kernel will check for the presence of this feature to determine if it is running with SEV active. Define the SEV enable bit for the VMCB control structure. The hypervisor will use this bit to enable SE

[RFC PATCH v2 05/32] x86: Use encrypted access of BOOT related data with SEV

2017-03-02 Thread Brijesh Singh
From: Tom Lendacky When Secure Encrypted Virtualization (SEV) is active, BOOT data (such as EFI related data, setup data) is encrypted and needs to be accessed as such when mapped. Update the architecture override in early_memremap to keep the encryption attribute when mapping this data. Signed-

[RFC PATCH v2 30/32] kvm: svm: Add support for SEV DEBUG_ENCRYPT command

2017-03-02 Thread Brijesh Singh
The command copies a plain text into guest memory and encrypts it using the VM encryption key. The command will be used for debug purposes (e.g setting breakpoint through gdbserver) Signed-off-by: Brijesh Singh --- arch/x86/kvm/svm.c | 87

[RFC PATCH v2 06/32] x86/pci: Use memremap when walking setup data

2017-03-02 Thread Brijesh Singh
From: Tom Lendacky The use of ioremap will force the setup data to be mapped decrypted even though setup data is encrypted. Switch to using memremap which will be able to perform the proper mapping. Signed-off-by: Tom Lendacky --- arch/x86/pci/common.c |4 ++-- 1 file changed, 2 insertion

[RFC PATCH v2 32/32] x86: kvm: Pin the guest memory when SEV is active

2017-03-02 Thread Brijesh Singh
the KVM code to remove the pinning logical without making any changes into userspace (qemu). The patch pins userspace memory when a new slot is created and unpin the memory when slot is removed. [1] http://support.amd.com/TechDocs/55766_SEV-KM%20API_Spec.pdf Signed-off-by: Brijesh Singh --- arch

[RFC PATCH v2 31/32] kvm: svm: Add support for SEV LAUNCH_MEASURE command

2017-03-02 Thread Brijesh Singh
The command is used to retrieve the measurement of memory encrypted through the LAUNCH_UPDATE_DATA command. This measurement can be used for attestation purposes. Signed-off-by: Brijesh Singh --- arch/x86/kvm/svm.c | 52 1 file changed, 52

[RFC PATCH v2 24/32] kvm: x86: prepare for SEV guest management API support

2017-03-02 Thread Brijesh Singh
have asid value within asid range obtained through CPUID. - SEV guest must have the same asid for all vcpu's. A TLB flush is required if different vcpu for the same ASID is to be run on the same host CPU. Signed-off-by: Brijesh Singh --- arch/x86/include/asm/kvm_host.h |8 ++ arc

[RFC PATCH v2 01/32] x86: Add the Secure Encrypted Virtualization CPU feature

2017-03-02 Thread Brijesh Singh
From: Tom Lendacky Update the CPU features to include identifying and reporting on the Secure Encrypted Virtualization (SEV) feature. SME is identified by CPUID 0x801f, but requires BIOS support to enable it (set bit 23 of MSR_K8_SYSCFG and set bit 0 of MSR_K7_HWCR). Only show the SEV featu

[RFC PATCH v2 03/32] KVM: SVM: prepare for new bit definition in nested_ctl

2017-03-02 Thread Brijesh Singh
From: Tom Lendacky Currently the nested_ctl variable in the vmcb_control_area structure is used to indicate nested paging support. The nested paging support field is actually defined as bit 0 of the field. In order to support a new feature flag the usage of the nested_ctl and nested paging suppor

[RFC PATCH v2 23/32] kvm: introduce KVM_MEMORY_ENCRYPT_OP ioctl

2017-03-02 Thread Brijesh Singh
If hardware supports encrypting then KVM_MEMORY_ENCRYPT_OP ioctl can be used by qemu to issue platform specific memory encryption commands. Signed-off-by: Brijesh Singh --- arch/x86/include/asm/kvm_host.h |2 ++ arch/x86/kvm/x86.c | 12 include/uapi/linux/kvm.h

[RFC PATCH v2 18/32] kvm: svm: Use the hardware provided GPA instead of page walk

2017-03-02 Thread Brijesh Singh
ff-by: Brijesh Singh --- arch/x86/include/asm/kvm_emulate.h |1 + arch/x86/include/asm/kvm_host.h|3 ++ arch/x86/kvm/emulate.c | 20 +--- arch/x86/kvm/svm.c |2 ++ arch/x86/kvm/x86.c | 45 5

[RFC PATCH v2 22/32] kvm: svm: prepare to reserve asid for SEV guest

2017-03-02 Thread Brijesh Singh
In current implementation, asid allocation starts from 1, this patch adds a min_asid variable in svm_vcpu structure to allow starting asid from something other than 1. Signed-off-by: Brijesh Singh Reviewed-by: Paolo Bonzini --- arch/x86/kvm/svm.c |4 +++- 1 file changed, 3 insertions(+), 1

[RFC PATCH v2 16/32] x86: kvm: Provide support to create Guest and HV shared per-CPU variables

2017-03-02 Thread Brijesh Singh
Signed-off-by: Brijesh Singh --- arch/x86/kernel/kvm.c | 43 +++-- include/asm-generic/vmlinux.lds.h |3 +++ include/linux/percpu-defs.h |9 3 files changed, 48 insertions(+), 7 deletions(-) diff --git a/arch/x86/kernel/kvm.c b/

[RFC PATCH v2 29/32] kvm: svm: Add support for SEV DEBUG_DECRYPT command

2017-03-02 Thread Brijesh Singh
The command is used to decrypt guest memory region for debug purposes. Signed-off-by: Brijesh Singh --- arch/x86/kvm/svm.c | 76 1 file changed, 76 insertions(+) diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index 977aa22..ce8819a

[RFC PATCH v2 25/32] kvm: svm: Add support for SEV LAUNCH_START command

2017-03-02 Thread Brijesh Singh
The command is used to bootstrap SEV guest from unencrypted boot images. The command creates a new VM encryption key (VEK) using the guest owner's public DH certificates, and session data. The VEK will be used to encrypt the guest memory. Signed-off-by: Brijesh Singh --- arch/x86/kvm/

[RFC PATCH v2 20/32] crypto: ccp: Add Platform Security Processor (PSP) interface support

2017-03-02 Thread Brijesh Singh
: Brijesh Singh --- drivers/crypto/ccp/Kconfig |7 + drivers/crypto/ccp/Makefile |1 drivers/crypto/ccp/psp-dev.c | 211 ++ drivers/crypto/ccp/psp-dev.h | 102 drivers/crypto/ccp/sp-dev.c | 16 +++ drivers/crypto/ccp/sp

[RFC PATCH v2 21/32] crypto: ccp: Add Secure Encrypted Virtualization (SEV) interface support

2017-03-02 Thread Brijesh Singh
userspace. - in-kernel API's to encrypt the guest memory region. The in-kernel APIs will be used by KVM to bootstrap and debug the SEV guest. SEV key management spec is available here [1] [1] http://support.amd.com/TechDocs/55766_SEV-KM%20API_Specification.pdf Signed-off-by: Brijesh

[RFC PATCH v2 28/32] kvm: svm: Add support for SEV GUEST_STATUS command

2017-03-02 Thread Brijesh Singh
The command is used for querying the SEV guest status. Signed-off-by: Brijesh Singh --- arch/x86/kvm/svm.c | 37 + 1 file changed, 37 insertions(+) diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index c108064..977aa22 100644 --- a/arch/x86/kvm/svm.c

[RFC PATCH v2 26/32] kvm: svm: Add support for SEV LAUNCH_UPDATE_DATA command

2017-03-02 Thread Brijesh Singh
The command is used for encrypting the guest memory region using the VM encryption key (VEK) created from LAUNCH_START. Signed-off-by: Brijesh Singh --- arch/x86/kvm/svm.c | 150 1 file changed, 150 insertions(+) diff --git a/arch/x86/kvm

[RFC PATCH v2 12/32] x86: Add early boot support when running with SEV active

2017-03-02 Thread Brijesh Singh
From: Tom Lendacky Early in the boot process, add checks to determine if the kernel is running with Secure Encrypted Virtualization (SEV) active by issuing a CPUID instruction. During early compressed kernel booting, if SEV is active the pagetables are updated so that data is accessed and decomp

[RFC PATCH v2 13/32] KVM: SVM: Enable SEV by setting the SEV_ENABLE CPU feature

2017-03-02 Thread Brijesh Singh
From: Tom Lendacky Modify the SVM cpuid update function to indicate if Secure Encrypted Virtualization (SEV) is active in the guest by setting the SEV KVM CPU features bit. SEV is active if Secure Memory Encryption is enabled in the host and the SEV_ENABLE bit of the VMCB is set. Signed-off-by:

[RFC PATCH v2 14/32] x86: mm: Provide support to use memblock when spliting large pages

2017-03-02 Thread Brijesh Singh
Secure Encrypted Virtualization (SEV) mode, where we may need to change the memory region attributes in early boot process. Signed-off-by: Brijesh Singh --- arch/x86/mm/pageattr.c | 51 1 file changed, 42 insertions(+), 9 deletions(-) diff --git a

[RFC PATCH v2 10/32] x86: DMA support for SEV memory encryption

2017-03-02 Thread Brijesh Singh
From: Tom Lendacky DMA access to memory mapped as encrypted while SEV is active can not be encrypted during device write or decrypted during device read. In order for DMA to properly work when SEV is active, the swiotlb bounce buffers must be used. Signed-off-by: Tom Lendacky --- arch/x86/mm/m

[RFC PATCH v2 15/32] x86: Add support for changing memory encryption attribute in early boot

2017-03-02 Thread Brijesh Singh
code. Signed-off-by: Brijesh Singh --- arch/x86/include/asm/mem_encrypt.h | 15 + arch/x86/mm/mem_encrypt.c | 63 2 files changed, 78 insertions(+) diff --git a/arch/x86/include/asm/mem_encrypt.h b/arch/x86/include/asm/mem_encrypt.h index

[RFC PATCH v2 00/32] x86: Secure Encrypted Virtualization (AMD)

2017-03-02 Thread Brijesh Singh
x27;s review feedbacks - add APIs to support sharing the guest physical address with hypervisor - update kvm pvclock driver to use the shared buffer when SEV is active - pin the SEV guest memory Brijesh Singh (18): x86: mm: Provide support to use memblock when spliting large pages

Re: [RFC PATCH v2 19/32] crypto: ccp: Introduce the AMD Secure Processor device

2017-03-02 Thread Brijesh Singh
Hi Mark, On 03/02/2017 11:39 AM, Mark Rutland wrote: On Thu, Mar 02, 2017 at 10:16:15AM -0500, Brijesh Singh wrote: The CCP device is part of the AMD Secure Processor. In order to expand the usage of the AMD Secure Processor, create a framework that allows functional components of the AMD

[RFC PATCH v2 27/32] kvm: svm: Add support for SEV LAUNCH_FINISH command

2017-03-02 Thread Brijesh Singh
The command is used for finializing the SEV guest launch process. Signed-off-by: Brijesh Singh --- arch/x86/kvm/svm.c | 36 1 file changed, 36 insertions(+) diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index 62c2b22..c108064 100644 --- a/arch/x86

[RFC PATCH v2 17/32] x86: kvmclock: Clear encryption attribute when SEV is active

2017-03-02 Thread Brijesh Singh
hypervisor and guest can access the data. Signed-off-by: Brijesh Singh --- arch/x86/kernel/kvmclock.c | 65 ++-- 1 file changed, 56 insertions(+), 9 deletions(-) diff --git a/arch/x86/kernel/kvmclock.c b/arch/x86/kernel/kvmclock.c index 278de4f..3b38b3d

Re: [RFC PATCH v2 01/32] x86: Add the Secure Encrypted Virtualization CPU feature

2017-03-03 Thread Brijesh Singh
Hi Boris, On 03/03/2017 10:59 AM, Borislav Petkov wrote: On Thu, Mar 02, 2017 at 10:12:09AM -0500, Brijesh Singh wrote: From: Tom Lendacky Update the CPU features to include identifying and reporting on the Secure Encrypted Virtualization (SEV) feature. SME is identified by CPUID 0x801f

Re: [RFC PATCH v2 00/32] x86: Secure Encrypted Virtualization (AMD)

2017-03-03 Thread Brijesh Singh
Hi Bjorn, On 03/03/2017 02:33 PM, Bjorn Helgaas wrote: On Thu, Mar 02, 2017 at 10:12:01AM -0500, Brijesh Singh wrote: This RFC series provides support for AMD's new Secure Encrypted Virtualization (SEV) feature. This RFC is build upon Secure Memory Encryption (SME) RFCv4 [1]. What k

Re: [RFC PATCH v2 01/32] x86: Add the Secure Encrypted Virtualization CPU feature

2017-03-06 Thread Brijesh Singh
On 03/04/2017 04:11 AM, Borislav Petkov wrote: > On Fri, Mar 03, 2017 at 03:01:23PM -0600, Brijesh Singh wrote: > > This looks like a wraparound... > > $ test-apply.sh /tmp/brijesh.singh.delta > checking file Documentation/admin-guide/kernel-parameters.txt > Hunk #1 succeed

[RFC Part2 PATCH v3 00/26] x86: Secure Encrypted Virtualization (AMD)

2017-07-24 Thread Brijesh Singh
y ranges (recommend by Paolo) * Extend kvm_x86_ops to provide new memory_encryption_enabled ops * Enhance DEBUG DECRYPT/ENCRYPT commands to work with more than one page (recommended by Paolo) * Optimize LAUNCH_UPDATE command to reduce the number of calls to AMD-SP driver * Changes to address v2

[RFC Part2 PATCH v3 02/26] crypto: ccp: Add Platform Security Processor (PSP) device support

2017-07-24 Thread Brijesh Singh
tursted applications. Cc: Herbert Xu Cc: David S. Miller Cc: Gary Hook Cc: linux-crypto@vger.kernel.org Signed-off-by: Brijesh Singh --- drivers/crypto/ccp/Kconfig | 9 ++ drivers/crypto/ccp/Makefile | 1 + drivers/crypto/ccp/psp-dev.c | 226

[RFC Part2 PATCH v3 03/26] crypto: ccp: Add Secure Encrypted Virtualization (SEV) device support

2017-07-24 Thread Brijesh Singh
encryption context for the SEV guests. - a userspace IOCTL to manage the platform certificates etc Cc: Herbert Xu Cc: David S. Miller Cc: Gary Hook Cc: linux-crypto@vger.kernel.org Signed-off-by: Brijesh Singh --- drivers/crypto/ccp/Kconfig | 10 + drivers/crypto/ccp/Makefile | 1 + drivers

Re: [RFC Part2 PATCH v3 02/26] crypto: ccp: Add Platform Security Processor (PSP) device support

2017-07-25 Thread Brijesh Singh
On 07/25/2017 03:29 AM, Kamil Konieczny wrote: Hi, minor misspelling, On 24.07.2017 22:02, Brijesh Singh wrote: Platform Security Processor (PSP) is part of AMD Secure Processor (AMD-SP), PSP is a dedicated processor that provides the support for key management commands in a Secure Encrypted

Re: [RFC Part2 PATCH v3 02/26] crypto: ccp: Add Platform Security Processor (PSP) device support

2017-09-06 Thread Brijesh Singh
Hi Boris, On 09/06/2017 12:00 PM, Borislav Petkov wrote: ... -- |diff --git a/drivers/crypto/ccp/sp-dev.c b/drivers/crypto/ccp/sp-dev.c |index a017233..d263ba4 100644 |--- a/drivers/crypto/ccp/sp-dev.c |+++ b/drivers/crypto/ccp/sp-dev.c -- What

Re: [RFC Part2 PATCH v3 02/26] crypto: ccp: Add Platform Security Processor (PSP) device support

2017-09-07 Thread Brijesh Singh
Hi Boris, On 09/07/2017 09:27 AM, Borislav Petkov wrote: ... The commit message above reads better to me as the help text than what you have here. Also, in order to make it easier for the user, I think we'll need a CONFIG_AMD_MEM_ENCRYPT_SEV or so and make that depend on CONFIG_KVM_AMD, this

Re: [RFC Part2 PATCH v3 02/26] crypto: ccp: Add Platform Security Processor (PSP) device support

2017-09-08 Thread Brijesh Singh
On 09/08/2017 03:40 AM, Borislav Petkov wrote: On Thu, Sep 07, 2017 at 05:19:32PM -0500, Brijesh Singh wrote: At high level, AMD-SP (AMD Secure Processor) (i.e CCP driver) will provide the support for CCP, SEV and TEE FW commands. +--- CCP | AMD-SP

Re: [RFC Part2 PATCH v3 02/26] crypto: ccp: Add Platform Security Processor (PSP) device support

2017-09-08 Thread Brijesh Singh
On 09/08/2017 03:40 AM, Borislav Petkov wrote: On Thu, Sep 07, 2017 at 05:19:32PM -0500, Brijesh Singh wrote: At high level, AMD-SP (AMD Secure Processor) (i.e CCP driver) will provide the support for CCP, SEV and TEE FW commands. +--- CCP | AMD-SP

Re: [RFC Part2 PATCH v3 03/26] crypto: ccp: Add Secure Encrypted Virtualization (SEV) device support

2017-09-12 Thread Brijesh Singh
Hi Boris, I will address all your feedback in next rev. On 09/12/2017 09:02 AM, Borislav Petkov wrote: ... You could make that more tabular like this: case SEV_CMD_INIT: return sizeof(struct sev_data_init); case SEV_CMD_PLATFORM_STATUS: return sizeof(struct

Re: [RFC Part2 PATCH v3 03/26] crypto: ccp: Add Secure Encrypted Virtualization (SEV) device support

2017-09-13 Thread Brijesh Singh
On 09/13/2017 09:17 AM, Borislav Petkov wrote: ... + +unlock: + mutex_unlock(&sev_cmd_mutex); + print_hex_dump_debug("(out): ", DUMP_PREFIX_OFFSET, 16, 2, data, + sev_cmd_buffer_len(cmd), false); + return ret; ... and here you return psp_ret == 0 even

[Part2 PATCH v4 00/29] x86: Secure Encrypted Virtualization (AMD)

2017-09-19 Thread Brijesh Singh
n_enabled ops * Enhance DEBUG DECRYPT/ENCRYPT commands to work with more than one page \ (recommended by Paolo) * Optimize LAUNCH_UPDATE command to reduce the number of calls to AMD-SP driver * Changes to address v2 feedbacks Brijesh Singh (26): Documentation/virtual/kvm: Add AMD Se

[Part2 PATCH v4 07/29] crypto: ccp: Add Secure Encrypted Virtualization (SEV) command support

2017-09-19 Thread Brijesh Singh
org Signed-off-by: Brijesh Singh --- drivers/crypto/ccp/psp-dev.c | 743 ++- drivers/crypto/ccp/psp-dev.h | 17 + include/linux/psp-sev.h | 171 ++ include/uapi/linux/psp-sev.h | 114 +++ 4 files changed, 1044 insertions(+), 1 deletion(-) c

[Part2 PATCH v4 06/29] ccp: crypto: Define SEV key management command id

2017-09-19 Thread Brijesh Singh
: "Radim Krčmář" Cc: Borislav Petkov Cc: Herbert Xu Cc: Gary Hook Cc: Tom Lendacky Cc: linux-crypto@vger.kernel.org Cc: k...@vger.kernel.org Cc: linux-ker...@vger.kernel.org Signed-off-by: Brijesh Singh --- include/linux/psp-sev.h | 512 ++

[Part2 PATCH v4 05/29] crypto: ccp: Add Platform Security Processor (PSP) device support

2017-09-19 Thread Brijesh Singh
trusted applications. Cc: Paolo Bonzini Cc: "Radim Krčmář" Cc: Borislav Petkov Cc: Herbert Xu Cc: Gary Hook Cc: Tom Lendacky Cc: linux-crypto@vger.kernel.org Cc: k...@vger.kernel.org Cc: linux-ker...@vger.kernel.org Signed-off-by: Brijesh Singh --- drivers/crypto/ccp/Kconf

[Part2 PATCH v4.1 05/30] crypto: ccp: Add Platform Security Processor (PSP) device support

2017-09-29 Thread Brijesh Singh
-party trusted applications. Cc: Paolo Bonzini Cc: "Radim Krčmář" Cc: Borislav Petkov Cc: Herbert Xu Cc: Gary Hook Cc: Tom Lendacky Cc: linux-crypto@vger.kernel.org Cc: k...@vger.kernel.org Cc: linux-ker...@vger.kernel.org Signed-off-by: Brijesh Singh --- Hi Boris, I have been goi

Re: [PATCH] crypto: ccp: Build the AMD secure processor driver only with AMD CPU support

2017-09-30 Thread Brijesh Singh
On 9/30/17 3:30 AM, Borislav Petkov wrote: ... > From: Borislav Petkov > > This is AMD-specific hardware so present it in Kconfig only when AMD > CPU support is enabled. > > Signed-off-by: Borislav Petkov > Cc: Brijesh Singh > Cc: Tom Lendacky > Cc: Gary Hook >

Re: [Part2 PATCH v4 05/29] crypto: ccp: Add Platform Security Processor (PSP) device support

2017-09-30 Thread Brijesh Singh
On 9/29/17 10:16 AM, Borislav Petkov wrote: ... > + >> +config CRYPTO_DEV_SP_PSP >> +bool "Platform Security Processor (PSP) device" >> +default y >> +depends on CRYPTO_DEV_CCP_DD > So this last symbol CRYPTO_DEV_CCP_DD is default m and it doesn't depend > on anything. And I'm pretty

Re: [Part2 PATCH v4 05/29] crypto: ccp: Add Platform Security Processor (PSP) device support

2017-10-01 Thread Brijesh Singh
On 9/30/17 11:11 AM, Borislav Petkov wrote: > I think just from having CRYPTO_DEV_CCP_DD depend on CPU_SUP_AMD || > ARM64, CRYPTO_DEV_SP_PSP gets almost the same dependency transitively. > But sure, let's make the PSP build only on x86. It should depend on > X86_64, to be precise. I think theore

[Part2 Patch v4.2] crypto: ccp: Add Platform Security Processor (PSP) device support

2017-10-02 Thread Brijesh Singh
acky Cc: linux-crypto@vger.kernel.org Cc: k...@vger.kernel.org Cc: linux-ker...@vger.kernel.org Signed-off-by: Brijesh Singh --- Changes since v4.1: * Add CPU_SUP_AMD depends * Add a note in commit message that PSP can be used outside KVM * Fix the Kconfig help based on Boris feedback

[Part2 PATCH v4.1 07/29] crypto: ccp: Add Secure Encrypted Virtualization (SEV) command support

2017-10-02 Thread Brijesh Singh
org Signed-off-by: Brijesh Singh --- Changes since v4: * fixes reported by kbuild robot * update sev_cmd_buffer_len() to use tabular format to make it more readable drivers/crypto/ccp/psp-dev.c | 734 +++ drivers/crypto/ccp/psp-dev.h | 17 + include

[Part2 PATCH v4.1 06/29] crypto: ccp: Define SEV key management command id

2017-10-02 Thread Brijesh Singh
ert Xu Cc: Gary Hook Cc: Tom Lendacky Cc: linux-crypto@vger.kernel.org Cc: k...@vger.kernel.org Cc: linux-ker...@vger.kernel.org Signed-off-by: Brijesh Singh --- Changes since v4: * add spec reference include/linux/psp-sev.h | 515 1 file ch

Re: [Part2 PATCH v4 05/29] crypto: ccp: Add Platform Security Processor (PSP) device support

2017-10-03 Thread Brijesh Singh
-by: Borislav Petkov Cc: Brijesh Singh Cc: Tom Lendacky Cc: Gary Hook Cc: Herbert Xu Cc: "David S. Miller" Cc: linux-crypto@vger.kernel.org --- drivers/crypto/ccp/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/crypto/ccp/Kconfig b/drivers/crypto/ccp/Kco

[Part2 PATCH v5 00/31] x86: Secure Encrypted Virtualization (AMD)

2017-10-04 Thread Brijesh Singh
orislav Petkov (1): crypto: ccp: Build the AMD secure processor driver only with AMD CPU support Brijesh Singh (27): Documentation/virtual/kvm: Add AMD Secure Encrypted Virtualization (SEV) KVM: SVM: Prepare to reserve asid for SEV guest KVM: X86: Extend CPUID range to include new leaf

[Part2 PATCH v5 11/31] crypto: ccp: Define SEV key management command id

2017-10-04 Thread Brijesh Singh
ert Xu Cc: Gary Hook Cc: Tom Lendacky Cc: linux-crypto@vger.kernel.org Cc: k...@vger.kernel.org Cc: linux-ker...@vger.kernel.org Signed-off-by: Brijesh Singh --- include/linux/psp-sev.h | 515 1 file changed, 515 insertions(+) create mode 1006

[Part2 PATCH v5 12/31] crypto: ccp: Add Secure Encrypted Virtualization (SEV) command support

2017-10-04 Thread Brijesh Singh
org Signed-off-by: Brijesh Singh --- drivers/crypto/ccp/psp-dev.c | 734 +++ drivers/crypto/ccp/psp-dev.h | 17 + include/linux/psp-sev.h | 159 ++ include/uapi/linux/psp-sev.h | 116 +++ 4 files changed, 1026 insertions(+) create mode 1006

[Part2 PATCH v5 09/31] crypto: ccp: Build the AMD secure processor driver only with AMD CPU support

2017-10-04 Thread Brijesh Singh
From: Borislav Petkov This is AMD-specific hardware so present it in Kconfig only when AMD CPU support is enabled or on ARM64 where it is also used. Signed-off-by: Signed-off-by: Borislav Petkov Cc: Brijesh Singh Cc: Tom Lendacky Cc: Gary Hook Cc: Herbert Xu Cc: "David S. Miller

[Part2 PATCH v5 10/31] crypto: ccp: Add Platform Security Processor (PSP) device support

2017-10-04 Thread Brijesh Singh
acky Cc: linux-crypto@vger.kernel.org Cc: k...@vger.kernel.org Cc: linux-ker...@vger.kernel.org Signed-off-by: Brijesh Singh --- drivers/crypto/ccp/Kconfig | 11 + drivers/crypto/ccp/Makefile | 1 + drivers/crypto/ccp/psp-dev.c | 109 +++ drivers

Re: [Part2 PATCH v5 09/31] crypto: ccp: Build the AMD secure processor driver only with AMD CPU support

2017-10-04 Thread Brijesh Singh
On 10/04/2017 04:47 PM, Borislav Petkov wrote:> Signed-off-by: Borislav Petkov Signed-off-by: Brijesh Singh i.e., the first SOB is the author's and the second is yours which means, you've handled the patch further on, like sending it upstream, for example. Noted, thanks

Re: [Part2 PATCH v5 12/31] crypto: ccp: Add Secure Encrypted Virtualization (SEV) command support

2017-10-06 Thread Brijesh Singh
On 10/6/17 1:49 PM, Borislav Petkov wrote: ... >> + >> +static unsigned int sev_poll; >> +module_param(sev_poll, uint, 0444); >> +MODULE_PARM_DESC(sev_poll, "Poll for sev command completion - any non-zero >> value"); > What is that used for? Some debugging leftover probably? If not, add a > comm

[Part2 PATCH v5.1 10/31] crypto: ccp: Add Platform Security Processor (PSP) device support

2017-10-06 Thread Brijesh Singh
: Gary Hook Cc: Tom Lendacky Cc: linux-crypto@vger.kernel.org Cc: k...@vger.kernel.org Cc: linux-ker...@vger.kernel.org Improvements-by: Borislav Petkov Signed-off-by: Brijesh Singh Reviewed-by: Borislav Petkov --- Changes since v5: * move psp_entry in sp-pci.c (based on Boris improvement p

[Part2 PATCH v5.1 12.7/31] crypto: ccp: Implement SEV_PEK_CSR ioctl command

2017-10-06 Thread Brijesh Singh
kernel.org Cc: linux-ker...@vger.kernel.org Signed-off-by: Brijesh Singh --- drivers/crypto/ccp/psp-dev.c | 85 1 file changed, 85 insertions(+) diff --git a/drivers/crypto/ccp/psp-dev.c b/drivers/crypto/ccp/psp-dev.c index 28efb7a9245a..8038ca7ae

[Part2 PATCH v5.1 12.2/31] crypto: ccp: Define SEV userspace ioctl and command id

2017-10-06 Thread Brijesh Singh
Cc: linux-ker...@vger.kernel.org Signed-off-by: Brijesh Singh --- include/uapi/linux/psp-sev.h | 115 +++ 1 file changed, 115 insertions(+) create mode 100644 include/uapi/linux/psp-sev.h diff --git a/include/uapi/linux/psp-sev.h b/include/uapi/linux/psp

[Part2 PATCH v5.1 12.6/31] crypto: ccp: Implement SEV_PDH_GEN ioctl command

2017-10-06 Thread Brijesh Singh
.org Cc: k...@vger.kernel.org Cc: linux-ker...@vger.kernel.org Signed-off-by: Brijesh Singh --- drivers/crypto/ccp/psp-dev.c | 32 1 file changed, 32 insertions(+) diff --git a/drivers/crypto/ccp/psp-dev.c b/drivers/crypto/ccp/psp-dev.c index 03d7bd03ad58..28efb7a9245a 100644 ---

[Part2 PATCH v5.1 12.9/31] crypto: ccp: Implement SEV_PDH_CERT_EXPORT ioctl command

2017-10-06 Thread Brijesh Singh
.org Cc: k...@vger.kernel.org Cc: linux-ker...@vger.kernel.org Signed-off-by: Brijesh Singh --- drivers/crypto/ccp/psp-dev.c | 110 +++ 1 file changed, 110 insertions(+) diff --git a/drivers/crypto/ccp/psp-dev.c b/drivers/crypto/ccp/psp-dev.c index 861c44bf2910..0a

[Part2 PATCH v5.1 12.8/31] crypto: ccp: Implement SEV_PEK_CERT_IMPORT ioctl command

2017-10-06 Thread Brijesh Singh
kernel.org Cc: linux-ker...@vger.kernel.org Signed-off-by: Brijesh Singh --- drivers/crypto/ccp/psp-dev.c | 97 1 file changed, 97 insertions(+) diff --git a/drivers/crypto/ccp/psp-dev.c b/drivers/crypto/ccp/psp-dev.c index 8038ca7aef03..861c44bf2910 10

[Part2 PATCH v5.1 12.4/31] crypto: ccp: Implement SEV_PLATFORM_STATUS ioctl command

2017-10-06 Thread Brijesh Singh
nux-crypto@vger.kernel.org Cc: k...@vger.kernel.org Cc: linux-ker...@vger.kernel.org Signed-off-by: Brijesh Singh --- drivers/crypto/ccp/psp-dev.c | 34 ++ 1 file changed, 34 insertions(+) diff --git a/drivers/crypto/ccp/psp-dev.c b/drivers/crypto/ccp/psp-dev.c index 94

[Part2 PATCH v5.1 12.5/31] crypto: ccp: Implement SEV_PEK_GEN ioctl command

2017-10-06 Thread Brijesh Singh
kernel.org Cc: linux-ker...@vger.kernel.org Signed-off-by: Brijesh Singh --- drivers/crypto/ccp/psp-dev.c | 68 1 file changed, 68 insertions(+) diff --git a/drivers/crypto/ccp/psp-dev.c b/drivers/crypto/ccp/psp-dev.c index d68303a06464..03d7bd03ad58 10

[Part2 PATCH v5.1 12.1/31] crypto: ccp: Add Secure Encrypted Virtualization (SEV) command support

2017-10-06 Thread Brijesh Singh
Improvements-by: Borislav Petkov Signed-off-by: Brijesh Singh --- Based on Boris feedback split this patch in 9 logical patches, they are numbers from 12.1 to 12.9. drivers/crypto/ccp/psp-dev.c | 244 +++ drivers/crypto/ccp/psp-dev.h | 17 +++ include/

[Part2 PATCH v5.1 12.3/31] crypto: ccp: Implement SEV_FACTORY_RESET ioctl command

2017-10-06 Thread Brijesh Singh
kernel.org Cc: k...@vger.kernel.org Cc: linux-ker...@vger.kernel.org Signed-off-by: Brijesh Singh --- drivers/crypto/ccp/psp-dev.c | 29 - 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/drivers/crypto/ccp/psp-dev.c b/drivers/crypto/ccp/psp-dev.c index e9

Re: [Part2 PATCH v5 12/31] crypto: ccp: Add Secure Encrypted Virtualization (SEV) command support

2017-10-07 Thread Brijesh Singh
On 10/6/17 1:49 PM, Borislav Petkov wrote: ... >> +static int sev_wait_cmd_ioc(struct psp_device *psp, unsigned int *reg) >> +{ >> +psp->sev_int_rcvd = 0; >> + >> +wait_event(psp->sev_int_queue, psp->sev_int_rcvd); > What happens if the command times out and it never sets psp->sev_int_rcv

Re: [Part2 PATCH v5.1 12.1/31] crypto: ccp: Add Secure Encrypted Virtualization (SEV) command support

2017-10-08 Thread Brijesh Singh
On 10/7/17 1:40 PM, Borislav Petkov wrote: ... > A bunch of fixes ontop: > > * sev_fops_registered is superfluous if you can use psp->has_sev_fops I am okay with all your fixes except this one. I will add my comment below. ... > static int sev_ops_init(struct psp_device *psp) > { > stru

Re: [Part2 PATCH v5 11/31] crypto: ccp: Define SEV key management command id

2017-10-08 Thread Brijesh Singh
On 10/5/17 3:56 PM, Borislav Petkov wrote: > On Wed, Oct 04, 2017 at 08:13:52AM -0500, Brijesh Singh wrote: >> Define Secure Encrypted Virtualization (SEV) key management command id >> and structure. The command definition is available in SEV KM [1] spec >> 0.14. >> &g

Re: [Part2 PATCH v5.1 12.2/31] crypto: ccp: Define SEV userspace ioctl and command id

2017-10-08 Thread Brijesh Singh
On 10/7/17 9:20 AM, Borislav Petkov wrote: > On Fri, Oct 06, 2017 at 08:06:00PM -0500, Brijesh Singh wrote: >> Add a include file which defines the ioctl and command id used for >> issuing SEV platform management specific commands. >> >> Cc: Paolo Bonzini >> Cc

Re: [Part2 PATCH v5.1 12.1/31] crypto: ccp: Add Secure Encrypted Virtualization (SEV) command support

2017-10-08 Thread Brijesh Singh
On 10/8/17 9:00 AM, Borislav Petkov wrote: > On Sun, Oct 08, 2017 at 08:30:47AM -0500, Brijesh Singh wrote: >> During the device probe, sev_ops_init() will be called for every device >> instance which claims to support the SEV.  One of the device will be >> 'master'

Re: [Part2 PATCH v5.1 12.1/31] crypto: ccp: Add Secure Encrypted Virtualization (SEV) command support

2017-10-10 Thread Brijesh Singh
On 10/09/2017 10:21 AM, Borislav Petkov wrote: ... 03:00.1 Encryption controller: Advanced Micro Devices, Inc. [AMD] Device 1468 13:00.2 Encryption controller: Advanced Micro Devices, Inc. [AMD] Device 1456 Btw, what do those PCI functions each do? Public PPR doesn't have them documented.

Re: [Part2 PATCH v5.1 12.1/31] crypto: ccp: Add Secure Encrypted Virtualization (SEV) command support

2017-10-11 Thread Brijesh Singh
On 10/11/2017 09:19 AM, Borislav Petkov wrote: On Sun, Oct 08, 2017 at 08:30:47AM -0500, Brijesh Singh wrote: Basically we need some variable which is outside the per-device structure so that we don't end up creating multiple /dev/sev nodes. If needed, I think we can remove 'ha

[Part2 PATCH v5.2 12.1/31] crypto: ccp: Define SEV userspace ioctl and command id

2017-10-11 Thread Brijesh Singh
Cc: linux-ker...@vger.kernel.org Improvements-by: Borislav Petkov Signed-off-by: Brijesh Singh Reviewed-by: Borislav Petkov --- Make it as the first patch in the series (changed from 12.2/31 -> 12.1/31) Changes since v5.1: * add __packed improvement from Boris The full tree is available at:

[Part2 PATCH v5.2 12.2/31] crypto: ccp: Add Secure Encrypted Virtualization (SEV) command support

2017-10-11 Thread Brijesh Singh
Improvements-by: Borislav Petkov Signed-off-by: Brijesh Singh --- Make it as a second patch in the series (changes from 12.1 -> 12.2) Changes since v5.1: * text streamlining (from Boris) * rename sev_handle_cmd -> sev_do_cmd (from Boris) * PSP_P2CMSG needs arg eval (from Boris) * use

[Part2 PATCH v5.2 12.3/31] crypto: ccp: Implement SEV_FACTORY_RESET ioctl command

2017-10-11 Thread Brijesh Singh
kernel.org Cc: k...@vger.kernel.org Cc: linux-ker...@vger.kernel.org Improvements-by: Borislav Petkov Signed-off-by: Brijesh Singh --- Changes since v5.1: * rename sev_handle_cmd -> sev_do_cmd (from Boris) * skip copy_to_user when invalid cmd id is passed (from Boris) * use SEV_MAX instead o

[Part2 PATCH v5.2 12.4/31] crypto: ccp: Implement SEV_PLATFORM_STATUS ioctl command

2017-10-11 Thread Brijesh Singh
nux-crypto@vger.kernel.org Cc: k...@vger.kernel.org Cc: linux-ker...@vger.kernel.org Signed-off-by: Brijesh Singh --- Changes since v5.1: * rename sev_handle_cmd -> sev_do_cmd drivers/crypto/ccp/psp-dev.c | 34 ++ 1 file changed, 34 insertions(+) diff --git a/drivers/c

Re: [Part2 PATCH v5.1 12.4/31] crypto: ccp: Implement SEV_PLATFORM_STATUS ioctl command

2017-10-11 Thread Brijesh Singh
On 10/11/2017 12:02 PM, Borislav Petkov wrote: ... What's with the curly brackets around the case: statements? I will remove the curly braces. Anyway, here are some more improvements: * you can get rid of the struct copying into out and the bitfields by doing something like this:

Re: [Part2 PATCH v5.1 12.4/31] crypto: ccp: Implement SEV_PLATFORM_STATUS ioctl command

2017-10-11 Thread Brijesh Singh
On 10/11/2017 03:04 PM, Borislav Petkov wrote: On Wed, Oct 11, 2017 at 02:49:55PM -0500, Brijesh Singh wrote: This is OK for now. But in future if FW steals another bit from reserved1 field to expose a new flag then 'owner' name will no longer be valid. If you don't to use bi

Re: [Part2 PATCH v5.1 12.4/31] crypto: ccp: Implement SEV_PLATFORM_STATUS ioctl command

2017-10-11 Thread Brijesh Singh
On 10/11/2017 03:28 PM, Borislav Petkov wrote: On Wed, Oct 11, 2017 at 03:10:49PM -0500, Brijesh Singh wrote: The current 'struct sev_data_status' matches with the firmware names and the bit fields. Only thing I did was the fields with no name is called as "reservedX" O

Re: [Part2 PATCH v5.1 12.4/31] crypto: ccp: Implement SEV_PLATFORM_STATUS ioctl command

2017-10-11 Thread Brijesh Singh
On 10/11/2017 03:45 PM, Brijesh Singh wrote: On 10/11/2017 03:28 PM, Borislav Petkov wrote: On Wed, Oct 11, 2017 at 03:10:49PM -0500, Brijesh Singh wrote: The current 'struct sev_data_status' matches with the firmware names and the bit fields. Only thing I did was the fields wi

Re: [Part2 PATCH v5.2 12.1/31] crypto: ccp: Define SEV userspace ioctl and command id

2017-10-12 Thread Brijesh Singh
On 10/12/2017 08:27 AM, Borislav Petkov wrote: ... +/** + * struct sev_user_data_status - PLATFORM_STATUS command parameters + * + * @major: major API version + * @minor: minor API version + * @state: platform state + * @owner: self-owned or externally owned + * @config: platform config flag

Re: [Part2 PATCH v5.2 12.2/31] crypto: ccp: Add Secure Encrypted Virtualization (SEV) command support

2017-10-12 Thread Brijesh Singh
On 10/12/17 1:21 PM, Borislav Petkov wrote: . > Btw, that function returns 0 unconditionally. So you can make it return > void and... Will do >> +if (ret) >> +goto unlock; > ... remove this check and initialize ret to 0 at the beginning. > Will do

Re: [Part2 PATCH v5.1 12.5/31] crypto: ccp: Implement SEV_PEK_GEN ioctl command

2017-10-12 Thread Brijesh Singh
On 10/12/17 1:28 PM, Borislav Petkov wrote: > On Fri, Oct 06, 2017 at 08:06:03PM -0500, Brijesh Singh wrote: >> The SEV_PEK_GEN command is used to generate a new Platform Endorsement >> Key (PEK). The command is defined in SEV spec section 5.6. >> >> Cc: Paolo Bo

Re: [Part2 PATCH v5.1 12.6/31] crypto: ccp: Implement SEV_PDH_GEN ioctl command

2017-10-12 Thread Brijesh Singh
On 10/12/17 1:48 PM, Borislav Petkov wrote: ... > On Fri, Oct 06, 2017 at 08:06:04PM -0500, Brijesh Singh wrote: >> The SEV_PDH_GEN command is used to re-generate the Platform >> Diffie-Hellman (PDH) key. The command is defined in SEV spec section >> 5.9. >> >>

  1   2   3   4   >