Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp758970imm; Wed, 29 Aug 2018 11:25:44 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbQPmknQbFaXA4ziiQBsxjtAbCuHPzqtYrvbaN71Gz7aXJ8Yzh+eltmmVcjhP293+3vyJL9 X-Received: by 2002:a63:5465:: with SMTP id e37-v6mr6763824pgm.316.1535567144597; Wed, 29 Aug 2018 11:25:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535567144; cv=none; d=google.com; s=arc-20160816; b=uhBnbf67gSVefUosJzDzDfbXPcfjYGJ+pmbSYWiIquDwjCe+uZ0TarWW652XnCBN63 bRUIEPKgmtKE1kdSegDqWllqX9OFVLTKGCMMKMVpngMv3Unb8mDJ9qW0N7KzHkDWALUK DI8wv1g3AncytatPJHTMAQzzQlZAwF/+31qlcFfAxKdI9Nh7ecwdLEUHNhPYdK97ngt0 +M04EyZQ9pXWzPn/sRcZoyamYquNUCXnSpDo6Z6MrCdNH0P38G8JOHKy/EOBaQNTzyyB IPjNRFq8l0AfPnHk43HqvSDjbUOKgfzatM+5i0BUj4n6OGv3pyleLTAYdPRXVFDT1Oq/ OZSA== 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 :message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=jqN4uFLS7ec9SHBb91Uw5xUkDkLZCW9DVaC83lns6/Q=; b=wsTbP7gD6y5vRhkWFZSD5EPHgR/t/+k1o35y0XLZW9kYPauSx+Oit6MH/sIPbnDLvY cXxY5T8ZUiMJqHN8kuLqZgPtnZ+/1GCbdMNqGeTQtPjRup65caPJuYsMUAsazG+UIrsn 2T/xAqKNCyV3jA4HYHQR03EjcoLEXpLpuK5Mye57BPap8Sl+WbubEgbU4ezwOsXch2CH 01a3OqcIt0LAiXlkt1AU8xM8kbyNHSiF0Qqavq1w5DDH0uYLWkN9Kov2QPqjN4ZRRVnR 3nvRtZOQmek/3X6MwX7g2MFszbSJIaytvFEPbBtBveEMnvyxwDeJk/6MBvnLxO1wWxhe otIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector1-amd-com header.b=clXlo60i; 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 f29-v6si4305511pgl.570.2018.08.29.11.25.28; Wed, 29 Aug 2018 11:25:44 -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=clXlo60i; 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 S1728145AbeH2WWZ (ORCPT + 99 others); Wed, 29 Aug 2018 18:22:25 -0400 Received: from mail-cys01nam02on0069.outbound.protection.outlook.com ([104.47.37.69]:40616 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727399AbeH2WWZ (ORCPT ); Wed, 29 Aug 2018 18:22:25 -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=jqN4uFLS7ec9SHBb91Uw5xUkDkLZCW9DVaC83lns6/Q=; b=clXlo60iYEr5zfQtjGKjjp8SBs5ajUlb0jZcbOp28Ap7NGYqiMSMfbNG0uBJnn0hHoD9bwh/W9EjQmgKDgV2mvtRBKjkXrWm4/7S27K5K3CEiyzYFrl0G9e1ux7pXef63RvYrZyxkxzwNEyqO1qq+2RnOExFQDAIAnRBq+2Vmt8= 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:12 +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 , Paolo Bonzini , Sean Christopherson , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= Subject: [PATCH v3 0/4] x86: Fix SEV guest regression Date: Wed, 29 Aug 2018 13:23:56 -0500 Message-Id: <1535567040-1370-1-git-send-email-brijesh.singh@amd.com> X-Mailer: git-send-email 2.7.4 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: 764c8a60-8eea-4b01-472a-08d60ddc9f1b 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);SRVR:BYAPR12MB2678; X-Microsoft-Exchange-Diagnostics: 1;BYAPR12MB2678;3:RKanTWm18ufmsj9gYfcuPjfRpy/O+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UMoWe2JvfkDZ/D4JUkqMSj4sjcPtMCGeDMgFkQIh7z9vFx6dl3n4DB7VOuthZPFF4+GUPcRwqU/cR6CO0dUugdul7ohQuLfjMsKgQar94/1rK6Gcssj194BcoDA9ojGII4wV1m0muShbSQw5V0sZ8GvazSJlNAUU/ySDZYROGnB54MAynCl7HxDCo1atrFcq/UBxenD2/ITLOZ++YaghyVKL97vJKIS0X0DfImcXisdpCFUFs9gLHB+FfwUHttS/m6lqzzmdpbP82T2onW71l5YLp2tYPet46HfDA+NkB4w59lxMU+zQNf49HsCndoO5YHVdIS8Y;4:PGfPMtgFuJuViBG5zyB+1L22OIKbNvTeXGNYo778e4REt8BGOB78ub95Gg8b8JKyyrBq7LS+S/WOdIRAe2GBetqgEU8JhTRWO7nHvBsdQhw0RR/GECWRNJ3RKp9DN/2SsiADUsfu0ANIS+aHAePxOCF4l9Q08ddXoRl5rl2RZreIYX+8kXAq4JQpBNlgB1QKJCPZQ5HfrIMdnmF5JULgbade79NMzi4rDR5OMrMBxj1224VK0o2XWRk8ZtR56C7XxKXijF5iT7/Ba4O1fYjQiNYQnWazPvNL4s21bsUbBDMgWi2GCrfY0Ar9CKf2farDAmqwMWKb5KzzgEaP3CeYJd88Rm0iwX9h081oZ6cYur7Cz3QrQFoH2SNpWvAnqEAI X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110)(84791874153150)(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)(6306002)(14444005)(54906003)(4326008)(6666003)(966005)(97736004)(25786009)(23676004)(7736002)(52116002)(7696005)(305945005)(50466002)(50226002)(53416004)(36756003)(81156014)(81166006)(8936002)(106356001)(2616005)(956004)(476003)(3846002)(6116002)(86362001)(2870700001)(2906002)(47776003)(68736007)(186003)(16526019)(486006)(66066001)(316002)(105586002)(26005)(8676002)(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?MTtCWUFQUjEyTUIyNjc4OzIzOlkvelE1UGhra2trYUVNY0VYL2JIRDB1bjNJ?= =?utf-8?B?TjN6MTZVMXdkcGdja0h5SDY2SThuRU83eFdmWFR4czJjN1FKVDdESGM1S2hy?= =?utf-8?B?V2NhV2ZkcjFlc0FSVDNFNkRtZy9uK0lOQXlBZW1ZbU1CV3RwRWtXVXFJTDVP?= =?utf-8?B?NTVvUHVBYysyTFRwWmwxK3B5U1pXY0s1ZDZQUUpva3dVR3J4UWZLSGhHVURP?= =?utf-8?B?eS9RZW9iU2FRZllrTHc3ZVVIbS9TYVhBbUUxNzBTQXJRUUJreFZUbE1PQTFR?= =?utf-8?B?L3p6UThuNE5VWkVJL2ZiUWRrOU5FbUNRQXRZQ3g0aHl2U1FoQ0xnc1BYK1Nj?= =?utf-8?B?djY1d1V1Z0NHTTl1RW85dFROQ0RIV2FyRXA5VlVhQUs1clNiUUdJTnhPY3lH?= =?utf-8?B?S2Z3RGQzdFRnZDlNMW9HZVl5RGg3azlPM3pTLy9SZS82ejY3WWNFZm45cG9Z?= =?utf-8?B?U3lIM1dsN245dTJndmlnYzYyVDV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RjE1ejNOZ3VCUlVad0E3TGNSY3h4SGhNYlJkRWZyK2t1?= =?utf-8?B?WEFRNndhTFhoZFcxMTZ3WTRieURkY0I0MWpZZWdwS2FxcmxNUnpxVGovVmhy?= =?utf-8?B?aFdVS2xiS1RPdFpuS1Y5TWxrVGcyMkpybllydG0rNjVqMUY2SUthRmc1d2NM?= =?utf-8?Q?B9MtT9COseahOwSKs4UvYHaKdtPQF6XZJPPJwrvD5zuo=3D?= X-Microsoft-Antispam-Message-Info: WmKcozGK2U/ZRGSeT24s5JQOXStPbe3ERLFIjPDBDdX8yiONjPkW0F4MONtAgzRMpR0up1CgKKgZaZ6iy+ZzvNXn7YPYQYyTfy+1+OejdfLdL+nAQVAojNkGnhZf7mOGo2QZz6E1AlreCBW9BKu03frn0dVTeWSJlY9razT4xU2o/78Jy1PWcZzO1cbzox0Jyi7qsizcNFa6ifj+uVDZRWY8uYFOAqi63d6/ULL0NDB86dvwPW8NltM/euzTn47ihVVl8YUzdW2nj2y0rtvDQaccYmncvs/FHouMz4/w6nhHOxE5BStBc5BKbsjG+4yMj/0QGPjDvNRsz/LSKJv7suCwoliIHZPUUaJP/WGLKYo= X-Microsoft-Exchange-Diagnostics: 1;BYAPR12MB2678;6:ew+bUHAhDQmcWP4yjFRHo0VXO2SUyVZXv0euN0IksagmohtVaQvHcrmDBsYpETJ0aMFR873f7Zg9b8AgUwHNsSMQ0zxQRhwAbttdOfddlpmPxO6XM16EzReUt8MrZFuShA9iVNLyp/gPkCLvvmO3uUoisDqDeIESdCg10BQKjvQilRoc/HeKoHskzJmMNGOG5h/2OeMVHTnVudO7MdVbWr5poIbc+pBBQpdUNEDXGVRS0mZeu2ZFcIf5+BSSYwoSj476Q2iqy7nqkgrhwWJtkprEaUMeWtUpABil05wfAAZ2WFHxot29TYwP1skiIaoaKDDFIKlxaeHH30nEYzCHO3YcL/sf472wYCRjvb4hribRyhxrT3BOC05+lHxAujWvkravUbp50OfeMYdrK4s/XEg4ByNqUemHw6blw0imb/PEXshf6nixKydfz365eFeyGHjYokqCt4Y80BZslU/cOw==;5:iiUGjSGWv+vatRCAvYa7WJJ//7qCbSqD01sMXbiCr/uxkZlAqyZgDZ7olBoce3XhOHxpYSxL7F30ppVPATy+ETBEqP+LxM3cjoP5HSjwuKYtC8uB2wOzwNTei6tfzJig/hzegxsYHqR2p7DgKOfaxq72j0DArapGnLrr4iaQPJc=;7:g42TPz6i0kzZlRVTdCOlTVfp0myEmn9zKDA18HjDPW0RtMErYNSMINu/YD1DIvWZMtJwYviO2JDa/Hit5BQXc+jWBSbt8hTsZs88VPl2SXR6mkcMpOvi9oOFB+ffhWBSoH387VIJBl1fluMVLn12MQlQCYajxctoeaHc3y6MUFvx1E5PjQ6Utv5I3/D91romVnUfxSl03za2wuJjXaBgTf0luWj9N1CfkJSx/m87j0YimlqhIATpvIgXotSteklS SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;BYAPR12MB2678;20:DfJA8PKKFeQ1czWW288RwMdC60Cfxem0TuXOf0TKC0nVgzGe0FN/g0L1VJi3cumQ+QNPSX+mB0WXNZ0tqc+ZxMsux8uILl/U3imZ3uX0YI5jHK5V0mdHDcq8UrDFO9eucga3gh0s0alLCAbxAe9oKarxhzxwkBxJ8RiA9WPQ27u0zEduEd5Apnl+Xt1+HpI8TUjF0I8PJ+3LGX/J1hA02YAeW+m5HieL13QFj5B1G5a9TMBHoCbvRdeGutBwOrav X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2018 18:24:12.4084 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 764c8a60-8eea-4b01-472a-08d60ddc9f1b 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 The following commit " x86/kvmclock: Remove memblock dependency https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=368a540e0232ad446931f5a4e8a5e06f69f21343 " introduced SEV guest regression. The guest physical address holding the wall_clock and hv_clock_boot are shared with the hypervisor must be mapped with C=0 when SEV is active. To clear the C-bit we use kernel_physical_mapping_init() to split the large pages. The above commit moved the kvmclock initialization very early and kernel_physical_mapping_init() fails to allocate memory while spliting the large page. To solve it, we add a special .data..decrypted section, this section can be used to hold the shared variables. Early boot code maps this section with C=0. The section is pmd aligned and sized to avoid the need to split the pages. Caller can use __decrypted attribute to add the variables in .data..decrypted section. Cc: Tom Lendacky Cc: Thomas Gleixner Cc: Borislav Petkov Cc: Paolo Bonzini Cc: Sean Christopherson Cc: "Radim Krčmář" Changes since v2: - commit message and code comment improvements (based on Boris feedback) - move sme_populate_pgd fixes in new patch. - drop stable Cc - will submit to stable after patch is upstreamed. Changes since v1: - move the logic to re-arrange mapping in new patch - move the definition of __start_data_* in mem_encrypt.h - map the workarea buffer as encrypted when SEV is enabled - enhance the sme_populate_pgd to update the pte/pmd flags when mapping exist Brijesh Singh (4): x86/mm: Restructure sme_encrypt_kernel() x86/mm: fix sme_populate_pgd() to update page flags x86/mm: add .data..decrypted section to hold shared variables x86/kvm: use __decrypted attribute in shared variables arch/x86/include/asm/mem_encrypt.h | 6 + arch/x86/kernel/head64.c | 11 ++ arch/x86/kernel/kvmclock.c | 30 ++++- arch/x86/kernel/vmlinux.lds.S | 17 +++ arch/x86/mm/mem_encrypt_identity.c | 232 +++++++++++++++++++++++++++---------- 5 files changed, 229 insertions(+), 67 deletions(-) -- 2.7.4