From patchwork Tue Jul 27 22:26:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Lendacky X-Patchwork-Id: 12404463 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A2338C43216 for ; Tue, 27 Jul 2021 22:27:13 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 734F160F6E for ; Tue, 27 Jul 2021 22:27:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 734F160F6E Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id ED3B36E802; Tue, 27 Jul 2021 22:27:12 +0000 (UTC) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2059.outbound.protection.outlook.com [40.107.223.59]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5D4766E802; Tue, 27 Jul 2021 22:27:11 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ai1UQTOIwf/KXrk+Ua5QCpoK4sY+emn8rG4THDjxdDvb3tyGUee31bCK2gJVeZMwX9PJqbQO4xHhqVTPqzDxBcCfcFn1QZVBFWGCxk2d1SaUb+kDwGVIW0LWEcBm2aFM0FATjFdjZqiI/wp37tbC1qU+XAElaajd1fiAG6qJ4/DmXvtjeown9iMK/3UtVomXvBsPcl6IzFio1LbjQz05IMVYBKjue5IkWnI3GOdT/a2kkqzEPOXfhotGUi2f96HHGFBi+56hukoASOxUJp1EFuCxfHdpRN+NXxRJiIM+8uFPCLVHxZzHUC6DzNL1M8qDCrhqoHcipHPIK9Lqi3aBFQ== 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-SenderADCheck; bh=7rBYhxwUFw8fcyx0fuQ206NyJJMRUZngGck8eTaViKU=; b=E5ej607xPfpPPO51/1pKN4g4pWiGRiPct/UxaqpHZu0mb6H0YsGT8w/xrtWT4cESCV9TME9SgBJQaeb2Pck4s2Rx0JK1B+PgdLbHMP3kMN9eCG3iLjIoOPdHPX3uhDCCWVc5CL+4as2UnS4ROFViSzQQiX0eSALUeoJTImqNurImO2RZqHkyFyI6jeho0geNnd98Sdaj+5f1AL5ulxpEgNPm9C4CPmgxx9ssQAEu6oCLVH88skMVYbJ5UCttU4hhg1vmBG/Rn4Z85/rT3eVMUTksMCxNgLOsL4qci50kERoc9IzwIsNc05Kg9JqjsnRLUzMtgnzD9DIlgCMqu/84wQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7rBYhxwUFw8fcyx0fuQ206NyJJMRUZngGck8eTaViKU=; b=4JNGme4WyKZeEVBRd4wuMKiOM+j1chWIXrWAkn2h5i0AO4O3/ld8WZcWtC62e+Ur6i92qFCUdop52l7pgf8UrU02IpRwjqCVwpxTNqCX4aFWOi5tzovzlF9JIzrJ070DY9d/LHxvhAbnTCLsAtFHqC1QT4zAn88AHtFlx0YeEW0= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=amd.com; Received: from DM4PR12MB5229.namprd12.prod.outlook.com (2603:10b6:5:398::12) by DM4PR12MB5357.namprd12.prod.outlook.com (2603:10b6:5:39b::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.18; Tue, 27 Jul 2021 22:27:09 +0000 Received: from DM4PR12MB5229.namprd12.prod.outlook.com ([fe80::73:2581:970b:3208]) by DM4PR12MB5229.namprd12.prod.outlook.com ([fe80::73:2581:970b:3208%3]) with mapi id 15.20.4352.031; Tue, 27 Jul 2021 22:27:09 +0000 From: Tom Lendacky To: linux-kernel@vger.kernel.org, x86@kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, iommu@lists.linux-foundation.org, kvm@vger.kernel.org, linux-efi@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-graphics-maintainer@vmware.com, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, kexec@lists.infradead.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 03/11] powerpc/pseries/svm: Add a powerpc version of prot_guest_has() Date: Tue, 27 Jul 2021 17:26:06 -0500 Message-Id: <19f7eefdc98e091fbfae9db0db575422f18f0543.1627424774.git.thomas.lendacky@amd.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-ClientProxiedBy: SA9PR13CA0001.namprd13.prod.outlook.com (2603:10b6:806:21::6) To DM4PR12MB5229.namprd12.prod.outlook.com (2603:10b6:5:398::12) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from tlendack-t1.amd.com (165.204.77.1) by SA9PR13CA0001.namprd13.prod.outlook.com (2603:10b6:806:21::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.7 via Frontend Transport; Tue, 27 Jul 2021 22:27:07 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9f293814-4a4b-4e53-7f3f-08d9514dac4c X-MS-TrafficTypeDiagnostic: DM4PR12MB5357: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1417; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xAbHVrjzIYpjzq53UexUtPS4Mqj3/v17JOVKeJ1nk0z7aeEtELuC1CKLeBIsW95qO88RTTuIcs4aebvcZc3B6nCzcSN82Npu/UH69rG/Pxlcwc4HDdX48/BTJ7QNGhs/gmSzWpqbhTo/5aIks8fOBv0UJG/ImnMdbIbDsDURfgkx67Ya7Y7KJXfAqt1j1kUnTwP+u6n4CyBybiwQyOcwIJUSab4NSCucsPZMVl8Mp6Rfe0puH5nZnyXVJWiedHxGFNA30PccDFQ2NaLWk//PkDiCS5bPdIKNVG/ijQstBKnbNSPoLxBkXU79qF3szQeKYL0wGbZpwgtqiwdeZ14Ri3+kmd6VdY3feLm6NojfUxE0QrY/qz6u5lWgTfnMgpGVWbBrVxikvYEspGmwsW87T/yUkvly2qy19LKaIfwti0zvK/3XBS7cwhmnaDAYYVopkQPOip9kdII/WNIOQySYZ6kX4FcR1o7NVGElNXbyrECmxbJ9bC7/I0tuJ+ubXfQNo1Ro8ZoE3GCU4GpisgiWlnWZyWWO2E/N5SzwMRXIJLrYlYAc5lIx/BXlLpzMLNkipOp3JUKS3oXinyVifjuagAmf4hzkcxPDuSuzf9dMj9mfDoO0SXpWqhruUglfvh4+uup1VFXrbLOOaB560m+iEcvZykIcqryZCirgkV2dbiYOuW4L/eN44QUQHYey9ZCebmCC1JYSEXWCIcQB1YU5OQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM4PR12MB5229.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(39860400002)(366004)(346002)(376002)(136003)(5660300002)(36756003)(54906003)(956004)(66556008)(4326008)(316002)(86362001)(8676002)(921005)(2616005)(66946007)(38350700002)(38100700002)(66476007)(7696005)(2906002)(6486002)(7416002)(478600001)(26005)(52116002)(8936002)(186003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: kc7iz37gigN3u+7RGOhMMt7PioywRpKQ+A+3saV+wOhLSSKgZDhPLONaxLer+tbc4SMj4dV6uHS6XyQwSM1Lh7VzGU3j6YnLCVUeqSqdREewhTgUyIsjaGVa7IZskbey1kKo81/fw4bKE5fDpGUnqw/1Ryodw2FHScckh0cajaepUI518bHjFJiH8Nh5GR8QOEQYzGwdeyHbfscZEqvG0rbSmmUTzOocsZxNRkfWzu0Td9ELiu8lTRZaYclf8NAd9/XJctPbxW2niGR8/tJf6ca8+QIw9Wr41E42VrddgyZ37mVPyELznu+YVPH65U7E1LhAcq9Ag9feNiqYxYRWnrXc+DnLMUPnzI2Ac4EC1QkzKEe9CKg9/0XKT2BIPINlqaUq1MNadW7U5MqobXx9JrkccwyAl2nR7ReEM5gOK9G8KBltrwNXLbQOQbdsVuLtU01dvC6/INfwHk7dNk74E2EyjcPuUJ8KbedVun5IqVFAxZaVrVCYEBGgeM/3TyqO6lUapt2ZB6Nx37HEbhgw6kPrCGpx8rXdk4KVD36lx231hPbzzebz3JU3FM7z+y75QRV2xImlBb0QMWJcw6oGMueZ5oUXCJGtDwhCKuMfjB3/Pulbp3xZYvwdxRX+7XeMcQE5vwhEYxjjGEITuORZqMzs/f1sYn4rdcsltu0iQQwRuTsw1SUJVixwluMUzsyicwxIprUbhKerbjQEL4gm3V+PLDHVl1dBGeC3wLu0UlxjNq4hXWvZCQFNCGWztVGRiW+iL4CDEOCXyoKY8d2R5wU6EHcQBQgegb7itpVKY0dClL8oKNlS5w7OonkK35K2smdue+uAKO1mSVyXBroN51AAWADf4WS46pQgBrx0fcTY+hXhEJZ/CkpwMO3PgkpTalCVjL16H8hUiceiOLyGDdNcZ/b3B9yg+YjhmCX9Wk5ZMetfAOIlf4cMHYmzJ2Vg51hWnGOq3NzwMxf2pHlgr745Gut+mb8E+sFo7OdOZ94KvcZ4xS0gNsUR2xfyWSOni8FRE5Bp9WP/KGlKrb7LhE8C+nD6lZom3hxiOeUMKnP9z8Do0MBSdKdJKkwYdfZP/hP1bf55Mkxiyf0HgKa5oiU0RhH9SXrh79Fic+ouRc+0iOpq2K1w+iELD1u/KH2zBTsGpgR84ATwMfXVS/wm6KNMDr6y3AeyrvS2KfGPJXla0QZrme6/D8OTm3NQDy5qYX/ps5t/4xwjcGEAORb9oSKU4J0ULDIsiMIFj8Okkh+RozTDg5pqkMGcq7Mr81kqAxKQFcZwzVXbO1CwaWHLG+r+RshD+d0suNgfuqYXpX1x7N+gKLc0jz+QVTd0376Z X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9f293814-4a4b-4e53-7f3f-08d9514dac4c X-MS-Exchange-CrossTenant-AuthSource: DM4PR12MB5229.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jul 2021 22:27:09.6792 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: j3g9RhCcbhfP0KRAR+GITdr3ah14k0zwHJB6A4wX1eUIvHbQ1wBo7wlIiqoOaJZqZEByf2FPZxawQyr3ZydedA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5357 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sathyanarayanan Kuppuswamy , Andi Kleen , Tianyu Lan , Michael Ellerman , Joerg Roedel , Borislav Petkov , Brijesh Singh , Paul Mackerras Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Introduce a powerpc version of the prot_guest_has() function. This will be used to replace the powerpc mem_encrypt_active() implementation, so the implementation will initially only support the PATTR_MEM_ENCRYPT attribute. Cc: Michael Ellerman Cc: Benjamin Herrenschmidt Cc: Paul Mackerras Signed-off-by: Tom Lendacky --- arch/powerpc/include/asm/protected_guest.h | 30 ++++++++++++++++++++++ arch/powerpc/platforms/pseries/Kconfig | 1 + 2 files changed, 31 insertions(+) create mode 100644 arch/powerpc/include/asm/protected_guest.h diff --git a/arch/powerpc/include/asm/protected_guest.h b/arch/powerpc/include/asm/protected_guest.h new file mode 100644 index 000000000000..ce55c2c7e534 --- /dev/null +++ b/arch/powerpc/include/asm/protected_guest.h @@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Protected Guest (and Host) Capability checks + * + * Copyright (C) 2021 Advanced Micro Devices, Inc. + * + * Author: Tom Lendacky + */ + +#ifndef _POWERPC_PROTECTED_GUEST_H +#define _POWERPC_PROTECTED_GUEST_H + +#include + +#ifndef __ASSEMBLY__ + +static inline bool prot_guest_has(unsigned int attr) +{ + switch (attr) { + case PATTR_MEM_ENCRYPT: + return is_secure_guest(); + + default: + return false; + } +} + +#endif /* __ASSEMBLY__ */ + +#endif /* _POWERPC_PROTECTED_GUEST_H */ diff --git a/arch/powerpc/platforms/pseries/Kconfig b/arch/powerpc/platforms/pseries/Kconfig index 5e037df2a3a1..8ce5417d6feb 100644 --- a/arch/powerpc/platforms/pseries/Kconfig +++ b/arch/powerpc/platforms/pseries/Kconfig @@ -159,6 +159,7 @@ config PPC_SVM select SWIOTLB select ARCH_HAS_MEM_ENCRYPT select ARCH_HAS_FORCE_DMA_UNENCRYPTED + select ARCH_HAS_PROTECTED_GUEST help There are certain POWER platforms which support secure guests using the Protected Execution Facility, with the help of an Ultravisor