From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id E93DFC6FD1D for ; Fri, 17 Mar 2023 17:19:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 87CCC6B007B; Fri, 17 Mar 2023 13:19:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 82D126B007D; Fri, 17 Mar 2023 13:19:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6CE4C6B007E; Fri, 17 Mar 2023 13:19:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 598E26B007B for ; Fri, 17 Mar 2023 13:19:35 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 2954E1A19EA for ; Fri, 17 Mar 2023 17:19:35 +0000 (UTC) X-FDA: 80579051910.24.03D47D2 Received: from mail-io1-f51.google.com (mail-io1-f51.google.com [209.85.166.51]) by imf30.hostedemail.com (Postfix) with ESMTP id 4705580021 for ; Fri, 17 Mar 2023 17:19:33 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=BsAbRnkM; spf=pass (imf30.hostedemail.com: domain of glider@google.com designates 209.85.166.51 as permitted sender) smtp.mailfrom=glider@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1679073573; a=rsa-sha256; cv=none; b=sl6U+6+Ynog9ji10X8UqqUd1hV5NmE+wR4TY8L0jdfW8OJLDrlOrodRv2V+feg9NyxXYfs 0JKNNO6dUIAZzQCvOS9Uwy0yjTPVcRS7f5E1Z/ZmaeHo4HDsn6xp+O6oRrit2yoGDK9JnI at1UaateQoc8l5XPY+78IP0G6ZM54/k= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=BsAbRnkM; spf=pass (imf30.hostedemail.com: domain of glider@google.com designates 209.85.166.51 as permitted sender) smtp.mailfrom=glider@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1679073573; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=cZ1jfFaVI6yh/37IHeoLsAnsMSdzqOsbZaMRVGssD1U=; b=68y/hAG52bFNz1WoVvbqPMKrBIqFdf3ZTJf2DSpq0redRpxZCzuAG8ReMZ0ZxcyIVCCr2k qaCHtXqyeesovEWRXOBrVZk2OJ9d61KePRheeliEAEr4vW+NoivyQW81vUl2wya7BVxzca YSdYDUGv5UEI1Yqi4GPGSYTVRttTq4o= Received: by mail-io1-f51.google.com with SMTP id o14so2602667ioa.3 for ; Fri, 17 Mar 2023 10:19:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1679073572; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=cZ1jfFaVI6yh/37IHeoLsAnsMSdzqOsbZaMRVGssD1U=; b=BsAbRnkM6qn7OVPAhdQZsax2D7QZoj0xaj0pSluv7758cMzZ9eJ5IsMbmRfBdkp1dc UgTxWu2ccQut1F4ZnLvN2zX7USa9t4uvEanwBcKDmTXKAwFBre4yU6boWzEyTTe5TCpB pOXbT3GYMZIiNnpmL7IuzQNxonvIxXvpmqKSawN84zylpQLdR6KuHSOlb86k6ZK0U0q9 Tavtmqflj2sqr+yxQ/e5Rh6jXFutZNqPF6aqAlqEHBLMjflzwmbMI/qWtkZ0AdgmA2v7 AGHQhr3wLIPAdAIAbbV/Xbb96/oOQa76cdkiWGQYaF+7EiLo8z3YezP3w7M8S/HUt6jr LrIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679073572; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cZ1jfFaVI6yh/37IHeoLsAnsMSdzqOsbZaMRVGssD1U=; b=i+/ptQyUaNp48E3xqoHjVn0fSrwPHDi7f++r8P0w395wnvJqw+6mHOB5sL1jCRdubm rGi55LKo8MYCb7XBXaMPY9LFbSfZYB7wZBfyjEWpVV0sORtEy1pRgfiiyh9X7RMTTSuB QqnIgxe51Mu+j8mnfr5pJAmGuCEMdY8geRESXIhUPZ7sIdyDlGXYWoTS/Bb5aT+IBLPb 4DCJ1yQwZ5qN15lWW+xv/JOxbs4Th4CSC2PATKOHN0ZujCMY6nihvSKYgF1kcV56LsRB psP1xPsPlsI9cSROsi3zT44Z4epbqmD7CmDrpJrDpTybDIFoSWgoydHThv9E6H7XmokH tqoQ== X-Gm-Message-State: AO0yUKXvI2wPsDlXsbSCrWoOAhiHZeUuDUfbE9NLAPMgWhey5umn8keu BTFA8waQKGDdEi72XqWYbLSA9LYvXlMI6FlArdfaww== X-Google-Smtp-Source: AK7set9ZkmPhByF2aaxm+U5uE9Zmao/FLOBaByI68TINytAeD2dV0Dg7XbZOP8QJFS/VIKn1sXMSml5Id3DPtpub+K0= X-Received: by 2002:a5e:8a0d:0:b0:74c:97ee:4e56 with SMTP id d13-20020a5e8a0d000000b0074c97ee4e56mr211043iok.3.1679073572221; Fri, 17 Mar 2023 10:19:32 -0700 (PDT) MIME-Version: 1.0 References: <20230312112612.31869-1-kirill.shutemov@linux.intel.com> In-Reply-To: <20230312112612.31869-1-kirill.shutemov@linux.intel.com> From: Alexander Potapenko Date: Fri, 17 Mar 2023 18:18:55 +0100 Message-ID: Subject: Re: [PATCHv16 00/17] Linear Address Masking enabling To: "Kirill A. Shutemov" , x86@kernel.org Cc: Andy Lutomirski , Peter Zijlstra , Kostya Serebryany , Andrey Ryabinin , Andrey Konovalov , Taras Madan , Dmitry Vyukov , "H . J . Lu" , Andi Kleen , Rick Edgecombe , Bharata B Rao , Jacob Pan , Ashok Raj , Linus Torvalds , linux-mm@kvack.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspam-User: X-Rspamd-Queue-Id: 4705580021 X-Rspamd-Server: rspam01 X-Stat-Signature: xce5dtz3w7pje7th65zha7t5zsob96at X-HE-Tag: 1679073573-201559 X-HE-Meta: U2FsdGVkX1+EZgFCRvEkghQpm0BGNgpDAuajVPfOh2FdFCU6aYyUObFuZdDXY+pz7JEpeWJK5dFcWm4OZvLpmppXZ2m3ompD4yxEQFOqnpVXFrVLXx/Kc7FSpJbcu9DCOd/iX1gvJfgJD8n1fxSMhpJvdvPIXyN26OGVziuRr93XdrnIbyx6FGEENwwiGV9+KwxRcFz4Eg+Zwm0sAt9DuB6xkpTKSh5mEQVveVITIMEwrWsIoytyoTKgr1KwujJAhdWfhR+nnue8uUJV0UWD2NeuUiVlK0L8KMwcxWeXxIlFB4VdSvqzI6rB+h2DKXiRPCwoAMVcarT6lUxgBoXl8sOAik6sOQ1/YY+7IYeDeLt8tLHrOFVbQgDR7EVy7sBVwCSu7aQOs99pycAKrKzycymqmvC74StePFJNyLl42CYP3LMMG0h9HYPsMvxm00omEXHlJqqD/tscIZ/VtQHCC2FkXS8EomB9f7L/YBzAjN6AcqER6AYqb5oyal5ukneIknJmTeOa5enLWvWMrVf9jiKtkA8MwDnaPAeMowrlQGz62K5rJo5Y8y0JyePNIcAvJ4TdI0ibShamItwsYHJhgYu6DE325qukXTg7PVIeybY1pjlUXJsmqbv2/GzghYEHcsheayRZG6WaM6RXk/6sQLfCr8iYA4+qZuIF5i/TMFOqvJKD+xcZlses9hLy/QKTDMX/mXBPDjwi+AjZG2cvsXdZMnux0RxRSempjEBtRdT3fYPo9baomayd+H+ZTuzLg5k6zSlG/pX8i/oUKSDV/nnu8yYdRNP79F28BauyF05qg22fny/ME7IUzISUqGQwY0BKwAc0qSmN9typpCl2DPCcGNmhDWrTQyEL1hkY/zdLgY07gMvq3pwvyLwBz+5Hul+2RMCvSRdJQDjIdsbLmwEhLQL7V+Tpr06Uy2U4ZhsyzTeC5QvQwBEICErt7wbxRXdGQvIZSv8xLeQoZ8n akGRP29P AfSVtB+9gXaxfUltYfWRFE72az3mLbvnJO0oA/BM+tb8Vritm+hXW1kZDIYqTiW9QKWFC41bobCFP4zFA+b3d/lD9vDVz0fW8XEi1UvdMH0cM8Ou2RzbfsddDv61tHj7kdXl5P3DsuURd9XTXD33pU9Wt0nc/g+of3Ei1ZnJVMopMSMi//fk0drIj75NeLHC9DsV4zL9MvoVASecQKxYQcOPqiHTOGtmaai/xA9yOrC+JTxJ/q4i3dUx2zPhnS840g/BtyJhAiAkPDlMRHyDeU3y9DDtqoLuJYjicmrR649NdioyusvRQrm2eBYjFqSpuTjz1VCtTteMd0O7MSbBQl3cfehQkT3HNhEP6C3LYnp2r6vZYn5S6pOfsB+3OnAfMWh+nd5IzY9xovae3Mv5hu85FQQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Dear x86 maintainers, the series looks pretty mature now, any chance it can be considered for upstream? On Sun, Mar 12, 2023 at 12:26=E2=80=AFPM Kirill A. Shutemov wrote: > > Linear Address Masking[1] (LAM) modifies the checking that is applied to > 64-bit linear addresses, allowing software to use of the untranslated > address bits for metadata. > > The capability can be used for efficient address sanitizers (ASAN) > implementation and for optimizations in JITs and virtual machines. > > The patchset brings support for LAM for userspace addresses. Only LAM_U57= at > this time. > > Please review and consider applying. > > git://git.kernel.org/pub/scm/linux/kernel/git/kas/linux.git lam > > v16: > - Add #include into fs/proc/array.c; > - Whitespace fix; > - Add Alexander's Tested-bys; > v15: > - Replace static branch in untagged_addr() with alternative; > - Drop unneeded READ_ONCE(); > - Acks from Peter; > v14: > - Rework address range check in get_user() and put_user(); > - Introduce CONFIG_ADDRESS_MASKING; > - Cache untag masking in per-CPU variable; > - Reject LAM enabling via PTRACE_ARCH_PRCTL; > - Fix locking around untagged_addr_remote(); > - Fix typo in MM_CONTEXT_ conversion patch; > - Fix selftest; > v13: > - Fix race between untagged_addr() and LAM enabling: > + Do not allow to enable LAM after the process spawned the second thr= ead; > + untagged_addr() untags the address according to rules of the curren= t > process; > + untagged_addr_remote() can be used for untagging addresses for fore= ign > process. It requires mmap lock for the target process to be taken; > v12: > - Rebased onto tip/x86/mm; > - Drop VM_WARN_ON() that may produce false-positive on race between con= text > switch and LAM enabling; > - Adjust comments explain possible race; > - User READ_ONCE() in mm_lam_cr3_mask(); > - Do not assume &init_mm =3D=3D mm in initialize_tlbstate_and_flush(); > - Ack by Andy; > v11: > - Move untag_mask to /proc/$PID/status; > - s/SVM/SVA/g; > - static inline arch_pgtable_dma_compat() instead of macros; > - Replace pasid_valid() with mm_valid_pasid(); > - Acks from Ashok and Jacob (forgot to apply from v9); > v10: > - Rebased to v6.1-rc1; > - Add selftest for SVM vs LAM; > v9: > - Fix race between LAM enabling and check that KVM memslot address does= n't > have any tags; > - Reduce untagged_addr() overhead until the first LAM user; > - Clarify SVM vs. LAM semantics; > - Use mmap_lock to serialize LAM enabling; > v8: > - Drop redundant smb_mb() in prctl_enable_tagged_addr(); > - Cleanup code around build_cr3(); > - Fix commit messages; > - Selftests updates; > - Acked/Reviewed/Tested-bys from Alexander and Peter; > v7: > - Drop redundant smb_mb() in prctl_enable_tagged_addr(); > - Cleanup code around build_cr3(); > - Fix commit message; > - Fix indentation; > v6: > - Rebased onto v6.0-rc1 > - LAM_U48 excluded from the patchet. Still available in the git tree; > - add ARCH_GET_MAX_TAG_BITS; > - Fix build without CONFIG_DEBUG_VM; > - Update comments; > - Reviewed/Tested-by from Alexander; > v5: > - Do not use switch_mm() in enable_lam_func() > - Use mb()/READ_ONCE() pair on LAM enabling; > - Add self-test by Weihong Zhang; > - Add comments; > v4: > - Fix untagged_addr() for LAM_U48; > - Remove no-threads restriction on LAM enabling; > - Fix mm_struct access from /proc/$PID/arch_status > - Fix LAM handling in initialize_tlbstate_and_flush() > - Pack tlb_state better; > - Comments and commit messages; > v3: > - Rebased onto v5.19-rc1 > - Per-process enabling; > - API overhaul (again); > - Avoid branches and costly computations in the fast path; > - LAM_U48 is in optional patch. > v2: > - Rebased onto v5.18-rc1 > - New arch_prctl(2)-based API > - Expose status of LAM (or other thread features) in > /proc/$PID/arch_status > > [1] ISE, Chapter 10. https://cdrdv2.intel.com/v1/dl/getContent/671368 > > Kirill A. Shutemov (12): > x86/mm: Rework address range check in get_user() and put_user() > x86: Allow atomic MM_CONTEXT flags setting > x86: CPUID and CR3/CR4 flags for Linear Address Masking > x86/mm: Handle LAM on context switch > mm: Introduce untagged_addr_remote() > x86/uaccess: Provide untagged_addr() and remove tags before address > check > x86/mm: Reduce untagged_addr() overhead for systems without LAM > x86/mm: Provide arch_prctl() interface for LAM > mm: Expose untagging mask in /proc/$PID/status > iommu/sva: Replace pasid_valid() helper with mm_valid_pasid() > x86/mm/iommu/sva: Make LAM and SVA mutually exclusive > selftests/x86/lam: Add test cases for LAM vs thread creation > > Weihong Zhang (5): > selftests/x86/lam: Add malloc and tag-bits test cases for > linear-address masking > selftests/x86/lam: Add mmap and SYSCALL test cases for linear-address > masking > selftests/x86/lam: Add io_uring test cases for linear-address masking > selftests/x86/lam: Add inherit test cases for linear-address masking > selftests/x86/lam: Add ARCH_FORCE_TAGGED_SVA test cases for > linear-address masking > > arch/arm64/include/asm/mmu_context.h | 6 + > arch/sparc/include/asm/mmu_context_64.h | 6 + > arch/sparc/include/asm/uaccess_64.h | 2 + > arch/x86/Kconfig | 11 + > arch/x86/entry/vsyscall/vsyscall_64.c | 2 +- > arch/x86/include/asm/cpufeatures.h | 1 + > arch/x86/include/asm/disabled-features.h | 8 +- > arch/x86/include/asm/mmu.h | 18 +- > arch/x86/include/asm/mmu_context.h | 49 +- > arch/x86/include/asm/processor-flags.h | 2 + > arch/x86/include/asm/tlbflush.h | 48 +- > arch/x86/include/asm/uaccess.h | 58 +- > arch/x86/include/uapi/asm/prctl.h | 5 + > arch/x86/include/uapi/asm/processor-flags.h | 6 + > arch/x86/kernel/process.c | 6 + > arch/x86/kernel/process_64.c | 66 +- > arch/x86/kernel/traps.c | 6 +- > arch/x86/lib/getuser.S | 83 +- > arch/x86/lib/putuser.S | 54 +- > arch/x86/mm/init.c | 5 + > arch/x86/mm/tlb.c | 53 +- > drivers/iommu/iommu-sva.c | 8 +- > drivers/vfio/vfio_iommu_type1.c | 2 +- > fs/proc/array.c | 7 + > fs/proc/task_mmu.c | 9 +- > include/linux/ioasid.h | 9 - > include/linux/mm.h | 11 - > include/linux/mmu_context.h | 14 + > include/linux/sched/mm.h | 8 +- > include/linux/uaccess.h | 22 + > mm/gup.c | 4 +- > mm/madvise.c | 5 +- > mm/migrate.c | 11 +- > tools/testing/selftests/x86/Makefile | 2 +- > tools/testing/selftests/x86/lam.c | 1241 +++++++++++++++++++ > 35 files changed, 1699 insertions(+), 149 deletions(-) > create mode 100644 tools/testing/selftests/x86/lam.c > > -- > 2.39.2 > --=20 Alexander Potapenko Software Engineer Google Germany GmbH Erika-Mann-Stra=C3=9Fe, 33 80636 M=C3=BCnchen Gesch=C3=A4ftsf=C3=BChrer: Paul Manicle, Liana Sebastian Registergericht und -nummer: Hamburg, HRB 86891 Sitz der Gesellschaft: Hamburg