All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eduardo Habkost <ehabkost@redhat.com>
To: Brijesh Singh <brijesh.singh@amd.com>
Cc: crosthwaite.peter@gmail.com, armbru@redhat.com, mst@redhat.com,
	p.fedin@samsung.com, qemu-devel@nongnu.org,
	lcapitulino@redhat.com, pbonzini@redhat.com, rth@twiddle.net,
	"Daniel P. Berrange" <berrange@redhat.com>
Subject: Re: [Qemu-devel] [RFC PATCH v1 06/22] sev: add initial SEV support
Date: Tue, 13 Sep 2016 19:00:44 -0300	[thread overview]
Message-ID: <20160913220044.GY24695@thinpad.lan.raisama.net> (raw)
In-Reply-To: <6411b07f-4edd-390c-acca-5342ab1187ba@amd.com>

(CCing Daniel Berrange in case he has feedback on the
nonce/dh_pub_qx/dh_pub_qy loading/parsing at the end of this
message)

On Tue, Sep 13, 2016 at 02:54:40PM -0500, Brijesh Singh wrote:
> 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

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 contains pointers
to sections or tables in the firmware interface docs).

Some of the questions I have about the fields are:
* Do we really need the user to provide all the options below?
  * Can't QEMU or KVM calculate vcpu_count/vcpu_length/vcpu_mask,
    for example?
* Is bit 0 (KS) the only bit that can be set on flags? If so, why
  not a boolean "ks" option?
* Is "policy" the guest policy structure described at page 23? If
  so, why exposing the raw value instead of separate fields for
  each bit/field in the structure? (and only for the ones that
  are supposed to be set by the user)
* If vcpu_mask is a bitmap for each VCPU, should we represent it
  as a list of VCPU indexes?

A good way to model this data and document it more properly is
through a QAPI schema. grep for "opts_visitor_new()" in the code
for examples where QEMU options are parsed according to a QAPI
schema. The downside is that using a QAPI visitor is (AFAIK) not
possible if using -object like I suggest below.

> 
> > > [sev-launch]
> > > 	flags = "00000000"
> > > 	policy	= "000000"
> > > 	dh_pub_qx = "0123456789abcdef0123456789abcdef"
> > > 	dh_pub_qy = "0123456789abcdef0123456789abcdef"
> > > 	nonce = "0123456789abcdef"
> > > 	vcpu_count = "1"
> > > 	vcpu_length = "30"
> > > 	vcpu_mask = "00ab"
> > 
> > Why a separate config file loading mechanism? If the user really
> > needs to load the SEV configuration data from a separate file,
> > you can just use regular config sections and use -readconfig.
> > 
> I will look into -readconfig and see if we can use that.
> 
> > Now, about the format of the new config sections ("sev" and
> > "sev-launch"): I am not sure adding new command-line options and
> > config sections is necessary. Is it possible to implement it as a
> > combination of:
> > * new options to existing command-line options and/or
> > * new options to existing objects and/or
> > * new options to existing devices and/or
> > * new types for -object? (see how crypto secrets and net filters
> >   are configured, for an example)
> > 
> > 
> 
> All these config parameters should be provided by the guest owner before
> launching or migrating a guest. I believe we need to make changes in
> libvirt, virsh and other upper layer software stack to communicate with
> guest owner to get these input parameters. For development purposes I choose
> a simple config file to get these parameters. I am not sure if we will able
> to "add new option to a existing objects/device" but we can look into
> creating a "new type for -object" or we can simply accept a fd from upper
> layer and read the fd to get these parameters.

I was thinking of something like:

  -object sev-launch-rule,flags=0,policy=0,dh_pub_qx=XXXXX,dh_pub_qy=YYYYY,nonce=ZZZZ,vcpu_count=1,vcpu_length=30,vcpu_mask=00ab \
  -machine pc,accel=kvm,sev=on  # see note below[1]

With this, you won't need separate code for command-line, config
files, and QMP commands. They will all be able to use the same
mechanisms.

...but this conflicts with the idea of using QAPI. So I am not
sure which way to go. (But either way we go, we need a clearer
and better documented set of parameters).

[1] I would go even further and separate the accel object options
    from the machine options, but this would require reworking
    the accelerator configuration inside QEMU. e.g.:

  -object kvm-accel,sev=on,id=kvm0
  -machine pc,accel=kvm0

[...]
> > > +static unsigned int read_config_u32(QemuOpts *opts, const char *key)
> > > +{
> > > +    unsigned int val;
> > > +
> > > +    val = qemu_opt_get_number_del(opts, key, -1);
> > > +    DPRINTF(" %s = %08x\n", key, val);
> > > +
> > > +    return val;
> > > +}
> > > +
> > > +static int read_config_u8(QemuOpts *opts, const char *key, uint8_t *val)
> > 
> > Function name confused me (it seemed to read only one u8 value).
> > 
> I will fix the name, the function converts string into a hex bytes array.
> e.g "12aabbccdd" is converted to val[] = {0x12,0xaa,0xbb,0xcc, 0xdd}.
> 
> > > +{
> > > +    int i;
> > > +    const char *v;
> > > +
> > > +    v = qemu_opt_get(opts, key);
> > > +    if (!v) {
> > > +        return 0;
> > > +    }
> > > +
> > > +    DPRINTF(" %s = ", key);
> > > +    i = 0;
> > > +    while (*v) {
> > > +        sscanf(v, "%2hhx", &val[i]);
> > 
> > Function doesn't check for array length.
> Thanks, i will fix this.
> > 
> > > +        DPRINTF("%02hhx", val[i]);
> > > +        v += 2;
> > > +        i++;
> > > +    }
> > > +    DPRINTF("\n");
> > > +
> > > +    return i;
> > 
> > Do we really need to write our own parser? I wonder if we can
> > reuse crypto/secret.c for loading the keys.
> > 
> I just looked at crypto/secret.c for loading the keys but not sure if will
> able to reuse the secret_load routines, this is mainly because the SEV
> inputs parameters are different compare to what we have in crypto/secrets.c.
> I will still look more closely and see if we can find some common code.

There are other parameters, sure, but maybe it would be
appropriate to just load nonce/dh_pub_qx/dh_pub_qy as
TTYPE_QCRYPTO_SECRET object(s) (-object secret,...)? I am not
sure because I don't understand the crypto part fully.

Daniel, what do you think?

-- 
Eduardo

  parent reply	other threads:[~2016-09-13 22:00 UTC|newest]

Thread overview: 125+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-13 14:46 [Qemu-devel] [RFC PATCH v1 00/22] x86: Secure Encrypted Virtualization (AMD) Brijesh Singh
2016-09-13 14:46 ` [Qemu-devel] [RFC PATCH v1 01/22] exec: add guest RAM read/write ops Brijesh Singh
2016-09-13 14:47 ` [Qemu-devel] [RFC PATCH v1 02/22] cpu-common: add debug version of physical memory read/write Brijesh Singh
2016-09-13 14:47 ` [Qemu-devel] [RFC PATCH v1 03/22] monitor: use debug version of physical memory read api Brijesh Singh
2016-09-13 14:47 ` [Qemu-devel] [RFC PATCH v1 04/22] memattrs: add SEV debug attrs Brijesh Singh
2016-09-13 23:00   ` Paolo Bonzini
2016-09-14 20:30     ` Brijesh Singh
2016-09-13 14:47 ` [Qemu-devel] [RFC PATCH v1 05/22] i386: add new option to enable SEV guest Brijesh Singh
2016-09-13 22:41   ` Paolo Bonzini
2016-09-14  8:41     ` Daniel P. Berrange
2016-09-14  9:11       ` Paolo Bonzini
2016-09-13 14:47 ` [Qemu-devel] [RFC PATCH v1 06/22] sev: add initial SEV support Brijesh Singh
2016-09-13 15:58   ` Eduardo Habkost
2016-09-13 19:54     ` Brijesh Singh
2016-09-13 20:10       ` Michael S. Tsirkin
2016-09-13 22:00       ` Eduardo Habkost [this message]
2016-09-14  8:30         ` Daniel P. Berrange
2016-09-14 11:54           ` Eduardo Habkost
2016-09-14 11:58             ` Daniel P. Berrange
2016-09-14 16:10         ` Brijesh Singh
2016-09-14 16:13           ` Daniel P. Berrange
2016-09-14 16:20           ` Michael S. Tsirkin
2016-09-14 18:46             ` Brijesh Singh
2016-09-14 20:23               ` Michael S. Tsirkin
2016-09-14  8:37   ` Daniel P. Berrange
2016-09-13 14:47 ` [Qemu-devel] [RFC PATCH v1 07/22] sev: add SEV launch start command Brijesh Singh
2016-09-13 14:48 ` [Qemu-devel] [RFC PATCH v1 08/22] sev: add SEV launch update command Brijesh Singh
2016-09-13 14:48 ` [Qemu-devel] [RFC PATCH v1 09/22] sev: add SEV launch finish command Brijesh Singh
2016-09-13 22:15   ` Eduardo Habkost
2016-09-13 14:48 ` [Qemu-devel] [RFC PATCH v1 10/22] sev: add SEV debug decrypt command Brijesh Singh
2016-09-14  2:28   ` Michael S. Tsirkin
2016-09-14  8:57     ` Paolo Bonzini
2016-09-14 13:05       ` Michael S. Tsirkin
2016-09-14 13:07         ` Paolo Bonzini
2016-09-14 13:23           ` Daniel P. Berrange
2016-09-14 13:32             ` Michael S. Tsirkin
2016-09-14 13:37               ` Daniel P. Berrange
2016-09-14 13:50                 ` Michael S. Tsirkin
2016-09-14 14:08                   ` Eduardo Habkost
2016-09-14 14:14                     ` Paolo Bonzini
2016-09-14 14:38                       ` Michael S. Tsirkin
2016-09-14 15:17                     ` Michael S. Tsirkin
2016-09-14 14:15                   ` Daniel P. Berrange
2016-09-14 14:48                     ` Michael S. Tsirkin
2016-09-14 15:06                       ` Daniel P. Berrange
2016-09-14 15:46                         ` Michael S. Tsirkin
2016-09-14 17:35                           ` Eduardo Habkost
2016-09-14 22:05                             ` Michael S. Tsirkin
2016-09-15 14:58                               ` Eduardo Habkost
2016-09-14 13:27           ` [Qemu-devel] [PATCH v2] virtio_pci: Limit DMA mask to 44 bits for legacy virtio devices Michael S. Tsirkin
2016-09-14 13:36     ` [Qemu-devel] [RFC PATCH v1 10/22] sev: add SEV debug decrypt command Brijesh Singh
2016-09-14 13:48       ` Michael S. Tsirkin
2016-09-14 14:19         ` Paolo Bonzini
2016-09-14 15:02           ` Michael S. Tsirkin
2016-09-14 16:53             ` Paolo Bonzini
2016-09-14 18:15               ` Michael S. Tsirkin
2016-09-14 18:45                 ` Paolo Bonzini
2016-09-14 19:24                   ` Michael S. Tsirkin
2016-09-14 19:58                     ` Paolo Bonzini
2016-09-14 20:36                       ` Michael S. Tsirkin
2016-09-14 20:44                         ` Paolo Bonzini
2016-09-14 21:25                           ` Brijesh Singh
2016-09-14 21:38                           ` Michael S. Tsirkin
2016-09-13 14:48 ` [Qemu-devel] [RFC PATCH v1 11/22] sev: add SEV debug encrypt command Brijesh Singh
2016-09-13 14:48 ` [Qemu-devel] [RFC PATCH v1 12/22] sev: add SEV guest status command Brijesh Singh
2016-09-13 14:48 ` [Qemu-devel] [RFC PATCH v1 13/22] hmp: update 'info kvm' to display SEV status Brijesh Singh
2016-09-13 16:09   ` Eric Blake
2016-09-14 16:16     ` Brijesh Singh
2016-09-15  4:13       ` Michael S. Tsirkin
2016-09-13 23:01   ` Paolo Bonzini
2016-09-13 14:49 ` [Qemu-devel] [RFC PATCH v1 14/22] sev: provide SEV-enabled guest RAM read/write ops Brijesh Singh
2016-09-13 14:49 ` [Qemu-devel] [RFC PATCH v1 15/22] i386: sev: register RAM read/write ops for BIOS and PC.RAM region Brijesh Singh
2016-09-13 23:05   ` Paolo Bonzini
2016-09-14 20:59     ` Brijesh Singh
2016-09-14 21:00       ` Paolo Bonzini
2016-09-14 21:47         ` Brijesh Singh
2016-09-14 21:52           ` Paolo Bonzini
2016-09-14 22:06             ` Brijesh Singh
2016-09-14 22:17               ` Paolo Bonzini
2016-09-14 22:26                 ` Brijesh Singh
2016-09-15 14:13                 ` Brijesh Singh
2016-09-15 15:19                   ` Paolo Bonzini
2016-09-13 14:49 ` [Qemu-devel] [RFC PATCH v1 17/22] target-i386: add cpuid Fn8000_001f Brijesh Singh
2016-09-13 23:07   ` Paolo Bonzini
2016-09-21 16:20     ` Brijesh Singh
2016-09-21 16:24       ` Paolo Bonzini
2016-09-21 18:21       ` Eduardo Habkost
2016-09-13 14:49 ` [Qemu-devel] [RFC PATCH v1 18/22] i386: clear C-bit in SEV guest page table walk Brijesh Singh
2016-09-13 14:49 ` [Qemu-devel] [RFC PATCH v1 19/22] exec: set debug attribute in SEV-enabled guest Brijesh Singh
2016-09-13 23:06   ` Paolo Bonzini
2016-09-13 14:50 ` [Qemu-devel] [RFC PATCH v1 20/22] fw_cfg: sev: disable dma in real mode Brijesh Singh
2016-09-13 18:39   ` Michael S. Tsirkin
2016-09-13 20:46     ` Brijesh Singh
2016-09-13 20:55       ` Michael S. Tsirkin
2016-09-13 22:53   ` Paolo Bonzini
2016-09-14  2:33     ` Michael S. Tsirkin
2016-09-14  8:58       ` Paolo Bonzini
2016-09-21 18:00         ` [Qemu-devel] [RFC PATCH v1 20/22] fw_cfg: sev: disable dma in real mode Message-ID: <20160921205731-mutt-send-email-mst@kernel.org> Michael S. Tsirkin
2016-09-14 12:09       ` [Qemu-devel] [RFC PATCH v1 20/22] fw_cfg: sev: disable dma in real mode Eduardo Habkost
2016-09-14 13:01         ` Paolo Bonzini
2016-09-14 13:14           ` Michael S. Tsirkin
2016-09-14 13:51             ` Eduardo Habkost
2016-09-14 16:10               ` Michael S. Tsirkin
2016-09-14 17:25                 ` Eduardo Habkost
2016-09-21 18:03         ` Michael S. Tsirkin
2016-09-21 18:19           ` Brijesh Singh
2016-09-13 14:50 ` [Qemu-devel] [RFC PATCH v1 21/22] hw: add pre and post system reset callback Brijesh Singh
2016-09-13 22:47   ` Paolo Bonzini
2016-09-14 16:19     ` Brijesh Singh
2016-09-13 14:50 ` [Qemu-devel] [RFC PATCH v1 22/22] loader: reload bios image on ROM reset in SEV-enabled guest Brijesh Singh
2016-09-13 18:47   ` Michael S. Tsirkin
2016-09-13 22:59   ` Paolo Bonzini
2016-09-14  2:38     ` Michael S. Tsirkin
2016-09-14 20:29     ` Brijesh Singh
2016-09-14 20:38       ` Paolo Bonzini
2016-09-14 21:09         ` Michael S. Tsirkin
2016-09-14 21:11           ` Paolo Bonzini
2016-09-14 21:24         ` Brijesh Singh
2016-09-13 15:20 ` [Qemu-devel] [RFC PATCH v1 00/22] x86: Secure Encrypted Virtualization (AMD) Eduardo Habkost
     [not found] ` <147377816978.11859.942423377333907417.stgit@brijesh-build-machine>
2016-09-13 18:37   ` [Qemu-devel] [RFC PATCH v1 16/22] i386: pc: load OS images at fixed location in SEV-enabled guest Michael S. Tsirkin
2016-09-21 15:55     ` Brijesh Singh
2016-09-21 15:58       ` Paolo Bonzini
2016-09-21 16:08         ` Brijesh Singh
2016-09-21 16:17           ` Paolo Bonzini
2016-09-14  2:55 ` [Qemu-devel] [RFC PATCH v1 00/22] x86: Secure Encrypted Virtualization (AMD) Michael S. Tsirkin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160913220044.GY24695@thinpad.lan.raisama.net \
    --to=ehabkost@redhat.com \
    --cc=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=brijesh.singh@amd.com \
    --cc=crosthwaite.peter@gmail.com \
    --cc=lcapitulino@redhat.com \
    --cc=mst@redhat.com \
    --cc=p.fedin@samsung.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.