Received: by 2002:a5d:925a:0:0:0:0:0 with SMTP id e26csp1725513iol; Fri, 10 Jun 2022 13:35:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz3ZWF9OgBWnajzjjSiHpH72XUqzlMpte902N8Ohl/XbqoZfxie2Guit8EPKkPX35MWaY10 X-Received: by 2002:a17:907:7f8f:b0:711:623e:b344 with SMTP id qk15-20020a1709077f8f00b00711623eb344mr14750307ejc.230.1654893336893; Fri, 10 Jun 2022 13:35:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654893336; cv=none; d=google.com; s=arc-20160816; b=qCJqLFo9iv2BRl7nnG8VF3ArwfNTAHPzvYYy7do4jO3qjcJtg943F77Csyf2wgtj35 aOnCAmgfM7oK/wpmGOvI/ma8e9/jQs6g1jiaFYdofbN6sRBlV8PFwIi5DvaziNbN+VS2 q8Pk6jm3JazYR5TRcbAVKy/BXovbAO242yjMH6Lu+Qe3CKywvnAGM6nz6ODK6Www+Yux WvfyBTOHEADChqB8XsqPuAx+KxBhz4nSMybS6hZCyt0SEnj5zkR5NgFrgYdywAC9XXGB U3GZS1qVbQrmWTA26S0u5P7hhrX6L+FU4CzxnpNFWOx/G/cc9yY0soPrG3pZYJ/lemvi rQkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=CMK9HHoC+CkaS7ESlgdwWQx56QlM6DUYZIowUim1ARU=; b=P8+EgqEc0h+E75wiS4nQ9i6uwssI6gm6rTsAxI0sk3nwycegVBo7mVJ4BTKRKHB++g 6vYWyN5oHIZ+Q3VrAR9cyFRQquWb5Jo4gl9fFqYoWC86sF1MERgFg5vwpvy8p9mTOeXW hg1jp561jZrh4zHhRmikOCfE38ogJzttlCzHo4RPps+F/fEDVgL++fMtC6JZowRe3Inm DBzZ7M8WcNKrALT69Acn0RCb1EMUWhFNh88IQoHRpTvzpWFiPhukkdIYlDzRTZH9qFRG YcX4fY4fTHCxTIYsPB6RgyUg5V7coxocoM74EIQo3/JbUHZ4KN6PO/v5pDPQCt7npkoN ZZPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=ZLB1iJby; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r23-20020aa7d597000000b0042dec850ef4si210903edq.486.2022.06.10.13.35.00; Fri, 10 Jun 2022 13:35:36 -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=@google.com header.s=20210112 header.b=ZLB1iJby; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347622AbiFJUW3 (ORCPT + 99 others); Fri, 10 Jun 2022 16:22:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350145AbiFJUWY (ORCPT ); Fri, 10 Jun 2022 16:22:24 -0400 Received: from mail-il1-x136.google.com (mail-il1-x136.google.com [IPv6:2607:f8b0:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 856B63002C7 for ; Fri, 10 Jun 2022 13:22:22 -0700 (PDT) Received: by mail-il1-x136.google.com with SMTP id f12so166795ilj.1 for ; Fri, 10 Jun 2022 13:22:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=CMK9HHoC+CkaS7ESlgdwWQx56QlM6DUYZIowUim1ARU=; b=ZLB1iJbyDobtzDI6Is5SV0nGWNdc2St9G6RlgjYVVGp0uVrZ6v4ZI92gVUwT0/BUmg J1/JWP6jEh3acyYwnnlCKNfItePYtpwUoe4FsgljkRzHTiAD8WdXLlFypHP5c9KtpVT6 OVc61CGaDh4DF57LxzGE9s/A9/9Jq6BpcSWUXxunYSqP+/8OBDRgx34AFQV8gQtQVb3g TJs4tFwoXAMtvtHU5s1KN/0NC9+7/vIBAv1VmSLm104PLcIWCxPocPztCu5rDgBE5O8v HDOefH58ccSQ3qHiFcHoLvaXVgGb1gZxnK5xmyQvSOufs5BGfU+dJ3Efrt+8fZGNdIVA R/ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=CMK9HHoC+CkaS7ESlgdwWQx56QlM6DUYZIowUim1ARU=; b=w2gJgIs/+tSdgogF+zf5fFVGDwDxJ2pQWrr0KzoIGHkYtFzO4YkyaEP5Reqg247eqA FU70iwK9OedJoYKGYaRMYVr8Nd3DLYZ9gsElbt7BTpB4rQ2EbqLmYi12ICe2bBP2dxXg g3fnp4xOe0aKHjXGqiTO1VRJH7NShke1EW85bbmWlNMvjinL7ivds5ApHHzQ79OEFeOY qNGhHGVC05FtgkCYo9kzcQylZmwTSKvybCUxa0EbdVeZt+xXBLhUvZBUBPCXeNGHWDK8 /8/A5zO72KB0GzeiJZJj67nIhqdFRvIWDYTuJCtg6maUXLMxu9jyINij2r9jvU+9e4c4 r2eg== X-Gm-Message-State: AOAM533XC1Dskb7AfTpxkrheZpW5N2r43W9k5PnPrVxcyOYTEo+wM5dS CWfgYOXfoZodq5FjiThTnFrAD0ahNtoqKMsWAL7/gQ== X-Received: by 2002:a92:c24c:0:b0:2d1:cdd0:1959 with SMTP id k12-20020a92c24c000000b002d1cdd01959mr25304794ilo.39.1654892541600; Fri, 10 Jun 2022 13:22:21 -0700 (PDT) MIME-Version: 1.0 References: <20220610143527.22974-1-kirill.shutemov@linux.intel.com> In-Reply-To: <20220610143527.22974-1-kirill.shutemov@linux.intel.com> From: Kostya Serebryany Date: Fri, 10 Jun 2022 13:22:09 -0700 Message-ID: Subject: Re: [PATCHv3 0/8] Linear Address Masking enabling To: "Kirill A. Shutemov" Cc: Dave Hansen , Andy Lutomirski , Peter Zijlstra , x86@kernel.org, Andrey Ryabinin , Andrey Konovalov , Alexander Potapenko , Dmitry Vyukov , "H . J . Lu" , Andi Kleen , Rick Edgecombe , linux-mm@kvack.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED,USER_IN_DEF_DKIM_WL, USER_IN_DEF_SPF_WL 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 Thanks for working on this, please make LAM happen. It enables efficient memory safety testing that is already available on AAr= ch64. Memory error detectors, such as ASAN and Valgrind (or KASAN for the kernel) have limited applicability, primarily because of their run-time overheads (CPU, RAM, and code size). In many cases, the major obstacle to a wider deployment is the RAM overhead, which is typically 2x-3x. There is another = tool, HWASAN [1], which solves the same problem and has < 10% RAM overhead. This tool is available only on AArch64 because it relies on the top-byte-ignore (TBI) feature. Full support for that feature [2] has been added to the kernel in order to enable HWASAN. Adding support for LAM will enable HWASAN on x86_64. HWASAN is already the main memory safety tool for Android [3] - the reduced= RAM overhead allowed us to utilize this testing tool where ASAN=E2=80=99s RAM o= verhead was prohibitive. We have also prototyped the x86_64 variant of HWASAN, and we c= an observe that it is a major improvement over ASAN. The kernel support and hardware availability are the only missing parts. Making HWASAN available on x86_64 will enable developers of server and client software to scale up their memory safety testing, and thus improve the quality and security of their products. [1] https://clang.llvm.org/docs/HardwareAssistedAddressSanitizerDesign.html [2] https://www.kernel.org/doc/html/latest/arm64/tagged-address-abi.html [3] https://source.android.com/devices/tech/debug/hwasan --kcc On Fri, Jun 10, 2022 at 7:35 AM 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 patchset brings support for LAM for userspace addresses. > > LAM_U48 enabling is controversial since it competes for bits with > 5-level paging. Its enabling isolated into an optional last patch that > can be applied at maintainer's discretion. > > Please review and consider applying. > > 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 14. > https://software.intel.com/content/dam/develop/external/us/en/documents-t= ps/architecture-instruction-set-extensions-programming-reference.pdf > > Kirill A. Shutemov (8): > x86/mm: Fix CR3_ADDR_MASK > x86: CPUID and CR3/CR4 flags for Linear Address Masking > mm: Pass down mm_struct to untagged_addr() > x86/mm: Handle LAM on context switch > x86/uaccess: Provide untagged_addr() and remove tags before address che= ck > x86/mm: Provide ARCH_GET_UNTAG_MASK and ARCH_ENABLE_TAGGED_ADDR > x86: Expose untagging mask in /proc/$PID/arch_status > x86/mm: Extend LAM to support to LAM_U48 > > arch/arm64/include/asm/memory.h | 4 +- > arch/arm64/include/asm/signal.h | 2 +- > arch/arm64/include/asm/uaccess.h | 4 +- > arch/arm64/kernel/hw_breakpoint.c | 2 +- > arch/arm64/kernel/traps.c | 4 +- > arch/arm64/mm/fault.c | 10 +-- > arch/sparc/include/asm/pgtable_64.h | 2 +- > arch/sparc/include/asm/uaccess_64.h | 2 + > arch/x86/include/asm/cpufeatures.h | 1 + > arch/x86/include/asm/elf.h | 3 +- > arch/x86/include/asm/mmu.h | 2 + > arch/x86/include/asm/mmu_context.h | 58 +++++++++++++++++ > arch/x86/include/asm/processor-flags.h | 2 +- > arch/x86/include/asm/tlbflush.h | 3 + > arch/x86/include/asm/uaccess.h | 44 ++++++++++++- > arch/x86/include/uapi/asm/prctl.h | 3 + > arch/x86/include/uapi/asm/processor-flags.h | 6 ++ > arch/x86/kernel/Makefile | 2 + > arch/x86/kernel/fpu/xstate.c | 47 -------------- > arch/x86/kernel/proc.c | 50 +++++++++++++++ > arch/x86/kernel/process.c | 3 + > arch/x86/kernel/process_64.c | 54 +++++++++++++++- > arch/x86/kernel/sys_x86_64.c | 5 +- > arch/x86/mm/hugetlbpage.c | 6 +- > arch/x86/mm/mmap.c | 9 ++- > arch/x86/mm/tlb.c | 62 ++++++++++++++----- > .../gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 2 +- > drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 2 +- > drivers/gpu/drm/radeon/radeon_gem.c | 2 +- > drivers/infiniband/hw/mlx4/mr.c | 2 +- > drivers/media/common/videobuf2/frame_vector.c | 2 +- > drivers/media/v4l2-core/videobuf-dma-contig.c | 2 +- > .../staging/media/atomisp/pci/hmm/hmm_bo.c | 2 +- > drivers/tee/tee_shm.c | 2 +- > drivers/vfio/vfio_iommu_type1.c | 2 +- > fs/proc/task_mmu.c | 2 +- > include/linux/mm.h | 11 ---- > include/linux/uaccess.h | 11 ++++ > lib/strncpy_from_user.c | 2 +- > lib/strnlen_user.c | 2 +- > mm/gup.c | 6 +- > mm/madvise.c | 2 +- > mm/mempolicy.c | 6 +- > mm/migrate.c | 2 +- > mm/mincore.c | 2 +- > mm/mlock.c | 4 +- > mm/mmap.c | 2 +- > mm/mprotect.c | 2 +- > mm/mremap.c | 2 +- > mm/msync.c | 2 +- > virt/kvm/kvm_main.c | 2 +- > 51 files changed, 342 insertions(+), 126 deletions(-) > create mode 100644 arch/x86/kernel/proc.c > > -- > 2.35.1 >