Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp933775rdg; Fri, 13 Oct 2023 05:48:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE/yrDGVSi+Og4wgOk6NYYj9pqSt3s/cZ88XZvpVWZ7TC6mbRObpG+TxNiCOW+9S3IMDh9N X-Received: by 2002:a17:903:2103:b0:1c9:e774:58d0 with SMTP id o3-20020a170903210300b001c9e77458d0mr2864821ple.34.1697201328491; Fri, 13 Oct 2023 05:48:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697201328; cv=none; d=google.com; s=arc-20160816; b=GUFYFWdUo3V26ZxW/fcm5tFhe6tsnX5FIyJLJ0WwPSjpgp0t0O01FSDiipdlDEwTdg jj3DDbrc2R3dkD+9F464AMZ6e+nlL/9umZhHgvSA6R4vPwWFAZkZlqw6rOYuIuqa0WUe QUX8AZaQhf5nDDxqa3KRA4HckLoCHekX05S1wyLJFK+4DOQAMgUSzRBlmwJ8a5xHWVIi kyslICN9jJLOUeIu6C6ZkInV5y+3nvtaMyBVrnWOkZvjclW61CWHQbt5MBPjoWeRCwwA ezvdO+jZ+MhBBZnQLMN1hEVL2WA23AoWz04tKMmy4xtqrb3/8+TpgFIgYk43tShiFnqt TsFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :content-language:references:to:subject:cc:user-agent:mime-version :date:message-id:dkim-signature; bh=D7DQqkFR63x9MGCSDe3y3y38hV9T9FQLx0LYWCg23rk=; fh=SHGEek85kQW07oEEl+82+wKoaQvWfr01qG+ms7NOMBk=; b=lnwddKrZQacOS3EIga3qOuhbukmz7U0Nu3Jo60mGq0NIu5NO9H2lyBcBiAOo0UyLFI r4gQt9byIgwO6KTYEXsNYccrYiL2vJp3lO3tDr3IxpsIq3Dx0D5HUYz4pTG4cvTHG+Q4 irMu1TEy8gH3NVHtSutwoOqH55fRIWwpiRTgZaSSBepIT4gotV+FhAeHZAnrEtYYfnED gdcKPsdMEzvBLHkABDBc9+qITOz1feWBlP8Fploaiz+D5JYBM8R28ol798pZ3uoEYTVc jHPKEP7+TB+aaW+1awfTXkGpevqrtl3tD1n9wqbLJqMsqAs6ua5njLBJ7fOzIAI0S8Xk 9Lug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=WNQi1vR6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id b3-20020a170902d30300b001c7380aca09si4340495plc.512.2023.10.13.05.48.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 05:48:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=WNQi1vR6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 1257C834E5BA; Fri, 13 Oct 2023 05:48:46 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231664AbjJMMsf (ORCPT + 99 others); Fri, 13 Oct 2023 08:48:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229726AbjJMMsd (ORCPT ); Fri, 13 Oct 2023 08:48:33 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4403EBD; Fri, 13 Oct 2023 05:48:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697201312; x=1728737312; h=message-id:date:mime-version:cc:subject:to:references: from:in-reply-to:content-transfer-encoding; bh=6iMpv2UTySZaEAYqtKN2xhPIH1oWxAEbKNCY7/VQAbU=; b=WNQi1vR6MPq/QtYAWVbC4+8731puk+NTl5hPI30g6DfjuvPCAu6Ypn6+ 363rKuN2iHMAOjcYFvm/aL6h3Z3UEWqmgjXLZVY55H1eF5ejf6KabQitr 36J+tMIYdmwjVo+lEPksZINurU9LDHRUcJWmhf2MeX7KT4XsxIXeIRhNe mDY0WOV+5jLM8MvXL+5KPDPUY+Cf0EtVcoYavbhcdZRsK8/jzAyuBFTsM RH0EMSz8W1IX/tei86EQ4igzwv/JPC0lcp6gc3EYHpNh1Agn+dfZiLX9c lUB0z/B/I21pwUgRiteTigcmKP0Ms4lYnEPHow6915ZIYE68W1qSQtIsn A==; X-IronPort-AV: E=McAfee;i="6600,9927,10862"; a="385012422" X-IronPort-AV: E=Sophos;i="6.03,222,1694761200"; d="scan'208";a="385012422" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Oct 2023 05:48:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10862"; a="820620478" X-IronPort-AV: E=Sophos;i="6.03,222,1694761200"; d="scan'208";a="820620478" Received: from blu2-mobl.ccr.corp.intel.com (HELO [10.249.170.232]) ([10.249.170.232]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Oct 2023 05:48:22 -0700 Message-ID: Date: Fri, 13 Oct 2023 20:48:19 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Cc: baolu.lu@linux.intel.com, "cohuck@redhat.com" , "eric.auger@redhat.com" , "nicolinc@nvidia.com" , "kvm@vger.kernel.org" , "mjrosato@linux.ibm.com" , "chao.p.peng@linux.intel.com" , "yi.y.sun@linux.intel.com" , "peterx@redhat.com" , "jasowang@redhat.com" , "shameerali.kolothum.thodi@huawei.com" , "lulu@redhat.com" , "suravee.suthikulpanit@amd.com" , "iommu@lists.linux.dev" , "linux-kernel@vger.kernel.org" , "linux-kselftest@vger.kernel.org" , "Duan, Zhenzhong" , "Martins, Joao" , Jacob Pan Subject: Re: [PATCH v5 04/11] iommu/vt-d: Add helper to setup pasid nested translation To: Yi Liu , "Tian, Kevin" , "joro@8bytes.org" , "alex.williamson@redhat.com" , "jgg@nvidia.com" , "robin.murphy@arm.com" References: <20230921075431.125239-1-yi.l.liu@intel.com> <20230921075431.125239-5-yi.l.liu@intel.com> <8974035d-9f9c-e209-79d6-8e3c6402e516@intel.com> Content-Language: en-US From: Baolu Lu In-Reply-To: <8974035d-9f9c-e209-79d6-8e3c6402e516@intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.1 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Fri, 13 Oct 2023 05:48:46 -0700 (PDT) On 2023/10/13 20:40, Yi Liu wrote: >> >>> +        return -EINVAL; >>> +    } >>> + >>> +    if ((s1_cfg->flags & IOMMU_VTD_S1_SRE) && !ecap_srs(iommu- >>>> ecap)) { >>> +        pr_err_ratelimited("No supervisor request support on %s\n", >>> +                   iommu->name); >>> +        return -EINVAL; >>> +    } >>> + >>> +    if ((s1_cfg->flags & IOMMU_VTD_S1_EAFE) && !ecap_eafs(iommu- >>>> ecap)) { >>> +        pr_err_ratelimited("No extended access flag support >>> on %s\n", >>> +                   iommu->name); >>> +        return -EINVAL; >>> +    } >>> + >>> +    spin_lock(&iommu->lock); >>> +    pte = intel_pasid_get_entry(dev, pasid); >>> +    if (!pte) { >>> +        spin_unlock(&iommu->lock); >>> +        return -ENODEV; >>> +    } >>> +    if (pasid_pte_is_present(pte)) { >>> +        spin_unlock(&iommu->lock); >>> +        return -EBUSY; >>> +    } >>> + >>> +    pasid_clear_entry(pte); >>> + >>> +    if (s1_cfg->addr_width == ADDR_WIDTH_5LEVEL) >>> +        pasid_set_flpm(pte, 1); >>> + >>> +    pasid_set_flptr(pte, (uintptr_t)s1_gpgd); >>> + >>> +    if (s1_cfg->flags & IOMMU_VTD_S1_SRE) { >>> +        pasid_set_sre(pte); >>> +        if (s1_cfg->flags & IOMMU_VTD_S1_WPE) >>> +            pasid_set_wpe(pte); >>> +    } >>> + >>> +    if (s1_cfg->flags & IOMMU_VTD_S1_EAFE) >>> +        pasid_set_eafe(pte); >>> + >>> +    if (s2_domain->force_snooping) >>> +        pasid_set_pgsnp(pte); >>> + >>> +    pasid_set_slptr(pte, virt_to_phys(pgd)); >>> +    pasid_set_fault_enable(pte); >>> +    pasid_set_domain_id(pte, did); >>> +    pasid_set_address_width(pte, s2_domain->agaw); >>> +    pasid_set_page_snoop(pte, !!ecap_smpwc(iommu->ecap)); >>> +    pasid_set_translation_type(pte, PASID_ENTRY_PGTT_NESTED); >>> +    pasid_set_present(pte); >>> +    spin_unlock(&iommu->lock); >> >> All changes within iommu->lock are specific to the device specific >> PASID entry. Probably this is one potential cleanup TODO to >> use a per-device lock instead. > > yeah, a separate cleanup. is it, @Baolu? Sure. I'd like to take some time to consider this further. Please keep it as-is for the time being. Best regards, baolu