Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp964662ybg; Wed, 29 Jul 2020 02:15:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwnW7snbnSiKYlg5Y7BYTd1RO/PvVhKpjhOJ25bYX2mpXGtcBGIsXN9+FHQLuJPD42rTuCZ X-Received: by 2002:a05:6402:1d93:: with SMTP id dk19mr10844294edb.382.1596014100839; Wed, 29 Jul 2020 02:15:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596014100; cv=none; d=google.com; s=arc-20160816; b=zrr+yWWGsME8l7WC6icW0aBSiot13jjHS2Cuf0P4S2c0NcT6CZchCaBDuaOVQ/ZIBv cjqCE3KsUwgN0CS5rJXj+WBJxOlLYZuYdRvOznK7lL19SCvRbQgOYGkADWjjLxZ2q+VU lq2uvqVFg9KPq98jhOMxhcgQMZNhV7x6b8Q4mKZFbnQG5IkKZ3RwDJM0rYeq63brwRmt yqYrvYEhJ5IainWyw5GeHRugpRc3IRj7HDdy2UnyWrKXOJcmjO5YZpeE2D1fKgUlvICZ 54qDmG3ZBoe2jBMSUJFn8AD5zRh/65EMFDfQ+0mhBnInWrlIo/MqLCyuAcbC/+ei9TMO lBJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=J0SIyyCqtngJmxWOxvkn9MOwqoIdVm/BuYE3QogVzc8=; b=jr69fvA4jPbcpALCp4Z0PRl77z4xN1olh/VCXf9C8GxOkwofV2/GmU4ssHKep4H0Ox WsxVNTqc82DE8CKZAh02OXFM/P5ey3TLBK5WZN4+qckpahBVSOsNfPNzDT5CyGNLDQ+U NnS9wg0IC+R0qM4wYdUxNznY/V3HR1ZDxfdfQ2f+GTKoinf+IRE9gwONL47Pv/SJ+wGP w16kE8Q1Ti40kopEF01l7AIaZcJ9RenL43Sr0pt7lr1216c3W+Z+LqZrMTgimI0FC1sZ kJwhS8CFjtASXVgkRMGpTecCg3n78h6NjAfUZZD5U04Q2va/PfFS8FdCPufWCHh879c6 444g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b=hpVGUku4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v16si319400edi.123.2020.07.29.02.14.39; Wed, 29 Jul 2020 02:15:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b=hpVGUku4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727794AbgG2JL7 (ORCPT + 99 others); Wed, 29 Jul 2020 05:11:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726737AbgG2JL6 (ORCPT ); Wed, 29 Jul 2020 05:11:58 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83AA8C061794 for ; Wed, 29 Jul 2020 02:11:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=J0SIyyCqtngJmxWOxvkn9MOwqoIdVm/BuYE3QogVzc8=; b=hpVGUku45zWWGcg3Prx2nBUfqb wC7X8NqIK6c6gnNIbhOYj17a2dqHkheORFnbppCmKyIBj/YKeSpuQyiisJqs50YqU3dAyGOIems4V LHIXzMKWl6aFtCjwT1NrwYz2JAmdz/FS2XpPJ9NKiP6AYrQ0T8NUz3aPFAuadCNZrl8sQJeEO7yhY NfBCwK4vvGWkub3aVF14dJdSw2TasQjmhM1EshBuXO9ZWJ9ca87kAYesGvw6kMeMFjDCJpWLuJ0ou gI+D78lyyCVpDihtztlVMkpTsBqbMuluBhHYDHfhaxQ9ZuYYFF6G7+MVd3xjGvcRthS7+WBZEnMcz B8FIoJoA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1k0i7u-0003PP-J3; Wed, 29 Jul 2020 09:11:54 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 3265F300238; Wed, 29 Jul 2020 11:11:54 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 1D9B22B804951; Wed, 29 Jul 2020 11:11:54 +0200 (CEST) Date: Wed, 29 Jul 2020 11:11:54 +0200 From: peterz@infradead.org To: Andy Lutomirski Cc: Gabriel Krisman Bertazi , Christoph Hellwig , Thomas Gleixner , Kees Cook , X86 ML , LKML , kernel@collabora.com Subject: Re: [PATCH 2/6] arch: x86: Wrap TIF_IA32 checks Message-ID: <20200729091154.GB119549@hirez.programming.kicks-ass.net> References: <20200728202229.1195682-1-krisman@collabora.com> <20200728202229.1195682-3-krisman@collabora.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 28, 2020 at 08:43:27PM -0700, Andy Lutomirski wrote: > On Tue, Jul 28, 2020 at 1:22 PM Gabriel Krisman Bertazi > > diff --git a/arch/x86/events/intel/ds.c b/arch/x86/events/intel/ds.c > > index dc43cc124e09..27d1cc1f3d05 100644 > > --- a/arch/x86/events/intel/ds.c > > +++ b/arch/x86/events/intel/ds.c > > @@ -1261,7 +1261,7 @@ static int intel_pmu_pebs_fixup_ip(struct pt_regs *regs) > > old_to = to; > > > > #ifdef CONFIG_X86_64 > > - is_64bit = kernel_ip(to) || !test_thread_flag(TIF_IA32); > > + is_64bit = kernel_ip(to) || !TASK_IA32(current); > > PeterZ, does PEBS not give us a CPL? Is it really just IP? > > Anyway, this should probably be: > > is_64bit = kernel_ip(to) || user_64bit_mode(regs) || !user_mode(regs); Correct, PEBS doesn't have the segment registers and we get to guess :/ Look at the various pebs_record_* structures in arch/x86/events/intel/ds.c. That said, in fixup_ip() we're guaranteed to be in the same process, so unless the task does really funny things like switch mode between triggering the assist and getting the PMI, we ought to be able to trust regs.