Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp6759206iob; Wed, 11 May 2022 04:55:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJywowaAxYvHzeqSw48+oYpio60CXPUgA8QVbUEMFqy4ujgeYz0bd+Ev2mlltxqGVZdkFxBD X-Received: by 2002:a17:906:130c:b0:6f3:8bbd:740a with SMTP id w12-20020a170906130c00b006f38bbd740amr24283487ejb.621.1652270152445; Wed, 11 May 2022 04:55:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652270152; cv=none; d=google.com; s=arc-20160816; b=wuyjaOL8EEulH7V1DVRWPJbwQqAcGKbD1a5Enh4iXOS3GW5w5lE2GiuHwYAzQ6ti5t cJXgu34it6Y0xcfitR4QN8vZlMCkEUmUscfV43vF/pUq2wVA4MeQV06nOwgWyo97i56a wv0SAvRTKm065ExVItoE1DgL2MNwChoew8GDKDqGFckenl0SyIW3JzbBkJZjkTMY15Yg ee0Z7Udzg8yqGYUWCfpWPBfsxbW0WRsPwoU2JzC6zixZXnxnSjWC2WZpXUo+cmGhaFmX NMgVvxV4TB4vmTUmx6HU1uIUXE1jLeUwfgCHW5t82f/fZ9dU7XiQkNHxNKqEZEgbRSyX pXtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=WqQvvzTawsUra3llaTMtecCGxHMoJa0AaVmr+uqshgk=; b=WgLfe7b3zlbmrlmq93IZiz81fkc1+w4FsHO9vFCvu+cl5kWTU+Ax6AWuIMndQzboQ/ kwoNi8MVAev/f6taLRIatOqRXoHpVv4CXL1dhbxb4YXwE/dR7WhG1FBoGIsu9eOqpfmC 2QIntzUBbs9RehEYzHocZpAkJckPYTVnM7se0ELY79nTtGXNmik5+/XIyZV02HZ2jXur q7ksFKR0Qub7zH1EVnX9YRfa6+nBVuDKwA/zhF8UO+YZNERmUq1YgVUq3yH79wXggY2I tdMdsdNHZAxVWJQz9V+PWQ2NMtE5eFrAW03vHLibafECIRkxw61zjGhNDGxIEZ4WH2WF CaAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=rXYulYiO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f11-20020a0564021e8b00b00425ed8d4c0csi2833571edf.263.2022.05.11.04.55.28; Wed, 11 May 2022 04:55:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=rXYulYiO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242906AbiEKH1N (ORCPT + 99 others); Wed, 11 May 2022 03:27:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241426AbiEKH1C (ORCPT ); Wed, 11 May 2022 03:27:02 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D7733BBC1 for ; Wed, 11 May 2022 00:27:01 -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=WqQvvzTawsUra3llaTMtecCGxHMoJa0AaVmr+uqshgk=; b=rXYulYiOCSxQOkz21USvuZ8PMZ TFMOCQktj/apPUevOQxpan2cX+AhwEDOr7WXdUVoA21F/MINzQLqplcr3DnEtIkCuBFQzIYGlVpcz iwTSzsGhevzamCUouHqSkWI3AzTOR7KDHHraSFvv9iCDUougczpM5iSCjchEwHWyrEx8seEsjAFp8 I0Q2NoC2U43NCqaZFejkQApFweQvaB9ecj+xvMJMinXynwM/qFm1Xl0IRWUgf+OLAUoz4Phf3g5fo URRiGJ+HUn/aRnclAPxEz8gn39NHtp0w1CftST7ng5oE4E/lV+ya7UHoIaI3XcAW0iJTYXP22RTgA LdIbpmEg==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=worktop.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1nogkG-005ENO-GQ; Wed, 11 May 2022 07:26:52 +0000 Received: by worktop.programming.kicks-ass.net (Postfix, from userid 1000) id 0CFF0980E3A; Wed, 11 May 2022 09:26:52 +0200 (CEST) Date: Wed, 11 May 2022 09:26:51 +0200 From: Peter Zijlstra To: "Kirill A. Shutemov" Cc: Dave Hansen , Andy Lutomirski , x86@kernel.org, Andrey Ryabinin , Alexander Potapenko , Dmitry Vyukov , "H . J . Lu" , Andi Kleen , Rick Edgecombe , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [RFCv2 09/10] x86/mm: Add userspace API to enable Linear Address Masking Message-ID: <20220511072651.GV76023@worktop.programming.kicks-ass.net> References: <20220511022751.65540-1-kirill.shutemov@linux.intel.com> <20220511022751.65540-11-kirill.shutemov@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220511022751.65540-11-kirill.shutemov@linux.intel.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 11, 2022 at 05:27:50AM +0300, Kirill A. Shutemov wrote: > @@ -1013,8 +1017,23 @@ static long thread_feature_prctl(struct task_struct *task, int option, > > /* Handle ARCH_THREAD_FEATURE_ENABLE */ > > + if (features & (X86_THREAD_LAM_U48 | X86_THREAD_LAM_U57)) { > + long ret; > + > + /* LAM is only available in long mode */ > + if (in_32bit_syscall()) > + return -EINVAL; So what happens if userspace sets up a 32bit code entry in the LDT and does the LAM thing as a 64bit syscamm but then goes run 32bit code? > + > + ret = enable_lam(task, features); > + if (ret) > + return ret; > + } > + > task->thread.features |= features; > out: > + /* Update CR3 to get LAM active */ > + switch_mm(task->mm, task->mm, task); > + > return task->thread.features; > } >