Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932105AbbFLIRs (ORCPT ); Fri, 12 Jun 2015 04:17:48 -0400 Received: from terminus.zytor.com ([198.137.202.10]:33706 "EHLO mail.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753200AbbFLIRc (ORCPT ); Fri, 12 Jun 2015 04:17:32 -0400 User-Agent: K-9 Mail for Android In-Reply-To: <20150612075013.GA8759@gmail.com> References: <1434066338-6619-1-git-send-email-srinivas.pandruvada@linux.intel.com> <20150612060747.GA25024@gmail.com> <20150612075013.GA8759@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Subject: Re: [PATCH] x86: General protection fault after STR (32 bit systems only) From: "H. Peter Anvin" Date: Fri, 12 Jun 2015 01:15:58 -0700 To: Ingo Molnar , Andy Lutomirski CC: Srinivas Pandruvada , Ingo Molnar , Thomas Gleixner , Pavel Machek , "Rafael J. Wysocki" , X86 ML , "linux-pm@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Denys Vlasenko , Borislav Petkov , Brian Gerst , Linus Torvalds Message-ID: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2201 Lines: 72 %es is used implicitly by string instructions. On June 12, 2015 12:50:13 AM PDT, Ingo Molnar wrote: > >* Andy Lutomirski wrote: > >> > --- a/arch/x86/kernel/acpi/wakeup_32.S >> > +++ b/arch/x86/kernel/acpi/wakeup_32.S >> > @@ -81,6 +81,10 @@ ENTRY(do_suspend_lowlevel) >> > jmp ret_point >> > .p2align 4,,7 >> > ret_point: >> > + /* In case the BIOS corrupted DS, make the kernel context >minimally functional: */ >> > + movl $__KERNEL_DS, %eax >> > + movl %eax, %ds >> > + >> >> On further thought, I think you want movl $__USER_DS, %eax. The >> 32-bit kernel is a strange beast. Also, you should probably fix up >> %es as well. > >So restore_processor_state() already restores ES. The idea here was to >reload DS >early on, because the kernel implicitly uses it for data access so we >need it to >be good to be able to continue executing any generic kernel code. > >We don't use %es: prefixed assembly AFAICS, what are the implicit users >of ES? > >Also, to further confuse things, we also have: > >ENTRY(wakeup_pmode_return) >wakeup_pmode_return: > movw $__KERNEL_DS, %ax > movw %ax, %ss > movw %ax, %ds > movw %ax, %es > movw %ax, %fs > movw %ax, %gs > > # reload the gdt, as we need the full 32 bit address > lidt saved_idt > lldt saved_ldt > ljmp $(__KERNEL_CS), $1f >1: > movl %cr3, %eax > movl %eax, %cr3 > wbinvd > >which seems to be another layer of restoration - but it possibly does >not trigger >in the S2RAM case here. > >Oh, funny the 'reload the gdt' comment: do you see an LGDT there? It >reloads all >segment selectors, the IDT, LDT and CR3, but does not seem to reload >the GDT - the >only thing the comment describes. > >Thanks, > > Ingo -- Sent from my mobile phone. Please pardon brevity and lack of formatting. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/