linux-mips.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: James Hogan <james.hogan@imgtec.com>
To: <jiang.biao2@zte.com.cn>
Cc: <linux-mips@linux-mips.org>, <pbonzini@redhat.com>,
	<rkrcmar@redhat.com>, <ralf@linux-mips.org>,
	<kvm@vger.kernel.org>
Subject: Re: [PATCH 20/30] KVM: MIPS/MMU: Invalidate GVA PTs on ASID changes
Date: Mon, 16 Jan 2017 16:07:23 +0000	[thread overview]
Message-ID: <20170116160723.GA19393@jhogan-linux.le.imgtec.org> (raw)
In-Reply-To: <201701111154365057441@zte.com.cn>

Hi,

On Wed, Jan 11, 2017 at 11:54:36AM +0800, jiang.biao2@zte.com.cn 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

WARNING: multiple messages have this Message-ID (diff)
From: James Hogan <james.hogan@imgtec.com>
To: jiang.biao2@zte.com.cn
Cc: linux-mips@linux-mips.org, pbonzini@redhat.com,
	rkrcmar@redhat.com, ralf@linux-mips.org, kvm@vger.kernel.org
Subject: Re: [PATCH 20/30] KVM: MIPS/MMU: Invalidate GVA PTs on ASID changes
Date: Mon, 16 Jan 2017 16:07:23 +0000	[thread overview]
Message-ID: <20170116160723.GA19393@jhogan-linux.le.imgtec.org> (raw)
Message-ID: <20170116160723.rsZYtqcftSUJxf66jeB-CE10JKgM4r2jNAramYd-7e8@z> (raw)
In-Reply-To: <201701111154365057441@zte.com.cn>

Hi,

On Wed, Jan 11, 2017 at 11:54:36AM +0800, jiang.biao2@zte.com.cn 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

  parent reply	other threads:[~2017-01-16 16:07 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <201701111154365057441@zte.com.cn>
2017-01-11  8:34 ` [PATCH 20/30] KVM: MIPS/MMU: Invalidate GVA PTs on ASID changes Ralf Baechle
2017-01-16 16:07 ` James Hogan [this message]
2017-01-16 16:07   ` James Hogan
2017-01-06  1:32 [PATCH 0/30] KVM: MIPS: Implement GVA page tables James Hogan
2017-01-06  1:32 ` [PATCH 20/30] KVM: MIPS/MMU: Invalidate GVA PTs on ASID changes James Hogan
2017-01-06  1:32   ` James Hogan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170116160723.GA19393@jhogan-linux.le.imgtec.org \
    --to=james.hogan@imgtec.com \
    --cc=jiang.biao2@zte.com.cn \
    --cc=kvm@vger.kernel.org \
    --cc=linux-mips@linux-mips.org \
    --cc=pbonzini@redhat.com \
    --cc=ralf@linux-mips.org \
    --cc=rkrcmar@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).