x86: use pgd accessors when cloning a pgd range.
Subsystems (2)
PATCH 1/1 x86: use pgd accessors when cloning a pgd range.
Page tables should always be updated using the proper accessor methods. Not doing so bypasses the paravirt infrastructure.
In this case the failure to do so was exposed under Xen by b40827fa7268 "x86-32, mm: Add an initial page table for core bootstrapping".
--- arch/x86/include/asm/pgtable.h | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)
arch/x86/include/asm/pgtable.h +4 -1
@@ -619,7 +619,10 @@ static inline void ptep_set_wrprotect(struct mm_struct *mm,*/ static inline void clone_pgd_range (pgd_t *dst,pgd_t *src,int count) { -memcpy (dst, src, count *sizeof (pgd_t)); +int i; + +for (i=0 ; i<count; i++) +set_pgd (&dst[i], src[i]); }
Signature · 1 line
1.5.6.5
Borislav Petkov
maintainerQuoted 20 lines · Ian Campbell
Page tables should always be updated using the proper accessor methods. Not doing so bypasses the paravirt infrastructure.
In this case the failure to do so was exposed under Xen by
b40827fa7268"x86-32, mm: Add an initial page table for core bootstrapping".Signed-off-by Ian Campbell <[email protected]>Cc Borislav Petkov <[email protected]>Cc H. Peter Anvin <[email protected]>Cc Jeremy Fitzhardinge <[email protected]>--- arch/x86/include/asm/pgtable.h | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)arch/x86/include/asm/pgtable.h +0
-0
arch/x86/include/asm/pgtable.h static inline void ptep_set_wrprotect(struct mm_struct *mm, · line 625
Quoted 8 lines
arch/x86/include/asm/pgtable.h +4
-1@@ -619,7 +619,10 @@ static inline void ptep_set_wrprotect(struct mm_struct *mm,*/ static inline void clone_pgd_range (pgd_t *dst,pgd_t *src,int count) { -memcpy (dst, src, count *sizeof (pgd_t)); +int i; + +for (i=0 ; i<count; i++) +set_pgd (&dst[i], src[i]);
Hmm, this slows down clone_pgd_range(). It is called at 3 sites total, two of which happen only on boot in setup_arch() so they can be ignored but the callchain
copy_process()
...mm_init()
|->mm_alloc_pgd()
|->pgd_alloc()
|->pgd_ctor()
|->clone_pgd_range()could become noticeable. To be on the safe side, I'd make clone_pgd_range() a macro calling either the native or the xen version..
hpa?
Signature · 2 lines
Regards/Gruss, Boris.
Quoted 38 lines · Borislav Petkov
Quoted 20 lines · Ian Campbell
Page tables should always be updated using the proper accessor methods. Not doing so bypasses the paravirt infrastructure.
In this case the failure to do so was exposed under Xen by
b40827fa7268"x86-32, mm: Add an initial page table for core bootstrapping".Signed-off-by Ian Campbell <[email protected]>Cc Borislav Petkov <[email protected]>Cc H. Peter Anvin <[email protected]>Cc Jeremy Fitzhardinge <[email protected]>--- arch/x86/include/asm/pgtable.h | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)arch/x86/include/asm/pgtable.h +0
-0arch/x86/include/asm/pgtable.h static inline void ptep_set_wrprotect(struct mm_struct *mm, · line 625
Quoted 8 lines
arch/x86/include/asm/pgtable.h +4
-1@@ -619,7 +619,10 @@ static inline void ptep_set_wrprotect(struct mm_struct *mm,*/ static inline void clone_pgd_range (pgd_t *dst,pgd_t *src,int count) { -memcpy (dst, src, count *sizeof (pgd_t)); +int i; + +for (i=0 ; i<count; i++) +set_pgd (&dst[i], src[i]);Hmm, this slows down
clone_pgd_range(). It is called at 3 sites total, two of which happen only on boot insetup_arch()so they can be ignored but the callchain
copy_process()
...mm_init()
|->mm_alloc_pgd()
|->pgd_alloc()
Quoted 5 lines
|->pgd_ctor() |->clone_pgd_range()could become noticeable. To be on the safe side, I'd make
clone_pgd_range()a macro calling either the native or the xen version..
Frankly I'd want to see some numbers before getting too worried about it; if it were a problem we could make the native set_pgd inlined into the callside (it is just a memory write after all), which will be very similar to memcpy in performance.
I am, however, more concerned about the effect on performance under Xen. xen_set_pgd will avoid doing a hypercall in this case (the pagetable isn't yet pinned), but it has to do a moderate amount of work to avoid doing the hypercall, and could really add some measurable latency to process creation (which is not something we need right now). For that a clone_pgd_range() hypercall is the most straightforward answer, but I'm loathe to propose that right now.
This never used to be a problem. Perhaps we can change how clone_pgd_range is used at boot time to avoid it in the Xen case (since we don't care about the secondary pagetable)?
J
Quoted 5 lines · Jeremy Fitzhardinge
This never used to be a problem. Perhaps we can change how
clone_pgd_rangeis used at boot time to avoid it in the Xen case (since we don't care about the secondary pagetable)?
Xen shouldn't have any users of this, since it's used for low-level operations like SMP bootstrap, suspend to RAM, reboot and low-level BIOS functionality.
-hpa
Quoted 11 lines · H. Peter Anvin
Quoted 5 lines · Jeremy Fitzhardinge
This never used to be a problem. Perhaps we can change how
clone_pgd_rangeis used at boot time to avoid it in the Xen case (since we don't care about the secondary pagetable)?Xen shouldn't have any users of this, since it's used for low-level operations like SMP bootstrap, suspend to RAM, reboot and low-level BIOS functionality.
Right, but it is being called smack in the middle of setup_arch(). It looks like they could be hidden away in native_pagetable_setup_start/done though.
J
Quoted 8 lines · Jeremy Fitzhardinge
Quoted 7 lines · H. Peter Anvin
Quoted 5 lines · Jeremy Fitzhardinge
This never used to be a problem. Perhaps we can change how
clone_pgd_rangeis used at boot time to avoid it in the Xen case (since we don't care about the secondary pagetable)?
Quoted 9 lines
Quoted 4 lines
Xen shouldn't have any users of this, since it's used for low-level operations like SMP bootstrap, suspend to RAM, reboot and low-level BIOS functionality.
Right, but it is being called smack in the middle of
setup_arch(). It looks like they could be hidden away in native_pagetable_setup_start/done though.
This is what makes me absolutely hate paravirt with a passion... "let's hid things away in <obscure place> and make it absolutely impossible to either follow the code flow or figure out what the intended semantics are supposed to be." (Let not even get me started on how ill-defined the semantics of some of the paravirt operations are.) In this case, at the most you need a single flag of state... or you could even just ignore this low-level data structure that you will never use in the first place. Ian's message just mentioned "a failure" and never described in any way what kind of "failure" it was.
-hpa
Quoted 19 lines · H. Peter Anvin
Quoted 8 lines · Jeremy Fitzhardinge
Quoted 7 lines · H. Peter Anvin
Quoted 5 lines · Jeremy Fitzhardinge
This never used to be a problem. Perhaps we can change how
clone_pgd_rangeis used at boot time to avoid it in the Xen case (since we don't care about the secondary pagetable)?Quoted 9 lines
Quoted 4 lines
Xen shouldn't have any users of this, since it's used for low-level operations like SMP bootstrap, suspend to RAM, reboot and low-level BIOS functionality.
Right, but it is being called smack in the middle of
setup_arch(). It looks like they could be hidden away in native_pagetable_setup_start/done though.
Quoted 9 lines
This is what makes me absolutely hate paravirt with a passion... "let's hid things away in <obscure place> and make it absolutely impossible to either follow the code flow or figure out what the intended semantics are supposed to be." (Let not even get me started on how ill-defined the semantics of some of the paravirt operations are.) In this case, at the most you need a single flag of state... or you could even just ignore this low-level data structure that you will never use in the first place. Ian's message just mentioned "a failure" and never described in any way what kind of "failure" it was.
That was vague of me, sorry about that. The failure was Xen shooting the guest due to an attempt to write to swapper_pg_dir directly, which isn't allowed for active pagetables under Xen.
Ian.
Quoted 20 lines · H. Peter Anvin
Quoted 9 lines · Jeremy Fitzhardinge
Quoted 8 lines · H. Peter Anvin
Quoted 6 lines · Jeremy Fitzhardinge
This never used to be a problem. Perhaps we can change how
clone_pgd_rangeis used at boot time to avoid it in the Xen case (since
we don't care about the secondary pagetable)?Quoted 9 lines
Quoted 4 lines
Xen shouldn't have any users of this, since it's used for low-level operations like SMP bootstrap, suspend to RAM, reboot and low-level BIOS functionality.
Right, but it is being called smack in the middle of
setup_arch(). It looks like they could be hidden away in native_pagetable_setup_start/done though.
Quoted 4 lines
This is what makes me absolutely hate paravirt with a passion... "let's hid things away in <obscure place> and make it absolutely impossible to either follow the code flow or figure out what the intended semantics are supposed to be."
Its not really an obscure place; it's where x86-32 does the rest of its boot-time pagetable adjustments (like cleaning out the low identity maps, etc). Having those clone_pgd_ranges() floating around in setup_arch() is out of place.
Quoted 6 lines
(Let not even get me started on how ill-defined the semantics of some of the paravirt operations are.) In this case, at the most you need a single flag of state... or you could even just ignore this low-level data structure that you will never use in the first place. Ian's message just mentioned "a failure" and never described in any way what kind of "failure" it was.
It would be a pagefault from Xen preventing a direct write to the pgd level of an active pagetable. At the point in setup_arch() where it does the first clone_pgd_range() we're already running on swapper_pg_dir and the copy from initial_page_table is outright wrong.
As Ian suggests, we could switch Xen to use initial_page_table at boot then move to swapper_pg_dir in the same way native does.
J
Quoted 9 lines · Jeremy Fitzhardinge
Quoted 2 lines · H. Peter Anvin
Ian's message just mentioned "a failure" and never described in any way what kind of "failure" it was.
It would be a pagefault from Xen preventing a direct write to the pgd level of an active pagetable. At the point in
setup_arch()where it does the firstclone_pgd_range()we're already running onswapper_pg_dirand the copy frominitial_page_tableis outright wrong.
I'd missed that aspect, yes the contents of initial_page_table are wrong. I'm not sure now how my patch to clone_pgd_range even made a difference...
Quoted 2 lines
As Ian suggests, we could switch Xen to use
initial_page_tableat boot then move toswapper_pg_dirin the same way native does.
Accidentally did that in private mail, for everyone else the gory details are:
Quoted 20 lines
xen_setup_kernel_pagetableoperates oninitial_page_tableinstead ofswapper_pg_dir. We do not pininitial_page_tableapart from the implicit
one from writing it to cr3 (it is necessarily r/o though).So we enter
setup_archrunning oninitial_page_tableand withswapper_pg_dirmapped r/w, which is how it looks on native too. So at this point the:
clone_pgd_range(swapper_pg_dir +KERNEL_PGD_BOUNDARY,
initial_page_table+KERNEL_PGD_BOUNDARY,KERNEL_PGD_PTRS);
works just fine and we reach:load_cr3(swapper_pg_dir);Then in
__xen_write_cr3we notice the first attempt to switch toswapper_pg_dirand only at that point do we make it r/o and pin it. When
we then actually do the switch toswapper_pg_dirthat releases the implicit pin oninitial_page_tableso we can make it r/o again.
Quoted 8 lines
The later on we reach the:
clone_pgd_range(initial_page_table +KERNEL_PGD_BOUNDARY,
swapper_pg_dir+KERNEL_PGD_BOUNDARY,
KERNEL_PGD_PTRS);
which will succeed becauseinitial_page_tableis r/w again.We don't care about the pin on
initial_page_tablebecause we should never need it again.
Ian.
Quoted 11 lines · Jeremy Fitzhardinge
Quoted 5 lines
This is what makes me absolutely hate paravirt with a passion... "let's hid things away in<obscure place> and make it absolutely impossible to either follow the code flow or figure out what the intended semantics are supposed to be."
Its not really an obscure place; it's where x86-32 does the rest of its boot-time pagetable adjustments (like cleaning out the low identity maps, etc). Having those
clone_pgd_ranges()floating around insetup_arch()is out of place.
"Cleaning out the low identity maps" is part of what this patchset eliminates. This is exactly a good reason why paravirt_ops damages the kernel -- it makes it impossible to make forward process.
Quoted 7 lines
Quoted 6 lines
(Let not even get me started on how ill-defined the semantics of some of the paravirt operations are.) In this case, at the most you need a single flag of state... or you could even just ignore this low-level data structure that you will never use in the first place. Ian's message just mentioned "a failure" and never described in any way what kind of "failure" it was.
Quoted 7 lines
It would be a pagefault from Xen preventing a direct write to the pgd level of an active pagetable. At the point in
setup_arch()where it does the firstclone_pgd_range()we're already running onswapper_pg_dirand the copy frominitial_page_tableis outright wrong.As Ian suggests, we could switch Xen to use
initial_page_tableat boot then move toswapper_pg_dirin the same way native does.
Once the failure was explained, it makes more sense. Either that or just skip this setting if we're already running on swapper_pg_dir.
Let me state this clearly: if Xen is going to continue to live as a merged platform, it has to have an obligation to follow changes on the native platform. This is not unique to Xen, but rather a universal rule for integrated platforms. Xen is more widely used than a lot of the other minority platforms, which means it legitimately gets allowed more slack, but that is moderated by its tremendous invasiveness.
Quite frankly, the single biggest thing you could improve is to improve documentation about what you expect in terms of semantics of various entry points. There are a number of cleanups which we currently cannot do because they are directly mapped to paravirt_ops which unclear or nonsensical semantics. Having a more explicit description of the design space would help there.
paravirt_ops is fundamentally misdesigned as a large monolithic driverization layer which combines a lot of unrelated things. In a whole lot of cases it directly duplicates driverization layers already in the kernel, meaning we take the cost both in cost clarity and performance multiple times. The patching technology is nice, and it would be good to have that available to other platform layers as well, but paravirt_ops as it currently sits is going to have to go at some point.
-hpa
Quoted 7 lines · H. Peter Anvin
Quoted 6 lines · Jeremy Fitzhardinge
Quoted 5 lines
This is what makes me absolutely hate paravirt with a passion... "let's hid things away in<obscure place> and make it absolutely impossible to either follow the code flow or figure out what the intended semantics are supposed to be."
Quoted 8 lines
Quoted 5 lines
Its not really an obscure place; it's where x86-32 does the rest of its boot-time pagetable adjustments (like cleaning out the low identity maps, etc). Having those
clone_pgd_ranges()floating around insetup_arch()is out of place."Cleaning out the low identity maps" is part of what this patchset eliminates.
Sorry, I didn't look closely enough; its actually removing mappings beyond the end of physical memory (though I'm not sure why it is 32-bit only?).
Quoted 2 lines
This is exactly a good reason why
paravirt_opsdamages the kernel --
it makes it impossible to make forward process.
I don't follow. Why is it impossible to make forward progress? How specifically does pvops make it impossible?
Quoted 10 lines
Quoted 7 lines
It would be a pagefault from Xen preventing a direct write to the pgd level of an active pagetable. At the point in
setup_arch()where it does the firstclone_pgd_range()we're already running onswapper_pg_dirand the copy frominitial_page_tableis outright wrong.As Ian suggests, we could switch Xen to use
initial_page_tableat boot then move toswapper_pg_dirin the same way native does.Once the failure was explained, it makes more sense. Either that or just skip this setting if we're already running on
swapper_pg_dir.
Yes, that's probably the simplest answer (Ian just proposed it independently).
Quoted 7 lines
Let me state this clearly: if Xen is going to continue to live as a merged platform, it has to have an obligation to follow changes on the native platform. This is not unique to Xen, but rather a universal rule for integrated platforms. Xen is more widely used than a lot of the other minority platforms, which means it legitimately gets allowed more slack, but that is moderated by its tremendous invasiveness.
Quoted 5 lines
Quite frankly, the single biggest thing you could improve is to improve documentation about what you expect in terms of semantics of various entry points. There are a number of cleanups which we currently cannot do because they are directly mapped to
paravirt_opswhich unclear or nonsensical semantics.
What do you have in mind? I'm always pro-cleanup.
Quoted 1 line
Having a more explicit description of the design space would help there.
I agree. The hot-path pvops (interrupt control, context switch, mmu updates, etc) are fairly easily defined, but the init time ops are pretty ad-hoc and often defy simple definition.
Quoted 5 lines
paravirt_opsis fundamentally misdesigned as a large monolithic driverization layer which combines a lot of unrelated things. In a whole lot of cases it directly duplicates driverization layers already in the kernel, meaning we take the cost both in cost clarity and performance multiple times.
Again, do you have something specific in mind? We always adopted the view that we should use an existing abstraction if one is available, rather than always extending pvops. If a new common layer comes into existence that subsumes or obsoletes pvops (or can be easily adoped to do so), then I'm always eager to do that.
Quoted 3 lines
The patching technology is nice, and it would be good to have that
available to other platform layers as well, butparavirt_opsas it currently sits is going to have to go at some point.
"pvops" as a single thing is a bit of a misnomer these days, in that it has been devolving into a number of different functional pieces specific to different problem domains, with the only unifying thing is that they share the patching machinery. They're also all controlled by a single fat CONFIG_PARAVIRT, but someone posted a patch to separate them out into distinct config options so they could be enabled/disabled independently as needed, but it seems it was never merged. I even remember acking it.
Aside from that, the notion of pvops has been extending into this broader notion of supporting non-traditional x86 platforms, and indeed the hooks I'm referring to here are now part of that (or at least tglx factored them out of the pvops infrastructure at the same time as the things like timers and the like). So really what you're complaining about is that we have lots of indirection and late binding - and yes, well, there is rather a lot of that in the kernel overall.
J
Quoted 10 lines · Jeremy Fitzhardinge
"pvops" as a single thing is a bit of a misnomer these days, in that it has been devolving into a number of different functional pieces specific to different problem domains, with the only unifying thing is that they share the patching machinery. They're also all controlled by a single fat
CONFIG_PARAVIRT, but someone posted a patch to separate them out into distinct config options so they could be enabled/disabled independently as needed, but it seems it was never merged. I even remember acking it.
Quoted 8 lines
Aside from that, the notion of pvops has been extending into this broader notion of supporting non-traditional x86 platforms, and indeed the hooks I'm referring to here are now part of that (or at least tglx factored them out of the pvops infrastructure at the same time as the things like timers and the like). So really what you're complaining about is that we have lots of indirection and late binding - and yes, well, there is rather a lot of that in the kernel overall.
tglx's changes are part of the work to clean up and eliminate pvops where it is redundant. However, the pvops machinery has been too rigid to be reused, resulting in that we now have something like four different patching machineries in the kernel.
But of course, the worst part of pvops is that it is used at a low level in a lot of hot paths, and the resulting header files looking like someone barfed on a piece of paper, full little inlines pointing "here, no over here, no over here."
The indirection and late binding is a problem, especially when the indirection layer is badly designed, and encodes design bugs. Last I checked, as an example, there are three paravirt_ops to deal with two levels of page tables on non-PAE i386. One of them (not sure which one) doesn't do anything on native, but hell if anyone knows if they are actually dead.
-hpa
One more thing: one thing in particular that is very obnoxious are hooks that are null on native hardware, but aren't documented. That means there is no actual reference for their expected behavior.
-hpa
Borislav Petkov
maintainerQuoted 7 lines · Jeremy Fitzhardinge
Quoted 4 lines
Xen shouldn't have any users of this, since it's used for low-level operations like SMP bootstrap, suspend to RAM, reboot and low-level BIOS functionality.
Right, but it is being called smack in the middle of
setup_arch(). It looks like they could be hidden away in native_pagetable_setup_start/done though.
I think I can put the second sync-back clone_pgd_range in native_pagetable_setup_done but the first one needs to take place right at the beginning of setup_arch() because a lot of code in-between relies on swapper_pg_dir containing proper entries.
Just to make sure I understand you correctly: best it would be for xen to not have the copy_pgd_range() calls in setup_arch, correct?
Signature · 2 lines
Regards/Gruss, Boris.
Quoted 5 lines · Borislav Petkov
Quoted 4 lines · Jeremy Fitzhardinge
Quoted 4 lines
Xen shouldn't have any users of this, since it's used for low-level operations like SMP bootstrap, suspend to RAM, reboot and low-level BIOS functionality.
Quoted 7 lines
Quoted 3 lines
Right, but it is being called smack in the middle of
setup_arch(). It looks like they could be hidden away in native_pagetable_setup_start/done though.I think I can put the second sync-back
clone_pgd_rangeinnative_pagetable_setup_donebut the first one needs to take place right at the beginning ofsetup_arch()because a lot of code in-between relies onswapper_pg_dircontaining proper entries.
OK.
Quoted 2 lines
Just to make sure I understand you correctly: best it would be for xen to not have the
copy_pgd_range()calls insetup_arch, correct?
Right. Could you put the first copy into swapper_pg_dir earlier, before setup_arch() somewhere that's specific to booting via head_32.S?
J
Quoted 9 lines · Borislav Petkov
Quoted 7 lines · Jeremy Fitzhardinge
Quoted 4 lines
Xen shouldn't have any users of this, since it's used for low-level operations like SMP bootstrap, suspend to RAM, reboot and low-level BIOS functionality.
Right, but it is being called smack in the middle of
setup_arch(). It looks like they could be hidden away in native_pagetable_setup_start/done though.
Quoted 7 lines
I think I can put the second sync-back
clone_pgd_rangeinnative_pagetable_setup_donebut the first one needs to take place right at the beginning ofsetup_arch()because a lot of code in-between relies onswapper_pg_dircontaining proper entries.Just to make sure I understand you correctly: best it would be for xen to not have the
copy_pgd_range()calls insetup_arch, correct?
Yes, or to ensure that swapper_pg_dir has not yet been marked as a pagetable at this point. Under Xen we are running on swapper_pg_dir when setup_arch is called.
I think we could achieve this within the Xen pvops backend but e.g. the following would likely work also.
(Note, untested. I also omitted the reindent for clarity at this point)
arch/x86/kernel/setup.c +2 -0
@@ -705,12 +705,14 @@ void __init setup_arch(char **cmdline_p)* copy kernel address range established so far and switch * to the proper swapper page table */ +if (read_cr3 () !=__pa (swapper_pg_dir)) {clone_pgd_range (swapper_pg_dir +KERNEL_PGD_BOUNDARY , initial_page_table +KERNEL_PGD_BOUNDARY ,KERNEL_PGD_PTRS );load_cr3 (swapper_pg_dir);__flush_tlb_all (); + }#else printk (KERN_INFO "Command line: %s\n" , boot_command_line);#endif
Quoted 5 lines · Ian Campbell
I think we could achieve this within the Xen pvops backend but e.g. the following would likely work also.
(Note, untested. I also omitted the reindent for clarity at this point)
Now tested and it works. Patch below.
I'm also going to look into switching Xen to startup on initial_page_table, since I think the consistency with native would be useful from a principle of least surprise PoV. However the following is a useful stopgap if nothing else.
BTW, are there plans to unify 32 and 64 bit WRT the use of swapper_pg_dir vs initial_page_table?
Ian.
8<-------------------------
Quoted 1 line
From
9bbce2e6b198cc7efeeebb87131e5b4e9ac923bdMon Sep 17 00:00:00 2001
From: Ian Campbell <[email protected]>
Date: Thu, 28 Oct 2010 10:16:52 +0100
Subject: [PATCH] x86/32: skip early initialisation of swapper_pg_dir if it is already current
In particular in the Xen PV case the Xen early startup code has already initialised swapper_pg_dir and switched to it. In this case initial_page_table is uninitialised since Xen has no use for it so copying it over swapper_pg_dir is not correct.
--- arch/x86/kernel/setup.c | 12 +++++++----- 1 files changed, 7 insertions(+), 5 deletions(-)
arch/x86/kernel/setup.c +7 -5
@@ -705,12 +705,14 @@ void __init setup_arch(char **cmdline_p)* copy kernel address range established so far and switch * to the proper swapper page table */ -clone_pgd_range (swapper_pg_dir +KERNEL_PGD_BOUNDARY , - initial_page_table +KERNEL_PGD_BOUNDARY , -KERNEL_PGD_PTRS ); +if (read_cr3 () !=__pa (swapper_pg_dir)) { +clone_pgd_range (swapper_pg_dir +KERNEL_PGD_BOUNDARY , + initial_page_table +KERNEL_PGD_BOUNDARY , +KERNEL_PGD_PTRS ); -load_cr3 (swapper_pg_dir); -__flush_tlb_all (); +load_cr3 (swapper_pg_dir); +__flush_tlb_all (); + }#else printk (KERN_INFO "Command line: %s\n" , boot_command_line);#endif
Signature · 1 line
1.5.6.5
Quoted 1 line · Ian Campbell
Now tested and it works. Patch below.
I'm assuming you tested bare metal too?
Quoted 4 lines
I'm also going to look into switching Xen to startup on
initial_page_table, since I think the consistency with native would be useful from a principle of least surprise PoV. However the following is a useful stopgap if nothing else.
Sounds good. Then we can drop this temporary workaround.
Quoted 2 lines
BTW, are there plans to unify 32 and 64 bit WRT the use of
swapper_pg_dirvsinitial_page_table?
To be honest, I thought about it but 64bit does the bootstrapping differently. I'll look into it one fine day when there's time. (like there ever is :))
Quoted 9 lines
From: Ian Campbell <[email protected]>
Date: Thu, 28 Oct 2010 10:16:52 +0100
Subject: [PATCH] x86/32: skip early initialisation ofswapper_pg_dirif it is already currentIn particular in the Xen PV case the Xen early startup code has already initialised
swapper_pg_dirand switched to it. In this caseinitial_page_tableis uninitialised since Xen has no use for it so copying it overswapper_pg_diris not correct.
Quoted 4 lines
Signed-off-by Ian Campbell <[email protected]>Cc Borislav Petkov <[email protected]>Cc H. Peter Anvin <[email protected]>Cc Jeremy Fitzhardinge <[email protected]>
Signature · 2 lines
Regards/Gruss, Boris.
Quoted 4 lines · Borislav Petkov
Quoted 1 line · Ian Campbell
Now tested and it works. Patch below.
I'm assuming you tested bare metal too?
Yes, I tried PAE with and without CONFIG_PARAVIRT as well as non-PAE without CONFIG_PARAVIRT.
Ian.
Quoted 8 lines · Borislav Petkov
Quoted 3 lines
BTW, are there plans to unify 32 and 64 bit WRT the use of
swapper_pg_dirvsinitial_page_table?To be honest, I thought about it but 64bit does the bootstrapping differently. I'll look into it one fine day when there's time. (like there ever is :))
The delta between the early 32- and 64-bit code is one of our big problems at the moment.
-hpa
Quoted 4 lines · Ian Campbell
BTW, are there plans to unify 32 and 64 bit WRT the use of
swapper_pg_dirvsinitial_page_table?
Yes, we're not there yet, though.
-hpa
Quoted 3 lines · Ian Campbell
I'm also going to look into switching Xen to startup on
initial_page_table, since I think the consistency with native would be useful from a principle of least surprise PoV.
Here it is.
8<---------------
Quoted 1 line
From
1aa3d8dc160bcee9bd92940853fad509df38d1a2Mon Sep 17 00:00:00 2001
From: Ian Campbell <[email protected]>
Date: Wed, 3 Nov 2010 15:32:21 +0000
Subject: [PATCH] xen: x86/32: perform initial startup on initial_page_table
Only make swapper_pg_dir readonly and pinned when generic x86 architecture code (which also starts on initial_page_table) switches to it. This helps ensure that the generic setup paths work on Xen unmodified. In particular clone_pgd_range writes directly to the destination pgd entries and is used to initialise swapper_pg_dir so we need to ensure that it remains writeable until the last possible moment during bring up.
This is complicated slightly by the need to avoid sharing kernel PMD entries when running under Xen, therefore the Xen implementation must make a copy of the kernel PMD (which is otherwise referred to by both intial_page_table and swapper_pg_dir) before switching to swapper_pg_dir.
--- arch/x86/xen/enlighten.c | 2 - arch/x86/xen/mmu.c | 69 +++++++++++++++++++++++++++++++++++++-------- 2 files changed, 56 insertions(+), 15 deletions(-)
arch/x86/xen/enlighten.c +0 -2
@@ -1198,8 +1198,6 @@ asmlinkage void __init xen_start_kernel(void)/* Allocate and initialize top and mid mfn levels for p2m structure */ xen_build_mfn_list_list (); - init_mm.pgd = pgd; -/* keep using Xen gdt for now; no urgent need to change it */ #ifdef CONFIG_X86_32
arch/x86/xen/mmu.c +56 -13
107 lines not on this page · raw message
Signature · 9 lines
1.5.6.5 -- Ian Campbell Booze is the answer. I don't remember the question.