All of lore.kernel.org
 help / color / mirror / Atom feed
* Standardizing an MSR or other hypercall to get an RNG seed?
@ 2014-09-18  2:50 Andy Lutomirski
  2014-09-18 14:40 ` KY Srinivasan
                   ` (2 more replies)
  0 siblings, 3 replies; 84+ messages in thread
From: Andy Lutomirski @ 2014-09-18  2:50 UTC (permalink / raw)
  To: Linux Virtualization, kvm list
  Cc: Gleb Natapov, Paolo Bonzini, Theodore Ts'o, H. Peter Anvin

Hi all-

I would like to standardize on a very simple protocol by which a guest
OS can obtain an RNG seed early in boot.

The main design requirements are:

 - The interface should be very easy to use.  Linux, at least, will
want to use it extremely early in boot as part of kernel ASLR.  This
means that PCI and ACPI will not work.

 - It should be synchronous.  We don't want to delay boot while
waiting for a slow host RNG.  (On Linux, at least, we have a separate
interface for that: virtio-rng.  I think that Windows has some support
for virtio-rng as well.)

 - Random numbers obtained through this interface should be
best-effort.  We want the best quality randomness that the host can
provide immediately.

It seems to me that the best interface for the actual request for a
random number is rdmsr.  This is supported on all hypervisors and all
virtualization technologies.  It can return a 64 bit random number,
and it is easy to rdmsr the same register more than once to get a
larger random number.

The main questions are what MSR index to use and how to detect the
presence of the MSR.  I've played with two approaches:

1. Use CPUID to detect the presence of this feature.  This is very
easy for KVM to implement by using a KVM-specific CPUID feature.  The
problem is that this will necessarily be KVM-specific, as the guest
must first probe for KVM and then probe for the KVM feature.  I doubt
that Hyper-V, for example, wants to claim to be KVM.  If we could
standardize a non-hypervisor-specific CPUID feature, then this problem
would go away.

2. Detect the existence of the MSR by trying to read it and handling
the #GP(0) that will occur if the MSR is not present.  Linux, at
least, is okay with doing this, and I have code to enable an IDT and
an rdmsr fixup early enough in boot to use it for ASLR.  I don't know
whether other operating systems can do this, though.

The major questions, then, are what enumeration mechanism should be
used and what MSR index should be used.

For the MSR index, we could use an MSR from the Intel range if Intel
were to give explicit approval, thus guaranteeing that nothing would
conflict.  Or we could try to agree on an MSR index in the
0x40000000-0x4fffffff range that is unlikely to conflict with
anything.

For enumeration, we could just probe the MSR if all relevant guests
are okay with this or we could standardize on a CPUID-based mechanism.
If we do the latter, I don't know what that mechanism would be.

NB: This thread will be cc'd to Microsoft and possibly Hyper-V people
shortly.  I very much appreciate Jun Nakajima's help with this!

Thanks,
Andy

-- 
Andy Lutomirski
AMA Capital Management, LLC

^ permalink raw reply	[flat|nested] 84+ messages in thread

end of thread, other threads:[~2014-09-22 23:01 UTC | newest]

Thread overview: 84+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-18  2:50 Standardizing an MSR or other hypercall to get an RNG seed? Andy Lutomirski
2014-09-18 14:40 ` KY Srinivasan
2014-09-18 14:40 ` KY Srinivasan
2014-09-18 14:43   ` H. Peter Anvin
2014-09-18 15:38     ` Andy Lutomirski
2014-09-18 15:44       ` Andy Lutomirski
2014-09-18 15:58         ` Paolo Bonzini
2014-09-18 16:36       ` KY Srinivasan
2014-09-18 17:13         ` Nakajima, Jun
2014-09-18 17:17           ` Paolo Bonzini
2014-09-18 17:17           ` Paolo Bonzini
2014-09-18 17:20             ` Jake Oshins
2014-09-18 17:20             ` Jake Oshins
2014-09-18 17:20             ` KY Srinivasan
2014-09-18 17:20             ` KY Srinivasan
2014-09-18 17:42               ` Nakajima, Jun
2014-09-18 18:35                 ` Andy Lutomirski
2014-09-18 18:39                   ` H. Peter Anvin
2014-09-18 18:54                     ` Niels Ferguson
2014-09-18 19:03                       ` Andy Lutomirski
2014-09-18 21:54                         ` David Hepkin
2014-09-19  6:04                           ` Paolo Bonzini
2014-09-18 21:54                         ` David Hepkin
2014-09-18 18:58                   ` Paolo Bonzini
2014-09-18 19:07                     ` Andy Lutomirski
2014-09-18 21:21                       ` Nakajima, Jun
2014-09-18 21:35                         ` Andy Lutomirski
2014-09-18 21:46                       ` David Hepkin
2014-09-18 21:57                         ` H. Peter Anvin
2014-09-18 22:07                           ` Andy Lutomirski
2014-09-19  0:49                             ` Nakajima, Jun
2014-09-19  0:49                             ` Nakajima, Jun
2014-09-19  1:03                               ` Andy Lutomirski
2014-09-19  1:28                                 ` Andy Lutomirski
2014-09-19 16:14                                   ` Nakajima, Jun
2014-09-19 16:22                                     ` Paolo Bonzini
2014-09-19 16:40                                     ` H. Peter Anvin
2014-09-19 17:21                                       ` Andy Lutomirski
2014-09-19 17:36                                         ` H. Peter Anvin
2014-09-19 17:39                                           ` Andy Lutomirski
2014-09-19 22:05                                       ` Theodore Ts'o
2014-09-19 22:06                                         ` Andy Lutomirski
2014-09-19 22:57                                           ` Nakajima, Jun
2014-09-19 22:57                                           ` Theodore Ts'o
2014-09-19 23:12                                             ` Andy Lutomirski
2014-09-19 23:29                                               ` H. Peter Anvin
2014-09-19 23:35                                                 ` Theodore Ts'o
2014-09-19 23:41                                                   ` Andy Lutomirski
2014-09-20  0:06                                                   ` H. Peter Anvin
2014-09-19 23:29                                               ` H. Peter Anvin
2014-09-19  1:28                                 ` Andy Lutomirski
2014-09-18 22:00                         ` Andy Lutomirski
2014-09-18 22:03                           ` H. Peter Anvin
2014-09-19 16:37                           ` Gleb Natapov
2014-09-19 16:40                             ` H. Peter Anvin
2014-09-19 16:53                               ` Gleb Natapov
2014-09-19 17:08                                 ` H. Peter Anvin
2014-09-19 17:15                                   ` Gleb Natapov
2014-09-19 17:18                                     ` H. Peter Anvin
2014-09-19 17:49                                       ` Gleb Natapov
2014-09-19 18:02                                         ` Andy Lutomirski
2014-09-19 18:12                                           ` Gleb Natapov
2014-09-19 18:20                                             ` Andy Lutomirski
2014-09-19 20:53                                               ` Gleb Natapov
2014-09-22  4:11                                               ` Alok Kataria
2014-09-19 17:18                                     ` H. Peter Anvin
2014-09-19 17:21                                 ` Andy Lutomirski
2014-09-19 17:59                                   ` Gleb Natapov
2014-09-19 17:59                                   ` Gleb Natapov
2014-09-18 21:46                       ` David Hepkin
2014-09-18 18:56                 ` Paolo Bonzini
2014-09-18 16:36       ` KY Srinivasan
2014-09-19 18:30 ` Christopher Covington
2014-09-19 18:42   ` Andy Lutomirski
2014-09-19 20:21     ` Nadav Amit
2014-09-19 20:46       ` Andy Lutomirski
2014-09-19 21:46         ` H. Peter Anvin
2014-09-22 13:31           ` Christopher Covington
2014-09-22 14:17             ` H. Peter Anvin
2014-09-22 14:18               ` H. Peter Anvin
2014-09-22 23:01             ` H. Peter Anvin
2014-09-21 12:39         ` Paolo Bonzini
2014-09-19 20:21     ` Nadav Amit
2014-09-22 13:33     ` Christopher Covington

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.