Re: [PATCH 3/5] KVM: PPC: Paravirtualize SPRG4-7, ESR, PIR, MASn

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 27.08.2011, at 01:31, Scott Wood wrote:

> Signed-off-by: Scott Wood <scottwood@xxxxxxxxxxxxx>

Patch description missing.

> ---
> arch/powerpc/include/asm/kvm_e500.h |    8 --
> arch/powerpc/include/asm/kvm_host.h |    2 -
> arch/powerpc/include/asm/kvm_para.h |   28 +++++-
> arch/powerpc/kernel/asm-offsets.c   |    9 ++
> arch/powerpc/kernel/kvm.c           |  201 +++++++++++++++++++++++++++++------
> arch/powerpc/kvm/booke.c            |    7 +-
> arch/powerpc/kvm/booke_emulate.c    |    4 +-
> arch/powerpc/kvm/e500.c             |   24 ++--
> arch/powerpc/kvm/e500_emulate.c     |   38 ++++---
> arch/powerpc/kvm/e500_tlb.c         |   83 ++++++++-------
> arch/powerpc/kvm/e500_tlb.h         |   25 ++---
> arch/powerpc/kvm/emulate.c          |    3 +-
> arch/powerpc/kvm/powerpc.c          |    2 +-
> 13 files changed, 299 insertions(+), 135 deletions(-)
> 
> diff --git a/arch/powerpc/include/asm/kvm_e500.h b/arch/powerpc/include/asm/kvm_e500.h
> index bc17441..8cd50a5 100644
> --- a/arch/powerpc/include/asm/kvm_e500.h
> +++ b/arch/powerpc/include/asm/kvm_e500.h
> @@ -71,14 +71,6 @@ struct kvmppc_vcpu_e500 {
> 	u32 pid[E500_PID_NUM];
> 	u32 svr;
> 
> -	u32 mas0;
> -	u32 mas1;
> -	u32 mas2;
> -	u64 mas7_3;
> -	u32 mas4;
> -	u32 mas5;
> -	u32 mas6;
> -
> 	/* vcpu id table */
> 	struct vcpu_id_table *idt;
> 
> diff --git a/arch/powerpc/include/asm/kvm_host.h b/arch/powerpc/include/asm/kvm_host.h
> index cc22b28..3305af4 100644
> --- a/arch/powerpc/include/asm/kvm_host.h
> +++ b/arch/powerpc/include/asm/kvm_host.h
> @@ -329,7 +329,6 @@ struct kvm_vcpu_arch {
> 	ulong mcsrr0;
> 	ulong mcsrr1;
> 	ulong mcsr;
> -	ulong esr;
> 	u32 dec;
> 	u32 decar;
> 	u32 tbl;
> @@ -338,7 +337,6 @@ struct kvm_vcpu_arch {
> 	u32 tsr;
> 	u32 ivor[64];
> 	ulong ivpr;
> -	u32 pir;
> 	u32 pvr;
> 
> 	u32 shadow_pid;
> diff --git a/arch/powerpc/include/asm/kvm_para.h b/arch/powerpc/include/asm/kvm_para.h
> index 50533f9..e04b4a5 100644
> --- a/arch/powerpc/include/asm/kvm_para.h
> +++ b/arch/powerpc/include/asm/kvm_para.h
> @@ -33,11 +33,32 @@ struct kvm_vcpu_arch_shared {
> 	__u64 sprg3;
> 	__u64 srr0;
> 	__u64 srr1;
> -	__u64 dar;
> +	__u64 dar;		/* dear on BookE */
> 	__u64 msr;
> 	__u32 dsisr;
> 	__u32 int_pending;	/* Tells the guest if we have an interrupt */
> 	__u32 sr[16];
> +	__u32 mas0;
> +	__u32 mas1;
> +	__u64 mas7_3;
> +	__u64 mas2;
> +	__u32 mas4;
> +	__u32 mas6;
> +	__u32 esr;
> +	__u32 pir;
> +
> +	/*
> +	 * SPRG4-7 are user-readable, so we can't keep these
> +	 * consistent between the magic page and the real
> +	 * registers.  We provide space in case the guest
> +	 * can deal with this.
> +	 *
> +	 * This also applies to SPRG3 on some chips.
> +	 */
> +	__u64 sprg4;
> +	__u64 sprg5;
> +	__u64 sprg6;
> +	__u64 sprg7;

Hrm. You're touching sprg4-7 but don't remove the fields from vcpu->arch. That sounds wrong. Also, the entry/exit code needs to use these now instead of the vcpu struct fields to restore the correct values.

> };
> 
> #define KVM_SC_MAGIC_R0		0x4b564d21 /* "KVM!" */
> @@ -47,7 +68,10 @@ struct kvm_vcpu_arch_shared {
> 
> #define KVM_FEATURE_MAGIC_PAGE	1
> 
> -#define KVM_MAGIC_FEAT_SR	(1 << 0)
> +#define KVM_MAGIC_FEAT_SR		(1 << 0)
> +
> +/* MASn, ESR, PIR, and high SPRGs */
> +#define KVM_MAGIC_FEAT_MAS0_TO_SPRG7	(1 << 1)
> 
> #ifdef __KERNEL__
> 
> diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c
> index 5f078bc..34da20d 100644
> --- a/arch/powerpc/kernel/asm-offsets.c
> +++ b/arch/powerpc/kernel/asm-offsets.c
> @@ -431,6 +431,15 @@ int main(void)
> 	DEFINE(VCPU_SHARED_MSR, offsetof(struct kvm_vcpu_arch_shared, msr));
> 	DEFINE(VCPU_SHADOW_MSR, offsetof(struct kvm_vcpu, arch.shadow_msr));
> 
> +#ifdef CONFIG_FSL_BOOKE
> +	DEFINE(VCPU_SHARED_MAS0, offsetof(struct kvm_vcpu_arch_shared, mas0));
> +	DEFINE(VCPU_SHARED_MAS1, offsetof(struct kvm_vcpu_arch_shared, mas1));
> +	DEFINE(VCPU_SHARED_MAS2, offsetof(struct kvm_vcpu_arch_shared, mas2));
> +	DEFINE(VCPU_SHARED_MAS7_3, offsetof(struct kvm_vcpu_arch_shared, mas7_3));
> +	DEFINE(VCPU_SHARED_MAS4, offsetof(struct kvm_vcpu_arch_shared, mas4));
> +	DEFINE(VCPU_SHARED_MAS6, offsetof(struct kvm_vcpu_arch_shared, mas6));
> +#endif

While I agree that they only make sense on BookE, the fields in the ABI are not #ifdef'ed, so I don't see why the asm-offsets fields should be.

> +
> 	/* book3s */
> #ifdef CONFIG_KVM_BOOK3S_64_HV
> 	DEFINE(KVM_LPID, offsetof(struct kvm, arch.lpid));
> diff --git a/arch/powerpc/kernel/kvm.c b/arch/powerpc/kernel/kvm.c
> index e50c683..eb95a03 100644
> --- a/arch/powerpc/kernel/kvm.c
> +++ b/arch/powerpc/kernel/kvm.c
> @@ -48,23 +48,14 @@
> #define KVM_RT_30		0x03c00000
> #define KVM_MASK_RB		0x0000f800
> #define KVM_INST_MFMSR		0x7c0000a6
> -#define KVM_INST_MFSPR_SPRG0	0x7c1042a6
> -#define KVM_INST_MFSPR_SPRG1	0x7c1142a6
> -#define KVM_INST_MFSPR_SPRG2	0x7c1242a6
> -#define KVM_INST_MFSPR_SPRG3	0x7c1342a6
> -#define KVM_INST_MFSPR_SRR0	0x7c1a02a6
> -#define KVM_INST_MFSPR_SRR1	0x7c1b02a6
> -#define KVM_INST_MFSPR_DAR	0x7c1302a6
> -#define KVM_INST_MFSPR_DSISR	0x7c1202a6
> -
> -#define KVM_INST_MTSPR_SPRG0	0x7c1043a6
> -#define KVM_INST_MTSPR_SPRG1	0x7c1143a6
> -#define KVM_INST_MTSPR_SPRG2	0x7c1243a6
> -#define KVM_INST_MTSPR_SPRG3	0x7c1343a6
> -#define KVM_INST_MTSPR_SRR0	0x7c1a03a6
> -#define KVM_INST_MTSPR_SRR1	0x7c1b03a6
> -#define KVM_INST_MTSPR_DAR	0x7c1303a6
> -#define KVM_INST_MTSPR_DSISR	0x7c1203a6
> +
> +#define SPR_FROM		0
> +#define SPR_TO			0x100
> +
> +#define KVM_INST_SPR(sprn, moveto) (0x7c0002a6 | \
> +				    (((sprn) & 0x1f) << 16) | \
> +				    (((sprn) & 0x3e0) << 6) | \
> +				    (moveto))

#define KVM_INST_MFSPR(sprn) KVM_INST_MFSPR(sprn, SPR_FROM)
#define KVM_INST_MTSPR(sprn) KVM_INST_MFSPR(sprn, SPR_TO)

makes it more readable really :)
> 
> 

[...]

> @@ -618,6 +618,7 @@ int kvm_arch_vcpu_setup(struct kvm_vcpu *vcpu)
> 	vcpu->arch.pc = 0;
> 	vcpu->arch.shared->msr = 0;
> 	vcpu->arch.shadow_msr = MSR_USER | MSR_DE | MSR_IS | MSR_DS;
> +	vcpu->arch.shared->pir = vcpu->vcpu_id;

That one rings a bell. Are you sure this patch set is on top of the other one that fixes PIR?


Alex

--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM Development]     [KVM ARM]     [KVM ia64]     [Linux Virtualization]     [Linux USB Devel]     [Linux Video]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux