Skip to contentSkip to conversation

Pass PVR in sregs

PATCH In review Alexander Graf 4 participants 9 messages Jul 7, 2009 – Sep 11, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/23 Pass PVR in sregs

Right now sregs is unused on PPC, so we can use it for initialization of the CPU.

KVM on BookE always virtualizes the host CPU. On PPC64 we go a step further and take the PVR from userspace that tells us what kind of CPU we are supposed to virtualize, because we support PPC32 and PPC64 guests.

In order to get that information, we use the sregs ioctl, because we don't want to reset the guest CPU on every normal register set.

---
 arch/powerpc/include/asm/kvm.h |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
arch/powerpc/include/asm/kvm.h +1 -0
index bb2de6a..96b02cd 100644
@@ -46,6 +46,7 @@ struct kvm_regs {
 };
 
 struct kvm_sregs {
+	__u64 pvr;
 };
 
 struct kvm_fpu {
Signature · 1 line
1.6.0.2
#1 lore raw
Quoted 20 lines · Alexander Graf

Right now sregs is unused on PPC, so we can use it for initialization of the CPU.

KVM on BookE always virtualizes the host CPU. On PPC64 we go a step further and take the PVR from userspace that tells us what kind of CPU we are supposed to virtualize, because we support PPC32 and PPC64 guests.

In order to get that information, we use the sregs ioctl, because we don't want to reset the guest CPU on every normal register set.

---
  arch/powerpc/include/asm/kvm.h |    1 +
  1 files changed, 1 insertions(+), 0 deletions(-)
arch/powerpc/include/asm/kvm.h +0 -0
index bb2de6a..96b02cd 100644

arch/powerpc/include/asm/kvm.h struct kvm_regs { · line 51

Quoted 6 lines
arch/powerpc/include/asm/kvm.h +1 -0
@@ -46,6 +46,7 @@ struct kvm_regs {
  };
 
  struct kvm_sregs {
+	__u64 pvr;
  };
 

You can only do that if existing userspace never calls KVM_SET_SREGS. Hollis?

Also, make sure to reserve a bunch of space in there so you if you forget something you can add it later.

Signature · 1 line
error compiling committee.c: too many arguments to function
#2 lore raw
In reply to Alexander Graf
Quoted 23 lines · Avi Kivity
Quoted 22 lines · Alexander Graf

Right now sregs is unused on PPC, so we can use it for initialization of the CPU.

KVM on BookE always virtualizes the host CPU. On PPC64 we go a step further and take the PVR from userspace that tells us what kind of CPU we are supposed to virtualize, because we support PPC32 and PPC64 guests.

In order to get that information, we use the sregs ioctl, because we don't want to reset the guest CPU on every normal register set.

---
  arch/powerpc/include/asm/kvm.h |    1 +
  1 files changed, 1 insertions(+), 0 deletions(-)
arch/powerpc/include/asm/kvm.h +0 -0
index bb2de6a..96b02cd 100644
@@ -46,6 +46,7 @@ struct kvm_regs {
  };
 
Quoted 7 lines

arch/powerpc/include/asm/kvm.h struct kvm_regs { · line 51

Quoted 4 lines
arch/powerpc/include/asm/kvm.h +1 -0
  struct kvm_sregs {
+	__u64 pvr;
  };
 

You can only do that if existing userspace never calls KVM_SET_SREGS. Hollis?

It doesn't.

Quoted 2 lines

Also, make sure to reserve a bunch of space in there so you if you forget something you can add it later.

Agreed.

The PVR register is basically the equivalent of cpuid. It might make more sense to exit to qemu to handle those accesses. Today, PVR reads are emulated in-kernel.

Hmm, I don't remember where arch->vcpu.pvr is being set at all for 440 and e500...

Signature · 2 lines
Hollis Blanchard
IBM Linux Technology Center
#3 lore raw
In reply to Alexander Graf
Quoted 39 lines · Hollis Blanchard
Quoted 28 lines · Avi Kivity
Quoted 27 lines · Alexander Graf

Right now sregs is unused on PPC, so we can use it for initialization
of the CPU.

KVM on BookE always virtualizes the host CPU. On PPC64 we go a step further
and take the PVR from userspace that tells us what kind of CPU we are supposed
to virtualize, because we support PPC32 and PPC64 guests.

In order to get that information, we use the sregs ioctl, because we don't
want to reset the guest CPU on every normal register set.

---
 arch/powerpc/include/asm/kvm.h |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
arch/powerpc/include/ renamed from arch/powerpc/include/asm/kvm.h +0 -0

asm/kvm.h
index bb2de6a..96b02cd 100644

arch/powerpc/include/asm/kvm.h +0 -0
@@ -46,6 +46,7 @@ struct kvm_regs {
 };
 
Quoted 7 lines

arch/powerpc/include/asm/kvm.h struct kvm_regs { · line 51

Quoted 4 lines
arch/powerpc/include/asm/kvm.h +1 -0
 struct kvm_sregs {
+	__u64 pvr;
 };
 

You can only do that if existing userspace never calls KVM_SET_SREGS. Hollis?

It doesn't.

Quoted 8 lines
Quoted 2 lines

Also, make sure to reserve a bunch of space in there so you if you forget something you can add it later.

Agreed.

The PVR register is basically the equivalent of cpuid. It might make more sense to exit to qemu to handle those accesses. Today, PVR reads are emulated in-kernel.

I actually use it in 970.c to find out which guest MMU to choose from. So even if we were to do it in userspace, we'd still need the information what CPU to create in the guest on the kernel side. Which in turn means we don't win anything from leaving the PVR emulation to userspace.

Quoted 2 lines

Hmm, I don't remember where arch->vcpu.pvr is being set at all for 440 and e500...

It used to be in some creation code - either general kvm or vcpu. But some recent patch removed vcpu->arch.pvr and made emulate.c do an mfspr(SPRN_PVR).

Alex

#4 lore raw
In reply to Alexander Graf
Quoted 27 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Alexander Graf
Sent: Wednesday, July 08, 2009 7:23 AM
To: Hollis Blanchard
Cc: Avi Kivity; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 01/23] Pass PVR in sregs

Quoted 3 lines · Hollis Blanchard

The PVR register is basically the equivalent of cpuid. It might make more sense to exit to qemu to handle those accesses. Today,

PVR reads

Quoted 1 line

are emulated in-kernel.

I actually use it in 970.c to find out which guest MMU to choose from. So even if we were to do it in userspace, we'd still need the information what CPU to create in the guest on the kernel side. Which
in turn means we don't win anything from leaving the PVR emulation to
userspace.

Quoted 9 lines
Quoted 1 line

Hmm, I don't remember where arch->vcpu.pvr is being set at

all for 440

Quoted 1 line

and e500...

It used to be in some creation code - either general kvm or vcpu. But
some recent patch removed vcpu->arch.pvr and made emulate.c do an mfspr(SPRN_PVR).

Yes. Since the demand to emulate PVR for 440 and e500 is still vague. Directly return the real value can simplify the code, and latter patches can easily change it.
The same thing goes for PIR.

#5 lore raw
In reply to Alexander Graf
Quoted 36 lines · On Wed, 2009-07-08 at 10:28 +0800, Liu Yu-B13201 wrote:
Quoted 26 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Alexander Graf
Sent: Wednesday, July 08, 2009 7:23 AM
To: Hollis Blanchard
Cc: Avi Kivity; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 01/23] Pass PVR in sregs

Quoted 3 lines · Hollis Blanchard

The PVR register is basically the equivalent of cpuid. It might make more sense to exit to qemu to handle those accesses. Today,

PVR reads

Quoted 1 line

are emulated in-kernel.

I actually use it in 970.c to find out which guest MMU to choose from. So even if we were to do it in userspace, we'd still need the information what CPU to create in the guest on the kernel side. Which
in turn means we don't win anything from leaving the PVR emulation to
userspace.

Quoted 9 lines
Quoted 1 line

Hmm, I don't remember where arch->vcpu.pvr is being set at

all for 440

Quoted 1 line

and e500...

It used to be in some creation code - either general kvm or vcpu. But
some recent patch removed vcpu->arch.pvr and made emulate.c do an mfspr(SPRN_PVR).

Quoted 4 lines

Yes. Since the demand to emulate PVR for 440 and e500 is still vague. Directly return the real value can simplify the code, and latter patches can easily change it.
The same thing goes for PIR.

By the way, I don't like that PVR patch you sent to Avi (and he committed). It's my own fault for not reading more closely, but in the future could you send me patches that touch code which isn't e500-specific?

Signature · 2 lines
Hollis Blanchard
IBM Linux Technology Center
#6 lore raw
In reply to Alexander Graf
Quoted 54 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Hollis Blanchard
Sent: Friday, July 10, 2009 8:52 AM
To: Liu Yu-B13201
Cc: Alexander Graf; Avi Kivity; [email protected]; [email protected]; [email protected]
Subject: RE: [PATCH 01/23] Pass PVR in sregs

Quoted 11 lines · On Wed, 2009-07-08 at 10:28 +0800, Liu Yu-B13201 wrote:
Quoted 11 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Alexander Graf
Sent: Wednesday, July 08, 2009 7:23 AM
To: Hollis Blanchard
Cc: Avi Kivity; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 01/23] Pass PVR in sregs

Quoted 3 lines
Quoted 3 lines · Hollis Blanchard
Quoted 2 lines

The PVR register is basically the equivalent of cpuid.

It might make

Quoted 5 lines
Quoted 5 lines
Quoted 1 line

more sense to exit to qemu to handle those accesses. Today,

PVR reads

Quoted 1 line

are emulated in-kernel.

I actually use it in 970.c to find out which guest MMU to

choose from.

Quoted 7 lines
Quoted 7 lines

So even if we were to do it in userspace, we'd still need the information what CPU to create in the guest on the kernel side. Which
in turn means we don't win anything from leaving the PVR emulation to
userspace.

Quoted 7 lines
Quoted 7 lines
Quoted 1 line

Hmm, I don't remember where arch->vcpu.pvr is being set at

all for 440

Quoted 1 line

and e500...

It used to be in some creation code - either general kvm or vcpu. But
some recent patch removed vcpu->arch.pvr and made

emulate.c do an

Quoted 4 lines
Quoted 2 lines

mfspr(SPRN_PVR).

Yes. Since the demand to emulate PVR for 440 and e500 is

still vague.

Quoted 1 line

Directly return the real value can simplify the code, and

Quoted 9 lines

latter patches

Quoted 2 lines

can easily change it.
The same thing goes for PIR.

By the way, I don't like that PVR patch you sent to Avi (and he committed). It's my own fault for not reading more closely, but in the future could you send me patches that touch code which isn't e500-specific?

OK.

#7 lore raw

PATCH 1/23 Pass PVR in sregs

In reply to Alexander Graf

Right now sregs is unused on PPC, so we can use it for initialization of the CPU.

KVM on BookE always virtualizes the host CPU. On Book3s we go a step further and take the PVR from userspace that tells us what kind of CPU we are supposed to virtualize, because we support Book3s_32 and Book3s_64 guests.

In order to get that information, we use the sregs ioctl, because we don't want to reset the guest CPU on every normal register set.

---
 arch/powerpc/include/asm/kvm.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
arch/powerpc/include/asm/kvm.h +2 -0
index bb2de6a..b82bd68 100644
@@ -46,6 +46,8 @@ struct kvm_regs {
 };
 
 struct kvm_sregs {
+	__u64 pvr;
+	char pad[1016];
 };
 
 struct kvm_fpu {
Signature · 1 line
1.6.0.2
#8 lore raw
In reply to Alexander Graf

Hi Avi, would you apply this patch? Looks like the corresponding qemu patch went in a while ago, so the qemu build has been broken for some time.

Signature · 2 lines
Hollis Blanchard
IBM Linux Technology Center
Quoted 28 lines · Alexander Graf

Right now sregs is unused on PPC, so we can use it for initialization of the CPU.

KVM on BookE always virtualizes the host CPU. On Book3s we go a step further and take the PVR from userspace that tells us what kind of CPU we are supposed to virtualize, because we support Book3s_32 and Book3s_64 guests.

In order to get that information, we use the sregs ioctl, because we don't want to reset the guest CPU on every normal register set.

---
 arch/powerpc/include/asm/kvm.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
arch/powerpc/include/asm/kvm.h +2 -0
index bb2de6a..b82bd68 100644
@@ -46,6 +46,8 @@ struct kvm_regs {
 };
 
 struct kvm_sregs {
+	__u64 pvr;
+	char pad[1016];
 };
 
 struct kvm_fpu {