linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* random: Providing a seed value to VM guests
  2014-05-01 18:53                 ` Andy Lutomirski
@ 2014-05-01 18:59                   ` H. Peter Anvin
  0 siblings, 0 replies; 17+ messages in thread
From: H. Peter Anvin @ 2014-05-01 18:59 UTC (permalink / raw)
  To: Andy Lutomirski, Theodore Ts'o, Florian Weimer,
	linux-kernel@vger.kernel.org, Kees Cook, kvm list

On 05/01/2014 11:53 AM, Andy Lutomirski wrote:
> 
> A CPUID leaf or an MSR advertised by a CPUID leaf has another
> advantage: it's easy to use in the ASLR code -- I don't think there's
> a real IDT, so there's nothing like rdmsr_safe available.  It also
> avoids doing anything complicated with the boot process to allow the
> same seed to be used for ASLR and random.c; it can just be invoked
> twice on boot.
> 

At that point we are talking an x86-specific interface, and so we might
as well simply emulate RDRAND (urandom) and RDSEED (random) if the CPU
doesn't support them.  I believe KVM already has a way to report CPUID
features that are "emulated but supported anyway", i.e. they work but
are slow.

> What's the right forum for this?  This thread is probably not it.

Change the subject line?

	-hpa



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

* Re: random: Providing a seed value to VM guests
@ 2014-05-01 19:02 Andy Lutomirski
  2014-05-01 19:26 ` tytso
  2014-05-01 19:41 ` H. Peter Anvin
  0 siblings, 2 replies; 17+ messages in thread
From: Andy Lutomirski @ 2014-05-01 19:02 UTC (permalink / raw)
  To: H. Peter Anvin
  Cc: Theodore Ts'o, Florian Weimer, linux-kernel@vger.kernel.org,
	Kees Cook, kvm list

On Thu, May 1, 2014 at 11:59 AM, H. Peter Anvin <hpa@zytor.com> wrote:
> On 05/01/2014 11:53 AM, Andy Lutomirski wrote:
>>
>> A CPUID leaf or an MSR advertised by a CPUID leaf has another
>> advantage: it's easy to use in the ASLR code -- I don't think there's
>> a real IDT, so there's nothing like rdmsr_safe available.  It also
>> avoids doing anything complicated with the boot process to allow the
>> same seed to be used for ASLR and random.c; it can just be invoked
>> twice on boot.
>>
>
> At that point we are talking an x86-specific interface, and so we might
> as well simply emulate RDRAND (urandom) and RDSEED (random) if the CPU
> doesn't support them.  I believe KVM already has a way to report CPUID
> features that are "emulated but supported anyway", i.e. they work but
> are slow.

Do existing kernels and userspace respect this?  If the normal bit for
RDRAND is unset, then we might be okay, but, if not, then I think this
may kill guest performance.

Is RDSEED really reasonable here?  Won't it slow down by several
orders of magnitude?

>
>> What's the right forum for this?  This thread is probably not it.
>
> Change the subject line?

:)

>
>         -hpa
>
>



-- 
Andy Lutomirski
AMA Capital Management, LLC

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

* Re: random: Providing a seed value to VM guests
  2014-05-01 19:02 random: Providing a seed value to VM guests Andy Lutomirski
@ 2014-05-01 19:26 ` tytso
  2014-05-01 19:40   ` H. Peter Anvin
  2014-05-01 20:16   ` Andy Lutomirski
  2014-05-01 19:41 ` H. Peter Anvin
  1 sibling, 2 replies; 17+ messages in thread
From: tytso @ 2014-05-01 19:26 UTC (permalink / raw)
  To: Andy Lutomirski
  Cc: H. Peter Anvin, Florian Weimer, linux-kernel@vger.kernel.org,
	Kees Cook, kvm list

On Thu, May 01, 2014 at 12:02:49PM -0700, Andy Lutomirski wrote:
> 
> Is RDSEED really reasonable here?  Won't it slow down by several
> orders of magnitude?

That is I think the biggest problem; RDRAND and RDSEED are fast if
they are native, but they will involve a VM exit if they need to be
emulated.  So when an OS might want to use RDRAND and RDSEED might be
quite different if we know they are being emulated.

Using the RDRAND and RDSEED "api" certainly makes sense, at least for
x86, but I suspect we might want to use a different way of signalling
that a VM guest can use RDRAND and RDSEED if they are running on a CPU
which doesn't provide that kind of access.  Maybe a CPUID extended
function parameter, if one could be allocated for use by a Linux
hypervisor?

						- Ted


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

* Re: random: Providing a seed value to VM guests
  2014-05-01 19:26 ` tytso
@ 2014-05-01 19:40   ` H. Peter Anvin
  2014-05-01 20:16   ` Andy Lutomirski
  1 sibling, 0 replies; 17+ messages in thread
From: H. Peter Anvin @ 2014-05-01 19:40 UTC (permalink / raw)
  To: tytso, Andy Lutomirski
  Cc: Florian Weimer, linux-kernel@vger.kernel.org, Kees Cook, kvm list

As I said... I think KVM has already added an emulated instructions enumeration API.

On May 1, 2014 12:26:18 PM PDT, tytso@mit.edu wrote:
>On Thu, May 01, 2014 at 12:02:49PM -0700, Andy Lutomirski wrote:
>> 
>> Is RDSEED really reasonable here?  Won't it slow down by several
>> orders of magnitude?
>
>That is I think the biggest problem; RDRAND and RDSEED are fast if
>they are native, but they will involve a VM exit if they need to be
>emulated.  So when an OS might want to use RDRAND and RDSEED might be
>quite different if we know they are being emulated.
>
>Using the RDRAND and RDSEED "api" certainly makes sense, at least for
>x86, but I suspect we might want to use a different way of signalling
>that a VM guest can use RDRAND and RDSEED if they are running on a CPU
>which doesn't provide that kind of access.  Maybe a CPUID extended
>function parameter, if one could be allocated for use by a Linux
>hypervisor?
>
>						- Ted

-- 
Sent from my mobile phone.  Please pardon brevity and lack of formatting.

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

* Re: random: Providing a seed value to VM guests
  2014-05-01 19:02 random: Providing a seed value to VM guests Andy Lutomirski
  2014-05-01 19:26 ` tytso
@ 2014-05-01 19:41 ` H. Peter Anvin
  1 sibling, 0 replies; 17+ messages in thread
From: H. Peter Anvin @ 2014-05-01 19:41 UTC (permalink / raw)
  To: Andy Lutomirski
  Cc: Theodore Ts'o, Florian Weimer, linux-kernel@vger.kernel.org,
	Kees Cook, kvm list

The normal CPUID bit is unset I believe.

On May 1, 2014 12:02:49 PM PDT, Andy Lutomirski <luto@amacapital.net> wrote:
>On Thu, May 1, 2014 at 11:59 AM, H. Peter Anvin <hpa@zytor.com> wrote:
>> On 05/01/2014 11:53 AM, Andy Lutomirski wrote:
>>>
>>> A CPUID leaf or an MSR advertised by a CPUID leaf has another
>>> advantage: it's easy to use in the ASLR code -- I don't think
>there's
>>> a real IDT, so there's nothing like rdmsr_safe available.  It also
>>> avoids doing anything complicated with the boot process to allow the
>>> same seed to be used for ASLR and random.c; it can just be invoked
>>> twice on boot.
>>>
>>
>> At that point we are talking an x86-specific interface, and so we
>might
>> as well simply emulate RDRAND (urandom) and RDSEED (random) if the
>CPU
>> doesn't support them.  I believe KVM already has a way to report
>CPUID
>> features that are "emulated but supported anyway", i.e. they work but
>> are slow.
>
>Do existing kernels and userspace respect this?  If the normal bit for
>RDRAND is unset, then we might be okay, but, if not, then I think this
>may kill guest performance.
>
>Is RDSEED really reasonable here?  Won't it slow down by several
>orders of magnitude?
>
>>
>>> What's the right forum for this?  This thread is probably not it.
>>
>> Change the subject line?
>
>:)
>
>>
>>         -hpa
>>
>>

-- 
Sent from my mobile phone.  Please pardon brevity and lack of formatting.

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

* Re: random: Providing a seed value to VM guests
  2014-05-01 19:26 ` tytso
  2014-05-01 19:40   ` H. Peter Anvin
@ 2014-05-01 20:16   ` Andy Lutomirski
  2014-05-01 20:30     ` H. Peter Anvin
  1 sibling, 1 reply; 17+ messages in thread
From: Andy Lutomirski @ 2014-05-01 20:16 UTC (permalink / raw)
  To: Ted Ts'o
  Cc: linux-kernel@vger.kernel.org, H. Peter Anvin, kvm list,
	Florian Weimer, Kees Cook

On May 1, 2014 12:26 PM, <tytso@mit.edu> wrote:
>
> On Thu, May 01, 2014 at 12:02:49PM -0700, Andy Lutomirski wrote:
> >
> > Is RDSEED really reasonable here?  Won't it slow down by several
> > orders of magnitude?
>
> That is I think the biggest problem; RDRAND and RDSEED are fast if
> they are native, but they will involve a VM exit if they need to be
> emulated.  So when an OS might want to use RDRAND and RDSEED might be
> quite different if we know they are being emulated.
>
> Using the RDRAND and RDSEED "api" certainly makes sense, at least for
> x86, but I suspect we might want to use a different way of signalling
> that a VM guest can use RDRAND and RDSEED if they are running on a CPU
> which doesn't provide that kind of access.  Maybe a CPUID extended
> function parameter, if one could be allocated for use by a Linux
> hypervisor?
>

I'm still not convinced.  This will affect userspace as well as the
guest kernel, and I don't see why guest user code should be able to
access this API.  RDRAND for CPL0 only would work, but that seems odd.

And I think that RDSEED emulation is asking for trouble.  RDSEED is
synchronous, but /dev/random is asynchronous.  And making bootup wait
for even a single byte from /dev/random seems bad.  In any event,
virtio-rng should be a better interface for this.

>                                                 - Ted
>

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

* Re: random: Providing a seed value to VM guests
  2014-05-01 20:16   ` Andy Lutomirski
@ 2014-05-01 20:30     ` H. Peter Anvin
  2014-05-01 20:32       ` Andy Lutomirski
  0 siblings, 1 reply; 17+ messages in thread
From: H. Peter Anvin @ 2014-05-01 20:30 UTC (permalink / raw)
  To: Andy Lutomirski, Ted Ts'o
  Cc: linux-kernel@vger.kernel.org, kvm list, Florian Weimer, Kees Cook

RDSEED is not synchronous.  It is, however, nonblocking.

On May 1, 2014 1:16:40 PM PDT, Andy Lutomirski <luto@amacapital.net> wrote:
>On May 1, 2014 12:26 PM, <tytso@mit.edu> wrote:
>>
>> On Thu, May 01, 2014 at 12:02:49PM -0700, Andy Lutomirski wrote:
>> >
>> > Is RDSEED really reasonable here?  Won't it slow down by several
>> > orders of magnitude?
>>
>> That is I think the biggest problem; RDRAND and RDSEED are fast if
>> they are native, but they will involve a VM exit if they need to be
>> emulated.  So when an OS might want to use RDRAND and RDSEED might be
>> quite different if we know they are being emulated.
>>
>> Using the RDRAND and RDSEED "api" certainly makes sense, at least for
>> x86, but I suspect we might want to use a different way of signalling
>> that a VM guest can use RDRAND and RDSEED if they are running on a
>CPU
>> which doesn't provide that kind of access.  Maybe a CPUID extended
>> function parameter, if one could be allocated for use by a Linux
>> hypervisor?
>>
>
>I'm still not convinced.  This will affect userspace as well as the
>guest kernel, and I don't see why guest user code should be able to
>access this API.  RDRAND for CPL0 only would work, but that seems odd.
>
>And I think that RDSEED emulation is asking for trouble.  RDSEED is
>synchronous, but /dev/random is asynchronous.  And making bootup wait
>for even a single byte from /dev/random seems bad.  In any event,
>virtio-rng should be a better interface for this.
>
>>                                                 - Ted
>>

-- 
Sent from my mobile phone.  Please pardon brevity and lack of formatting.

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

* Re: random: Providing a seed value to VM guests
  2014-05-01 20:30     ` H. Peter Anvin
@ 2014-05-01 20:32       ` Andy Lutomirski
  2014-05-01 20:39         ` tytso
  0 siblings, 1 reply; 17+ messages in thread
From: Andy Lutomirski @ 2014-05-01 20:32 UTC (permalink / raw)
  To: H. Peter Anvin
  Cc: Ted Ts'o, linux-kernel@vger.kernel.org, kvm list,
	Florian Weimer, Kees Cook

On Thu, May 1, 2014 at 1:30 PM, H. Peter Anvin <hpa@zytor.com> wrote:
> RDSEED is not synchronous.  It is, however, nonblocking.

What I mean is: IIUC it's reasonable to call RDSEED a few times in a
loop and hope it works.  It makes no sense to do that with
/dev/random.

>
> On May 1, 2014 1:16:40 PM PDT, Andy Lutomirski <luto@amacapital.net> wrote:
>>On May 1, 2014 12:26 PM, <tytso@mit.edu> wrote:
>>>
>>> On Thu, May 01, 2014 at 12:02:49PM -0700, Andy Lutomirski wrote:
>>> >
>>> > Is RDSEED really reasonable here?  Won't it slow down by several
>>> > orders of magnitude?
>>>
>>> That is I think the biggest problem; RDRAND and RDSEED are fast if
>>> they are native, but they will involve a VM exit if they need to be
>>> emulated.  So when an OS might want to use RDRAND and RDSEED might be
>>> quite different if we know they are being emulated.
>>>
>>> Using the RDRAND and RDSEED "api" certainly makes sense, at least for
>>> x86, but I suspect we might want to use a different way of signalling
>>> that a VM guest can use RDRAND and RDSEED if they are running on a
>>CPU
>>> which doesn't provide that kind of access.  Maybe a CPUID extended
>>> function parameter, if one could be allocated for use by a Linux
>>> hypervisor?
>>>
>>
>>I'm still not convinced.  This will affect userspace as well as the
>>guest kernel, and I don't see why guest user code should be able to
>>access this API.  RDRAND for CPL0 only would work, but that seems odd.
>>
>>And I think that RDSEED emulation is asking for trouble.  RDSEED is
>>synchronous, but /dev/random is asynchronous.  And making bootup wait
>>for even a single byte from /dev/random seems bad.  In any event,
>>virtio-rng should be a better interface for this.
>>
>>>                                                 - Ted
>>>
>
> --
> Sent from my mobile phone.  Please pardon brevity and lack of formatting.



-- 
Andy Lutomirski
AMA Capital Management, LLC

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

* Re: random: Providing a seed value to VM guests
  2014-05-01 20:32       ` Andy Lutomirski
@ 2014-05-01 20:39         ` tytso
  2014-05-01 20:56           ` Andy Lutomirski
  0 siblings, 1 reply; 17+ messages in thread
From: tytso @ 2014-05-01 20:39 UTC (permalink / raw)
  To: Andy Lutomirski
  Cc: H. Peter Anvin, linux-kernel@vger.kernel.org, kvm list,
	Florian Weimer, Kees Cook

On Thu, May 01, 2014 at 01:32:55PM -0700, Andy Lutomirski wrote:
> On Thu, May 1, 2014 at 1:30 PM, H. Peter Anvin <hpa@zytor.com> wrote:
> > RDSEED is not synchronous.  It is, however, nonblocking.
> 
> What I mean is: IIUC it's reasonable to call RDSEED a few times in a
> loop and hope it works.  It makes no sense to do that with
> /dev/random.

RDSEED is allowed to return an error if there is insufficient entropy.
So long as the caller understands that this is an emulated
instruction, I don't see a problem.

						- Ted

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

* Re: random: Providing a seed value to VM guests
  2014-05-01 20:39         ` tytso
@ 2014-05-01 20:56           ` Andy Lutomirski
  2014-05-01 21:01             ` H. Peter Anvin
  0 siblings, 1 reply; 17+ messages in thread
From: Andy Lutomirski @ 2014-05-01 20:56 UTC (permalink / raw)
  To: Theodore Ts'o, Andy Lutomirski, H. Peter Anvin,
	linux-kernel@vger.kernel.org, kvm list, Florian Weimer, Kees Cook

On Thu, May 1, 2014 at 1:39 PM,  <tytso@mit.edu> wrote:
> On Thu, May 01, 2014 at 01:32:55PM -0700, Andy Lutomirski wrote:
>> On Thu, May 1, 2014 at 1:30 PM, H. Peter Anvin <hpa@zytor.com> wrote:
>> > RDSEED is not synchronous.  It is, however, nonblocking.
>>
>> What I mean is: IIUC it's reasonable to call RDSEED a few times in a
>> loop and hope it works.  It makes no sense to do that with
>> /dev/random.
>
> RDSEED is allowed to return an error if there is insufficient entropy.
> So long as the caller understands that this is an emulated
> instruction, I don't see a problem.

What's the point?

I think this is too caught up in x86 architectural stuff.  As I see
it, the goal is to give guests a way to ask their hosts to give them,
immediately and synchronously, some bytes suitable for seeding an RNG.
 These bytes need not contain true entropy, because the host may not
be able to provide entropy an a timely manner.  The mechanism should
be usable extremely early after boot, it should be usable after a
guest reboot, and it should be reliable.  I think there's an added
benefit if all architectures can implement a semantically equivalent
function, even if the interface is completely different.

There's no need for anything new to provide asynchronous and-or very
slow true random data -- virtio-rng already exists. *

Emulating RDRAND for this purpose is a little weird because it's
normally available to user code and it has the flag indicating
failure.  We're also not going to want the guest kernel to access it
through the arch_get_random interface.

Even if we could emulate RDSEED effectively**, I don't really
understand what the guest is expected to do with it.  And I generally
dislike defining an interface with no known sensible users, because it
means that there's a good chance that the interface won't end up
working.

* I still don't know why it doesn't work for me.  I'll fiddle with it,
but I think that the right solution is to fix it for this purpose, not
to replace it.
** Doing this sensibly in the host will be awkward.  Is the host
supposed to use non-blocking reads of /dev/random?  Getting anything
remotely fair may be difficult.

>
>                                                 - Ted



-- 
Andy Lutomirski
AMA Capital Management, LLC

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

* Re: random: Providing a seed value to VM guests
  2014-05-01 20:56           ` Andy Lutomirski
@ 2014-05-01 21:01             ` H. Peter Anvin
  2014-05-01 21:06               ` Andy Lutomirski
  0 siblings, 1 reply; 17+ messages in thread
From: H. Peter Anvin @ 2014-05-01 21:01 UTC (permalink / raw)
  To: Andy Lutomirski, Theodore Ts'o, linux-kernel@vger.kernel.org,
	kvm list, Florian Weimer, Kees Cook

On 05/01/2014 01:56 PM, Andy Lutomirski wrote:
> 
> Even if we could emulate RDSEED effectively**, I don't really
> understand what the guest is expected to do with it.  And I generally
> dislike defining an interface with no known sensible users, because it
> means that there's a good chance that the interface won't end up
> working.
>
> ** Doing this sensibly in the host will be awkward.  Is the host
> supposed to use non-blocking reads of /dev/random?  Getting anything
> remotely fair may be difficult.

The host can use nonblocking reads of /dev/random.  Fairness would have
to be implemented at the host level, but that is true for anything.

	-hpa



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

* Re: random: Providing a seed value to VM guests
  2014-05-01 21:01             ` H. Peter Anvin
@ 2014-05-01 21:06               ` Andy Lutomirski
  2014-05-01 22:28                 ` tytso
  0 siblings, 1 reply; 17+ messages in thread
From: Andy Lutomirski @ 2014-05-01 21:06 UTC (permalink / raw)
  To: H. Peter Anvin
  Cc: Theodore Ts'o, linux-kernel@vger.kernel.org, kvm list,
	Florian Weimer, Kees Cook

On Thu, May 1, 2014 at 2:01 PM, H. Peter Anvin <hpa@zytor.com> wrote:
> On 05/01/2014 01:56 PM, Andy Lutomirski wrote:
>>
>> Even if we could emulate RDSEED effectively**, I don't really
>> understand what the guest is expected to do with it.  And I generally
>> dislike defining an interface with no known sensible users, because it
>> means that there's a good chance that the interface won't end up
>> working.
>>
>> ** Doing this sensibly in the host will be awkward.  Is the host
>> supposed to use non-blocking reads of /dev/random?  Getting anything
>> remotely fair may be difficult.
>
> The host can use nonblocking reads of /dev/random.  Fairness would have
> to be implemented at the host level, but that is true for anything.
>

I still don't see the point.  What does this do better than virtio-rng?

The ASLR code doesn't even try to use RDSEED.  RDSEED is used in
add_interrupt_randomness, which should drain the host's /dev/random
even if it could, and it's used in init_std_data.  The logic there is:

                if (!arch_get_random_seed_long(&rv) &&
                    !arch_get_random_long(&rv))
                        rv = random_get_entropy();

I think this is better achieved by having the host try to supply the
highest quality data it can.

The third RDSEED use is arch_random_refill.  This purpose would be
much better served by the khwrng stuff and virtio-rng.

So I still claim that fancy emulated RDSEED support will have no users.

--Andy

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

* Re: random: Providing a seed value to VM guests
  2014-05-01 21:06               ` Andy Lutomirski
@ 2014-05-01 22:28                 ` tytso
  2014-05-01 22:32                   ` Andy Lutomirski
  0 siblings, 1 reply; 17+ messages in thread
From: tytso @ 2014-05-01 22:28 UTC (permalink / raw)
  To: Andy Lutomirski
  Cc: H. Peter Anvin, linux-kernel@vger.kernel.org, kvm list,
	Florian Weimer, Kees Cook

On Thu, May 01, 2014 at 02:06:13PM -0700, Andy Lutomirski wrote:
> 
> I still don't see the point.  What does this do better than virtio-rng?

I believe you had been complaining about how complicated it was to set
up virtio?  And this complexity is also an issue if we want to use it
to initialize the RNG used for the kernel text ASLR --- which has to
be done very early in the boot process, and where making something as
simple as possible is a Good Thing.

And since we would want to use RDRAND/RDSEED if it is available
*anyway*, perhaps in combination with other things, why not use the
RDRAND/RDSEED interface?

							- Ted

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

* Re: random: Providing a seed value to VM guests
  2014-05-01 22:28                 ` tytso
@ 2014-05-01 22:32                   ` Andy Lutomirski
  2014-05-01 22:46                     ` H. Peter Anvin
  0 siblings, 1 reply; 17+ messages in thread
From: Andy Lutomirski @ 2014-05-01 22:32 UTC (permalink / raw)
  To: Theodore Ts'o, Andy Lutomirski, H. Peter Anvin,
	linux-kernel@vger.kernel.org, kvm list, Florian Weimer, Kees Cook

On Thu, May 1, 2014 at 3:28 PM,  <tytso@mit.edu> wrote:
> On Thu, May 01, 2014 at 02:06:13PM -0700, Andy Lutomirski wrote:
>>
>> I still don't see the point.  What does this do better than virtio-rng?
>
> I believe you had been complaining about how complicated it was to set
> up virtio?  And this complexity is also an issue if we want to use it
> to initialize the RNG used for the kernel text ASLR --- which has to
> be done very early in the boot process, and where making something as
> simple as possible is a Good Thing.

It's complicated, so it won't be up until much later in the boot
process.  This is completely fine for /dev/random, but it's a problem
for /dev/urandom, ASLR, and such.

>
> And since we would want to use RDRAND/RDSEED if it is available
> *anyway*, perhaps in combination with other things, why not use the
> RDRAND/RDSEED interface?

Because it's awkward.  I don't think it simplifies anything.

--Andy

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

* Re: random: Providing a seed value to VM guests
  2014-05-01 22:32                   ` Andy Lutomirski
@ 2014-05-01 22:46                     ` H. Peter Anvin
  2014-05-01 22:56                       ` Andy Lutomirski
  0 siblings, 1 reply; 17+ messages in thread
From: H. Peter Anvin @ 2014-05-01 22:46 UTC (permalink / raw)
  To: Andy Lutomirski, Theodore Ts'o, linux-kernel@vger.kernel.org,
	kvm list, Florian Weimer, Kees Cook

On 05/01/2014 03:32 PM, Andy Lutomirski wrote:
> On Thu, May 1, 2014 at 3:28 PM,  <tytso@mit.edu> wrote:
>> On Thu, May 01, 2014 at 02:06:13PM -0700, Andy Lutomirski wrote:
>>>
>>> I still don't see the point.  What does this do better than virtio-rng?
>>
>> I believe you had been complaining about how complicated it was to set
>> up virtio?  And this complexity is also an issue if we want to use it
>> to initialize the RNG used for the kernel text ASLR --- which has to
>> be done very early in the boot process, and where making something as
>> simple as possible is a Good Thing.
> 
> It's complicated, so it won't be up until much later in the boot
> process.  This is completely fine for /dev/random, but it's a problem
> for /dev/urandom, ASLR, and such.
> 
>>
>> And since we would want to use RDRAND/RDSEED if it is available
>> *anyway*, perhaps in combination with other things, why not use the
>> RDRAND/RDSEED interface?
> 
> Because it's awkward.  I don't think it simplifies anything.
> 

It greatly simplifies discovery, which is a Big Deal[TM] in early code.

	-hpa



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

* Re: random: Providing a seed value to VM guests
  2014-05-01 22:46                     ` H. Peter Anvin
@ 2014-05-01 22:56                       ` Andy Lutomirski
  2014-05-01 23:00                         ` H. Peter Anvin
  0 siblings, 1 reply; 17+ messages in thread
From: Andy Lutomirski @ 2014-05-01 22:56 UTC (permalink / raw)
  To: H. Peter Anvin
  Cc: Theodore Ts'o, linux-kernel@vger.kernel.org, kvm list,
	Florian Weimer, Kees Cook

On Thu, May 1, 2014 at 3:46 PM, H. Peter Anvin <hpa@zytor.com> wrote:
> On 05/01/2014 03:32 PM, Andy Lutomirski wrote:
>> On Thu, May 1, 2014 at 3:28 PM,  <tytso@mit.edu> wrote:
>>> On Thu, May 01, 2014 at 02:06:13PM -0700, Andy Lutomirski wrote:
>>>>
>>>> I still don't see the point.  What does this do better than virtio-rng?
>>>
>>> I believe you had been complaining about how complicated it was to set
>>> up virtio?  And this complexity is also an issue if we want to use it
>>> to initialize the RNG used for the kernel text ASLR --- which has to
>>> be done very early in the boot process, and where making something as
>>> simple as possible is a Good Thing.
>>
>> It's complicated, so it won't be up until much later in the boot
>> process.  This is completely fine for /dev/random, but it's a problem
>> for /dev/urandom, ASLR, and such.
>>
>>>
>>> And since we would want to use RDRAND/RDSEED if it is available
>>> *anyway*, perhaps in combination with other things, why not use the
>>> RDRAND/RDSEED interface?
>>
>> Because it's awkward.  I don't think it simplifies anything.
>>
>
> It greatly simplifies discovery, which is a Big Deal[TM] in early code.

I think we're comparing:

a) cpuid to detect rdrand *or* emulated rdrand followed by rdrand

to

b) cpuid to detect rdrand or the paravirt seed msr/cpuid call,
followed by rdrand or the msr or cpuid read

this seems like it barely makes a difference, especially since (a)
probably requires detecting KVM anyway.


For the real kernel code, it's probably even closer to making no
difference, since I don't think we'll want arch_get_random_long to use
emulated rdrand.

--Andy

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

* Re: random: Providing a seed value to VM guests
  2014-05-01 22:56                       ` Andy Lutomirski
@ 2014-05-01 23:00                         ` H. Peter Anvin
  0 siblings, 0 replies; 17+ messages in thread
From: H. Peter Anvin @ 2014-05-01 23:00 UTC (permalink / raw)
  To: Andy Lutomirski
  Cc: Theodore Ts'o, linux-kernel@vger.kernel.org, kvm list,
	Florian Weimer, Kees Cook

On 05/01/2014 03:56 PM, Andy Lutomirski wrote:
> 
> I think we're comparing:
> 
> a) cpuid to detect rdrand *or* emulated rdrand followed by rdrand
> 
> to
> 
> b) cpuid to detect rdrand or the paravirt seed msr/cpuid call,
> followed by rdrand or the msr or cpuid read
> 
> this seems like it barely makes a difference, especially since (a)
> probably requires detecting KVM anyway.

Well, it lets one do something like:

	if (boot_cpu_has(X86_FEATURE_RDRAND) ||
            boot_cpu_has(X86_FEATURE_RDRAND_SIMULATED))
		rdrand_long(...);

We need the ifs anyway for early code; the arch_*() interfaces are only
available after alternatives run.

	-hpa


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

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

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-01 19:02 random: Providing a seed value to VM guests Andy Lutomirski
2014-05-01 19:26 ` tytso
2014-05-01 19:40   ` H. Peter Anvin
2014-05-01 20:16   ` Andy Lutomirski
2014-05-01 20:30     ` H. Peter Anvin
2014-05-01 20:32       ` Andy Lutomirski
2014-05-01 20:39         ` tytso
2014-05-01 20:56           ` Andy Lutomirski
2014-05-01 21:01             ` H. Peter Anvin
2014-05-01 21:06               ` Andy Lutomirski
2014-05-01 22:28                 ` tytso
2014-05-01 22:32                   ` Andy Lutomirski
2014-05-01 22:46                     ` H. Peter Anvin
2014-05-01 22:56                       ` Andy Lutomirski
2014-05-01 23:00                         ` H. Peter Anvin
2014-05-01 19:41 ` H. Peter Anvin
  -- strict thread matches above, loose matches on Subject: below --
2014-04-28 19:52 [PATCH] random: Add "initialized" variable to proc Florian Weimer
2014-04-28 21:41 ` Theodore Ts'o
2014-04-29 17:51   ` Florian Weimer
2014-04-29 18:26     ` Theodore Ts'o
2014-04-30 20:52       ` Andy Lutomirski
2014-05-01  2:06         ` Theodore Ts'o
2014-05-01  4:05           ` H. Peter Anvin
2014-05-01 15:05             ` tytso
2014-05-01 15:35               ` Andy Lutomirski
2014-05-01 18:53                 ` Andy Lutomirski
2014-05-01 18:59                   ` random: Providing a seed value to VM guests H. Peter Anvin

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).