From patchwork Mon Jul 17 21:10:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Lendacky X-Patchwork-Id: 9846247 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 25AEB60392 for ; Mon, 17 Jul 2017 21:22:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5C1C0228C9 for ; Mon, 17 Jul 2017 21:22:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 503DD28417; Mon, 17 Jul 2017 21:22:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7A43F228C9 for ; Mon, 17 Jul 2017 21:22:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751506AbdGQVLy (ORCPT ); Mon, 17 Jul 2017 17:11:54 -0400 Received: from mail-bn3nam01on0076.outbound.protection.outlook.com ([104.47.33.76]:46539 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751882AbdGQVLm (ORCPT ); Mon, 17 Jul 2017 17:11:42 -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; bh=CtKX9TOFFQ+IHa/geqTqmY/DjSqOg+AyFXuRRQInFgw=; b=xRRqd/UQNBvdsfXHAzBEpCHf1HCqm4bREREcj71MXZVXjaMNlG+4wIFnX2g6EwlNv/dIelrkssbPmrO6o0qEWLPZLj9nUrZgsYVjC3IL+Epp/o9muLwpLf9lAOc9AA2P1S42xayMmfB/S+6VHQsnR09GpgH7l3lbHc7osKYN43I= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none; kernel.org; dmarc=none action=none header.from=amd.com; Received: from tlendack-t1.amdoffice.net (165.204.77.1) by MWHPR12MB1151.namprd12.prod.outlook.com (10.169.204.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1261.13; Mon, 17 Jul 2017 21:11:30 +0000 From: Tom Lendacky To: x86@kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-efi@vger.kernel.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, kvm@vger.kernel.org, kasan-dev@googlegroups.com Cc: =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Arnd Bergmann , Jonathan Corbet , Matt Fleming , Konrad Rzeszutek Wilk , Andrey Ryabinin , Ingo Molnar , Borislav Petkov , Andy Lutomirski , "H. Peter Anvin" , Paolo Bonzini , Alexander Potapenko , Thomas Gleixner , Dmitry Vyukov , Rik van Riel , Larry Woodman , Dave Young , Toshimitsu Kani , "Michael S. Tsirkin" , Brijesh Singh Subject: [PATCH v10 12/38] x86/mm: Extend early_memremap() support with additional attrs Date: Mon, 17 Jul 2017 16:10:09 -0500 Message-Id: <479b5832c30fae3efa7932e48f81794e86397229.1500319216.git.thomas.lendacky@amd.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: BN6PR03CA0008.namprd03.prod.outlook.com (10.168.230.146) To MWHPR12MB1151.namprd12.prod.outlook.com (10.169.204.15) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 61e44b1d-ec04-4389-e04f-08d4cd586752 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(48565401081)(300000503095)(300135400095)(201703131423075)(201703031133081)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:MWHPR12MB1151; X-Microsoft-Exchange-Diagnostics: 1; MWHPR12MB1151; 3:4Jw2NeWFD6gbIqqyAwfvpFXuqwcN9APpmzcuy00NhPILdExc2ZZKNLvofBl9Yw94U+M9wYKgIQBHBceZbgYp2zYlUFdZgsWYkXTmKRRs/elUY7l6066cw/gPCnQqhnZGYZsDbNLyjU50V/maEWra4Ys5hF+MuFQ6FKDKazxqYj1ng8mGidYcYeQXH681ZSTUQkkzipnfshR66dvTtA0d3LQ8qFHtLT1gtlNX6ob2BcFG6bnlpGGpd0bjvDZCdLPmGqIOoejMV97rFCJLPYPGVIDg6+JnEssNyq54og4ForAWYP/B363WbotVfFcwni/XjUApT8LWg8I7fU8cZhLiVGiEk1PB9PNBVW0vvWyRKjje+nKL8td+x/2pVXnFgANSCYVGHuiPGypnIN7fCipPxFqqmGSBmzYUnTLNl+y3dyeulqsOU2F9UKninNNmU4lU4eOYU/1rJafGxec1BeKDYU+00R7bPfaSGOspm62vdXPE0inw+6DMF6EHlpGz99rw6xAaUs5RIS6Gb+ohDsiKl50xzyKYT+7g78x3JvTwCHhcRcuIgyqIbiILzYI+nP1Q9l3mI0wv1ggIy3I0qhRUufHL1uNaZwA7w0gwPapD9mdZpG27/fGngDAK/e1XsN2Sq7bRl3mOF+Qeknox28fRT25HtsaoZjjbpkonYOWvbqjERjyEgr8DURdExlbIs2UaJBxhx10DB0iSYUQ3YZVkdMZ+XwWhdyZ5D5Q1EPwFRp9/n50OKGaTW0iw1feNGLx2DBPtiTTJIo7KRlGHSbBziA== X-MS-TrafficTypeDiagnostic: MWHPR12MB1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mjcWxULXY2q+3bgz/C/D7aDS4iVU95G2BgOca4/FcAio3iFPAHpt64WnEOsex4tex2jV197jyWeyw0hab+GDCgaBpMYJ/ScIvq3c0gnAZGJD X-Exchange-Antispam-Report-Test: UriScan:(133145235818549)(236129657087228)(767451399110); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(2017060910075)(5005006)(8121501046)(100000703101)(100105400095)(3002001)(10201501046)(93006095)(93001095)(6055026)(6041248)(20161123558100)(20161123555025)(20161123562025)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:MWHPR12MB1151; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:MWHPR12MB1151; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; MWHPR12MB1151; 4:3TjHLLpbwpDzCNEh6jOPd8BbctIFodFqgjDm/e1zTh?= =?us-ascii?Q?zONSVBOBBHllbP1yJnhw7O+yLpj/hmVamSPL5rbrzOrDLB0hQ7TUw2KSpr2/?= =?us-ascii?Q?6OFLJCrtxoKrKgdvgaHDtTJtmg2LuJLn+i0NUK9XsjbgGJFeWXZXj5pY/wx9?= =?us-ascii?Q?3V2EQZ0kyEhbEkfqTfxEnge+Pu5xXCcHsPBPE8iTq1kIgoYvV9JZXTJJ8nvo?= =?us-ascii?Q?AfaFbCno9tdSCDZog2FeIX+Tnso1KhgrOyEz6gG2aB1fH/0TyJE2/mQ3DEss?= =?us-ascii?Q?5y5odeLtYR4L/i3akxrVv6ua1tP4P1MHw57SbGCr4+IcypRSA+0YNUd1YLYU?= =?us-ascii?Q?JJuH4AFmMi2SDCZoX+OjC8OF032Sopgp6/ySzVSBjRmAljfvmKHVHFhxf/C7?= =?us-ascii?Q?Wc41a22vF9QM65KFgWqlBpj8vowyeS8IDkfGz/YfOtWdoIBUcw0yA/v/Hw82?= =?us-ascii?Q?FVO4Ccy0WRMiU3jh34hdixUQ/2ChwqW58baqml0U4/JhMq8oVHm70JS7sEX0?= =?us-ascii?Q?xTLaULFX/9Cv53JTez2J2mFeT1PVgNHhmgiZyIdF2mOU/e5ntM8SCBrx31IN?= =?us-ascii?Q?IjlxCuw5x5uftpTcynZWS6wUaC0RO9kru04csoXgWAFhSj0Q/QvsfT8H2xAf?= =?us-ascii?Q?JUgcPS/rtOUnyEucabseKv2wE9DZRDQ040YPzWCfaJFWatEWZTpmx0ilp56m?= =?us-ascii?Q?CY4+OP9WRho/vr9Txiy3XzqKK9u8AbIoEk3TzIrm9v978Y3ooIj039mbyujj?= =?us-ascii?Q?BKeorqZHVyMyvjZmb5u30FmyQReOCtrofJOFwfLxQ2SX9EUoYHIJzFBJud0D?= =?us-ascii?Q?jNbWtuYwzlSH5hwl2viFywduaPwAI1ctx5EZm26sf42jXN1agPaT1sYYhrOh?= =?us-ascii?Q?26/DzrJXa2/50bNbRbiG9VVhZPvCpiRaQGoI5i+jObPWnFEbCqAFBkPwgW81?= =?us-ascii?Q?OSz3dDgDMsIZN8wpNur728cHy3M8z0WnSmT9u+GAGxo1UDu/plJSO+CBTfn6?= =?us-ascii?Q?aywK2Ma77dgpOqPJrxlMPUP+HsRx19WPEwbmSWjkPWJa+SBbWEF3MaejbraW?= =?us-ascii?Q?77uHsueqFQhzju2Y5weqy2iQBcM28tN9N3QhM1DkicZWF73jsHKQpepJbF6e?= =?us-ascii?Q?puCbT4msBkm6MHoGPdDOTb5tP3hL0q/mBXG8M6wN+CAsY6laO/a4Qvde/Wsd?= =?us-ascii?Q?k2dftOq6d4ZSURy3QCih7S2FgKprzFoLDR/jsPwi78wMcwRUJbvM0I191MDF?= =?us-ascii?Q?OGyHnVn7Lx2t3hq6h75y6NqjGDyIC4+6B5vUNcV0QyWbVJE9NTn2C+8OTddA?= =?us-ascii?Q?7ll35Psri5fZXggf4MhmU=3D?= X-Forefront-PRVS: 0371762FE7 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(7370300001)(6009001)(39410400002)(39850400002)(39840400002)(39860400002)(39400400002)(39450400003)(25786009)(6506006)(33646002)(54906002)(7416002)(76176999)(478600001)(8676002)(50986999)(6486002)(47776003)(5660300001)(189998001)(42186005)(38730400002)(305945005)(72206003)(53416004)(66066001)(50466002)(48376002)(110136004)(118296001)(2950100002)(81166006)(5003940100001)(3846002)(6666003)(36756003)(53936002)(7350300001)(6512007)(2906002)(7736002)(6116002)(86362001)(4326008)(50226002); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR12MB1151; H:tlendack-t1.amdoffice.net; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; MWHPR12MB1151; 23:I0cnjFiM12FzMFQXMFrTCVcgBeyNl/gmY9USaHE5e?= =?us-ascii?Q?l1lixCYl79s5oJTzAEjQ5NlWVZ4VP969/LsKUKvmPtcQbPR9M5/0fuRAf289?= =?us-ascii?Q?0g/qvZ54EkA90k/qC1Z0tdYooEqZnJx5sk3vcmnczzmE0EC/7d5Y+Z1E6Clt?= =?us-ascii?Q?PeaWemwplJpdr7/UQRBGDNIc+HPe2uV7MyK87On1QgBX/psvHcxX5zactX7Y?= =?us-ascii?Q?kRZ9QQ0QhX5XfjC8s+2kzlNYAyRWt6w8JLYR7AZDpAg5w3KoxDeed3o5x6P1?= =?us-ascii?Q?vUmNYsnCNzo7/xYZkC0zyCnPw1U0PYK07xv7DpTCqo5BrNSZgI+iRn2wDxOI?= =?us-ascii?Q?yOZDuAy0kLHoAtUNckwLeP48xoqhkYt/nHoyEtVdhVN51b/deEQGERN7gL04?= =?us-ascii?Q?LZlXqxzL6U2WcgILqD1OSoRtyYJ/c/AjlK1DHoSF7MX0wUMUXe09FCJoNAr3?= =?us-ascii?Q?tVt+5+6rqrrjyC4L9OW//HXsk85fW0oVP4Gy4K7JfPD8cBmJWx/gYhPd156e?= =?us-ascii?Q?7lnIOHFCxwkF1ccWOKIO0gwMb+fN46Nnbcto/pgBCAI3f8oczI2432u4FzJr?= =?us-ascii?Q?+Tp4RHwi+7+s1D00YGSfc1+VQBdjQT7lxljGCice43+Rcvkd+fQD/txAsAxD?= =?us-ascii?Q?HrH5lH6BESxOQIFE7dOGMEA4ySEVUI2ZhA5ZbrGkooLf3CjlF5zYucAshhdO?= =?us-ascii?Q?DdcxlA0lMQQBOALctw5zQs82LMimrIj+IplhiXZemjJO3h92FJbFetXzIPAL?= =?us-ascii?Q?57mm6MVo6IzX0bz02zeLysuTf9JbaNW0iDv8mz/hwUqh+31LAG1B+rDHWapm?= =?us-ascii?Q?6jsdsYDeHzx95/mUarjscnlBUXsJcloKkMe/cg8x3Ngv5OFuNfNLQbGdk7Jo?= =?us-ascii?Q?NGnGg7cuW452eILfo2XKe+hFvqIjRjVfo7HRdbDS/OR04AoiUqHpWsuy0Db8?= =?us-ascii?Q?cxQSyp+CwXUH6X7yvL+Qy5yFN+mj4ZYzmUfsJ4qjDw4wegZ8X7bM67ylHn80?= =?us-ascii?Q?sQC8JTON1rNYLxR41YA3ydq1IWRDbcavZ9YmrFHPRfeLc2Bs1xZm0V/qBq7e?= =?us-ascii?Q?cZsQ/u3S5StXjTjbcAfUmiLpROgrNSVYAL3kZjPaXEz1UeRFnHThmt7s1qZD?= =?us-ascii?Q?F7xVplTaozZviM1f6Y+J7YA32kEKtv9JGPKrYBsH3mimTDB+WwwInvCEygbM?= =?us-ascii?Q?i6vrInStdR+ph4=3D?= X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; MWHPR12MB1151; 6:xXzo9wFmAiSQkfRzZbru1WbEAJFKE8sq94mHOiJhH6?= =?us-ascii?Q?owCw6XPKTV1pm4QoMwQTlKzsTyJd+OuFbIwAsp/CRIQvS1aHqX/dpUDyUqwT?=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I93L09TsFz6zHD15nf40Y0G0vUCYIN2ZJJp?= =?us-ascii?Q?lOciM1Gfx0wR+V18Mim7qF?= X-Microsoft-Exchange-Diagnostics: 1; MWHPR12MB1151; 5:Sy1TlNd5efQEnRNUaqfuf2A5o5NSMgumvcQCos0NhYDXxcCS+yxKi2nY0kdShMciFTCJuGR8nGcDB1h1gp+QYdddC6MCc3XCTDV1HJXn0/z+9/v8FKBv5VOz/Pt28Vd0+e4qe/fJhtfQ53UKczqswXIZodqVHZmQARoySGCYEDnnALxFDZJO3aSwSc4n9YFgfwoenIryshf504itAYwHU89THx0PQgZMeYz22nzupR3cANT8F8k+H7MqavOPQ3Cx+aft2urlTuD+s6FHutzBhjmwI9Cghe/YIEKFLMMMx1BbWMX9NGDXviW7TR/Z6rtx6w45WN4cDk60bmjX+MqRuPzW92HYX9At+7JzLC0Uesy/i1DGqrkzY/EwrAJIfXZo3fio7BRYESoIF6lg5uZkB1q8jEj3Vy/2QCAYXiJtlvwBySCELQGnaenEVNKA8juZoYkE3L2WLld3e/wjFTMVV+ylNmGSp3uPGmjRsWPxcBeigzLsTmpHTT5bx8AWvTGN; 24:AtczjzNLti7qgHGtQHP1JSlyrKtDs0nZH0BXCUXb1OUCW1Beehr5moxBR1IP8ceZhCIaJL69A4qyP0dLXhlsD+uvkoIor6VWjcjdG7S+O0s= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; MWHPR12MB1151; 7:0RZ8GOnW6rPhcX7/sPM0sgMTzCKOM6PuMdFUIxDHYyEvbAM7dx1w7CNHxAGJmZO1lO5B4B75ZZw6HbYEN1QzFXlxmnCgMkT/9EckwFYu8eX4zf1Yp7yPzrLCzdZyUBnpbYL0llvtFGoGNqKiHsGHDYfkgtRpv9QBhR2u5rkBRY9xcY/VXqIMnFq3kfODcEneynsciH8j4cj2/o/AD2DtYOtQ5oUOaWm3Ssm1Ajt2mu17ma15wofq3xJiDvsOCIF8ZP+N6WWqJw9FdRu/WfW0pzTh6t5RBE8G2dTFM6bZmkBsOKO2HZss8r7bswZzoECqZmzc0Q6DQ2jIKni4ATWHL55Fe7jIcWsTenXvlJgsdIayb6ZYD0Q7te9Y73aXhnTgyxmc3HCLM6cI1tRivbUF6lePnS3u3TCUqJUP5tPxDHPyda9i1GMbMD5VXZ99Z5KPu9NHfuMHMemhBAX/b8Rz6s2GcX3ecbK/MG+PhwyM5TJsg8LMMwXgsLBu8HPA3go6wJsjXjoCWNqSwJRRYs1kPf6nhNQUNiihcIGOUjqW8ALSwyFVHdSii/xJnPbgO8ML4dRJyhC00KJu1fDrWEJrj6/HVfjImCo8WaF89gjbNPJ9Pe2z8QdtT5vALtvm9hNIwEDWrd/5IMNxF8UXA4JkKvJ9XqOcXxa6pkr9/N213hfrfHoSxSvRZeAQrgaWpX5tyCrhz6x+XXnasQnlVMi8lxYPfBVmvEJIx3xCvhS75n8drNBlWuDiTON6c2gOhduI7P/9vTf6ahseTTmkZitoXmG1uh3f+vD2vCxKgIJwedg= X-Microsoft-Exchange-Diagnostics: 1; MWHPR12MB1151; 20:6u22Iv3frh698fivnFh2M/9islr2vsIyWgxpTMJ/KzDvguIutccGzS2PxUPwDi+vKa828bdQ8FrIMgYLdHhoxQoYcJcV+HKyHVmPRySvPCMDfe4QVy+RkTBLNjPIu+l3xd8rSkUfGccD0E/AS3oxNheDMjhPld5Rz07YWVtyBrqur5Y10d8LGvpCnXp/dlgTXBHld1x4zT23qSDcl5Mj8aU5HHbAxF8anJtfy2E1sy3QORnoTkxEu0ACgUhAHVbB X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jul 2017 21:11:30.2381 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR12MB1151 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add early_memremap() support to be able to specify encrypted and decrypted mappings with and without write-protection. The use of write-protection is necessary when encrypting data "in place". The write-protect attribute is considered cacheable for loads, but not stores. This implies that the hardware will never give the core a dirty line with this memtype. Reviewed-by: Borislav Petkov Signed-off-by: Tom Lendacky --- arch/x86/Kconfig | 4 ++++ arch/x86/include/asm/fixmap.h | 13 +++++++++++ arch/x86/include/asm/pgtable_types.h | 8 +++++++ arch/x86/mm/ioremap.c | 44 ++++++++++++++++++++++++++++++++++++ include/asm-generic/early_ioremap.h | 2 ++ mm/early_ioremap.c | 10 ++++++++ 6 files changed, 81 insertions(+) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index ba7b93d..8328bcb 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -1440,6 +1440,10 @@ config AMD_MEM_ENCRYPT_ACTIVE_BY_DEFAULT If set to N, then the encryption of system memory can be activated with the mem_encrypt=on command line option. +config ARCH_USE_MEMREMAP_PROT + def_bool y + depends on AMD_MEM_ENCRYPT + # Common NUMA Features config NUMA bool "Numa Memory Allocation and Scheduler Support" diff --git a/arch/x86/include/asm/fixmap.h b/arch/x86/include/asm/fixmap.h index d9ff226..dcd9fb5 100644 --- a/arch/x86/include/asm/fixmap.h +++ b/arch/x86/include/asm/fixmap.h @@ -164,6 +164,19 @@ static inline void __set_fixmap(enum fixed_addresses idx, */ #define FIXMAP_PAGE_NOCACHE PAGE_KERNEL_IO_NOCACHE +/* + * Early memremap routines used for in-place encryption. The mappings created + * by these routines are intended to be used as temporary mappings. + */ +void __init *early_memremap_encrypted(resource_size_t phys_addr, + unsigned long size); +void __init *early_memremap_encrypted_wp(resource_size_t phys_addr, + unsigned long size); +void __init *early_memremap_decrypted(resource_size_t phys_addr, + unsigned long size); +void __init *early_memremap_decrypted_wp(resource_size_t phys_addr, + unsigned long size); + #include #define __late_set_fixmap(idx, phys, flags) __set_fixmap(idx, phys, flags) diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h index de32ca3..32095af 100644 --- a/arch/x86/include/asm/pgtable_types.h +++ b/arch/x86/include/asm/pgtable_types.h @@ -161,6 +161,7 @@ enum page_cache_mode { #define _PAGE_CACHE_MASK (_PAGE_PAT | _PAGE_PCD | _PAGE_PWT) #define _PAGE_NOCACHE (cachemode2protval(_PAGE_CACHE_MODE_UC)) +#define _PAGE_CACHE_WP (cachemode2protval(_PAGE_CACHE_MODE_WP)) #define PAGE_NONE __pgprot(_PAGE_PROTNONE | _PAGE_ACCESSED) #define PAGE_SHARED __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | \ @@ -189,6 +190,7 @@ enum page_cache_mode { #define __PAGE_KERNEL_VVAR (__PAGE_KERNEL_RO | _PAGE_USER) #define __PAGE_KERNEL_LARGE (__PAGE_KERNEL | _PAGE_PSE) #define __PAGE_KERNEL_LARGE_EXEC (__PAGE_KERNEL_EXEC | _PAGE_PSE) +#define __PAGE_KERNEL_WP (__PAGE_KERNEL | _PAGE_CACHE_WP) #define __PAGE_KERNEL_IO (__PAGE_KERNEL) #define __PAGE_KERNEL_IO_NOCACHE (__PAGE_KERNEL_NOCACHE) @@ -202,6 +204,12 @@ enum page_cache_mode { #define _KERNPG_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED | \ _PAGE_DIRTY | _PAGE_ENC) +#define __PAGE_KERNEL_ENC (__PAGE_KERNEL | _PAGE_ENC) +#define __PAGE_KERNEL_ENC_WP (__PAGE_KERNEL_WP | _PAGE_ENC) + +#define __PAGE_KERNEL_NOENC (__PAGE_KERNEL) +#define __PAGE_KERNEL_NOENC_WP (__PAGE_KERNEL_WP) + #define PAGE_KERNEL __pgprot(__PAGE_KERNEL | _PAGE_ENC) #define PAGE_KERNEL_RO __pgprot(__PAGE_KERNEL_RO | _PAGE_ENC) #define PAGE_KERNEL_EXEC __pgprot(__PAGE_KERNEL_EXEC | _PAGE_ENC) diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c index 66ddf5e..570201b 100644 --- a/arch/x86/mm/ioremap.c +++ b/arch/x86/mm/ioremap.c @@ -417,6 +417,50 @@ void unxlate_dev_mem_ptr(phys_addr_t phys, void *addr) iounmap((void __iomem *)((unsigned long)addr & PAGE_MASK)); } +#ifdef CONFIG_ARCH_USE_MEMREMAP_PROT +/* Remap memory with encryption */ +void __init *early_memremap_encrypted(resource_size_t phys_addr, + unsigned long size) +{ + return early_memremap_prot(phys_addr, size, __PAGE_KERNEL_ENC); +} + +/* + * Remap memory with encryption and write-protected - cannot be called + * before pat_init() is called + */ +void __init *early_memremap_encrypted_wp(resource_size_t phys_addr, + unsigned long size) +{ + /* Be sure the write-protect PAT entry is set for write-protect */ + if (__pte2cachemode_tbl[_PAGE_CACHE_MODE_WP] != _PAGE_CACHE_MODE_WP) + return NULL; + + return early_memremap_prot(phys_addr, size, __PAGE_KERNEL_ENC_WP); +} + +/* Remap memory without encryption */ +void __init *early_memremap_decrypted(resource_size_t phys_addr, + unsigned long size) +{ + return early_memremap_prot(phys_addr, size, __PAGE_KERNEL_NOENC); +} + +/* + * Remap memory without encryption and write-protected - cannot be called + * before pat_init() is called + */ +void __init *early_memremap_decrypted_wp(resource_size_t phys_addr, + unsigned long size) +{ + /* Be sure the write-protect PAT entry is set for write-protect */ + if (__pte2cachemode_tbl[_PAGE_CACHE_MODE_WP] != _PAGE_CACHE_MODE_WP) + return NULL; + + return early_memremap_prot(phys_addr, size, __PAGE_KERNEL_NOENC_WP); +} +#endif /* CONFIG_ARCH_USE_MEMREMAP_PROT */ + static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __page_aligned_bss; static inline pmd_t * __init early_ioremap_pmd(unsigned long addr) diff --git a/include/asm-generic/early_ioremap.h b/include/asm-generic/early_ioremap.h index 734ad4d..2edef8d 100644 --- a/include/asm-generic/early_ioremap.h +++ b/include/asm-generic/early_ioremap.h @@ -13,6 +13,8 @@ extern void *early_memremap(resource_size_t phys_addr, unsigned long size); extern void *early_memremap_ro(resource_size_t phys_addr, unsigned long size); +extern void *early_memremap_prot(resource_size_t phys_addr, + unsigned long size, unsigned long prot_val); extern void early_iounmap(void __iomem *addr, unsigned long size); extern void early_memunmap(void *addr, unsigned long size); diff --git a/mm/early_ioremap.c b/mm/early_ioremap.c index 6d5717b..d7d30da 100644 --- a/mm/early_ioremap.c +++ b/mm/early_ioremap.c @@ -226,6 +226,16 @@ void __init early_iounmap(void __iomem *addr, unsigned long size) } #endif +#ifdef CONFIG_ARCH_USE_MEMREMAP_PROT +void __init * +early_memremap_prot(resource_size_t phys_addr, unsigned long size, + unsigned long prot_val) +{ + return (__force void *)__early_ioremap(phys_addr, size, + __pgprot(prot_val)); +} +#endif + #define MAX_MAP_CHUNK (NR_FIX_BTMAPS << PAGE_SHIFT) void __init copy_from_early_mem(void *dest, phys_addr_t src, unsigned long size)