Skip to contentSkip to conversation

Get rid of mandatory huge page defines

PATCH Applied Christoffer Dall 2 participants 13 messages Oct 2, 2013 – Oct 14, 2013

Subsystems (10)
Arm (32-bit) x86 KVM PowerPC +6 more subsystems
lore
Share & tools
lore
#0 lore raw

cover Get rid of mandatory huge page defines

The current KVM code relies on a number of definitions to exist for each architecture:
KVM_HPAGE_GFN_SHIFT
KVM_NR_HPAGE_SIZES
KVM_PAGES_PER_HPAGE

However, these defines are only used in the gfn_to_index function, which is only used in the x86 code. This series moves the gfn_to_index function from the generic KVM code into the x86 world and gets rid of the definitions from archiectures that don't use them. s390 actually uses these values in other code, so we leave that part untouched.

Patches based on kvm/next and available here:
git://git.linaro.org/people/cdall/linux-kvm-arm.git kvm-pagesize-cleanup

Christoffer Dall (6):
KVM: Move gfn_to_index to x86 specific code
KVM: ARM: Get rid of KVM_HPAGE defines
KVM: arm64: Get rid of KVM_HPAGE defines
KVM: mips: Get rid of KVM_HPAGE defines
KVM: ia64: Get rid of KVM_HPAGE defines
KVM: PPC: Get rid of KVM_HPAGE defines

 arch/arm/include/asm/kvm_host.h     |    5 -----
 arch/arm64/include/asm/kvm_host.h   |    5 -----
 arch/ia64/include/asm/kvm_host.h    |    4 ----
 arch/mips/include/asm/kvm_host.h    |    7 -------
 arch/powerpc/include/asm/kvm_host.h |    5 -----
 arch/x86/include/asm/kvm_host.h     |    7 +++++++
 include/linux/kvm_host.h            |    7 -------
 7 files changed, 7 insertions(+), 33 deletions(-)
Signature · 1 line
1.7.10.4
#1 lore raw

PATCH 1/6 KVM: Move gfn_to_index to x86 specific code

The gfn_to_index function relies on huge page defines which either may not make sense on systems that don't support huge pages or are defined in an unconvenient way for other architectures. Since this is x86-specific, move the function to arch/x86/include/asm/kvm_host.h.

---
 arch/x86/include/asm/kvm_host.h |    7 +++++++
 include/linux/kvm_host.h        |    7 -------
 2 files changed, 7 insertions(+), 7 deletions(-)
arch/x86/include/asm/kvm_host.h +7 -0
index c76ff74..4134cf6 100644
@@ -79,6 +79,13 @@
 #define KVM_HPAGE_MASK(x)	(~(KVM_HPAGE_SIZE(x) - 1))
 #define KVM_PAGES_PER_HPAGE(x)	(KVM_HPAGE_SIZE(x) / PAGE_SIZE)
 
+static inline gfn_t gfn_to_index(gfn_t gfn, gfn_t base_gfn, int level)
+{
+	/* KVM_HPAGE_GFN_SHIFT(PT_PAGE_TABLE_LEVEL) must be 0. */
+	return (gfn >> KVM_HPAGE_GFN_SHIFT(level)) -
+		(base_gfn >> KVM_HPAGE_GFN_SHIFT(level));
+}
+
 #define SELECTOR_TI_MASK (1 << 2)
 #define SELECTOR_RPL_MASK 0x03
 
include/linux/kvm_host.h +0 -7
index ca645a0..5a1e553 100644
@@ -841,13 +841,6 @@ static inline int memslot_id(struct kvm *kvm, gfn_t gfn)
 	return gfn_to_memslot(kvm, gfn)->id;
 }
 
-static inline gfn_t gfn_to_index(gfn_t gfn, gfn_t base_gfn, int level)
-{
-	/* KVM_HPAGE_GFN_SHIFT(PT_PAGE_TABLE_LEVEL) must be 0. */
-	return (gfn >> KVM_HPAGE_GFN_SHIFT(level)) -
-		(base_gfn >> KVM_HPAGE_GFN_SHIFT(level));
-}
-
 static inline gfn_t
 hva_to_gfn_memslot(unsigned long hva, struct kvm_memory_slot *slot)
 {
Signature · 1 line
1.7.10.4
#2 lore raw

PATCH 2/6 KVM: ARM: Get rid of KVM_HPAGE defines

In reply to Christoffer Dall

The KVM_HPAGE_DEFINES are a little artificial on ARM, since the huge page size is statically defined at compile time and there is only a single huge page size.

Now when the main kvm code relying on these defines has been moved to the x86 specific part of the world, we can get rid of these.

---
 arch/arm/include/asm/kvm_host.h |    5 -----
 1 file changed, 5 deletions(-)
arch/arm/include/asm/kvm_host.h +0 -5
index 7d22517..e45a74b 100644
@@ -38,11 +38,6 @@
 
 #define KVM_VCPU_MAX_FEATURES 1
 
-/* We don't currently support large pages. */
-#define KVM_HPAGE_GFN_SHIFT(x)	0
-#define KVM_NR_PAGE_SIZES	1
-#define KVM_PAGES_PER_HPAGE(x)	(1UL<<31)
-
 #include <kvm/arm_vgic.h>
 
 struct kvm_vcpu;
Signature · 1 line
1.7.10.4
#3 lore raw

PATCH 3/6 KVM: arm64: Get rid of KVM_HPAGE defines

In reply to Christoffer Dall

Now when the main kvm code relying on these defines has been moved to the x86 specific part of the world, we can get rid of these.

---
 arch/arm64/include/asm/kvm_host.h |    5 -----
 1 file changed, 5 deletions(-)
arch/arm64/include/asm/kvm_host.h +0 -5
index 0859a4d..54c064f 100644
@@ -36,11 +36,6 @@
 
 #define KVM_VCPU_MAX_FEATURES 2
 
-/* We don't currently support large pages. */
-#define KVM_HPAGE_GFN_SHIFT(x)	0
-#define KVM_NR_PAGE_SIZES	1
-#define KVM_PAGES_PER_HPAGE(x)	(1UL<<31)
-
 struct kvm_vcpu;
 int kvm_target_cpu(void);
 int kvm_reset_vcpu(struct kvm_vcpu *vcpu);
Signature · 1 line
1.7.10.4
#4 lore raw

PATCH 4/6 KVM: mips: Get rid of KVM_HPAGE defines

In reply to Christoffer Dall

Now when the main kvm code relying on these defines has been moved to the x86 specific part of the world, we can get rid of these.

---
 arch/mips/include/asm/kvm_host.h |    7 -------
 1 file changed, 7 deletions(-)
arch/mips/include/asm/kvm_host.h +0 -7
index 4d6fa0b..3296696 100644
@@ -27,13 +27,6 @@
 
 #define KVM_COALESCED_MMIO_PAGE_OFFSET 1
 
-/* Don't support huge pages */
-#define KVM_HPAGE_GFN_SHIFT(x)	0
-
-/* We don't currently support large pages. */
-#define KVM_NR_PAGE_SIZES	1
-#define KVM_PAGES_PER_HPAGE(x)	1
-
 
 
 /* Special address that contains the comm page, used for reducing # of traps */
Signature · 1 line
1.7.10.4
#5 lore raw

PATCH 5/6 KVM: ia64: Get rid of KVM_HPAGE defines

In reply to Christoffer Dall

Now when the main kvm code relying on these defines has been moved to the x86 specific part of the world, we can get rid of these.

---
 arch/ia64/include/asm/kvm_host.h |    4 ----
 1 file changed, 4 deletions(-)
arch/ia64/include/asm/kvm_host.h +0 -4
index 989dd3f..95a3ff9 100644
@@ -234,10 +234,6 @@ struct kvm_vm_data {
 #define KVM_REQ_PTC_G		32
 #define KVM_REQ_RESUME		33
 
-#define KVM_HPAGE_GFN_SHIFT(x)	0
-#define KVM_NR_PAGE_SIZES	1
-#define KVM_PAGES_PER_HPAGE(x)	1
-
 struct kvm;
 struct kvm_vcpu;
 
Signature · 1 line
1.7.10.4
#6 lore raw

PATCH 6/6 KVM: PPC: Get rid of KVM_HPAGE defines

In reply to Christoffer Dall

Now when the main kvm code relying on these defines has been moved to the x86 specific part of the world, we can get rid of these.

---
 arch/powerpc/include/asm/kvm_host.h |    5 -----
 1 file changed, 5 deletions(-)
arch/powerpc/include/asm/kvm_host.h +0 -5
index 3328353..0866230 100644
@@ -63,11 +63,6 @@ extern void kvm_set_spte_hva(struct kvm *kvm, unsigned long hva, pte_t pte);
 
 #endif
 
-/* We don't currently support large pages. */
-#define KVM_HPAGE_GFN_SHIFT(x)	0
-#define KVM_NR_PAGE_SIZES	1
-#define KVM_PAGES_PER_HPAGE(x)	(1UL<<31)
-
 #define HPTEG_CACHE_NUM			(1 << 15)
 #define HPTEG_HASH_BITS_PTE		13
 #define HPTEG_HASH_BITS_PTE_LONG	12
Signature · 1 line
1.7.10.4
#7 lore raw
In reply to Christoffer Dall
Quoted 15 lines · Christoffer Dall

The current KVM code relies on a number of definitions to exist for each architecture:
KVM_HPAGE_GFN_SHIFT
KVM_NR_HPAGE_SIZES
KVM_PAGES_PER_HPAGE

However, these defines are only used in the gfn_to_index function, which is only used in the x86 code. This series moves the gfn_to_index function from the generic KVM code into the x86 world and gets rid of the definitions from archiectures that don't use them. s390 actually uses these values in other code, so we leave that part untouched.

Patches based on kvm/next and available here:
git://git.linaro.org/people/cdall/linux-kvm-arm.git kvm-pagesize-cleanup

Quoted 8 lines

Christoffer Dall (6):
KVM: Move gfn_to_index to x86 specific code
KVM: ARM: Get rid of KVM_HPAGE defines
KVM: arm64: Get rid of KVM_HPAGE defines
KVM: mips: Get rid of KVM_HPAGE defines
KVM: ia64: Get rid of KVM_HPAGE defines
KVM: PPC: Get rid of KVM_HPAGE defines

Any comments on this one? I'd very much like to merge huge page support for KVM/ARM during the next merge window and it depends on this series.

Thanks!
-Christoffer

#8 lore raw
Quoted 25 lines · Christoffer Dall
Quoted 15 lines · Christoffer Dall

The current KVM code relies on a number of definitions to exist for each architecture:
KVM_HPAGE_GFN_SHIFT
KVM_NR_HPAGE_SIZES
KVM_PAGES_PER_HPAGE

However, these defines are only used in the gfn_to_index function, which is only used in the x86 code. This series moves the gfn_to_index function from the generic KVM code into the x86 world and gets rid of the definitions from archiectures that don't use them. s390 actually uses these values in other code, so we leave that part untouched.

Patches based on kvm/next and available here:
git://git.linaro.org/people/cdall/linux-kvm-arm.git kvm-pagesize-cleanup

Quoted 8 lines

Christoffer Dall (6):
KVM: Move gfn_to_index to x86 specific code
KVM: ARM: Get rid of KVM_HPAGE defines
KVM: arm64: Get rid of KVM_HPAGE defines
KVM: mips: Get rid of KVM_HPAGE defines
KVM: ia64: Get rid of KVM_HPAGE defines
KVM: PPC: Get rid of KVM_HPAGE defines

Quoted 4 lines

Any comments on this one? I'd very much like to merge huge page support for KVM/ARM during the next merge window and it depends on this series.

Looks fine to me, but why have you skipped s390?

--
Gleb.

#9 lore raw
Quoted 26 lines · Gleb Natapov
Quoted 25 lines · Christoffer Dall
Quoted 23 lines · Christoffer Dall

The current KVM code relies on a number of definitions to exist for each architecture:
KVM_HPAGE_GFN_SHIFT
KVM_NR_HPAGE_SIZES
KVM_PAGES_PER_HPAGE

However, these defines are only used in the gfn_to_index function, which is only used in the x86 code. This series moves the gfn_to_index function from the generic KVM code into the x86 world and gets rid of the definitions from archiectures that don't use them. s390 actually uses these values in other code, so we leave that part untouched.

Patches based on kvm/next and available here:
git://git.linaro.org/people/cdall/linux-kvm-arm.git kvm-pagesize-cleanup

Christoffer Dall (6):
KVM: Move gfn_to_index to x86 specific code
KVM: ARM: Get rid of KVM_HPAGE defines
KVM: arm64: Get rid of KVM_HPAGE defines
KVM: mips: Get rid of KVM_HPAGE defines
KVM: ia64: Get rid of KVM_HPAGE defines
KVM: PPC: Get rid of KVM_HPAGE defines

Quoted 6 lines
Quoted 4 lines

Any comments on this one? I'd very much like to merge huge page support for KVM/ARM during the next merge window and it depends on this series.

Looks fine to me, but why have you skipped s390?

Because the defines are actually used in their code, see above:

"... s390 actually uses these values in other code, so we leave that part untouched."

Will you apply these from the mailing list or should I send you a pull request?

Thanks,
-Christoffer

#10 lore raw
Quoted 31 lines · Christoffer Dall
Quoted 30 lines · Gleb Natapov
Quoted 29 lines · Christoffer Dall
Quoted 15 lines · Christoffer Dall

The current KVM code relies on a number of definitions to exist for each architecture:
KVM_HPAGE_GFN_SHIFT
KVM_NR_HPAGE_SIZES
KVM_PAGES_PER_HPAGE

However, these defines are only used in the gfn_to_index function, which is only used in the x86 code. This series moves the gfn_to_index function from the generic KVM code into the x86 world and gets rid of the definitions from archiectures that don't use them. s390 actually uses these values in other code, so we leave that part untouched.

Patches based on kvm/next and available here:
git://git.linaro.org/people/cdall/linux-kvm-arm.git kvm-pagesize-cleanup

Quoted 8 lines

Christoffer Dall (6):
KVM: Move gfn_to_index to x86 specific code
KVM: ARM: Get rid of KVM_HPAGE defines
KVM: arm64: Get rid of KVM_HPAGE defines
KVM: mips: Get rid of KVM_HPAGE defines
KVM: ia64: Get rid of KVM_HPAGE defines
KVM: PPC: Get rid of KVM_HPAGE defines

Any comments on this one? I'd very much like to merge huge page support for KVM/ARM during the next merge window and it depends on this series.

Quoted 8 lines
Quoted 2 lines

Looks fine to me, but why have you skipped s390?

Because the defines are actually used in their code, see above:

"... s390 actually uses these values in other code, so we leave that part untouched."

It does? Where? I actually removed then and the code still build.

Quoted 3 lines

Will you apply these from the mailing list or should I send you a pull request?

I will apply them from the mailing list.

--
Gleb.

#11 lore raw
Quoted 35 lines · Gleb Natapov
Quoted 34 lines · Christoffer Dall
Quoted 32 lines · Gleb Natapov
Quoted 25 lines · Christoffer Dall
Quoted 15 lines · Christoffer Dall

The current KVM code relies on a number of definitions to exist for each architecture:
KVM_HPAGE_GFN_SHIFT
KVM_NR_HPAGE_SIZES
KVM_PAGES_PER_HPAGE

However, these defines are only used in the gfn_to_index function, which is only used in the x86 code. This series moves the gfn_to_index function from the generic KVM code into the x86 world and gets rid of the definitions from archiectures that don't use them. s390 actually uses these values in other code, so we leave that part untouched.

Patches based on kvm/next and available here:
git://git.linaro.org/people/cdall/linux-kvm-arm.git kvm-pagesize-cleanup

Quoted 8 lines

Christoffer Dall (6):
KVM: Move gfn_to_index to x86 specific code
KVM: ARM: Get rid of KVM_HPAGE defines
KVM: arm64: Get rid of KVM_HPAGE defines
KVM: mips: Get rid of KVM_HPAGE defines
KVM: ia64: Get rid of KVM_HPAGE defines
KVM: PPC: Get rid of KVM_HPAGE defines

Quoted 4 lines

Any comments on this one? I'd very much like to merge huge page support for KVM/ARM during the next merge window and it depends on this series.

Looks fine to me, but why have you skipped s390?

Quoted 7 lines
Quoted 5 lines

Because the defines are actually used in their code, see above:

"... s390 actually uses these values in other code, so we leave that part untouched."

It does? Where? I actually removed then and the code still build.

Eh, I can't find them either. I must have messed something up, sorry about that. Missing patch following!

Quoted 5 lines
Quoted 3 lines

Will you apply these from the mailing list or should I send you a pull request?

I will apply them from the mailing list.

Thanks!

-Christoffer

Applied
#12 lore raw
Quoted 38 lines · Christoffer Dall
Quoted 37 lines · Gleb Natapov
Quoted 36 lines · Christoffer Dall
Quoted 26 lines · Gleb Natapov
Quoted 25 lines · Christoffer Dall
Quoted 23 lines · Christoffer Dall

The current KVM code relies on a number of definitions to exist for each architecture:
KVM_HPAGE_GFN_SHIFT
KVM_NR_HPAGE_SIZES
KVM_PAGES_PER_HPAGE

However, these defines are only used in the gfn_to_index function, which is only used in the x86 code. This series moves the gfn_to_index function from the generic KVM code into the x86 world and gets rid of the definitions from archiectures that don't use them. s390 actually uses these values in other code, so we leave that part untouched.

Patches based on kvm/next and available here:
git://git.linaro.org/people/cdall/linux-kvm-arm.git kvm-pagesize-cleanup

Christoffer Dall (6):
KVM: Move gfn_to_index to x86 specific code
KVM: ARM: Get rid of KVM_HPAGE defines
KVM: arm64: Get rid of KVM_HPAGE defines
KVM: mips: Get rid of KVM_HPAGE defines
KVM: ia64: Get rid of KVM_HPAGE defines
KVM: PPC: Get rid of KVM_HPAGE defines

Quoted 6 lines
Quoted 4 lines

Any comments on this one? I'd very much like to merge huge page support for KVM/ARM during the next merge window and it depends on this series.

Looks fine to me, but why have you skipped s390?

Because the defines are actually used in their code, see above:

Quoted 9 lines
Quoted 5 lines
Quoted 3 lines

"... s390 actually uses these values in other code, so we leave that part untouched."

It does? Where? I actually removed then and the code still build.

Eh, I can't find them either. I must have messed something up, sorry about that. Missing patch following!

Thanks, applied all to queue.

Quoted 9 lines
Quoted 5 lines
Quoted 3 lines

Will you apply these from the mailing list or should I send you a pull request?

I will apply them from the mailing list.

Thanks!

-Christoffer

--
Gleb.