linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] KVM: MIPS: fix compilation
@ 2020-03-31 15:47 Paolo Bonzini
  2020-03-31 16:07 ` Mike Rapoport
  2020-04-01 10:20 ` Sergei Shtylyov
  0 siblings, 2 replies; 5+ messages in thread
From: Paolo Bonzini @ 2020-03-31 15:47 UTC (permalink / raw)
  To: linux-kernel, kvm; +Cc: linux-mips, peterx, rppt

Commit 31168f033e37 is correct that pud_index() & __pud_offset() are the same
when pud_index() is actually provided, however it does not take into account
the __PAGETABLE_PUD_FOLDED case.  Provide kvm_pud_index so that MIPS KVM
compiles.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 arch/mips/kvm/mmu.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/arch/mips/kvm/mmu.c b/arch/mips/kvm/mmu.c
index 7dad7a293eae..ccf98c22fd2c 100644
--- a/arch/mips/kvm/mmu.c
+++ b/arch/mips/kvm/mmu.c
@@ -25,6 +25,12 @@
 #define KVM_MMU_CACHE_MIN_PAGES 2
 #endif
 
+#if defined(__PAGETABLE_PUD_FOLDED)
+#define kvm_pud_index(gva) 0
+#else
+#define kvm_pud_index(gva) pud_index(gva)
+#endif
+
 static int mmu_topup_memory_cache(struct kvm_mmu_memory_cache *cache,
 				  int min, int max)
 {
@@ -234,8 +240,8 @@ static bool kvm_mips_flush_gpa_pud(pud_t *pud, unsigned long start_gpa,
 {
 	pmd_t *pmd;
 	unsigned long end = ~0ul;
-	int i_min = pud_index(start_gpa);
-	int i_max = pud_index(end_gpa);
+	int i_min = kvm_pud_index(start_gpa);
+	int i_max = kvm_pud_index(end_gpa);
 	bool safe_to_remove = (i_min == 0 && i_max == PTRS_PER_PUD - 1);
 	int i;
 
@@ -361,8 +367,8 @@ static int kvm_mips_##name##_pud(pud_t *pud, unsigned long start,	\
 	int ret = 0;							\
 	pmd_t *pmd;							\
 	unsigned long cur_end = ~0ul;					\
-	int i_min = pud_index(start);				\
-	int i_max = pud_index(end);					\
+	int i_min = kvm_pud_index(start);				\
+	int i_max = kvm_pud_index(end);					\
 	int i;								\
 									\
 	for (i = i_min; i <= i_max; ++i, start = 0) {			\
@@ -896,8 +902,8 @@ static bool kvm_mips_flush_gva_pud(pud_t *pud, unsigned long start_gva,
 {
 	pmd_t *pmd;
 	unsigned long end = ~0ul;
-	int i_min = pud_index(start_gva);
-	int i_max = pud_index(end_gva);
+	int i_min = kvm_pud_index(start_gva);
+	int i_max = kvm_pud_index(end_gva);
 	bool safe_to_remove = (i_min == 0 && i_max == PTRS_PER_PUD - 1);
 	int i;
 
-- 
2.18.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] KVM: MIPS: fix compilation
  2020-03-31 15:47 [PATCH] KVM: MIPS: fix compilation Paolo Bonzini
@ 2020-03-31 16:07 ` Mike Rapoport
  2020-03-31 16:33   ` Paolo Bonzini
  2020-04-01 10:20 ` Sergei Shtylyov
  1 sibling, 1 reply; 5+ messages in thread
From: Mike Rapoport @ 2020-03-31 16:07 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: linux-kernel, kvm, linux-mips, peterx

On Tue, Mar 31, 2020 at 11:47:49AM -0400, Paolo Bonzini wrote:
> Commit 31168f033e37 is correct that pud_index() & __pud_offset() are the same
> when pud_index() is actually provided, however it does not take into account
> the __PAGETABLE_PUD_FOLDED case.  Provide kvm_pud_index so that MIPS KVM
> compiles.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  arch/mips/kvm/mmu.c | 18 ++++++++++++------
>  1 file changed, 12 insertions(+), 6 deletions(-)
> 
> diff --git a/arch/mips/kvm/mmu.c b/arch/mips/kvm/mmu.c
> index 7dad7a293eae..ccf98c22fd2c 100644
> --- a/arch/mips/kvm/mmu.c
> +++ b/arch/mips/kvm/mmu.c
> @@ -25,6 +25,12 @@
>  #define KVM_MMU_CACHE_MIN_PAGES 2
>  #endif
>  
> +#if defined(__PAGETABLE_PUD_FOLDED)
> +#define kvm_pud_index(gva) 0
> +#else
> +#define kvm_pud_index(gva) pud_index(gva)
> +#endif
> +

I'd prefer simply making pud_index() always defined. When pud level is
folded asm-generic/pgtable-nopud.h will define PTRS_PER_PUD to 1 and
pud_index() will evaluate to 0 anyway.

diff --git a/arch/mips/include/asm/pgtable-64.h b/arch/mips/include/asm/pgtable-64.h
index f92716cfa4f4..ee5dc0c145b9 100644
--- a/arch/mips/include/asm/pgtable-64.h
+++ b/arch/mips/include/asm/pgtable-64.h
@@ -172,6 +172,8 @@
 
 extern pte_t invalid_pte_table[PTRS_PER_PTE];
 
+#define pud_index(address)	(((address) >> PUD_SHIFT) & (PTRS_PER_PUD - 1))
+
 #ifndef __PAGETABLE_PUD_FOLDED
 /*
  * For 4-level pagetables we defines these ourselves, for 3-level the
@@ -210,8 +212,6 @@ static inline void p4d_clear(p4d_t *p4dp)
 	p4d_val(*p4dp) = (unsigned long)invalid_pud_table;
 }
 
-#define pud_index(address)	(((address) >> PUD_SHIFT) & (PTRS_PER_PUD - 1))
-
 static inline unsigned long p4d_page_vaddr(p4d_t p4d)
 {
 	return p4d_val(p4d);

>  static int mmu_topup_memory_cache(struct kvm_mmu_memory_cache *cache,
>  				  int min, int max)
>  {
> @@ -234,8 +240,8 @@ static bool kvm_mips_flush_gpa_pud(pud_t *pud, unsigned long start_gpa,
>  {
>  	pmd_t *pmd;
>  	unsigned long end = ~0ul;
> -	int i_min = pud_index(start_gpa);
> -	int i_max = pud_index(end_gpa);
> +	int i_min = kvm_pud_index(start_gpa);
> +	int i_max = kvm_pud_index(end_gpa);
>  	bool safe_to_remove = (i_min == 0 && i_max == PTRS_PER_PUD - 1);
>  	int i;
>  
> @@ -361,8 +367,8 @@ static int kvm_mips_##name##_pud(pud_t *pud, unsigned long start,	\
>  	int ret = 0;							\
>  	pmd_t *pmd;							\
>  	unsigned long cur_end = ~0ul;					\
> -	int i_min = pud_index(start);				\
> -	int i_max = pud_index(end);					\
> +	int i_min = kvm_pud_index(start);				\
> +	int i_max = kvm_pud_index(end);					\
>  	int i;								\
>  									\
>  	for (i = i_min; i <= i_max; ++i, start = 0) {			\
> @@ -896,8 +902,8 @@ static bool kvm_mips_flush_gva_pud(pud_t *pud, unsigned long start_gva,
>  {
>  	pmd_t *pmd;
>  	unsigned long end = ~0ul;
> -	int i_min = pud_index(start_gva);
> -	int i_max = pud_index(end_gva);
> +	int i_min = kvm_pud_index(start_gva);
> +	int i_max = kvm_pud_index(end_gva);
>  	bool safe_to_remove = (i_min == 0 && i_max == PTRS_PER_PUD - 1);
>  	int i;
>  
> -- 
> 2.18.2
> 

-- 
Sincerely yours,
Mike.


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] KVM: MIPS: fix compilation
  2020-03-31 16:07 ` Mike Rapoport
@ 2020-03-31 16:33   ` Paolo Bonzini
  2020-04-01  6:33     ` maobibo
  0 siblings, 1 reply; 5+ messages in thread
From: Paolo Bonzini @ 2020-03-31 16:33 UTC (permalink / raw)
  To: Mike Rapoport; +Cc: linux-kernel, kvm, linux-mips, peterx

On 31/03/20 18:07, Mike Rapoport wrote:
> On Tue, Mar 31, 2020 at 11:47:49AM -0400, Paolo Bonzini wrote:
>> Commit 31168f033e37 is correct that pud_index() & __pud_offset() are the same
>> when pud_index() is actually provided, however it does not take into account
>> the __PAGETABLE_PUD_FOLDED case.  Provide kvm_pud_index so that MIPS KVM
>> compiles.
>>
>> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
>> ---
>>  arch/mips/kvm/mmu.c | 18 ++++++++++++------
>>  1 file changed, 12 insertions(+), 6 deletions(-)
>>
>> diff --git a/arch/mips/kvm/mmu.c b/arch/mips/kvm/mmu.c
>> index 7dad7a293eae..ccf98c22fd2c 100644
>> --- a/arch/mips/kvm/mmu.c
>> +++ b/arch/mips/kvm/mmu.c
>> @@ -25,6 +25,12 @@
>>  #define KVM_MMU_CACHE_MIN_PAGES 2
>>  #endif
>>  
>> +#if defined(__PAGETABLE_PUD_FOLDED)
>> +#define kvm_pud_index(gva) 0
>> +#else
>> +#define kvm_pud_index(gva) pud_index(gva)
>> +#endif
>> +
> 
> I'd prefer simply making pud_index() always defined. When pud level is
> folded asm-generic/pgtable-nopud.h will define PTRS_PER_PUD to 1 and
> pud_index() will evaluate to 0 anyway.

I won't queue this patch for now, let's wait for the MIPS people to say
what they prefer.  Thanks!

Paolo

> diff --git a/arch/mips/include/asm/pgtable-64.h b/arch/mips/include/asm/pgtable-64.h
> index f92716cfa4f4..ee5dc0c145b9 100644
> --- a/arch/mips/include/asm/pgtable-64.h
> +++ b/arch/mips/include/asm/pgtable-64.h
> @@ -172,6 +172,8 @@
>  
>  extern pte_t invalid_pte_table[PTRS_PER_PTE];
>  
> +#define pud_index(address)	(((address) >> PUD_SHIFT) & (PTRS_PER_PUD - 1))
> +
>  #ifndef __PAGETABLE_PUD_FOLDED
>  /*
>   * For 4-level pagetables we defines these ourselves, for 3-level the
> @@ -210,8 +212,6 @@ static inline void p4d_clear(p4d_t *p4dp)
>  	p4d_val(*p4dp) = (unsigned long)invalid_pud_table;
>  }
>  
> -#define pud_index(address)	(((address) >> PUD_SHIFT) & (PTRS_PER_PUD - 1))
> -
>  static inline unsigned long p4d_page_vaddr(p4d_t p4d)
>  {
>  	return p4d_val(p4d);
> 
>>  static int mmu_topup_memory_cache(struct kvm_mmu_memory_cache *cache,
>>  				  int min, int max)
>>  {
>> @@ -234,8 +240,8 @@ static bool kvm_mips_flush_gpa_pud(pud_t *pud, unsigned long start_gpa,
>>  {
>>  	pmd_t *pmd;
>>  	unsigned long end = ~0ul;
>> -	int i_min = pud_index(start_gpa);
>> -	int i_max = pud_index(end_gpa);
>> +	int i_min = kvm_pud_index(start_gpa);
>> +	int i_max = kvm_pud_index(end_gpa);
>>  	bool safe_to_remove = (i_min == 0 && i_max == PTRS_PER_PUD - 1);
>>  	int i;
>>  
>> @@ -361,8 +367,8 @@ static int kvm_mips_##name##_pud(pud_t *pud, unsigned long start,	\
>>  	int ret = 0;							\
>>  	pmd_t *pmd;							\
>>  	unsigned long cur_end = ~0ul;					\
>> -	int i_min = pud_index(start);				\
>> -	int i_max = pud_index(end);					\
>> +	int i_min = kvm_pud_index(start);				\
>> +	int i_max = kvm_pud_index(end);					\
>>  	int i;								\
>>  									\
>>  	for (i = i_min; i <= i_max; ++i, start = 0) {			\
>> @@ -896,8 +902,8 @@ static bool kvm_mips_flush_gva_pud(pud_t *pud, unsigned long start_gva,
>>  {
>>  	pmd_t *pmd;
>>  	unsigned long end = ~0ul;
>> -	int i_min = pud_index(start_gva);
>> -	int i_max = pud_index(end_gva);
>> +	int i_min = kvm_pud_index(start_gva);
>> +	int i_max = kvm_pud_index(end_gva);
>>  	bool safe_to_remove = (i_min == 0 && i_max == PTRS_PER_PUD - 1);
>>  	int i;
>>  
>> -- 
>> 2.18.2
>>
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] KVM: MIPS: fix compilation
  2020-03-31 16:33   ` Paolo Bonzini
@ 2020-04-01  6:33     ` maobibo
  0 siblings, 0 replies; 5+ messages in thread
From: maobibo @ 2020-04-01  6:33 UTC (permalink / raw)
  To: Paolo Bonzini, Mike Rapoport; +Cc: linux-kernel, kvm, linux-mips, peterx



On 04/01/2020 12:33 AM, Paolo Bonzini wrote:
> On 31/03/20 18:07, Mike Rapoport wrote:
>> On Tue, Mar 31, 2020 at 11:47:49AM -0400, Paolo Bonzini wrote:
>>> Commit 31168f033e37 is correct that pud_index() & __pud_offset() are the same
>>> when pud_index() is actually provided, however it does not take into account
>>> the __PAGETABLE_PUD_FOLDED case.  Provide kvm_pud_index so that MIPS KVM
>>> compiles.
>>>
>>> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
>>> ---
>>>  arch/mips/kvm/mmu.c | 18 ++++++++++++------
>>>  1 file changed, 12 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/arch/mips/kvm/mmu.c b/arch/mips/kvm/mmu.c
>>> index 7dad7a293eae..ccf98c22fd2c 100644
>>> --- a/arch/mips/kvm/mmu.c
>>> +++ b/arch/mips/kvm/mmu.c
>>> @@ -25,6 +25,12 @@
>>>  #define KVM_MMU_CACHE_MIN_PAGES 2
>>>  #endif
>>>  
>>> +#if defined(__PAGETABLE_PUD_FOLDED)
>>> +#define kvm_pud_index(gva) 0
>>> +#else
>>> +#define kvm_pud_index(gva) pud_index(gva)
>>> +#endif
>>> +
>>
>> I'd prefer simply making pud_index() always defined. When pud level is
>> folded asm-generic/pgtable-nopud.h will define PTRS_PER_PUD to 1 and
>> pud_index() will evaluate to 0 anyway.
> 
> I won't queue this patch for now, let's wait for the MIPS people to say
> what they prefer.  Thanks!
Hi Paolo,

Thanks for patch, it passes to compile on my loongson64 box. I prefer to
the second method, since pgd_inde/pmd_index is already defined in
pgtable-64.h :)

> 
> Paolo

> 
>> diff --git a/arch/mips/include/asm/pgtable-64.h b/arch/mips/include/asm/pgtable-64.h
>> index f92716cfa4f4..ee5dc0c145b9 100644
>> --- a/arch/mips/include/asm/pgtable-64.h
>> +++ b/arch/mips/include/asm/pgtable-64.h
>> @@ -172,6 +172,8 @@
>>  
>>  extern pte_t invalid_pte_table[PTRS_PER_PTE];
>>  
>> +#define pud_index(address)	(((address) >> PUD_SHIFT) & (PTRS_PER_PUD - 1))
>> +
>>  #ifndef __PAGETABLE_PUD_FOLDED
>>  /*
>>   * For 4-level pagetables we defines these ourselves, for 3-level the
>> @@ -210,8 +212,6 @@ static inline void p4d_clear(p4d_t *p4dp)
>>  	p4d_val(*p4dp) = (unsigned long)invalid_pud_table;
>>  }
>>  
>> -#define pud_index(address)	(((address) >> PUD_SHIFT) & (PTRS_PER_PUD - 1))
>> -
>>  static inline unsigned long p4d_page_vaddr(p4d_t p4d)
>>  {
>>  	return p4d_val(p4d);
>>
>>>  static int mmu_topup_memory_cache(struct kvm_mmu_memory_cache *cache,
>>>  				  int min, int max)
>>>  {
>>> @@ -234,8 +240,8 @@ static bool kvm_mips_flush_gpa_pud(pud_t *pud, unsigned long start_gpa,
>>>  {
>>>  	pmd_t *pmd;
>>>  	unsigned long end = ~0ul;
>>> -	int i_min = pud_index(start_gpa);
>>> -	int i_max = pud_index(end_gpa);
>>> +	int i_min = kvm_pud_index(start_gpa);
>>> +	int i_max = kvm_pud_index(end_gpa);
>>>  	bool safe_to_remove = (i_min == 0 && i_max == PTRS_PER_PUD - 1);
>>>  	int i;
>>>  
>>> @@ -361,8 +367,8 @@ static int kvm_mips_##name##_pud(pud_t *pud, unsigned long start,	\
>>>  	int ret = 0;							\
>>>  	pmd_t *pmd;							\
>>>  	unsigned long cur_end = ~0ul;					\
>>> -	int i_min = pud_index(start);				\
>>> -	int i_max = pud_index(end);					\
>>> +	int i_min = kvm_pud_index(start);				\
>>> +	int i_max = kvm_pud_index(end);					\
>>>  	int i;								\
>>>  									\
>>>  	for (i = i_min; i <= i_max; ++i, start = 0) {			\
>>> @@ -896,8 +902,8 @@ static bool kvm_mips_flush_gva_pud(pud_t *pud, unsigned long start_gva,
>>>  {
>>>  	pmd_t *pmd;
>>>  	unsigned long end = ~0ul;
>>> -	int i_min = pud_index(start_gva);
>>> -	int i_max = pud_index(end_gva);
>>> +	int i_min = kvm_pud_index(start_gva);
>>> +	int i_max = kvm_pud_index(end_gva);
>>>  	bool safe_to_remove = (i_min == 0 && i_max == PTRS_PER_PUD - 1);
>>>  	int i;
>>>  
>>> -- 
>>> 2.18.2
>>>
>>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] KVM: MIPS: fix compilation
  2020-03-31 15:47 [PATCH] KVM: MIPS: fix compilation Paolo Bonzini
  2020-03-31 16:07 ` Mike Rapoport
@ 2020-04-01 10:20 ` Sergei Shtylyov
  1 sibling, 0 replies; 5+ messages in thread
From: Sergei Shtylyov @ 2020-04-01 10:20 UTC (permalink / raw)
  To: Paolo Bonzini, linux-kernel, kvm; +Cc: linux-mips, peterx, rppt

Hello!

On 31.03.2020 18:47, Paolo Bonzini wrote:

> Commit 31168f033e37 is correct that pud_index() & __pud_offset() are the same

    You should also specify the commit's 1-line summary enclosed in ("").

> when pud_index() is actually provided, however it does not take into account
> the __PAGETABLE_PUD_FOLDED case.  Provide kvm_pud_index so that MIPS KVM
> compiles.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
[...]

MBR, Sergei

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-04-01 10:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-31 15:47 [PATCH] KVM: MIPS: fix compilation Paolo Bonzini
2020-03-31 16:07 ` Mike Rapoport
2020-03-31 16:33   ` Paolo Bonzini
2020-04-01  6:33     ` maobibo
2020-04-01 10:20 ` Sergei Shtylyov

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).