* [PATCH] x86/mm: Skip the hypervisor range when walking PGD
@ 2015-11-05 18:56 Boris Ostrovsky
0 siblings, 0 replies; 6+ messages in thread
From: Boris Ostrovsky @ 2015-11-05 18:56 UTC (permalink / raw)
To: tglx, mingo, hpa; +Cc: linux, boris.ostrovsky, x86, linux-kernel, xen-devel
The range between 0xffff800000000000 and 0xffff87ffffffffff is reserved
for hypervisor and therefore we should not try to follow PGD's indexes
corresponding to those addresses.
While this has alsways been a problem, with commit e1a58320a38d ("x86/mm:
Warn on W^X mappings") ptdump_walk_pgd_level_core() can now be called
during boot, causing a PV Xen guest to crash.
Reported-by: Sander Eikelenboom <linux@eikelenboom.it>
Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
---
arch/x86/mm/dump_pagetables.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/arch/x86/mm/dump_pagetables.c b/arch/x86/mm/dump_pagetables.c
index 1bf417e..756c921 100644
--- a/arch/x86/mm/dump_pagetables.c
+++ b/arch/x86/mm/dump_pagetables.c
@@ -362,8 +362,13 @@ static void ptdump_walk_pgd_level_core(struct seq_file *m, pgd_t *pgd,
bool checkwx)
{
#ifdef CONFIG_X86_64
+/* ffff800000000000 - ffff87ffffffffff is reserved for hypervisor */
+#define is_hypervisor_range(idx) (paravirt_enabled() && \
+ (((idx) >= pgd_index(__PAGE_OFFSET) - 16) && \
+ ((idx) < pgd_index(__PAGE_OFFSET))))
pgd_t *start = (pgd_t *) &init_level4_pgt;
#else
+#define is_hypervisor_range(idx) 0
pgd_t *start = swapper_pg_dir;
#endif
pgprotval_t prot;
@@ -381,7 +386,7 @@ static void ptdump_walk_pgd_level_core(struct seq_file *m, pgd_t *pgd,
for (i = 0; i < PTRS_PER_PGD; i++) {
st.current_address = normalize_addr(i * PGD_LEVEL_MULT);
- if (!pgd_none(*start)) {
+ if (!pgd_none(*start) && !is_hypervisor_range(i)) {
if (pgd_large(*start) || !pgd_present(*start)) {
prot = pgd_flags(*start);
note_page(m, &st, __pgprot(prot), 1);
--
1.9.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] x86/mm: Skip the hypervisor range when walking PGD
2015-11-05 22:31 ` H. Peter Anvin
@ 2015-11-06 3:38 ` Boris Ostrovsky
2015-11-06 3:38 ` Boris Ostrovsky
1 sibling, 0 replies; 6+ messages in thread
From: Boris Ostrovsky @ 2015-11-06 3:38 UTC (permalink / raw)
To: H. Peter Anvin, tglx, mingo; +Cc: x86, linux-kernel, linux, xen-devel
On 11/05/2015 05:31 PM, H. Peter Anvin wrote:
> On 11/05/15 10:56, Boris Ostrovsky wrote:
>> The range between 0xffff800000000000 and 0xffff87ffffffffff is reserved
>> for hypervisor and therefore we should not try to follow PGD's indexes
>> corresponding to those addresses.
>>
>> While this has alsways been a problem, with commit e1a58320a38d ("x86/mm:
>> Warn on W^X mappings") ptdump_walk_pgd_level_core() can now be called
>> during boot, causing a PV Xen guest to crash.
>>
>> Reported-by: Sander Eikelenboom <linux@eikelenboom.it>
>> Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
>> ---
>> arch/x86/mm/dump_pagetables.c | 7 ++++++-
>> 1 file changed, 6 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/x86/mm/dump_pagetables.c b/arch/x86/mm/dump_pagetables.c
>> index 1bf417e..756c921 100644
>> --- a/arch/x86/mm/dump_pagetables.c
>> +++ b/arch/x86/mm/dump_pagetables.c
>> @@ -362,8 +362,13 @@ static void ptdump_walk_pgd_level_core(struct seq_file *m, pgd_t *pgd,
>> bool checkwx)
>> {
>> #ifdef CONFIG_X86_64
>> +/* ffff800000000000 - ffff87ffffffffff is reserved for hypervisor */
>> +#define is_hypervisor_range(idx) (paravirt_enabled() && \
>> + (((idx) >= pgd_index(__PAGE_OFFSET) - 16) && \
>> + ((idx) < pgd_index(__PAGE_OFFSET))))
>> pgd_t *start = (pgd_t *) &init_level4_pgt;
>> #else
>> +#define is_hypervisor_range(idx) 0
>> pgd_t *start = swapper_pg_dir;
>> #endif
>> pgprotval_t prot;
>> @@ -381,7 +386,7 @@ static void ptdump_walk_pgd_level_core(struct seq_file *m, pgd_t *pgd,
>>
>> for (i = 0; i < PTRS_PER_PGD; i++) {
>> st.current_address = normalize_addr(i * PGD_LEVEL_MULT);
>> - if (!pgd_none(*start)) {
>> + if (!pgd_none(*start) && !is_hypervisor_range(i)) {
>> if (pgd_large(*start) || !pgd_present(*start)) {
>> prot = pgd_flags(*start);
>> note_page(m, &st, __pgprot(prot), 1);
>>
> Maybe we could use the max_lines field in the address_markers[] array?
> We really shouldn't be mapping anything in the hypervisor space even on
> native.
You mean overload max_lines with a value indicating that the range needs
to be skipped?
That would require checking the range on each loop iteration since we
update st.marker *after* we've walked a particular index. (And I think
it would need to be done on each level to be generic).
I could just drop paravirt_enabled() in is_hypervisor_range() but you
are thinking about avoiding the macro altogether, right?
(I do need to add hypervisor range to address_markers[])
-boris
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] x86/mm: Skip the hypervisor range when walking PGD
2015-11-05 22:31 ` H. Peter Anvin
2015-11-06 3:38 ` Boris Ostrovsky
@ 2015-11-06 3:38 ` Boris Ostrovsky
1 sibling, 0 replies; 6+ messages in thread
From: Boris Ostrovsky @ 2015-11-06 3:38 UTC (permalink / raw)
To: H. Peter Anvin, tglx, mingo; +Cc: linux, x86, linux-kernel, xen-devel
On 11/05/2015 05:31 PM, H. Peter Anvin wrote:
> On 11/05/15 10:56, Boris Ostrovsky wrote:
>> The range between 0xffff800000000000 and 0xffff87ffffffffff is reserved
>> for hypervisor and therefore we should not try to follow PGD's indexes
>> corresponding to those addresses.
>>
>> While this has alsways been a problem, with commit e1a58320a38d ("x86/mm:
>> Warn on W^X mappings") ptdump_walk_pgd_level_core() can now be called
>> during boot, causing a PV Xen guest to crash.
>>
>> Reported-by: Sander Eikelenboom <linux@eikelenboom.it>
>> Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
>> ---
>> arch/x86/mm/dump_pagetables.c | 7 ++++++-
>> 1 file changed, 6 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/x86/mm/dump_pagetables.c b/arch/x86/mm/dump_pagetables.c
>> index 1bf417e..756c921 100644
>> --- a/arch/x86/mm/dump_pagetables.c
>> +++ b/arch/x86/mm/dump_pagetables.c
>> @@ -362,8 +362,13 @@ static void ptdump_walk_pgd_level_core(struct seq_file *m, pgd_t *pgd,
>> bool checkwx)
>> {
>> #ifdef CONFIG_X86_64
>> +/* ffff800000000000 - ffff87ffffffffff is reserved for hypervisor */
>> +#define is_hypervisor_range(idx) (paravirt_enabled() && \
>> + (((idx) >= pgd_index(__PAGE_OFFSET) - 16) && \
>> + ((idx) < pgd_index(__PAGE_OFFSET))))
>> pgd_t *start = (pgd_t *) &init_level4_pgt;
>> #else
>> +#define is_hypervisor_range(idx) 0
>> pgd_t *start = swapper_pg_dir;
>> #endif
>> pgprotval_t prot;
>> @@ -381,7 +386,7 @@ static void ptdump_walk_pgd_level_core(struct seq_file *m, pgd_t *pgd,
>>
>> for (i = 0; i < PTRS_PER_PGD; i++) {
>> st.current_address = normalize_addr(i * PGD_LEVEL_MULT);
>> - if (!pgd_none(*start)) {
>> + if (!pgd_none(*start) && !is_hypervisor_range(i)) {
>> if (pgd_large(*start) || !pgd_present(*start)) {
>> prot = pgd_flags(*start);
>> note_page(m, &st, __pgprot(prot), 1);
>>
> Maybe we could use the max_lines field in the address_markers[] array?
> We really shouldn't be mapping anything in the hypervisor space even on
> native.
You mean overload max_lines with a value indicating that the range needs
to be skipped?
That would require checking the range on each loop iteration since we
update st.marker *after* we've walked a particular index. (And I think
it would need to be done on each level to be generic).
I could just drop paravirt_enabled() in is_hypervisor_range() but you
are thinking about avoiding the macro altogether, right?
(I do need to add hypervisor range to address_markers[])
-boris
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] x86/mm: Skip the hypervisor range when walking PGD
2015-11-05 18:56 Boris Ostrovsky
2015-11-05 22:31 ` H. Peter Anvin
@ 2015-11-05 22:31 ` H. Peter Anvin
2015-11-06 3:38 ` Boris Ostrovsky
2015-11-06 3:38 ` Boris Ostrovsky
1 sibling, 2 replies; 6+ messages in thread
From: H. Peter Anvin @ 2015-11-05 22:31 UTC (permalink / raw)
To: Boris Ostrovsky, tglx, mingo; +Cc: x86, linux-kernel, linux, xen-devel
On 11/05/15 10:56, Boris Ostrovsky wrote:
> The range between 0xffff800000000000 and 0xffff87ffffffffff is reserved
> for hypervisor and therefore we should not try to follow PGD's indexes
> corresponding to those addresses.
>
> While this has alsways been a problem, with commit e1a58320a38d ("x86/mm:
> Warn on W^X mappings") ptdump_walk_pgd_level_core() can now be called
> during boot, causing a PV Xen guest to crash.
>
> Reported-by: Sander Eikelenboom <linux@eikelenboom.it>
> Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
> ---
> arch/x86/mm/dump_pagetables.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/mm/dump_pagetables.c b/arch/x86/mm/dump_pagetables.c
> index 1bf417e..756c921 100644
> --- a/arch/x86/mm/dump_pagetables.c
> +++ b/arch/x86/mm/dump_pagetables.c
> @@ -362,8 +362,13 @@ static void ptdump_walk_pgd_level_core(struct seq_file *m, pgd_t *pgd,
> bool checkwx)
> {
> #ifdef CONFIG_X86_64
> +/* ffff800000000000 - ffff87ffffffffff is reserved for hypervisor */
> +#define is_hypervisor_range(idx) (paravirt_enabled() && \
> + (((idx) >= pgd_index(__PAGE_OFFSET) - 16) && \
> + ((idx) < pgd_index(__PAGE_OFFSET))))
> pgd_t *start = (pgd_t *) &init_level4_pgt;
> #else
> +#define is_hypervisor_range(idx) 0
> pgd_t *start = swapper_pg_dir;
> #endif
> pgprotval_t prot;
> @@ -381,7 +386,7 @@ static void ptdump_walk_pgd_level_core(struct seq_file *m, pgd_t *pgd,
>
> for (i = 0; i < PTRS_PER_PGD; i++) {
> st.current_address = normalize_addr(i * PGD_LEVEL_MULT);
> - if (!pgd_none(*start)) {
> + if (!pgd_none(*start) && !is_hypervisor_range(i)) {
> if (pgd_large(*start) || !pgd_present(*start)) {
> prot = pgd_flags(*start);
> note_page(m, &st, __pgprot(prot), 1);
>
Maybe we could use the max_lines field in the address_markers[] array?
We really shouldn't be mapping anything in the hypervisor space even on
native.
-hpa
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] x86/mm: Skip the hypervisor range when walking PGD
2015-11-05 18:56 Boris Ostrovsky
@ 2015-11-05 22:31 ` H. Peter Anvin
2015-11-05 22:31 ` H. Peter Anvin
1 sibling, 0 replies; 6+ messages in thread
From: H. Peter Anvin @ 2015-11-05 22:31 UTC (permalink / raw)
To: Boris Ostrovsky, tglx, mingo; +Cc: linux, x86, linux-kernel, xen-devel
On 11/05/15 10:56, Boris Ostrovsky wrote:
> The range between 0xffff800000000000 and 0xffff87ffffffffff is reserved
> for hypervisor and therefore we should not try to follow PGD's indexes
> corresponding to those addresses.
>
> While this has alsways been a problem, with commit e1a58320a38d ("x86/mm:
> Warn on W^X mappings") ptdump_walk_pgd_level_core() can now be called
> during boot, causing a PV Xen guest to crash.
>
> Reported-by: Sander Eikelenboom <linux@eikelenboom.it>
> Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
> ---
> arch/x86/mm/dump_pagetables.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/mm/dump_pagetables.c b/arch/x86/mm/dump_pagetables.c
> index 1bf417e..756c921 100644
> --- a/arch/x86/mm/dump_pagetables.c
> +++ b/arch/x86/mm/dump_pagetables.c
> @@ -362,8 +362,13 @@ static void ptdump_walk_pgd_level_core(struct seq_file *m, pgd_t *pgd,
> bool checkwx)
> {
> #ifdef CONFIG_X86_64
> +/* ffff800000000000 - ffff87ffffffffff is reserved for hypervisor */
> +#define is_hypervisor_range(idx) (paravirt_enabled() && \
> + (((idx) >= pgd_index(__PAGE_OFFSET) - 16) && \
> + ((idx) < pgd_index(__PAGE_OFFSET))))
> pgd_t *start = (pgd_t *) &init_level4_pgt;
> #else
> +#define is_hypervisor_range(idx) 0
> pgd_t *start = swapper_pg_dir;
> #endif
> pgprotval_t prot;
> @@ -381,7 +386,7 @@ static void ptdump_walk_pgd_level_core(struct seq_file *m, pgd_t *pgd,
>
> for (i = 0; i < PTRS_PER_PGD; i++) {
> st.current_address = normalize_addr(i * PGD_LEVEL_MULT);
> - if (!pgd_none(*start)) {
> + if (!pgd_none(*start) && !is_hypervisor_range(i)) {
> if (pgd_large(*start) || !pgd_present(*start)) {
> prot = pgd_flags(*start);
> note_page(m, &st, __pgprot(prot), 1);
>
Maybe we could use the max_lines field in the address_markers[] array?
We really shouldn't be mapping anything in the hypervisor space even on
native.
-hpa
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] x86/mm: Skip the hypervisor range when walking PGD
@ 2015-11-05 18:56 Boris Ostrovsky
2015-11-05 22:31 ` H. Peter Anvin
2015-11-05 22:31 ` H. Peter Anvin
0 siblings, 2 replies; 6+ messages in thread
From: Boris Ostrovsky @ 2015-11-05 18:56 UTC (permalink / raw)
To: tglx, mingo, hpa; +Cc: x86, linux-kernel, linux, xen-devel, boris.ostrovsky
The range between 0xffff800000000000 and 0xffff87ffffffffff is reserved
for hypervisor and therefore we should not try to follow PGD's indexes
corresponding to those addresses.
While this has alsways been a problem, with commit e1a58320a38d ("x86/mm:
Warn on W^X mappings") ptdump_walk_pgd_level_core() can now be called
during boot, causing a PV Xen guest to crash.
Reported-by: Sander Eikelenboom <linux@eikelenboom.it>
Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
---
arch/x86/mm/dump_pagetables.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/arch/x86/mm/dump_pagetables.c b/arch/x86/mm/dump_pagetables.c
index 1bf417e..756c921 100644
--- a/arch/x86/mm/dump_pagetables.c
+++ b/arch/x86/mm/dump_pagetables.c
@@ -362,8 +362,13 @@ static void ptdump_walk_pgd_level_core(struct seq_file *m, pgd_t *pgd,
bool checkwx)
{
#ifdef CONFIG_X86_64
+/* ffff800000000000 - ffff87ffffffffff is reserved for hypervisor */
+#define is_hypervisor_range(idx) (paravirt_enabled() && \
+ (((idx) >= pgd_index(__PAGE_OFFSET) - 16) && \
+ ((idx) < pgd_index(__PAGE_OFFSET))))
pgd_t *start = (pgd_t *) &init_level4_pgt;
#else
+#define is_hypervisor_range(idx) 0
pgd_t *start = swapper_pg_dir;
#endif
pgprotval_t prot;
@@ -381,7 +386,7 @@ static void ptdump_walk_pgd_level_core(struct seq_file *m, pgd_t *pgd,
for (i = 0; i < PTRS_PER_PGD; i++) {
st.current_address = normalize_addr(i * PGD_LEVEL_MULT);
- if (!pgd_none(*start)) {
+ if (!pgd_none(*start) && !is_hypervisor_range(i)) {
if (pgd_large(*start) || !pgd_present(*start)) {
prot = pgd_flags(*start);
note_page(m, &st, __pgprot(prot), 1);
--
1.9.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-11-06 3:39 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-05 18:56 [PATCH] x86/mm: Skip the hypervisor range when walking PGD Boris Ostrovsky
-- strict thread matches above, loose matches on Subject: below --
2015-11-05 18:56 Boris Ostrovsky
2015-11-05 22:31 ` H. Peter Anvin
2015-11-05 22:31 ` H. Peter Anvin
2015-11-06 3:38 ` Boris Ostrovsky
2015-11-06 3:38 ` Boris Ostrovsky
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.