Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1025324rwb; Wed, 16 Nov 2022 10:52:04 -0800 (PST) X-Google-Smtp-Source: AA0mqf6fLR+ymVigqeWjFJKK6IrhicAqM1mfl6ezZlKaDuURRMTK/4Ks/GdztsG55VFgnPUiG8JP X-Received: by 2002:a17:907:8b0d:b0:78d:857d:b4a8 with SMTP id sz13-20020a1709078b0d00b0078d857db4a8mr17788387ejc.495.1668624724189; Wed, 16 Nov 2022 10:52:04 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1668624724; cv=pass; d=google.com; s=arc-20160816; b=ktrdMBIeaWo6BEatSipFFYUQb5joILFCdeLe6I7Zg64GS+zmQWwF48DHaw6nhZAz/r 2XAGFXYj9AFfkVSntdjF8ZUaP9q4dDuHeNgj98xe1ivT8IdWRU+BlJgq49WWuk5SM4X8 bB6GmKioFQP9aKkmZfBow6AiZMzUApcJRuz7ojneoJeSfYkwGutJsy4FI+ttAjeA7hc9 obzskeH5KehFEzw9jx3ZjqWDtEeq3tgr3teExvFTH+4TBw67NfrOUsLWuy9sEF3KThTk yHv57wdbBZLa6f5rsmDrr8n7vyztR4UsYebYYe1OLPrjN6ryhgDMR6AjOWSsGCOkpRLa lMTQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=a+yUY1oU7EZvlInJkWwCVnIM5lY35B5anu5GgTI054E=; b=pwJrtiRV0c0Qyfs/AzHjMUZnYjkHRqdj2IWut1ACx4lgAJvkJxipy0lBtEy7mEQPSJ 87dA95+t0fj/RLvZC9VFA3v34fTJmW7Ug3pDxOaLrjwm4vlqq8BmwUkDKBiEuP1pD8br O5On4wrUtIsfUAaHBENXZvn+lEGABVJV2CjGVVVVmruWot7mCAdHUFDYXSYJzHAN30Dm /yIHhs3pSYKuAPe9neIML5LXRDi8mnKGMmMktyqtjl1GjAsO4xFjjrtcIm3QiZ/SMlHL lJKsNl464UiIQ7PSRY1ttYfyULopD3BZge8XyCbGQZFe1F+Ywjm3tudubFR0LZ5o5WRr 3BBQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector2 header.b=LrqNuFRn; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a91-20020a509ee4000000b0045c9904fdafsi15014352edf.74.2022.11.16.10.51.42; Wed, 16 Nov 2022 10:52:04 -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=LrqNuFRn; 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 S233533AbiKPSn3 (ORCPT + 90 others); Wed, 16 Nov 2022 13:43:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234504AbiKPSmo (ORCPT ); Wed, 16 Nov 2022 13:42:44 -0500 Received: from na01-obe.outbound.protection.outlook.com (mail-westcentralusazon11022025.outbound.protection.outlook.com [40.93.200.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D866861755; Wed, 16 Nov 2022 10:42:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MKgPU8nQ8fsXO2B2bSUjbxDgEluMAJvF0GuI/e+4F5jAOqnmQqc4EtgQBnY7+uO4bA0dd2gs6kSAp2opeg87UOD1vqwTMMfi9Vs9qqQTTy7aAcmow6BvZ/RtXRM93B76y4ImxrUyIGRzt9Ub+QdJ5Nwg46Vymq99W6d63r7BXect5uIp2+9zVqLpFq0Isuqz+9lWvGvRr/cTy29u0YnzTyqj2prlU7TqJCn1Ab+KakuibCmo+OdOSWjRwc942vQ435XzLHySO4HyvlrqGdXxSntgG5ltIpcg+WiVRQX8BsgNRBMkgYG0xp67tuvCTqIR/Q3TD5biUWsLrqLuL07FCg== 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=a+yUY1oU7EZvlInJkWwCVnIM5lY35B5anu5GgTI054E=; b=DxLJgVvoQ4IgGW6LttwEbuDXYyt7UDjsH4Z38rTgRO/ouQgOgk3SylyQEPaCvP8ZgA8f0aHB+aaWSwHp8nqzkfGZCGVKR1Wzc02zJhA/dwIwH7yTABQw3MIN9DxTgfbbXeeYIvnAhCds87P4VvNJ6+Z88Yex33070/3cxJlTf5sdC7/inRQ7Nzwt52eK+bL1zmpAVFfD+lKfOZN6Xo+pqRM5JsyS+cH6CfVhztmNWYwZXwnsLQPiQm5ObJ9yF/yub2sFzyG5yg+YqR3wgQxuDbPQ8blnCeeFVeQZWFZPkw2wh8LICnJdhGnArZKGA+GgRsPMwQOCdiPpQMnfpwlseQ== 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=a+yUY1oU7EZvlInJkWwCVnIM5lY35B5anu5GgTI054E=; b=LrqNuFRnpZP7Txjrjwmv2qR8AAKb16jH7GI4wfpAltD4JaprMimNILaagFWkJAQ8TtfNqkc4Tli284m69eEDVIwmISQRMEoNVgM0bIDh3m68FB2moPX2y9ZsMjYWYfJaRAlyyjbKBUIzZWCzgie5SSACtc4BUZu8pYYyQSqSoI0= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=microsoft.com; Received: from DM6PR21MB1370.namprd21.prod.outlook.com (2603:10b6:5:16b::28) by DM4PR21MB3130.namprd21.prod.outlook.com (2603:10b6:8:63::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5857.5; Wed, 16 Nov 2022 18:42:30 +0000 Received: from DM6PR21MB1370.namprd21.prod.outlook.com ([fe80::c3e3:a6ef:232c:299b]) by DM6PR21MB1370.namprd21.prod.outlook.com ([fe80::c3e3:a6ef:232c:299b%9]) with mapi id 15.20.5857.005; Wed, 16 Nov 2022 18:42:30 +0000 From: Michael Kelley 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 v3 04/14] Drivers: hv: Explicitly request decrypted in vmap_pfn() calls Date: Wed, 16 Nov 2022 10:41:27 -0800 Message-Id: <1668624097-14884-5-git-send-email-mikelley@microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1668624097-14884-1-git-send-email-mikelley@microsoft.com> References: <1668624097-14884-1-git-send-email-mikelley@microsoft.com> Content-Type: text/plain X-ClientProxiedBy: MW4PR03CA0178.namprd03.prod.outlook.com (2603:10b6:303:8d::33) To DM6PR21MB1370.namprd21.prod.outlook.com (2603:10b6:5:16b::28) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR21MB1370:EE_|DM4PR21MB3130:EE_ X-MS-Office365-Filtering-Correlation-Id: 9f4319e7-e54d-48a1-27fe-08dac802513c 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: SmTLd8Ujf4b1B5T1ZdWkU3my2lXcFGd3k8PEvOXO4qvsWsKKAl+O4cg6zV2ilSJCgIqD5DOAE+Jf5cDQWmDCSl8NzaDyzTDnKSXWzjHn5mfbot8g1A5l/8p5nAF2eWQV46dFUeF8Tw6GtbMxZm0CgeshrOsV1mTf41Lx1fIMJhLyZJmvi4VUk4O4kmhQrdvWE1EKaeRDrKUUom5xtnjzOT9F5sjhV1Aovcm+yb8gPIfiW4moUmPc/79HwKy0sibERrT5DKIJyiTCZVQSJW8q5gCnRSHYq+bqlGgJY17WlAY0/XDn4PZvqceeo6ORO6Z6TzCYd++MBEVCRTXPRrbq9I6rtNKRmHDzPMu5QDQbEnu2S2ANAS0Ve3d//tt4Eq+fJi/+SIiGl08Tj7UvNMr2SWMW4eVLbyJy0FXtlIRaVIXWwLZfeGPKXtCCI8lKqFJbwkG4aox7cJc8UflUHwps+AraDrYvCYe2mRM+ZOGzMBRupVyttbCp62WzDPGfpSOrJ+MnXKcNwsHzGLmKQvkgI7Xd2G52/d2CrIt12v6B+j5jGyGkXlHvcAaZeeftFLTJAT86WJmV2yHppslB3ZSKl6PBKyeU66CnWqgoC7npngMuJwLWKMHJdSmm9JWqjc/3QqnflSWOwFLsVRAdcRutZBMo6oMS1YV3dTu4iAQJIZMHzyVDFB+iK2ZImDH/cHdzS9SwqDGW3sOXhsfMG/+JUwoklGq8UZPHye2MJRAwC9XgXu8PwzCRHZ0D6CsjLhmuurwuwTkvHvkW4tXVBoaTYt2lkvOeuyl+GO/Lj2C5UGNFO7R1yDTE3V+9DJoPM8Kj04C89Pvn7f0Dw44SMfqiwA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR21MB1370.namprd21.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(376002)(346002)(366004)(396003)(39860400002)(136003)(451199015)(4326008)(5660300002)(8676002)(8936002)(7406005)(7416002)(2906002)(66556008)(66946007)(66476007)(41300700001)(107886003)(82950400001)(52116002)(2616005)(6666004)(82960400001)(6512007)(26005)(36756003)(10290500003)(186003)(83380400001)(316002)(6486002)(478600001)(38100700002)(38350700002)(6506007)(86362001)(921005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?PG3MD3G8R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ascii?Q?B46gWN3LKsjv+XaMFN8+BPnsOg+yF8zLES09KGrpj5tV87yOQt8+KiHhNcA+?= =?us-ascii?Q?kUUw/fkzaoueVCpjPgLKcx24UuB40jUo9dSVLVRU96FLPC6rxgTvTtJD6Wx9?= =?us-ascii?Q?SwR1BJ3qzeQ9NpSgFYOh4zpNi6/TF9RumV2+YDjcru2DqAMitkVxYa5bMEBV?= =?us-ascii?Q?IK9C3Ze4CCNfuEMka+CPe6KKw/g9z1ZEF3MfxLzLhznlc2BAkeXe0ztAf1aK?= =?us-ascii?Q?a2EKhTeJ+uod9p2YMowHRhtFUK5NhH7aLUdhgu9zAJbJl3CjF2rGjo0nP0R5?= =?us-ascii?Q?BC6DsCHrXp+UN+pbK1/WAxtENUjfdiETHQhXOTXsF1h/tuiqXg+um8ZEkNJb?= =?us-ascii?Q?XHz/AngM2UR6eEwpbJb8OElgu/KXcf7+8N3gtyQjVFfczfPo9KrtcFc3N51K?= =?us-ascii?Q?XgBWEK8GliyxtYcGupTeg5xcsBio5aWPOgUvF/tdGAaJhLn5/xqH7fs+G+E/?= =?us-ascii?Q?OxZSBeOberPL6yMSh8yhmNkeeDCeBTevLwAU37ME8OYj0kuwkXX9HN2IxGwV?= =?us-ascii?Q?7h6Xe9fZTNcmPGtlU/3B/KbKM7HGZ9dvC2+sprV6k72Jb9euP4ShtnnYlA0c?= =?us-ascii?Q?DjG/I9tz+LCeMUZDrB+KfNRHOlmtIkZwGcJ6DpW8BbjqRjpI+GMe1cgGqmCS?= =?us-ascii?Q?KP172Bk1AYtpnAObIAzI2UiZcBiMtxKpUic6/yiZ?= X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9f4319e7-e54d-48a1-27fe-08dac802513c X-MS-Exchange-CrossTenant-AuthSource: DM6PR21MB1370.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Nov 2022 18:42:30.6451 (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: iKLxOtXT+tO7L9c87+7uTujAbThWxkMQ2C7cIsfihItD5aF6+j8DboEr/Q1zQeN+QmUW++gFN0dxkV1PyvVXGw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR21MB3130 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,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: X-Mailing-List: linux-kernel@vger.kernel.org In preparation for a subsequent patch, update vmap_pfn() calls to explicitly request that the mapping be for decrypted access to the memory. There's no change in functionality since the PFNs passed to vmap_pfn() are above the shared_gpa_boundary, implicitly producing a decrypted mapping. But explicitly requesting decrypted allows the code to work before and after a subsequent patch that will cause vmap_pfn() to mask the PFNs to being below the shared_gpa_boundary. While another subsesquent patch removes the vmap_pfn() calls entirely, this temporary tweak avoids the need for a large patch that makes all the changes at once. Signed-off-by: Michael Kelley Reviewed-by: Tianyu Lan --- arch/x86/hyperv/ivm.c | 2 +- drivers/hv/ring_buffer.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/hyperv/ivm.c b/arch/x86/hyperv/ivm.c index f33c67e..e8be4c2 100644 --- a/arch/x86/hyperv/ivm.c +++ b/arch/x86/hyperv/ivm.c @@ -343,7 +343,7 @@ void *hv_map_memory(void *addr, unsigned long size) pfns[i] = vmalloc_to_pfn(addr + i * PAGE_SIZE) + (ms_hyperv.shared_gpa_boundary >> PAGE_SHIFT); - vaddr = vmap_pfn(pfns, size / PAGE_SIZE, PAGE_KERNEL_IO); + vaddr = vmap_pfn(pfns, size / PAGE_SIZE, pgprot_decrypted(PAGE_KERNEL_NOENC)); kfree(pfns); return vaddr; diff --git a/drivers/hv/ring_buffer.c b/drivers/hv/ring_buffer.c index 59a4aa8..b4a91b1 100644 --- a/drivers/hv/ring_buffer.c +++ b/drivers/hv/ring_buffer.c @@ -211,7 +211,7 @@ int hv_ringbuffer_init(struct hv_ring_buffer_info *ring_info, ring_info->ring_buffer = (struct hv_ring_buffer *) vmap_pfn(pfns_wraparound, page_cnt * 2 - 1, - PAGE_KERNEL); + pgprot_decrypted(PAGE_KERNEL_NOENC)); kfree(pfns_wraparound); if (!ring_info->ring_buffer) -- 1.8.3.1