diff mbox series

[kvm-unit-tests,v1,04/12] lib/asm: Fix definitions of memory areas

Message ID 20201216201200.255172-5-imbrenda@linux.ibm.com (mailing list archive)
State New, archived
Headers show
Series Fix and improve the page allocator | expand

Commit Message

Claudio Imbrenda Dec. 16, 2020, 8:11 p.m. UTC
Fix the definitions of the memory areas.

Bring the headers in line with the rest of the asm headers, by having the
appropriate #ifdef _ASM$ARCH_ guarding the headers.

Fixes: d74708246bd9 ("lib/asm: Add definitions of memory areas")

Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
---
 lib/asm-generic/memory_areas.h |  9 ++++-----
 lib/arm/asm/memory_areas.h     | 11 +++--------
 lib/arm64/asm/memory_areas.h   | 11 +++--------
 lib/powerpc/asm/memory_areas.h | 11 +++--------
 lib/ppc64/asm/memory_areas.h   | 11 +++--------
 lib/s390x/asm/memory_areas.h   | 13 ++++++-------
 lib/x86/asm/memory_areas.h     | 27 ++++++++++++++++-----------
 lib/alloc_page.h               |  3 +++
 lib/alloc_page.c               |  4 +---
 9 files changed, 42 insertions(+), 58 deletions(-)

Comments

Krish Sadhukhan Dec. 24, 2020, 6:17 p.m. UTC | #1
On 12/16/20 12:11 PM, Claudio Imbrenda wrote:
> Fix the definitions of the memory areas.
>
> Bring the headers in line with the rest of the asm headers, by having the
> appropriate #ifdef _ASM$ARCH_ guarding the headers.


Should we mention MAX_AREAS that the patch adds in each arch-specific 
header ?

> Fixes: d74708246bd9 ("lib/asm: Add definitions of memory areas")
>
> Signed-off-by: Claudio Imbrenda<imbrenda@linux.ibm.com>
> ---
>   lib/asm-generic/memory_areas.h |  9 ++++-----
>   lib/arm/asm/memory_areas.h     | 11 +++--------
>   lib/arm64/asm/memory_areas.h   | 11 +++--------
>   lib/powerpc/asm/memory_areas.h | 11 +++--------
>   lib/ppc64/asm/memory_areas.h   | 11 +++--------
>   lib/s390x/asm/memory_areas.h   | 13 ++++++-------
>   lib/x86/asm/memory_areas.h     | 27 ++++++++++++++++-----------
>   lib/alloc_page.h               |  3 +++
>   lib/alloc_page.c               |  4 +---
>   9 files changed, 42 insertions(+), 58 deletions(-)
>
> diff --git a/lib/asm-generic/memory_areas.h b/lib/asm-generic/memory_areas.h
> index 927baa7..3074afe 100644
> --- a/lib/asm-generic/memory_areas.h
> +++ b/lib/asm-generic/memory_areas.h
> @@ -1,11 +1,10 @@
> -#ifndef MEMORY_AREAS_H
> -#define MEMORY_AREAS_H
> +#ifndef __ASM_GENERIC_MEMORY_AREAS_H__
> +#define __ASM_GENERIC_MEMORY_AREAS_H__
>   
>   #define AREA_NORMAL_PFN 0
>   #define AREA_NORMAL_NUMBER 0
> -#define AREA_NORMAL 1
> +#define AREA_NORMAL (1 << AREA_NORMAL_NUMBER)
>   
> -#define AREA_ANY -1
> -#define AREA_ANY_NUMBER 0xff
> +#define MAX_AREAS 1
>   
>   #endif
> diff --git a/lib/arm/asm/memory_areas.h b/lib/arm/asm/memory_areas.h
> index 927baa7..c723310 100644
> --- a/lib/arm/asm/memory_areas.h
> +++ b/lib/arm/asm/memory_areas.h
> @@ -1,11 +1,6 @@
> -#ifndef MEMORY_AREAS_H
> -#define MEMORY_AREAS_H
> +#ifndef _ASMARM_MEMORY_AREAS_H_
> +#define _ASMARM_MEMORY_AREAS_H_
>   
> -#define AREA_NORMAL_PFN 0
> -#define AREA_NORMAL_NUMBER 0
> -#define AREA_NORMAL 1
> -
> -#define AREA_ANY -1
> -#define AREA_ANY_NUMBER 0xff
> +#include <asm-generic/memory_areas.h>
>   
>   #endif
> diff --git a/lib/arm64/asm/memory_areas.h b/lib/arm64/asm/memory_areas.h
> index 927baa7..18e8ca8 100644
> --- a/lib/arm64/asm/memory_areas.h
> +++ b/lib/arm64/asm/memory_areas.h
> @@ -1,11 +1,6 @@
> -#ifndef MEMORY_AREAS_H
> -#define MEMORY_AREAS_H
> +#ifndef _ASMARM64_MEMORY_AREAS_H_
> +#define _ASMARM64_MEMORY_AREAS_H_
>   
> -#define AREA_NORMAL_PFN 0
> -#define AREA_NORMAL_NUMBER 0
> -#define AREA_NORMAL 1
> -
> -#define AREA_ANY -1
> -#define AREA_ANY_NUMBER 0xff
> +#include <asm-generic/memory_areas.h>
>   
>   #endif
> diff --git a/lib/powerpc/asm/memory_areas.h b/lib/powerpc/asm/memory_areas.h
> index 927baa7..76d1738 100644
> --- a/lib/powerpc/asm/memory_areas.h
> +++ b/lib/powerpc/asm/memory_areas.h
> @@ -1,11 +1,6 @@
> -#ifndef MEMORY_AREAS_H
> -#define MEMORY_AREAS_H
> +#ifndef _ASMPOWERPC_MEMORY_AREAS_H_
> +#define _ASMPOWERPC_MEMORY_AREAS_H_
>   
> -#define AREA_NORMAL_PFN 0
> -#define AREA_NORMAL_NUMBER 0
> -#define AREA_NORMAL 1
> -
> -#define AREA_ANY -1
> -#define AREA_ANY_NUMBER 0xff
> +#include <asm-generic/memory_areas.h>
>   
>   #endif
> diff --git a/lib/ppc64/asm/memory_areas.h b/lib/ppc64/asm/memory_areas.h
> index 927baa7..b9fd46b 100644
> --- a/lib/ppc64/asm/memory_areas.h
> +++ b/lib/ppc64/asm/memory_areas.h
> @@ -1,11 +1,6 @@
> -#ifndef MEMORY_AREAS_H
> -#define MEMORY_AREAS_H
> +#ifndef _ASMPPC64_MEMORY_AREAS_H_
> +#define _ASMPPC64_MEMORY_AREAS_H_
>   
> -#define AREA_NORMAL_PFN 0
> -#define AREA_NORMAL_NUMBER 0
> -#define AREA_NORMAL 1
> -
> -#define AREA_ANY -1
> -#define AREA_ANY_NUMBER 0xff
> +#include <asm-generic/memory_areas.h>
>   
>   #endif
> diff --git a/lib/s390x/asm/memory_areas.h b/lib/s390x/asm/memory_areas.h
> index 4856a27..827bfb3 100644
> --- a/lib/s390x/asm/memory_areas.h
> +++ b/lib/s390x/asm/memory_areas.h
> @@ -1,16 +1,15 @@
> -#ifndef MEMORY_AREAS_H
> -#define MEMORY_AREAS_H
> +#ifndef _ASMS390X_MEMORY_AREAS_H_
> +#define _ASMS390X_MEMORY_AREAS_H_
>   
> -#define AREA_NORMAL_PFN BIT(31-12)
> +#define AREA_NORMAL_PFN (1 << 19)
>   #define AREA_NORMAL_NUMBER 0
> -#define AREA_NORMAL 1
> +#define AREA_NORMAL (1 << AREA_NORMAL_NUMBER)
>   
>   #define AREA_LOW_PFN 0
>   #define AREA_LOW_NUMBER 1
> -#define AREA_LOW 2
> +#define AREA_LOW (1 << AREA_LOW_NUMBER)
>   
> -#define AREA_ANY -1
> -#define AREA_ANY_NUMBER 0xff
> +#define MAX_AREAS 2
>   
>   #define AREA_DMA31 AREA_LOW
>   
> diff --git a/lib/x86/asm/memory_areas.h b/lib/x86/asm/memory_areas.h
> index 952f5bd..e84016f 100644
> --- a/lib/x86/asm/memory_areas.h
> +++ b/lib/x86/asm/memory_areas.h
> @@ -1,21 +1,26 @@
> -#ifndef MEMORY_AREAS_H
> -#define MEMORY_AREAS_H
> +#ifndef _ASM_X86_MEMORY_AREAS_H_
> +#define _ASM_X86_MEMORY_AREAS_H_
>   
>   #define AREA_NORMAL_PFN BIT(36-12)
>   #define AREA_NORMAL_NUMBER 0
> -#define AREA_NORMAL 1
> +#define AREA_NORMAL (1 << AREA_NORMAL_NUMBER)
>   
> -#define AREA_PAE_HIGH_PFN BIT(32-12)
> -#define AREA_PAE_HIGH_NUMBER 1
> -#define AREA_PAE_HIGH 2
> +#define AREA_HIGH_PFN BIT(32-12)
> +#define AREA_HIGH_NUMBER 1
> +#define AREA_HIGH (1 << AREA_HIGH_NUMBER)
>   
> -#define AREA_LOW_PFN 0
> +#define AREA_LOW_PFN BIT(24-12)
>   #define AREA_LOW_NUMBER 2
> -#define AREA_LOW 4
> +#define AREA_LOW (1 << AREA_LOW_NUMBER)
>   
> -#define AREA_PAE (AREA_PAE | AREA_LOW)
> +#define AREA_LOWEST_PFN 0
> +#define AREA_LOWEST_NUMBER 3
> +#define AREA_LOWEST (1 << AREA_LOWEST_NUMBER)
>   
> -#define AREA_ANY -1
> -#define AREA_ANY_NUMBER 0xff
> +#define MAX_AREAS 4
> +
> +#define AREA_DMA24 AREA_LOWEST
> +#define AREA_DMA32 (AREA_LOWEST | AREA_LOW)
> +#define AREA_PAE36 (AREA_LOWEST | AREA_LOW | AREA_HIGH)
>   
>   #endif
> diff --git a/lib/alloc_page.h b/lib/alloc_page.h
> index 816ff5d..b6aace5 100644
> --- a/lib/alloc_page.h
> +++ b/lib/alloc_page.h
> @@ -10,6 +10,9 @@
>   
>   #include <asm/memory_areas.h>
>   
> +#define AREA_ANY -1
> +#define AREA_ANY_NUMBER 0xff
> +
>   /* Returns true if the page allocator has been initialized */
>   bool page_alloc_initialized(void);
>   
> diff --git a/lib/alloc_page.c b/lib/alloc_page.c
> index 685ab1e..ed0ff02 100644
> --- a/lib/alloc_page.c
> +++ b/lib/alloc_page.c
> @@ -19,8 +19,6 @@
>   #define NLISTS ((BITS_PER_LONG) - (PAGE_SHIFT))
>   #define PFN(x) ((uintptr_t)(x) >> PAGE_SHIFT)
>   
> -#define MAX_AREAS	6
> -
>   #define ORDER_MASK	0x3f
>   #define ALLOC_MASK	0x40
>   #define SPECIAL_MASK	0x80
> @@ -509,7 +507,7 @@ void page_alloc_init_area(u8 n, uintptr_t base_pfn, uintptr_t top_pfn)
>   		return;
>   	}
>   #ifdef AREA_HIGH_PFN
> -	__page_alloc_init_area(AREA_HIGH_NUMBER, AREA_HIGH_PFN), base_pfn, &top_pfn);
> +	__page_alloc_init_area(AREA_HIGH_NUMBER, AREA_HIGH_PFN, base_pfn, &top_pfn);


Surprising that the compiler didn't complain !

>   #endif
>   	__page_alloc_init_area(AREA_NORMAL_NUMBER, AREA_NORMAL_PFN, base_pfn, &top_pfn);
>   #ifdef AREA_LOW_PFN
Claudio Imbrenda Jan. 4, 2021, 1:19 p.m. UTC | #2
On Thu, 24 Dec 2020 10:17:00 -0800
Krish Sadhukhan <krish.sadhukhan@oracle.com> wrote:

> On 12/16/20 12:11 PM, Claudio Imbrenda wrote:
> > Fix the definitions of the memory areas.
> >
> > Bring the headers in line with the rest of the asm headers, by
> > having the appropriate #ifdef _ASM$ARCH_ guarding the headers.  
> 
> 
> Should we mention MAX_AREAS that the patch adds in each arch-specific 
> header ?

not sure, it's a minor detail. I mentioned above that I "Fix the
definitions of the memory areas". 

MAX_AREAS is not totally new, now it's per-arch instead of being in the
generic code.

> > Fixes: d74708246bd9 ("lib/asm: Add definitions of memory areas")
> >
> > Signed-off-by: Claudio Imbrenda<imbrenda@linux.ibm.com>
> > ---
> >   lib/asm-generic/memory_areas.h |  9 ++++-----
> >   lib/arm/asm/memory_areas.h     | 11 +++--------
> >   lib/arm64/asm/memory_areas.h   | 11 +++--------
> >   lib/powerpc/asm/memory_areas.h | 11 +++--------
> >   lib/ppc64/asm/memory_areas.h   | 11 +++--------
> >   lib/s390x/asm/memory_areas.h   | 13 ++++++-------
> >   lib/x86/asm/memory_areas.h     | 27 ++++++++++++++++-----------
> >   lib/alloc_page.h               |  3 +++
> >   lib/alloc_page.c               |  4 +---
> >   9 files changed, 42 insertions(+), 58 deletions(-)
> >
> > diff --git a/lib/asm-generic/memory_areas.h
> > b/lib/asm-generic/memory_areas.h index 927baa7..3074afe 100644
> > --- a/lib/asm-generic/memory_areas.h
> > +++ b/lib/asm-generic/memory_areas.h
> > @@ -1,11 +1,10 @@
> > -#ifndef MEMORY_AREAS_H
> > -#define MEMORY_AREAS_H
> > +#ifndef __ASM_GENERIC_MEMORY_AREAS_H__
> > +#define __ASM_GENERIC_MEMORY_AREAS_H__
> >   
> >   #define AREA_NORMAL_PFN 0
> >   #define AREA_NORMAL_NUMBER 0
> > -#define AREA_NORMAL 1
> > +#define AREA_NORMAL (1 << AREA_NORMAL_NUMBER)
> >   
> > -#define AREA_ANY -1
> > -#define AREA_ANY_NUMBER 0xff
> > +#define MAX_AREAS 1
> >   
> >   #endif
> > diff --git a/lib/arm/asm/memory_areas.h b/lib/arm/asm/memory_areas.h
> > index 927baa7..c723310 100644
> > --- a/lib/arm/asm/memory_areas.h
> > +++ b/lib/arm/asm/memory_areas.h
> > @@ -1,11 +1,6 @@
> > -#ifndef MEMORY_AREAS_H
> > -#define MEMORY_AREAS_H
> > +#ifndef _ASMARM_MEMORY_AREAS_H_
> > +#define _ASMARM_MEMORY_AREAS_H_
> >   
> > -#define AREA_NORMAL_PFN 0
> > -#define AREA_NORMAL_NUMBER 0
> > -#define AREA_NORMAL 1
> > -
> > -#define AREA_ANY -1
> > -#define AREA_ANY_NUMBER 0xff
> > +#include <asm-generic/memory_areas.h>
> >   
> >   #endif
> > diff --git a/lib/arm64/asm/memory_areas.h
> > b/lib/arm64/asm/memory_areas.h index 927baa7..18e8ca8 100644
> > --- a/lib/arm64/asm/memory_areas.h
> > +++ b/lib/arm64/asm/memory_areas.h
> > @@ -1,11 +1,6 @@
> > -#ifndef MEMORY_AREAS_H
> > -#define MEMORY_AREAS_H
> > +#ifndef _ASMARM64_MEMORY_AREAS_H_
> > +#define _ASMARM64_MEMORY_AREAS_H_
> >   
> > -#define AREA_NORMAL_PFN 0
> > -#define AREA_NORMAL_NUMBER 0
> > -#define AREA_NORMAL 1
> > -
> > -#define AREA_ANY -1
> > -#define AREA_ANY_NUMBER 0xff
> > +#include <asm-generic/memory_areas.h>
> >   
> >   #endif
> > diff --git a/lib/powerpc/asm/memory_areas.h
> > b/lib/powerpc/asm/memory_areas.h index 927baa7..76d1738 100644
> > --- a/lib/powerpc/asm/memory_areas.h
> > +++ b/lib/powerpc/asm/memory_areas.h
> > @@ -1,11 +1,6 @@
> > -#ifndef MEMORY_AREAS_H
> > -#define MEMORY_AREAS_H
> > +#ifndef _ASMPOWERPC_MEMORY_AREAS_H_
> > +#define _ASMPOWERPC_MEMORY_AREAS_H_
> >   
> > -#define AREA_NORMAL_PFN 0
> > -#define AREA_NORMAL_NUMBER 0
> > -#define AREA_NORMAL 1
> > -
> > -#define AREA_ANY -1
> > -#define AREA_ANY_NUMBER 0xff
> > +#include <asm-generic/memory_areas.h>
> >   
> >   #endif
> > diff --git a/lib/ppc64/asm/memory_areas.h
> > b/lib/ppc64/asm/memory_areas.h index 927baa7..b9fd46b 100644
> > --- a/lib/ppc64/asm/memory_areas.h
> > +++ b/lib/ppc64/asm/memory_areas.h
> > @@ -1,11 +1,6 @@
> > -#ifndef MEMORY_AREAS_H
> > -#define MEMORY_AREAS_H
> > +#ifndef _ASMPPC64_MEMORY_AREAS_H_
> > +#define _ASMPPC64_MEMORY_AREAS_H_
> >   
> > -#define AREA_NORMAL_PFN 0
> > -#define AREA_NORMAL_NUMBER 0
> > -#define AREA_NORMAL 1
> > -
> > -#define AREA_ANY -1
> > -#define AREA_ANY_NUMBER 0xff
> > +#include <asm-generic/memory_areas.h>
> >   
> >   #endif
> > diff --git a/lib/s390x/asm/memory_areas.h
> > b/lib/s390x/asm/memory_areas.h index 4856a27..827bfb3 100644
> > --- a/lib/s390x/asm/memory_areas.h
> > +++ b/lib/s390x/asm/memory_areas.h
> > @@ -1,16 +1,15 @@
> > -#ifndef MEMORY_AREAS_H
> > -#define MEMORY_AREAS_H
> > +#ifndef _ASMS390X_MEMORY_AREAS_H_
> > +#define _ASMS390X_MEMORY_AREAS_H_
> >   
> > -#define AREA_NORMAL_PFN BIT(31-12)
> > +#define AREA_NORMAL_PFN (1 << 19)
> >   #define AREA_NORMAL_NUMBER 0
> > -#define AREA_NORMAL 1
> > +#define AREA_NORMAL (1 << AREA_NORMAL_NUMBER)
> >   
> >   #define AREA_LOW_PFN 0
> >   #define AREA_LOW_NUMBER 1
> > -#define AREA_LOW 2
> > +#define AREA_LOW (1 << AREA_LOW_NUMBER)
> >   
> > -#define AREA_ANY -1
> > -#define AREA_ANY_NUMBER 0xff
> > +#define MAX_AREAS 2
> >   
> >   #define AREA_DMA31 AREA_LOW
> >   
> > diff --git a/lib/x86/asm/memory_areas.h b/lib/x86/asm/memory_areas.h
> > index 952f5bd..e84016f 100644
> > --- a/lib/x86/asm/memory_areas.h
> > +++ b/lib/x86/asm/memory_areas.h
> > @@ -1,21 +1,26 @@
> > -#ifndef MEMORY_AREAS_H
> > -#define MEMORY_AREAS_H
> > +#ifndef _ASM_X86_MEMORY_AREAS_H_
> > +#define _ASM_X86_MEMORY_AREAS_H_
> >   
> >   #define AREA_NORMAL_PFN BIT(36-12)
> >   #define AREA_NORMAL_NUMBER 0
> > -#define AREA_NORMAL 1
> > +#define AREA_NORMAL (1 << AREA_NORMAL_NUMBER)
> >   
> > -#define AREA_PAE_HIGH_PFN BIT(32-12)
> > -#define AREA_PAE_HIGH_NUMBER 1
> > -#define AREA_PAE_HIGH 2
> > +#define AREA_HIGH_PFN BIT(32-12)
> > +#define AREA_HIGH_NUMBER 1
> > +#define AREA_HIGH (1 << AREA_HIGH_NUMBER)
> >   
> > -#define AREA_LOW_PFN 0
> > +#define AREA_LOW_PFN BIT(24-12)
> >   #define AREA_LOW_NUMBER 2
> > -#define AREA_LOW 4
> > +#define AREA_LOW (1 << AREA_LOW_NUMBER)
> >   
> > -#define AREA_PAE (AREA_PAE | AREA_LOW)
> > +#define AREA_LOWEST_PFN 0
> > +#define AREA_LOWEST_NUMBER 3
> > +#define AREA_LOWEST (1 << AREA_LOWEST_NUMBER)
> >   
> > -#define AREA_ANY -1
> > -#define AREA_ANY_NUMBER 0xff
> > +#define MAX_AREAS 4
> > +
> > +#define AREA_DMA24 AREA_LOWEST
> > +#define AREA_DMA32 (AREA_LOWEST | AREA_LOW)
> > +#define AREA_PAE36 (AREA_LOWEST | AREA_LOW | AREA_HIGH)
> >   
> >   #endif
> > diff --git a/lib/alloc_page.h b/lib/alloc_page.h
> > index 816ff5d..b6aace5 100644
> > --- a/lib/alloc_page.h
> > +++ b/lib/alloc_page.h
> > @@ -10,6 +10,9 @@
> >   
> >   #include <asm/memory_areas.h>
> >   
> > +#define AREA_ANY -1
> > +#define AREA_ANY_NUMBER 0xff
> > +
> >   /* Returns true if the page allocator has been initialized */
> >   bool page_alloc_initialized(void);
> >   
> > diff --git a/lib/alloc_page.c b/lib/alloc_page.c
> > index 685ab1e..ed0ff02 100644
> > --- a/lib/alloc_page.c
> > +++ b/lib/alloc_page.c
> > @@ -19,8 +19,6 @@
> >   #define NLISTS ((BITS_PER_LONG) - (PAGE_SHIFT))
> >   #define PFN(x) ((uintptr_t)(x) >> PAGE_SHIFT)
> >   
> > -#define MAX_AREAS	6
> > -
> >   #define ORDER_MASK	0x3f
> >   #define ALLOC_MASK	0x40
> >   #define SPECIAL_MASK	0x80
> > @@ -509,7 +507,7 @@ void page_alloc_init_area(u8 n, uintptr_t
> > base_pfn, uintptr_t top_pfn) return;
> >   	}
> >   #ifdef AREA_HIGH_PFN
> > -	__page_alloc_init_area(AREA_HIGH_NUMBER, AREA_HIGH_PFN),
> > base_pfn, &top_pfn);
> > +	__page_alloc_init_area(AREA_HIGH_NUMBER, AREA_HIGH_PFN,
> > base_pfn, &top_pfn);  
> 
> 
> Surprising that the compiler didn't complain !
> 
> >   #endif
> >   	__page_alloc_init_area(AREA_NORMAL_NUMBER,
> > AREA_NORMAL_PFN, base_pfn, &top_pfn); #ifdef AREA_LOW_PFN
Krish Sadhukhan Jan. 5, 2021, 1:17 a.m. UTC | #3
On 1/4/21 5:19 AM, Claudio Imbrenda wrote:
> On Thu, 24 Dec 2020 10:17:00 -0800
> Krish Sadhukhan <krish.sadhukhan@oracle.com> wrote:
>
>> On 12/16/20 12:11 PM, Claudio Imbrenda wrote:
>>> Fix the definitions of the memory areas.
>>>
>>> Bring the headers in line with the rest of the asm headers, by
>>> having the appropriate #ifdef _ASM$ARCH_ guarding the headers.
>>
>> Should we mention MAX_AREAS that the patch adds in each arch-specific
>> header ?
> not sure, it's a minor detail. I mentioned above that I "Fix the
> definitions of the memory areas".
>
> MAX_AREAS is not totally new, now it's per-arch instead of being in the
> generic code.
>
>>> Fixes: d74708246bd9 ("lib/asm: Add definitions of memory areas")
>>>
>>> Signed-off-by: Claudio Imbrenda<imbrenda@linux.ibm.com>
>>> ---
>>>    lib/asm-generic/memory_areas.h |  9 ++++-----
>>>    lib/arm/asm/memory_areas.h     | 11 +++--------
>>>    lib/arm64/asm/memory_areas.h   | 11 +++--------
>>>    lib/powerpc/asm/memory_areas.h | 11 +++--------
>>>    lib/ppc64/asm/memory_areas.h   | 11 +++--------
>>>    lib/s390x/asm/memory_areas.h   | 13 ++++++-------
>>>    lib/x86/asm/memory_areas.h     | 27 ++++++++++++++++-----------
>>>    lib/alloc_page.h               |  3 +++
>>>    lib/alloc_page.c               |  4 +---
>>>    9 files changed, 42 insertions(+), 58 deletions(-)
>>>
>>> diff --git a/lib/asm-generic/memory_areas.h
>>> b/lib/asm-generic/memory_areas.h index 927baa7..3074afe 100644
>>> --- a/lib/asm-generic/memory_areas.h
>>> +++ b/lib/asm-generic/memory_areas.h
>>> @@ -1,11 +1,10 @@
>>> -#ifndef MEMORY_AREAS_H
>>> -#define MEMORY_AREAS_H
>>> +#ifndef __ASM_GENERIC_MEMORY_AREAS_H__
>>> +#define __ASM_GENERIC_MEMORY_AREAS_H__
>>>    
>>>    #define AREA_NORMAL_PFN 0
>>>    #define AREA_NORMAL_NUMBER 0
>>> -#define AREA_NORMAL 1
>>> +#define AREA_NORMAL (1 << AREA_NORMAL_NUMBER)
>>>    
>>> -#define AREA_ANY -1
>>> -#define AREA_ANY_NUMBER 0xff
>>> +#define MAX_AREAS 1
>>>    
>>>    #endif
>>> diff --git a/lib/arm/asm/memory_areas.h b/lib/arm/asm/memory_areas.h
>>> index 927baa7..c723310 100644
>>> --- a/lib/arm/asm/memory_areas.h
>>> +++ b/lib/arm/asm/memory_areas.h
>>> @@ -1,11 +1,6 @@
>>> -#ifndef MEMORY_AREAS_H
>>> -#define MEMORY_AREAS_H
>>> +#ifndef _ASMARM_MEMORY_AREAS_H_
>>> +#define _ASMARM_MEMORY_AREAS_H_
>>>    
>>> -#define AREA_NORMAL_PFN 0
>>> -#define AREA_NORMAL_NUMBER 0
>>> -#define AREA_NORMAL 1
>>> -
>>> -#define AREA_ANY -1
>>> -#define AREA_ANY_NUMBER 0xff
>>> +#include <asm-generic/memory_areas.h>
>>>    
>>>    #endif
>>> diff --git a/lib/arm64/asm/memory_areas.h
>>> b/lib/arm64/asm/memory_areas.h index 927baa7..18e8ca8 100644
>>> --- a/lib/arm64/asm/memory_areas.h
>>> +++ b/lib/arm64/asm/memory_areas.h
>>> @@ -1,11 +1,6 @@
>>> -#ifndef MEMORY_AREAS_H
>>> -#define MEMORY_AREAS_H
>>> +#ifndef _ASMARM64_MEMORY_AREAS_H_
>>> +#define _ASMARM64_MEMORY_AREAS_H_
>>>    
>>> -#define AREA_NORMAL_PFN 0
>>> -#define AREA_NORMAL_NUMBER 0
>>> -#define AREA_NORMAL 1
>>> -
>>> -#define AREA_ANY -1
>>> -#define AREA_ANY_NUMBER 0xff
>>> +#include <asm-generic/memory_areas.h>
>>>    
>>>    #endif
>>> diff --git a/lib/powerpc/asm/memory_areas.h
>>> b/lib/powerpc/asm/memory_areas.h index 927baa7..76d1738 100644
>>> --- a/lib/powerpc/asm/memory_areas.h
>>> +++ b/lib/powerpc/asm/memory_areas.h
>>> @@ -1,11 +1,6 @@
>>> -#ifndef MEMORY_AREAS_H
>>> -#define MEMORY_AREAS_H
>>> +#ifndef _ASMPOWERPC_MEMORY_AREAS_H_
>>> +#define _ASMPOWERPC_MEMORY_AREAS_H_
>>>    
>>> -#define AREA_NORMAL_PFN 0
>>> -#define AREA_NORMAL_NUMBER 0
>>> -#define AREA_NORMAL 1
>>> -
>>> -#define AREA_ANY -1
>>> -#define AREA_ANY_NUMBER 0xff
>>> +#include <asm-generic/memory_areas.h>
>>>    
>>>    #endif
>>> diff --git a/lib/ppc64/asm/memory_areas.h
>>> b/lib/ppc64/asm/memory_areas.h index 927baa7..b9fd46b 100644
>>> --- a/lib/ppc64/asm/memory_areas.h
>>> +++ b/lib/ppc64/asm/memory_areas.h
>>> @@ -1,11 +1,6 @@
>>> -#ifndef MEMORY_AREAS_H
>>> -#define MEMORY_AREAS_H
>>> +#ifndef _ASMPPC64_MEMORY_AREAS_H_
>>> +#define _ASMPPC64_MEMORY_AREAS_H_
>>>    
>>> -#define AREA_NORMAL_PFN 0
>>> -#define AREA_NORMAL_NUMBER 0
>>> -#define AREA_NORMAL 1
>>> -
>>> -#define AREA_ANY -1
>>> -#define AREA_ANY_NUMBER 0xff
>>> +#include <asm-generic/memory_areas.h>
>>>    
>>>    #endif
>>> diff --git a/lib/s390x/asm/memory_areas.h
>>> b/lib/s390x/asm/memory_areas.h index 4856a27..827bfb3 100644
>>> --- a/lib/s390x/asm/memory_areas.h
>>> +++ b/lib/s390x/asm/memory_areas.h
>>> @@ -1,16 +1,15 @@
>>> -#ifndef MEMORY_AREAS_H
>>> -#define MEMORY_AREAS_H
>>> +#ifndef _ASMS390X_MEMORY_AREAS_H_
>>> +#define _ASMS390X_MEMORY_AREAS_H_
>>>    
>>> -#define AREA_NORMAL_PFN BIT(31-12)
>>> +#define AREA_NORMAL_PFN (1 << 19)
>>>    #define AREA_NORMAL_NUMBER 0
>>> -#define AREA_NORMAL 1
>>> +#define AREA_NORMAL (1 << AREA_NORMAL_NUMBER)
>>>    
>>>    #define AREA_LOW_PFN 0
>>>    #define AREA_LOW_NUMBER 1
>>> -#define AREA_LOW 2
>>> +#define AREA_LOW (1 << AREA_LOW_NUMBER)
>>>    
>>> -#define AREA_ANY -1
>>> -#define AREA_ANY_NUMBER 0xff
>>> +#define MAX_AREAS 2
>>>    
>>>    #define AREA_DMA31 AREA_LOW
>>>    
>>> diff --git a/lib/x86/asm/memory_areas.h b/lib/x86/asm/memory_areas.h
>>> index 952f5bd..e84016f 100644
>>> --- a/lib/x86/asm/memory_areas.h
>>> +++ b/lib/x86/asm/memory_areas.h
>>> @@ -1,21 +1,26 @@
>>> -#ifndef MEMORY_AREAS_H
>>> -#define MEMORY_AREAS_H
>>> +#ifndef _ASM_X86_MEMORY_AREAS_H_
>>> +#define _ASM_X86_MEMORY_AREAS_H_
>>>    
>>>    #define AREA_NORMAL_PFN BIT(36-12)
>>>    #define AREA_NORMAL_NUMBER 0
>>> -#define AREA_NORMAL 1
>>> +#define AREA_NORMAL (1 << AREA_NORMAL_NUMBER)
>>>    
>>> -#define AREA_PAE_HIGH_PFN BIT(32-12)
>>> -#define AREA_PAE_HIGH_NUMBER 1
>>> -#define AREA_PAE_HIGH 2
>>> +#define AREA_HIGH_PFN BIT(32-12)
>>> +#define AREA_HIGH_NUMBER 1
>>> +#define AREA_HIGH (1 << AREA_HIGH_NUMBER)
>>>    
>>> -#define AREA_LOW_PFN 0
>>> +#define AREA_LOW_PFN BIT(24-12)
>>>    #define AREA_LOW_NUMBER 2
>>> -#define AREA_LOW 4
>>> +#define AREA_LOW (1 << AREA_LOW_NUMBER)
>>>    
>>> -#define AREA_PAE (AREA_PAE | AREA_LOW)
>>> +#define AREA_LOWEST_PFN 0
>>> +#define AREA_LOWEST_NUMBER 3
>>> +#define AREA_LOWEST (1 << AREA_LOWEST_NUMBER)
>>>    
>>> -#define AREA_ANY -1
>>> -#define AREA_ANY_NUMBER 0xff
>>> +#define MAX_AREAS 4
>>> +
>>> +#define AREA_DMA24 AREA_LOWEST
>>> +#define AREA_DMA32 (AREA_LOWEST | AREA_LOW)
>>> +#define AREA_PAE36 (AREA_LOWEST | AREA_LOW | AREA_HIGH)
>>>    
>>>    #endif
>>> diff --git a/lib/alloc_page.h b/lib/alloc_page.h
>>> index 816ff5d..b6aace5 100644
>>> --- a/lib/alloc_page.h
>>> +++ b/lib/alloc_page.h
>>> @@ -10,6 +10,9 @@
>>>    
>>>    #include <asm/memory_areas.h>
>>>    
>>> +#define AREA_ANY -1
>>> +#define AREA_ANY_NUMBER 0xff
>>> +
>>>    /* Returns true if the page allocator has been initialized */
>>>    bool page_alloc_initialized(void);
>>>    
>>> diff --git a/lib/alloc_page.c b/lib/alloc_page.c
>>> index 685ab1e..ed0ff02 100644
>>> --- a/lib/alloc_page.c
>>> +++ b/lib/alloc_page.c
>>> @@ -19,8 +19,6 @@
>>>    #define NLISTS ((BITS_PER_LONG) - (PAGE_SHIFT))
>>>    #define PFN(x) ((uintptr_t)(x) >> PAGE_SHIFT)
>>>    
>>> -#define MAX_AREAS	6
>>> -
>>>    #define ORDER_MASK	0x3f
>>>    #define ALLOC_MASK	0x40
>>>    #define SPECIAL_MASK	0x80
>>> @@ -509,7 +507,7 @@ void page_alloc_init_area(u8 n, uintptr_t
>>> base_pfn, uintptr_t top_pfn) return;
>>>    	}
>>>    #ifdef AREA_HIGH_PFN
>>> -	__page_alloc_init_area(AREA_HIGH_NUMBER, AREA_HIGH_PFN),
>>> base_pfn, &top_pfn);
>>> +	__page_alloc_init_area(AREA_HIGH_NUMBER, AREA_HIGH_PFN,
>>> base_pfn, &top_pfn);
>>
>> Surprising that the compiler didn't complain !
>>
>>>    #endif
>>>    	__page_alloc_init_area(AREA_NORMAL_NUMBER,
>>> AREA_NORMAL_PFN, base_pfn, &top_pfn); #ifdef AREA_LOW_PFN
Reviewed-by: Krish Sadhukhan <krish.sadhukhan@oracle.com>
diff mbox series

Patch

diff --git a/lib/asm-generic/memory_areas.h b/lib/asm-generic/memory_areas.h
index 927baa7..3074afe 100644
--- a/lib/asm-generic/memory_areas.h
+++ b/lib/asm-generic/memory_areas.h
@@ -1,11 +1,10 @@ 
-#ifndef MEMORY_AREAS_H
-#define MEMORY_AREAS_H
+#ifndef __ASM_GENERIC_MEMORY_AREAS_H__
+#define __ASM_GENERIC_MEMORY_AREAS_H__
 
 #define AREA_NORMAL_PFN 0
 #define AREA_NORMAL_NUMBER 0
-#define AREA_NORMAL 1
+#define AREA_NORMAL (1 << AREA_NORMAL_NUMBER)
 
-#define AREA_ANY -1
-#define AREA_ANY_NUMBER 0xff
+#define MAX_AREAS 1
 
 #endif
diff --git a/lib/arm/asm/memory_areas.h b/lib/arm/asm/memory_areas.h
index 927baa7..c723310 100644
--- a/lib/arm/asm/memory_areas.h
+++ b/lib/arm/asm/memory_areas.h
@@ -1,11 +1,6 @@ 
-#ifndef MEMORY_AREAS_H
-#define MEMORY_AREAS_H
+#ifndef _ASMARM_MEMORY_AREAS_H_
+#define _ASMARM_MEMORY_AREAS_H_
 
-#define AREA_NORMAL_PFN 0
-#define AREA_NORMAL_NUMBER 0
-#define AREA_NORMAL 1
-
-#define AREA_ANY -1
-#define AREA_ANY_NUMBER 0xff
+#include <asm-generic/memory_areas.h>
 
 #endif
diff --git a/lib/arm64/asm/memory_areas.h b/lib/arm64/asm/memory_areas.h
index 927baa7..18e8ca8 100644
--- a/lib/arm64/asm/memory_areas.h
+++ b/lib/arm64/asm/memory_areas.h
@@ -1,11 +1,6 @@ 
-#ifndef MEMORY_AREAS_H
-#define MEMORY_AREAS_H
+#ifndef _ASMARM64_MEMORY_AREAS_H_
+#define _ASMARM64_MEMORY_AREAS_H_
 
-#define AREA_NORMAL_PFN 0
-#define AREA_NORMAL_NUMBER 0
-#define AREA_NORMAL 1
-
-#define AREA_ANY -1
-#define AREA_ANY_NUMBER 0xff
+#include <asm-generic/memory_areas.h>
 
 #endif
diff --git a/lib/powerpc/asm/memory_areas.h b/lib/powerpc/asm/memory_areas.h
index 927baa7..76d1738 100644
--- a/lib/powerpc/asm/memory_areas.h
+++ b/lib/powerpc/asm/memory_areas.h
@@ -1,11 +1,6 @@ 
-#ifndef MEMORY_AREAS_H
-#define MEMORY_AREAS_H
+#ifndef _ASMPOWERPC_MEMORY_AREAS_H_
+#define _ASMPOWERPC_MEMORY_AREAS_H_
 
-#define AREA_NORMAL_PFN 0
-#define AREA_NORMAL_NUMBER 0
-#define AREA_NORMAL 1
-
-#define AREA_ANY -1
-#define AREA_ANY_NUMBER 0xff
+#include <asm-generic/memory_areas.h>
 
 #endif
diff --git a/lib/ppc64/asm/memory_areas.h b/lib/ppc64/asm/memory_areas.h
index 927baa7..b9fd46b 100644
--- a/lib/ppc64/asm/memory_areas.h
+++ b/lib/ppc64/asm/memory_areas.h
@@ -1,11 +1,6 @@ 
-#ifndef MEMORY_AREAS_H
-#define MEMORY_AREAS_H
+#ifndef _ASMPPC64_MEMORY_AREAS_H_
+#define _ASMPPC64_MEMORY_AREAS_H_
 
-#define AREA_NORMAL_PFN 0
-#define AREA_NORMAL_NUMBER 0
-#define AREA_NORMAL 1
-
-#define AREA_ANY -1
-#define AREA_ANY_NUMBER 0xff
+#include <asm-generic/memory_areas.h>
 
 #endif
diff --git a/lib/s390x/asm/memory_areas.h b/lib/s390x/asm/memory_areas.h
index 4856a27..827bfb3 100644
--- a/lib/s390x/asm/memory_areas.h
+++ b/lib/s390x/asm/memory_areas.h
@@ -1,16 +1,15 @@ 
-#ifndef MEMORY_AREAS_H
-#define MEMORY_AREAS_H
+#ifndef _ASMS390X_MEMORY_AREAS_H_
+#define _ASMS390X_MEMORY_AREAS_H_
 
-#define AREA_NORMAL_PFN BIT(31-12)
+#define AREA_NORMAL_PFN (1 << 19)
 #define AREA_NORMAL_NUMBER 0
-#define AREA_NORMAL 1
+#define AREA_NORMAL (1 << AREA_NORMAL_NUMBER)
 
 #define AREA_LOW_PFN 0
 #define AREA_LOW_NUMBER 1
-#define AREA_LOW 2
+#define AREA_LOW (1 << AREA_LOW_NUMBER)
 
-#define AREA_ANY -1
-#define AREA_ANY_NUMBER 0xff
+#define MAX_AREAS 2
 
 #define AREA_DMA31 AREA_LOW
 
diff --git a/lib/x86/asm/memory_areas.h b/lib/x86/asm/memory_areas.h
index 952f5bd..e84016f 100644
--- a/lib/x86/asm/memory_areas.h
+++ b/lib/x86/asm/memory_areas.h
@@ -1,21 +1,26 @@ 
-#ifndef MEMORY_AREAS_H
-#define MEMORY_AREAS_H
+#ifndef _ASM_X86_MEMORY_AREAS_H_
+#define _ASM_X86_MEMORY_AREAS_H_
 
 #define AREA_NORMAL_PFN BIT(36-12)
 #define AREA_NORMAL_NUMBER 0
-#define AREA_NORMAL 1
+#define AREA_NORMAL (1 << AREA_NORMAL_NUMBER)
 
-#define AREA_PAE_HIGH_PFN BIT(32-12)
-#define AREA_PAE_HIGH_NUMBER 1
-#define AREA_PAE_HIGH 2
+#define AREA_HIGH_PFN BIT(32-12)
+#define AREA_HIGH_NUMBER 1
+#define AREA_HIGH (1 << AREA_HIGH_NUMBER)
 
-#define AREA_LOW_PFN 0
+#define AREA_LOW_PFN BIT(24-12)
 #define AREA_LOW_NUMBER 2
-#define AREA_LOW 4
+#define AREA_LOW (1 << AREA_LOW_NUMBER)
 
-#define AREA_PAE (AREA_PAE | AREA_LOW)
+#define AREA_LOWEST_PFN 0
+#define AREA_LOWEST_NUMBER 3
+#define AREA_LOWEST (1 << AREA_LOWEST_NUMBER)
 
-#define AREA_ANY -1
-#define AREA_ANY_NUMBER 0xff
+#define MAX_AREAS 4
+
+#define AREA_DMA24 AREA_LOWEST
+#define AREA_DMA32 (AREA_LOWEST | AREA_LOW)
+#define AREA_PAE36 (AREA_LOWEST | AREA_LOW | AREA_HIGH)
 
 #endif
diff --git a/lib/alloc_page.h b/lib/alloc_page.h
index 816ff5d..b6aace5 100644
--- a/lib/alloc_page.h
+++ b/lib/alloc_page.h
@@ -10,6 +10,9 @@ 
 
 #include <asm/memory_areas.h>
 
+#define AREA_ANY -1
+#define AREA_ANY_NUMBER 0xff
+
 /* Returns true if the page allocator has been initialized */
 bool page_alloc_initialized(void);
 
diff --git a/lib/alloc_page.c b/lib/alloc_page.c
index 685ab1e..ed0ff02 100644
--- a/lib/alloc_page.c
+++ b/lib/alloc_page.c
@@ -19,8 +19,6 @@ 
 #define NLISTS ((BITS_PER_LONG) - (PAGE_SHIFT))
 #define PFN(x) ((uintptr_t)(x) >> PAGE_SHIFT)
 
-#define MAX_AREAS	6
-
 #define ORDER_MASK	0x3f
 #define ALLOC_MASK	0x40
 #define SPECIAL_MASK	0x80
@@ -509,7 +507,7 @@  void page_alloc_init_area(u8 n, uintptr_t base_pfn, uintptr_t top_pfn)
 		return;
 	}
 #ifdef AREA_HIGH_PFN
-	__page_alloc_init_area(AREA_HIGH_NUMBER, AREA_HIGH_PFN), base_pfn, &top_pfn);
+	__page_alloc_init_area(AREA_HIGH_NUMBER, AREA_HIGH_PFN, base_pfn, &top_pfn);
 #endif
 	__page_alloc_init_area(AREA_NORMAL_NUMBER, AREA_NORMAL_PFN, base_pfn, &top_pfn);
 #ifdef AREA_LOW_PFN