Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp719774pxk; Thu, 17 Sep 2020 14:26:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyfg0KtNuqDgNGLqM1YACwKdZSgdJwbA4OFf5CdBpjH0aRC++xzAx60oOPgYyqgu5JBY0Xu X-Received: by 2002:a17:906:b7c1:: with SMTP id fy1mr32130767ejb.342.1600377996289; Thu, 17 Sep 2020 14:26:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600377996; cv=none; d=google.com; s=arc-20160816; b=IUdCiCg8XEojlrUi7/GLuVOdRfZGwVuy3k1I3MGUe8VR0xuuSF++l/kJ4+Oew3i7sK fIWpaNLZrPAkKR/nNxXNqbONjtL4R5AQXgZnqdLtVrOZ80aC64+5rNkEczAV+Fay8yr/ qDPluelB86Hh92PQzQtAz7Nuvw83Vq7tdfVNOt5N+uqsZxiWXhN7Co0tmqprsd5Hjf3T W9zswEB303Ba2x4IY8Nx2PaXYlUpfafC2d0bpeCGeQ6hU+2a9VULfIkG7P6ShJfzym58 nPqkXP7hE3Ky/cFCbD87RSF2ppNDGTOuIfmj5H2k8bgVcSsvgFtY107IIRAZ1qNCAFuo 5mJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=B/v9vNu+zU6hIEta/+tlEpVzUgGI6GPuyCPAg06RhJo=; b=IUkhJDA+eY/67plli3BQDwNy8omsG2GcFTFgE8oxKItj4r9eY69yhPLvZnh7C8WcOP S/cnDT+9dPh62LJFIQ0Nux+qw3thslNDVsGZuK2eLCWj5BeIkWTFOpeYjtWai/m04THS 9ccYeDrfsnKPapbHuwT3lXdnmFmDMWVpqe/TOcMzAYW1AdDlEWV54dA5ly0x1iX0Y0d1 8iPY3sOSysGdsdbpbjI6vGtVdEdyUPCwrRgmPqHuu5PWIHPchd/DLKhdJUs8xyOkMG9g LywefPu7An42XS39fY1NTlM2uMwK42e0g5p5ZnSoFYg4K/BQ2PDkEwWTrYegJwzaO6Fd gl2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=wEOcQdQM; 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 z3si693338edp.549.2020.09.17.14.26.12; Thu, 17 Sep 2020 14:26:36 -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=wEOcQdQM; 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 S1726174AbgIQVZM (ORCPT + 99 others); Thu, 17 Sep 2020 17:25:12 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:33292 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725858AbgIQVZI (ORCPT ); Thu, 17 Sep 2020 17:25:08 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 08HLFAlw012593; Thu, 17 Sep 2020 21:22: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=B/v9vNu+zU6hIEta/+tlEpVzUgGI6GPuyCPAg06RhJo=; b=wEOcQdQMpiA5HJh4e9nSiEyW9Xbz8aUc/5qXRsO7PxQ0mvqLRC7D0CWgZ8DLYKWnSyPw dYwCXhAN9AWLGlBRsiWJpz/EMD426iAUjv+hB0FOySuzjXcXkTytL6Y89W33BYbOt5MS uWt1s2uqnzyOzln5nsJd/6s88QQFDqwPhechW8tyZ+Z9/CUQnti8b+hkQbT7KtgZ8fE8 /s5GKMH5QyMVnhxXgiYZofxHUIx5e3ZcatXfCczxerR2dBPR6VuRDXbp8zDkbJ4UP+6r Hhq+gduGwcwCwQMIODaPnPYGumyTuxnJNEDap4dQgYQT122QwZaN0yzsYiEgQ0RqzhLC AQ== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 33gp9mku7f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 17 Sep 2020 21:22:32 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 08HLBYGZ124386; Thu, 17 Sep 2020 21:22:32 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3020.oracle.com with ESMTP id 33h88cge5c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 17 Sep 2020 21:22:31 +0000 Received: from abhmp0013.oracle.com (abhmp0013.oracle.com [141.146.116.19]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 08HLMQDA029051; Thu, 17 Sep 2020 21:22:26 GMT Received: from nsvm-sadhukhan-1.osdevelopmeniad.oraclevcn.com (/100.100.230.216) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 17 Sep 2020 21:22:26 +0000 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 1/3 v4] x86: AMD: Add hardware-enforced cache coherency as a CPUID feature Date: Thu, 17 Sep 2020 21:20:36 +0000 Message-Id: <20200917212038.5090-2-krish.sadhukhan@oracle.com> X-Mailer: git-send-email 2.18.4 In-Reply-To: <20200917212038.5090-1-krish.sadhukhan@oracle.com> References: <20200917212038.5090-1-krish.sadhukhan@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9747 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 spamscore=0 adultscore=0 suspectscore=1 phishscore=0 malwarescore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2009170158 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9747 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxlogscore=999 adultscore=0 malwarescore=0 clxscore=1015 lowpriorityscore=0 phishscore=0 spamscore=0 priorityscore=1501 suspectscore=1 impostorscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2009170158 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 a page. This hardware- enforced cache coherency is indicated by EAX[10] in CPUID leaf 0x8000001f. Suggested-by: Tom Lendacky Signed-off-by: Krish Sadhukhan --- arch/x86/include/asm/cpufeatures.h | 1 + arch/x86/kernel/cpu/scattered.c | 1 + 2 files changed, 2 insertions(+) diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h index 2901d5df4366..c3fada5f5f71 100644 --- a/arch/x86/include/asm/cpufeatures.h +++ b/arch/x86/include/asm/cpufeatures.h @@ -288,6 +288,7 @@ #define X86_FEATURE_FENCE_SWAPGS_USER (11*32+ 4) /* "" LFENCE in user entry SWAPGS path */ #define X86_FEATURE_FENCE_SWAPGS_KERNEL (11*32+ 5) /* "" LFENCE in kernel entry SWAPGS path */ #define X86_FEATURE_SPLIT_LOCK_DETECT (11*32+ 6) /* #AC for split lock */ +#define X86_FEATURE_SME_COHERENT (11*32+ 7) /* "" AMD hardware-enforced cache coherency */ /* Intel-defined CPU features, CPUID level 0x00000007:1 (EAX), word 12 */ #define X86_FEATURE_AVX512_BF16 (12*32+ 5) /* AVX512 BFLOAT16 instructions */ diff --git a/arch/x86/kernel/cpu/scattered.c b/arch/x86/kernel/cpu/scattered.c index 62b137c3c97a..0bc2668f22e6 100644 --- a/arch/x86/kernel/cpu/scattered.c +++ b/arch/x86/kernel/cpu/scattered.c @@ -41,6 +41,7 @@ static const struct cpuid_bit cpuid_bits[] = { { X86_FEATURE_MBA, CPUID_EBX, 6, 0x80000008, 0 }, { X86_FEATURE_SME, CPUID_EAX, 0, 0x8000001f, 0 }, { X86_FEATURE_SEV, CPUID_EAX, 1, 0x8000001f, 0 }, + { X86_FEATURE_SME_COHERENT, CPUID_EAX, 10, 0x8000001f, 0 }, { 0, 0, 0, 0, 0 } }; -- 2.18.4