From patchwork Fri Mar 11 11:29:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liam Merwick X-Patchwork-Id: 12777842 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 13C2EC433EF for ; Fri, 11 Mar 2022 11:32:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348287AbiCKLdP (ORCPT ); Fri, 11 Mar 2022 06:33:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348325AbiCKLdD (ORCPT ); Fri, 11 Mar 2022 06:33:03 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 116B81BA92B; Fri, 11 Mar 2022 03:32:01 -0800 (PST) Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 22BBMdpI021579; Fri, 11 Mar 2022 11:31:50 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 : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=jGh3T08BL2GYr2Jq3f90LU8od4bn89nJ7x5uOee7WYU=; b=Tamt5GH6NK+nJVsLPY6AZqwC98M/ukwUOPDck7MJOiYQnNzEZCFZeW8DY616GjSLXkki lZnpKY+IuhzrPo49Jd5loTTu+K7n1oB53+FS2z6QEHTXt64FfxcnOov16gfsoZkp1tRj hOa1s5XKnpuM4jXW8iqr80cl3fQMbNFYX4+ONhyWekA4KJ2tRUpDrV0CpEfAhaM29y+R 0iz90XdiFA1eENYK36XObb7E0Eb3H1L1cq6/LtKImMOruhUdqz52IG+OBuyibD1CvBi8 tPoi0MV51Zpa73LzP2U4egjE0zCQGGxRQFhGTk64csSzvaQIFoFzTxkeV6RiASHpNzfn DQ== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 3ekyfsrveq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 11 Mar 2022 11:31:39 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 22BBFjPk137782; Fri, 11 Mar 2022 11:30:17 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2105.outbound.protection.outlook.com [104.47.70.105]) by aserp3030.oracle.com with ESMTP id 3ekwwe27u5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 11 Mar 2022 11:30:17 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GnGtS+5OHIeXMpK0hQ1gyOkMer+WDseWE3XawpzjBWew7HN9p3tdmNBhrJ2MxAjslAh5XI3o0P90Qp7RZJPFmJbt+VzoZAr4LtnyeA9CqwXKBCXtfA4l2QUyYHiI3iFVowRJiMjl7d7U5ODrmyPC06AXUDAfzKzHWmOXXQ+ldURrP/IaTorLjodMRxv3boLcNedbX5Bs0STtTmScNTnTevEn1w9kjup6nn39k0OUXJ5w72An2HqPB4RCDOz0H8/GpW6LAv01W0WF6LT7trWI54aX/+d83MG+5hs69XvLXbCwxVTbHjACqhvDnWAIqan6uFkIW8C//+IuHLf4SOqLSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=jGh3T08BL2GYr2Jq3f90LU8od4bn89nJ7x5uOee7WYU=; b=MbyEFycf54++Vp2q9y4TceVKBYS2kNZPob8JE1L/YPKXa17NvUShFVuDkKJ4DqJSN3BOFsqMsCvW7V36hy6aOKzB+Mv5VhM4I1GMDE7Y+22PKzTTfTYXNSZPRLr0+Mofs3R8X9iNsEQPESGPFoKpVhftdSWwZCk/7sbgWabjBDV5PwYBklDlbwuDQ3RPSML5KakXzrzncEVFX1ZJqVRCAOIBPTt5txwHuzkLIR0kjhAEC+5qChfiqhNIUPndnEczdNYSH+552kC/uXSsxBFPpXU0T15cch+1vD3TmAtPajz0DlFYFfAP6a7V/9FON8Ll5Fs7DzXzM7cUdwWXAj4uyw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jGh3T08BL2GYr2Jq3f90LU8od4bn89nJ7x5uOee7WYU=; b=pxanBjmyQGvq3wfADuYTbl3SKcM3NlmuvstTAeCRA95xcCk6Rrqz9589+SzhE1R+qefzpq0wVrHO2ehX9QsUnKSaBN0lWpKixEHnVPmX2/BuKhuPUS0X8wsRZZ1sbOn4c5yXg17y3eUaMQZYgCwta2G8VBOwWJbkcuPVNRckteU= Received: from BN0PR10MB5030.namprd10.prod.outlook.com (2603:10b6:408:12a::18) by CY4PR10MB1430.namprd10.prod.outlook.com (2603:10b6:903:26::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.17; Fri, 11 Mar 2022 11:30:14 +0000 Received: from BN0PR10MB5030.namprd10.prod.outlook.com ([fe80::b9d4:8912:7bf8:14fb]) by BN0PR10MB5030.namprd10.prod.outlook.com ([fe80::b9d4:8912:7bf8:14fb%9]) with mapi id 15.20.5061.022; Fri, 11 Mar 2022 11:30:14 +0000 From: Liam Merwick To: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, x86@kernel.org Cc: pbonzini@redhat.com, bp@alien8.de, thomas.lendacky@amd.com, brijesh.singh@amd.com, krish.sadhukhan@oracle.com, liam.merwick@oracle.com Subject: [PATCH 5.4 1/4] x86/cpufeatures: Mark two free bits in word 3 Date: Fri, 11 Mar 2022 11:29:24 +0000 Message-Id: <20220311112927.8400-2-liam.merwick@oracle.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220311112927.8400-1-liam.merwick@oracle.com> References: <20220311112927.8400-1-liam.merwick@oracle.com> X-ClientProxiedBy: LO4P265CA0088.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:2bc::7) To BN0PR10MB5030.namprd10.prod.outlook.com (2603:10b6:408:12a::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 94f1bed4-cd29-4751-6b14-08da0352828a X-MS-TrafficTypeDiagnostic: CY4PR10MB1430:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ay9HzOLa70v1LjU6UE6AdAhlfnkOtLmxtK4eOkPQUF/XCjfSLi7NcS/OmqaqCvq0o8gvlZ4zX3I34mLgDshbnS8icXW9c0OcJOeOyfc0lFfEUOjdTymKB+ufUi2rCYx58+njIFFXrs8szuNKAcoTCR2WJCe2eCEhb08VoyHyh/g1byGUxgrNP0+5t26pCTBcNN8yeLwqLR7qM4eyX6ha8v7vpo8gMYuaNhGWONg1xKhmUnUPyD5CmqWdeV7MDAInrlzv+sqh0gxB5F+HRycSAfhSyMNfF+fKzfQ5tQ+iVzguyLm8Dj12e3e5BYPAyMhnPpBpRvDZyBx/SH14GkXMqdFAM3PaGn4J6NpEx/tmCdPW+xCAQC1aTJTA0JOHy3++GT4dPEi7dPLA+kd7jQxEgauamDL07yAVi4qQ3qb5pYSblubS6+p3t8a0Pa75LsTI1M5WNv7a75wuWhXP/2BzkLVQ37NyNlz+IOaxPwZjqeKUth8UnSiiufF0nWKQt6fB4DHS7nBtNAEDCid5+pNIsvDyHg/dh22gq8hLXFRo62JOvmaF1akhVI4Pevs1o4+a51WU6Wfou4r0qLeVXYgNbfbFqxIOos5c7iPKOa160kMVimH9juZaYEpM3Ye5Qm4Gs3paA6DRjwqmWb58wFpHQ5u//TwmjVxxj7S9GLltPVUyiOmV6QXdIlIO9R4ppZWzHS8y6BvIb1a2ky++lxTMC8Oq62xmevzTpUMm0CEocYOHjaiKx0O69gdH4tTQTaRMmFPJQBmYGHMTMu7B49oYJoQou2oyXsAkGEk5TPD2YpE= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN0PR10MB5030.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(366004)(38100700002)(8936002)(4326008)(6666004)(5660300002)(8676002)(66556008)(66476007)(66946007)(508600001)(44832011)(316002)(52116002)(6512007)(6506007)(38350700002)(966005)(6486002)(107886003)(86362001)(1076003)(186003)(26005)(2616005)(36756003)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: iTATJ+Xbo7QxsvCf7AdPyfOFzTDY0cqosiHaoOBybsKug/do8mRlvSDOJBejv4q4nAGXXZayvqFyZoROqFAiJPTweA4bF37/O1mJbazwPJWcuTiNR0AER48d4Aty2WJ59Us0/OwxBj1TpXI1GFnW57ls5ZK7bdMGNGi4wmLSYYXF7eBtaRkrke5xzgvQos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glGxAWMPAE6CyTun38Qy5cBKk+FQHTQdl9tqVrrlTPw2mMN6K7rpLw7apxiaKWP/5aRu56TMXeyhBjpj3+WWq/4vWLjAVTWz1d7ojecDDFHZveOuC2KettzqDT7LOyMtQhubeJwsrmIz3QsMZewtBDoBZhBV3AhUxvJdr2wnniBdL9gb6bT/+PmfwCD4+KXUkVhYczyh/1rqEnPY12HoeKhQ8FPOSuoJp+66iKeu5BINguqxuTu/Fr+GoWWbbsS/7s9D8CIvCkaCYv9aKVyLcw9DNVKfwufLPYw+UU2HYsnx3a2e3xw8iHWp+Jw09l4oSSgXCF8jE8kyXtVmpiKrnUNf1zPgRPDP56aLMQ0zEsp+bzptc= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 94f1bed4-cd29-4751-6b14-08da0352828a X-MS-Exchange-CrossTenant-AuthSource: BN0PR10MB5030.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Mar 2022 11:30:14.0533 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: D+J3qDvK1v8SEJiHXtH7eoqvK8dj9j9ntTB9K+OAKzXPyeSHw1eoK4fYZF5qHnyp1cvSgq+bIghW2U4d7gW8PQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR10MB1430 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10282 signatures=692556 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 spamscore=0 phishscore=0 bulkscore=0 adultscore=0 malwarescore=0 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2203110055 X-Proofpoint-GUID: szE5niXkZZ3y3LaEGNjWf7zyVr1iH3k- X-Proofpoint-ORIG-GUID: szE5niXkZZ3y3LaEGNjWf7zyVr1iH3k- Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Borislav Petkov commit fbd5969d1ff2598143d6a6fbc9491a9e40ab9b82 upstream. ... so that they get reused when needed. No functional changes. Signed-off-by: Borislav Petkov Link: https://lkml.kernel.org/r/20200604104150.2056-1-bp@alien8.de Signed-off-by: Liam Merwick --- arch/x86/include/asm/cpufeatures.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h index d912457f56a7..c934eb807f23 100644 --- a/arch/x86/include/asm/cpufeatures.h +++ b/arch/x86/include/asm/cpufeatures.h @@ -96,6 +96,7 @@ #define X86_FEATURE_SYSCALL32 ( 3*32+14) /* "" syscall in IA32 userspace */ #define X86_FEATURE_SYSENTER32 ( 3*32+15) /* "" sysenter in IA32 userspace */ #define X86_FEATURE_REP_GOOD ( 3*32+16) /* REP microcode works well */ +/* free ( 3*32+17) */ #define X86_FEATURE_LFENCE_RDTSC ( 3*32+18) /* "" LFENCE synchronizes RDTSC */ #define X86_FEATURE_ACC_POWER ( 3*32+19) /* AMD Accumulated Power Mechanism */ #define X86_FEATURE_NOPL ( 3*32+20) /* The NOPL (0F 1F) instructions */ @@ -107,6 +108,7 @@ #define X86_FEATURE_EXTD_APICID ( 3*32+26) /* Extended APICID (8 bits) */ #define X86_FEATURE_AMD_DCM ( 3*32+27) /* AMD multi-node processor */ #define X86_FEATURE_APERFMPERF ( 3*32+28) /* P-State hardware coordination feedback capability (APERF/MPERF MSRs) */ +/* free ( 3*32+29) */ #define X86_FEATURE_NONSTOP_TSC_S3 ( 3*32+30) /* TSC doesn't stop in S3 state */ #define X86_FEATURE_TSC_KNOWN_FREQ ( 3*32+31) /* TSC has known frequency */ From patchwork Fri Mar 11 11:29:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liam Merwick X-Patchwork-Id: 12777840 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C37BFC433F5 for ; Fri, 11 Mar 2022 11:32:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348289AbiCKLdJ (ORCPT ); Fri, 11 Mar 2022 06:33:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348270AbiCKLcr (ORCPT ); Fri, 11 Mar 2022 06:32:47 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B637D1BA92B; Fri, 11 Mar 2022 03:31:44 -0800 (PST) Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 22BAUBfF024112; Fri, 11 Mar 2022 11:31: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 : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=PdeRqTN9bEB8sUwFM4WlvpqoMF2l9jn/jBUtww5Cw3A=; b=vcIZNs2rXSTf8tA8db21aT3L7FUh28qx5Go+JGHMx1ew2iIBryssBrWhSNa53It7BC63 7NHe24tznSVRZ07j6DpxvXOVCKtUpmMgnhORq+XDI3CsPCuJhqxzvx4NB6CkTowy+m63 Wk5EAXyCvUxLvppBcDIklJQXQFQjl3quRzk+Nfwq4hmkr8Azcs3jtuuBXkC3LBZc6aHm RnNGDEjTz9WbJ/zgEjclpZgieaig13CBs0QYJKXH/OpP86fYukb3UGGcbaFUlI90xHhI 7RIoagwxlJmFhXhou9TIHPnbcQxCmwImciSjh2J0te/893DENDQ1+Rf4NPqQzOxwjxm3 Cg== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 3ekx9crbg3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 11 Mar 2022 11:31:19 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 22BBFjPm137782; Fri, 11 Mar 2022 11:30:18 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2105.outbound.protection.outlook.com [104.47.70.105]) by aserp3030.oracle.com with ESMTP id 3ekwwe27u5-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 11 Mar 2022 11:30:18 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=E1aQoNv5h/s8C5kZ68v/eLQmM0/ScKji4OxC18J1+4MDTCnHr0SCZmZri8PDd3VUFXcz9Gzy6PbjYt2E7CPKJDyV0mbQmnzdnBciWbK72VFFP1ASKikVuzI8ozwYhotY636pVdys4RVjV2bw4V9GIfWvF6N3vBysyO4U6mI8xADKRLAwb9ZXabhY0rhqB/VhDOFVXAgiwHYbDlxM+8ZP7HVgBZfW4E+Ml1/ay/bNJErY45AO3/WZEBatM5o1FtjCFLkJDISdLz2NuAD0B/Yi84PkaEFXBIV0tWu6gf3bcSeaABS2T7eRZqP/ra+FjyIor0tL1aKsfFD9l84v+yXCSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=PdeRqTN9bEB8sUwFM4WlvpqoMF2l9jn/jBUtww5Cw3A=; b=ST8hzK0f27IlejGSvt3WcCKB9S7R94Iqqh1noRWs1vG2mFRTSbtxfuOEfs5G4aHheEOmDoP1lTe4MTo1+PGV0VqNnz/kB2Rde34EzVh7iA+yUB6+FbYIc9f7iK9BPiwgKWQoy1OXRM5+Khqsv9LoxSzPrB7b6jIiGe1+gaAbd0+tIU+lhOAbbOR83GaT8Js3ApXXkLWRlgLMK1kXRQSI6G8J+YunmQw5koNsNnrC1WCDAmjuLK/yv/cqDndFBdCjUt6h7TSfVJUyJvCqipsfHFbOu/XVytS856D6+2DtdhU7pNrTEmeeZ9tqj9XliajyjXHmvdQGe2EdNNrc8j9soA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PdeRqTN9bEB8sUwFM4WlvpqoMF2l9jn/jBUtww5Cw3A=; b=MLYhetOCZeXsOyVoi1sgHVJQN73S6pK1tRChPs30Mdcx71jHCjk3WfrmRC9cPifIrpiHluOAT2SBff+raQTlzmroDvhq+SWaMNZGsZ1HS/0y57AuZ/cIUMn0jG2Wgy9oJfMh6EwLjGcyUt72YtBCK0V4G5sOBp55soeWAOXUxjU= Received: from BN0PR10MB5030.namprd10.prod.outlook.com (2603:10b6:408:12a::18) by CY4PR10MB1430.namprd10.prod.outlook.com (2603:10b6:903:26::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.17; Fri, 11 Mar 2022 11:30:16 +0000 Received: from BN0PR10MB5030.namprd10.prod.outlook.com ([fe80::b9d4:8912:7bf8:14fb]) by BN0PR10MB5030.namprd10.prod.outlook.com ([fe80::b9d4:8912:7bf8:14fb%9]) with mapi id 15.20.5061.022; Fri, 11 Mar 2022 11:30:15 +0000 From: Liam Merwick To: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, x86@kernel.org Cc: pbonzini@redhat.com, bp@alien8.de, thomas.lendacky@amd.com, brijesh.singh@amd.com, krish.sadhukhan@oracle.com, liam.merwick@oracle.com Subject: [PATCH 5.4 2/4] x86/cpu: Add hardware-enforced cache coherency as a CPUID feature Date: Fri, 11 Mar 2022 11:29:25 +0000 Message-Id: <20220311112927.8400-3-liam.merwick@oracle.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220311112927.8400-1-liam.merwick@oracle.com> References: <20220311112927.8400-1-liam.merwick@oracle.com> X-ClientProxiedBy: LO4P265CA0088.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:2bc::7) To BN0PR10MB5030.namprd10.prod.outlook.com (2603:10b6:408:12a::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9ed07ef7-0584-488e-ece3-08da0352839e X-MS-TrafficTypeDiagnostic: CY4PR10MB1430:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +Px9Mp8SBH7NRztaSZ6YllpP7ao24CGqZu4vtZHScwsmGmWwDZrsHSr0/99J7KqegAr0erO9oLY2eZT/ak/h75vx+jr+TzoQW/RrirThA6pw1Tv5UH7c0q+5eujI2FtM0Pf7T/sMkbj9u5nYDQTmUuzOGsB5/SjdJup8aUDBNDswOMrcPrD+YV9vg/ZhDz5jK/eX29Kj7wUIEWFpe9hv6S2rRFfGVpAXH5k/0/iurX1dGyup2Vv7f20PKdNtg5noPHW4bow45FhGQYxzQDQ7ISgv3pWW5g0QbRcXXCXbwc+qWq5Tra5rNAgm6bmgau05878vNkNLZV+y9D0tOLW7ghcXUTqn4qUU6QL70CRNiIn+lKArqANV0xH7Zy4VDP9BGWSMHFLpT7Mhd+H7dGp3q8tD1hPSqnmi9CFq7l5CoL2cwtMTjXFhdLRsjjMGfDyk51zL5OmDjVcbaval7MdIUwR/v58VeRFE565HUv5jRw5PWy8TvsdQj/FGxgLSts2psVVbsYst419KaTLLBNCuFEEsV3+ARrnOWa65t1igrhPC56GhFj6UsS98KYl1jifSiGafvpyyvqoFaOTHTYJnHo+PPBSU9P0wJJepQvfISFjzFHpzwhcD8WJZhE/hOVSxkXzryt9cbFYj3IctFNGs2cuS9tptP6bCNH0PzRuBSOKf0rtKFsj6rXQZp1YYjSHt858bRnKOUU8rVUw/0iFqwVSJEJGhlsYpCmjIOFbcG4qch5uZgg1qhujJmdLC0ovCk/hV3XKRtOBIfarRtfc1fk4fOzJZDT/Vxl/Mlwhg+Gg= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN0PR10MB5030.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(366004)(38100700002)(8936002)(4326008)(6666004)(5660300002)(8676002)(66556008)(66476007)(66946007)(508600001)(44832011)(316002)(52116002)(6512007)(6506007)(38350700002)(966005)(6486002)(107886003)(86362001)(1076003)(186003)(26005)(2616005)(36756003)(83380400001)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Za7NjJxkq7fsGwmBaK8wH3cmpzkQOohIBbuNHFcpQMoOcHRCSHeupskEoKeN8Ib7YS98dxCWkcKOveVQE5JAsShPtryZHMJd2avL1m2SxoNdNkjjeTXXy14kShcyh+Ka+ycL/HfyLfAod5WA6BSPvc1D2z87pooWcIFkJJoWYKeJ9fZc+YvZT1sJI7I8f0cz/eW3/ziQzJHzD0DdJLufi8ZFXhjQ3e43kw+dV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bnm6mgEfnBKoRHukLcs8e8dk1ZEwUPlBCCr2Uaf6dLWHUR5H68pMFBLl0PMnT2EJW/3s2FY/wwXwnVNxcu1kVO6FhHNe0bePpFWzvcjUn2CD+OxksVk2qwFN7QFnryMiUrwPBQFqRVZRPFSmLpw/3GE2M/tbWUtjHDWWn3itG3TphDYBbqHYgC5Rr3oQZ1OK9zN7B9Tpzo7XLIh6L1e/CXLuM7pLkOLz4v5SYBKARp6rWkIFiG1VR13fUvKiBvm5wMZhGYKlxivsR0J0STvH6FmS20WJUOhVQeMArFjCb7NES+iYZppangbjpy66wKiabdG+pNs6JhOynI= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9ed07ef7-0584-488e-ece3-08da0352839e X-MS-Exchange-CrossTenant-AuthSource: BN0PR10MB5030.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Mar 2022 11:30:15.8653 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: HcX7IYCNzZ8wCdSzZYPzz+hBitj3ZKi1UX4B5e8RSzrKL+IZnu+oSYqCRzTcjkaMTo8d6ype1Srid1ghVQD51A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR10MB1430 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10282 signatures=692556 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 spamscore=0 phishscore=0 bulkscore=0 adultscore=0 malwarescore=0 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2203110055 X-Proofpoint-ORIG-GUID: ROEi2xeJUoUrtr4KeeHf51EPsjjHzUuJ X-Proofpoint-GUID: ROEi2xeJUoUrtr4KeeHf51EPsjjHzUuJ Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Krish Sadhukhan commit 5866e9205b47a983a77ebc8654949f696342f2ab upstream. 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. [ bp: Use one of the free slots in word 3. ] Suggested-by: Tom Lendacky Signed-off-by: Krish Sadhukhan Signed-off-by: Borislav Petkov Link: https://lkml.kernel.org/r/20200917212038.5090-2-krish.sadhukhan@oracle.com Signed-off-by: Liam Merwick --- arch/x86/include/asm/cpufeatures.h | 2 +- arch/x86/kernel/cpu/scattered.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h index c934eb807f23..4705533eb88d 100644 --- a/arch/x86/include/asm/cpufeatures.h +++ b/arch/x86/include/asm/cpufeatures.h @@ -96,7 +96,7 @@ #define X86_FEATURE_SYSCALL32 ( 3*32+14) /* "" syscall in IA32 userspace */ #define X86_FEATURE_SYSENTER32 ( 3*32+15) /* "" sysenter in IA32 userspace */ #define X86_FEATURE_REP_GOOD ( 3*32+16) /* REP microcode works well */ -/* free ( 3*32+17) */ +#define X86_FEATURE_SME_COHERENT ( 3*32+17) /* "" AMD hardware-enforced cache coherency */ #define X86_FEATURE_LFENCE_RDTSC ( 3*32+18) /* "" LFENCE synchronizes RDTSC */ #define X86_FEATURE_ACC_POWER ( 3*32+19) /* AMD Accumulated Power Mechanism */ #define X86_FEATURE_NOPL ( 3*32+20) /* The NOPL (0F 1F) instructions */ diff --git a/arch/x86/kernel/cpu/scattered.c b/arch/x86/kernel/cpu/scattered.c index adf9b71386ef..53004dbd55c4 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 } }; From patchwork Fri Mar 11 11:29:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liam Merwick X-Patchwork-Id: 12777841 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6BBC2C433FE for ; Fri, 11 Mar 2022 11:32:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348342AbiCKLdM (ORCPT ); Fri, 11 Mar 2022 06:33:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348282AbiCKLcx (ORCPT ); Fri, 11 Mar 2022 06:32:53 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5DABE1BA92B; Fri, 11 Mar 2022 03:31:50 -0800 (PST) Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 22BAUeRS026237; Fri, 11 Mar 2022 11:31:36 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 : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=l9usY8zpgsndqi++rsG7DhqyaCrOyDcGgXp3J38awkg=; b=t4Jio8I/amkNTHkKMcecoRqATFYKmS2V0qmnfKWj7FmLn0sbjDGyfXfCu+E/JfQJlp80 ICiZhJhzpn+8vF3R7HEitYLGMRsc/iIdaaW5xi/VXcXhBuigvD4OiGsg8x/vWC9q8gaj fhl5FMPpACkO8mcWcR0gDPmYBjMWQ5DtS/iSmXboTemiDwQgblN8wY1TKsCWUHd8vPgv pZOTFmIbttgCOcT5YmenXwch82zznbBG67zZ5LD0L/mbDXVfNshaXJ9Hj1VfQWsEU3lz TN4hy4jNT8EVAnX3+cThQTi184rS9Oauweh5YYLFUHcw4yV1NjL9FwDnqjPk2clbWO3C eg== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3ekyfsrvfa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 11 Mar 2022 11:31:28 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 22BBHEhb192256; Fri, 11 Mar 2022 11:30:20 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2107.outbound.protection.outlook.com [104.47.70.107]) by userp3020.oracle.com with ESMTP id 3envvp36tu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 11 Mar 2022 11:30:20 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PJPUGRixPCjWmS5dFS/HdVb6pW+VQLB6C6rx6o8eM/ht0aDuEZJxwCuopPVa8yjG21ZceCo193YrcravcPZFO7jmukJSwBHdM5jZNOAfKF6kMAZ4H2EP9Ktq1eFienmurocoDMGV4Xxcqkv8zI+uz0QuhaZLyLHDw8QS62Vy4uQJGqO7WbqzR7SBWdeXeDSdPmP8DdJDcCveMY5qo2lfD5NJmPnJuvJ2cWWk8fL0lj7hf+j1x++vrbJsT/hmy5WXaUrEmqOELlxfaJm8gN1lqbV7Q7YuhRQqutrS1QI8RJSLhYr4c0A4wz3VC8ENVfMkvOA8rxDmqtB4s7Hy3OsSnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=l9usY8zpgsndqi++rsG7DhqyaCrOyDcGgXp3J38awkg=; b=kgr2YLL6y/XgvEjoAACxR35kRWkprqYxStbm1Rw9H9/QWqvZYbCZ2uVJO/2Pjbc30bRU2f7TDXt2GOAol4O5d4OnHvA4TIIrgjKCsPundaPjV+cpAz2ihj5lHICiol1O2XRUtkQfHl+oKc3647r0NMkNYr1WtQlymnji3N/shwKw0B3AuyjAF9K2RwMUkTH4KX9nnDAaLZaDR2rdnPe5ytnNCNU2LiclgKaTqx2tv3U9Po5KWUbMf6+iBnRLNhDljN+BatQ66+5JXrX1rOS8qv99kVUgLqeJFnH+BfKA9K0PjVHSWIWFmI5735pz2s4610UP9AahfXjcF0OLJONafw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=l9usY8zpgsndqi++rsG7DhqyaCrOyDcGgXp3J38awkg=; b=K/yGOpYSNJYroOp3LT88Lx+TBFT4XHxU8lazB7S9eIQxN9lUhoqxq1Tvvo4BYU/jE0pR0sgMHQurn4Iqzdrm5U/zquPpRASyRffoKosn8pt5iSaLnrF1IN66ImDwKpueF2SUSP4KowWD4nyv5jTBgOUJHQ252HTeJ9HgW30xH6w= Received: from BN0PR10MB5030.namprd10.prod.outlook.com (2603:10b6:408:12a::18) by CY4PR10MB1430.namprd10.prod.outlook.com (2603:10b6:903:26::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.17; Fri, 11 Mar 2022 11:30:17 +0000 Received: from BN0PR10MB5030.namprd10.prod.outlook.com ([fe80::b9d4:8912:7bf8:14fb]) by BN0PR10MB5030.namprd10.prod.outlook.com ([fe80::b9d4:8912:7bf8:14fb%9]) with mapi id 15.20.5061.022; Fri, 11 Mar 2022 11:30:17 +0000 From: Liam Merwick To: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, x86@kernel.org Cc: pbonzini@redhat.com, bp@alien8.de, thomas.lendacky@amd.com, brijesh.singh@amd.com, krish.sadhukhan@oracle.com, liam.merwick@oracle.com Subject: [PATCH 5.4 3/4] x86/mm/pat: Don't flush cache if hardware enforces cache coherency across encryption domnains Date: Fri, 11 Mar 2022 11:29:26 +0000 Message-Id: <20220311112927.8400-4-liam.merwick@oracle.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220311112927.8400-1-liam.merwick@oracle.com> References: <20220311112927.8400-1-liam.merwick@oracle.com> X-ClientProxiedBy: LO4P265CA0088.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:2bc::7) To BN0PR10MB5030.namprd10.prod.outlook.com (2603:10b6:408:12a::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 17770c70-6016-4fd5-c8ab-08da035284ba X-MS-TrafficTypeDiagnostic: CY4PR10MB1430:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TQwTL6NtW0kPANXnShp9nA7GkcFHjBEuq8u2UktzrVCit9LuXgjDuurnilskMDvLI8uQFCzi/TV0Lb48YgXslC3ayzby30xLl01upz9OXgM1Hj7Mola/1mGQwcV6N8UTJWHtoD5HjCuZu03L2VSQFl3bQ+e0YEYhKAUDFEZTH3q2m9BdjCFSYoCtHMm7Ab4G+NQLev6Cz+IXOUzO56B3yKMJGi34DzY1TuEvCbiEhPIXg8PjnPSoaRBiUd9f6M5+P36qG+r5s+AZAk3ErWPv74ME5Mq46F4goH786NT8J4bvAk3nwc6qP4LyKzboIXjiG6PxgOWvTrdic32MgzG9iGpOgjeoSR7vSfG9zYUSNaWpDcjMHUOLIFgSggWj29P0zyAALHdDGRk2IdygeRzPFIkJm/AoVcwfSFMDv3bII90CWuU6iq7BC29pdv9MwmnVCUMRp9M7v1oIZILU2bwLTiIJdVT7/+s6pbn5Sn4r3DOWxNOu1kz2FzqaeEYexUxSMMjeZmx3jt/X/preGZmU6pjR4fnIIEG49VnsAc3UTSHNyhTn5sxUlBm0M9PVTWLwGs2WuiMcTzuUnibYminaAcriDPdhtjsJwyiUj/MRirOKE9JAyYOf8xCM96ta6Bt5iedFeVY7xZ71OrTArRfdKpnQV+PWuQ9pGxdKtKX/8fQYdZX1nPe5xf/hMG1+FZezNAqmRdHZt9qydBXd/hwt0WJMRe9IFUEanwtuRuEfh5JFl7MbUF/KrHcQctOa/vPltm+sqq2q1vfy9cG7hMLLmkspNvtOHn1okFkcf/csFXI= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN0PR10MB5030.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(366004)(38100700002)(8936002)(4326008)(6666004)(5660300002)(8676002)(66556008)(66476007)(66946007)(508600001)(44832011)(316002)(52116002)(6512007)(6506007)(38350700002)(966005)(6486002)(107886003)(86362001)(1076003)(186003)(26005)(2616005)(36756003)(83380400001)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-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6gf6YtKF3VAc7GO7DiyfcuW7dySmDZzo2O87UxduD/8TpUag1c6NJzTRVcm5lo1l/m8XVba3i+AbRY+LYuHLIjYwvYBTqn5jKnVscHpcvLqwavj0/YB/4Jj+OwweGFYNGCDRns9b4+yBgPQgpoCXgvMUfVvZ9mbffZVmy3989BRsZivmbtqArbSCwyfHJb5h3enEEe0blYGXqQ+kfcjDZxkLIjZiTMmOEN9aKQJTQL2AJbthEk0NS3qF0QlRru/B4wKEFvE+osDe+oo2IwrxHFQDo0KP+fhBBjROBGJGSRI0hwht6AaoGkONsLuH0RuZqbgqLN1Y/LROl4WfHGd+K6ElUXiNgVnNkSZJSzWSxmo1RpTsOGxFYlYG/b2Lke9Lw4KM4elxTtI30fS/L6czjKf8tun1r+iyq/wAwt3tBKMyn6l8vQMKdWnQ0ERFxjV65HmiI9YsmcwxUwHeNoBn6ctHrh40WmVfZoGUB3OynQuyeKSqQ2ZZbjLXRZD6fqkqMlb66ClQhg6apMR/Gh3HHH5yzCACKPdwsdhHC21zyZq2eiNE4EEuP6Wqk6UeciosuxgEfXaM1pMviD5bvTAB5C8= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 17770c70-6016-4fd5-c8ab-08da035284ba X-MS-Exchange-CrossTenant-AuthSource: BN0PR10MB5030.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Mar 2022 11:30:17.8050 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 3JwaBQiU4rW0XvKU5uRm1Il9bNTs/Zi3UwzPib3hrwnn7Wanx8xqak5Dh7odS18I1PE94PepnuBdQ0BFsy9ggg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR10MB1430 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10282 signatures=692556 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxlogscore=999 bulkscore=0 phishscore=0 malwarescore=0 suspectscore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2203110055 X-Proofpoint-GUID: EO9kJN-RBLY62hdUooQlLsP000CP1eO8 X-Proofpoint-ORIG-GUID: EO9kJN-RBLY62hdUooQlLsP000CP1eO8 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Krish Sadhukhan commit 75d1cc0e05af579301ce4e49cf6399be4b4e6e76 upstream. 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. So check that bit before flushing the cache. [ bp: Massage commit message. ] Suggested-by: Tom Lendacky Signed-off-by: Krish Sadhukhan Signed-off-by: Borislav Petkov Link: https://lkml.kernel.org/r/20200917212038.5090-3-krish.sadhukhan@oracle.com Signed-off-by: Liam Merwick --- arch/x86/mm/pageattr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c index 281e584cfe39..d61313f5c5b9 100644 --- a/arch/x86/mm/pageattr.c +++ b/arch/x86/mm/pageattr.c @@ -1967,7 +1967,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_SME_COHERENT)); ret = __change_page_attr_set_clr(&cpa, 1); From patchwork Fri Mar 11 11:29:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liam Merwick X-Patchwork-Id: 12777838 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A7ED9C433F5 for ; Fri, 11 Mar 2022 11:30:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348254AbiCKLb5 (ORCPT ); Fri, 11 Mar 2022 06:31:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348241AbiCKLbz (ORCPT ); Fri, 11 Mar 2022 06:31:55 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 601FF1BA92B; Fri, 11 Mar 2022 03:30:53 -0800 (PST) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 22BAMQaZ004098; Fri, 11 Mar 2022 11:30: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 : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=tq5qBKP12qa1xEBLrPEOAt0ZMKim5AtL1JadHMsSPNE=; b=qDBkb9iRSvYgeJCE9DdCm7BCrUmE1yApRex/GL5NqNhk6E8266X1Jm3uCvVx6mXbX43A pfvPX16X9MdI6qjJqG5xK7hQQQ2ueEA5g540yYLuaqzYug4JdVj7lT0BiODAJ2ST8azo +uYe2Mii+aQash3hybprveiU0Twal8GP3Yijb1sOKs20i2HstxRQ/tdFFJgtKvDUhJ/g RzHeYJgH+pH5oh1AvBgz+7g5IpZT22i4IyQd9Li5M1c3aQJ14ppJ1BRCQCakb9Rg5vpZ UNuzptETGldpcSWiW9BFa3AHyqxauXdTNV087L9ZLGUbcfPTOmNX2CJ8h8C8+WAAcINI CA== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3em0du8sac-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 11 Mar 2022 11:30:32 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 22BBHL3S192676; Fri, 11 Mar 2022 11:30:22 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2101.outbound.protection.outlook.com [104.47.70.101]) by userp3020.oracle.com with ESMTP id 3envvp36u0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 11 Mar 2022 11:30:22 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=E9PpHPYRkK0BCdBZEtFiHf/W0v5d3mFy3Sl4RRW/rOilNJpavLxIo0X+Fr84a5atjS3PKTNT9R0RDnGLpWxP8OOQA7PjwmhyDNK2D9QUh4VdgV8/oB8DDkg98THPytzO++FukbTl+mGkVALM2H8d2KnEKdueYXIAs8gWZgJl636dM2lwke3cBDg0w5WK9L7OJxYuygGwstAZR7flocNG3cOec43ylaHYuCZv4lh5/YKF576Fj8dE7Cy9/bqqLbRE6Rk+41qvp0+YNISW2dMpKgjXmRH8LnB4xZOgRsYUNilixKs4NdNzL8Bq32iw7VINfa3n0HmSnTxnX1hJkMTxZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=tq5qBKP12qa1xEBLrPEOAt0ZMKim5AtL1JadHMsSPNE=; b=VP7WUmuVq3oVbps6zJsQCLAGzG8dfepyM9gHbgcpf3aLRtGddlEToxF4UTG4By7eA31J86+nVl4xeTsnZ1KxCJhYzRJlmbqXU/syfRrbSPQ7EVvLl8VPFkzd7+5ZWATv9lTXT7yiu+D4UCg5Ui1mO9gkGvIlUiHofsEZEd35suA8WntEVq9fuHsOjon4CMVeUB6CpvzNQg2BTqq5exN4w39mnEIEOV08ccxSYtZUUUAmECsIaCyYQFNsWr/69pGfbRFjwKTzHhobCsPPCzKordlU6y+oN+Wpsk4voGQGUafVCASjSw6nN3ky18iBY8E+8P8xBn660UxBKsW2Dgdbag== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=tq5qBKP12qa1xEBLrPEOAt0ZMKim5AtL1JadHMsSPNE=; b=oEFwGcMyemYffNFhGh97CSy/h9G6ZovDvdH+/IhdvUz8E1RXSCAMOAvKYAkdL7aX2TT/X2eo0bwwo4cZx5PPkmBXG7qbiYurGvVfC4mu2UqGf5QULHEPbc32cIn74JS8LsK6h4wTuq3P9gRLJj+IEc+Z5uSLdqGt3yAyLwyt+4E= Received: from BN0PR10MB5030.namprd10.prod.outlook.com (2603:10b6:408:12a::18) by CY4PR10MB1430.namprd10.prod.outlook.com (2603:10b6:903:26::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.17; Fri, 11 Mar 2022 11:30:19 +0000 Received: from BN0PR10MB5030.namprd10.prod.outlook.com ([fe80::b9d4:8912:7bf8:14fb]) by BN0PR10MB5030.namprd10.prod.outlook.com ([fe80::b9d4:8912:7bf8:14fb%9]) with mapi id 15.20.5061.022; Fri, 11 Mar 2022 11:30:19 +0000 From: Liam Merwick To: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, x86@kernel.org Cc: pbonzini@redhat.com, bp@alien8.de, thomas.lendacky@amd.com, brijesh.singh@amd.com, krish.sadhukhan@oracle.com, liam.merwick@oracle.com Subject: [PATCH 5.4 4/4] KVM: SVM: Don't flush cache if hardware enforces cache coherency across encryption domains Date: Fri, 11 Mar 2022 11:29:27 +0000 Message-Id: <20220311112927.8400-5-liam.merwick@oracle.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220311112927.8400-1-liam.merwick@oracle.com> References: <20220311112927.8400-1-liam.merwick@oracle.com> X-ClientProxiedBy: LO4P265CA0088.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:2bc::7) To BN0PR10MB5030.namprd10.prod.outlook.com (2603:10b6:408:12a::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2b20373c-d8ee-4083-38f1-08da035285fa X-MS-TrafficTypeDiagnostic: CY4PR10MB1430:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: k6aFsiJpAl2LawNZ57UGZomszPt7+2b16MCZ7xTB4LmgUykIi5ILA6XBh26Ojtzff7uSy6suCCjOeZtTEUr21898yHHRoHGcmgNYQzSUKfwX7l0uyNFxS1vXHR69GBonBO3Nyv2WVvYdb9ilvCXAxX3jlpy72+qs8BQg4f0LPquRJm9q2AhAW/r/DBpt+Vgo9xzOQkt2WxDfcI5uE/x/EhzsuoHDqVwij7GX07Gw/NSj0oBSF0Y488ohiQBLDpKb/ewIwINYvehjbuBfKatFyIsB87pvMgYWD2EjYZoopwFmBkkTIJz/d6PYnUifn52rloshqLolOe1uBkn/1vT8CaSJ9v+2hk8p6uHybFD2KmOPl+xaRGeXmO+b0qHeKUC9J+BXBbRC4vXESg0AgBmKL9HgxoNSFL0hs9QsRPMGP39//Tx87drJBuub4Gorey+b29N0XRTE6A6QF/+PdLQbswxfthsrJR6xB6JQWiGUjFcxpAO94/zzq8onJLnmkZXVTxJFpTUvL7/jN7v9+3QZrvTr28z9VTrz5LE3/ui4FL8n7OzOE8lHGYW7a9gzQ5DpQPIktUE3kLBNGWiXYUVqyU6SmlhPZCfUU5Dj6A1i7Ukz2oVUPb49zULYjcdMhqJhL/bRhS6HyBNGqBiPpjXSABJWOLPwOvV5ly76hksfFw4HCS8Z+nFroAhC6L14DqRDrFy/IzYt7tapXwDr4KJKd5vkhYz9CHlR+3Y+krnfCjJkaIl16DaBfTxtCDfAlGfnQMzU80x0tgI5xIhkodw1dcqRuyvmw8YvctGH6CEfVkc= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN0PR10MB5030.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(366004)(38100700002)(8936002)(4326008)(6666004)(5660300002)(8676002)(66556008)(66476007)(66946007)(508600001)(44832011)(316002)(52116002)(6512007)(6506007)(38350700002)(966005)(6486002)(107886003)(86362001)(1076003)(186003)(26005)(2616005)(36756003)(83380400001)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 7gI9y8phHMD+jGmnS9v0KhU84FmuEnqtMEu4lP44UOP/AcYgPbFmNAXR4ytZ+ahkGOwfuY/+aFjPNysF0em3civw18L/6gUS+GL1pkMZCvH/TUhZS8txKMBpEbv6bJsmXO8RMq8B3w0R33lsUw7tWDTm1YZ8z4zV4imhot53P3vO+2+wjim3kHDjyUau7Rj/C29kDdU9fUdPmDrqd1h450ZJj5EQf1Oek3rm/lDVO5Qt3WaAmYKrb9r6YcqnClTGwcHvcDES2nmp28jjC3gJXKR5QeFb15xSDGjTeADcnUzo5tt1Jn7e2VO88EHV9eSSrEfzpjzzkeE/S02N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/Ny7etvb0wQpkHaN1oQ53p8jufFlAoPrBz2KBjNcRqC4PpME996UcMst/eC3xjWhgUgnovo4sOXIVwi1luJPprLolSlRLxqNS4YbNQtDYaFVm1/xcrttrTsky+Z4bC4oZMRtqWpq55zb4YBnbFUn3O9fhr63yqGJyEePRz4XbbgAvZXS6DwBZIxFR+moac6FkW52yEMxnAVAcvQ4sxk5s/d3qSbLZx0Jjg4TmA= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2b20373c-d8ee-4083-38f1-08da035285fa X-MS-Exchange-CrossTenant-AuthSource: BN0PR10MB5030.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Mar 2022 11:30:19.8047 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: rV1Z1loqvLcA9JrBKPMN8RBi45ya+ctWeyXmARNfA3ro9i1iaBtfcqJgvEqxgy9ybTbaoYRkc4vPjTE4qGgl8g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR10MB1430 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10282 signatures=692556 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxlogscore=999 bulkscore=0 phishscore=0 malwarescore=0 suspectscore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2203110055 X-Proofpoint-ORIG-GUID: f5VO2VnAsKEXHoIqy-vdF6E1xC-IwR7x X-Proofpoint-GUID: f5VO2VnAsKEXHoIqy-vdF6E1xC-IwR7x Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Krish Sadhukhan commit e1ebb2b49048c4767cfa0d8466f9c701e549fa5e upstream. In some hardware implementations, coherency between the encrypted and unencrypted mappings of the same physical page in a VM is enforced. In such a system, it is not required for software to flush the VM's page from all CPU caches in the system prior to changing the value of the C-bit for the page. So check that bit before flushing the cache. Signed-off-by: Krish Sadhukhan Signed-off-by: Borislav Petkov Acked-by: Paolo Bonzini Link: https://lkml.kernel.org/r/20200917212038.5090-4-krish.sadhukhan@oracle.com Signed-off-by: Liam Merwick Conflicts: arch/x86/kvm/svm/sev.c [ The linux-5.4.y stable branch does not have the Linux 5.7 refactoring commit eaf78265a4ab ("KVM: SVM: Move SEV code to separate file") so the change was manually applied to sev_clflush_pages() in arch/x86/kvm/svm.c. ] --- arch/x86/kvm/svm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index 2f84509f2828..125970286f28 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -1904,7 +1904,8 @@ static void sev_clflush_pages(struct page *pages[], unsigned long npages) uint8_t *page_virtual; unsigned long i; - if (npages == 0 || pages == NULL) + if (this_cpu_has(X86_FEATURE_SME_COHERENT) || npages == 0 || + pages == NULL) return; for (i = 0; i < npages; i++) {