Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752721AbbGWQHE (ORCPT ); Thu, 23 Jul 2015 12:07:04 -0400 Received: from smtprelay0011.hostedemail.com ([216.40.44.11]:37966 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752902AbbGWQGy (ORCPT ); Thu, 23 Jul 2015 12:06:54 -0400 X-Session-Marker: 726F737465647440676F6F646D69732E6F7267 X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,rostedt@goodmis.org,:::::::::::::::,RULES_HIT:41:355:379:541:599:800:960:968:973:988:989:1260:1277:1311:1313:1314:1345:1359:1437:1515:1516:1518:1534:1542:1593:1594:1711:1730:1747:1777:1792:2194:2199:2393:2553:2559:2562:2693:3138:3139:3140:3141:3142:3354:3622:3865:3867:3868:3870:3871:3872:4250:4321:5007:6117:6119:6261:7875:10004:10400:10848:10967:11026:11232:11473:11658:11914:12043:12438:12517:12519:12740:13138:13161:13229:13231:14096:14097:21080,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0 X-HE-Tag: cub75_59028081f645b X-Filterd-Recvd-Size: 3428 Date: Thu, 23 Jul 2015 12:06:50 -0400 From: Steven Rostedt To: Andy Lutomirski Cc: X86 ML , linux-kernel@vger.kernel.org, Willy Tarreau , Borislav Petkov , Thomas Gleixner , Peter Zijlstra , Linus Torvalds Subject: Re: [PATCH 3/5] x86/entry: Merge 32-bit and 64-bit sysenter setup code Message-ID: <20150723120650.2257cd8c@gandalf.local.home> In-Reply-To: <0ed9e2434ed6b0832b0f1b28407ad962f66893a7.1437665045.git.luto@kernel.org> References: <0ed9e2434ed6b0832b0f1b28407ad962f66893a7.1437665045.git.luto@kernel.org> X-Mailer: Claws Mail 3.11.1 (GTK+ 2.24.28; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2495 Lines: 70 On Thu, 23 Jul 2015 08:31:41 -0700 Andy Lutomirski wrote: > - if (!boot_cpu_has(X86_FEATURE_SEP)) > + /* > + * On 64-bit CPUs, enable SEP unconditionally. On Intel CPUs, > + * it works and we use it. On AMD CPUs, the MSRs exist but EIP > + * is truncated to 32 bits. This doesn't matter because AMD > + * CPUs disallow SYSENTER in long mode. If AMD ever decides to > + * support SYSENTER, then they'll have to fix the truncation > + * issue, and this code will work as-is. > + */ > + > + if (IS_ENABLED(CONFIG_X86_32) && !boot_cpu_has(X86_FEATURE_SEP)) > goto out; > > +#ifdef CONFIG_X86_32 > /* > * We cache MSR_IA32_SYSENTER_CS's value in the TSS's ss1 field -- > * see the big comment in struct x86_hw_tss's definition. > */ > tss->x86_tss.ss1 = __KERNEL_CS; > +#endif > > wrmsrl_safe(MSR_IA32_SYSENTER_CS, __KERNEL_CS); > wrmsrl_safe(MSR_IA32_SYSENTER_ESP, > (unsigned long)tss + > offsetofend(struct tss_struct, SYSENTER_stack)); > +#ifdef CONFIG_X86_32 > wrmsrl_safe(MSR_IA32_SYSENTER_EIP, (unsigned long)entry_SYSENTER_32); > +#else > + wrmsrl_safe(MSR_IA32_SYSENTER_EIP, (unsigned long)entry_SYSENTER_compat); > +#endif As an additional clean up, what impact would we have to just rename entry_SYSENTER_compat to entry_SYSENTER_32 on x86_64? It would remove the need for the above #ifdef logic. -- Steve > > out: > put_cpu(); > @@ -1187,17 +1201,7 @@ void syscall_init(void) > > #ifdef CONFIG_IA32_EMULATION > wrmsrl(MSR_CSTAR, entry_SYSCALL_compat); > - /* > - * This only works on Intel CPUs. > - * On AMD CPUs these MSRs are 32-bit, CPU truncates MSR_IA32_SYSENTER_EIP. > - * This does not cause SYSENTER to jump to the wrong location, because > - * AMD doesn't allow SYSENTER in long mode (either 32- or 64-bit). > - */ > - wrmsrl_safe(MSR_IA32_SYSENTER_CS, __KERNEL_CS); > - wrmsrl_safe(MSR_IA32_SYSENTER_ESP, > - (unsigned long)&per_cpu(cpu_tss, smp_processor_id()) + > - offsetofend(struct tss_struct, SYSENTER_stack)); > - wrmsrl_safe(MSR_IA32_SYSENTER_EIP, (unsigned long)entry_SYSENTER_compat); > + enable_sep_cpu(); > #else > wrmsrl(MSR_CSTAR, ignore_sysret); > wrmsrl_safe(MSR_IA32_SYSENTER_CS, (u64)GDT_ENTRY_INVALID_SEG); -- 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/