[Qemu-devel] [RFC PATCH v1 02/22] cpu-common: add debug version of physical memory read/write

2016-09-13 Thread Brijesh Singh
create/set special sev specific MemTxAttrs to indicate that RAM access is for debugg purposes and use SEV debug commands to read and write guest memory for debug purposes. Signed-off-by: Brijesh Singh <brijesh.si...@amd.com> --- exec.c| 10 ++ include/ex

[Qemu-devel] [RFC PATCH v1 11/22] sev: add SEV debug encrypt command

2016-09-13 Thread Brijesh Singh
=147190861124032=2 http://marc.info/?l=kvm=147190861124032=2 Signed-off-by: Brijesh Singh <brijesh.si...@amd.com> --- include/sysemu/sev.h | 10 ++ sev.c| 23 +++ 2 files changed, 33 insertions(+) diff --git a/include/sysemu/sev.h b/include/sysemu/sev.h

[Qemu-devel] [RFC PATCH v1 22/22] loader: reload bios image on ROM reset in SEV-enabled guest

2016-09-13 Thread Brijesh Singh
In SEV-enabled mode we need to reload the BIOS image on loader reset, this will ensure that BIOS image gets encrypted and included as part of launch meausrement on guest reset. Signed-off-by: Brijesh Singh <brijesh.si...@amd.com> --- hw/core/loader.c |7 ++- 1 file changed, 6 inse

[Qemu-devel] [RFC PATCH v1 08/22] sev: add SEV launch update command

2016-09-13 Thread Brijesh Singh
://marc.info/?l=kvm=147190859023996=2 Signed-off-by: Brijesh Singh <brijesh.si...@amd.com> --- include/sysemu/sev.h |9 + sev.c| 36 2 files changed, 45 insertions(+) diff --git a/include/sysemu/sev.h b/include/sysemu/sev.h

[Qemu-devel] [RFC PATCH v1 03/22] monitor: use debug version of physical memory read api

2016-09-13 Thread Brijesh Singh
This patch updates hmp monitor to use cpu_physical_memory_read_debug() when accessing the guest memory for debug dumps. Signed-off-by: Brijesh Singh <brijesh.si...@amd.com> --- disas.c |2 +- monitor.c |2 +- target-i386/monitor.c | 18 ++-

[Qemu-devel] [RFC PATCH v1 14/22] sev: provide SEV-enabled guest RAM read/write ops

2016-09-13 Thread Brijesh Singh
The patch implements kvm_sev_get_ram_ops() which provides guest RAM read/write callback. Depending on the memory attributes and guest launch state, the callback will use SEV launch update or SEV debug commands to read/write into guest memory. Signed-off-by: Brijesh Singh <brijesh.si...@amd.

[Qemu-devel] [RFC PATCH v1 01/22] exec: add guest RAM read/write ops

2016-09-13 Thread Brijesh Singh
; memory_region_init_ram(mem, NULL, "memory", size, NULL); memory_region_set_ram_ops(mem, ops); Signed-off-by: Brijesh Singh <brijesh.si...@amd.com> --- exec.c| 304 +++-- include/exec/memory.h | 25 2 files changed

[Qemu-devel] [RFC PATCH v1 21/22] hw: add pre and post system reset callback

2016-09-13 Thread Brijesh Singh
. These callback will allow us to hook the SEV launch START and FINISH commands into qemu_system_reset() handlder to start and finalize the SEV guest launch process. Signed-off-by: Brijesh Singh <brijesh.si...@amd.com> --- include/hw/hw.h |2 ++ sev.c | 14 ++

[Qemu-devel] [RFC PATCH v1 06/22] sev: add initial SEV support

2016-09-13 Thread Brijesh Singh
abcdef" dh_pub_qy = "0123456789abcdef0123456789abcdef" nonce = "0123456789abcdef" vcpu_count = "1" vcpu_length = "30" vcpu_mask = "00ab" Signed-off-by: Brijesh Singh <brijesh.si...@amd.com> --- Makefile.targe

[Qemu-devel] [RFC PATCH v1 12/22] sev: add SEV guest status command

2016-09-13 Thread Brijesh Singh
=kvm=147190852423972=2 Signed-off-by: Brijesh Singh <brijesh.si...@amd.com> --- include/sysemu/sev.h | 18 ++ sev.c| 34 ++ 2 files changed, 52 insertions(+) diff --git a/include/sysemu/sev.h b/include/sysemu/sev.h index a

[Qemu-devel] [RFC PATCH v1 13/22] hmp: update 'info kvm' to display SEV status

2016-09-13 Thread Brijesh Singh
Update the 'info kvm' monitor command to display the SEV status. (qemu) info kvm kvm support: enabled sev support: enabled (running) Signed-off-by: Brijesh Singh <brijesh.si...@amd.com> --- hmp.c| 14 ++ qapi-schema.json |4 +++- qmp.c|1 + 3

[Qemu-devel] [RFC PATCH v1 18/22] i386: clear C-bit in SEV guest page table walk

2016-09-13 Thread Brijesh Singh
In SEV-enabled guest the physical addresses in page table will have C-bit set, we need to clear the C-bit when walking the page table. The C-bit position should be available in cpuid Fn8000_001f[EBX] Signed-off-by: Brijesh Singh <brijesh.si...@amd.com> --- target-i386/helper.c

[Qemu-devel] [RFC PATCH v1 05/22] i386: add new option to enable SEV guest

2016-09-13 Thread Brijesh Singh
commands before starting the guest. $ qemu -sev type=encrypted config=guest_02.conf The config file will contains various parameters (e.g key , policy) required during guest launch process. Signed-off-by: Brijesh Singh <brijesh.si...@amd.com> --- qemu-options.hx |6 ++

[Qemu-devel] [RFC PATCH v1 09/22] sev: add SEV launch finish command

2016-09-13 Thread Brijesh Singh
%20API_Spec.pdf The following KVM RFC patches defines and implements this command http://marc.info/?l=kvm=147190852423972=2 http://marc.info/?l=kvm=147190856623987=2 Signed-off-by: Brijesh Singh <brijesh.si...@amd.com> --- include/sysemu/sev.h | 17 +- sev.c

[Qemu-devel] [RFC PATCH v1 20/22] fw_cfg: sev: disable dma in real mode

2016-09-13 Thread Brijesh Singh
In SEV-enabled guest dma should be performed on shared pages. Since the SeaBIOS executes in non PAE mode and does not have access to C-bit to create a shared page hence disable the dma operation when reading from fw_cfg interface. Signed-off-by: Brijesh Singh <brijesh.si...@amd.com> --- hw

[Qemu-devel] [RFC PATCH v1 19/22] exec: set debug attribute in SEV-enabled guest

2016-09-13 Thread Brijesh Singh
DEBUG DECRYPT/ENCRYPT commands to read/write into guest memory. Signed-off-by: Brijesh Singh <brijesh.si...@amd.com> --- exec.c | 11 ++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/exec.c b/exec.c index 604bd05..b1df25d 100644 --- a/exec.c +++ b/exec.c @@ -

[Qemu-devel] [RFC PATCH v1 10/22] sev: add SEV debug decrypt command

2016-09-13 Thread Brijesh Singh
patches defines and implements this command http://marc.info/?l=kvm=147190852423972=2 http://marc.info/?l=kvm=147191068524579=2 Signed-off-by: Brijesh Singh <brijesh.si...@amd.com> --- include/sysemu/sev.h | 10 ++ sev.c| 23 +++ 2 files chang

[Qemu-devel] [RFC PATCH v1 04/22] memattrs: add SEV debug attrs

2016-09-13 Thread Brijesh Singh
The patch adds sev_debug_mode attribute in MemTxAttrs. This attribute will be set when debug version of memory read/write API's are used in SEV-enabled guest. Signed-off-by: Brijesh Singh <brijesh.si...@amd.com> --- include/exec/memattrs.h |4 1 file changed, 4 insertions(+) diff

[Qemu-devel] [RFC PATCH v1 17/22] target-i386: add cpuid Fn8000_001f

2016-09-13 Thread Brijesh Singh
Fn8000_001f cpuid provides the memory encryption (aka C-bit) Signed-off-by: Brijesh Singh <brijesh.si...@amd.com> --- target-i386/cpu.c |3 +++ 1 file changed, 3 insertions(+) diff --git a/target-i386/cpu.c b/target-i386/cpu.c index 6a1afab..e039c08 100644 --- a/target-i386/cpu.c

[Qemu-devel] [RFC PATCH v1 15/22] i386: sev: register RAM read/write ops for BIOS and PC.RAM region

2016-09-13 Thread Brijesh Singh
If guest is launched into SEV-enabled mode then read/write to the BIOS and RAM memory regions should be performed using the SEV commands. Signed-off-by: Brijesh Singh <brijesh.si...@amd.com> --- hw/i386/pc.c |5 + hw/i386/pc_sysfw.c |6 ++ 2 files changed, 11 inse

[Qemu-devel] [RFC PATCH v1 00/22] x86: Secure Encrypted Virtualization (AMD)

2016-09-13 Thread Brijesh Singh
://marc.info/?l=kvm=147191038624432=2 --- TODO: - send seabios RFC's on seabios mailing list - implement SEV guest migration command support - implement SEV snapshotting command support - virtio support in SEV guest Brijesh Singh (22): exec: add guest RAM read/write ops cpu-common: add debug

[Qemu-devel] [RFC PATCH v1 07/22] sev: add SEV launch start command

2016-09-13 Thread Brijesh Singh
/55766_SEV-KM%20API_Spec.pdf The following kvm RFC patches defines and implements this command http://marc.info/?l=kvm=147190852423972=2 http://marc.info/?l=kvm=147190946024236=2 Signed-off-by: Brijesh Singh <brijesh.si...@amd.com> --- include/sysemu/sev.h |7 ++

Re: [Qemu-devel] [RFC PATCH v1 10/22] sev: add SEV debug decrypt command

2016-09-14 Thread Brijesh Singh
On 09/13/2016 09:28 PM, Michael S. Tsirkin wrote: On Tue, Sep 13, 2016 at 10:48:27AM -0400, Brijesh Singh wrote: The SEV DEBUG_DECRYPT command is used for decrypting a guest memory for the debugging purposes. Note that debugging is permitting only when guest policy allows it. When wouldn't

Re: [Qemu-devel] [RFC PATCH v1 06/22] sev: add initial SEV support

2016-09-13 Thread Brijesh Singh
Hi Eduardo, On 09/13/2016 10:58 AM, Eduardo Habkost wrote: A typical SEV config file looks like this: Are those config options documented somewhere? Various commands and parameters are documented [1] [1] http://support.amd.com/TechDocs/55766_SEV-KM%20API_Spec.pdf [sev-launch]

Re: [Qemu-devel] [RFC PATCH v1 21/22] hw: add pre and post system reset callback

2016-09-14 Thread Brijesh Singh
Hi Paolo, On 09/13/2016 05:47 PM, Paolo Bonzini wrote: On 13/09/2016 16:50, Brijesh Singh wrote: This patch adds methods to register a callback in qemu_system_reset(). - qemu_register_pre_reset() : function will be called just after entering into qemu_system_reset

Re: [Qemu-devel] [RFC PATCH v1 06/22] sev: add initial SEV support

2016-09-14 Thread Brijesh Singh
Various commands and parameters are documented [1] [1] http://support.amd.com/TechDocs/55766_SEV-KM%20API_Spec.pdf If I understand correctly, the docs describe the firmware interface. The interface provided by QEMU is not the same thing, and needs to be documented as well (even if it

Re: [Qemu-devel] [RFC PATCH v1 13/22] hmp: update 'info kvm' to display SEV status

2016-09-14 Thread Brijesh Singh
Hi Eric, Thanks for feedback. # @present: true if KVM acceleration is built into this executable # +# @sev: true if SEV is active Worth expanding what the acronym stands for. Also needs a '(since 2.8)' designator. will fix in v2. +# # Since: 0.14.0 ## -{ 'struct': 'KvmInfo', 'data':

Re: [Qemu-devel] [RFC PATCH v1 06/22] sev: add initial SEV support

2016-09-14 Thread Brijesh Singh
Hi Michael, Yes policy is described in chapter 3, page 23. I am open to separate the fields. Let me know if something like this works sev-launch-rule,flags.ks=0,policy.dbg=0,policy.ks=0,policy.nosend=0,... My question is, does all of it have to be sev specific? For example, add a generic

Re: [Qemu-devel] [RFC PATCH v1 22/22] loader: reload bios image on ROM reset in SEV-enabled guest

2016-09-14 Thread Brijesh Singh
On 09/13/2016 05:59 PM, Paolo Bonzini wrote: On 13/09/2016 16:50, Brijesh Singh wrote: In SEV-enabled mode we need to reload the BIOS image on loader reset, this will ensure that BIOS image gets encrypted and included as part of launch meausrement on guest reset. Just to check if I

Re: [Qemu-devel] [RFC PATCH v1 22/22] loader: reload bios image on ROM reset in SEV-enabled guest

2016-09-14 Thread Brijesh Singh
On 09/14/2016 03:38 PM, Paolo Bonzini wrote: On 14/09/2016 22:29, Brijesh Singh wrote: Does the guest have to check the measured data (e.g. with a hash) too, to check that it hasn't been tampered with outside the secure processor's control? Of course this would result in garbage written

Re: [Qemu-devel] [RFC PATCH v1 10/22] sev: add SEV debug decrypt command

2016-09-14 Thread Brijesh Singh
On 09/14/2016 03:44 PM, Paolo Bonzini wrote: On 14/09/2016 22:36, Michael S. Tsirkin wrote: Specifically with debug, if you have debug then clearly you can dump guest memory. This is what this feature is about. If we want a hypervisor that can not dump guest memory, let's add a flag like

Re: [Qemu-devel] [RFC PATCH v1 04/22] memattrs: add SEV debug attrs

2016-09-14 Thread Brijesh Singh
*/ #define MEMTXATTRS_UNSPECIFIED ((MemTxAttrs) { .unspecified = 1 }) +/* Access the guest memory for debug purposes */ +#define MEMTXATTRS_SEV_DEBUG ((MemTxAttrs) { .sev_debug = 1 }) #endif Just make it "debug" and MEMTXATTRS_DEBUG. Thanks, will fix in v2.

Re: [Qemu-devel] [RFC PATCH v1 15/22] i386: sev: register RAM read/write ops for BIOS and PC.RAM region

2016-09-14 Thread Brijesh Singh
Hi Paolo, On 09/13/2016 06:05 PM, Paolo Bonzini wrote: On 13/09/2016 16:49, Brijesh Singh wrote: +/* Register SEV read/write ops for the guest RAM */ +if (kvm_sev_enabled()) +memory_region_set_ram_ops(ram, kvm_sev_get_ram_ops()); If you don't actually need this one except

Re: [Qemu-devel] [RFC PATCH v1 15/22] i386: sev: register RAM read/write ops for BIOS and PC.RAM region

2016-09-14 Thread Brijesh Singh
On 09/14/2016 04:00 PM, Paolo Bonzini wrote: On 14/09/2016 22:59, Brijesh Singh wrote: I will look into hooking up the callback into ROM read/write ops. I was thinking about adding a new argument in cpu_physical_memory_write_rom_internal() void cpu_physical_memory_write_rom(AddressSpace

Re: [Qemu-devel] [RFC PATCH v1 15/22] i386: sev: register RAM read/write ops for BIOS and PC.RAM region

2016-09-14 Thread Brijesh Singh
On 09/14/2016 04:52 PM, Paolo Bonzini wrote: On 14/09/2016 23:47, Brijesh Singh wrote: On 09/14/2016 04:00 PM, Paolo Bonzini wrote: On 14/09/2016 22:59, Brijesh Singh wrote: I will look into hooking up the callback into ROM read/write ops. I was thinking about adding a new argument

Re: [Qemu-devel] [RFC PATCH v1 20/22] fw_cfg: sev: disable dma in real mode

2016-09-13 Thread Brijesh Singh
Hi Michael, On 09/13/2016 01:39 PM, Michael S. Tsirkin wrote: On Tue, Sep 13, 2016 at 10:50:06AM -0400, Brijesh Singh wrote: In SEV-enabled guest dma should be performed on shared pages. Since the SeaBIOS executes in non PAE mode and does not have access to C-bit to create a shared page hence

Re: [Qemu-devel] [RFC PATCH v1 15/22] i386: sev: register RAM read/write ops for BIOS and PC.RAM region

2016-09-15 Thread Brijesh Singh
Hi Paolo, typedef struct { @@ -3568,6 +3578,7 @@ int cpu_memory_rw_debug(CPUState *cpu, target_ulong addr, int l; hwaddr phys_addr; target_ulong page; +int mode = is_write ? WRITE_DATA : READ_DATA; while (len > 0) { int asidx; @@ -3583,14 +3594,9 @@ int

Re: [Qemu-devel] [RFC PATCH v1 15/22] i386: sev: register RAM read/write ops for BIOS and PC.RAM region

2016-09-14 Thread Brijesh Singh
So looking at code, i have impression that write will go through the cpu_physical_memory_write_rom but the read will still go through address_space_rw which will eventually invoke address_space_read. Yes, you'd have to modify it a bit. Something like Sure this will works, thanks for the

Re: [Qemu-devel] [RFC PATCH v1 16/22] i386: pc: load OS images at fixed location in SEV-enabled guest

2016-09-21 Thread Brijesh Singh
Hi Paolo, On 09/21/2016 10:58 AM, Paolo Bonzini wrote: On 21/09/2016 17:55, Brijesh Singh wrote: I'm working on v2 and getting ready for another review but not sure how to address this feedback. For now, I can drop this patch from the series and get other patches reviewed. But I would like

Re: [Qemu-devel] [RFC PATCH v1 16/22] i386: pc: load OS images at fixed location in SEV-enabled guest

2016-09-21 Thread Brijesh Singh
Hi Michael and Paolo, On 09/13/2016 01:37 PM, Michael S. Tsirkin wrote: On Tue, Sep 13, 2016 at 10:49:29AM -0400, Brijesh Singh wrote: Typically linux kernel, initrd and cmdline are build and loaded into guest memory through linux optionrom. The linux optionrom is probed and executed

Re: [Qemu-devel] [RFC PATCH v1 17/22] target-i386: add cpuid Fn8000_001f

2016-09-21 Thread Brijesh Singh
Hi Paolo, On 09/13/2016 06:07 PM, Paolo Bonzini wrote: On 13/09/2016 16:49, Brijesh Singh wrote: Fn8000_001f cpuid provides the memory encryption (aka C-bit) Signed-off-by: Brijesh Singh <brijesh.si...@amd.com> --- target-i386/cpu.c |3 +++ 1 file changed, 3 insertions(+) diff

Re: [Qemu-devel] [RFC PATCH v1 20/22] fw_cfg: sev: disable dma in real mode

2016-09-21 Thread Brijesh Singh
Hi Michael, Again it isn't clear how much value does attestation have, we are assuming arbitrary restrictions on the attacker such as inability to trigger exits at random times, why not assume it can't attack guest during boot? IOW it seems reasonable to just ignore the need for attestation

Re: [Qemu-devel] [RFC PATCH v2 06/16] sev: add Secure Encrypted Virtulization (SEV) support

2016-09-22 Thread Brijesh Singh
Hi, On 09/22/2016 10:12 AM, Paolo Bonzini wrote: to use encrypted guest launch # $QEMU \ -object sev-receive-info,id=launch0 \ -object sev-send-info,id=send0 \ -object sev-guest-info,id=sev0,launch=launch0,send=send0 \ . References to other objects should be

[Qemu-devel] [RFC PATCH v2 14/16] i386: set memory encryption ops for PC.BIOS and PC.RAM regions

2016-09-22 Thread Brijesh Singh
nes to decrypt/encrypt the contents. A sequence looks like: cpu_phyiscal_memory_rw_debug cpu_phyiscal_memory_rw_debug_internal memory_encryption->write Signed-off-by: Brijesh Singh <brijesh.si...@amd.com> --- hw/i386/pc.c |7 +++ hw/i386/pc_sysfw.c |4 2 files

[Qemu-devel] [RFC PATCH v2 02/16] exec: add guest RAM read and write ops

2016-09-22 Thread Brijesh Singh
; memory_region_init_ram(mem, NULL, "memory", size, NULL); memory_region_set_ram_ops(mem, ops); Signed-off-by: Brijesh Singh <brijesh.si...@amd.com> --- exec.c| 57 - include/exec/cpu-common.h |2 +- include/exec/mem

[Qemu-devel] [RFC PATCH v2 07/16] hmp: display memory encryption support in 'info kvm'

2016-09-22 Thread Brijesh Singh
update 'info kvm' to display the memory encryption support. (qemu) info kvm kvm support: enabled memory encryption: disabled Signed-off-by: Brijesh Singh <brijesh.si...@amd.com> --- hmp.c|2 ++ qapi-schema.json |7 +-- qmp.c|1 + 3 files chan

[Qemu-devel] [RFC PATCH v2 16/16] i386: clear C-bit in SEV guest page table walk

2016-09-22 Thread Brijesh Singh
In SEV-enabled guest the physical addresses in page table will have C-bit set, we need to clear the C-bit when walking the page table. The C-bit position should be available in cpuid Fn8000_001f[EBX] Signed-off-by: Brijesh Singh <brijesh.si...@amd.com> --- target-i386/helper.c

[Qemu-devel] [RFC PATCH v2 11/16] sev: add LAUNCH_FINISH command

2016-09-22 Thread Brijesh Singh
the measurement via 'measurement' property defined in 'sev-launch-info' object. Signed-off-by: Brijesh Singh <brijesh.si...@amd.com> --- sev.c | 17 +++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/sev.c b/sev.c index dcd7c48..21c491c 100644 --- a/sev.c +++ b

[Qemu-devel] [RFC PATCH v2 03/16] exec: add debug version of physical memory read and write apis

2016-09-22 Thread Brijesh Singh
APIs then in future we can define some kind of global debug policy to control debug behavior. Signed-off-by: Brijesh Singh <brijesh.si...@amd.com> --- exec.c| 32 include/exec/cpu-common.h | 15 +++ 2 files changed, 47 inse

[Qemu-devel] [RFC PATCH v2 15/16] target-i386: add cpuid Fn8000_001f

2016-09-22 Thread Brijesh Singh
Fn8000_001f cpuid provides the memory encryption (aka C-bit) Signed-off-by: Brijesh Singh <brijesh.si...@amd.com> --- target-i386/cpu.c | 10 ++ 1 file changed, 10 insertions(+) diff --git a/target-i386/cpu.c b/target-i386/cpu.c index 6a1afab..43e698b 100644 --- a/target-i386

[Qemu-devel] [RFC PATCH v2 08/16] core: loader: create memory encryption context before copying data

2016-09-22 Thread Brijesh Singh
will go through the encryption routines which will encrypt the data as it copies into guest memory. Similarly after we are done with copying destory the encryption context. Signed-off-by: Brijesh Singh <brijesh.si...@amd.com> --- hw/core/loader.c | 13 + 1 file changed, 13 inse

[Qemu-devel] [RFC PATCH v2 10/16] sev: add LAUNCH_UPDATE command

2016-09-22 Thread Brijesh Singh
The command is used to encrypt a guest memory region using the VM Encryption Key (VEK) created by LAUNCH_START command. The firmware will also update the measurement with the contents of the memory region. This measurement can be retrieved by calling LAUNCH_FINISH command. Signed-off-by: Brijesh

[Qemu-devel] [RFC PATCH v2 09/16] sev: add LAUNCH_START command

2016-09-22 Thread Brijesh Singh
during launch start process will be used to encrypt the guest memory. Signed-off-by: Brijesh Singh <brijesh.si...@amd.com> --- sev.c | 30 +- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/sev.c b/sev.c index 226ad76..ead7c5a 100644 --- a/sev.c

[Qemu-devel] [RFC PATCH v2 06/16] sev: add Secure Encrypted Virtulization (SEV) support

2016-09-22 Thread Brijesh Singh
during guest launch. to use encrypted guest launch # $QEMU \ -object sev-receive-info,id=launch0 \ -object sev-send-info,id=send0 \ -object sev-guest-info,id=sev0,launch=launch0,send=send0 \ . Signed-off-by: Brijesh Singh <brijesh.si...@amd.com> --- Makefile.

[Qemu-devel] [RFC PATCH v2 04/16] monitor: use debug version of memory access apis

2016-09-22 Thread Brijesh Singh
updates hmp monitor to use debug version of memory access apis when accessing the guest memory. Signed-off-by: Brijesh Singh <brijesh.si...@amd.com> --- cpus.c|2 +- disas.c |2 +- monitor.c |2 +- target-i386/helper.c

[Qemu-devel] [RFC PATCH v2 12/16] sev: add DEBUG_DECRYPT command

2016-09-22 Thread Brijesh Singh
cpu_physical_memory_rw_debug_internal sev_debug_decrypt Signed-off-by: Brijesh Singh <brijesh.si...@amd.com> --- sev.c | 22 -- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/sev.c b/sev.c index 21c491c..c0f6ae4 100644 --- a/sev.c +++ b/sev.c @@ -

[Qemu-devel] [RFC PATCH v2 13/16] sev: add DEBUG_ENCRYPT command

2016-09-22 Thread Brijesh Singh
: cpu_memory_rw_debug cpu_physical_memory_rw_debug_internal sev_debug_encrypt Signed-off-by: Brijesh Singh <brijesh.si...@amd.com> --- sev.c | 22 +- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/sev.c b/sev.c index c0f6ae4..8a07c0d 100644 --- a/sev.c +++ b

[Qemu-devel] [RFC PATCH v2 05/16] core: add new security-policy object

2016-09-22 Thread Brijesh Singh
-guest,launch-id=unencrypted,id=sev-guest \ -object security-policy,id=memory-encryption=sev-guest,id=mypolicy \ -machine ...,security-policy=mypolicy Signed-off-by: Brijesh Singh <brijesh.si...@amd.com> --- exec.c |7 ++ hw/core/Makefil

[Qemu-devel] [RFC PATCH v2 00/16] x86: Secure Encrypted Virtualization (AMD)

2016-09-22 Thread Brijesh Singh
, RECEIVE_UPDATE and RECEIVE_FINISH commands - implement SEND_START, SEND_UPDATE and SEND_FINISH commands - implement SEV guest migration and snapshotting support - virtio support in SEV guest Brijesh Singh (16): memattrs: add debug attrs exec: add guest RAM read and write ops exec: add

[Qemu-devel] [RFC PATCH v2 01/16] memattrs: add debug attrs

2016-09-22 Thread Brijesh Singh
Add a new memory debug attribute, this attribute should be set when memory read or write access is performed for debugging purposes. Signed-off-by: Brijesh Singh <brijesh.si...@amd.com> --- include/exec/memattrs.h |4 1 file changed, 4 insertions(+) diff --git a/include/exec/mema

Re: [Qemu-devel] [RFC PATCH v2 04/16] monitor: use debug version of memory access apis

2016-09-22 Thread Brijesh Singh
Hi, On 09/22/2016 02:24 PM, Michael S. Tsirkin wrote: On Thu, Sep 22, 2016 at 10:52:28AM -0400, Brijesh Singh wrote: updates hmp monitor to use debug version of memory access apis when accessing the guest memory. Signed-off-by: Brijesh Singh <brijesh.si...@amd.com> Does this cover t

[Qemu-devel] [RFC PATCH v3 01/18] memattrs: add debug attrs

2016-11-01 Thread Brijesh Singh
Add a new memory debug attribute, this attribute should be set when memory read or write access is performed for debugging purposes. Signed-off-by: Brijesh Singh <brijesh.si...@amd.com> --- include/exec/memattrs.h |4 1 file changed, 4 insertions(+) diff --git a/include/exec/mema

[Qemu-devel] [RFC PATCH v3 09/18] core: loader: create memory encryption context before copying data

2016-11-01 Thread Brijesh Singh
will go through the encryption routines which will encrypt the data as it copies into guest memory. Similarly after we are done with copying destory the encryption context. Signed-off-by: Brijesh Singh <brijesh.si...@amd.com> --- hw/core/loader.c | 22 ++ 1 file chang

[Qemu-devel] [RFC PATCH v3 03/18] exec: add debug version of physical memory read and write apis

2016-11-01 Thread Brijesh Singh
APIs then in future we can define some kind of global debug policy to control debug behavior. Signed-off-by: Brijesh Singh <brijesh.si...@amd.com> Reviewed-by: Paolo Bonzini <pbonz...@redhat.com> --- exec.c| 32 include/exec/cpu-com

[Qemu-devel] [RFC PATCH v3 04/18] monitor: use debug version of memory access apis

2016-11-01 Thread Brijesh Singh
updates hmp monitor to use debug version of memory access apis when accessing the guest memory. Signed-off-by: Brijesh Singh <brijesh.si...@amd.com> --- cpus.c|2 +- disas.c |2 +- monitor.c |2 +- target-i386/helper.c

[Qemu-devel] [RFC PATCH v3 10/18] sev: add LAUNCH_START command

2016-11-01 Thread Brijesh Singh
during launch start process will be used to encrypt the guest memory. Signed-off-by: Brijesh Singh <brijesh.si...@amd.com> --- sev.c | 81 + 1 file changed, 81 insertions(+) diff --git a/sev.c b/sev.c index 487dba6..2fbab2f

[Qemu-devel] [RFC PATCH v3 06/18] kvm: add memory encryption APIs

2016-11-01 Thread Brijesh Singh
Add APIs to provide guest memory encryption support. Signed-off-by: Brijesh Singh <brijesh.si...@amd.com> --- include/sysemu/kvm.h |8 ++ kvm-all.c| 64 ++ 2 files changed, 72 insertions(+) diff --git a/include/sysemu/k

[Qemu-devel] [RFC PATCH v3 12/18] sev: add LAUNCH_FINISH command

2016-11-01 Thread Brijesh Singh
The command is used to finalize the SEV guest launch process. The command returns a measurement value of the data encrypted through the LAUNCH_UPDATE command. This measurement can be handed to the guest owner to verify that the guest was launched into SEV-enabled mode. Signed-off-by: Brijesh

[Qemu-devel] [RFC PATCH v3 18/18] migration: disable save/restore and migration on SEV guest

2016-11-01 Thread Brijesh Singh
Snapshot, Restore and Migration is not implemented in first phase. Return error when user tries to perform any of these operations. Signed-off-by: Brijesh Singh <brijesh.si...@amd.com> --- migration/migration.c |7 +++ migration/savevm.c| 11 +++ 2 files chang

[Qemu-devel] [RFC PATCH v3 11/18] sev: add LAUNCH_UPDATE command

2016-11-01 Thread Brijesh Singh
The command is used to encrypt a guest memory region using the VM Encryption Key (VEK) created by LAUNCH_START command. The firmware will also update the measurement with the contents of the memory region. This measurement can be retrieved by calling LAUNCH_FINISH command. Signed-off-by: Brijesh

[Qemu-devel] [RFC PATCH v3 16/18] target-i386: add cpuid Fn8000_001f

2016-11-01 Thread Brijesh Singh
Fn8000_001f cpuid provides the memory encryption (aka C-bit) location in a page table for the SEV-enabled guest. Signed-off-by: Brijesh Singh <brijesh.si...@amd.com> --- target-i386/cpu.c |6 ++ 1 file changed, 6 insertions(+) diff --git a/target-i386/cpu.c b/target-i386/cpu.c

[Qemu-devel] [RFC PATCH v3 14/18] sev: add DEBUG_ENCRYPT command

2016-11-01 Thread Brijesh Singh
sev_debug_encrypt Signed-off-by: Brijesh Singh <brijesh.si...@amd.com> --- sev.c | 29 ++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/sev.c b/sev.c index f690a86..1a579ca 100644 --- a/sev.c +++ b/sev.c @@ -351,18 +351,41 @@ sev_debug_decrypt(SEVState *s, u

[Qemu-devel] [RFC PATCH v3 15/18] i386: register memory encryption ops

2016-11-01 Thread Brijesh Singh
ion routines to decrypt/encrypt the guest RAM regions. A sequence looks like: cpu_phyiscal_memory_rw_debug cpu_phyiscal_memory_rw_debug_internal memory_encryption->write Signed-off-by: Brijesh Singh <brijesh.si...@amd.com> --- hw/i386/pc.c |7 +++ hw/i386/pc_sysfw.c |

[Qemu-devel] [RFC PATCH v3 17/18] i386: clear C-bit in SEV guest page table walk

2016-11-01 Thread Brijesh Singh
In SEV-enabled guest the physical addresses in page table will have C-bit set, we need to clear the C-bit when walking the page table. The C-bit position should be available in cpuid Fn8000_001f[EBX] Signed-off-by: Brijesh Singh <brijesh.si...@amd.com> --- target-i386/helper.c

[Qemu-devel] [RFC PATCH v3 02/18] exec: add guest RAM read and write ops

2016-11-01 Thread Brijesh Singh
; memory_region_init_ram(mem, NULL, "memory", size, NULL); memory_region_set_ram_debug_ops(mem, ops); Signed-off-by: Brijesh Singh <brijesh.si...@amd.com> --- exec.c| 55 - include/exec/memory.h | 25 +++

[Qemu-devel] [RFC PATCH v3 00/18] x86: Secure Encrypted Virtualization (AMD)

2016-11-01 Thread Brijesh Singh
. - Integrate SEV SEND and RECEIVE command in live migration. Brijesh Singh (18): memattrs: add debug attrs exec: add guest RAM read and write ops exec: add debug version of physical memory read and write apis monitor: use debug version of memory access apis core: add new

[Qemu-devel] [RFC PATCH v3 05/18] core: add new security-policy object

2016-11-01 Thread Brijesh Singh
=mypolicy \ -machine ...,security-policy=mypolicy Signed-off-by: Brijesh Singh <brijesh.si...@amd.com> --- exec.c |7 ++ hw/core/Makefile.objs|1 hw/core/machine.c| 22 + hw/core/security-policy.c

[Qemu-devel] [RFC PATCH v3 07/18] sev: add Secure Encrypted Virtulization (SEV) support

2016-11-01 Thread Brijesh Singh
from unencrypted boot images # $QEMU \ -object sev-launch-info,id=launch0,nonce=abcd,pub-dh-qx=1234 \ -object sev-guest,id,sev0 \ -object security-policy,id=secure0,memory-encryption=sev0 \ -machine ,security-policy=secure0 Signed-off-by: Brijesh Singh <brijesh.si...@amd.

[Qemu-devel] [RFC PATCH v3 08/18] hmp: display memory encryption support in 'info kvm'

2016-11-01 Thread Brijesh Singh
update 'info kvm' to display the memory encryption support. (qemu) info kvm kvm support: enabled memory encryption: disabled Signed-off-by: Brijesh Singh <brijesh.si...@amd.com> --- hmp.c|2 ++ qapi-schema.json |5 - qmp.c|1 + 3 files chan

[Qemu-devel] [RFC PATCH v3 13/18] sev: add DEBUG_DECRYPT command

2016-11-01 Thread Brijesh Singh
Signed-off-by: Brijesh Singh <brijesh.si...@amd.com> --- sev.c | 28 +--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/sev.c b/sev.c index ff9266a..f690a86 100644 --- a/sev.c +++ b/sev.c @@ -329,6 +329,28 @@ err: } static int +sev_debug_decrypt(SE

Re: [Qemu-devel] [RFC PATCH v4 02/20] memattrs: add debug attribute

2017-03-23 Thread Brijesh Singh
Hi Stefan, On 03/23/2017 06:29 AM, Stefan Hajnoczi wrote: On Wed, Mar 08, 2017 at 03:51:28PM -0500, Brijesh Singh wrote: Add a new debug attribute, the attribute should be set when guest memory accesses are performed for debug purposes. The attribute will be used in SEV guest, where we need

Re: [Qemu-devel] [RFC PATCH v4 02/20] memattrs: add debug attribute

2017-03-24 Thread Brijesh Singh
On 03/24/2017 10:36 AM, Stefan Hajnoczi wrote: I suggest something like this instead: /* Debug memory access for AMD SEV */ That way it's clear this "debug" flag has a very specific meaning in the context of memory encryption. Sure, will update comments. -Brijesh

Re: [Qemu-devel] [RFC PATCH v4 06/20] core: add new security-policy object

2017-03-27 Thread Brijesh Singh
On 03/27/2017 07:04 AM, Stefan Hajnoczi wrote: On Fri, Mar 24, 2017 at 02:42:47PM -0500, Brijesh Singh wrote: On 03/24/2017 10:40 AM, Stefan Hajnoczi wrote: Having one security policy doesn't make sense to me. As mentioned, there are many different areas of QEMU that have security

Re: [Qemu-devel] [RFC PATCH v4 06/20] core: add new security-policy object

2017-03-24 Thread Brijesh Singh
On 03/24/2017 10:40 AM, Stefan Hajnoczi wrote: Having one security policy doesn't make sense to me. As mentioned, there are many different areas of QEMU that have security relevant configuration. They are all unrelated so combining them into one object with vague parameter names like

Re: [Qemu-devel] [RFC PATCH v4 06/20] core: add new security-policy object

2017-03-23 Thread Brijesh Singh
Hi Stefan, On 03/23/2017 06:35 AM, Stefan Hajnoczi wrote: On Wed, Mar 08, 2017 at 03:52:09PM -0500, Brijesh Singh wrote: The object can be used to define global security policy for the guest. "security-policy" is very vague. Lots of parts of QEMU have security related options

[Qemu-devel] [RFC PATCH v4 06/20] core: add new security-policy object

2017-03-08 Thread Brijesh Singh
=mypolicy \ -machine ...,security-policy=mypolicy The memory-encryption property will be used for enabling AMD's SEV feature. Signed-off-by: Brijesh Singh <brijesh.si...@amd.com> --- exec.c |7 ++ hw/core/Makefile.objs|1 hw/core/mac

[Qemu-devel] [RFC PATCH v4 04/20] exec: add debug version of physical memory read and write api

2017-03-08 Thread Brijesh Singh
APIs then in future we can define some kind of global debug policy to control debug behavior. Signed-off-by: Brijesh Singh <brijesh.si...@amd.com> Reviewed-by: Paolo Bonzini <pbonz...@redhat.com> --- exec.c| 32 include/exec/cpu-com

[Qemu-devel] [RFC PATCH v4 10/20] vl: add memory encryption support

2017-03-08 Thread Brijesh Singh
If memory encryption is enabled then create memory encryption launch context to ensure that bootstrap data (bios images) get encrypted. Also release the encryption context after machine is succesfully created. Signed-off-by: Brijesh Singh <brijesh.si...@amd.com> --- vl.c

[Qemu-devel] [RFC PATCH v4 13/20] sev: add LAUNCH_UPDATE_DATA command

2017-03-08 Thread Brijesh Singh
The command is used to encrypt a guest memory region using the VM Encryption Key (VEK) created by LAUNCH_START command. The firmware will also update the measurement with the contents of the memory region for attestation. Signed-off-by: Brijesh Singh <brijesh.si...@amd.com> --- include/

[Qemu-devel] [RFC PATCH v4 01/20] kvm: update kvm.h header file

2017-03-08 Thread Brijesh Singh
Updates kmv.h to include memory encryption ioctls and SEV command structure introduced in KVM RFC [1] [1] http://marc.info/?l=linux-mm=148846752931115=2 Signed-off-by: Brijesh Singh <brijesh.si...@amd.com> --- linux-headers/linux/kvm.h | 100 ++

[Qemu-devel] [RFC PATCH v4 16/20] sev: add DEBUG_ENCRYPT command

2017-03-08 Thread Brijesh Singh
sev_debug_encrypt Signed-off-by: Brijesh Singh <brijesh.si...@amd.com> --- sev.c | 39 --- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/sev.c b/sev.c index f8d822d..52b75e3 100644 --- a/sev.c +++ b/sev.c @@ -350,16 +350,49 @@ err: } stat

[Qemu-devel] [RFC PATCH v4 09/20] hmp: display memory encryption support in 'info kvm'

2017-03-08 Thread Brijesh Singh
update 'info kvm' to display the memory encryption support. (qemu) info kvm kvm support: enabled memory encryption: disabled Signed-off-by: Brijesh Singh <brijesh.si...@amd.com> --- hmp.c|2 ++ qapi-schema.json |5 - qmp.c|1 + 3 files chan

[Qemu-devel] [RFC PATCH v4 18/20] target/i386: add cpuid Fn8000_001f

2017-03-08 Thread Brijesh Singh
Fn8000_001f cpuid provides the memory encryption (aka C-bit) location in a page table for the SEV-enabled guest. Signed-off-by: Brijesh Singh <brijesh.si...@amd.com> --- target/i386/cpu.c |6 ++ 1 file changed, 6 insertions(+) diff --git a/target/i386/cpu.c b/target/i386/cpu.c

Re: [Qemu-devel] [RFC PATCH v4 00/20] x86: Secure Encrypted Virtualization (AMD)

2017-03-08 Thread Brijesh Singh
On 03/08/2017 03:27 PM, Eduardo Habkost wrote: On Wed, Mar 08, 2017 at 03:51:07PM -0500, Brijesh Singh wrote: This RFC series provides support for AMD's new Secure Encrypted Virtualization (SEV) feature. This RFC is based KVM RFC [1]. SEV is an extension to the AMD-V architecture which

Re: [Qemu-devel] [RFC PATCH v4 20/20] migration: disable save/restore and migration when SEV is active

2017-03-08 Thread Brijesh Singh
On 03/08/2017 03:32 PM, Eduardo Habkost wrote: On Wed, Mar 08, 2017 at 03:54:43PM -0500, Brijesh Singh wrote: Snapshot, Restore and Migration is not implemented yet. Return error when user tries to perform any of these operations. Signed-off-by: Brijesh Singh <brijesh.si...@amd.

[Qemu-devel] [RFC PATCH v4 08/20] sev: add Secure Encrypted Virtulization (SEV) support

2017-03-08 Thread Brijesh Singh
unencrypted boot images # $QEMU \ -object sev-launch-info,id=launch0 \ -object sev-guest,id=sev0 \ -object security-policy,id=secure0,memory-encryption=sev0 \ -machine ,security-policy=secure0 Signed-off-by: Brijesh Singh <brijesh.si...@amd.com> --- Makefile.

[Qemu-devel] [RFC PATCH v4 11/20] sev: add LAUNCH_START command

2017-03-08 Thread Brijesh Singh
the boot images (such as BIOS). Signed-off-by: Brijesh Singh <brijesh.si...@amd.com> --- include/sysemu/sev.h |1 + kvm-all.c|1 + sev.c| 55 ++ 3 files changed, 57 insertions(+) diff --git a/include/sysemu/s

[Qemu-devel] [RFC PATCH v4 05/20] monitor/i386: use debug apis when accessing guest memory

2017-03-08 Thread Brijesh Singh
updates hmp monitor to use debug version of memory access apis when reading the guest memory. Signed-off-by: Brijesh Singh <brijesh.si...@amd.com> --- cpus.c|2 - disas.c |2 - monitor.c |2 - target/i386/helper.c | 16 +++ targe

[Qemu-devel] [RFC PATCH v4 07/20] kvm: add memory encryption api support

2017-03-08 Thread Brijesh Singh
Add high level API's to provide guest memory encryption support. Signed-off-by: Brijesh Singh <brijesh.si...@amd.com> --- include/sysemu/kvm.h |7 +++ kvm-all.c| 52 ++ kvm-stub.c

[Qemu-devel] [RFC PATCH v4 19/20] target/i386: clear memory encryption bit when walking SEV guest page table

2017-03-08 Thread Brijesh Singh
In SEV-enabled guest the pte entry will have C-bit set, we need to clear the C-bit when walking the page table. The C-bit position should be available in cpuid Fn8000_001f[EBX] Signed-off-by: Brijesh Singh <brijesh.si...@amd.com> --- target/i386/helper.c | 39 ++-

  1   2   3   4   5   >