Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp499763pxk; Fri, 11 Sep 2020 12:30:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwt+mG6+k9zzkl3aXBbFpSqW1L7wjfytilIROEt6QFbrNdjC29XgHaw55zsHMcbDyMrg6HJ X-Received: by 2002:a05:6402:445:: with SMTP id p5mr4072350edw.214.1599852659470; Fri, 11 Sep 2020 12:30:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599852659; cv=none; d=google.com; s=arc-20160816; b=ZKEmZ9lx1GT/5Y22jP5RmKVKyd+O2NsdW2BHJkWId3WTpoUA2YuqHoBLX7FZZgk57J 8KU2wA+2Tps+BNZ/FtRd9NqYPHnoe5n8noDcM7oaqmDNyKUJRl6zFfFThGFEitk19cwc pqgNPTwQNlnCMWVNCOJiujmU1Pb+Bs4VNwTslx3hhX9pIS/3P4Y6HgGvEnTZj5nmoQxc 7da3gGBWmz/FO6f1HqjJUURBe68Om43v44U38Scy/fBvW7rJCR6B42q2YcL21zZz+uQ+ 1k+7EdvZXf/2/Ewy9dhcWa4TCDU00PQEqp3SzW4daPIG3z98JjI1LrgHXHZetnx4ztj5 /BrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=fKzBLDraksrNeRPLk5jL1S3AX8FuSiY0yRsH87cl0To=; b=eRVEo9apD6Qsmin3mNpjSJMRgQDev3QtFGrlXkG5oLp6Dwu9fbtHK5kmLVjOO7n5Ky 4wywg58qBvq82huE1IfW4IfRIOa1KwVlFh9q300NKWaB/9YV1Cj7zwCrIZowZczGgjgX 0qX9HJb4pLnKgZ+TYfdMm1OVCWy3f8819pIyl5wDZSlmO90r3zxfEhshhND9BRKFbelo tjm17JMUljdToZB7XOiYiK651GvtqF299SvDOgQyO1eFnUnEZXnwc6D1Ngae0Ilz7voD UyeImKbenvpPuhzb43F2A0GgiRsxiBONzoL+ViPAN/IFK/xdOuoshQo0xbQVMl1yaiFp E2WQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b="Wr/PgsXY"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cw15si1963233edb.299.2020.09.11.12.30.35; Fri, 11 Sep 2020 12:30:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b="Wr/PgsXY"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725813AbgIKT24 (ORCPT + 99 others); Fri, 11 Sep 2020 15:28:56 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:33446 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725816AbgIKT2K (ORCPT ); Fri, 11 Sep 2020 15:28:10 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 08BJPOAA097013; Fri, 11 Sep 2020 19:26:32 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2020-01-29; bh=fKzBLDraksrNeRPLk5jL1S3AX8FuSiY0yRsH87cl0To=; b=Wr/PgsXYMa7GcOxZ/ziXuoyL6FgUQ6Od6ckgbYjwzK1UqmFelL2usvcsKR3DXW6IcpGE l+JnvEDL/II23kxU9Y6w4pdYAMQ22fFuxiAikDHiN7t4EGZ86BNK3bSwpfspvYNYpj+c zipAT+yUUrF8p7dTWJzIMlY9tnk3n2ywvdDO16VOcZgHaidlzI/+xQI1Z15Nw/rPlsVs 1+PoF2BLFGN7EcW9A006/z+cWGsajkB/Sx/9rNQJgNH+eCeQFTUL8XpVzTSOMrDB6kvb Z929Vbrdqq096ir203uZscwNOHtlyxdZCdWCSGg6oG8fTsubw92QS8KjfCpt3iyU19Ok WQ== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 33c23rg5a9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 11 Sep 2020 19:26:32 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 08BJPcR4076210; Fri, 11 Sep 2020 19:26:31 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3020.oracle.com with ESMTP id 33cmexqp5k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 11 Sep 2020 19:26:31 +0000 Received: from abhmp0002.oracle.com (abhmp0002.oracle.com [141.146.116.8]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 08BJQQTf031308; Fri, 11 Sep 2020 19:26:26 GMT Received: from nsvm-sadhukhan-1.osdevelopmeniad.oraclevcn.com (/100.100.230.216) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 11 Sep 2020 12:26:26 -0700 From: Krish Sadhukhan To: kvm@vger.kernel.org Cc: pbonzini@redhat.com, jmattson@google.com, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, x86@kernel.org, sean.j.christopherson@intel.com, vkuznets@redhat.com, wanpengli@tencent.com, joro@8bytes.org, dave.hansen@linux.intel.com, luto@kernel.org, peterz@infradead.org, linux-kernel@vger.kernel.org, hpa@zytor.com Subject: [PATCH 3/4 v3] x86: AMD: Don't flush cache if hardware enforces cache coherency across encryption domnains Date: Fri, 11 Sep 2020 19:26:00 +0000 Message-Id: <20200911192601.9591-4-krish.sadhukhan@oracle.com> X-Mailer: git-send-email 2.18.4 In-Reply-To: <20200911192601.9591-1-krish.sadhukhan@oracle.com> References: <20200911192601.9591-1-krish.sadhukhan@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9741 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 suspectscore=1 adultscore=0 bulkscore=0 phishscore=0 malwarescore=0 mlxlogscore=999 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2009110155 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9741 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 priorityscore=1501 mlxlogscore=999 mlxscore=0 bulkscore=0 suspectscore=1 spamscore=0 malwarescore=0 phishscore=0 lowpriorityscore=0 clxscore=1011 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2009110155 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In some hardware implementations, coherency between the encrypted and unencrypted mappings of the same physical page is enforced. In such a system, it is not required for software to flush the page from all CPU caches in the system prior to changing the value of the C-bit for the page. Suggested-by: Tom Lendacky Signed-off-by: Krish Sadhukhan --- arch/x86/mm/pat/set_memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/mm/pat/set_memory.c b/arch/x86/mm/pat/set_memory.c index d1b2a889f035..78d5511c5edd 100644 --- a/arch/x86/mm/pat/set_memory.c +++ b/arch/x86/mm/pat/set_memory.c @@ -1999,7 +1999,7 @@ static int __set_memory_enc_dec(unsigned long addr, int numpages, bool enc) /* * Before changing the encryption attribute, we need to flush caches. */ - cpa_flush(&cpa, 1); + cpa_flush(&cpa, !this_cpu_has(X86_FEATURE_HW_CACHE_COHERENCY)); ret = __change_page_attr_set_clr(&cpa, 1); -- 2.18.4