Re: [PATCH 20/30] KVM: MIPS/MMU: Invalidate GVA PTs on ASID changes

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

 



Hi,

On Wed, Jan 11, 2017 at 11:54:36AM +0800, jiang.biao2@xxxxxxxxxx wrote:
> > +void kvm_mips_flush_gva_pt(pgd_t *pgd, enum kvm_mips_flush flags)
> > +{
>
> > +    if (flags & KMF_GPA) {
>
> > +        /* all of guest virtual address space could be affected */
> > +        if (flags & KMF_KERN)
> > +            /* useg, kseg0, seg2/3 */
> > +            kvm_mips_flush_gva_pgd(pgd, 0, 0x7fffffff)
> > +        else
> > +            /* useg */
> > +            kvm_mips_flush_gva_pgd(pgd, 0, 0x3fffffff)
> > +    } else {
> > +        /* useg */
> > +        kvm_mips_flush_gva_pgd(pgd, 0, 0x3fffffff)
> > +
> > +        /* kseg2/3 */
> > +        if (flags & KMF_KERN)
> > +            kvm_mips_flush_gva_pgd(pgd, 0x60000000, 0x7fffffff)
> > +    }
> > +}
>
>
>
>
> Is it maybe better to replace the hard code *0x7fffffff*, *0x60000000*, *0x3fffffff* with marco?

I did consider it. E.g. there are definitions in kvm_host.h:

#define KVM_GUEST_KUSEG			0x00000000UL
#define KVM_GUEST_KSEG0			0x40000000UL
#define KVM_GUEST_KSEG1			0x40000000UL
#define KVM_GUEST_KSEG23		0x60000000UL

and conditional definitions in asm/addrspace.h:

64-bit:
#define CKSEG0				_CONST64_(0xffffffff80000000)
#define CKSEG1				_CONST64_(0xffffffffa0000000)
#define CKSSEG				_CONST64_(0xffffffffc0000000)
#define CKSEG3				_CONST64_(0xffffffffe0000000)

32-bit:
#define KUSEG				0x00000000
#define KSEG0				0x80000000
#define KSEG1				0xa0000000
#define KSEG2				0xc0000000
#define KSEG3				0xe0000000

#define CKUSEG				0x00000000
#define CKSEG0				0x80000000
#define CKSEG1				0xa0000000
#define CKSEG2				0xc0000000
#define CKSEG3				0xe0000000

So (u32)CKSEG0 - 1, KVM_GUEST_KSEG23, and KVM_GUEST_KSEG0 - 1 would have
worked, but given that the ranges sometimes cover multiple segments it
just seemed more readable to use the hex literals rather than a
sprinkling of opaque definitions from different places.

Thanks for reviewing!

Cheers
James




[Index of Archives]     [Linux MIPS Home]     [LKML Archive]     [Linux ARM Kernel]     [Linux ARM]     [Linux]     [Git]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux