Message ID | 1669138842-30100-1-git-send-email-mikelley@microsoft.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2353126wrr; Tue, 22 Nov 2022 09:46:51 -0800 (PST) X-Google-Smtp-Source: AA0mqf7L8IfkIDbun6d89BtGOicbhUF3/HHBpvEXYJHtSf70USSBVSCltn39044ZZ7QvLL8y63Gg X-Received: by 2002:a63:5544:0:b0:477:6fe2:c1d1 with SMTP id f4-20020a635544000000b004776fe2c1d1mr4841563pgm.444.1669139211392; Tue, 22 Nov 2022 09:46:51 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1669139211; cv=pass; d=google.com; s=arc-20160816; b=s90fGpWlIe1i48OobVuYLb4gGDars+OKjlkax0Y3g5n92LOpxY/BUas1VTJnOa/iE7 Iaa7UqnfRCMkjB5RrW6z3FTxpHI8kSTncYxbdeta6Pv89f3AkTsNxNnlLFhChWBmW49y vKe7rCvAoilfSjy5a5i3NhW+2vtFbXb5uILSFuD2yxzZfLyUzRpCo3KigTghMwp0GZLM HYVyG5Tzre5cJHCT26Htzg4dLE1YzWuZDxUWoFY/mwUMY+ECY/jQyRUFsKkRHRoA1sVc Ms98MoEc1E21FH3GzDdfZPldJeJ421F/hLKfMUt4SSpb3MlXi7KULy0gXJk9zi1HXC1F NOdA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from :dkim-signature; bh=GF+ZspVrzWWFsb4Y1zyj4l5I6i2RQL4kbglTZ1rx4SI=; b=WaJbXW744LtDzTL4yOD9DxwOokYmOSiV+0e3B2Vd+N2eq2sdeZheR1nM7gHKrIcfd/ ZS/pgpCmdRMyPU1M5sWQ4mn7W33zJv5fORnQB05Uz8wLyrbk/XAPIa33tt7gYUpQOJPM IE+mDUBZo/hO/NoQciy6zcSLRUC3hNJ/MFJLdjA7tpd4X2+irTtF4lUUVw2aUg86g101 VDeRKQzvSAlr9DnsPq5Mq3KaQorKwUeirhG1pOac2yi4V1SNeqHHC9AqX3SYbC+ESwgn vQ+a7ZlM8STZwlJk3VXCsGfx1CIPXRpCEjbYEfnZASLZVk/Vv8k/Z+lNg+b2fHGvElcD QoQg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector2 header.b=FofFUq2E; arc=pass (i=1 spf=pass spfdomain=microsoft.com dkim=pass dkdomain=microsoft.com dmarc=pass fromdomain=microsoft.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id pf11-20020a17090b1d8b00b002186dc355c2si15858705pjb.31.2022.11.22.09.46.37; Tue, 22 Nov 2022 09:46:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector2 header.b=FofFUq2E; arc=pass (i=1 spf=pass spfdomain=microsoft.com dkim=pass dkdomain=microsoft.com dmarc=pass fromdomain=microsoft.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233936AbiKVRm1 (ORCPT <rfc822;cjcooper78@gmail.com> + 99 others); Tue, 22 Nov 2022 12:42:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234342AbiKVRmY (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 22 Nov 2022 12:42:24 -0500 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2097.outbound.protection.outlook.com [40.107.243.97]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 397107C015; Tue, 22 Nov 2022 09:42:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DtaTvrg7N3QlvCNMoKWXrLKo2glPv7j/nOPvMvWJKHfsXIgoyIEBFLomSpl0ynPG6LAnp3AAZK0EM81c0inzg/N0rrx/K/1iz9IYYsdlP2QuTCkH3KHH/a3UsmcewzBWqJ2u3y7A/ml36GeIMYUXFznVcrsB7fKN8mje/+4t+4nwrwRPU6qWwZCpS3URLJ0dNqVbslpbhwnvzK8pqu/SszLCaQyKXhU5aI7Rw7izAJ49NE6yazJJI17TbdcsfAHdWBGkdAoLY7cS2Hvk4WpPcd8DqQFc8By2TiZCPfeExL/3ZNXj/9s1VDK5Fx+ZT+4wKhF+vzJGlaUoq+H0Yj5OUw== 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=GF+ZspVrzWWFsb4Y1zyj4l5I6i2RQL4kbglTZ1rx4SI=; b=UAYsMrNZEQRbs7c4KrvWPKeRtpmiQIEpHOPD5ORBHs20TS2ru0tQEe8xeqrGKe4hFtOXUhfbt8w9s3jiXzlSdDmmJulXHvrd2AtUzQvP5IoRoosUQajIHMGITgINS3dAwTw4jlxaPh7BLedrGV/W3eeu7trthdE0RR1J67fRPBMbWIYfky+jm/FUkpK65jzOiI6SwE9sH8vhAJA1Y4/BUlleJGI9VNo7uxO658bHnooCin6XDryEuEqEocg1K4umY+UschvSVSQN6nDhY4sFa6/oVOHdt5RcBmfXZ12vOkyR/DsO/rNBRX1ajikZwzH9o9kgd4X72K90DUu+GgcjAA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microsoft.com; dmarc=pass action=none header.from=microsoft.com; dkim=pass header.d=microsoft.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=GF+ZspVrzWWFsb4Y1zyj4l5I6i2RQL4kbglTZ1rx4SI=; b=FofFUq2EDKgfGL0rYX9BBVggmlC+W21LlgSeNHxa/gmdH5tSdaoOtlkY/FdYQ9IhaWuF9suyrlQ/2Gpd5X/j15Uqo/qiMc/mHoStQpxkTYIlh6bVBFvZDrY5LhUzwaEoThtssvK8og99DUsfahi+0/gEBXCQbAoLMNJc90OLzxU= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=microsoft.com; Received: from BN8PR21MB1361.namprd21.prod.outlook.com (2603:10b6:408:a7::23) by BL1PR21MB3379.namprd21.prod.outlook.com (2603:10b6:208:39f::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.2; Tue, 22 Nov 2022 17:42:09 +0000 Received: from BN8PR21MB1361.namprd21.prod.outlook.com ([fe80::a8a1:1319:9d94:77e7]) by BN8PR21MB1361.namprd21.prod.outlook.com ([fe80::a8a1:1319:9d94:77e7%4]) with mapi id 15.20.5880.002; Tue, 22 Nov 2022 17:42:07 +0000 From: Michael Kelley <mikelley@microsoft.com> To: hpa@zytor.com, kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, luto@kernel.org, peterz@infradead.org, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, lpieralisi@kernel.org, robh@kernel.org, kw@linux.com, bhelgaas@google.com, arnd@arndb.de, hch@infradead.org, m.szyprowski@samsung.com, robin.murphy@arm.com, thomas.lendacky@amd.com, brijesh.singh@amd.com, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, Tianyu.Lan@microsoft.com, kirill.shutemov@linux.intel.com, sathyanarayanan.kuppuswamy@linux.intel.com, ak@linux.intel.com, isaku.yamahata@intel.com, dan.j.williams@intel.com, jane.chu@oracle.com, seanjc@google.com, tony.luck@intel.com, x86@kernel.org, linux-kernel@vger.kernel.org, linux-hyperv@vger.kernel.org, netdev@vger.kernel.org, linux-pci@vger.kernel.org, linux-arch@vger.kernel.org, iommu@lists.linux.dev Cc: mikelley@microsoft.com Subject: [PATCH v4 1/1] x86/ioremap: Fix page aligned size calculation in __ioremap_caller() Date: Tue, 22 Nov 2022 09:40:42 -0800 Message-Id: <1669138842-30100-1-git-send-email-mikelley@microsoft.com> X-Mailer: git-send-email 1.8.3.1 Content-Type: text/plain X-ClientProxiedBy: MW4PR03CA0059.namprd03.prod.outlook.com (2603:10b6:303:8e::34) To BN8PR21MB1361.namprd21.prod.outlook.com (2603:10b6:408:a7::23) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8PR21MB1361:EE_|BL1PR21MB3379:EE_ X-MS-Office365-Filtering-Correlation-Id: 90f8cd86-1f20-42c6-016a-08daccb0e031 X-LD-Processed: 72f988bf-86f1-41af-91ab-2d7cd011db47,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nkIGM3HcKtGDPHNTsLgtvGhbqgUoacoB3gGQmojiIVL/KYw8M02OWdMjYzSIAKjy47/4dBO8OBtAPLU9gKcdIa9vvNTLj2NkHc8fU8oOCYoQi5sbS+ll1O+BxLIFhKns+hFiBhTOsr/DuS/1Oekle5sMgP7oV4qmTHzt91cvUwdh1f6O/meFbgzQ+Smazt7kfWTzYpJGgGEZmx/FzCuYrj5F8M3y9SAgxrTaFuEYCDIGf+hxQxDddVdAQ31w+Q2yaaxkJBjXEa96tzhhjga88GPJSR8uuDndOQevlvx27bOBkGNrBJdws2ntEryi8xmO0Y4AwoAWq1jq7RiUcpQ0OGS2Jms6AxOJ4FW2I5JTc7NTMDchHEVN0UOujerGMPe6gfs0ToblLwfSLbpJ7rw0GzXZObXNORaHHAuWPYQjxdGY1NlZ4fg3PN09EIwFh+4c7YyUB1oIJzqcohXf6emNrpuZClNF/Q1JZu52BFffxBA6kojPYXlaQU90Bx6lC7TGWYbIwlKn5qlr0zfL6nMBEI7Hxf3aAJM8Z/y4l577FG9WiccXsLAEkHWlzKI4uaIo2X7sUArDgzSQ9T8SL0VNPV8x5MiDTHDv9rKg8SKe2GQYh3sOUYIQsotI1+AeAATqn+KGioCxUIQsNMYku2CXePRW1QZrzxTutu3nMnkiLWxoMf96LU7RJEfQuCGUeYmnFbMRmYAdR+Y+dKxzTVcuyTtp6gskvKCj/eY/a2L+YpBhKtYqCDml2RUlI2tFbUuso6se55ZR/dZOZeszTknEFurrSwZNkprz0GIJSFqH3FI= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN8PR21MB1361.namprd21.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(366004)(136003)(376002)(39860400002)(396003)(346002)(451199015)(36756003)(82960400001)(921005)(2906002)(8936002)(8676002)(7416002)(7406005)(82950400001)(83380400001)(86362001)(38100700002)(316002)(10290500003)(186003)(2616005)(966005)(6486002)(4326008)(478600001)(38350700002)(5660300002)(66946007)(66556008)(66476007)(41300700001)(52116002)(107886003)(6666004)(26005)(6506007)(6512007);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: YBSQ1HoozY0JR5zS2HUPqHoWvcil5nIgsFKE3D1S6vSm3XsM0+pFew9ECGco0TDA2RPcX44zSEkSbH8RDlwuts2e5bgEKzTUoeKmQxih1w3BSfrFrMUBupbQyCcMEosGbyMkouxvEubXuQoDu4KvhiSLxVbmsCnO7nY7Wada/louJtoHMsPj/y+t8JAZeGAeWxDzec837seX0zOLLjNVtv8G+7mGkCUjePbIdIfXrQgB5zLUQ2FXjSRFQ90qV8nO9fw920ewUn0OCFCayMSiFn9Z+43BDWw4t22GIiUAG8VItbpXXklcQuhwJQW52nPQRa3sQuTQIDoxqdwUumE0dnPY+/Jm3Aynn3YSyJuGKo7jMknuh6xGJR1NSatjKvz2SzFUhe09OabAjnN4ZYWe0g10dYON3JCkApjdRTK1oxIICri7PRUeNzRBHdnp3nDC1F+CLavwsaNWfg/7VgpbgEvAufqZj7xZRizP8BDiewdNfx0YCdbyPUwRbVIcDHANQtAi6od/ZXL7mGnuCNakAPZX4wHCFEVa2CZyqLPRFaqOkc73hsIZluy4c0La6J7UIIPxCzmSCE/jmQuTYYNGlo6e6rUXRJB1RA+DBH26+sD2slFxqEU/c/r6epvMn/ztI5WE25VXyHo3JEYn6Crvki5X5ASn2RbTRBuLfwX+KL7gVZrhjp9Te8Qmmwa3Rr7QcgLUQS3+l8d2ozkrgMIj2NxZW0EheRDS8/aeANkcZGPovC/lEvLcGDQJYNTAfnuZ2pP1UmH3WshiBR3bZrSpB2MBTbfkC9/OKnZ3wOTgm2YSDKpWnYhMKJvKj+DQg+0HR9+Dp4xB3EG6GH5OLC2O8qvYYwKRQpRti322htu+pqymnLGG3/NkBAJPV2XPiD2jGqo2AshE64d7x2AjWXK/Dv/SkSN1gJn+ZpAf+nvj5b7S8t9lmR3dZ01l/iGluJxT8C3lYjiKCFMISlr7KyDbff8NPOidQcYwfct/DFqTRV0xXvBkgAefFAej3YeP57OfDJbEUixw7Zh7fl+Fy//6YMfcPMU9OVc/f3k7scKT/ECrPX5g/bLvNLVdM18LM0SPzOHGt/veskukf6OASwjfnQsLeB73vo6PrWHkmxwRD1CjudfTDXu8D+Em3jEVxhOcPCbJIlZVd4Cuvp+EoCDhWihvICP8gC5xeJR9ftoH1YrZ1qO5OLReqt8DuvqavlZ5QNLguUx6Hol7HcWn29luAGKAhTW8JuzXEFfI5u4GdnSlE+ElrlWF//W9EQo3pb16xw4js4XuvtyUenaK03q0JuJ0kikhGciAjiLXSVNUGkSThlHl5fQI0iFt/SY+MCyLULmH5cyFq8TlXE4lf45Krdhf5lchm0ji11E4J1fCU1thYeHfKrLaSs9zxXAOgH1++flKSPSoPbBPW1pd5VDmXaamE64XYjYbep7Wh1EOE8AasNjzPE9vSPenSOCcOmxlkpy12cuhhaflklNKtrSotyHKZGkgDLHvATesdo64gK1tugH1SVvIPBif+NySDHv06tX1szH2+1JzzW5HNj4D+wDw5UmJ+PRFYr9E/EQuwDDOR//ZcIJjdK/L3d71IKYE X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 90f8cd86-1f20-42c6-016a-08daccb0e031 X-MS-Exchange-CrossTenant-AuthSource: BN8PR21MB1361.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Nov 2022 17:42:07.7078 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 1NNRh5wz6j334e8LlGLGno8gkAOisPCfo96dyRiP9RHX0+zzVO1Mo2AUV8N0dEbHW5MbjlGhv3+Ln9RV3nD+iA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR21MB3379 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750219317999295952?= X-GMAIL-MSGID: =?utf-8?q?1750219317999295952?= |
Series |
[v4,1/1] x86/ioremap: Fix page aligned size calculation in __ioremap_caller()
|
|
Commit Message
Michael Kelley (LINUX)
Nov. 22, 2022, 5:40 p.m. UTC
Current code re-calculates the size after aligning the starting and ending physical addresses on a page boundary. But the re-calculation also embeds the masking of high order bits that exceed the size of the physical address space (via PHYSICAL_PAGE_MASK). If the masking removes any high order bits, the size calculation results in a huge value that is likely to immediately fail. Fix this by re-calculating the page-aligned size first. Then mask any high order bits using PHYSICAL_PAGE_MASK. Fixes: ffa71f33a820 ("x86, ioremap: Fix incorrect physical address handling in PAE mode") Acked-by: Dave Hansen <dave.hansen@linux.intel.com> Signed-off-by: Michael Kelley <mikelley@microsoft.com> --- This patch was previously Patch 1 of a larger series[1]. Breaking it out separately per discussion with Dave Hansen and Boris Petkov. [1] https://lore.kernel.org/linux-hyperv/1668624097-14884-1-git-send-email-mikelley@microsoft.com/ arch/x86/mm/ioremap.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
Comments
On Tue, Nov 22, 2022 at 09:40:42AM -0800, Michael Kelley wrote: > Current code re-calculates the size after aligning the starting and > ending physical addresses on a page boundary. But the re-calculation > also embeds the masking of high order bits that exceed the size of > the physical address space (via PHYSICAL_PAGE_MASK). If the masking > removes any high order bits, the size calculation results in a huge > value that is likely to immediately fail. > > Fix this by re-calculating the page-aligned size first. Then mask any > high order bits using PHYSICAL_PAGE_MASK. > > Fixes: ffa71f33a820 ("x86, ioremap: Fix incorrect physical address handling in PAE mode") > Acked-by: Dave Hansen <dave.hansen@linux.intel.com> > Signed-off-by: Michael Kelley <mikelley@microsoft.com> Reviewed-by: Wei Liu <wei.liu@kernel.org> > --- > > This patch was previously Patch 1 of a larger series[1]. Breaking > it out separately per discussion with Dave Hansen and Boris Petkov. > > [1] https://lore.kernel.org/linux-hyperv/1668624097-14884-1-git-send-email-mikelley@microsoft.com/ > > arch/x86/mm/ioremap.c | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > > diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c > index 78c5bc6..6453fba 100644 > --- a/arch/x86/mm/ioremap.c > +++ b/arch/x86/mm/ioremap.c > @@ -217,9 +217,15 @@ static void __ioremap_check_mem(resource_size_t addr, unsigned long size, > * Mappings have to be page-aligned > */ > offset = phys_addr & ~PAGE_MASK; > - phys_addr &= PHYSICAL_PAGE_MASK; > + phys_addr &= PAGE_MASK; > size = PAGE_ALIGN(last_addr+1) - phys_addr; > > + /* > + * Mask out any bits not part of the actual physical > + * address, like memory encryption bits. > + */ > + phys_addr &= PHYSICAL_PAGE_MASK; > + > retval = memtype_reserve(phys_addr, (u64)phys_addr + size, > pcm, &new_pcm); > if (retval) { > -- > 1.8.3.1 >
From: Wei Liu <wei.liu@kernel.org> Sent: Friday, November 25, 2022 7:20 AM > > On Tue, Nov 22, 2022 at 09:40:42AM -0800, Michael Kelley wrote: > > Current code re-calculates the size after aligning the starting and > > ending physical addresses on a page boundary. But the re-calculation > > also embeds the masking of high order bits that exceed the size of > > the physical address space (via PHYSICAL_PAGE_MASK). If the masking > > removes any high order bits, the size calculation results in a huge > > value that is likely to immediately fail. > > > > Fix this by re-calculating the page-aligned size first. Then mask any > > high order bits using PHYSICAL_PAGE_MASK. > > > > Fixes: ffa71f33a820 ("x86, ioremap: Fix incorrect physical address handling in PAE mode") > > Acked-by: Dave Hansen <dave.hansen@linux.intel.com> > > Signed-off-by: Michael Kelley <mikelley@microsoft.com> > > Reviewed-by: Wei Liu <wei.liu@kernel.org> > > > --- > > > > This patch was previously Patch 1 of a larger series[1]. Breaking > > it out separately per discussion with Dave Hansen and Boris Petkov. > > > > [1] https://lore.kernel.org/linux-hyperv/1668624097-14884-1-git-send-email-mikelley@microsoft.com/ > > Boris -- you were going to pick up this patch separately though urgent. Can you go ahead and do that? https://lore.kernel.org/linux-hyperv/Y3vo5drAFPQSsrF4@zn.tnic/ Michael > > arch/x86/mm/ioremap.c | 8 +++++++- > > 1 file changed, 7 insertions(+), 1 deletion(-) > > > > diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c > > index 78c5bc6..6453fba 100644 > > --- a/arch/x86/mm/ioremap.c > > +++ b/arch/x86/mm/ioremap.c > > @@ -217,9 +217,15 @@ static void __ioremap_check_mem(resource_size_t addr, unsigned long size, > > * Mappings have to be page-aligned > > */ > > offset = phys_addr & ~PAGE_MASK; > > - phys_addr &= PHYSICAL_PAGE_MASK; > > + phys_addr &= PAGE_MASK; > > size = PAGE_ALIGN(last_addr+1) - phys_addr; > > > > + /* > > + * Mask out any bits not part of the actual physical > > + * address, like memory encryption bits. > > + */ > > + phys_addr &= PHYSICAL_PAGE_MASK; > > + > > retval = memtype_reserve(phys_addr, (u64)phys_addr + size, > > pcm, &new_pcm); > > if (retval) { > > -- > > 1.8.3.1 > >
On Mon, Nov 28, 2022 at 02:43:28PM +0000, Michael Kelley (LINUX) wrote: > Boris -- you were going to pick up this patch separately > though urgent. Can you go ahead and do that? Did you not get the tip-bot notification? https://lore.kernel.org/r/166911713030.4906.16935727667401525991.tip-bot2@tip-bot2 you're on Cc there too.
From: Borislav Petkov <bp@alien8.de> Sent: Monday, November 28, 2022 7:46 AM > > On Mon, Nov 28, 2022 at 02:43:28PM +0000, Michael Kelley (LINUX) wrote: > > Boris -- you were going to pick up this patch separately > > though urgent. Can you go ahead and do that? > > Did you not get the tip-bot notification? > > https://lore.kernel.org/all/166911713030.4906.16935727667401525991.tip-bot2@tip-bot2/ > > you're on Cc there too. > Argh. My mistake. Thanks. Michael
diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c index 78c5bc6..6453fba 100644 --- a/arch/x86/mm/ioremap.c +++ b/arch/x86/mm/ioremap.c @@ -217,9 +217,15 @@ static void __ioremap_check_mem(resource_size_t addr, unsigned long size, * Mappings have to be page-aligned */ offset = phys_addr & ~PAGE_MASK; - phys_addr &= PHYSICAL_PAGE_MASK; + phys_addr &= PAGE_MASK; size = PAGE_ALIGN(last_addr+1) - phys_addr; + /* + * Mask out any bits not part of the actual physical + * address, like memory encryption bits. + */ + phys_addr &= PHYSICAL_PAGE_MASK; + retval = memtype_reserve(phys_addr, (u64)phys_addr + size, pcm, &new_pcm); if (retval) {