Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp761993imm; Wed, 29 Aug 2018 11:30:49 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbcBfEs1ezTtPLYeGRAhR1dVFb3Nbn4+HC4ubwqXpAkZHx53bhbOxrtJ44uRe7ptjwYba7X X-Received: by 2002:a17:902:a24:: with SMTP id 33-v6mr6870374plo.293.1535567449213; Wed, 29 Aug 2018 11:30:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535567449; cv=none; d=google.com; s=arc-20160816; b=MGp3VM0Nc1taBzFpjT4eOcarfd3Qhb8JUCK3fon3s8n5PphvfTOvJT7CLcf/nMIiaR sG157a+i6lr8hE5qbmcjKDKA1eF1ohnXIw52y46tkd0tcvlRqDieswPxiMqMuSdcZ45P A5R+Pq0U8p9RdgFrzWyiVKsRN7XO0fR4g8ap5WYPkhRMooGo5pmVv5AZMo/82N+oghrL bhjwAd3NBVyvN4LcB7xDXAMYMEDAUOR8M7HgTHvNGysvzDv33bIRjYeugPMwDL7IQ5ek eqbEv8PmvUs64CmE8j3q3SpKJKZUC7tUsXPENICfrE9soTgGYLQkblTfGn/uraj9esf0 xt7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:spamdiagnosticmetadata :spamdiagnosticoutput:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=f6PW9E0NX+svtefZx6/rCifZcI4kR5EN7WimzZP/yVQ=; b=aJUMKZYABvS70m09sMMx0o22YzjARY/MBLNdsoAQMspyc0FhzpmFa3sWlug5j6whSG LNrYEhxq2NhzFsuruWblkYizGbHHl628Ers006PaoUDZVc3ba6TKhuyCdjslvBY2Pb3y MOkNOyGJthRTyxFScRIs2jyJ+ONw0nPpSiM6ZXAtqldbCJckTgf6AMeveq7L3c/8mMZI 2enwrYvTeJUX4JG00dkEpmx8MfLgPPUlevH1MGgB22nQ7skLmDIM7ioDwCUgPWTGqYDd 3jfwgZuH9YmYZBIC7kp0uFlJun8faJBb9AeurJWIb+/GPiV/BjHyDtEUzdqRKjqp75OH l5eQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector1-amd-com header.b=hz6KcMqA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x5-v6si4121332plv.304.2018.08.29.11.30.33; Wed, 29 Aug 2018 11:30:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector1-amd-com header.b=hz6KcMqA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728437AbeH2W0x (ORCPT + 99 others); Wed, 29 Aug 2018 18:26:53 -0400 Received: from mail-cys01nam02on0068.outbound.protection.outlook.com ([104.47.37.68]:16160 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727399AbeH2W0w (ORCPT ); Wed, 29 Aug 2018 18:26:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=f6PW9E0NX+svtefZx6/rCifZcI4kR5EN7WimzZP/yVQ=; b=hz6KcMqADc9KYJ8AmYMZAqKkajDTh7u3nCofgSDN8I67DvafBFj3hDFZVFFCrx6yUiDfW0xowDcCcSh6kGp8WpPL2GQC7tVG/MEYyC1+HOJcIjEDeQQqtwQa+FZmJK/XYTNzQGICgZ9mt2qOnfJc93uZRbZaLnYWbbSl4gHOKe0= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; Received: from sbrijesh-desktop.amd.com (165.204.77.1) by BYAPR12MB2678.namprd12.prod.outlook.com (2603:10b6:a03:69::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1101.14; Wed, 29 Aug 2018 18:24:15 +0000 From: Brijesh Singh To: x86@kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: Brijesh Singh , Tom Lendacky , Thomas Gleixner , Borislav Petkov , "H. Peter Anvin" , Paolo Bonzini , Sean Christopherson , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= Subject: [PATCH v3 2/4] x86/mm: fix sme_populate_pgd() to update page flags Date: Wed, 29 Aug 2018 13:23:58 -0500 Message-Id: <1535567040-1370-3-git-send-email-brijesh.singh@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1535567040-1370-1-git-send-email-brijesh.singh@amd.com> References: <1535567040-1370-1-git-send-email-brijesh.singh@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: CY4PR1801CA0020.namprd18.prod.outlook.com (2603:10b6:910:74::33) To BYAPR12MB2678.namprd12.prod.outlook.com (2603:10b6:a03:69::27) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f9674059-9b18-4ffa-aa57-08d60ddca101 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020);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mJOoSCIQ1bET6jn+CoVaXk0jpI+UYfKLibFKk8pAp3PQecNDGWS7elbGaTiNm1IBZsohEvV57r4ZEeZ0IYvMS8STSjja364grVFs0Y2V66djMkswvDF4zt8A/YlUGx7ytqV20LbdQ41I6c/nQdh0KOkS9GhdniEHmviFauJmzgG2RnhQ+OUzPiOgTPkc5P0QzfofnAQXu1NaIDBzF3+iKdCm3EtL9pUG8k+TnuxDs/k2JbCjND+z/76nh1F+vl9ROVCnFdTRz9OPa9LT2XebdzJnSkfsmKO2vb3efTTUhJZC/AEvZ8OGKDfih9d3tV/NGe8eEPLUeugoFxvvrFc71ddh3+BfCIKafHSnT8Jn3Vf8MJ5eWsj8FyYaDziYt72lvV8D/1nEVyuu8TxsiOiT;4:0c8ra8xzGMSORGTcsVngQ8IVulxsb3Ep0ixpA9nqfoagsNhLyovyPKhyMb9O8yYhrBkic/uxOLu9Sfurr88PRGI8pt8wvsezsKTCbJ1rxxtYUAzuxKoAz98SAoI7fBsmuS1Zh5ka/mLkB4pV2rdcDNBaSoDOSg8EDZKcpltkJJX6qOJwTKJJMMZl8varLIDBWkFCdlJYPf2Esqu95DZfqzuuOBv6gvqTLUIbEowj2aXMSIU9qIyIN3LEoyrzhvGJd6QrtMTnurDlhRh4Z6T+Xf8LZQKt3UTsjMr6H/5v4umI2CVz6PPu0IOqOX+Q83roNiu0TR5abcD3w2cnTS0NfOY8MAyYA8fhjWF4DaOKndU4pFP2VK+0chvY+SDTWO2v X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(9452136761055)(767451399110)(228905959029699); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(823301075)(93006095)(93001095)(3231311)(944501410)(52105095)(3002001)(10201501046)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(201708071742011)(7699016);SRVR:BYAPR12MB2678;BCL:0;PCL:0;RULEID:;SRVR:BYAPR12MB2678; X-Forefront-PRVS: 077929D941 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(396003)(39860400002)(346002)(366004)(376002)(136003)(189003)(199004)(478600001)(386003)(6486002)(53936002)(5660300001)(14444005)(54906003)(4326008)(6666003)(97736004)(25786009)(23676004)(7736002)(52116002)(7696005)(305945005)(76176011)(50466002)(15650500001)(50226002)(53416004)(36756003)(81156014)(81166006)(8936002)(106356001)(2616005)(956004)(476003)(3846002)(6116002)(86362001)(2870700001)(2906002)(47776003)(446003)(68736007)(186003)(16526019)(486006)(66066001)(316002)(105586002)(26005)(8676002)(11346002)(44832011);DIR:OUT;SFP:1101;SCL:1;SRVR:BYAPR12MB2678;H:sbrijesh-desktop.amd.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtCWUFQUjEyTUIyNjc4OzIzOmNRbjAzTTI0NU9uRmJNMFM1cENzLzZsK1lP?= =?utf-8?B?dndBV0lDWEZJdzdzZ3AxTlVJU0p4YUtBWUNHdnBkRGk1WkphYzJvSmduZzUw?= =?utf-8?B?eGpjb0p3UlpKeWMwdHF2ZkdTTlpBZCtKZHJaVXlrME1PR3h5clRIRXBIeEN0?= =?utf-8?B?MFllSWtGTjhBLy9RbEVFV2pkY2ljb0dMaXZFRnR0djNQektGR0ZkdXdpTWJv?= =?utf-8?B?RVlUSm85UkppYThhc1M4elVBNW5obVlxbVJpWFZmclR2ZWVGOWM4cDVBMGpM?= =?utf-8?B?ekQxY0xpYnY3OTBqOG5FRGo2bnFjd0Njc3M4cHg5cDJKTDI5d0lPUUQ2T0xW?= =?utf-8?B?MHkrWHQrZkxHc21FYkt2Qzl6eTVGN0JwcUVLRXJnSDlselAxYnJCYWt5aGJJ?= =?utf-8?B?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ant-OriginalArrivalTime: 29 Aug 2018 18:24:15.2366 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f9674059-9b18-4ffa-aa57-08d60ddca101 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB2678 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Fix sme_populate_pgd() to update page flags if the PMD/PTE entry already exists. Signed-off-by: Brijesh Singh Cc: Tom Lendacky Cc: kvm@vger.kernel.org Cc: Thomas Gleixner Cc: Borislav Petkov Cc: "H. Peter Anvin" Cc: linux-kernel@vger.kernel.org Cc: Paolo Bonzini Cc: Sean Christopherson Cc: kvm@vger.kernel.org Cc: "Radim Krčmář" --- arch/x86/mm/mem_encrypt_identity.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/arch/x86/mm/mem_encrypt_identity.c b/arch/x86/mm/mem_encrypt_identity.c index 92265d3..7659e65 100644 --- a/arch/x86/mm/mem_encrypt_identity.c +++ b/arch/x86/mm/mem_encrypt_identity.c @@ -154,9 +154,6 @@ static void __init sme_populate_pgd_large(struct sme_populate_pgd_data *ppd) return; pmd = pmd_offset(pud, ppd->vaddr); - if (pmd_large(*pmd)) - return; - set_pmd(pmd, __pmd(ppd->paddr | ppd->pmd_flags)); } @@ -182,8 +179,7 @@ static void __init sme_populate_pgd(struct sme_populate_pgd_data *ppd) return; pte = pte_offset_map(pmd, ppd->vaddr); - if (pte_none(*pte)) - set_pte(pte, __pte(ppd->paddr | ppd->pte_flags)); + set_pte(pte, __pte(ppd->paddr | ppd->pte_flags)); } static void __init __sme_map_range_pmd(struct sme_populate_pgd_data *ppd) -- 2.7.4