From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753097AbdKTWBZ (ORCPT ); Mon, 20 Nov 2017 17:01:25 -0500 Received: from Galois.linutronix.de ([146.0.238.70]:60587 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752935AbdKTWBX (ORCPT ); Mon, 20 Nov 2017 17:01:23 -0500 Date: Mon, 20 Nov 2017 23:01:19 +0100 (CET) From: Thomas Gleixner To: Andy Lutomirski cc: X86 ML , Borislav Petkov , "linux-kernel@vger.kernel.org" , Brian Gerst , Dave Hansen , Linus Torvalds , Josh Poimboeuf Subject: Re: [PATCH 04/16] x86/fixmap: Generalize the GDT fixmap mechanism In-Reply-To: <81302a25ec65f28660cba8d1d9d75b42c4c58939.1511195781.git.luto@kernel.org> Message-ID: References: <81302a25ec65f28660cba8d1d9d75b42c4c58939.1511195781.git.luto@kernel.org> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 20 Nov 2017, Andy Lutomirski wrote: Just a few nits. > /* Provide the fixmap address of the remapped GDT */ > static inline struct desc_struct *get_cpu_gdt_ro(int cpu) > { > - unsigned int idx = get_cpu_gdt_ro_index(cpu); > - return (struct desc_struct *)__fix_to_virt(idx); > + return (struct desc_struct *)&get_cpu_entry_area(cpu)->gdt; > } > > /* Provide the current read-only GDT */ > diff --git a/arch/x86/include/asm/fixmap.h b/arch/x86/include/asm/fixmap.h > index b0c505fe9a95..5ff8e251772a 100644 > --- a/arch/x86/include/asm/fixmap.h > +++ b/arch/x86/include/asm/fixmap.h > @@ -44,6 +44,17 @@ extern unsigned long __FIXADDR_TOP; > PAGE_SIZE) > #endif > > +/* > + * cpu_entry_area is a percpu region in the fixmap that contains things > + * need by the CPU and early entry/exit code. Real types aren't used here s/need/needed/ > + * to avoid circular header dependencies. :( > + */ > +struct cpu_entry_area > +{ > + char gdt[PAGE_SIZE]; > +}; > + > +#define CPU_ENTRY_AREA_PAGES (sizeof(struct cpu_entry_area) / PAGE_SIZE) > +static inline unsigned int __get_cpu_entry_area_page_index(int cpu, int page) > +{ > + BUILD_BUG_ON(sizeof(struct cpu_entry_area) % PAGE_SIZE != 0); > + > + return FIX_CPU_ENTRY_AREA_BOTTOM - cpu*CPU_ENTRY_AREA_PAGES - page; > +} > + > +#define __get_cpu_entry_area_offset_index(cpu, offset) ({ \ > + BUILD_BUG_ON(offset % PAGE_SIZE != 0); \ > + __get_cpu_entry_area_page_index(cpu, offset / PAGE_SIZE); \ > + }) > + > +#define get_cpu_entry_area_index(cpu, field) \ > + __get_cpu_entry_area_offset_index((cpu), offsetof(struct cpu_entry_area, field)) Any reason why those need to be macros? > +static inline struct cpu_entry_area *get_cpu_entry_area(int cpu) > +{ > + return (struct cpu_entry_area *) > + __fix_to_virt(__get_cpu_entry_area_page_index(cpu, 0)); > +} > + Thanks, tglx