Skip to contentSkip to conversation

KVM: MIPS/MMU: Invalidate GVA PTs on ASID changes

PATCH Ralf Baechle 2 participants 2 messages Jan 11, 2017 – Jan 16, 2017 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive
Quoted 33 lines · On Wed, Jan 11, 2017 at 11:54:36AM +0800, [email protected] wrote:

Date: Wed, 11 Jan 2017 11:54:36 +0800 (CST)
From: [email protected]
To: [email protected]
Cc: [email protected], [email protected], [email protected],
[email protected], [email protected], [email protected]
Subject: Re: [PATCH 20/30] KVM: MIPS/MMU: Invalidate GVA PTs on ASID changes
Content-Type: multipart/mixed; boundary="=====_001_next====="

Hi,

> +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);
> + }

Quoted 5 lines

> +}

Is it maybe better to replace the hard code *0x7fffffff*, *0x60000000*, *0x3fffffff* with marco?

I think to anybody familiar with the architecture the raw numbers are easier to understand than weird defines.

Ralf

#2 lore raw
In reply to a message not in the archive

Hi,

Quoted 25 lines · On Wed, Jan 11, 2017 at 11:54:36AM +0800, [email protected] 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)
> + }
> +}

Quoted 1 line

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