Skip to contentSkip to conversation

x86 updates

GIT PULL Ingo Molnar 4 participants 9 messages Feb 13, 2008 – Feb 15, 2008

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

Linus, please pull the latest x86 git tree from:

git://git.kernel.org/pub/scm/linux/kernel/git/x86/linux-2.6-x86.git

Shortlog and diffstat attached below.

low-key fixes and updates. 2.6.25-rc1 looks pretty solid so far in terms of arch/x86 with no major regression reported against the 1000+ x86.git commits. (no native kernel boot problem or runtime failure/crash - there was one paravirt boot crash report)

The gcc sigcontext.h header fixes, the Xen-guest boot fixes and the EFI fixes stand out. [there are more CPA cleanups still brewing but none of that is urgent.]

Ingo

------------------>
Andi Kleen (1):
x86: CPA: fix gbpages support in try_preserve_large_page

Harvey Harrison (1):
x86: pit_clockevent can be static

Huang, Ying (1):
x86: EFI runtime code mapping enhancement

Ingo Molnar (1):
x86: fix sigcontext.h user export

Jeremy Fitzhardinge (2):
x86/early_ioremap: don't assume we're using swapper_pg_dir
xen: unpin initial Xen pagetable once we're finished with it

Jody Belka (1):
x86: fixup machine_ops reboot_{32|64}.c unification fallout

Thomas Gleixner (1):
x86: EFI: fix use of unitialized variable and the cache logic

 arch/x86/kernel/efi.c        |   12 +++----
 arch/x86/kernel/efi_64.c     |   32 ++++++++------------
 arch/x86/kernel/i8253.c      |    2 +-
 arch/x86/kernel/reboot.c     |   46 +++++++++++++++++++++++------
 arch/x86/mm/ioremap.c        |    4 ++-
 arch/x86/mm/pageattr.c       |    4 +-
 arch/x86/xen/enlighten.c     |    4 ++
 include/asm-x86/sigcontext.h |   66 ++++++++++++++++++++++++++++++++++++++++++
 8 files changed, 130 insertions(+), 40 deletions(-)
arch/x86/kernel/efi.c +5 -7
index 32dd62b..cbdf9ba 100644
@@ -384,9 +384,6 @@ static void __init runtime_code_page_mkexec(void)
 	efi_memory_desc_t *md;
 	void *p;
 
-	if (!(__supported_pte_mask & _PAGE_NX))
-		return;
-
 	/* Make EFI runtime service code area executable */
 	for (p = memmap.map; p < memmap.map_end; p += memmap.desc_size) {
 		md = p;
@@ -428,9 +425,6 @@ void __init efi_enter_virtual_mode(void)
 		else
 			va = efi_ioremap(md->phys_addr, size);
 
-		if (md->attribute & EFI_MEMORY_WB)
-			set_memory_uc(md->virt_addr, size);
-
 		md->virt_addr = (u64) (unsigned long) va;
 
 		if (!va) {
@@ -439,6 +433,9 @@ void __init efi_enter_virtual_mode(void)
 			continue;
 		}
 
+		if (!(md->attribute & EFI_MEMORY_WB))
+			set_memory_uc(md->virt_addr, size);
+
 		systab = (u64) (unsigned long) efi_phys.systab;
 		if (md->phys_addr <= systab && systab < end) {
 			systab += md->virt_addr - md->phys_addr;
@@ -476,7 +473,8 @@ void __init efi_enter_virtual_mode(void)
 	efi.get_next_high_mono_count = virt_efi_get_next_high_mono_count;
 	efi.reset_system = virt_efi_reset_system;
 	efi.set_virtual_address_map = virt_efi_set_virtual_address_map;
-	runtime_code_page_mkexec();
+	if (__supported_pte_mask & _PAGE_NX)
+		runtime_code_page_mkexec();
 	early_iounmap(memmap.map, memmap.nr_map * memmap.desc_size);
 	memmap.map = NULL;
 }
arch/x86/kernel/efi_64.c +13 -19
index 09d5c23..d143a1e 100644
@@ -35,6 +35,7 @@
 #include <asm/tlbflush.h>
 #include <asm/proto.h>
 #include <asm/efi.h>
+#include <asm/cacheflush.h>
 
 static pgd_t save_pgd __initdata;
 static unsigned long efi_flags __initdata;
@@ -43,22 +44,15 @@ static void __init early_mapping_set_exec(unsigned long start,
 					  unsigned long end,
 					  int executable)
 {
-	pte_t *kpte;
-	unsigned int level;
-
-	while (start < end) {
-		kpte = lookup_address((unsigned long)__va(start), &level);
-		BUG_ON(!kpte);
-		if (executable)
-			set_pte(kpte, pte_mkexec(*kpte));
-		else
-			set_pte(kpte, __pte((pte_val(*kpte) | _PAGE_NX) & \
-					    __supported_pte_mask));
-		if (level == PG_LEVEL_4K)
-			start = (start + PAGE_SIZE) & PAGE_MASK;
-		else
-			start = (start + PMD_SIZE) & PMD_MASK;
-	}
+	unsigned long num_pages;
+
+	start &= PMD_MASK;
+	end = (end + PMD_SIZE - 1) & PMD_MASK;
+	num_pages = (end - start) >> PAGE_SHIFT;
+	if (executable)
+		set_memory_x((unsigned long)__va(start), num_pages);
+	else
+		set_memory_nx((unsigned long)__va(start), num_pages);
 }
 
 static void __init early_runtime_code_mapping_set_exec(int executable)
@@ -74,7 +68,7 @@ static void __init early_runtime_code_mapping_set_exec(int executable)
 		md = p;
 		if (md->type == EFI_RUNTIME_SERVICES_CODE) {
 			unsigned long end;
-			end = md->phys_addr + (md->num_pages << PAGE_SHIFT);
+			end = md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT);
 			early_mapping_set_exec(md->phys_addr, end, executable);
 		}
 	}
@@ -84,8 +78,8 @@ void __init efi_call_phys_prelog(void)
 {
 	unsigned long vaddress;
 
-	local_irq_save(efi_flags);
 	early_runtime_code_mapping_set_exec(1);
+	local_irq_save(efi_flags);
 	vaddress = (unsigned long)__va(0x0UL);
 	save_pgd = *pgd_offset_k(0x0UL);
 	set_pgd(pgd_offset_k(0x0UL), *pgd_offset_k(vaddress));
@@ -98,9 +92,9 @@ void __init efi_call_phys_epilog(void)
 	 * After the lock is released, the original page table is restored.
 	 */
 	set_pgd(pgd_offset_k(0x0UL), save_pgd);
-	early_runtime_code_mapping_set_exec(0);
 	__flush_tlb_all();
 	local_irq_restore(efi_flags);
+	early_runtime_code_mapping_set_exec(0);
 }
 
 void __init efi_reserve_bootmem(void)
arch/x86/kernel/i8253.c +1 -1
index ef62b07..8540abe 100644
@@ -95,7 +95,7 @@ static int pit_next_event(unsigned long delta, struct clock_event_device *evt)
  * registered. This mechanism replaces the previous #ifdef LOCAL_APIC -
  * !using_apic_timer decisions in do_timer_interrupt_hook()
  */
-struct clock_event_device pit_clockevent = {
+static struct clock_event_device pit_clockevent = {
 	.name		= "pit",
 	.features	= CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT,
 	.set_mode	= init_pit_timer,
arch/x86/kernel/reboot.c +36 -10

77 lines not on this page · raw message

arch/x86/mm/ioremap.c +3 -1
index a4897a8..9f42d7e 100644
@@ -265,7 +265,9 @@ static __initdata pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)]
 
 static inline pmd_t * __init early_ioremap_pmd(unsigned long addr)
 {
-	pgd_t *pgd = &swapper_pg_dir[pgd_index(addr)];
+	/* Don't assume we're using swapper_pg_dir at this point */
+	pgd_t *base = __va(read_cr3());
+	pgd_t *pgd = &base[pgd_index(addr)];
 	pud_t *pud = pud_offset(pgd, addr);
 	pmd_t *pmd = pmd_offset(pud, addr);
 
arch/x86/mm/pageattr.c +2 -2
index 440210a..bd61ed1 100644
@@ -275,8 +275,8 @@ try_preserve_large_page(pte_t *kpte, unsigned long address,
 		break;
 #ifdef CONFIG_X86_64
 	case PG_LEVEL_1G:
-		psize = PMD_PAGE_SIZE;
-		pmask = PMD_PAGE_MASK;
+		psize = PUD_PAGE_SIZE;
+		pmask = PUD_PAGE_MASK;
 		break;
 #endif
 	default:
arch/x86/xen/enlighten.c +4 -0
index de647bc..49e5358 100644
@@ -798,6 +798,10 @@ static __init void xen_pagetable_setup_start(pgd_t *base)
 	 * added to the table can be prepared properly for Xen.
 	 */
 	xen_write_cr3(__pa(base));
+
+	/* Unpin initial Xen pagetable */
+	pin_pagetable_pfn(MMUEXT_UNPIN_TABLE,
+			  PFN_DOWN(__pa(xen_start_info->pt_base)));
 }
 
 static __init void xen_pagetable_setup_done(pgd_t *base)
include/asm-x86/sigcontext.h +66 -0

90 lines not on this page · raw message

author Applied
#2 lore raw
Quoted 4 lines · Balbir Singh

Ingo, could you also please consider the KVM build fix at
http://marc.info/?l=linux-kernel&m=120262794315024&w=2 which has been acked by Avi. I suspect this patch should be route through git-x86 since it affects arch/x86/Kconfig.

thanks, applied - this first looked like a KVM item, that's why i havent added it. [Btw., feel free to push it via kvm.git as well - as long as you are sure it does not break the build ;-) ]

Ingo

#3 lore raw
Quoted 7 lines · Ingo Molnar
Quoted 2 lines · Balbir Singh

Ingo, could you also please consider the KVM build fix at http://marc.info/?l=linux-kernel&m=120262794315024&w=2 which has been acked by Avi. I suspect this patch should be route through git-x86 since it affects arch/x86/Kconfig.

thanks, applied - this first looked like a KVM item, that's why i havent added it. [Btw., feel free to push it via kvm.git as well - as long as you are sure it does not break the build ;-) ]

Yeah, I'm queuing it as well, it will get there one way or the other.

Signature · 1 line
error compiling committee.c: too many arguments to function
#4 lore raw
Quoted 10 lines · Avi Kivity
Quoted 9 lines · Ingo Molnar
Quoted 5 lines · Balbir Singh

Ingo, could you also please consider the KVM build fix at
http://marc.info/?l=linux-kernel&m=120262794315024&w=2 which has been acked by Avi. I suspect this patch should be route through git-x86 since it affects arch/x86/Kconfig.

Quoted 6 lines
Quoted 3 lines

thanks, applied - this first looked like a KVM item, that's why i havent added it. [Btw., feel free to push it via kvm.git as well - as long as you are sure it does not break the build ;-) ]

Yeah, I'm queuing it as well, it will get there one way or the other.

Excellent! :)

Signature · 4 lines
	Warm Regards,
	Balbir Singh
	Linux Technology Center
	IBM, ISTL
#5 lore raw
In reply to Avi Kivity
Quoted 5 lines · Avi Kivity
Quoted 3 lines

thanks, applied - this first looked like a KVM item, that's why i havent added it. [Btw., feel free to push it via kvm.git as well - as long as you are sure it does not break the build ;-) ]

Yeah, I'm queuing it as well, it will get there one way or the other.

x86.git won that race ;-)

i've had a good deal of build testing done with that patch and there's no [bzImage-level] build breakage that i can report. Which is not a surprise, the quality of arch/x86/kvm/ is outstandingly high:

  $ code-quality arch/x86/kvm/

errors lines of code errors/KLOC
arch/x86/kvm/ 29 14566 1.9

as a comparison:

errors lines of code errors/KLOC
kernel/ 729 92796 7.8

see: http://redhat.com/~mingo/x86.git/code-quality . It's as arbitrary of a metric as all static code metrics, but the numbers it emits are surprisingly close to my personal estimation of the cleanliness of some in-kernel codebases i ran it again.

[ hint, try "code-quality kernel/sched.c" too ;-) ]

Ingo

#6 lore raw
In reply to Ingo Molnar
Quoted 3 lines · Ingo Molnar

Thomas Gleixner (1):
x86: EFI: fix use of unitialized variable and the cache logic

Your honor, I would like to register a differing opinion...

I submitted that fix originally in a different form, but it got finally stripped down to this. However in my opinion the full version of the patch is still needed, otherwise EFI still does the mapping wrong.

Even with this patch EFI still passes in ioremap (on 32bit) and fixmap (on 64bit) addresses to cpa which it will mishandle.

On 64bit cpa will still change cache attributes on random low pages and cause illegal caching attribute aliases on both 32bit and 64bit.

See http://marc.info/?l=linux-kernel&m=120290071713708&w=2 for details.

git-x86#mm made some attempts to also fix this in pageattr.c which fixed some parts of the problem on 64bit (static_protections should be ok now), but not all (alias handling still not good)

See http://marc.info/?l=linux-kernel&m=120290203315953&w=2
for details

In particular the direct mapping cache alias handling for ioremap/fixmap (and EFI uses that) is not correct on both 32bit and 64bit.

Also all ioremaps have this same problem so all uncached mappings are broken when the direct mapping happens to overlap them (common on 64bit with enough RAM). Right now when you do a uncached ioremap the direct mapping will not be changed, which causes illegal conflicting caching aliasing.

My original patch above avoided that by not calling set_memory_uc() for the EFI case, but I did not fix the general ioremap case for other users yet (will send a patch later for this unless someone beats me to it)

Note even with ioremap generally fixed the original patch
http://marc.info/?l=linux-kernel&m=120284838904660&w=2
in its full form will be still needed to pass in the correct attribute to ioremap in the first place.

I would recommend to either mark EFI CONFIG_BROKEN for now or apply the complete patch I posted earlier
http://marc.info/?l=linux-kernel&m=120284838904660&w=2
or fix it in some other way in pageattr.c as described in
http://marc.info/?l=linux-kernel&m=120290203315953&w=2
(although that might be intrusive and I don't think such a change would be a good idea at this stage of the release)

And a separate patch fixing ioremap_nocache() will be needed too.

-Andi

#7 lore raw
Quoted 6 lines · Andi Kleen
Quoted 3 lines · Ingo Molnar

Thomas Gleixner (1):
x86: EFI: fix use of unitialized variable and the cache logic

Your honor, I would like to register a differing opinion...

As i mentioned it (in the portion of my email that you clipped), there are other pending CPA patches in x86.git:

Quoted 2 lines
Quoted 2 lines

[there are more CPA cleanups still brewing but none of that is urgent.]

We didnt plan to push these secondary alias fixes out yet with yesterday's push, and i disagree with you about their urgency.

Quoted 4 lines

I submitted that fix originally in a different form, but it got finally stripped down to this. However in my opinion the full version of the patch is still needed, otherwise EFI still does the mapping wrong.

well, not really. Firtly, and most importantly, can you see any failures on any real boxes?

I'd be surprised if you could see any failures, because secondary aliases have little practical relevance today. Getting the _primary_ alias right is the most important task of CPA and -git does that all correctly. (we'd be seeing crashes left and right in -rc1 if it didnt)

Secondary virtual alias discovery indeed has an ugly-looking but fortunately harmless bug in -git (fixed in x86.git#mm).

The fix is rather straightforward, but we want to test it some more. We'll push the fix probably before -rc2 though, in the next few days.

Quoted 2 lines

On 64bit cpa will still change cache attributes on random low pages and cause illegal caching attribute aliases on both 32bit and 64bit.

Well, this is moot with latest x86.git, but you are still wrong.

Firstly, what we do currently incorrectly (and which is fixed in x86.git) is that we do a __pa() on a vmalloc/ioremap-range address on 64-bit in secondary alias discovery. But as i showed it to you days ago in my reply, while it will yield a "random" looking address, but that address is a guaranteed-high physical address in the higher than 0x410000000000 (i.e. 65TB+) physical range, so we'll just return harmlessly from the filter function. So yes, it's very much ugly and unintended and we've been working on fixing it (and have fixed it).

Secondly, your suggestion that inconsistent caching attribute aliases are not permitted is incorrect. They are very much not allowed under PAT, and they are "nice to avoid" even on non-PAT (early CPU iterations sometimes have erratas in this area), but we always had them in one way or another - permanently and temporarily as well. What Linux still relies on fundamentally for cache attributes are the MTRR attributes.

Anyway, please take a look at today's x86.git#mm:

git://git.kernel.org/pub/scm/linux/kernel/git/x86/linux-2.6-x86.git mm

it should handle secondary aliases correctly - but we are still working on some other cleanups to make it complete.

If anyone proves us wrong (with a specific example - what is mapped where, and what bad effect does it have, or if it's available a crashlog, etc.) we'll certainly reconsider.

Ingo

#8 lore raw
Quoted 19 lines · Ingo Molnar
Quoted 6 lines · Andi Kleen
Quoted 3 lines · Ingo Molnar

Thomas Gleixner (1):
x86: EFI: fix use of unitialized variable and the cache logic

Your honor, I would like to register a differing opinion...

As i mentioned it (in the portion of my email that you clipped), there are other pending CPA patches in x86.git:

Quoted 2 lines
Quoted 2 lines

[there are more CPA cleanups still brewing but none of that is urgent.]

We didnt plan to push these secondary alias fixes out yet with yesterday's push, and i disagree with you about their urgency.

Quoted 7 lines
Quoted 4 lines

I submitted that fix originally in a different form, but it got finally stripped down to this. However in my opinion the full version of the patch is still needed, otherwise EFI still does the mapping wrong.

well, not really. Firtly, and most importantly, can you see any failures on any real boxes?

I don't have any EFI boxes.

However with the one bug I found recently (set_memory_uc passed in bytes for numpages) I doubt it was ever tested in the current form in tree (perhaps it came from some merge mistake?)

Quoted 1 line

have little practical relevance today. Getting the _primary_

The original motivation for pageattr.c back in 2002 was a very real problem with AGP cache corruption coming from the direct mapping aliases.

Also while I was still maintaining that code and occasionally broke it :-] I usually got reports after 1-2 releases from people who were hitting real failures from the breakage (given a lot of that was the proprietary Nvidia driver, but I see no reason it won't hit on completely free software too)

So from practical experience I beg to disagree.

Quoted 2 lines

alias right is the most important task of CPA and -git does that all correctly. (we'd be seeing crashes left and right in -rc1 if it didnt)

No you don't see quick crashes left and right from alias attributes, but subtle cache corruptions after a long time. That is because it only causes problems when the CPU does some prefetching on the wrong address and that typically takes some time to happen.

The typical symptom is that at some point (after many hours) someone's 3d driver errors out with some internal inconsistency when the 3d card happened to be feed a corrupted cache line.

But I have no doubts that non 3d workloads will hit it eventually too (just takes longer because they tend to move much less data)

Quoted 3 lines

Firstly, what we do currently incorrectly (and which is fixed in x86.git) is that we do a __pa() on a vmalloc/ioremap-range address on 64-bit in secondary alias discovery. But as i showed it to you days ago

First before you started rewriting ioremap that all worked correctly[1] since quite some releases. I fixed this originally long ago (it was already in 2.6.12; I'm too lazy to search back further)

So 2.6.25 would be the first kernel since at least 2.6.12 that would not do this correctly.

I polititely request that you do something about this regression for .25. Either apply my patches or fix it yourself in whatever way you want. Just fix it.

[1] modulo the relatively minor problem of end_pfn_map sometimes being a few pages off I recently sent a patch for.

Quoted 3 lines

in my reply, while it will yield a "random" looking address, but that address is a guaranteed-high physical address in the higher than 0x410000000000 (i.e. 65TB+) physical range, so we'll just return

Again 64bit efi_ioremap passes in a fixmap address. And fixmap is >= the kernel mapping so __pa() will resolve it to a physical address <= 2GB.

Your 65TB analysis assumed it passed in the vmalloc/ioremap range. The analysis would be fine for that (although still dubious code). Unfortunately it had a faulty starting point.

For 32bit it also was wrong I think for the more obscure __PAGE_OFFSET splits. This is it likely was ok[1] for the default 3:1 but not e.g. for 1:3.

[1] ok as in not clearly broken; not clean code.

Quoted 3 lines

Secondly, your suggestion that inconsistent caching attribute aliases are not permitted is incorrect. They are very much not allowed under PAT,

_PCD is PAT!!!! Even if you don't change the PAT MSRs ever setting _PCD anywhere makes you a PAT user. And ioremap definitely sets _PCD.

Quoted 1 line

and they are "nice to avoid" even on non-PAT (early CPU iterations

It's not "nice to avoid". It's "if you don't avoid it your cache will be eventually corrupted". And yes we've had this case in the past where it broke real setups.

Quoted 6 lines

Anyway, please take a look at today's x86.git#mm:

git://git.kernel.org/pub/scm/linux/kernel/git/x86/linux-2.6-x86.git mm

it should handle secondary aliases correctly - but we are still working on some other cleanups to make it complete.

Ok cpa_check_alias seems to be gone again. That's at least some progress. And all the __pas are gone too. That's good.

I see you started to follow
http://marc.info/?l=linux-kernel&m=120290203315953&w=2
too which is also good although I haven't checked if it's ok for all cases.

Doing it this way is probably fine for .26 but you still need a quicker regression fix for .25.

Also it would be nice if someone would apply the remaining CPA patches I posted earlier this week. Some of them went uncommented so far and should be not controversal.

Quoted 3 lines

If anyone proves us wrong (with a specific example - what is mapped where, and what bad effect does it have, or if it's available a crashlog, etc.) we'll certainly reconsider.

Right now first priority should be getting .25 right. This means you should fix at least EFI (see my earlier patch today) and fix the (imho serious) ioremap() alias regression (see other patch) EFI is a regression too for 32bit BTW.

Still putting the end_pfn_map fixes into .25 would be nice too, although they're at least not regression fixes.

The ioremap patch would be obsolete with the #mm pageattr.c (assuming you got the alias cases right this time), from the EFI patch at least the numpages<->size fix is still needed even for #mm

-Andi