From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752354AbdLLSnu (ORCPT ); Tue, 12 Dec 2017 13:43:50 -0500 Received: from Galois.linutronix.de ([146.0.238.70]:34267 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751643AbdLLSnr (ORCPT ); Tue, 12 Dec 2017 13:43:47 -0500 Date: Tue, 12 Dec 2017 19:43:45 +0100 (CET) From: Thomas Gleixner To: Peter Zijlstra cc: Andy Lutomirski , LKML , X86 ML , Linus Torvalds , Dave Hansen , Borislav Petkov , Greg KH , Kees Cook , Hugh Dickins , Brian Gerst , Josh Poimboeuf , Denys Vlasenko , Boris Ostrovsky , Juergen Gross , David Laight , Eduardo Valentin , aliguori@amazon.com, Will Deacon , "linux-mm@kvack.org" Subject: Re: [patch 13/16] x86/ldt: Introduce LDT write fault handler In-Reply-To: <20171212181902.a3dj3haouw3corhq@hirez.programming.kicks-ass.net> Message-ID: References: <20171212173221.496222173@linutronix.de> <20171212173334.345422294@linutronix.de> <20171212181902.a3dj3haouw3corhq@hirez.programming.kicks-ass.net> 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 Tue, 12 Dec 2017, Peter Zijlstra wrote: > On Tue, Dec 12, 2017 at 09:58:58AM -0800, Andy Lutomirski wrote: > > On Tue, Dec 12, 2017 at 9:32 AM, Thomas Gleixner wrote: > > > > +bool __ldt_write_fault(unsigned long address) > > > +{ > > > + struct ldt_struct *ldt = current->mm->context.ldt; > > > + unsigned long start, end, entry; > > > + struct desc_struct *desc; > > > + > > > + start = (unsigned long) ldt->entries; > > > + end = start + ldt->nr_entries * LDT_ENTRY_SIZE; > > > + > > > + if (address < start || address >= end) > > > + return false; > > > + > > > + desc = (struct desc_struct *) ldt->entries; > > > + entry = (address - start) / LDT_ENTRY_SIZE; > > > + desc[entry].type |= 0x01; > > > > You have another patch that unconditionally sets the accessed bit on > > installation. What gives? > > Right, initially we didn't set that unconditionally. But even when we > did do that, we've observed the CPU generating these write faults. > > > Also, this patch is going to die a horrible death if IRET ever hits > > this condition. Or load gs. > > Us touching the CS/SS descriptors with LAR should avoid IRET going off > the rails, I'm not familiar with the whole gs thing, but we could very > easily augment refresh_ldt_segments() I suppose. > > Would you care to be a little more specific and or propose a testcase > for this situation? Again. load gs does not cause a fault at all like any other segment load. The fault comes when the segment is accessed the first time or via LAR. Thanks, tglx