Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp4302882rwl; Mon, 3 Apr 2023 03:02:27 -0700 (PDT) X-Google-Smtp-Source: AK7set/1Exob47LVNJpjDbCa1Wc7PRuxlpJmmZ48GYCLMl5afERRg4OVR420t9JzSLJ1jdPqKjtV X-Received: by 2002:a05:6a20:1221:b0:dd:cae3:641c with SMTP id v33-20020a056a20122100b000ddcae3641cmr27238116pzf.55.1680516146999; Mon, 03 Apr 2023 03:02:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680516146; cv=none; d=google.com; s=arc-20160816; b=Qds6tfNCitR84UWshkwG/WJZoPcCtgqV3I/4kRusmb1bAEt5WL7l0pw6xuE5vjFw7M a/zGOPJtZvXeBr1H2bH/J1aewa2XUsHlyE1mqhucZE6hD325/PsIKM97PFsgAuAZy04k P+eP180uYcWsUKeaTABgNp2ViV+V3AuLh5N+oWPBUsIVAHnmixEG3owEjVNrPQp51WIQ JgFXp615RQ1XIOrNXGz3pARv7ug+CNyvzWKdRshlfjRJ+wSlMmJheLJTiAlLLLJcZqEE yb7xSAlAQsGfBs5cqdnA8SYBcwIgLIDGs6ILPE6k1xB7Szxuxn7EBxsae0/tEel0dfUx Je1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=71ApqNmMAqc4Lfz0XA+lWiPJaPmbA5X6z6e3Zew4cpc=; b=04kuQpQEk1jn7KFtdE5QPYeKWKWE4ehWE2gS57rKj5Qi9hefkdAl9gHEdLN75Sqm2c ryxKFLM3Z/xMFRGeJBdDS0J1yMJ9v2ZQJXsCFw+C/IoD5tyB2QQE5HY+awXpsT130Fxl E1i3btblpWMu8krpVBFugdKXySAseN0d/TBRqBSFUUG7IE7vwm7CyFxRYahYdAKgOEuE ijNEYcrfHqYQpo6bR4GJVmNTJ0KmK3mtV7pqQzc1WoR0co9Z9yo87nBGZ40+eZaUMTn7 yh4pElXwiHA0Xy4wmSfniyVglGmtGfK5sXuv8oliqht1T6BVL43fHDEUIgSHA5+C/5gN d5BA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=GX3fVIvy; 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 u24-20020a632358000000b005030925d31asi8007120pgm.203.2023.04.03.03.02.04; Mon, 03 Apr 2023 03:02:26 -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=GX3fVIvy; 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 S231876AbjDCJ5c (ORCPT + 99 others); Mon, 3 Apr 2023 05:57:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231433AbjDCJ5G (ORCPT ); Mon, 3 Apr 2023 05:57:06 -0400 Received: from mail-lf1-x131.google.com (mail-lf1-x131.google.com [IPv6:2a00:1450:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B91EAF1B for ; Mon, 3 Apr 2023 02:57:03 -0700 (PDT) Received: by mail-lf1-x131.google.com with SMTP id q16so37262601lfe.10 for ; Mon, 03 Apr 2023 02:57:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1680515821; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=71ApqNmMAqc4Lfz0XA+lWiPJaPmbA5X6z6e3Zew4cpc=; b=GX3fVIvy58RxfVyJr3T9lH3qWTKv1R3J2cYs2LqG/Pxof1FznaSmJdRQPc54Ygd72w He6JnRb0h4tO4BJIDU4u2tX2M1E5Pq7Bhw7ygTGotCWkLt9Xttv/9bnjx8RAK/iOwn7y j64ats3imVw54SohsHFdRdUBWZ6EJbd23PW6dzwbZ2Ptpy9/MdM+Gae/hWM95t5BIVUH zp+IR7dAS4uh30xMdS7wozo0XmPPdFRmCNXoxfG5Dzeq7LjpE/t7Wocbt3FgxT82hlxb FLIcsmTVkDwuS039a+DK2dnbO+2MEPkCoAFm02pFkMbGPRPCAywQ2iry+OoG4EGVRqeb 22BA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680515821; h=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=71ApqNmMAqc4Lfz0XA+lWiPJaPmbA5X6z6e3Zew4cpc=; b=iiBpshsCgfJ3MuQZ3lBEgizCYHRX5efxosicFm2z1f/9dpbaZiI3YMZ7YODA1NZgnR NSef+LW06rnV6OOK+vANyGO6geivf6mrzq0pVKUKIIO/3fnlTrWqySIwI/E0xBN5MY28 7LAPjj+artwCqyd6Rzzvbk9v/i6DXsgTGe5tKDfMFeFdG8R3i5wXjyUTdMByPnPtsL5G lR/facgPpiN6AezgTSxnRpBV9v7SQgYVpiATKFo3lTPic/lAiS5k8KWqOkc+4+z03umz kj6W/bn0W8qUUo55qjSBF7rZ/ui2RHd5ihtNmWEak/RqR3uAfrnvFw9Sf6Dq+jTT9VFd 4INw== X-Gm-Message-State: AAQBX9fS7v2Lf1nhBD5+8SJmcje5BV/TSNYOxUxJpfecdA6m3JLMONS7 uPomwS4U6IFxHjg4LIfbKLjUuwN4K/A/T2P8yc9cvA== X-Received: by 2002:ac2:43b3:0:b0:4db:44f9:a641 with SMTP id t19-20020ac243b3000000b004db44f9a641mr10124181lfl.6.1680515821272; Mon, 03 Apr 2023 02:57:01 -0700 (PDT) MIME-Version: 1.0 References: <20230312112612.31869-1-kirill.shutemov@linux.intel.com> <20230312112612.31869-12-kirill.shutemov@linux.intel.com> <20230403094419.zl2ncsd4qyd35fex@box> In-Reply-To: <20230403094419.zl2ncsd4qyd35fex@box> From: Dmitry Vyukov Date: Mon, 3 Apr 2023 11:56:48 +0200 Message-ID: Subject: Re: [PATCHv16 11/17] x86/mm/iommu/sva: Make LAM and SVA mutually exclusive To: "Kirill A. Shutemov" Cc: "Kirill A. Shutemov" , Dave Hansen , Andy Lutomirski , Peter Zijlstra , x86@kernel.org, Kostya Serebryany , Andrey Ryabinin , Andrey Konovalov , Alexander Potapenko , Taras Madan , "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" X-Spam-Status: No, score=-15.7 required=5.0 tests=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,USER_IN_DEF_DKIM_WL, USER_IN_DEF_SPF_WL autolearn=unavailable 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 Mon, 3 Apr 2023 at 11:44, Kirill A. Shutemov wrote: > > On Mon, Apr 03, 2023 at 08:18:57AM +0200, Dmitry Vyukov wrote: > > Hi Kirill, > > > > ARCH_ENABLE_TAGGED_ADDR checks that task->mm == current->mm, > > shouldn't ARCH_FORCE_TAGGED_SVA check that as well? > > Do you a particular race in mind? I cannot think of anything right away. > > I guess we can add the check for consistency. But if there's a bug it is a > different story. No, I don't have a particular race in mind. Was thinking solely about consistency and if these things should be set for other processes (relaxing the check is always possible in future, but adding new restrictions is generally not possible). > > Also it looks like currently to enable both LAM and SVA. > > LAM enabling checks for SVA, but SVA doesn't and both are not mutually > > exclusive. > > For LAM we check SVM with mm_valid_pasid() && !test_bit() in > prctl_enable_tagged_addr(). > > For SVM we check for LAM with !mm_lam_cr3_mask() || test_bit() in > arch_pgtable_dma_compat() which called from iommu_sva_alloc_pasid(). It seems that currently it's possible to both enable LAM and set SVA bit. Then arch_pgtable_dma_compat() will return true, but LAM is enabled.