From: Paolo Bonzini <pbonzini@redhat.com>
To: Andy Lutomirski <luto@amacapital.net>,
kvm@vger.kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
"Theodore Ts'o" <tytso@mit.edu>,
linux-kernel@vger.kernel.org, Kees Cook <keescook@chromium.org>,
x86@kernel.org
Cc: Daniel Borkmann <dborkman@redhat.com>,
Srivatsa Vaddagiri <vatsa@linux.vnet.ibm.com>,
Raghavendra K T <raghavendra.kt@linux.vnet.ibm.com>,
Gleb Natapov <gleb@kernel.org>,
bsd@redhat.com, Andrew Honig <ahonig@google.com>
Subject: Re: [PATCH v5 1/5] x86,kvm: Add MSR_KVM_GET_RNG_SEED and a matching feature bit
Date: Thu, 31 Jul 2014 13:56:47 +0200 [thread overview]
Message-ID: <53DA2EFF.5000900@redhat.com> (raw)
In-Reply-To: <3e019617640d1b07d0ab1c9a91455957c201d4cd.1406177531.git.luto@amacapital.net>
Il 24/07/2014 06:57, Andy Lutomirski ha scritto:
> This adds a simple interface to allow a guest to request 64 bits of
> host nonblocking entropy. This is independent of virtio-rng for a
> couple of reasons:
>
> - It's intended to be usable during early boot, when a trivial
> synchronous interface is needed.
>
> - virtio-rng gives blocking entropy, and making guest boot wait for
> the host's /dev/random will cause problems.
>
> MSR_KVM_GET_RNG_SEED is intended to provide 64 bits of best-effort
> cryptographically secure data for use as a seed. It provides no
> guarantee that the result contains any actual entropy.
>
> Signed-off-by: Andy Lutomirski <luto@amacapital.net>
> ---
> Documentation/virtual/kvm/cpuid.txt | 3 +++
> arch/x86/include/uapi/asm/kvm_para.h | 2 ++
> arch/x86/kvm/cpuid.c | 3 ++-
> arch/x86/kvm/x86.c | 4 ++++
> 4 files changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/Documentation/virtual/kvm/cpuid.txt b/Documentation/virtual/kvm/cpuid.txt
> index 3c65feb..0ab043b 100644
> --- a/Documentation/virtual/kvm/cpuid.txt
> +++ b/Documentation/virtual/kvm/cpuid.txt
> @@ -54,6 +54,9 @@ KVM_FEATURE_PV_UNHALT || 7 || guest checks this feature bit
> || || before enabling paravirtualized
> || || spinlock support.
> ------------------------------------------------------------------------------
> +KVM_FEATURE_GET_RNG_SEED || 8 || host provides rng seed data via
> + || || MSR_KVM_GET_RNG_SEED.
> +------------------------------------------------------------------------------
> KVM_FEATURE_CLOCKSOURCE_STABLE_BIT || 24 || host will warn if no guest-side
> || || per-cpu warps are expected in
> || || kvmclock.
> diff --git a/arch/x86/include/uapi/asm/kvm_para.h b/arch/x86/include/uapi/asm/kvm_para.h
> index 94dc8ca..e2eaf93 100644
> --- a/arch/x86/include/uapi/asm/kvm_para.h
> +++ b/arch/x86/include/uapi/asm/kvm_para.h
> @@ -24,6 +24,7 @@
> #define KVM_FEATURE_STEAL_TIME 5
> #define KVM_FEATURE_PV_EOI 6
> #define KVM_FEATURE_PV_UNHALT 7
> +#define KVM_FEATURE_GET_RNG_SEED 8
>
> /* The last 8 bits are used to indicate how to interpret the flags field
> * in pvclock structure. If no bits are set, all flags are ignored.
> @@ -40,6 +41,7 @@
> #define MSR_KVM_ASYNC_PF_EN 0x4b564d02
> #define MSR_KVM_STEAL_TIME 0x4b564d03
> #define MSR_KVM_PV_EOI_EN 0x4b564d04
> +#define MSR_KVM_GET_RNG_SEED 0x4b564d05
>
> struct kvm_steal_time {
> __u64 steal;
> diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
> index 38a0afe..40d6763 100644
> --- a/arch/x86/kvm/cpuid.c
> +++ b/arch/x86/kvm/cpuid.c
> @@ -479,7 +479,8 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
> (1 << KVM_FEATURE_ASYNC_PF) |
> (1 << KVM_FEATURE_PV_EOI) |
> (1 << KVM_FEATURE_CLOCKSOURCE_STABLE_BIT) |
> - (1 << KVM_FEATURE_PV_UNHALT);
> + (1 << KVM_FEATURE_PV_UNHALT) |
> + (1 << KVM_FEATURE_GET_RNG_SEED);
>
> if (sched_info_on())
> entry->eax |= (1 << KVM_FEATURE_STEAL_TIME);
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index f644933..4e81853 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -48,6 +48,7 @@
> #include <linux/pci.h>
> #include <linux/timekeeper_internal.h>
> #include <linux/pvclock_gtod.h>
> +#include <linux/random.h>
> #include <trace/events/kvm.h>
>
> #define CREATE_TRACE_POINTS
> @@ -2480,6 +2481,9 @@ int kvm_get_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 *pdata)
> case MSR_KVM_PV_EOI_EN:
> data = vcpu->arch.pv_eoi.msr_val;
> break;
> + case MSR_KVM_GET_RNG_SEED:
> + get_random_bytes(&data, sizeof(data));
> + break;
> case MSR_IA32_P5_MC_ADDR:
> case MSR_IA32_P5_MC_TYPE:
> case MSR_IA32_MCG_CAP:
>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
next prev parent reply other threads:[~2014-07-31 11:56 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-24 4:57 [PATCH v5 0/5] random,x86,kvm: Rework arch RNG seeds and get some from kvm Andy Lutomirski
2014-07-24 4:57 ` [PATCH v5 1/5] x86,kvm: Add MSR_KVM_GET_RNG_SEED and a matching feature bit Andy Lutomirski
2014-07-31 11:56 ` Paolo Bonzini [this message]
2014-07-24 4:57 ` [PATCH v5 2/5] random: Add and use arch_get_rng_seed Andy Lutomirski
2014-07-29 23:46 ` Andy Lutomirski
2014-08-04 22:25 ` Theodore Ts'o
2014-07-24 4:57 ` [PATCH v5 3/5] x86,random: Add an x86 implementation of arch_get_rng_seed Andy Lutomirski
2014-07-24 4:57 ` [PATCH v5 4/5] x86,random,kvm: Use KVM_GET_RNG_SEED in arch_get_rng_seed Andy Lutomirski
2014-07-31 11:56 ` Paolo Bonzini
2014-07-24 4:57 ` [PATCH v5 5/5] x86,kaslr: Use MSR_KVM_GET_RNG_SEED for KASLR if available Andy Lutomirski
2014-07-31 11:56 ` Paolo Bonzini
2014-08-12 19:11 ` [PATCH v5 0/5] random,x86,kvm: Rework arch RNG seeds and get some from kvm Andy Lutomirski
2014-08-12 19:17 ` Theodore Ts'o
2014-08-12 19:22 ` Andy Lutomirski
2014-08-13 7:48 ` H. Peter Anvin
2014-08-13 8:37 ` Andy Lutomirski
2014-08-13 14:32 ` Theodore Ts'o
2014-08-13 16:13 ` Andy Lutomirski
2014-08-13 17:45 ` H. Peter Anvin
2014-08-13 18:22 ` Theodore Ts'o
2014-08-13 18:33 ` Andy Lutomirski
2014-08-13 18:44 ` H. Peter Anvin
2014-08-14 2:41 ` H. Peter Anvin
2014-08-14 5:14 ` Andy Lutomirski
2014-08-17 8:44 ` Paolo Bonzini
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=53DA2EFF.5000900@redhat.com \
--to=pbonzini@redhat.com \
--cc=ahonig@google.com \
--cc=bsd@redhat.com \
--cc=dborkman@redhat.com \
--cc=gleb@kernel.org \
--cc=hpa@zytor.com \
--cc=keescook@chromium.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=raghavendra.kt@linux.vnet.ibm.com \
--cc=tytso@mit.edu \
--cc=vatsa@linux.vnet.ibm.com \
--cc=x86@kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).