Re: [PATCH 3/3] KVM: PPC: Book3S: Add support for hwrng found on some powernv systems

2013-10-03 Thread Gleb Natapov
On Thu, Oct 03, 2013 at 08:21:20AM +1000, Benjamin Herrenschmidt wrote: On Wed, 2013-10-02 at 17:37 +0300, Gleb Natapov wrote: On Wed, Oct 02, 2013 at 04:33:18PM +0200, Paolo Bonzini wrote: Il 02/10/2013 16:08, Alexander Graf ha scritto: The hwrng is accessible by host userspace via

Re: [PATCH 3/3] KVM: PPC: Book3S: Add support for hwrng found on some powernv systems

2013-10-03 Thread Gleb Natapov
On Thu, Oct 03, 2013 at 08:07:22AM +1000, Benjamin Herrenschmidt wrote: On Wed, 2013-10-02 at 13:02 +0300, Gleb Natapov wrote: Yes, I alluded to it in my email to Paul and Paolo asked also. How this interface is disabled? Also hwrnd is MMIO in a host why guest needs to use hypercall

Re: [PATCH 3/3] KVM: PPC: Book3S: Add support for hwrng found on some powernv systems

2013-10-03 Thread Benjamin Herrenschmidt
On Thu, 2013-10-03 at 08:43 +0300, Gleb Natapov wrote: Why it can be a bad idea? User can drain hwrng continuously making other users of it much slower, or even worse, making them fall back to another much less reliable, source of entropy. Not in a very significant way, we generate entropy at

Re: [PATCH 3/3] KVM: PPC: Book3S: Add support for hwrng found on some powernv systems

2013-10-03 Thread Paul Mackerras
On Thu, Oct 03, 2013 at 08:48:03AM +0300, Gleb Natapov wrote: On Thu, Oct 03, 2013 at 08:45:42AM +1000, Paul Mackerras wrote: On Wed, Oct 02, 2013 at 04:36:05PM +0200, Alexander Graf wrote: On 02.10.2013, at 16:33, Paolo Bonzini wrote: Il 02/10/2013 16:08, Alexander Graf ha

Re: [PATCH 3/3] KVM: PPC: Book3S: Add support for hwrng found on some powernv systems

2013-10-03 Thread Gleb Natapov
On Thu, Oct 03, 2013 at 08:06:30PM +1000, Paul Mackerras wrote: On Thu, Oct 03, 2013 at 08:48:03AM +0300, Gleb Natapov wrote: On Thu, Oct 03, 2013 at 08:45:42AM +1000, Paul Mackerras wrote: On Wed, Oct 02, 2013 at 04:36:05PM +0200, Alexander Graf wrote: On 02.10.2013, at 16:33,

Re: [PATCH 3/3] KVM: PPC: Book3S: Add support for hwrng found on some powernv systems

2013-10-02 Thread Paolo Bonzini
Il 01/10/2013 23:44, Benjamin Herrenschmidt ha scritto: On Tue, 2013-10-01 at 13:19 +0200, Paolo Bonzini wrote: Il 01/10/2013 11:38, Benjamin Herrenschmidt ha scritto: So for the sake of that dogma you are going to make us do something that is about 100 times slower ? (and possibly involves

Re: [PATCH 3/3] KVM: PPC: Book3S: Add support for hwrng found on some powernv systems

2013-10-02 Thread Paolo Bonzini
Il 02/10/2013 07:09, Paul Mackerras ha scritto: On Tue, Oct 01, 2013 at 01:19:06PM +0200, Paolo Bonzini wrote: Anyhow, I would like to know more about this hwrng and hypercall. Does the hwrng return random numbers (like rdrand) or real entropy (like rdseed that Intel will add in Broadwell)?

Re: [PATCH 3/3] KVM: PPC: Book3S: Add support for hwrng found on some powernv systems

2013-10-02 Thread Benjamin Herrenschmidt
On Wed, 2013-10-02 at 10:46 +0200, Paolo Bonzini wrote: Thanks. Any chance you can give some numbers of a kernel hypercall and a userspace hypercall on Power, so we have actual data? For example a hypercall that returns H_PARAMETER as soon as possible. I don't have (yet) numbers at hand

Re: [PATCH 3/3] KVM: PPC: Book3S: Add support for hwrng found on some powernv systems

2013-10-02 Thread Alexander Graf
On 02.10.2013, at 11:06, Benjamin Herrenschmidt wrote: On Wed, 2013-10-02 at 10:46 +0200, Paolo Bonzini wrote: Thanks. Any chance you can give some numbers of a kernel hypercall and a userspace hypercall on Power, so we have actual data? For example a hypercall that returns H_PARAMETER

Re: [PATCH 3/3] KVM: PPC: Book3S: Add support for hwrng found on some powernv systems

2013-10-02 Thread Alexander Graf
On 02.10.2013, at 11:11, Alexander Graf wrote: On 02.10.2013, at 11:06, Benjamin Herrenschmidt wrote: On Wed, 2013-10-02 at 10:46 +0200, Paolo Bonzini wrote: Thanks. Any chance you can give some numbers of a kernel hypercall and a userspace hypercall on Power, so we have actual

Re: [PATCH 3/3] KVM: PPC: Book3S: Add support for hwrng found on some powernv systems

2013-10-02 Thread Gleb Natapov
On Wed, Oct 02, 2013 at 11:50:50AM +0200, Alexander Graf wrote: On 02.10.2013, at 11:11, Alexander Graf wrote: On 02.10.2013, at 11:06, Benjamin Herrenschmidt wrote: On Wed, 2013-10-02 at 10:46 +0200, Paolo Bonzini wrote: Thanks. Any chance you can give some numbers of a

Re: [PATCH 3/3] KVM: PPC: Book3S: Add support for hwrng found on some powernv systems

2013-10-02 Thread Michael Ellerman
On Wed, 2013-10-02 at 13:02 +0300, Gleb Natapov wrote: On Wed, Oct 02, 2013 at 11:50:50AM +0200, Alexander Graf wrote: On 02.10.2013, at 11:11, Alexander Graf wrote: So how do you solve live migration between a kernel that has this patch and one that doesn't? Yes, I alluded to it

Re: [PATCH 3/3] KVM: PPC: Book3S: Add support for hwrng found on some powernv systems

2013-10-02 Thread Alexander Graf
On 02.10.2013, at 15:57, Michael Ellerman wrote: On Wed, 2013-10-02 at 13:02 +0300, Gleb Natapov wrote: On Wed, Oct 02, 2013 at 11:50:50AM +0200, Alexander Graf wrote: On 02.10.2013, at 11:11, Alexander Graf wrote: So how do you solve live migration between a kernel that has this patch

Re: [PATCH 3/3] KVM: PPC: Book3S: Add support for hwrng found on some powernv systems

2013-10-02 Thread Gleb Natapov
On Wed, Oct 02, 2013 at 11:57:55PM +1000, Michael Ellerman wrote: On Wed, 2013-10-02 at 13:02 +0300, Gleb Natapov wrote: On Wed, Oct 02, 2013 at 11:50:50AM +0200, Alexander Graf wrote: On 02.10.2013, at 11:11, Alexander Graf wrote: So how do you solve live migration between a

Re: [PATCH 3/3] KVM: PPC: Book3S: Add support for hwrng found on some powernv systems

2013-10-02 Thread Paolo Bonzini
Il 02/10/2013 16:08, Alexander Graf ha scritto: The hwrng is accessible by host userspace via /dev/mem. A guest should live on the same permission level as a user space application. If you run QEMU as UID 1000 without access to /dev/mem, why should the guest suddenly be able to directly

Re: [PATCH 3/3] KVM: PPC: Book3S: Add support for hwrng found on some powernv systems

2013-10-02 Thread Paolo Bonzini
Il 02/10/2013 16:36, Alexander Graf ha scritto: With Michael's earlier patch in this series, the hwrng is accessible by host userspace via /dev/hwrng, no? Yes, but there's not token from user space that gets passed into the kernel to check whether access is ok or not. So while QEMU may

Re: [PATCH 3/3] KVM: PPC: Book3S: Add support for hwrng found on some powernv systems

2013-10-02 Thread Alexander Graf
On 02.10.2013, at 16:33, Paolo Bonzini wrote: Il 02/10/2013 16:08, Alexander Graf ha scritto: The hwrng is accessible by host userspace via /dev/mem. A guest should live on the same permission level as a user space application. If you run QEMU as UID 1000 without access to /dev/mem, why

Re: [PATCH 3/3] KVM: PPC: Book3S: Add support for hwrng found on some powernv systems

2013-10-02 Thread Gleb Natapov
On Wed, Oct 02, 2013 at 04:33:18PM +0200, Paolo Bonzini wrote: Il 02/10/2013 16:08, Alexander Graf ha scritto: The hwrng is accessible by host userspace via /dev/mem. A guest should live on the same permission level as a user space application. If you run QEMU as UID 1000 without access

Re: [PATCH 3/3] KVM: PPC: Book3S: Add support for hwrng found on some powernv systems

2013-10-02 Thread Benjamin Herrenschmidt
On Wed, 2013-10-02 at 11:11 +0200, Alexander Graf wrote: Right, and the difference for the patch in question is really whether we handle in in kernel virtual mode or in QEMU, so the bulk of the overhead (kicking threads out of guest context, switching MMU context, etc) happens either way.

Re: [PATCH 3/3] KVM: PPC: Book3S: Add support for hwrng found on some powernv systems

2013-10-02 Thread Benjamin Herrenschmidt
On Wed, 2013-10-02 at 13:02 +0300, Gleb Natapov wrote: Yes, I alluded to it in my email to Paul and Paolo asked also. How this interface is disabled? Also hwrnd is MMIO in a host why guest needs to use hypercall instead of emulating the device (in kernel or somewhere else?). Migration will

Re: [PATCH 3/3] KVM: PPC: Book3S: Add support for hwrng found on some powernv systems

2013-10-02 Thread Benjamin Herrenschmidt
On Wed, 2013-10-02 at 13:02 +0300, Gleb Natapov wrote: Yes, I alluded to it in my email to Paul and Paolo asked also. How this interface is disabled? Also hwrnd is MMIO in a host why guest needs to use hypercall instead of emulating the device (in kernel or somewhere else?). Another things is

Re: [PATCH 3/3] KVM: PPC: Book3S: Add support for hwrng found on some powernv systems

2013-10-02 Thread Benjamin Herrenschmidt
On Wed, 2013-10-02 at 16:08 +0200, Alexander Graf wrote: A guest should live on the same permission level as a user space application. If you run QEMU as UID 1000 without access to /dev/mem, why should the guest suddenly be able to directly access a memory location (MMIO) it couldn't access

Re: [PATCH 3/3] KVM: PPC: Book3S: Add support for hwrng found on some powernv systems

2013-10-02 Thread Benjamin Herrenschmidt
On Wed, 2013-10-02 at 17:37 +0300, Gleb Natapov wrote: On Wed, Oct 02, 2013 at 04:33:18PM +0200, Paolo Bonzini wrote: Il 02/10/2013 16:08, Alexander Graf ha scritto: The hwrng is accessible by host userspace via /dev/mem. A guest should live on the same permission level as a user

Re: [PATCH 3/3] KVM: PPC: Book3S: Add support for hwrng found on some powernv systems

2013-10-02 Thread Paul Mackerras
On Wed, Oct 02, 2013 at 04:36:05PM +0200, Alexander Graf wrote: On 02.10.2013, at 16:33, Paolo Bonzini wrote: Il 02/10/2013 16:08, Alexander Graf ha scritto: The hwrng is accessible by host userspace via /dev/mem. A guest should live on the same permission level as a user space

Re: [PATCH 3/3] KVM: PPC: Book3S: Add support for hwrng found on some powernv systems

2013-10-02 Thread Gleb Natapov
On Thu, Oct 03, 2013 at 08:02:20AM +1000, Benjamin Herrenschmidt wrote: On Wed, 2013-10-02 at 13:02 +0300, Gleb Natapov wrote: Yes, I alluded to it in my email to Paul and Paolo asked also. How this interface is disabled? Also hwrnd is MMIO in a host why guest needs to use hypercall

Re: [PATCH 3/3] KVM: PPC: Book3S: Add support for hwrng found on some powernv systems

2013-10-02 Thread Gleb Natapov
On Thu, Oct 03, 2013 at 08:45:42AM +1000, Paul Mackerras wrote: On Wed, Oct 02, 2013 at 04:36:05PM +0200, Alexander Graf wrote: On 02.10.2013, at 16:33, Paolo Bonzini wrote: Il 02/10/2013 16:08, Alexander Graf ha scritto: The hwrng is accessible by host userspace via /dev/mem.

Re: [PATCH 3/3] KVM: PPC: Book3S: Add support for hwrng found on some powernv systems

2013-10-01 Thread Michael Ellerman
On Thu, Sep 26, 2013 at 11:06:59AM +0200, Paolo Bonzini wrote: Il 26/09/2013 08:31, Michael Ellerman ha scritto: Some powernv systems include a hwrng. Guests can access it via the H_RANDOM hcall. Is there any reason to do this in the kernel? It's less code, and it's faster :) It does

Re: [PATCH 3/3] KVM: PPC: Book3S: Add support for hwrng found on some powernv systems

2013-10-01 Thread Michael Ellerman
On Fri, Sep 27, 2013 at 07:45:45PM +0530, Anshuman Khandual wrote: On 09/26/2013 12:01 PM, Michael Ellerman wrote: +int powernv_hwrng_present(void) +{ + return __raw_get_cpu_var(powernv_rng) != NULL; +} + static unsigned long rng_whiten(struct powernv_rng *rng, unsigned long val)

Re: [PATCH 3/3] KVM: PPC: Book3S: Add support for hwrng found on some powernv systems

2013-10-01 Thread Gleb Natapov
On Tue, Oct 01, 2013 at 06:34:26PM +1000, Michael Ellerman wrote: On Thu, Sep 26, 2013 at 11:06:59AM +0200, Paolo Bonzini wrote: Il 26/09/2013 08:31, Michael Ellerman ha scritto: Some powernv systems include a hwrng. Guests can access it via the H_RANDOM hcall. Is there any reason to

Re: [PATCH 3/3] KVM: PPC: Book3S: Add support for hwrng found on some powernv systems

2013-10-01 Thread Paul Mackerras
On Tue, Oct 01, 2013 at 11:39:08AM +0300, Gleb Natapov wrote: On Tue, Oct 01, 2013 at 06:34:26PM +1000, Michael Ellerman wrote: On Thu, Sep 26, 2013 at 11:06:59AM +0200, Paolo Bonzini wrote: Il 26/09/2013 08:31, Michael Ellerman ha scritto: Some powernv systems include a hwrng. Guests

Re: [PATCH 3/3] KVM: PPC: Book3S: Add support for hwrng found on some powernv systems

2013-10-01 Thread Benjamin Herrenschmidt
On Tue, 2013-10-01 at 11:39 +0300, Gleb Natapov wrote: On Tue, Oct 01, 2013 at 06:34:26PM +1000, Michael Ellerman wrote: On Thu, Sep 26, 2013 at 11:06:59AM +0200, Paolo Bonzini wrote: Il 26/09/2013 08:31, Michael Ellerman ha scritto: Some powernv systems include a hwrng. Guests can

Re: [PATCH 3/3] KVM: PPC: Book3S: Add support for hwrng found on some powernv systems

2013-10-01 Thread Paolo Bonzini
Il 01/10/2013 10:34, Michael Ellerman ha scritto: If you really want to have the hypercall, implementing it in QEMU means that you can support it on all systems, in fact even when running without KVM. Sure, I can add a fallback to /dev/hwrng for full emulation. The QEMU command line

Re: [PATCH 3/3] KVM: PPC: Book3S: Add support for hwrng found on some powernv systems

2013-10-01 Thread Gleb Natapov
On Tue, Oct 01, 2013 at 07:23:20PM +1000, Paul Mackerras wrote: On Tue, Oct 01, 2013 at 11:39:08AM +0300, Gleb Natapov wrote: On Tue, Oct 01, 2013 at 06:34:26PM +1000, Michael Ellerman wrote: On Thu, Sep 26, 2013 at 11:06:59AM +0200, Paolo Bonzini wrote: Il 26/09/2013 08:31, Michael

Re: [PATCH 3/3] KVM: PPC: Book3S: Add support for hwrng found on some powernv systems

2013-10-01 Thread Alexander Graf
On 10/01/2013 11:23 AM, Paul Mackerras wrote: On Tue, Oct 01, 2013 at 11:39:08AM +0300, Gleb Natapov wrote: On Tue, Oct 01, 2013 at 06:34:26PM +1000, Michael Ellerman wrote: On Thu, Sep 26, 2013 at 11:06:59AM +0200, Paolo Bonzini wrote: Il 26/09/2013 08:31, Michael Ellerman ha scritto: Some

Re: [PATCH 3/3] KVM: PPC: Book3S: Add support for hwrng found on some powernv systems

2013-10-01 Thread Paolo Bonzini
Il 01/10/2013 11:38, Benjamin Herrenschmidt ha scritto: So for the sake of that dogma you are going to make us do something that is about 100 times slower ? (and possibly involves more lines of code) If it's 100 times slower there is something else that's wrong. It's most likely not 100 times

Re: [PATCH 3/3] KVM: PPC: Book3S: Add support for hwrng found on some powernv systems

2013-10-01 Thread Benjamin Herrenschmidt
On Tue, 2013-10-01 at 13:19 +0200, Paolo Bonzini wrote: Il 01/10/2013 11:38, Benjamin Herrenschmidt ha scritto: So for the sake of that dogma you are going to make us do something that is about 100 times slower ? (and possibly involves more lines of code) If it's 100 times slower there is

Re: [PATCH 3/3] KVM: PPC: Book3S: Add support for hwrng found on some powernv systems

2013-10-01 Thread Paul Mackerras
On Tue, Oct 01, 2013 at 01:19:06PM +0200, Paolo Bonzini wrote: Anyhow, I would like to know more about this hwrng and hypercall. Does the hwrng return random numbers (like rdrand) or real entropy (like rdseed that Intel will add in Broadwell)? What about the hypercall? Well, firstly, your

Re: [PATCH 3/3] KVM: PPC: Book3S: Add support for hwrng found on some powernv systems

2013-09-27 Thread Anshuman Khandual
On 09/26/2013 12:01 PM, Michael Ellerman wrote: +int powernv_hwrng_present(void) +{ + return __raw_get_cpu_var(powernv_rng) != NULL; +} + static unsigned long rng_whiten(struct powernv_rng *rng, unsigned long val) { unsigned long parity; @@ -42,6 +48,17 @@ static unsigned long

Re: [PATCH 3/3] KVM: PPC: Book3S: Add support for hwrng found on some powernv systems

2013-09-26 Thread Paolo Bonzini
Il 26/09/2013 08:31, Michael Ellerman ha scritto: Some powernv systems include a hwrng. Guests can access it via the H_RANDOM hcall. We add a real mode implementation of H_RANDOM when a hwrng is found. Userspace can detect the presence of the hwrng by quering the KVM_CAP_PPC_HWRNG