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 X-Spam-Level: X-Spam-Status: No, score=-15.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_2 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3C186C433E0 for ; Mon, 22 Feb 2021 18:01:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F334D64D9C for ; Mon, 22 Feb 2021 18:01:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230515AbhBVSB1 (ORCPT ); Mon, 22 Feb 2021 13:01:27 -0500 Received: from mga06.intel.com ([134.134.136.31]:4652 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231936AbhBVSAQ (ORCPT ); Mon, 22 Feb 2021 13:00:16 -0500 IronPort-SDR: P1ztj35Hud7HIUErJQ9wcUp1xZO/wkjTj840sZ7vNuFDDrSOZ+QP7LzqU8S4ogcfUwHH8HB5xK KLMuGGYryd7g== X-IronPort-AV: E=McAfee;i="6000,8403,9903"; a="245958041" X-IronPort-AV: E=Sophos;i="5.81,197,1610438400"; d="scan'208";a="245958041" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Feb 2021 09:58:30 -0800 IronPort-SDR: IA7AY8wsZOxpoKUHheB4xcj/giQmReA+JZG0euxu7ms2z7uPEeoGak2bviLbsthLmeu3gP6qzR znzSJYah6wwQ== X-IronPort-AV: E=Sophos;i="5.81,197,1610438400"; d="scan'208";a="432171493" Received: from jacob-builder.jf.intel.com (HELO jacob-builder) ([10.7.199.155]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Feb 2021 09:58:29 -0800 Date: Mon, 22 Feb 2021 10:01:06 -0800 From: Jacob Pan To: "Tian, Kevin" Cc: LKML , "iommu@lists.linux-foundation.org" , Joerg Roedel , Lu Baolu , "Liu, Yi L" , "Raj, Ashok" , "Wu, Hao" , "Sun, Yi Y" , "Jiang, Dave" , Eric Auger , Jean-Philippe Brucker , "Kumar, Sanjay K" , jacob.jun.pan@linux.intel.com Subject: Re: [PATCH 2/4] iommu/vt-d: Enable write protect propagation from guest Message-ID: <20210222100106.0ae8380e@jacob-builder> In-Reply-To: References: <1613683878-89946-1-git-send-email-jacob.jun.pan@linux.intel.com> <1613683878-89946-3-git-send-email-jacob.jun.pan@linux.intel.com> <20210219090841.4ae6f01c@jacob-builder> Organization: OTC X-Mailer: Claws Mail 3.17.5 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Kevin, On Sat, 20 Feb 2021 02:38:02 +0000, "Tian, Kevin" wrote: > > From: Jacob Pan > > Sent: Saturday, February 20, 2021 1:09 AM > > > > Hi Kevin, > > > > On Fri, 19 Feb 2021 06:19:04 +0000, "Tian, Kevin" > > wrote: > > > > > > From: Jacob Pan > > > > Sent: Friday, February 19, 2021 5:31 AM > > > > > > > > Write protect bit, when set, inhibits supervisor writes to the > > > > read-only pages. In guest supervisor shared virtual addressing > > > > (SVA), write-protect should be honored upon guest bind supervisor > > > > PASID request. > > > > > > > > This patch extends the VT-d portion of the IOMMU UAPI to include WP > > > > bit. WPE bit of the supervisor PASID entry will be set to match > > > > CPU CR0.WP bit. > > > > > > > > Signed-off-by: Sanjay Kumar > > > > Signed-off-by: Jacob Pan > > > > --- > > > > drivers/iommu/intel/pasid.c | 5 +++++ > > > > include/uapi/linux/iommu.h | 3 ++- > > > > 2 files changed, 7 insertions(+), 1 deletion(-) > > > > > > > > diff --git a/drivers/iommu/intel/pasid.c > > > > b/drivers/iommu/intel/pasid.c index 0b7e0e726ade..c7a2ec930af4 > > > > 100644 --- a/drivers/iommu/intel/pasid.c > > > > +++ b/drivers/iommu/intel/pasid.c > > > > @@ -763,6 +763,11 @@ intel_pasid_setup_bind_data(struct > > intel_iommu > > > > *iommu, struct pasid_entry *pte, > > > > return -EINVAL; > > > > } > > > > pasid_set_sre(pte); > > > > + /* Enable write protect WP if guest requested */ > > > > + if (pasid_data->flags & IOMMU_SVA_VTD_GPASID_WPE) { > > > > + if (pasid_enable_wpe(pte)) > > > > + return -EINVAL; > > > > > > We should call pasid_set_wpe directly, as this binding is about guest > > > page table and suppose the guest has done whatever check required > > > (e.g. gcr0.wp) before setting this bit. pasid_enable_wpe has an > > > additional check on host cr0.wp thus is logically incorrect here. > > > > > If the host CPU does not support WP, can guest VCPU still support WP? If > > so, I agree. > > > > If you change 'support' to 'enable', then the answer is yes. I agree, thanks for explaining. Will change it to pasid_set_wpe. Thanks, Jacob